foolio 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. data/.gitignore +22 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +21 -0
  6. data/examples/timer.rb +20 -0
  7. data/ext/foolio/extconf.rb +34 -0
  8. data/ext/foolio/foolio_ext.c +921 -0
  9. data/ext/foolio/gen.rb +50 -0
  10. data/ext/foolio/make_table.rb +12 -0
  11. data/ext/foolio/templ +243 -0
  12. data/ext/libuv/.gitignore +33 -0
  13. data/ext/libuv/.mailmap +13 -0
  14. data/ext/libuv/.travis.yml +9 -0
  15. data/ext/libuv/AUTHORS +61 -0
  16. data/ext/libuv/LICENSE +44 -0
  17. data/ext/libuv/Makefile +71 -0
  18. data/ext/libuv/README.md +90 -0
  19. data/ext/libuv/common.gypi +178 -0
  20. data/ext/libuv/gyp_uv +73 -0
  21. data/ext/libuv/include/uv-private/eio.h +403 -0
  22. data/ext/libuv/include/uv-private/ev.h +838 -0
  23. data/ext/libuv/include/uv-private/ngx-queue.h +108 -0
  24. data/ext/libuv/include/uv-private/tree.h +768 -0
  25. data/ext/libuv/include/uv-private/uv-unix.h +324 -0
  26. data/ext/libuv/include/uv-private/uv-win.h +517 -0
  27. data/ext/libuv/include/uv.h +1838 -0
  28. data/ext/libuv/src/fs-poll.c +235 -0
  29. data/ext/libuv/src/inet.c +293 -0
  30. data/ext/libuv/src/unix/async.c +148 -0
  31. data/ext/libuv/src/unix/core.c +696 -0
  32. data/ext/libuv/src/unix/cygwin.c +83 -0
  33. data/ext/libuv/src/unix/darwin.c +342 -0
  34. data/ext/libuv/src/unix/dl.c +83 -0
  35. data/ext/libuv/src/unix/eio/Changes +63 -0
  36. data/ext/libuv/src/unix/eio/LICENSE +36 -0
  37. data/ext/libuv/src/unix/eio/Makefile.am +15 -0
  38. data/ext/libuv/src/unix/eio/aclocal.m4 +8957 -0
  39. data/ext/libuv/src/unix/eio/autogen.sh +3 -0
  40. data/ext/libuv/src/unix/eio/config.h.in +86 -0
  41. data/ext/libuv/src/unix/eio/config_cygwin.h +80 -0
  42. data/ext/libuv/src/unix/eio/config_darwin.h +141 -0
  43. data/ext/libuv/src/unix/eio/config_freebsd.h +81 -0
  44. data/ext/libuv/src/unix/eio/config_linux.h +94 -0
  45. data/ext/libuv/src/unix/eio/config_netbsd.h +81 -0
  46. data/ext/libuv/src/unix/eio/config_openbsd.h +137 -0
  47. data/ext/libuv/src/unix/eio/config_sunos.h +84 -0
  48. data/ext/libuv/src/unix/eio/configure.ac +22 -0
  49. data/ext/libuv/src/unix/eio/demo.c +194 -0
  50. data/ext/libuv/src/unix/eio/ecb.h +370 -0
  51. data/ext/libuv/src/unix/eio/eio.3 +3428 -0
  52. data/ext/libuv/src/unix/eio/eio.c +2593 -0
  53. data/ext/libuv/src/unix/eio/eio.pod +969 -0
  54. data/ext/libuv/src/unix/eio/libeio.m4 +195 -0
  55. data/ext/libuv/src/unix/eio/xthread.h +164 -0
  56. data/ext/libuv/src/unix/error.c +105 -0
  57. data/ext/libuv/src/unix/ev/Changes +388 -0
  58. data/ext/libuv/src/unix/ev/LICENSE +36 -0
  59. data/ext/libuv/src/unix/ev/Makefile.am +18 -0
  60. data/ext/libuv/src/unix/ev/Makefile.in +771 -0
  61. data/ext/libuv/src/unix/ev/README +58 -0
  62. data/ext/libuv/src/unix/ev/aclocal.m4 +8957 -0
  63. data/ext/libuv/src/unix/ev/autogen.sh +6 -0
  64. data/ext/libuv/src/unix/ev/config.guess +1526 -0
  65. data/ext/libuv/src/unix/ev/config.h.in +125 -0
  66. data/ext/libuv/src/unix/ev/config.sub +1658 -0
  67. data/ext/libuv/src/unix/ev/config_cygwin.h +123 -0
  68. data/ext/libuv/src/unix/ev/config_darwin.h +122 -0
  69. data/ext/libuv/src/unix/ev/config_freebsd.h +120 -0
  70. data/ext/libuv/src/unix/ev/config_linux.h +141 -0
  71. data/ext/libuv/src/unix/ev/config_netbsd.h +120 -0
  72. data/ext/libuv/src/unix/ev/config_openbsd.h +126 -0
  73. data/ext/libuv/src/unix/ev/config_sunos.h +122 -0
  74. data/ext/libuv/src/unix/ev/configure +13037 -0
  75. data/ext/libuv/src/unix/ev/configure.ac +18 -0
  76. data/ext/libuv/src/unix/ev/depcomp +630 -0
  77. data/ext/libuv/src/unix/ev/ev++.h +816 -0
  78. data/ext/libuv/src/unix/ev/ev.3 +5311 -0
  79. data/ext/libuv/src/unix/ev/ev.c +3925 -0
  80. data/ext/libuv/src/unix/ev/ev.pod +5243 -0
  81. data/ext/libuv/src/unix/ev/ev_epoll.c +266 -0
  82. data/ext/libuv/src/unix/ev/ev_kqueue.c +235 -0
  83. data/ext/libuv/src/unix/ev/ev_poll.c +148 -0
  84. data/ext/libuv/src/unix/ev/ev_port.c +179 -0
  85. data/ext/libuv/src/unix/ev/ev_select.c +310 -0
  86. data/ext/libuv/src/unix/ev/ev_vars.h +203 -0
  87. data/ext/libuv/src/unix/ev/ev_win32.c +153 -0
  88. data/ext/libuv/src/unix/ev/ev_wrap.h +196 -0
  89. data/ext/libuv/src/unix/ev/event.c +402 -0
  90. data/ext/libuv/src/unix/ev/event.h +170 -0
  91. data/ext/libuv/src/unix/ev/install-sh +294 -0
  92. data/ext/libuv/src/unix/ev/libev.m4 +39 -0
  93. data/ext/libuv/src/unix/ev/ltmain.sh +8413 -0
  94. data/ext/libuv/src/unix/ev/missing +336 -0
  95. data/ext/libuv/src/unix/ev/mkinstalldirs +111 -0
  96. data/ext/libuv/src/unix/freebsd.c +326 -0
  97. data/ext/libuv/src/unix/fs.c +739 -0
  98. data/ext/libuv/src/unix/internal.h +188 -0
  99. data/ext/libuv/src/unix/kqueue.c +120 -0
  100. data/ext/libuv/src/unix/linux/inotify.c +239 -0
  101. data/ext/libuv/src/unix/linux/linux-core.c +557 -0
  102. data/ext/libuv/src/unix/linux/syscalls.c +388 -0
  103. data/ext/libuv/src/unix/linux/syscalls.h +124 -0
  104. data/ext/libuv/src/unix/loop-watcher.c +62 -0
  105. data/ext/libuv/src/unix/loop.c +94 -0
  106. data/ext/libuv/src/unix/netbsd.c +108 -0
  107. data/ext/libuv/src/unix/openbsd.c +295 -0
  108. data/ext/libuv/src/unix/pipe.c +259 -0
  109. data/ext/libuv/src/unix/poll.c +114 -0
  110. data/ext/libuv/src/unix/process.c +495 -0
  111. data/ext/libuv/src/unix/signal.c +269 -0
  112. data/ext/libuv/src/unix/stream.c +990 -0
  113. data/ext/libuv/src/unix/sunos.c +481 -0
  114. data/ext/libuv/src/unix/tcp.c +393 -0
  115. data/ext/libuv/src/unix/thread.c +251 -0
  116. data/ext/libuv/src/unix/timer.c +136 -0
  117. data/ext/libuv/src/unix/tty.c +145 -0
  118. data/ext/libuv/src/unix/udp.c +659 -0
  119. data/ext/libuv/src/unix/uv-eio.c +107 -0
  120. data/ext/libuv/src/unix/uv-eio.h +13 -0
  121. data/ext/libuv/src/uv-common.c +380 -0
  122. data/ext/libuv/src/uv-common.h +170 -0
  123. data/ext/libuv/src/win/async.c +100 -0
  124. data/ext/libuv/src/win/atomicops-inl.h +56 -0
  125. data/ext/libuv/src/win/core.c +278 -0
  126. data/ext/libuv/src/win/dl.c +86 -0
  127. data/ext/libuv/src/win/error.c +155 -0
  128. data/ext/libuv/src/win/fs-event.c +510 -0
  129. data/ext/libuv/src/win/fs.c +1948 -0
  130. data/ext/libuv/src/win/getaddrinfo.c +365 -0
  131. data/ext/libuv/src/win/handle-inl.h +149 -0
  132. data/ext/libuv/src/win/handle.c +154 -0
  133. data/ext/libuv/src/win/internal.h +343 -0
  134. data/ext/libuv/src/win/loop-watcher.c +122 -0
  135. data/ext/libuv/src/win/pipe.c +1672 -0
  136. data/ext/libuv/src/win/poll.c +616 -0
  137. data/ext/libuv/src/win/process-stdio.c +500 -0
  138. data/ext/libuv/src/win/process.c +1013 -0
  139. data/ext/libuv/src/win/req-inl.h +220 -0
  140. data/ext/libuv/src/win/req.c +25 -0
  141. data/ext/libuv/src/win/signal.c +57 -0
  142. data/ext/libuv/src/win/stream-inl.h +67 -0
  143. data/ext/libuv/src/win/stream.c +167 -0
  144. data/ext/libuv/src/win/tcp.c +1394 -0
  145. data/ext/libuv/src/win/thread.c +372 -0
  146. data/ext/libuv/src/win/threadpool.c +74 -0
  147. data/ext/libuv/src/win/timer.c +224 -0
  148. data/ext/libuv/src/win/tty.c +1799 -0
  149. data/ext/libuv/src/win/udp.c +716 -0
  150. data/ext/libuv/src/win/util.c +864 -0
  151. data/ext/libuv/src/win/winapi.c +132 -0
  152. data/ext/libuv/src/win/winapi.h +4452 -0
  153. data/ext/libuv/src/win/winsock.c +557 -0
  154. data/ext/libuv/src/win/winsock.h +171 -0
  155. data/ext/libuv/test/benchmark-async-pummel.c +97 -0
  156. data/ext/libuv/test/benchmark-async.c +137 -0
  157. data/ext/libuv/test/benchmark-fs-stat.c +135 -0
  158. data/ext/libuv/test/benchmark-getaddrinfo.c +94 -0
  159. data/ext/libuv/test/benchmark-list.h +127 -0
  160. data/ext/libuv/test/benchmark-loop-count.c +88 -0
  161. data/ext/libuv/test/benchmark-million-timers.c +65 -0
  162. data/ext/libuv/test/benchmark-ping-pongs.c +213 -0
  163. data/ext/libuv/test/benchmark-pound.c +324 -0
  164. data/ext/libuv/test/benchmark-pump.c +462 -0
  165. data/ext/libuv/test/benchmark-sizes.c +44 -0
  166. data/ext/libuv/test/benchmark-spawn.c +162 -0
  167. data/ext/libuv/test/benchmark-tcp-write-batch.c +140 -0
  168. data/ext/libuv/test/benchmark-thread.c +64 -0
  169. data/ext/libuv/test/benchmark-udp-packet-storm.c +247 -0
  170. data/ext/libuv/test/blackhole-server.c +118 -0
  171. data/ext/libuv/test/dns-server.c +321 -0
  172. data/ext/libuv/test/echo-server.c +378 -0
  173. data/ext/libuv/test/fixtures/empty_file +0 -0
  174. data/ext/libuv/test/fixtures/load_error.node +1 -0
  175. data/ext/libuv/test/run-benchmarks.c +64 -0
  176. data/ext/libuv/test/run-tests.c +138 -0
  177. data/ext/libuv/test/runner-unix.c +295 -0
  178. data/ext/libuv/test/runner-unix.h +36 -0
  179. data/ext/libuv/test/runner-win.c +285 -0
  180. data/ext/libuv/test/runner-win.h +42 -0
  181. data/ext/libuv/test/runner.c +355 -0
  182. data/ext/libuv/test/runner.h +159 -0
  183. data/ext/libuv/test/task.h +112 -0
  184. data/ext/libuv/test/test-async.c +118 -0
  185. data/ext/libuv/test/test-callback-order.c +76 -0
  186. data/ext/libuv/test/test-callback-stack.c +203 -0
  187. data/ext/libuv/test/test-connection-fail.c +148 -0
  188. data/ext/libuv/test/test-cwd-and-chdir.c +64 -0
  189. data/ext/libuv/test/test-delayed-accept.c +188 -0
  190. data/ext/libuv/test/test-dlerror.c +58 -0
  191. data/ext/libuv/test/test-error.c +59 -0
  192. data/ext/libuv/test/test-fail-always.c +29 -0
  193. data/ext/libuv/test/test-fs-event.c +474 -0
  194. data/ext/libuv/test/test-fs-poll.c +146 -0
  195. data/ext/libuv/test/test-fs.c +1843 -0
  196. data/ext/libuv/test/test-get-currentexe.c +63 -0
  197. data/ext/libuv/test/test-get-loadavg.c +36 -0
  198. data/ext/libuv/test/test-get-memory.c +38 -0
  199. data/ext/libuv/test/test-getaddrinfo.c +122 -0
  200. data/ext/libuv/test/test-getsockname.c +342 -0
  201. data/ext/libuv/test/test-hrtime.c +54 -0
  202. data/ext/libuv/test/test-idle.c +81 -0
  203. data/ext/libuv/test/test-ipc-send-recv.c +209 -0
  204. data/ext/libuv/test/test-ipc.c +620 -0
  205. data/ext/libuv/test/test-list.h +427 -0
  206. data/ext/libuv/test/test-loop-handles.c +336 -0
  207. data/ext/libuv/test/test-multiple-listen.c +102 -0
  208. data/ext/libuv/test/test-mutexes.c +63 -0
  209. data/ext/libuv/test/test-pass-always.c +28 -0
  210. data/ext/libuv/test/test-ping-pong.c +253 -0
  211. data/ext/libuv/test/test-pipe-bind-error.c +140 -0
  212. data/ext/libuv/test/test-pipe-connect-error.c +96 -0
  213. data/ext/libuv/test/test-platform-output.c +87 -0
  214. data/ext/libuv/test/test-poll-close.c +72 -0
  215. data/ext/libuv/test/test-poll.c +573 -0
  216. data/ext/libuv/test/test-process-title.c +49 -0
  217. data/ext/libuv/test/test-ref.c +338 -0
  218. data/ext/libuv/test/test-run-once.c +48 -0
  219. data/ext/libuv/test/test-semaphore.c +111 -0
  220. data/ext/libuv/test/test-shutdown-close.c +103 -0
  221. data/ext/libuv/test/test-shutdown-eof.c +183 -0
  222. data/ext/libuv/test/test-signal.c +162 -0
  223. data/ext/libuv/test/test-spawn.c +863 -0
  224. data/ext/libuv/test/test-stdio-over-pipes.c +246 -0
  225. data/ext/libuv/test/test-tcp-bind-error.c +191 -0
  226. data/ext/libuv/test/test-tcp-bind6-error.c +154 -0
  227. data/ext/libuv/test/test-tcp-close-while-connecting.c +80 -0
  228. data/ext/libuv/test/test-tcp-close.c +129 -0
  229. data/ext/libuv/test/test-tcp-connect-error-after-write.c +95 -0
  230. data/ext/libuv/test/test-tcp-connect-error.c +70 -0
  231. data/ext/libuv/test/test-tcp-connect-timeout.c +85 -0
  232. data/ext/libuv/test/test-tcp-connect6-error.c +68 -0
  233. data/ext/libuv/test/test-tcp-flags.c +51 -0
  234. data/ext/libuv/test/test-tcp-shutdown-after-write.c +131 -0
  235. data/ext/libuv/test/test-tcp-unexpected-read.c +113 -0
  236. data/ext/libuv/test/test-tcp-write-error.c +168 -0
  237. data/ext/libuv/test/test-tcp-write-to-half-open-connection.c +135 -0
  238. data/ext/libuv/test/test-tcp-writealot.c +170 -0
  239. data/ext/libuv/test/test-thread.c +183 -0
  240. data/ext/libuv/test/test-threadpool.c +57 -0
  241. data/ext/libuv/test/test-timer-again.c +141 -0
  242. data/ext/libuv/test/test-timer.c +152 -0
  243. data/ext/libuv/test/test-tty.c +110 -0
  244. data/ext/libuv/test/test-udp-dgram-too-big.c +86 -0
  245. data/ext/libuv/test/test-udp-ipv6.c +156 -0
  246. data/ext/libuv/test/test-udp-multicast-join.c +139 -0
  247. data/ext/libuv/test/test-udp-multicast-ttl.c +86 -0
  248. data/ext/libuv/test/test-udp-options.c +86 -0
  249. data/ext/libuv/test/test-udp-send-and-recv.c +208 -0
  250. data/ext/libuv/test/test-util.c +97 -0
  251. data/ext/libuv/test/test-walk-handles.c +77 -0
  252. data/ext/libuv/uv.gyp +375 -0
  253. data/ext/libuv/vcbuild.bat +105 -0
  254. data/foolio.gemspec +18 -0
  255. data/lib/foolio.rb +9 -0
  256. data/lib/foolio/handle.rb +27 -0
  257. data/lib/foolio/listener.rb +26 -0
  258. data/lib/foolio/loop.rb +79 -0
  259. data/lib/foolio/stream.rb +109 -0
  260. data/lib/foolio/version.rb +3 -0
  261. metadata +309 -0
