c
QQ327536427
这个作者很懒,什么都没留下…
展开
-
libevent中事件优先级实现过程
首先它是通过指向struct event_list的指针的指针来实现的 在struct event_base结构中体现如下: [code="C"]/* active event management */ struct event_list **activequeues; int nactivequeues;[/code] 其中nactivequeues为活动事件队列链表数,对应的优先级...2009-10-22 15:56:05 · 194 阅读 · 0 评论 -
C语言基础问题可当面试题
[code="C"]int main() { char a[1000]; int i; for(i=0; i原创 2013-09-24 17:11:55 · 334 阅读 · 0 评论 -
位数组
[code="c"] #define CHAR_BIT (8) #define BITMASK(b) (1原创 2013-06-27 11:29:46 · 122 阅读 · 0 评论 -
itoa
[code="c"]#include void itoa (int n,char s[]);//atoi 函数:将s转换为整形数 int main(void ) { int n; char s[100]; printf("Input n:\n"); scanf("%d",&n); printf("the string : \n"); itoa (n,s); ...原创 2011-07-17 22:04:20 · 113 阅读 · 0 评论 -
atoi
[code="c"]#include #include int atoi (char s[]); int main(void ) { char s[100]; gets(s); printf("integer=%d\n",atoi(s)); return 0; } int atoi (char s[]) { int i,n,sign...2011-07-17 21:59:21 · 85 阅读 · 0 评论 -
Linux C 多线程编程使用-D_REENTRANT
1、多线程编译使用-D_REENTRANT,如: gcc -D_REENTRANT -lpthread -o test test.c 2、头文件定义了一些标准库函数的reentrant变化的原型 3、重新定义了errno,让多线程函数有一个自己的安全的errno,而不是全局的。宏定义如下: #define errno (*(__errno_location()))...原创 2011-06-29 17:15:40 · 151 阅读 · 0 评论 -
lighttpd中的watcher workers模型
[code="C"]/* start watcher and workers */ num_childs = srv->srvconf.max_worker; if (num_childs > 0) { int child = 0; while (!child && !srv_shutdown && !graceful_shutdown) { if (num_child...原创 2010-05-06 16:37:02 · 109 阅读 · 0 评论 -
c中的FASTCALL
在阅读Linux内核源代码的时候,发现有很多__attribute__其中有一个宏FASTCALL用的就比较多 #define FASTCALL __attribute__((regparm(3))) 意思是,最多可以使用3个寄存器(或许是eax,edx,ecx)来传送前3个参数,其他参数则压入栈中,而一般来说,函数的调用是基于栈的。 #define asmlinkage CPP_ASM...2009-05-21 11:10:40 · 352 阅读 · 0 评论 -
libevent事件处理框架分析
几个重要的结构体定义: [code="C"]struct event_base { const struct eventop *evsel;/*事件驱动模型入口,在event_init函数中确定事件驱动模型*/ void *evbase;/*对应事件驱动模型实现相关属性参数*/ int event_count; /* counts number of total events */...2009-10-23 10:33:04 · 80 阅读 · 0 评论 -
C语言初级优化
程序进行优化,通常是指优化程序代码或程序执行速度。优化代码和优化速度实际上是一个予盾的统一,一般是优化了代码的尺寸,就会带来执行时间的增加,如果优化了程序的执行速度,通常会带来代码增加的副作用,很难鱼与熊掌兼得,只能在设计时掌握一个平衡点。 一、程序结构的优化 1、程序的书写结构 虽然书写格式并不会影响生成的代码质量,但是在实际编写程序时还是应该尊循一定的书写规则,一个书写清晰、明了的程...原创 2013-09-24 18:35:32 · 147 阅读 · 0 评论