passenger 5.0.8 → 5.0.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (168) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/.editorconfig +20 -0
  5. data/CHANGELOG +21 -0
  6. data/bin/passenger-install-apache2-module +3 -1
  7. data/build/agents.rb +7 -5
  8. data/build/basics.rb +3 -3
  9. data/build/common_library.rb +52 -30
  10. data/build/cxx_tests.rb +20 -13
  11. data/build/misc.rb +5 -5
  12. data/doc/Design and Architecture.html +1 -1
  13. data/doc/Design and Architecture.txt +1 -1
  14. data/doc/Packaging.html +4 -4
  15. data/doc/Packaging.txt.md +4 -4
  16. data/doc/Users guide Apache.html +22 -9
  17. data/doc/Users guide Apache.idmap.txt +4 -2
  18. data/doc/Users guide Apache.txt +2 -0
  19. data/doc/Users guide Nginx.html +22 -9
  20. data/doc/Users guide Nginx.idmap.txt +4 -2
  21. data/doc/Users guide Nginx.txt +2 -0
  22. data/doc/Users guide Standalone.html +14 -9
  23. data/doc/Users guide Standalone.idmap.txt +4 -2
  24. data/doc/users_guide_snippets/installation.txt +10 -6
  25. data/ext/apache2/Hooks.cpp +13 -2
  26. data/ext/common/ApplicationPool2/Pool/Inspection.h +8 -3
  27. data/ext/common/BackgroundEventLoop.cpp +249 -67
  28. data/ext/common/BackgroundEventLoop.h +5 -5
  29. data/ext/common/Constants.h +1 -1
  30. data/ext/common/InstanceDirectory.h +8 -6
  31. data/ext/common/ServerKit/Context.h +8 -2
  32. data/ext/common/ServerKit/FileBufferedChannel.h +262 -226
  33. data/ext/common/ServerKit/HeaderTable.h +28 -3
  34. data/ext/common/ServerKit/HttpHeaderParser.h +37 -13
  35. data/ext/common/ServerKit/HttpServer.h +17 -1
  36. data/ext/common/ServerKit/Implementation.cpp +2 -0
  37. data/ext/common/ServerKit/Server.h +25 -28
  38. data/ext/common/Utils/IOUtils.cpp +11 -0
  39. data/ext/common/Utils/ProcessMetricsCollector.h +4 -0
  40. data/ext/common/Utils/StrIntUtils.cpp +11 -7
  41. data/ext/common/Utils/StrIntUtils.h +1 -1
  42. data/ext/common/Utils/StrIntUtilsNoStrictAliasing.cpp +21 -16
  43. data/ext/common/agents/Base.cpp +6 -0
  44. data/ext/common/agents/Base.h +2 -0
  45. data/ext/common/agents/HelperAgent/AdminServer.h +25 -25
  46. data/ext/common/agents/HelperAgent/Main.cpp +37 -12
  47. data/ext/common/agents/HelperAgent/RequestHandler.h +18 -20
  48. data/ext/common/agents/HelperAgent/RequestHandler/AppResponse.h +4 -0
  49. data/ext/common/agents/HelperAgent/RequestHandler/ForwardResponse.cpp +10 -6
  50. data/ext/common/agents/HelperAgent/RequestHandler/Hooks.cpp +2 -0
  51. data/ext/common/agents/HelperAgent/RequestHandler/InitRequest.cpp +1 -1
  52. data/ext/common/agents/HelperAgent/RequestHandler/SendRequest.cpp +1 -1
  53. data/ext/common/agents/HelperAgent/RequestHandler/Utils.cpp +9 -2
  54. data/ext/common/agents/HelperAgent/ResponseCache.h +11 -11
  55. data/ext/common/agents/LoggingAgent/AdminServer.h +8 -8
  56. data/ext/common/agents/LoggingAgent/Main.cpp +6 -5
  57. data/ext/common/agents/Watchdog/AdminServer.h +13 -13
  58. data/ext/common/agents/Watchdog/Main.cpp +8 -3
  59. data/ext/libuv/.gitignore +72 -0
  60. data/ext/libuv/AUTHORS +199 -0
  61. data/ext/libuv/ChangeLog +2023 -0
  62. data/ext/libuv/LICENSE +46 -0
  63. data/ext/libuv/Makefile.am +336 -0
  64. data/ext/libuv/README.md +197 -0
  65. data/ext/libuv/checksparse.sh +233 -0
  66. data/ext/libuv/common.gypi +210 -0
  67. data/ext/libuv/configure.ac +67 -0
  68. data/ext/libuv/gyp_uv.py +96 -0
  69. data/ext/libuv/include/android-ifaddrs.h +54 -0
  70. data/ext/libuv/include/pthread-fixes.h +72 -0
  71. data/ext/libuv/include/tree.h +768 -0
  72. data/ext/libuv/include/uv-aix.h +32 -0
  73. data/ext/libuv/include/uv-bsd.h +34 -0
  74. data/ext/libuv/include/uv-darwin.h +61 -0
  75. data/ext/libuv/include/uv-errno.h +418 -0
  76. data/ext/libuv/include/uv-linux.h +34 -0
  77. data/ext/libuv/include/uv-sunos.h +44 -0
  78. data/ext/libuv/include/uv-threadpool.h +37 -0
  79. data/ext/libuv/include/uv-unix.h +383 -0
  80. data/ext/libuv/include/uv-version.h +39 -0
  81. data/ext/libuv/include/uv.h +1455 -0
  82. data/ext/libuv/libuv.pc.in +11 -0
  83. data/ext/libuv/m4/.gitignore +4 -0
  84. data/ext/libuv/m4/as_case.m4 +21 -0
  85. data/ext/libuv/m4/libuv-check-flags.m4 +319 -0
  86. data/ext/libuv/src/fs-poll.c +255 -0
  87. data/ext/libuv/src/heap-inl.h +245 -0
  88. data/ext/libuv/src/inet.c +313 -0
  89. data/ext/libuv/src/queue.h +92 -0
  90. data/ext/libuv/src/threadpool.c +303 -0
  91. data/ext/libuv/src/unix/aix.c +1240 -0
  92. data/ext/libuv/src/unix/android-ifaddrs.c +703 -0
  93. data/ext/libuv/src/unix/async.c +284 -0
  94. data/ext/libuv/src/unix/atomic-ops.h +60 -0
  95. data/ext/libuv/src/unix/core.c +985 -0
  96. data/ext/libuv/src/unix/darwin-proctitle.c +206 -0
  97. data/ext/libuv/src/unix/darwin.c +331 -0
  98. data/ext/libuv/src/unix/dl.c +83 -0
  99. data/ext/libuv/src/unix/freebsd.c +435 -0
  100. data/ext/libuv/src/unix/fs.c +1189 -0
  101. data/ext/libuv/src/unix/fsevents.c +899 -0
  102. data/ext/libuv/src/unix/getaddrinfo.c +202 -0
  103. data/ext/libuv/src/unix/getnameinfo.c +120 -0
  104. data/ext/libuv/src/unix/internal.h +314 -0
  105. data/ext/libuv/src/unix/kqueue.c +418 -0
  106. data/ext/libuv/src/unix/linux-core.c +876 -0
  107. data/ext/libuv/src/unix/linux-inotify.c +257 -0
  108. data/ext/libuv/src/unix/linux-syscalls.c +471 -0
  109. data/ext/libuv/src/unix/linux-syscalls.h +158 -0
  110. data/ext/libuv/src/unix/loop-watcher.c +63 -0
  111. data/ext/libuv/src/unix/loop.c +135 -0
  112. data/ext/libuv/src/unix/netbsd.c +368 -0
  113. data/ext/libuv/src/unix/openbsd.c +384 -0
  114. data/ext/libuv/src/unix/pipe.c +288 -0
  115. data/ext/libuv/src/unix/poll.c +113 -0
  116. data/ext/libuv/src/unix/process.c +551 -0
  117. data/ext/libuv/src/unix/proctitle.c +102 -0
  118. data/ext/libuv/src/unix/pthread-fixes.c +103 -0
  119. data/ext/libuv/src/unix/signal.c +465 -0
  120. data/ext/libuv/src/unix/spinlock.h +53 -0
  121. data/ext/libuv/src/unix/stream.c +1598 -0
  122. data/ext/libuv/src/unix/sunos.c +763 -0
  123. data/ext/libuv/src/unix/tcp.c +327 -0
  124. data/ext/libuv/src/unix/thread.c +519 -0
  125. data/ext/libuv/src/unix/timer.c +172 -0
  126. data/ext/libuv/src/unix/tty.c +265 -0
  127. data/ext/libuv/src/unix/udp.c +833 -0
  128. data/ext/libuv/src/uv-common.c +544 -0
  129. data/ext/libuv/src/uv-common.h +214 -0
  130. data/ext/libuv/src/version.c +49 -0
  131. data/ext/libuv/uv.gyp +487 -0
  132. data/ext/nginx/ContentHandler.c +21 -10
  133. data/ext/nginx/ngx_http_passenger_module.c +7 -0
  134. data/ext/oxt/implementation.cpp +9 -2
  135. data/ext/oxt/initialize.hpp +5 -1
  136. data/lib/phusion_passenger.rb +3 -3
  137. data/lib/phusion_passenger/admin_tools/instance.rb +10 -6
  138. data/lib/phusion_passenger/admin_tools/instance_registry.rb +6 -2
  139. data/lib/phusion_passenger/packaging.rb +3 -4
  140. data/lib/phusion_passenger/platform_info.rb +13 -1
  141. data/lib/phusion_passenger/platform_info/apache.rb +15 -4
  142. data/lib/phusion_passenger/platform_info/apache_detector.rb +5 -1
  143. data/lib/phusion_passenger/rack/thread_handler_extension.rb +184 -99
  144. data/lib/phusion_passenger/request_handler/thread_handler.rb +13 -6
  145. data/lib/phusion_passenger/standalone/start_command.rb +2 -2
  146. data/resources/templates/apache2/apache_install_broken.txt.erb +2 -1
  147. metadata +99 -22
  148. metadata.gz.asc +7 -7
  149. data/ext/libeio/Changes +0 -76
  150. data/ext/libeio/LICENSE +0 -36
  151. data/ext/libeio/Makefile.am +0 -15
  152. data/ext/libeio/Makefile.in +0 -694
  153. data/ext/libeio/aclocal.m4 +0 -9418
  154. data/ext/libeio/autogen.sh +0 -3
  155. data/ext/libeio/config.guess +0 -1540
  156. data/ext/libeio/config.h.in +0 -136
  157. data/ext/libeio/config.sub +0 -1779
  158. data/ext/libeio/configure +0 -14822
  159. data/ext/libeio/configure.ac +0 -22
  160. data/ext/libeio/demo.c +0 -194
  161. data/ext/libeio/ecb.h +0 -714
  162. data/ext/libeio/eio.c +0 -2818
  163. data/ext/libeio/eio.h +0 -414
  164. data/ext/libeio/install-sh +0 -520
  165. data/ext/libeio/libeio.m4 +0 -195
  166. data/ext/libeio/ltmain.sh +0 -9636
  167. data/ext/libeio/missing +0 -376
  168. data/ext/libeio/xthread.h +0 -166
