註:因為排版有點困難所以直接搬到這裡重新開始
a value stored in an object or returned by a function
Types are partitioned into :
- function type
- object type
- incomplete type
a pointer points to a word.
doubly free 會造成 undefined behavior
free(NULL) 是合乎規範的用法,它不會做任何事情
在需要歸零的情況下 calloc
比 malloc
+ memset
更有效率
void *
存在的目的就是為了被轉型
float *
has type ''pointer to float''float * const
. Its type is ''const-qualified pointer to float''.const float *
has type ''pointer to const-qualified float''An object that is accessed through a restrict-qualified pointer has a special association with that pointer.
If an object is accessed through one of the pointer parameters, then it is not also accessed through the other.
https://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html
The rule may be avoid by union.
gcc | |
---|---|
-o | 生成目的檔案 |
-E | only preprocessing |
-c | no linking |
-Werror | 把 warning 轉為 error |
-Wall | generate all warnings |
-w | no warning |
-I | specify header path |
-L | specify function library path |
-static | 連結成靜態函式庫 |
-g | 包含 debug 資訊 |
-v | 輸出編譯過程資訊 |
-O<n> | 編譯器最佳化等級 預設為 O1 |
交換編譯:在一種平台上編譯,然後放到另一種平台執行。
objdump -d *.c 反組譯命令
run
___
run
___ <
___ (run)whatis
_break
___ [if
___]*argv[]
https://hackmd.io/@sysprog/gnu-linux-dev/https%3A%2F%2Fhackmd.io%2Fs%2FSySTMXPvl
If only one branch of a conditional statement is a single statement, all the branches should use braces.
typeof()
取得 data type__attribute__()
POSIX = Portable Operating System Interface 規範 kernel 與 application 間的界面
/var/lock/
arch | CPU 相關程式碼 |
block | |
certs | 證書機制 |
crypto | 加密相關 |
Documentation | |
drivers | |
fs | file system |
include | |
init | |
ipc | interprocess communication |
kernel | process management, scheduler, lock, e.t.c. |
lib | |
mm | memory management |
net | 網路通訊協定相關 |
samples | |
scripts | |
security | |
sound | 音效卡相關 |
tools | 一些開發工具,如 perf 等 |
usr | |
virt | 虛擬化相關 |
usr: unix software resource
fd: file descriptor
Linux 抽象出 VFS (virtual file system) 軟體層,以便於支援多種檔案系統架構。
設定檔 .config
Linux kernel 於 <list.h>
中提供了 struct list_head
及一套框架來操作 list
使用上需要將 struct list_head
嵌入其它資料結構,並使用 container_of()
來獲取需要的內容。使用範例如下: