1/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to
5 * deal in the Software without restriction, including without limitation the
6 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 * sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 * IN THE SOFTWARE.
20 */
21
22#ifndef UV_LINUX_SYSCALL_H_
23#define UV_LINUX_SYSCALL_H_
24
25#undef _GNU_SOURCE
26#define _GNU_SOURCE
27
28#include <stdint.h>
29#include <signal.h>
30#include <sys/types.h>
31#include <sys/time.h>
32#include <sys/socket.h>
33
34#if defined(__alpha__)
35# define UV__O_CLOEXEC 0x200000
36#elif defined(__hppa__)
37# define UV__O_CLOEXEC 0x200000
38#elif defined(__sparc__)
39# define UV__O_CLOEXEC 0x400000
40#else
41# define UV__O_CLOEXEC 0x80000
42#endif
43
44#if defined(__alpha__)
45# define UV__O_NONBLOCK 0x4
46#elif defined(__hppa__)
47# define UV__O_NONBLOCK O_NONBLOCK
48#elif defined(__mips__)
49# define UV__O_NONBLOCK 0x80
50#elif defined(__sparc__)
51# define UV__O_NONBLOCK 0x4000
52#else
53# define UV__O_NONBLOCK 0x800
54#endif
55
56#define UV__EFD_CLOEXEC UV__O_CLOEXEC
57#define UV__EFD_NONBLOCK UV__O_NONBLOCK
58
59#define UV__IN_CLOEXEC UV__O_CLOEXEC
60#define UV__IN_NONBLOCK UV__O_NONBLOCK
61
62#define UV__SOCK_CLOEXEC UV__O_CLOEXEC
63#if defined(SOCK_NONBLOCK)
64# define UV__SOCK_NONBLOCK SOCK_NONBLOCK
65#else
66# define UV__SOCK_NONBLOCK UV__O_NONBLOCK
67#endif
68
69/* inotify flags */
70#define UV__IN_ACCESS 0x001
71#define UV__IN_MODIFY 0x002
72#define UV__IN_ATTRIB 0x004
73#define UV__IN_CLOSE_WRITE 0x008
74#define UV__IN_CLOSE_NOWRITE 0x010
75#define UV__IN_OPEN 0x020
76#define UV__IN_MOVED_FROM 0x040
77#define UV__IN_MOVED_TO 0x080
78#define UV__IN_CREATE 0x100
79#define UV__IN_DELETE 0x200
80#define UV__IN_DELETE_SELF 0x400
81#define UV__IN_MOVE_SELF 0x800
82
83struct uv__statx_timestamp {
84 int64_t tv_sec;
85 uint32_t tv_nsec;
86 int32_t unused0;
87};
88
89struct uv__statx {
90 uint32_t stx_mask;
91 uint32_t stx_blksize;
92 uint64_t stx_attributes;
93 uint32_t stx_nlink;
94 uint32_t stx_uid;
95 uint32_t stx_gid;
96 uint16_t stx_mode;
97 uint16_t unused0;
98 uint64_t stx_ino;
99 uint64_t stx_size;
100 uint64_t stx_blocks;
101 uint64_t stx_attributes_mask;
102 struct uv__statx_timestamp stx_atime;
103 struct uv__statx_timestamp stx_btime;
104 struct uv__statx_timestamp stx_ctime;
105 struct uv__statx_timestamp stx_mtime;
106 uint32_t stx_rdev_major;
107 uint32_t stx_rdev_minor;
108 uint32_t stx_dev_major;
109 uint32_t stx_dev_minor;
110 uint64_t unused1[14];
111};
112
113struct uv__inotify_event {
114 int32_t wd;
115 uint32_t mask;
116 uint32_t cookie;
117 uint32_t len;
118 /* char name[0]; */
119};
120
121struct uv__mmsghdr {
122 struct msghdr msg_hdr;
123 unsigned int msg_len;
124};
125
126int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags);
127int uv__eventfd(unsigned int count);
128int uv__eventfd2(unsigned int count, int flags);
129int uv__inotify_init(void);
130int uv__inotify_init1(int flags);
131int uv__inotify_add_watch(int fd, const char* path, uint32_t mask);
132int uv__inotify_rm_watch(int fd, int32_t wd);
133int uv__pipe2(int pipefd[2], int flags);
134int uv__recvmmsg(int fd,
135 struct uv__mmsghdr* mmsg,
136 unsigned int vlen,
137 unsigned int flags,
138 struct timespec* timeout);
139int uv__sendmmsg(int fd,
140 struct uv__mmsghdr* mmsg,
141 unsigned int vlen,
142 unsigned int flags);
143ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, int64_t offset);
144ssize_t uv__pwritev(int fd, const struct iovec *iov, int iovcnt, int64_t offset);
145int uv__dup3(int oldfd, int newfd, int flags);
146int uv__statx(int dirfd,
147 const char* path,
148 int flags,
149 unsigned int mask,
150 struct uv__statx* statxbuf);
151
152#endif /* UV_LINUX_SYSCALL_H_ */
153