|Design| Benefits of using Macro

What is the Macro?
If you write as “#define” in your code, that is “Macro” .

Macro will handle by the preprocessor.
You can think Macro as a method to replace the String which appears in you code..

– run faster than writing as function

– occupy memories

– there is no the concept of pointer in macro.
just “replacing the string”

An question:
What is the output of the following code?

#define macro_to_func(pp) ({printf("in Macro ...\n"); minus ;})

void do_something(int *a, int *b){
    int c;
    c = *a + *b;
    printf("do_something %d \n", c);

int minus(int *a, int *b){
    int c;
    c = *a - *b +1;
    printf("minus a = %d \n", *a);
    printf("minus b = %d \n", *b);
    printf("minus %d \n", c);
    return c;

int main()
    int (*do_something)(int* c, int* d);
    //printf("fptr 1 do_something %p\n", &do_something);

    int m = -1;
    int n = 7;

    printf("do_something = macro_to_func\n");
    do_something = macro_to_func(pp);
    //printf("fptr minus %p\n", &minus);
    //printf("fptr 2 do_something %p\n", &do_something);
        printf("in IF!!\n");
        do_something(&m, &n); --------------------------->???
    return 0;


do_something = macro_to_func
in Macro …
in IF!!
minus a = -1
minus b = 7
minus -7

“int (*do_something)” is a local function pointer.
In the macro, the macro_to_func will be replaced as “minus”, but do_something !!!

|Code| LLVM initial

One day, if you want to implement a module on the platform x86_64 for arm64, you will need to know the tool chain, “cross compiler”.
The famous modern compiler is LLVM.

Why should we understand the compiler?
– build for multi-platform
– improve the efficiency of your code
– …..

I have a conclusion for the developer whose library is under the user space.
Use suitable optimization provided by LLVM, and make your code readable.
Dazzle coding is meaningless.

你所不知道的 C 語言:編譯器和最佳化原理篇
[共筆] 不深不淺,帶你認識 LLVM
“編譯器 LLVM 淺淺玩” by Pokai Chang

|Jobs| Who is worthy of being called “Engineer” ?

The core competencies of engineer are
– never complain
– segmenting problems
hands-on problem solving
– not defeatist

You can win if you want.

If I am an interviewer, I just want to know ……
Will he/she want to solve problems?
Is he/she a defeatism?
Will he/she look down on other fields?
I don’t like whom disregard others.
It means he/she ignore details in him/her life.

|LTE| 開啟行動上網 ……

若想知道更多,可利用 > 後的關鍵字去做搜尋。

我們一開機,不是在飛航模式 ……
– UE 會向 NW 做 “initial attach”
> RRC connection (手機告訴網路說:我想要連線啦~基地台快醒來服務我)
> Attach request (我要送東西ㄛ~大概是一個包裹的大小,
> EMM 通知後端網路及認證 (電信商的櫃台忙著聯絡服務中心)
> RRC reconfiguration (開始配送貨車來服務客人送貨)


– Initial attach 之後,表示 UE 已經向網路拿到派發的 IP
– 這時候手機裡的 data service 會向 modem 取得 IP address
– 設定 Linux 裡的 “rmnet_data”、”DNS” ……
但還沒有要送封包出去哦 ……

開始要送封包 ……
封包從 APP 開始,會經過:
– IP
– rmnet driver 走出去到網路端啦~
The packet flow, from userspace to kernel driver in Linux network stack


LTE initial attach