@@ -0,0 +1,257 @@
1
+ /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ * of this software and associated documentation files (the "Software"), to
4
+ * deal in the Software without restriction, including without limitation the
5
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6
+ * sell copies of the Software, and to permit persons to whom the Software is
7
+ * furnished to do so, subject to the following conditions:
8
+ *
9
+ * The above copyright notice and this permission notice shall be included in
10
+ * all copies or substantial portions of the Software.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
18
+ * IN THE SOFTWARE.
19
+ */
20
+
21
+ #include "uv.h"
22
+ #include "tree.h"
23
+ #include "internal.h"
24
+
25
+ #include <stdint.h>
26
+ #include <stdio.h>
27
+ #include <stdlib.h>
28
+ #include <string.h>
29
+ #include <assert.h>
30
+ #include <errno.h>
31
+
32
+ #include <sys/types.h>
33
+ #include <unistd.h>
34
+
35
+ struct watcher_list {
36
+ RB_ENTRY(watcher_list) entry;
37
+ QUEUE watchers;
38
+ char* path;
39
+ int wd;
40
+ };
41
+
42
+ struct watcher_root {
43
+ struct watcher_list* rbh_root;
44
+ };
45
+ #define CAST(p) ((struct watcher_root*)(p))
46
+
47
+
48
+ static int compare_watchers(const struct watcher_list* a,
49
+ const struct watcher_list* b) {
50
+ if (a->wd < b->wd) return -1;
51
+ if (a->wd > b->wd) return 1;
52
+ return 0;
53
+ }
54
+
55
+
56
+ RB_GENERATE_STATIC(watcher_root, watcher_list, entry, compare_watchers)
57
+
58
+
59
+ static void uv__inotify_read(uv_loop_t* loop,
60
+ uv__io_t* w,
61
+ unsigned int revents);
62
+
63
+
64
+ static int new_inotify_fd(void) {
65
+ int err;
66
+ int fd;
67
+
68
+ fd = uv__inotify_init1(UV__IN_NONBLOCK | UV__IN_CLOEXEC);
69
+ if (fd != -1)
70
+ return fd;
71
+
72
+ if (errno != ENOSYS)
73
+ return -errno;
74
+
75
+ fd = uv__inotify_init();
76
+ if (fd == -1)
77
+ return -errno;
78
+
79
+ err = uv__cloexec(fd, 1);
80
+ if (err == 0)
81
+ err = uv__nonblock(fd, 1);
82
+
83
+ if (err) {
84
+ uv__close(fd);
85
+ return err;
86
+ }
87
+
88
+ return fd;
89
+ }
90
+
91
+
92
+ static int init_inotify(uv_loop_t* loop) {
93
+ int err;
94
+
95
+ if (loop->inotify_fd != -1)
96
+ return 0;
97
+
98
+ err = new_inotify_fd();
99
+ if (err < 0)
100
+ return err;
101
+
102
+ loop->inotify_fd = err;
103
+ uv__io_init(&loop->inotify_read_watcher, uv__inotify_read, loop->inotify_fd);
104
+ uv__io_start(loop, &loop->inotify_read_watcher, UV__POLLIN);
105
+
106
+ return 0;
107
+ }
108
+
109
+
110
+ static struct watcher_list* find_watcher(uv_loop_t* loop, int wd) {
111
+ struct watcher_list w;
112
+ w.wd = wd;
113
+ return RB_FIND(watcher_root, CAST(&loop->inotify_watchers), &w);
114
+ }
115
+
116
+
117
+ static void uv__inotify_read(uv_loop_t* loop,
118
+ uv__io_t* dummy,
119
+ unsigned int events) {
120
+ const struct uv__inotify_event* e;
121
+ struct watcher_list* w;
122
+ uv_fs_event_t* h;
123
+ QUEUE* q;
124
+ const char* path;
125
+ ssize_t size;
126
+ const char *p;
127
+ /* needs to be large enough for sizeof(inotify_event) + strlen(path) */
128
+ char buf[4096];
129
+
130
+ while (1) {
131
+ do
132
+ size = read(loop->inotify_fd, buf, sizeof(buf));
133
+ while (size == -1 && errno == EINTR);
134
+
135
+ if (size == -1) {
136
+ assert(errno == EAGAIN || errno == EWOULDBLOCK);
137
+ break;
138
+ }
139
+
140
+ assert(size > 0); /* pre-2.6.21 thing, size=0 == read buffer too small */
141
+
142
+ /* Now we have one or more inotify_event structs. */
143
+ for (p = buf; p < buf + size; p += sizeof(*e) + e->len) {
144
+ e = (const struct uv__inotify_event*)p;
145
+
146
+ events = 0;
147
+ if (e->mask & (UV__IN_ATTRIB|UV__IN_MODIFY))
148
+ events |= UV_CHANGE;
149
+ if (e->mask & ~(UV__IN_ATTRIB|UV__IN_MODIFY))
150
+ events |= UV_RENAME;
151
+
152
+ w = find_watcher(loop, e->wd);
153
+ if (w == NULL)
154
+ continue; /* Stale event, no watchers left. */
155
+
156
+ /* inotify does not return the filename when monitoring a single file
157
+ * for modifications. Repurpose the filename for API compatibility.
158
+ * I'm not convinced this is a good thing, maybe it should go.
159
+ */
160
+ path = e->len ? (const char*) (e + 1) : uv__basename_r(w->path);
161
+
162
+ QUEUE_FOREACH(q, &w->watchers) {
163
+ h = QUEUE_DATA(q, uv_fs_event_t, watchers);
164
+ h->cb(h, path, events, 0);
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+
171
+ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
172
+ uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT);
173
+ return 0;
174
+ }
175
+
176
+
177
+ int uv_fs_event_start(uv_fs_event_t* handle,
178
+ uv_fs_event_cb cb,
179
+ const char* path,
180
+ unsigned int flags) {
181
+ struct watcher_list* w;
182
+ int events;
183
+ int err;
184
+ int wd;
185
+
186
+ if (uv__is_active(handle))
187
+ return -EINVAL;
188
+
189
+ err = init_inotify(handle->loop);
190
+ if (err)
191
+ return err;
192
+
193
+ events = UV__IN_ATTRIB
194
+ | UV__IN_CREATE
195
+ | UV__IN_MODIFY
196
+ | UV__IN_DELETE
197
+ | UV__IN_DELETE_SELF
198
+ | UV__IN_MOVE_SELF
199
+ | UV__IN_MOVED_FROM
200
+ | UV__IN_MOVED_TO;
201
+
202
+ wd = uv__inotify_add_watch(handle->loop->inotify_fd, path, events);
203
+ if (wd == -1)
204
+ return -errno;
205
+
206
+ w = find_watcher(handle->loop, wd);
207
+ if (w)
208
+ goto no_insert;
209
+
210
+ w = malloc(sizeof(*w) + strlen(path) + 1);
211
+ if (w == NULL)
212
+ return -ENOMEM;
213
+
214
+ w->wd = wd;
215
+ w->path = strcpy((char*)(w + 1), path);
216
+ QUEUE_INIT(&w->watchers);
217
+ RB_INSERT(watcher_root, CAST(&handle->loop->inotify_watchers), w);
218
+
219
+ no_insert:
220
+ uv__handle_start(handle);
221
+ QUEUE_INSERT_TAIL(&w->watchers, &handle->watchers);
222
+ handle->path = w->path;
223
+ handle->cb = cb;
224
+ handle->wd = wd;
225
+
226
+ return 0;
227
+ }
228
+
229
+
230
+ int uv_fs_event_stop(uv_fs_event_t* handle) {
231
+ struct watcher_list* w;
232
+
233
+ if (!uv__is_active(handle))
234
+ return 0;
235
+
236
+ w = find_watcher(handle->loop, handle->wd);
237
+ assert(w != NULL);
238
+
239
+ handle->wd = -1;
240
+ handle->path = NULL;
241
+ uv__handle_stop(handle);
242
+ QUEUE_REMOVE(&handle->watchers);
243
+
244
+ if (QUEUE_EMPTY(&w->watchers)) {
245
+ /* No watchers left for this path. Clean up. */
246
+ RB_REMOVE(watcher_root, CAST(&handle->loop->inotify_watchers), w);
247
+ uv__inotify_rm_watch(handle->loop->inotify_fd, w->wd);
248
+ free(w);
249
+ }
250
+
251
+ return 0;
252
+ }
253
+
254
+
255
+ void uv__fs_event_close(uv_fs_event_t* handle) {
256
+ uv_fs_event_stop(handle);
257
+ }
@@ -0,0 +1,471 @@
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
+ #include "linux-syscalls.h"
23
+ #include <unistd.h>
24
+ #include <signal.h>
25
+ #include <sys/syscall.h>
26
+ #include <sys/types.h>
27
+ #include <errno.h>
28
+
29
+ #if defined(__has_feature)
30
+ # if __has_feature(memory_sanitizer)
31
+ # define MSAN_ACTIVE 1
32
+ # include <sanitizer/msan_interface.h>
33
+ # endif
34
+ #endif
35
+
36
+ #if defined(__i386__)
37
+ # ifndef __NR_socketcall
38
+ # define __NR_socketcall 102
39
+ # endif
40
+ #endif
41
+
42
+ #if defined(__arm__)
43
+ # if defined(__thumb__) || defined(__ARM_EABI__)
44
+ # define UV_SYSCALL_BASE 0
45
+ # else
46
+ # define UV_SYSCALL_BASE 0x900000
47
+ # endif
48
+ #endif /* __arm__ */
49
+
50
+ #ifndef __NR_accept4
51
+ # if defined(__x86_64__)
52
+ # define __NR_accept4 288
53
+ # elif defined(__i386__)
54
+ /* Nothing. Handled through socketcall(). */
55
+ # elif defined(__arm__)
56
+ # define __NR_accept4 (UV_SYSCALL_BASE + 366)
57
+ # endif
58
+ #endif /* __NR_accept4 */
59
+
60
+ #ifndef __NR_eventfd
61
+ # if defined(__x86_64__)
62
+ # define __NR_eventfd 284
63
+ # elif defined(__i386__)
64
+ # define __NR_eventfd 323
65
+ # elif defined(__arm__)
66
+ # define __NR_eventfd (UV_SYSCALL_BASE + 351)
67
+ # endif
68
+ #endif /* __NR_eventfd */
69
+
70
+ #ifndef __NR_eventfd2
71
+ # if defined(__x86_64__)
72
+ # define __NR_eventfd2 290
73
+ # elif defined(__i386__)
74
+ # define __NR_eventfd2 328
75
+ # elif defined(__arm__)
76
+ # define __NR_eventfd2 (UV_SYSCALL_BASE + 356)
77
+ # endif
78
+ #endif /* __NR_eventfd2 */
79
+
80
+ #ifndef __NR_epoll_create
81
+ # if defined(__x86_64__)
82
+ # define __NR_epoll_create 213
83
+ # elif defined(__i386__)
84
+ # define __NR_epoll_create 254
85
+ # elif defined(__arm__)
86
+ # define __NR_epoll_create (UV_SYSCALL_BASE + 250)
87
+ # endif
88
+ #endif /* __NR_epoll_create */
89
+
90
+ #ifndef __NR_epoll_create1
91
+ # if defined(__x86_64__)
92
+ # define __NR_epoll_create1 291
93
+ # elif defined(__i386__)
94
+ # define __NR_epoll_create1 329
95
+ # elif defined(__arm__)
96
+ # define __NR_epoll_create1 (UV_SYSCALL_BASE + 357)
97
+ # endif
98
+ #endif /* __NR_epoll_create1 */
99
+
100
+ #ifndef __NR_epoll_ctl
101
+ # if defined(__x86_64__)
102
+ # define __NR_epoll_ctl 233 /* used to be 214 */
103
+ # elif defined(__i386__)
104
+ # define __NR_epoll_ctl 255
105
+ # elif defined(__arm__)
106
+ # define __NR_epoll_ctl (UV_SYSCALL_BASE + 251)
107
+ # endif
108
+ #endif /* __NR_epoll_ctl */
109
+
110
+ #ifndef __NR_epoll_wait
111
+ # if defined(__x86_64__)
112
+ # define __NR_epoll_wait 232 /* used to be 215 */
113
+ # elif defined(__i386__)
114
+ # define __NR_epoll_wait 256
115
+ # elif defined(__arm__)
116
+ # define __NR_epoll_wait (UV_SYSCALL_BASE + 252)
117
+ # endif
118
+ #endif /* __NR_epoll_wait */
119
+
120
+ #ifndef __NR_epoll_pwait
121
+ # if defined(__x86_64__)
122
+ # define __NR_epoll_pwait 281
123
+ # elif defined(__i386__)
124
+ # define __NR_epoll_pwait 319
125
+ # elif defined(__arm__)
126
+ # define __NR_epoll_pwait (UV_SYSCALL_BASE + 346)
127
+ # endif
128
+ #endif /* __NR_epoll_pwait */
129
+
130
+ #ifndef __NR_inotify_init
131
+ # if defined(__x86_64__)
132
+ # define __NR_inotify_init 253
133
+ # elif defined(__i386__)
134
+ # define __NR_inotify_init 291
135
+ # elif defined(__arm__)
136
+ # define __NR_inotify_init (UV_SYSCALL_BASE + 316)
137
+ # endif
138
+ #endif /* __NR_inotify_init */
139
+
140
+ #ifndef __NR_inotify_init1
141
+ # if defined(__x86_64__)
142
+ # define __NR_inotify_init1 294
143
+ # elif defined(__i386__)
144
+ # define __NR_inotify_init1 332
145
+ # elif defined(__arm__)
146
+ # define __NR_inotify_init1 (UV_SYSCALL_BASE + 360)
147
+ # endif
148
+ #endif /* __NR_inotify_init1 */
149
+
150
+ #ifndef __NR_inotify_add_watch
151
+ # if defined(__x86_64__)
152
+ # define __NR_inotify_add_watch 254
153
+ # elif defined(__i386__)
154
+ # define __NR_inotify_add_watch 292
155
+ # elif defined(__arm__)
156
+ # define __NR_inotify_add_watch (UV_SYSCALL_BASE + 317)
157
+ # endif
158
+ #endif /* __NR_inotify_add_watch */
159
+
160
+ #ifndef __NR_inotify_rm_watch
161
+ # if defined(__x86_64__)
162
+ # define __NR_inotify_rm_watch 255
163
+ # elif defined(__i386__)
164
+ # define __NR_inotify_rm_watch 293
165
+ # elif defined(__arm__)
166
+ # define __NR_inotify_rm_watch (UV_SYSCALL_BASE + 318)
167
+ # endif
168
+ #endif /* __NR_inotify_rm_watch */
169
+
170
+ #ifndef __NR_pipe2
171
+ # if defined(__x86_64__)
172
+ # define __NR_pipe2 293
173
+ # elif defined(__i386__)
174
+ # define __NR_pipe2 331
175
+ # elif defined(__arm__)
176
+ # define __NR_pipe2 (UV_SYSCALL_BASE + 359)
177
+ # endif
178
+ #endif /* __NR_pipe2 */
179
+
180
+ #ifndef __NR_recvmmsg
181
+ # if defined(__x86_64__)
182
+ # define __NR_recvmmsg 299
183
+ # elif defined(__i386__)
184
+ # define __NR_recvmmsg 337
185
+ # elif defined(__arm__)
186
+ # define __NR_recvmmsg (UV_SYSCALL_BASE + 365)
187
+ # endif
188
+ #endif /* __NR_recvmsg */
189
+
190
+ #ifndef __NR_sendmmsg
191
+ # if defined(__x86_64__)
192
+ # define __NR_sendmmsg 307
193
+ # elif defined(__i386__)
194
+ # define __NR_sendmmsg 345
195
+ # elif defined(__arm__)
196
+ # define __NR_sendmmsg (UV_SYSCALL_BASE + 374)
197
+ # endif
198
+ #endif /* __NR_sendmmsg */
199
+
200
+ #ifndef __NR_utimensat
201
+ # if defined(__x86_64__)
202
+ # define __NR_utimensat 280
203
+ # elif defined(__i386__)
204
+ # define __NR_utimensat 320
205
+ # elif defined(__arm__)
206
+ # define __NR_utimensat (UV_SYSCALL_BASE + 348)
207
+ # endif
208
+ #endif /* __NR_utimensat */
209
+
210
+ #ifndef __NR_preadv
211
+ # if defined(__x86_64__)
212
+ # define __NR_preadv 295
213
+ # elif defined(__i386__)
214
+ # define __NR_preadv 333
215
+ # elif defined(__arm__)
216
+ # define __NR_preadv (UV_SYSCALL_BASE + 361)
217
+ # endif
218
+ #endif /* __NR_preadv */
219
+
220
+ #ifndef __NR_pwritev
221
+ # if defined(__x86_64__)
222
+ # define __NR_pwritev 296
223
+ # elif defined(__i386__)
224
+ # define __NR_pwritev 334
225
+ # elif defined(__arm__)
226
+ # define __NR_pwritev (UV_SYSCALL_BASE + 362)
227
+ # endif
228
+ #endif /* __NR_pwritev */
229
+
230
+ #ifndef __NR_dup3
231
+ # if defined(__x86_64__)
232
+ # define __NR_dup3 292
233
+ # elif defined(__i386__)
234
+ # define __NR_dup3 330
235
+ # elif defined(__arm__)
236
+ # define __NR_dup3 (UV_SYSCALL_BASE + 358)
237
+ # endif
238
+ #endif /* __NR_pwritev */
239
+
240
+
241
+ int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags) {
242
+ #if defined(__i386__)
243
+ unsigned long args[4];
244
+ int r;
245
+
246
+ args[0] = (unsigned long) fd;
247
+ args[1] = (unsigned long) addr;
248
+ args[2] = (unsigned long) addrlen;
249
+ args[3] = (unsigned long) flags;
250
+
251
+ r = syscall(__NR_socketcall, 18 /* SYS_ACCEPT4 */, args);
252
+
253
+ /* socketcall() raises EINVAL when SYS_ACCEPT4 is not supported but so does
254
+ * a bad flags argument. Try to distinguish between the two cases.
255
+ */
256
+ if (r == -1)
257
+ if (errno == EINVAL)
258
+ if ((flags & ~(UV__SOCK_CLOEXEC|UV__SOCK_NONBLOCK)) == 0)
259
+ errno = ENOSYS;
260
+
261
+ return r;
262
+ #elif defined(__NR_accept4)
263
+ return syscall(__NR_accept4, fd, addr, addrlen, flags);
264
+ #else
265
+ return errno = ENOSYS, -1;
266
+ #endif
267
+ }
268
+
269
+
270
+ int uv__eventfd(unsigned int count) {
271
+ #if defined(__NR_eventfd)
272
+ return syscall(__NR_eventfd, count);
273
+ #else
274
+ return errno = ENOSYS, -1;
275
+ #endif
276
+ }
277
+
278
+
279
+ int uv__eventfd2(unsigned int count, int flags) {
280
+ #if defined(__NR_eventfd2)
281
+ return syscall(__NR_eventfd2, count, flags);
282
+ #else
283
+ return errno = ENOSYS, -1;
284
+ #endif
285
+ }
286
+
287
+
288
+ int uv__epoll_create(int size) {
289
+ #if defined(__NR_epoll_create)
290
+ return syscall(__NR_epoll_create, size);
291
+ #else
292
+ return errno = ENOSYS, -1;
293
+ #endif
294
+ }
295
+
296
+
297
+ int uv__epoll_create1(int flags) {
298
+ #if defined(__NR_epoll_create1)
299
+ return syscall(__NR_epoll_create1, flags);
300
+ #else
301
+ return errno = ENOSYS, -1;
302
+ #endif
303
+ }
304
+
305
+
306
+ int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event* events) {
307
+ #if defined(__NR_epoll_ctl)
308
+ return syscall(__NR_epoll_ctl, epfd, op, fd, events);
309
+ #else
310
+ return errno = ENOSYS, -1;
311
+ #endif
312
+ }
313
+
314
+
315
+ int uv__epoll_wait(int epfd,
316
+ struct uv__epoll_event* events,
317
+ int nevents,
318
+ int timeout) {
319
+ #if defined(__NR_epoll_wait)
320
+ int result;
321
+ result = syscall(__NR_epoll_wait, epfd, events, nevents, timeout);
322
+ #if MSAN_ACTIVE
323
+ if (result > 0)
324
+ __msan_unpoison(events, sizeof(events[0]) * result);
325
+ #endif
326
+ return result;
327
+ #else
328
+ return errno = ENOSYS, -1;
329
+ #endif
330
+ }
331
+
332
+
333
+ int uv__epoll_pwait(int epfd,
334
+ struct uv__epoll_event* events,
335
+ int nevents,
336
+ int timeout,
337
+ uint64_t sigmask) {
338
+ #if defined(__NR_epoll_pwait)
339
+ int result;
340
+ result = syscall(__NR_epoll_pwait,
341
+ epfd,
342
+ events,
343
+ nevents,
344
+ timeout,
345
+ &sigmask,
346
+ sizeof(sigmask));
347
+ #if MSAN_ACTIVE
348
+ if (result > 0)
349
+ __msan_unpoison(events, sizeof(events[0]) * result);
350
+ #endif
351
+ return result;
352
+ #else
353
+ return errno = ENOSYS, -1;
354
+ #endif
355
+ }
356
+
357
+
358
+ int uv__inotify_init(void) {
359
+ #if defined(__NR_inotify_init)
360
+ return syscall(__NR_inotify_init);
361
+ #else
362
+ return errno = ENOSYS, -1;
363
+ #endif
364
+ }
365
+
366
+
367
+ int uv__inotify_init1(int flags) {
368
+ #if defined(__NR_inotify_init1)
369
+ return syscall(__NR_inotify_init1, flags);
370
+ #else
371
+ return errno = ENOSYS, -1;
372
+ #endif
373
+ }
374
+
375
+
376
+ int uv__inotify_add_watch(int fd, const char* path, uint32_t mask) {
377
+ #if defined(__NR_inotify_add_watch)
378
+ return syscall(__NR_inotify_add_watch, fd, path, mask);
379
+ #else
380
+ return errno = ENOSYS, -1;
381
+ #endif
382
+ }
383
+
384
+
385
+ int uv__inotify_rm_watch(int fd, int32_t wd) {
386
+ #if defined(__NR_inotify_rm_watch)
387
+ return syscall(__NR_inotify_rm_watch, fd, wd);
388
+ #else
389
+ return errno = ENOSYS, -1;
390
+ #endif
391
+ }
392
+
393
+
394
+ int uv__pipe2(int pipefd[2], int flags) {
395
+ #if defined(__NR_pipe2)
396
+ int result;
397
+ result = syscall(__NR_pipe2, pipefd, flags);
398
+ #if MSAN_ACTIVE
399
+ if (!result)
400
+ __msan_unpoison(pipefd, sizeof(int[2]));
401
+ #endif
402
+ return result;
403
+ #else
404
+ return errno = ENOSYS, -1;
405
+ #endif
406
+ }
407
+
408
+
409
+ int uv__sendmmsg(int fd,
410
+ struct uv__mmsghdr* mmsg,
411
+ unsigned int vlen,
412
+ unsigned int flags) {
413
+ #if defined(__NR_sendmmsg)
414
+ return syscall(__NR_sendmmsg, fd, mmsg, vlen, flags);
415
+ #else
416
+ return errno = ENOSYS, -1;
417
+ #endif
418
+ }
419
+
420
+
421
+ int uv__recvmmsg(int fd,
422
+ struct uv__mmsghdr* mmsg,
423
+ unsigned int vlen,
424
+ unsigned int flags,
425
+ struct timespec* timeout) {
426
+ #if defined(__NR_recvmmsg)
427
+ return syscall(__NR_recvmmsg, fd, mmsg, vlen, flags, timeout);
428
+ #else
429
+ return errno = ENOSYS, -1;
430
+ #endif
431
+ }
432
+
433
+
434
+ int uv__utimesat(int dirfd,
435
+ const char* path,
436
+ const struct timespec times[2],
437
+ int flags)
438
+ {
439
+ #if defined(__NR_utimensat)
440
+ return syscall(__NR_utimensat, dirfd, path, times, flags);
441
+ #else
442
+ return errno = ENOSYS, -1;
443
+ #endif
444
+ }
445
+
446
+
447
+ ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset) {
448
+ #if defined(__NR_preadv)
449
+ return syscall(__NR_preadv, fd, iov, iovcnt, offset);
450
+ #else
451
+ return errno = ENOSYS, -1;
452
+ #endif
453
+ }
454
+
455
+
456
+ ssize_t uv__pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset) {
457
+ #if defined(__NR_pwritev)
458
+ return syscall(__NR_pwritev, fd, iov, iovcnt, offset);
459
+ #else
460
+ return errno = ENOSYS, -1;
461
+ #endif
462
+ }
463
+
464
+
465
+ int uv__dup3(int oldfd, int newfd, int flags) {
466
+ #if defined(__NR_dup3)
467
+ return syscall(__NR_dup3, oldfd, newfd, flags);
468
+ #else
469
+ return errno = ENOSYS, -1;
470
+ #endif
471
+ }