Although system calls are used mainly by User Mode
processes, they can also be invoked by kernel threads , which cannot use library functions. To simplify the
declarations of the corresponding wrapper routines , Linux defines a set of seven macros called
In the name of each macro, the numbers 0 through 6 correspond to the number of parameters used by the system call (excluding the system call number). The macros are used to declare wrapper routines that are not already included in the libc standard library (for instance, because the Linux system call is not yet supported by the library); however, they cannot be used to define wrapper routines for system calls that have more than six parameters (excluding the system call number) or for system calls that yield nonstandard return values.
Each macro requires exactly 2 + 2 × n
parameters, with n being the number of parameters
of the system call. The first two parameters specify the return type and
the name of the system call; each additional pair of parameters
specifies the type and the name of the corresponding system call
parameter. Thus, for instance, the wrapper routine of the
fork( ) system call may be generated by:
while the wrapper routine of the
) system call may be generated by:
_syscall3(int,write,int,fd,const char *,buf,unsigned int,count)
In the latter case, the macro yields the following code:
int write(int fd,const char * buf,unsigned int count) ...