2013-06-25 22 views
1

我想知道在下面的代碼%P3的含義:含義在Linux內核內聯組件的

#define get_user(x, ptr)      \ 
({         \ 
    int __ret_gu;       \ 
    register __inttype(*(ptr)) __val_gu asm("%edx");  \ 
    __chk_user_ptr(ptr);      \ 
    might_fault();       \ 
    asm volatile("call __get_user_%P3"    \ 
      : "=a" (__ret_gu), "=r" (__val_gu)   \ 
      : "0" (ptr), "i" (sizeof(*(ptr))));  \ 
    (x) = (__typeof__(*(ptr))) __val_gu;    \ 
    __ret_gu;       \ 
}) 

而且在LLVM IR代碼被映射到:

call { i32*, i64 } asm sideeffect "call __get_user_${3:P}", "={ax},={edx},0,i,~{dirflag},~{fpsr},~{flags}"(i32* %tmp73, i64 4) 

我的理解是,這實際上調用了arch/x86/lib/getuser.S中的特定函數__get_user_X,但是不清楚哪一個特別(__get_user_4?)。

最後,我想了解%P和%P之間的差異。

回答

1

我認爲%P3表示在__get_user_X的X是依賴於 「I」(的sizeof((PTR))。如的sizeof((PTR))可以是1,2,4,8。

3意味着,ASM揮發性裏面的第三個參數(「...」)語句,而且%p是字符串連接。

大約%p和%p區別,我想這是對字符串規範,但我我不知道,我複製了GCC用戶手冊中的以下句子:

%p Substitutes the standard macro predefinitions for the current target machine. 
    Use this when running cpp. 
%P Like ‘%p’, but puts ‘__’ before and after the name of each predefined macro, 
    except for macros that start with ‘__’ or with ‘_L’, where L is an uppercase 
    letter. This is for ISO C. 
+0

[文檔似乎用於「spec文件」](https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html),它似乎與GAS沒有關係 – delcypher