04 2014 档案
摘要:网上很多关于EPOLL的介绍,或者翻译man手册,或者找一些国外的文章,还有一些很好得心得分享。但是看完总有一种模糊的感觉,尤其是关于 ET LT 两种模式,今天自己做一些例子仔细体会下。一:概念 边沿触发(edge triggered),就是在事务的两个状态交替的边沿触发,对socket来讲就是...
阅读全文
摘要:Python调用C,主要是依靠Python的ctypes调用动态链接库返回“简单类型”C代码:intmultiply(int num1, int num2){ return num1 * num2;}gcc命令:gcc -c -fPIC libtest.cgcc -shared libtest...
阅读全文
摘要:我们经常遇到一种场景,比如把 链表结点或者队列结点 放入到 数据结构体 中,当我们知道结点地址,想要得到数据结构的地址,下面这个宏可以出场了。#define offsetof(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER )举例:#include typ...
阅读全文
摘要:直接上命令:gcc -gdwarf-2 -g3 xxx.c怎么得到的呢?man gcc找到-glevel Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3. -gdwarf-2 does not accept a concatenated debug level, because GCC used to support an option ...
阅读全文