Skip to content

Commit

Permalink
linux: add eventfd and eventfd2 syscalls
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Jun 11, 2012
1 parent 78bc0d6 commit 3b417d1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
38 changes: 38 additions & 0 deletions src/unix/linux/syscalls.c
Expand Up @@ -49,6 +49,26 @@
# endif
#endif /* __NR_accept4 */

#ifndef __NR_eventfd
# if __x86_64__
# define __NR_eventfd 284
# elif __i386__
# define __NR_eventfd 323
# elif __arm__
# define __NR_eventfd (UV_SYSCALL_BASE + 351)
# endif
#endif /* __NR_eventfd */

#ifndef __NR_eventfd2
# if __x86_64__
# define __NR_eventfd2 290
# elif __i386__
# define __NR_eventfd2 328
# elif __arm__
# define __NR_eventfd2 (UV_SYSCALL_BASE + 356)
# endif
#endif /* __NR_eventfd2 */

#ifndef __NR_inotify_init
# if __x86_64__
# define __NR_inotify_init 253
Expand Down Expand Up @@ -147,6 +167,24 @@ int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags) {
}


int uv__eventfd(unsigned int count) {
#if __NR_eventfd
return syscall(__NR_eventfd, count);
#else
return errno = ENOSYS, -1;
#endif
}


int uv__eventfd2(unsigned int count, int flags) {
#if __NR_eventfd2
return syscall(__NR_eventfd2, count, flags);
#else
return errno = ENOSYS, -1;
#endif
}


int uv__inotify_init(void) {
#if __NR_inotify_init
return syscall(__NR_inotify_init);
Expand Down
10 changes: 8 additions & 2 deletions src/unix/linux/syscalls.h
Expand Up @@ -32,12 +32,16 @@
#define UV__O_NONBLOCK 0x800
#define UV__O_CLOEXEC 0x80000

#define UV__SOCK_CLOEXEC UV__O_CLOEXEC
#define UV__SOCK_NONBLOCK UV__O_NONBLOCK
#define UV__EFD_CLOEXEC UV__O_CLOEXEC
#define UV__EFD_NONBLOCK UV__O_NONBLOCK

#define UV__IN_CLOEXEC UV__O_CLOEXEC
#define UV__IN_NONBLOCK UV__O_NONBLOCK

#define UV__SOCK_CLOEXEC UV__O_CLOEXEC
#define UV__SOCK_NONBLOCK UV__O_NONBLOCK

/* inotify flags */
#define UV__IN_ACCESS 0x001
#define UV__IN_MODIFY 0x002
#define UV__IN_ATTRIB 0x004
Expand Down Expand Up @@ -65,6 +69,8 @@ struct uv__mmsghdr {
};

int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags);
int uv__eventfd(unsigned int count);
int uv__eventfd2(unsigned int count, int flags);
int uv__inotify_init(void);
int uv__inotify_init1(int flags);
int uv__inotify_add_watch(int fd, const char* path, __u32 mask);
Expand Down

0 comments on commit 3b417d1

Please sign in to comment.