摘要: #include #include int getMulprocessorCount(){ cudaDeviceProp prop; cudaGetDeviceProperties(&prop,0); return prop.multiProcessorCount;}__constant__ int a[10]={1,2,3,4,5,6,7,8,9};__global__ void add(int *c){ c[1]=a[2];}int main(){ int *c; int h_c[10]; int m... 阅读全文
posted @ 2013-10-21 15:23 戴安澜式编程 阅读(2599) 评论(0) 推荐(0) 编辑
摘要: [转]http://www.cnblogs.com/mydomain/archive/2012/09/24/2699467.htmlawk引用外部变量一、用awk有以下几种方法去调用变量:1. awk '{print a, b}' a=111 b=222 yourfile注意,变量位置要在file名之前,否则就不能调用。还有,于BEGIN{}中是不能调用这些的variable.要用之后所讲的第二种方法才可解决.2. awk –v a=111–v b=222 '{print a,b}' yourfile注意,对每一个变量加一个 –v作传递.3. awk ' 阅读全文
posted @ 2013-07-12 12:31 戴安澜式编程 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 今天在调试程序遇到一个段错误。而检查程序逻辑没有可能产生错误可能性。最终通过google找到了该问题的愿意。以下是转来的:发现出错在 inet_ntoa 那一行。查看了 inet_ntoa 的帮助,没有发现什么特别的地方。试着打开编译的warning开关看看有没有什么发现:[shengkui@uranus ~]$ gcc -g -o getaddr getaddr.c -Wallgetaddr.c: In function 'get_host_ip':getaddr.c:26: warning: implicit declaration of function 'ine 阅读全文
posted @ 2012-03-08 14:13 戴安澜式编程 阅读(1111) 评论(0) 推荐(0) 编辑
摘要: C语言,数组 阅读全文
posted @ 2012-02-23 13:38 戴安澜式编程 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 下面先总结下“位字段”的几个概念:定义:位字段简称字段,是“字”中相邻位的集合;所谓“字”是由实现定义的单一存储单元。字段定义和访问的语法基于结构。位字段所允许的类型:C语言允许unsigned int类型,signed int类型或int类型的位字段,分别称为无符号字段,带符号字段和普通位字段。和普通字符一样,普通位字段可以无符号或带符号。C99允许_Bool类型的位字段。应用:位段结构也是一种结构体类型,只不过其中含有以位为单位定义存储长度的整数类型位段成员。采用位段结构既节省存储空间,又可方便操作。定义格式:unsigned <成员名>:<二进制位数>例如:str 阅读全文
posted @ 2012-02-03 10:10 戴安澜式编程 阅读(1797) 评论(0) 推荐(0) 编辑
摘要: 转载注明出处:http://www.cnblogs.com/renhao/archive/2011/12/16/2289823.html问题1:Packet size limited during capture解决方案(来源):http://blogold.chinaunix.net/u2/71257/showart.php?id=2320384在linux下用tcpdump抓取http数据包,之后用wireshark打开,发现数据包的内容是不全的,如图:这时,想分析和获取http包中的内容是不可能是,在图中可以发现,wireshark给出了“Packet size limited duri 阅读全文
posted @ 2011-12-16 10:27 戴安澜式编程 阅读(2057) 评论(0) 推荐(0) 编辑
摘要: DNS解析 API文档参考英文文档:http://docstore.mik.ua/orelly/networking_2ndEd/dns/ch15_02.htmhttp://www.opensource.apple.com/source/libresolv/libresolv-46/ns_name.c一.工具函数集合(1)int ns_name_ntop(const u_char *src, char *dst, size_t dstsiz)功能: 该函数将网络域名格式【eg:3www5baidu3com0】转换为通常类型的域名格式【www.baidu.com】返回:写到buffer中的字节数 阅读全文
posted @ 2011-11-14 16:01 戴安澜式编程 阅读(3246) 评论(0) 推荐(0) 编辑
摘要: (1)ubuntu下配置文件目录:/etc/profile(2)命令:sudo vim /etc/profile(3)编辑如下:a.对于头文件的搜索路径:C_INCLUDE_PATH=<your include path>;export C_INCLUDE_PATH对于库文件的搜索路径:LIBRARY_PATH=<your lib path>;export LIBRARY_PATH对于链接程序ld使用的库文件搜索路径:LD_LIBRARY_PATH=<your ldlib path>;export LD_LIBRARY_PATH 阅读全文
posted @ 2011-10-24 16:32 戴安澜式编程 阅读(475) 评论(0) 推荐(0) 编辑
摘要: (1)系统调用 int nids_init() 初始化程序(2)int nids_init() 调用函数 init_procs(); 以下是该函数的实现代码: 1 staticvoid init_procs() 2 { 3 ip_frag_procs = mknew(struct proc_node); 4 ip_frag_procs->item = gen_ip_frag_proc; 5 ip_frag_procs->next =0; 6 ip_procs = mknew(struct proc_node); 7 ip_procs->item = g... 阅读全文
posted @ 2011-08-29 16:39 戴安澜式编程 阅读(2715) 评论(0) 推荐(0) 编辑
摘要: 1 void 2 register_callback(struct proc_node **procs, void (*x)) 3 { 4 struct proc_node *ipp; 5 6 for (ipp =*procs; ipp; ipp = ipp->next)//判断该回调函数是否存在 7 if (x == ipp->item) 8 return; 9 ipp = mknew(struct proc_node);10 ipp->item = x;11 ipp->next =*procs;12 *procs = ipp;13 }采用函数链表存储处理函数,采用前 阅读全文
posted @ 2011-08-29 13:55 戴安澜式编程 阅读(578) 评论(0) 推荐(1) 编辑