[转发]Linux的系统调用宏

原来在linux/include/linux/syscalls.h 中定义了如下的宏:

复制代码
#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)

#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)

#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)

#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)

#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)

#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
复制代码
 

还有:

复制代码
#define SYSCALL_DEFINEx(x, sname, ...)                          \

       __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)

 

#define __SYSCALL_DEFINEx(x, name, ...)                               \

       asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__));        \

       static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__));  \

       asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__))             \

       {                                                      \

              __SC_TEST##x(__VA_ARGS__);                            \

              return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__));  \

       }                                                      \

       SYSCALL_ALIAS(sys##name, SyS##name);                        \

       static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__))
复制代码
 

你可能感兴趣的:(linux)