摘要: Let's take a look at a group of codes:#undef PDEBUG /* undef it, just in case */#ifdef SCULL_DEBUG# ifdef __KERNEL__ /* This one if debugging is on, and kernel space */# define PDEBUG(fmt, args...) printk( KERN_DEBUG "scull: " fmt, ## args)# else /* This one for user space */... 阅读全文
posted @ 2013-07-07 13:42 &Flare 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 先看下面一段代码,typedef struct CLIF_option_struct CLIF_option;struct CLIF_option_struct { const char *short_opt; const char *long_opt; const char *arg_name; const char *help_string; int (*function) (CLIF_option *optn, char *arg); void *data; int (*function_p... 阅读全文
posted @ 2013-05-21 22:41 &Flare 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 我们先来看一段shell脚本,[ $# -lt 2 ] && { echo "Usage: $0 target store_dir" >&2 exit 2}这段代码真的很精简,专业而成熟;其中包含的知识点有if条件,&&技巧,{}的块语块作用,重定向; 阅读全文
posted @ 2013-05-13 15:11 &Flare 阅读(323) 评论(0) 推荐(0) 编辑
摘要: 刚阅读源代码,发现关于内存对齐的宏,越发的觉得自己该补一补数学知识了#define ALIGN_C(SIZE, boundary) \ (((SIZE) + (boundary) - 1) & ~((boundary) - 1))这个宏的作用是,将分配的SIZE大小的内存,按boundary对齐 阅读全文
posted @ 2012-10-17 19:29 &Flare 阅读(346) 评论(0) 推荐(0) 编辑
摘要: APUE, Advanced Programming in the Unix Environment, is the most famous book for learning Linux or Unix-like programming.And I will study APUE in Linux/Ubuntu 12.04 LTS. Suppose your current working directory is $HOME(on my machine, HOME=/home/rex),Follow these steps,1. The source codes on the book c 阅读全文
posted @ 2012-10-07 23:31 &Flare 阅读(459) 评论(0) 推荐(0) 编辑