@@ -0,0 +1,388 @@
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 "syscalls.h"
23
+ #include <unistd.h>
24
+ #include <sys/syscall.h>
25
+ #include <sys/types.h>
26
+ #include <errno.h>
27
+
28
+ #if __i386__
29
+ # ifndef __NR_socketcall
30
+ # define __NR_socketcall 102
31
+ # endif
32
+ #endif
33
+
34
+ #if __arm__
35
+ # if __thumb__ || __ARM_EABI__
36
+ # define UV_SYSCALL_BASE 0
37
+ # else
38
+ # define UV_SYSCALL_BASE 0x900000
39
+ # endif
40
+ #endif /* __arm__ */
41
+
42
+ #ifndef __NR_accept4
43
+ # if __x86_64__
44
+ # define __NR_accept4 288
45
+ # elif __i386__
46
+ /* Nothing. Handled through socketcall(). */
47
+ # elif __arm__
48
+ # define __NR_accept4 (UV_SYSCALL_BASE + 366)
49
+ # endif
50
+ #endif /* __NR_accept4 */
51
+
52
+ #ifndef __NR_eventfd
53
+ # if __x86_64__
54
+ # define __NR_eventfd 284
55
+ # elif __i386__
56
+ # define __NR_eventfd 323
57
+ # elif __arm__
58
+ # define __NR_eventfd (UV_SYSCALL_BASE + 351)
59
+ # endif
60
+ #endif /* __NR_eventfd */
61
+
62
+ #ifndef __NR_eventfd2
63
+ # if __x86_64__
64
+ # define __NR_eventfd2 290
65
+ # elif __i386__
66
+ # define __NR_eventfd2 328
67
+ # elif __arm__
68
+ # define __NR_eventfd2 (UV_SYSCALL_BASE + 356)
69
+ # endif
70
+ #endif /* __NR_eventfd2 */
71
+
72
+ #ifndef __NR_epoll_create
73
+ # if __x86_64__
74
+ # define __NR_epoll_create 213
75
+ # elif __i386__
76
+ # define __NR_epoll_create 254
77
+ # elif __arm__
78
+ # define __NR_epoll_create (UV_SYSCALL_BASE + 250)
79
+ # endif
80
+ #endif /* __NR_epoll_create */
81
+
82
+ #ifndef __NR_epoll_create1
83
+ # if __x86_64__
84
+ # define __NR_epoll_create1 291
85
+ # elif __i386__
86
+ # define __NR_epoll_create1 329
87
+ # elif __arm__
88
+ # define __NR_epoll_create1 (UV_SYSCALL_BASE + 357)
89
+ # endif
90
+ #endif /* __NR_epoll_create1 */
91
+
92
+ #ifndef __NR_epoll_ctl
93
+ # if __x86_64__
94
+ # define __NR_epoll_ctl 233 /* used to be 214 */
95
+ # elif __i386__
96
+ # define __NR_epoll_ctl 255
97
+ # elif __arm__
98
+ # define __NR_epoll_ctl (UV_SYSCALL_BASE + 251)
99
+ # endif
100
+ #endif /* __NR_epoll_ctl */
101
+
102
+ #ifndef __NR_epoll_wait
103
+ # if __x86_64__
104
+ # define __NR_epoll_wait 232 /* used to be 215 */
105
+ # elif __i386__
106
+ # define __NR_epoll_wait 256
107
+ # elif __arm__
108
+ # define __NR_epoll_wait (UV_SYSCALL_BASE + 252)
109
+ # endif
110
+ #endif /* __NR_epoll_wait */
111
+
112
+ #ifndef __NR_epoll_pwait
113
+ # if __x86_64__
114
+ # define __NR_epoll_pwait 281
115
+ # elif __i386__
116
+ # define __NR_epoll_pwait 319
117
+ # elif __arm__
118
+ # define __NR_epoll_pwait (UV_SYSCALL_BASE + 346)
119
+ # endif
120
+ #endif /* __NR_epoll_pwait */
121
+
122
+ #ifndef __NR_inotify_init
123
+ # if __x86_64__
124
+ # define __NR_inotify_init 253
125
+ # elif __i386__
126
+ # define __NR_inotify_init 291
127
+ # elif __arm__
128
+ # define __NR_inotify_init (UV_SYSCALL_BASE + 316)
129
+ # endif
130
+ #endif /* __NR_inotify_init */
131
+
132
+ #ifndef __NR_inotify_init1
133
+ # if __x86_64__
134
+ # define __NR_inotify_init1 294
135
+ # elif __i386__
136
+ # define __NR_inotify_init1 332
137
+ # elif __arm__
138
+ # define __NR_inotify_init1 (UV_SYSCALL_BASE + 360)
139
+ # endif
140
+ #endif /* __NR_inotify_init1 */
141
+
142
+ #ifndef __NR_inotify_add_watch
143
+ # if __x86_64__
144
+ # define __NR_inotify_add_watch 254
145
+ # elif __i386__
146
+ # define __NR_inotify_add_watch 292
147
+ # elif __arm__
148
+ # define __NR_inotify_add_watch (UV_SYSCALL_BASE + 317)
149
+ # endif
150
+ #endif /* __NR_inotify_add_watch */
151
+
152
+ #ifndef __NR_inotify_rm_watch
153
+ # if __x86_64__
154
+ # define __NR_inotify_rm_watch 255
155
+ # elif __i386__
156
+ # define __NR_inotify_rm_watch 293
157
+ # elif __arm__
158
+ # define __NR_inotify_rm_watch (UV_SYSCALL_BASE + 318)
159
+ # endif
160
+ #endif /* __NR_inotify_rm_watch */
161
+
162
+ #ifndef __NR_pipe2
163
+ # if __x86_64__
164
+ # define __NR_pipe2 293
165
+ # elif __i386__
166
+ # define __NR_pipe2 331
167
+ # elif __arm__
168
+ # define __NR_pipe2 (UV_SYSCALL_BASE + 359)
169
+ # endif
170
+ #endif /* __NR_pipe2 */
171
+
172
+ #ifndef __NR_recvmmsg
173
+ # if __x86_64__
174
+ # define __NR_recvmmsg 299
175
+ # elif __i386__
176
+ # define __NR_recvmmsg 337
177
+ # elif __arm__
178
+ # define __NR_recvmmsg (UV_SYSCALL_BASE + 365)
179
+ # endif
180
+ #endif /* __NR_recvmsg */
181
+
182
+ #ifndef __NR_sendmmsg
183
+ # if __x86_64__
184
+ # define __NR_sendmmsg 307
185
+ # elif __i386__
186
+ # define __NR_sendmmsg 345
187
+ # elif __arm__
188
+ # define __NR_sendmmsg (UV_SYSCALL_BASE + 374)
189
+ # endif
190
+ #endif /* __NR_sendmmsg */
191
+
192
+ #ifndef __NR_utimensat
193
+ # if __x86_64__
194
+ # define __NR_utimensat 280
195
+ # elif __i386__
196
+ # define __NR_utimensat 320
197
+ # elif __arm__
198
+ # define __NR_utimensat (UV_SYSCALL_BASE + 348)
199
+ # endif
200
+ #endif /* __NR_utimensat */
201
+
202
+
203
+ int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags) {
204
+ #if __i386__
205
+ unsigned long args[4];
206
+ int r;
207
+
208
+ args[0] = (unsigned long) fd;
209
+ args[1] = (unsigned long) addr;
210
+ args[2] = (unsigned long) addrlen;
211
+ args[3] = (unsigned long) flags;
212
+
213
+ r = syscall(__NR_socketcall, 18 /* SYS_ACCEPT4 */, args);
214
+
215
+ /* socketcall() raises EINVAL when SYS_ACCEPT4 is not supported but so does
216
+ * a bad flags argument. Try to distinguish between the two cases.
217
+ */
218
+ if (r == -1)
219
+ if (errno == EINVAL)
220
+ if ((flags & ~(UV__SOCK_CLOEXEC|UV__SOCK_NONBLOCK)) == 0)
221
+ errno = ENOSYS;
222
+
223
+ return r;
224
+ #elif __NR_accept4
225
+ return syscall(__NR_accept4, fd, addr, addrlen, flags);
226
+ #else
227
+ return errno = ENOSYS, -1;
228
+ #endif
229
+ }
230
+
231
+
232
+ int uv__eventfd(unsigned int count) {
233
+ #if __NR_eventfd
234
+ return syscall(__NR_eventfd, count);
235
+ #else
236
+ return errno = ENOSYS, -1;
237
+ #endif
238
+ }
239
+
240
+
241
+ int uv__eventfd2(unsigned int count, int flags) {
242
+ #if __NR_eventfd2
243
+ return syscall(__NR_eventfd2, count, flags);
244
+ #else
245
+ return errno = ENOSYS, -1;
246
+ #endif
247
+ }
248
+
249
+
250
+ int uv__epoll_create(void) {
251
+ #if __NR_epoll_create
252
+ return syscall(__NR_epoll_create);
253
+ #else
254
+ return errno = ENOSYS, -1;
255
+ #endif
256
+ }
257
+
258
+
259
+ int uv__epoll_create1(int flags) {
260
+ #if __NR_epoll_create1
261
+ return syscall(__NR_epoll_create1, flags);
262
+ #else
263
+ return errno = ENOSYS, -1;
264
+ #endif
265
+ }
266
+
267
+
268
+ int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event* events) {
269
+ #if __NR_epoll_ctl
270
+ return syscall(__NR_epoll_ctl, epfd, op, fd, events);
271
+ #else
272
+ return errno = ENOSYS, -1;
273
+ #endif
274
+ }
275
+
276
+
277
+ int uv__epoll_wait(int epfd,
278
+ struct uv__epoll_event* events,
279
+ int nevents,
280
+ int timeout) {
281
+ #if __NR_epoll_wait
282
+ return syscall(__NR_epoll_wait, epfd, events, nevents, timeout);
283
+ #else
284
+ return errno = ENOSYS, -1;
285
+ #endif
286
+ }
287
+
288
+
289
+ int uv__epoll_pwait(int epfd,
290
+ struct uv__epoll_event* events,
291
+ int nevents,
292
+ int timeout,
293
+ const sigset_t* sigmask) {
294
+ #if __NR_epoll_pwait
295
+ return syscall(__NR_epoll_pwait,
296
+ epfd,
297
+ events,
298
+ nevents,
299
+ timeout,
300
+ sigmask,
301
+ sizeof(*sigmask));
302
+ #else
303
+ return errno = ENOSYS, -1;
304
+ #endif
305
+ }
306
+
307
+
308
+ int uv__inotify_init(void) {
309
+ #if __NR_inotify_init
310
+ return syscall(__NR_inotify_init);
311
+ #else
312
+ return errno = ENOSYS, -1;
313
+ #endif
314
+ }
315
+
316
+
317
+ int uv__inotify_init1(int flags) {
318
+ #if __NR_inotify_init1
319
+ return syscall(__NR_inotify_init1, flags);
320
+ #else
321
+ return errno = ENOSYS, -1;
322
+ #endif
323
+ }
324
+
325
+
326
+ int uv__inotify_add_watch(int fd, const char* path, __u32 mask) {
327
+ #if __NR_inotify_add_watch
328
+ return syscall(__NR_inotify_add_watch, fd, path, mask);
329
+ #else
330
+ return errno = ENOSYS, -1;
331
+ #endif
332
+ }
333
+
334
+
335
+ int uv__inotify_rm_watch(int fd, __s32 wd) {
336
+ #if __NR_inotify_rm_watch
337
+ return syscall(__NR_inotify_rm_watch, fd, wd);
338
+ #else
339
+ return errno = ENOSYS, -1;
340
+ #endif
341
+ }
342
+
343
+
344
+ int uv__pipe2(int pipefd[2], int flags) {
345
+ #if __NR_pipe2
346
+ return syscall(__NR_pipe2, pipefd, flags);
347
+ #else
348
+ return errno = ENOSYS, -1;
349
+ #endif
350
+ }
351
+
352
+
353
+ int uv__sendmmsg(int fd,
354
+ struct uv__mmsghdr* mmsg,
355
+ unsigned int vlen,
356
+ unsigned int flags) {
357
+ #if __NR_sendmmsg
358
+ return syscall(__NR_sendmmsg, fd, mmsg, vlen, flags);
359
+ #else
360
+ return errno = ENOSYS, -1;
361
+ #endif
362
+ }
363
+
364
+
365
+ int uv__recvmmsg(int fd,
366
+ struct uv__mmsghdr* mmsg,
367
+ unsigned int vlen,
368
+ unsigned int flags,
369
+ struct timespec* timeout) {
370
+ #if __NR_recvmmsg
371
+ return syscall(__NR_recvmmsg, fd, mmsg, vlen, flags, timeout);
372
+ #else
373
+ return errno = ENOSYS, -1;
374
+ #endif
375
+ }
376
+
377
+
378
+ int uv__utimesat(int dirfd,
379
+ const char* path,
380
+ const struct timespec times[2],
381
+ int flags)
382
+ {
383
+ #if __NR_utimensat
384
+ return syscall(__NR_utimensat, dirfd, path, times, flags);
385
+ #else
386
+ return errno = ENOSYS, -1;
387
+ #endif
388
+ }
@@ -0,0 +1,124 @@
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 <signal.h>
29
+ #include <sys/types.h>
30
+ #include <sys/socket.h>
31
+ #include <linux/types.h>
32
+
33
+ #define UV__O_NONBLOCK 0x800
34
+ #define UV__O_CLOEXEC 0x80000
35
+
36
+ #define UV__EFD_CLOEXEC UV__O_CLOEXEC
37
+ #define UV__EFD_NONBLOCK UV__O_NONBLOCK
38
+
39
+ #define UV__IN_CLOEXEC UV__O_CLOEXEC
40
+ #define UV__IN_NONBLOCK UV__O_NONBLOCK
41
+
42
+ #define UV__SOCK_CLOEXEC UV__O_CLOEXEC
43
+ #define UV__SOCK_NONBLOCK UV__O_NONBLOCK
44
+
45
+ /* epoll flags */
46
+ #define UV__EPOLL_CLOEXEC UV__O_CLOEXEC
47
+ #define UV__EPOLL_CTL_ADD 1
48
+ #define UV__EPOLL_CTL_DEL 2
49
+ #define UV__EPOLL_CTL_MOD 3
50
+
51
+ #define UV__EPOLLIN 1
52
+ #define UV__EPOLLOUT 4
53
+ #define UV__EPOLLERR 8
54
+ #define UV__EPOLLHUP 16
55
+ #define UV__EPOLLONESHOT 0x40000000
56
+ #define UV__EPOLLET 0x80000000
57
+
58
+ /* inotify flags */
59
+ #define UV__IN_ACCESS 0x001
60
+ #define UV__IN_MODIFY 0x002
61
+ #define UV__IN_ATTRIB 0x004
62
+ #define UV__IN_CLOSE_WRITE 0x008
63
+ #define UV__IN_CLOSE_NOWRITE 0x010
64
+ #define UV__IN_OPEN 0x020
65
+ #define UV__IN_MOVED_FROM 0x040
66
+ #define UV__IN_MOVED_TO 0x080
67
+ #define UV__IN_CREATE 0x100
68
+ #define UV__IN_DELETE 0x200
69
+ #define UV__IN_DELETE_SELF 0x400
70
+ #define UV__IN_MOVE_SELF 0x800
71
+
72
+ struct uv__epoll_event {
73
+ __u32 events;
74
+ __u64 data;
75
+ } __attribute__((packed));
76
+
77
+ struct uv__inotify_event {
78
+ __s32 wd;
79
+ __u32 mask;
80
+ __u32 cookie;
81
+ __u32 len;
82
+ /* char name[0]; */
83
+ };
84
+
85
+ struct uv__mmsghdr {
86
+ struct msghdr msg_hdr;
87
+ unsigned int msg_len;
88
+ };
89
+
90
+ int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags);
91
+ int uv__eventfd(unsigned int count);
92
+ int uv__epoll_create(void);
93
+ int uv__epoll_create1(int flags);
94
+ int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event *ev);
95
+ int uv__epoll_wait(int epfd,
96
+ struct uv__epoll_event* events,
97
+ int nevents,
98
+ int timeout);
99
+ int uv__epoll_pwait(int epfd,
100
+ struct uv__epoll_event* events,
101
+ int nevents,
102
+ int timeout,
103
+ const sigset_t* sigmask);
104
+ int uv__eventfd2(unsigned int count, int flags);
105
+ int uv__inotify_init(void);
106
+ int uv__inotify_init1(int flags);
107
+ int uv__inotify_add_watch(int fd, const char* path, __u32 mask);
108
+ int uv__inotify_rm_watch(int fd, __s32 wd);
109
+ int uv__pipe2(int pipefd[2], int flags);
110
+ int uv__recvmmsg(int fd,
111
+ struct uv__mmsghdr* mmsg,
112
+ unsigned int vlen,
113
+ unsigned int flags,
114
+ struct timespec* timeout);
115
+ int uv__sendmmsg(int fd,
116
+ struct uv__mmsghdr* mmsg,
117
+ unsigned int vlen,
118
+ unsigned int flags);
119
+ int uv__utimesat(int dirfd,
120
+ const char* path,
121
+ const struct timespec times[2],
122
+ int flags);
123
+
124
+ #endif /* UV_LINUX_SYSCALL_H_ */