Skip to content

Instantly share code, notes, and snippets.

@afcidk
afcidk / Makefile
Last active May 10, 2025 15:13
A simple kernel module to show why mutex locks matters.
CONFIG_MODULE_SIG = n
TARGET_MODULE := test_mutex
obj-m := $(TARGET_MODULE).o
ccflags-y := -std=gnu99 -Wno-declaration-after-statement
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
all: client
@afcidk
afcidk / Makefile
Last active March 14, 2019 06:17
Simple kernel module to test speed of fp and int operation
PWD := $(shell pwd)
KDIR = /usr/src/linux-headers-$(shell uname -r)/
MODULE_NAME = floating
obj-m := $(MODULE_NAME).o
ccflags-y := -std=gnu99 -Wno-declaration-after-statement -mhard-float
all: clean integer_ver float_ver
gnuplot plot.gp
@afcidk
afcidk / extension_alias.c
Created March 12, 2019 15:45
Sample code of gnu c extension alias
// Reference: https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html
#include <stdio.h>
extern void func(void);
void print_hi(void) {
printf("hello~\n");
}
@afcidk
afcidk / Makefile
Created February 25, 2019 14:30
Simple code for checking the speed difference between function call and macro
CC = gcc
SIZE = 100000
all: macro function
macro: base.c
$(CC) -o macro base.c -DMACRO -g -DNAME=\"macro.log\"
function: base.c
$(CC) -o function base.c -g -DNAME=\"func.log\"
void wrong_change(int number) {
int num;
num = number;
num++;
}
#include<stdio.h>
void wrong_change(int);
void correct_change(int*);
int main() {
int number = 5;
printf("the number now is : %d\n",number);