server: Use the syscall function instead of inline assembly.
This commit is contained in:
parent
91ecb05f29
commit
0ae3816264
|
@ -98,38 +98,17 @@ struct inotify_event {
|
|||
|
||||
static inline int inotify_init( void )
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__( "int $0x80"
|
||||
: "=a" (ret)
|
||||
: "0" (SYS_inotify_init));
|
||||
if (ret<0) { errno = -ret; ret = -1; }
|
||||
return ret;
|
||||
return syscall( SYS_inotify_init );
|
||||
}
|
||||
|
||||
static inline int inotify_add_watch( int fd, const char *name, unsigned int mask )
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__( "pushl %%ebx;\n\t"
|
||||
"movl %2,%%ebx;\n\t"
|
||||
"int $0x80;\n\t"
|
||||
"popl %%ebx"
|
||||
: "=a" (ret) : "0" (SYS_inotify_add_watch),
|
||||
"r" (fd), "c" (name), "d" (mask) );
|
||||
if (ret<0) { errno = -ret; ret = -1; }
|
||||
return ret;
|
||||
return syscall( SYS_inotify_add_watch, fd, name, mask );
|
||||
}
|
||||
|
||||
static inline int inotify_rm_watch( int fd, int wd )
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__( "pushl %%ebx;\n\t"
|
||||
"movl %2,%%ebx;\n\t"
|
||||
"int $0x80;\n\t"
|
||||
"popl %%ebx"
|
||||
: "=a" (ret) : "0" (SYS_inotify_rm_watch),
|
||||
"r" (fd), "c" (wd) );
|
||||
if (ret<0) { errno = -ret; ret = -1; }
|
||||
return ret;
|
||||
return syscall( SYS_inotify_rm_watch, fd, wd );
|
||||
}
|
||||
|
||||
#define USE_INOTIFY
|
||||
|
|
24
server/fd.c
24
server/fd.c
|
@ -127,38 +127,20 @@ struct epoll_event
|
|||
epoll_data_t data;
|
||||
};
|
||||
|
||||
#define SYSCALL_RET(ret) do { \
|
||||
if (ret < 0) { errno = -ret; ret = -1; } \
|
||||
return ret; \
|
||||
} while(0)
|
||||
|
||||
static inline int epoll_create( int size )
|
||||
{
|
||||
int ret;
|
||||
__asm__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
|
||||
: "=a" (ret) : "0" (254 /*NR_epoll_create*/), "r" (size) );
|
||||
SYSCALL_RET(ret);
|
||||
return syscall( 254 /*NR_epoll_create*/, size );
|
||||
}
|
||||
|
||||
static inline int epoll_ctl( int epfd, int op, int fd, const struct epoll_event *event )
|
||||
{
|
||||
int ret;
|
||||
__asm__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
|
||||
: "=a" (ret)
|
||||
: "0" (255 /*NR_epoll_ctl*/), "r" (epfd), "c" (op), "d" (fd), "S" (event), "m" (*event) );
|
||||
SYSCALL_RET(ret);
|
||||
return syscall( 255 /*NR_epoll_ctl*/, epfd, op, fd, event );
|
||||
}
|
||||
|
||||
static inline int epoll_wait( int epfd, struct epoll_event *events, int maxevents, int timeout )
|
||||
{
|
||||
int ret;
|
||||
__asm__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
|
||||
: "=a" (ret)
|
||||
: "0" (256 /*NR_epoll_wait*/), "r" (epfd), "c" (events), "d" (maxevents), "S" (timeout)
|
||||
: "memory" );
|
||||
SYSCALL_RET(ret);
|
||||
return syscall( 256 /*NR_epoll_wait*/, epfd, events, maxevents, timeout );
|
||||
}
|
||||
#undef SYSCALL_RET
|
||||
|
||||
#endif /* linux && __i386__ && HAVE_STDINT_H */
|
||||
|
||||
|
|
Loading…
Reference in New Issue