Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2292439
  • 博文数量: 252
  • 博客积分: 5472
  • 博客等级: 大校
  • 技术积分: 3107
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-17 18:39
文章分类

全部博文(252)

文章存档

2012年(96)

2011年(156)

分类: 系统运维

2012-03-13 17:02:51

1 编译Nginx,会在源代码根目录下生成objs目录,该目录中包含有ngx_auto_config.h和ngx_auto_headers.h,以及ngx_modules.c文件,当然,还有Makefile文件等。
2 make
3 make install

nginx简单的数据类型的表示

在 core/ngx_config.h 目录里面定义了基本的数据类型的映射,大部分都映射到c语言自身的数据类型


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


其中 ngx_int_t, nginx_flag_t, 都映射为 intptr_t; ngx_uint_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


所以基本的操作和整形/指针类型的操作类似

建立文件


  1. #include
  2. #include "../../core/ngx_config.h"

  3. int main()
  4. {
  5. ngx_uint_t a;
  6. ngx_int_t b;
  7. a = 1000;
  8. b = -1000;
  9. printf ("%d + %d = %d\n", a, b, a+b);
  10. return 0;
  11. }


编译测试


  1. gcc -I ../../../objs/ -I ../../os/unix/ basic_types_int.c -o basic_types_int

./basic_types_int

输出结果 :

1000 + -1000 = 0

阅读(3071) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~