abc_begin

导航

nginx源码学习_数据结构(ngx_int_t)

nginx中关于整型的数据结构位于src/core/ngx_config.h中

结构比较简单,就是一个typedef的操作,具体如下:

1 typedef intptr_t        ngx_int_t;
2 typedef uintptr_t       ngx_uint_t;
3 typedef intptr_t        ngx_flag_t;

 

里面的intptr_t和uintptr_t的定义位于/usr/include/stdint.h中

 1 /* Types for `void *' pointers.  */
 2 #if __WORDSIZE == 64
 3 # ifndef __intptr_t_defined
 4 typedef long int        intptr_t;
 5 #  define __intptr_t_defined
 6 # endif
 7 typedef unsigned long int   uintptr_t;
 8 #else
 9 # ifndef __intptr_t_defined
10 typedef int         intptr_t;
11 #  define __intptr_t_defined
12 # endif
13 typedef unsigned int        uintptr_t;
14 #endif

另外,C99 标准定义了 intptr_t 和 uintptr_t 类型给一个可以持有一个指针值的整型变量。这是因为它们的大小和指针的大小一样,因此也有了注释中的/* Types for `void *' pointers. */这句话。

 

posted on 2017-09-18 11:45  LastBattle  阅读(791)  评论(0编辑  收藏  举报