todolist and pattern...

This commit is contained in:
gatieme
2017-04-13 11:39:28 +08:00
parent 227af86354
commit 97f83e4e11
5 changed files with 74 additions and 8 deletions
+7 -1
View File
@@ -24,5 +24,11 @@ LDD-LinuxDeviceDrivers
#3 TODOLIST--目前在完成的工作
-------
| 任务 | 描述 |
|:----:|:----:|
| study/debug | 内核调试工具集锦, 包括debugfs, trace, gdb, systemtap 的介绍和使用 |
| study/pattern | 内核设计的奇技淫巧, 介绍内核中使用的一些高级语法技巧和设计思路 |
| study/kernel/data_structure | 介绍内核中提供的数据结构的用法 |
@@ -1,5 +1,5 @@
CFLAGS = -std=gnu99
target=not_power_of_2 zero
target=not_power_of_2 zero null
all:$(target)
@@ -12,19 +12,19 @@ zero : build_bug_on_zero.o
@echo "BUILD_BUG_ON_ZERO..."
SCClient : SCClient.o
null : build_bug_on_null.o
$(CC) $^ -o $@ $(LDFLAGS) -lpthread
@echo "简单的模拟高并发的客户端..."
@echo "BUILD_BUG_ON_NULL..."
SCMClient : SCMClient.o
invalid : build_bug_on_invalid.o
$(CC) $^ -o $@ $(LDFLAGS) -lpthread
@echo "带线程锁的模拟高并发的客户端..."
@echo "BUILD_BUG_ON_INVALID..."
%.o : %.c
-$(CC) -c $^ -o $@ $(CFLAGS) $(DEFINES)
$(CC) -c $^ -o $@ $(CFLAGS) $(DEFINES)
%.o : %.cpp
-$(CXX) -c $^ -o $@ $(CFLAGS) $(DEFINES)
$(CXX) -c $^ -o $@ $(CFLAGS) $(DEFINES)
clean :
rm -rf *.o
@@ -0,0 +1,34 @@
/*************************************************************************
> File Name: build_bug_on_invalid.c
> Author: GatieMe
> Mail: gatieme@163.com
> Created Time: Thu 13 Apr 2017 11:26:18 AM CST
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "bug.h"
# define __force __attribute__((force))
#ifndef BUILD_BUG_ON_INVALID
/*
* BUILD_BUG_ON_INVALID() permits the compiler to check the validity of the
* expression but avoids the generation of any code, even if that expression
* has side-effects.
*/
#define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
#endif
#define NUM 12_$
int main(int argc, char *argv[])
{
BUILD_BUG_ON_INVALID(NUM);
return EXIT_SUCCESS;
}
@@ -0,0 +1,26 @@
/*************************************************************************
> File Name: build_bug_on_null.c
> Author: GatieMe
> Mail: gatieme@163.com
> Created Time: Thu 13 Apr 2017 11:20:31 AM CST
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "bug.h"
#ifndef BUILD_BUG_ON_NULL
#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
#endif
#define POINT !(NULL)
int main(int argc, char *argv[])
{
BUILD_BUG_ON_NULL(POINT);
return EXIT_SUCCESS;
}
Binary file not shown.