contributed by < joey-ycpeng
>
Anwser:
「展開」(expand) 和「嵌入」(embed) 這兩個詞彙意義不同,回頭看 C preprocessor 用了哪個詞。工程人員用語務必精準,及早脫離「文組TM」
查閱 Linux x86_64 application binary interface (ABI) 的規格,確保「將 arguments 反序 push 到 stack」是否總是正確
Yu-Cheng PengTue, Mar 5, 2019 12:26 AM
根據 System V ABI - AMD64 Architecture Processor Supplement3.2.3 Parameter Passing
"Arguments of types (signed and unsigned) Bool, char, short, int, long, long long, and pointers are in the INTEGER class."
"INTEGER This class consists of integral types that fit into one of the general purpose registers"
"Passing Once arguments are classified, the registers get assigned (in left-to-rightorder) for passing as follows:
… If the class is INTEGER, the next available register of the sequence %rdi,%rsi, %rdx, %rcx, %r8 and %r9 is used."以此解釋下面
call.c
:
1.
Anwser:
int x=0; typeof(x) y=1;
,y
也是int
container_of
Answer:
type
類型指標((type *) 0)->member)
:
type
類型下的 member
__typeof__(((type *) 0)->member)
:
member
所屬的類型const __typeof__(((type *) 0)->member) *__pmember = (ptr)
:
member
所屬的類型常量的指標 __pmember
ptr
to __pmember
offsetof(type, member)
:
member
在 type
類型裡的 byte offset(char *) __pmember - offsetof(type, member)
:
(type *) ((char *) __pmember - offsetof(type, member));
:
type
類型的指標__extension__({...;})
:
__extension__
告訴 GCC 不要對 C 以外的擴充功能發出警告container_off(ptr, type, member)
回傳一個指向 struct type
物件的指標,這個物件的 member
指向 ptr
list.h
還定義一系列操作,為什麼呢?這些有什麼益處?LIST_POISONING
這樣的設計有何意義?list_for_each_safe
和 list_for_each
的差異在哪?"safe" 在執行時期的影響為何?* 提示:對照其他程式語言,如 Perl 和 Python
@
符號,這有何意義?你能否應用在後續的程式開發呢?* 提示: 對照看 Doxygen
tests/
目錄底下的 unit test 的作用為何?就軟體工程來說的精神為何?tests/
目錄的 unit test 可如何持續精進和改善呢?qtest
homework