- 博客(129)
- 资源 (126)
- 论坛 (2)
- 问答 (2)
- 收藏
- 关注
原创 函数指针,指针函数
You can't have any of these:a function can't return a function, so you'll never see foo()() a function can't return an array, so you'll never see foo()[] an array can't hold a function, so you'll ...
2019-01-31 22:17:32
181
原创 const int *, int const *, int * const
const int * grape;int const * grape;int * const grape_jelly;The last of these cases makes the pointer read-only, whereas the other two make the object that it points at read-only; and of course, ...
2019-01-31 22:14:13
96
原创 ANSI C:+++
#include <stdio.h>#define _s(i) printf("%s: %d\n", #i, i)int main(){ int x = 1; int y = 2; int z = x+++y; _s(x);_s(y);_s(z); //z = x+++++y; //erro...
2019-01-31 21:48:08
409
原创 Symbol Overloading in C
Symbol Overloading in C Symbol Meaning static Inside a function, retains its value between calls At the function level, visible only in this file extern Applied to a function definiti...
2019-01-31 21:39:44
96
原创 The One 'l' nul and the Two 'l' null
Memorize this little rhyme to recall the correct terminology for pointers and ASCII zero:The one "l" NUL ends an ASCII string, The two "l" NULL points to no thing.Apologies to Ogden Nash, but the ...
2019-01-31 21:31:15
103
原创 /dev/tty和/dev/console
目录1.串行端口终端(/dev/ttySn)2.伪终端(/dev/pty/)3.控制终端(/dev/tty) 4.控制台终端(/dev/ttyn, /dev/console) 5.其它类型 (1)/dev/console是系统控制终端,系统的错误信息什么的都输出到这里。 (2)/dev/tty(n或者Sn)是进程控制台,如果在进程里打开一个这样的文件且该文件不是其他进程...
2019-01-31 21:25:46
327
原创 Depending on whether you compile it under K&R or ANSI C
#include <stdio.h>int array[] = { 23, 34, 12, 17, 204, 99, 16 };#define TOTAL_ELEMENTS (sizeof(array) /sizeof(array[0]))//#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))//ins...
2019-01-31 20:54:08
107
原创 Undefined Behavior Causes CPU Meltdown in IBM PC's!
The suggestion of undefined software behavior causing CPU meltdown isn't as farfetched asit first appears.The original IBM PC monitor operated at a horizontal scan rate provided by the video control...
2019-01-31 20:30:56
111
原创 K&R C与ANSI C
起初,C语言没有官方标准。1978年由美国电话电报公司(AT&T)贝尔实验室正式发表了C语言。布莱恩·柯林汉(Brian Kernighan) 和 丹尼斯·里奇(Dennis Ritchie) 出版了一本书,名叫《The C Programming Language》。这本书被 C语言开发者们称为K&R,很多年来被当作 C语言的非正式的标准说明。人们称这个版本的 C语言为K&...
2019-01-31 20:26:38
191
原创 atof、atoi、atol、atoll
atoi.c stdlib 964 2018/8/1 3/* Convert a string to a double. */doubleatof (const char *nptr){ return strtod (nptr, (char **) NULL);}/* Convert a string to an int. */intatoi ...
2019-01-29 22:15:37
433
3
原创 bits order swap
glibc-2.28:byteswap.h bits 2449 2018/8/1 12/* Swap bytes in 16-bit value. */#define __bswap_constant_16(x) \ ((__uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) <...
2019-01-29 22:04:42
128
原创 VA
glibc-2.28:err.c misc 3818 2018/8/1 98#define VA(call) \{ \ va_list ap; \ va_start (ap, format); \ call; \ va_en...
2019-01-29 21:55:46
114
原创 __attribute__ ((__format__ (__printf__, 1, 2)));
glibc-2.28:err.h misc 2209 2018/8/1 /* 4.4BSD utility functions for error messages. Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library....
2019-01-29 21:52:25
508
原创 __builtin_expect提高运行效率
这个指令是gcc引入的,作用是"允许程序员将最有可能执行的分支告诉编译器"。这个指令的写法为:__builtin_expect(EXP, N)。意思是:EXP==N的概率很大。给出glibc-2.28中cdefs.h misc\sys 18008 2018/8/1 #if __GNUC__ >= 3# define __glibc_unlikely(c...
2019-01-29 21:36:55
333
原创 cygwin不支持__malloc_hook
GLIBC-2.28中malloc.h里面有这样一段:/* Hooks for debugging and user-defined versions. */extern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr, c...
2019-01-29 21:13:03
194
原创 MALLOC_HOOK
NAME __malloc_hook, __malloc_initialize_hook, __memalign_hook, __free_hook, __realloc_hook, __after_morecore_hook - malloc debugging variablesSYNOPSIS ...
2019-01-29 21:06:08
875
原创 Memory Allocation Hooks
The GNU C Library lets you modify the behavior of malloc, realloc, and free by specifying appropriate hook functions. You can use these hooks to help you debug programs that use dynamic memory allocat...
2019-01-29 20:56:34
169
原创 linux内核驱动之 用户空间和内核空间
A module runs in kernel space, whereas applications run in user space. This concept is at the base of operating systems theory.一个模块在内核空间运行, 而应用程序在用户空间运行. 这个概念是操作系统理论的基础.操作系统的角色, 实际上, 是给程序提供一个一致的计算机...
2019-01-28 22:27:47
738
原创 linux内核驱动之 设备和模块的分类
目录字符设备块设备网络接口其他划分方式以 Linux 的方式看待设备可区分为 3 种基本设备类型. 每个模块常常实现 3 种类型中的 1 种, 因此可分类成字符模块, 块模块, 或者一个网络模块. 这种将模块分成不同类型或类别的方法并非是固定不变的; 程序员可以选择建立在一个大块代码中实现了不同驱动的巨大模块. 但是, 好的程序员, 常常创建一个不同的模块给每个它们实现的新功能...
2019-01-28 22:20:30
600
原创 linux驱动之可加载模块
Linux 的众多优良特性之一就是可以在运行时扩展由内核提供的特性的能力. 这意味着你可以在系统正在运行着的时候增加内核的功能( 也可以去除 ).每块可以在运行时添加到内核的代码, 被称为一个模块. Linux 内核提供了对许多模块类型的支持, 包括但不限于, 设备驱动. 每个模块由目标代码组成( 没有连接成一个完整可执行文件 ), 可以动态连接到运行中的内核中, 通过 insmod 程序, ...
2019-01-28 22:16:25
257
原创 linux内核驱动之 设备驱动简介之内核划分
目录进程管理内存管理文件系统设备控制网络在 Unix 系统中, 几个并发的进程专注于不同的任务. 每个进程请求系统资源, 象计算能力, 内存, 网络连接, 或者一些别的资源. 内核是个大块的可执行文件, 负责处理所有这样的请求. 尽管不同内核任务间的区别常常不是能清楚划分, 内核的角色可以划分(如同图内核的划分)成下列几个部分:进程管理内核负责创建和销毁进程, 并处...
2019-01-28 22:14:07
177
原创 linux内核驱动之 驱动程序的角色
作为一个程序员, 你能够对你的驱动作出你自己的选择, 并且在所需的编程时间和结果的灵活性之间, 选择一个可接受的平衡. 尽管说一个驱动是"灵活"的, 听起来有些奇怪, 但是我们喜欢这个字眼, 因为它强调了一个驱动程序的角色是提供机制, 而不是策略.机制和策略的区分是其中一个在 Unix 设计背后的最好观念. 大部分的编程问题其实可以划分为 2 部分:" 提供什么能力"(机制) 和 "如何使用这些...
2019-01-28 22:11:03
113
原创 glibc:one of ioctl.c
/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the term...
2019-01-28 21:55:56
128
原创 glibc:__attribute__((weak, alias("name")))
#include <stdio.h>int fun(){ printf("func\n"); return 0;}int f() __attribute__((weak, alias("fun")));#define weak_alias(name, aliasname) \ typeof(name) aliasname ...
2019-01-28 21:40:02
210
1
原创 Seismic migration - Wikipedia
学英语。RationaleUseTypes of migrationTime migrationDepth migrationResolutionGraphical migrationTechnical detailsSee alsoReferencesFrom Wikipedia, the free encyclopediaJump to navi...
2019-01-27 20:03:36
292
原创 [GitHub]一个简单的网络驱动
GitHub地址:https://github.com/gautamanshul/Network-driver项目中的Makefile可能有一定的问题,我重写了一下,并在下面给出network.c和makefile文件;network.c#include <linux/module.h>#include <linux/netdevice.h>#includ...
2019-01-27 19:10:31
487
转载 linux驱动头文件说明
编译后的linux内核,驱动头文件路径为/usr/src/kernels/3.10.0-693.el7.x86_64/include/linux,根据不同的内核版本,写成通用的路径模式为:$ cd /usr/src/kernels/`uname -r`/include/linux$ pwd/usr/src/kernels/3.10.0-693.el7.x86_64/include/lin...
2019-01-27 18:59:01
255
转载 在Linux下写一个简单的驱动程序
目录一个简单的驱动编写驱动程序驱动程序的Makefile驱动程序的测试程序驱动程序的编译加载驱动init函数创建节点PS:/proc/devices 与 /dev的区别运行上层应用程序编译:运行卸载驱动彻底删除设备文件驱动模板头文件初始化函数退出函数版权信息功能函数从上层应用到底层驱动的执行过程linux系统的...
2019-01-27 18:32:14
718
原创 这辈子真的找不到SIOCIFCREATE了吗?
#include <sys/types.h> #include <sys/ioctl.h> #include <sys/socket.h...
2019-01-27 12:55:24
319
转载 Tun/Tap接口教材-[翻译:Tun/Tap interface tutorial]
英文原文:https://backreference.org/2010/03/26/tuntap-interface-tutorial/翻译原文:https://www.jianshu.com/p/6a2e5a0cceb2目录工作原理创建虚拟接口使用一个简单的程序TunnelsExtensions and improvements前言:请注意,这里提供的代码仅用...
2019-01-27 12:53:02
402
转载 Linux的TUN/TAP编程
TUN/TAP虚拟网络设备为用户空间程序提供了网络数据包的发送和接收能力。他既可以当做点对点设备(TUN),也可以当做以太网设备(TAP)。实际上,不仅Linux支持TUN/TAP虚拟网络设备,其他UNIX也是支持的,他们之间只有少许差别。原理简介TUN/TAP虚拟网络设备的原理比较简单,他在Linux内核中添加了一个TUN/TAP虚拟网络设备的驱动程序和一个与之相关连的字符设备/dev/net...
2019-01-27 12:17:34
457
2
原创 netintro — introduction to networking facilities:“SIOCIFCREATE”
NAMEnetintro — introduction to networking facilitiesSYNOPSIS#include <sys/socket.h> #include <net/route.h> #include <net/if.h>TABLE OF CONTENTSNAMESYNOPSISTABLE OF CONT...
2019-01-27 10:54:11
383
原创 ioctls.h
在glibc-2.28中,有个文件:sysdeps/unix/sysv/linux/bits/ioctls.h,内容如下:/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free softw...
2019-01-26 19:13:10
372
1
原创 Q&A:ifconfig: SIOCIFCREATE2: Invalid argument - 2
https://sourceforge.net/p/tuntaposx/mailman/message/30457237/ Re: [tuntaposx-users] tap0 10.8.2 woes From: Joe Erlewein <joe@er...> - 2013-02-07 16:20:41 When I do "ifconfig tap0 ...
2019-01-26 19:05:57
775
原创 Q&A:ifconfig clone error - "SIOCIFCREATE2: Invalid argument"
https://lists.freebsd.org/pipermail/freebsd-questions/2008-July/178114.htmlHi there,I've been playing with a new FB7.0 setup (using the standard isodistribution), and trying to create some vlans...
2019-01-26 18:59:22
444
原创 QNX Software Development Platform
广告:QNX Software Development Platform地址:http://www.qnx.com/developers/docs/6.5.0/index.jspA Roadmap to the QNX Software Development PlatformDinkum DocumentationQNX Database for QNX NeutrinoQN...
2019-01-26 18:32:12
409
原创 ioctl(), ioctl_socket()
http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fi%2Fioctl.html目录Synopsis:Arguments:Library:Description:How ioctl() commands map to other commands...
2019-01-26 18:25:17
331
原创 if_tun.h
Browse the source code of linux/include/uapi/linux/if_tun.h1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */2 /*3 * Universal TUN/TAP device driver.4 * Copyright (C) 1999-200...
2019-01-26 18:13:18
448
转载 Useful “ifconfig” Commands to Configure Network Interface in Linux
https://www.tecmint.com/ifconfig-command-examples/ifconfig in short “interface configuration” utility for system/network administration in Unix/Linux operating systems to configure, manage and query...
2019-01-26 10:15:11
430
MPI, OpenMP, CUDA, OpenCL, OpenACC,
2018-06-03
中国电信DPDK技术白皮书.pdf
2020-10-25
OpenCV自带视频测试文件vtest.avi
2018-05-04
C Reference Manual.pdf
2019-08-04
Virtual Memory and Linux - AlanOtt.pdf
2020-11-10
Aarch64 Kernel Memory Management.pptx
2020-11-08
LKM:Linux Kernel Map(图解Linux内核)PDF,SVG,PNG格式
2020-11-01
The BSD Packet Filter A New Architecture for User-level Packet Capture.pdf
2020-10-30
XDP_DDoS_protecting_osd2017.pdf
2020-10-10
极简化的TCP/UDP测试工具-吞吐量
2020-07-22
Linux内核图解LKM.pdf
2020-04-04
vxworks-product-overview.pdf
2020-02-23
conf20200210.darkTheme.xml
2020-02-10
C语言如何从源函数中获取指向它的函数指针的地址
发表于 2020-05-21 最后回复 2020-06-15
Koma_Wong的留言板
发表于 2020-01-02 最后回复 2020-03-08
谁知道这个模板用法是什么意思
2019-03-31
C语言如何将字符串“int”转化为int类型
2019-01-09
TA创建的收藏夹 TA关注的收藏夹
TA关注的人 TA的粉丝