全部博文(92)
分类: 嵌入式
2009-08-22 21:12:46
_syscall0(type,name) _syscall1(type,name,type1,arg1) _syscall2(type,name,type1,arg1,type2,arg2) _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) |
They don't look like macro, but its essence is the same with the format like that:
# define MAXSIZE 100
which there is no difference between the MAXSIZE.
Their role is that forming the corresponding function prototype for system calls in the procedure. We are easily found in the law, _syscall behind the numbers and typeN, argN number as many. In fact, _syscall followed by the number specified after the start of the formation function of the number of parameters, let us look at an example of the time which is just used system call:
_syscall1 (time_t, time, time_t *, tloc)
time_t time(time_t * tloc) { long __res; __asm__ volatile("int $0x80" : "=a" (__res) : "0" (13),"b" ((long)(tloc))); do { if ((unsigned long)(__res) >= (unsigned long)(-125)) { errno = -(__res); __res = -1; } return (time_t) (__res); } while (0) ; } |
As can be seen, _syscall1 (time_t, time, time_t *, tloc) started as a function of time, time_t is a function of the original parameters of the return type, the original and time_t * parameters, respectively, constitute a new tloc function parameters. In fact, the procedure used in the prototype function of time is that.
Commonly used system call *fcntl() int fcntl(int fd, int cmd); int fcntl(int fd,int cmd,long arg); int fcntl(int fd,int cmd,struct flock * lock);
fcntl () used to operate some features in file descriptor, for example calling the fcntl to set O_NONBLOCK signs, so that the file descriptor into non-blocking mode.
*open() int open(const char * pathname, int flages); int open(const char * pathname,int flages, mode_t mode); open() used to open the assigned path file
*creat() int creat(const char * pathname, mode_tmode); creat()used to create a file and return file descriptor
*int close(int fd);
*ssize_t read(int fd, void * buf,size_t count);
*ssize_t write(int fd,void * buf,size_t count);
*ssize_t writev(int fildes, const struct iovec *iov, int iovcnt); write the data in the buffer array into document
*ssize_t readv(int fildes,const struct iovec * iov,int iovcnt); read the data from document to buffer array