Tips of Linux C programming
Linux  /  houtizong 发布于 3年前   96
struct list_head { struct list_head *next, *prev;};#define LIST_HEAD_INIT(name) { &(name), &(name) }
struct user_t { data domain; list_head * node;};struct user_t g_user_list;LIST_HEAD_INIT(&g_user_list);
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)#define container_of(ptr, type, member) ({ const typeof(((type *)0)->member) * __mptr = (ptr); (type *)((char *)__mptr - offsetof(type, member)); })struct user_t* next = container_of(g_user_list->next->node, struct user_t, node);
likely/unlikely。#define likely(x) __builtin_expect(!!(x), 1)#define unlikely(x) __builtin_expect(!!(x), 0)long __builtin_expect (long EXP, long C)
__asm__ __volatile__( " lock ;n" " addl %1,%0 ;n" : "=m" (my_var) //output : "ir" (my_int), "m" (my_var) //input : //modify /* no clobber-list */ );
struct line { int length; char contents[0]; };struct line *thisline = (struct line *)malloc (sizeof (struct line) + this_length);thisline->length = this_length;
http://www.ibm.com/developerworks/cn/linux/kernel/l-chain/index.htmlhttp://kernelnewbies.org/FAQ/LikelyUnlikelyhttp://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.htmlhttp://gcc.gnu.org/onlinedocs/gcc/Zero-Length.htmlhttp://zh.wikipedia.org/wiki/%E6%9D%A1%E4%BB%B6%E8%BF%90%E7%AE%97%E7%AC%A6
请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成
网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];
文章归档
文章标签
友情链接