foolio 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
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,324 @@
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_UNIX_H
23
+ #define UV_UNIX_H
24
+
25
+ #include "ngx-queue.h"
26
+
27
+ #include "ev.h"
28
+ #include "eio.h"
29
+
30
+ #include <sys/types.h>
31
+ #include <sys/stat.h>
32
+ #include <fcntl.h>
33
+
34
+ #include <sys/socket.h>
35
+ #include <netinet/in.h>
36
+ #include <netinet/tcp.h>
37
+ #include <arpa/inet.h>
38
+ #include <netdb.h>
39
+
40
+ #include <termios.h>
41
+ #include <pwd.h>
42
+
43
+ #include <pthread.h>
44
+ #include <signal.h>
45
+
46
+ #if defined(__APPLE__) && defined(__MACH__)
47
+ # include <mach/mach.h>
48
+ # include <mach/task.h>
49
+ # include <mach/semaphore.h>
50
+ #else
51
+ # include <semaphore.h>
52
+ #endif
53
+
54
+ #if defined(__sun)
55
+ # include <sys/port.h>
56
+ # include <port.h>
57
+ #endif
58
+
59
+ /* Note: May be cast to struct iovec. See writev(2). */
60
+ typedef struct {
61
+ char* base;
62
+ size_t len;
63
+ } uv_buf_t;
64
+
65
+ typedef int uv_file;
66
+
67
+ typedef int uv_os_sock_t;
68
+
69
+ typedef struct stat uv_statbuf_t;
70
+
71
+ #define UV_ONCE_INIT PTHREAD_ONCE_INIT
72
+
73
+ typedef pthread_once_t uv_once_t;
74
+ typedef pthread_t uv_thread_t;
75
+ typedef pthread_mutex_t uv_mutex_t;
76
+ typedef pthread_rwlock_t uv_rwlock_t;
77
+ #if defined(__APPLE__) && defined(__MACH__)
78
+ typedef semaphore_t uv_sem_t;
79
+ #else
80
+ typedef sem_t uv_sem_t;
81
+ #endif
82
+
83
+ /* Platform-specific definitions for uv_spawn support. */
84
+ typedef gid_t uv_gid_t;
85
+ typedef uid_t uv_uid_t;
86
+
87
+ /* Platform-specific definitions for uv_dlopen support. */
88
+ #define UV_DYNAMIC /* empty */
89
+ typedef struct {
90
+ void* handle;
91
+ char* errmsg;
92
+ } uv_lib_t;
93
+
94
+ struct uv__io_s;
95
+ struct uv_loop_s;
96
+
97
+ typedef struct uv__io_s uv__io_t;
98
+ typedef void (*uv__io_cb)(struct uv_loop_s* loop, uv__io_t* handle, int events);
99
+
100
+ struct uv__io_s {
101
+ ev_io io_watcher;
102
+ };
103
+
104
+ #define UV_REQ_TYPE_PRIVATE /* empty */
105
+
106
+ #if defined(__linux__)
107
+ # define UV_LOOP_PRIVATE_PLATFORM_FIELDS \
108
+ uv__io_t inotify_read_watcher; \
109
+ void* inotify_watchers; \
110
+ int inotify_fd;
111
+ #elif defined(PORT_SOURCE_FILE)
112
+ # define UV_LOOP_PRIVATE_PLATFORM_FIELDS \
113
+ uv__io_t fs_event_watcher; \
114
+ int fs_fd;
115
+ #else
116
+ # define UV_LOOP_PRIVATE_PLATFORM_FIELDS
117
+ #endif
118
+
119
+ #define UV_LOOP_PRIVATE_FIELDS \
120
+ unsigned long flags; \
121
+ /* Poll result queue */ \
122
+ eio_channel uv_eio_channel; \
123
+ struct ev_loop* ev; \
124
+ /* Various thing for libeio. */ \
125
+ uv_async_t uv_eio_want_poll_notifier; \
126
+ uv_async_t uv_eio_done_poll_notifier; \
127
+ uv_idle_t uv_eio_poller; \
128
+ uv_handle_t* closing_handles; \
129
+ ngx_queue_t process_handles[1]; \
130
+ ngx_queue_t prepare_handles; \
131
+ ngx_queue_t check_handles; \
132
+ ngx_queue_t idle_handles; \
133
+ ngx_queue_t async_handles; \
134
+ uv__io_t async_watcher; \
135
+ int async_pipefd[2]; \
136
+ /* RB_HEAD(uv__timers, uv_timer_s) */ \
137
+ struct uv__timers { struct uv_timer_s* rbh_root; } timer_handles; \
138
+ uint64_t time; \
139
+ void* signal_ctx; \
140
+ uv_signal_t child_watcher; \
141
+ UV_LOOP_PRIVATE_PLATFORM_FIELDS
142
+
143
+ #define UV_REQ_BUFSML_SIZE (4)
144
+
145
+ #define UV_REQ_PRIVATE_FIELDS /* empty */
146
+
147
+ #define UV_WRITE_PRIVATE_FIELDS \
148
+ ngx_queue_t queue; \
149
+ int write_index; \
150
+ uv_buf_t* bufs; \
151
+ int bufcnt; \
152
+ int error; \
153
+ uv_buf_t bufsml[UV_REQ_BUFSML_SIZE];
154
+
155
+ #define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */
156
+
157
+ #define UV_CONNECT_PRIVATE_FIELDS \
158
+ ngx_queue_t queue;
159
+
160
+ #define UV_UDP_SEND_PRIVATE_FIELDS \
161
+ ngx_queue_t queue; \
162
+ struct sockaddr_in6 addr; \
163
+ int bufcnt; \
164
+ uv_buf_t* bufs; \
165
+ ssize_t status; \
166
+ uv_udp_send_cb send_cb; \
167
+ uv_buf_t bufsml[UV_REQ_BUFSML_SIZE]; \
168
+
169
+ #define UV_PRIVATE_REQ_TYPES /* empty */
170
+
171
+
172
+ /* TODO: union or classes please! */
173
+ #define UV_HANDLE_PRIVATE_FIELDS \
174
+ int flags; \
175
+ uv_handle_t* next_closing; \
176
+
177
+
178
+ #define UV_STREAM_PRIVATE_FIELDS \
179
+ uv_connect_t *connect_req; \
180
+ uv_shutdown_t *shutdown_req; \
181
+ uv__io_t read_watcher; \
182
+ uv__io_t write_watcher; \
183
+ ngx_queue_t write_queue; \
184
+ ngx_queue_t write_completed_queue; \
185
+ uv_connection_cb connection_cb; \
186
+ int delayed_error; \
187
+ int accepted_fd; \
188
+ int fd; \
189
+
190
+
191
+ /* UV_TCP, idle_handle is for UV_TCP_SINGLE_ACCEPT handles */
192
+ #define UV_TCP_PRIVATE_FIELDS \
193
+ uv_idle_t* idle_handle; \
194
+
195
+
196
+ /* UV_UDP */
197
+ #define UV_UDP_PRIVATE_FIELDS \
198
+ int fd; \
199
+ uv_alloc_cb alloc_cb; \
200
+ uv_udp_recv_cb recv_cb; \
201
+ uv__io_t read_watcher; \
202
+ uv__io_t write_watcher; \
203
+ ngx_queue_t write_queue; \
204
+ ngx_queue_t write_completed_queue; \
205
+
206
+
207
+ /* UV_NAMED_PIPE */
208
+ #define UV_PIPE_PRIVATE_FIELDS \
209
+ const char* pipe_fname; /* strdup'ed */
210
+
211
+
212
+ /* UV_POLL */
213
+ #define UV_POLL_PRIVATE_FIELDS \
214
+ int fd; \
215
+ uv__io_t io_watcher;
216
+
217
+
218
+ /* UV_PREPARE */
219
+ #define UV_PREPARE_PRIVATE_FIELDS \
220
+ uv_prepare_cb prepare_cb; \
221
+ ngx_queue_t queue;
222
+
223
+
224
+ /* UV_CHECK */
225
+ #define UV_CHECK_PRIVATE_FIELDS \
226
+ uv_check_cb check_cb; \
227
+ ngx_queue_t queue;
228
+
229
+
230
+ /* UV_IDLE */
231
+ #define UV_IDLE_PRIVATE_FIELDS \
232
+ uv_idle_cb idle_cb; \
233
+ ngx_queue_t queue;
234
+
235
+
236
+ /* UV_ASYNC */
237
+ #define UV_ASYNC_PRIVATE_FIELDS \
238
+ volatile sig_atomic_t pending; \
239
+ uv_async_cb async_cb; \
240
+ ngx_queue_t queue;
241
+
242
+
243
+ /* UV_TIMER */
244
+ #define UV_TIMER_PRIVATE_FIELDS \
245
+ /* RB_ENTRY(uv_timer_s) node; */ \
246
+ struct { \
247
+ struct uv_timer_s* rbe_left; \
248
+ struct uv_timer_s* rbe_right; \
249
+ struct uv_timer_s* rbe_parent; \
250
+ int rbe_color; \
251
+ } tree_entry; \
252
+ uv_timer_cb timer_cb; \
253
+ uint64_t timeout; \
254
+ uint64_t repeat;
255
+
256
+ #define UV_GETADDRINFO_PRIVATE_FIELDS \
257
+ uv_getaddrinfo_cb cb; \
258
+ struct addrinfo* hints; \
259
+ char* hostname; \
260
+ char* service; \
261
+ struct addrinfo* res; \
262
+ int retcode;
263
+
264
+ #define UV_PROCESS_PRIVATE_FIELDS \
265
+ ngx_queue_t queue; \
266
+ int errorno; \
267
+
268
+ #define UV_FS_PRIVATE_FIELDS \
269
+ struct stat statbuf; \
270
+ uv_file file; \
271
+ eio_req* eio; \
272
+
273
+ #define UV_WORK_PRIVATE_FIELDS \
274
+ eio_req* eio;
275
+
276
+ #define UV_TTY_PRIVATE_FIELDS \
277
+ struct termios orig_termios; \
278
+ int mode;
279
+
280
+ #define UV_SIGNAL_PRIVATE_FIELDS \
281
+ ngx_queue_t queue; \
282
+ unsigned int signum; \
283
+
284
+ /* UV_FS_EVENT_PRIVATE_FIELDS */
285
+ #if defined(__linux__)
286
+
287
+ #define UV_FS_EVENT_PRIVATE_FIELDS \
288
+ ngx_queue_t watchers; \
289
+ uv_fs_event_cb cb; \
290
+ int wd; \
291
+ void* pad0; \
292
+ void* pad1; \
293
+
294
+ #elif defined(__APPLE__) \
295
+ || defined(__FreeBSD__) \
296
+ || defined(__DragonFly__) \
297
+ || defined(__OpenBSD__) \
298
+ || defined(__NetBSD__)
299
+
300
+ #define UV_FS_EVENT_PRIVATE_FIELDS \
301
+ ev_io event_watcher; \
302
+ uv_fs_event_cb cb; \
303
+ int fflags; \
304
+ int fd;
305
+
306
+ #elif defined(__sun)
307
+
308
+ #ifdef PORT_SOURCE_FILE
309
+ # define UV_FS_EVENT_PRIVATE_FIELDS \
310
+ uv_fs_event_cb cb; \
311
+ file_obj_t fo; \
312
+ int fd;
313
+ #else /* !PORT_SOURCE_FILE */
314
+ # define UV_FS_EVENT_PRIVATE_FIELDS
315
+ #endif
316
+
317
+ #else
318
+
319
+ /* Stub for platforms where the file watcher isn't implemented yet. */
320
+ #define UV_FS_EVENT_PRIVATE_FIELDS
321
+
322
+ #endif
323
+
324
+ #endif /* UV_UNIX_H */
@@ -0,0 +1,517 @@
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 _WIN32_WINNT
23
+ # define _WIN32_WINNT 0x0502
24
+ #endif
25
+
26
+ #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
27
+ typedef intptr_t ssize_t;
28
+ # define _SSIZE_T_
29
+ # define _SSIZE_T_DEFINED
30
+ #endif
31
+
32
+ #include <winsock2.h>
33
+ #include <mswsock.h>
34
+ #include <ws2tcpip.h>
35
+ #include <windows.h>
36
+
37
+ #include <process.h>
38
+ #include <stdint.h>
39
+ #include <sys/stat.h>
40
+
41
+ #include "tree.h"
42
+ #include "ngx-queue.h"
43
+
44
+ #define MAX_PIPENAME_LEN 256
45
+
46
+ #ifndef S_IFLNK
47
+ # define S_IFLNK 0xA000
48
+ #endif
49
+
50
+ /*
51
+ * Guids and typedefs for winsock extension functions
52
+ * Mingw32 doesn't have these :-(
53
+ */
54
+ #ifndef WSAID_ACCEPTEX
55
+ # define WSAID_ACCEPTEX \
56
+ {0xb5367df1, 0xcbac, 0x11cf, \
57
+ {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
58
+
59
+ # define WSAID_CONNECTEX \
60
+ {0x25a207b9, 0xddf3, 0x4660, \
61
+ {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}}
62
+
63
+ # define WSAID_GETACCEPTEXSOCKADDRS \
64
+ {0xb5367df2, 0xcbac, 0x11cf, \
65
+ {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
66
+
67
+ # define WSAID_DISCONNECTEX \
68
+ {0x7fda2e11, 0x8630, 0x436f, \
69
+ {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
70
+
71
+ # define WSAID_TRANSMITFILE \
72
+ {0xb5367df0, 0xcbac, 0x11cf, \
73
+ {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
74
+
75
+ typedef BOOL PASCAL (*LPFN_ACCEPTEX)
76
+ (SOCKET sListenSocket,
77
+ SOCKET sAcceptSocket,
78
+ PVOID lpOutputBuffer,
79
+ DWORD dwReceiveDataLength,
80
+ DWORD dwLocalAddressLength,
81
+ DWORD dwRemoteAddressLength,
82
+ LPDWORD lpdwBytesReceived,
83
+ LPOVERLAPPED lpOverlapped);
84
+
85
+ typedef BOOL PASCAL (*LPFN_CONNECTEX)
86
+ (SOCKET s,
87
+ const struct sockaddr* name,
88
+ int namelen,
89
+ PVOID lpSendBuffer,
90
+ DWORD dwSendDataLength,
91
+ LPDWORD lpdwBytesSent,
92
+ LPOVERLAPPED lpOverlapped);
93
+
94
+ typedef void PASCAL (*LPFN_GETACCEPTEXSOCKADDRS)
95
+ (PVOID lpOutputBuffer,
96
+ DWORD dwReceiveDataLength,
97
+ DWORD dwLocalAddressLength,
98
+ DWORD dwRemoteAddressLength,
99
+ LPSOCKADDR* LocalSockaddr,
100
+ LPINT LocalSockaddrLength,
101
+ LPSOCKADDR* RemoteSockaddr,
102
+ LPINT RemoteSockaddrLength);
103
+
104
+ typedef BOOL PASCAL (*LPFN_DISCONNECTEX)
105
+ (SOCKET hSocket,
106
+ LPOVERLAPPED lpOverlapped,
107
+ DWORD dwFlags,
108
+ DWORD reserved);
109
+
110
+ typedef BOOL PASCAL (*LPFN_TRANSMITFILE)
111
+ (SOCKET hSocket,
112
+ HANDLE hFile,
113
+ DWORD nNumberOfBytesToWrite,
114
+ DWORD nNumberOfBytesPerSend,
115
+ LPOVERLAPPED lpOverlapped,
116
+ LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
117
+ DWORD dwFlags);
118
+
119
+ typedef PVOID RTL_SRWLOCK;
120
+ typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
121
+ #endif
122
+
123
+ typedef int (WSAAPI* LPFN_WSARECV)
124
+ (SOCKET socket,
125
+ LPWSABUF buffers,
126
+ DWORD buffer_count,
127
+ LPDWORD bytes,
128
+ LPDWORD flags,
129
+ LPWSAOVERLAPPED overlapped,
130
+ LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
131
+
132
+ typedef int (WSAAPI* LPFN_WSARECVFROM)
133
+ (SOCKET socket,
134
+ LPWSABUF buffers,
135
+ DWORD buffer_count,
136
+ LPDWORD bytes,
137
+ LPDWORD flags,
138
+ struct sockaddr* addr,
139
+ LPINT addr_len,
140
+ LPWSAOVERLAPPED overlapped,
141
+ LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
142
+
143
+ #ifndef _NTDEF_
144
+ typedef LONG NTSTATUS;
145
+ typedef NTSTATUS *PNTSTATUS;
146
+ #endif
147
+
148
+ typedef struct _AFD_POLL_HANDLE_INFO {
149
+ HANDLE Handle;
150
+ ULONG Events;
151
+ NTSTATUS Status;
152
+ } AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO;
153
+
154
+ typedef struct _AFD_POLL_INFO {
155
+ LARGE_INTEGER Timeout;
156
+ ULONG NumberOfHandles;
157
+ ULONG Exclusive;
158
+ AFD_POLL_HANDLE_INFO Handles[1];
159
+ } AFD_POLL_INFO, *PAFD_POLL_INFO;
160
+
161
+ #define UV_MSAFD_PROVIDER_COUNT 3
162
+
163
+
164
+ /**
165
+ * It should be possible to cast uv_buf_t[] to WSABUF[]
166
+ * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
167
+ */
168
+ typedef struct uv_buf_t {
169
+ ULONG len;
170
+ char* base;
171
+ } uv_buf_t;
172
+
173
+ typedef int uv_file;
174
+
175
+ typedef struct _stati64 uv_statbuf_t;
176
+
177
+ typedef SOCKET uv_os_sock_t;
178
+
179
+ typedef HANDLE uv_thread_t;
180
+
181
+ typedef HANDLE uv_sem_t;
182
+
183
+ typedef CRITICAL_SECTION uv_mutex_t;
184
+
185
+ typedef union {
186
+ /* srwlock_ has type SRWLOCK, but not all toolchains define this type in */
187
+ /* windows.h. */
188
+ SRWLOCK srwlock_;
189
+ struct {
190
+ uv_mutex_t read_mutex_;
191
+ uv_mutex_t write_mutex_;
192
+ unsigned int num_readers_;
193
+ } fallback_;
194
+ } uv_rwlock_t;
195
+
196
+ #define UV_ONCE_INIT { 0, NULL, NULL }
197
+
198
+ typedef struct uv_once_s {
199
+ unsigned char ran;
200
+ /* The actual event handle must be aligned to sizeof(HANDLE), so in */
201
+ /* practice it might overlap padding a little. */
202
+ HANDLE event;
203
+ HANDLE padding;
204
+ } uv_once_t;
205
+
206
+ /* Platform-specific definitions for uv_spawn support. */
207
+ typedef unsigned char uv_uid_t;
208
+ typedef unsigned char uv_gid_t;
209
+
210
+ /* Platform-specific definitions for uv_dlopen support. */
211
+ #define UV_DYNAMIC FAR WINAPI
212
+ typedef struct {
213
+ HMODULE handle;
214
+ char* errmsg;
215
+ } uv_lib_t;
216
+
217
+ RB_HEAD(uv_timer_tree_s, uv_timer_s);
218
+
219
+ #define UV_LOOP_PRIVATE_FIELDS \
220
+ /* The loop's I/O completion port */ \
221
+ HANDLE iocp; \
222
+ /* The current time according to the event loop. in msecs. */ \
223
+ int64_t time; \
224
+ /* Tail of a single-linked circular queue of pending reqs. If the queue */ \
225
+ /* is empty, tail_ is NULL. If there is only one item, */ \
226
+ /* tail_->next_req == tail_ */ \
227
+ uv_req_t* pending_reqs_tail; \
228
+ /* Head of a single-linked list of closed handles */ \
229
+ uv_handle_t* endgame_handles; \
230
+ /* The head of the timers tree */ \
231
+ struct uv_timer_tree_s timers; \
232
+ /* Lists of active loop (prepare / check / idle) watchers */ \
233
+ uv_prepare_t* prepare_handles; \
234
+ uv_check_t* check_handles; \
235
+ uv_idle_t* idle_handles; \
236
+ /* This pointer will refer to the prepare/check/idle handle whose */ \
237
+ /* callback is scheduled to be called next. This is needed to allow */ \
238
+ /* safe removal from one of the lists above while that list being */ \
239
+ /* iterated over. */ \
240
+ uv_prepare_t* next_prepare_handle; \
241
+ uv_check_t* next_check_handle; \
242
+ uv_idle_t* next_idle_handle; \
243
+ /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \
244
+ SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \
245
+ /* Counter to keep track of active tcp streams */ \
246
+ unsigned int active_tcp_streams; \
247
+ /* Counter to keep track of active udp streams */ \
248
+ unsigned int active_udp_streams;
249
+
250
+ #define UV_REQ_TYPE_PRIVATE \
251
+ /* TODO: remove the req suffix */ \
252
+ UV_ACCEPT, \
253
+ UV_FS_EVENT_REQ, \
254
+ UV_POLL_REQ, \
255
+ UV_PROCESS_EXIT, \
256
+ UV_READ, \
257
+ UV_UDP_RECV, \
258
+ UV_WAKEUP,
259
+
260
+ #define UV_REQ_PRIVATE_FIELDS \
261
+ union { \
262
+ /* Used by I/O operations */ \
263
+ struct { \
264
+ OVERLAPPED overlapped; \
265
+ size_t queued_bytes; \
266
+ }; \
267
+ }; \
268
+ struct uv_req_s* next_req;
269
+
270
+ #define UV_WRITE_PRIVATE_FIELDS \
271
+ int ipc_header; \
272
+ uv_buf_t write_buffer; \
273
+ HANDLE event_handle; \
274
+ HANDLE wait_handle;
275
+
276
+ #define UV_CONNECT_PRIVATE_FIELDS \
277
+ /* empty */
278
+
279
+ #define UV_SHUTDOWN_PRIVATE_FIELDS \
280
+ /* empty */
281
+
282
+ #define UV_UDP_SEND_PRIVATE_FIELDS \
283
+ /* empty */
284
+
285
+ #define UV_PRIVATE_REQ_TYPES \
286
+ typedef struct uv_pipe_accept_s { \
287
+ UV_REQ_FIELDS \
288
+ HANDLE pipeHandle; \
289
+ struct uv_pipe_accept_s* next_pending; \
290
+ } uv_pipe_accept_t; \
291
+ \
292
+ typedef struct uv_tcp_accept_s { \
293
+ UV_REQ_FIELDS \
294
+ SOCKET accept_socket; \
295
+ char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \
296
+ HANDLE event_handle; \
297
+ HANDLE wait_handle; \
298
+ struct uv_tcp_accept_s* next_pending; \
299
+ } uv_tcp_accept_t; \
300
+ \
301
+ typedef struct uv_read_s { \
302
+ UV_REQ_FIELDS \
303
+ HANDLE event_handle; \
304
+ HANDLE wait_handle; \
305
+ } uv_read_t;
306
+
307
+ #define uv_stream_connection_fields \
308
+ unsigned int write_reqs_pending; \
309
+ uv_shutdown_t* shutdown_req;
310
+
311
+ #define uv_stream_server_fields \
312
+ uv_connection_cb connection_cb;
313
+
314
+ #define UV_STREAM_PRIVATE_FIELDS \
315
+ unsigned int reqs_pending; \
316
+ int activecnt; \
317
+ uv_read_t read_req; \
318
+ union { \
319
+ struct { uv_stream_connection_fields }; \
320
+ struct { uv_stream_server_fields }; \
321
+ };
322
+
323
+ #define uv_tcp_server_fields \
324
+ uv_tcp_accept_t* accept_reqs; \
325
+ unsigned int processed_accepts; \
326
+ uv_tcp_accept_t* pending_accepts; \
327
+ LPFN_ACCEPTEX func_acceptex;
328
+
329
+ #define uv_tcp_connection_fields \
330
+ uv_buf_t read_buffer; \
331
+ LPFN_CONNECTEX func_connectex;
332
+
333
+ #define UV_TCP_PRIVATE_FIELDS \
334
+ SOCKET socket; \
335
+ int bind_error; \
336
+ union { \
337
+ struct { uv_tcp_server_fields }; \
338
+ struct { uv_tcp_connection_fields }; \
339
+ };
340
+
341
+ #define UV_UDP_PRIVATE_FIELDS \
342
+ SOCKET socket; \
343
+ unsigned int reqs_pending; \
344
+ int activecnt; \
345
+ uv_req_t recv_req; \
346
+ uv_buf_t recv_buffer; \
347
+ struct sockaddr_storage recv_from; \
348
+ int recv_from_len; \
349
+ uv_udp_recv_cb recv_cb; \
350
+ uv_alloc_cb alloc_cb; \
351
+ LPFN_WSARECV func_wsarecv; \
352
+ LPFN_WSARECVFROM func_wsarecvfrom;
353
+
354
+ #define uv_pipe_server_fields \
355
+ int pending_instances; \
356
+ uv_pipe_accept_t* accept_reqs; \
357
+ uv_pipe_accept_t* pending_accepts;
358
+
359
+ #define uv_pipe_connection_fields \
360
+ uv_timer_t* eof_timer; \
361
+ uv_write_t ipc_header_write_req; \
362
+ int ipc_pid; \
363
+ uint64_t remaining_ipc_rawdata_bytes; \
364
+ unsigned char reserved[sizeof(void*)]; \
365
+ struct { \
366
+ WSAPROTOCOL_INFOW* socket_info; \
367
+ int tcp_connection; \
368
+ } pending_ipc_info; \
369
+ uv_write_t* non_overlapped_writes_tail;
370
+
371
+ #define UV_PIPE_PRIVATE_FIELDS \
372
+ HANDLE handle; \
373
+ WCHAR* name; \
374
+ union { \
375
+ struct { uv_pipe_server_fields }; \
376
+ struct { uv_pipe_connection_fields }; \
377
+ };
378
+
379
+ /* TODO: put the parser states in an union - TTY handles are always */
380
+ /* half-duplex so read-state can safely overlap write-state. */
381
+ #define UV_TTY_PRIVATE_FIELDS \
382
+ HANDLE handle; \
383
+ HANDLE read_line_handle; \
384
+ uv_buf_t read_line_buffer; \
385
+ HANDLE read_raw_wait; \
386
+ DWORD original_console_mode; \
387
+ /* Fields used for translating win */ \
388
+ /* keystrokes into vt100 characters */ \
389
+ char last_key[8]; \
390
+ unsigned char last_key_offset; \
391
+ unsigned char last_key_len; \
392
+ INPUT_RECORD last_input_record; \
393
+ WCHAR last_utf16_high_surrogate; \
394
+ /* utf8-to-utf16 conversion state */ \
395
+ unsigned char utf8_bytes_left; \
396
+ unsigned int utf8_codepoint; \
397
+ /* eol conversion state */ \
398
+ unsigned char previous_eol; \
399
+ /* ansi parser state */ \
400
+ unsigned char ansi_parser_state; \
401
+ unsigned char ansi_csi_argc; \
402
+ unsigned short ansi_csi_argv[4]; \
403
+ COORD saved_position; \
404
+ WORD saved_attributes;
405
+
406
+ #define UV_POLL_PRIVATE_FIELDS \
407
+ SOCKET socket; \
408
+ /* Used in fast mode */ \
409
+ SOCKET peer_socket; \
410
+ AFD_POLL_INFO afd_poll_info_1; \
411
+ AFD_POLL_INFO afd_poll_info_2; \
412
+ /* Used in fast and slow mode. */ \
413
+ uv_req_t poll_req_1; \
414
+ uv_req_t poll_req_2; \
415
+ unsigned char submitted_events_1; \
416
+ unsigned char submitted_events_2; \
417
+ unsigned char mask_events_1; \
418
+ unsigned char mask_events_2; \
419
+ unsigned char events;
420
+
421
+ #define UV_TIMER_PRIVATE_FIELDS \
422
+ RB_ENTRY(uv_timer_s) tree_entry; \
423
+ int64_t due; \
424
+ int64_t repeat; \
425
+ uv_timer_cb timer_cb;
426
+
427
+ #define UV_ASYNC_PRIVATE_FIELDS \
428
+ struct uv_req_s async_req; \
429
+ uv_async_cb async_cb; \
430
+ /* char to avoid alignment issues */ \
431
+ char volatile async_sent;
432
+
433
+ #define UV_PREPARE_PRIVATE_FIELDS \
434
+ uv_prepare_t* prepare_prev; \
435
+ uv_prepare_t* prepare_next; \
436
+ uv_prepare_cb prepare_cb;
437
+
438
+ #define UV_CHECK_PRIVATE_FIELDS \
439
+ uv_check_t* check_prev; \
440
+ uv_check_t* check_next; \
441
+ uv_check_cb check_cb;
442
+
443
+ #define UV_IDLE_PRIVATE_FIELDS \
444
+ uv_idle_t* idle_prev; \
445
+ uv_idle_t* idle_next; \
446
+ uv_idle_cb idle_cb;
447
+
448
+ #define UV_HANDLE_PRIVATE_FIELDS \
449
+ uv_handle_t* endgame_next; \
450
+ unsigned int flags;
451
+
452
+ #define UV_GETADDRINFO_PRIVATE_FIELDS \
453
+ uv_getaddrinfo_cb getaddrinfo_cb; \
454
+ void* alloc; \
455
+ WCHAR* node; \
456
+ WCHAR* service; \
457
+ struct addrinfoW* hints; \
458
+ struct addrinfoW* res; \
459
+ int retcode;
460
+
461
+ #define UV_PROCESS_PRIVATE_FIELDS \
462
+ struct uv_process_exit_s { \
463
+ UV_REQ_FIELDS \
464
+ } exit_req; \
465
+ BYTE* child_stdio_buffer; \
466
+ uv_err_t spawn_error; \
467
+ int exit_signal; \
468
+ HANDLE wait_handle; \
469
+ HANDLE process_handle; \
470
+ volatile char exit_cb_pending;
471
+
472
+ #define UV_FS_PRIVATE_FIELDS \
473
+ int flags; \
474
+ DWORD sys_errno_; \
475
+ union { \
476
+ /* TODO: remove me in 0.9. */ \
477
+ WCHAR* pathw; \
478
+ int fd; \
479
+ }; \
480
+ union { \
481
+ struct { \
482
+ int mode; \
483
+ WCHAR* new_pathw; \
484
+ int file_flags; \
485
+ int fd_out; \
486
+ void* buf; \
487
+ size_t length; \
488
+ int64_t offset; \
489
+ }; \
490
+ struct _stati64 stat; \
491
+ struct { \
492
+ double atime; \
493
+ double mtime; \
494
+ }; \
495
+ };
496
+
497
+ #define UV_WORK_PRIVATE_FIELDS \
498
+
499
+ #define UV_FS_EVENT_PRIVATE_FIELDS \
500
+ struct uv_fs_event_req_s { \
501
+ UV_REQ_FIELDS \
502
+ } req; \
503
+ HANDLE dir_handle; \
504
+ int req_pending; \
505
+ uv_fs_event_cb cb; \
506
+ WCHAR* filew; \
507
+ WCHAR* short_filew; \
508
+ WCHAR* dirw; \
509
+ char* buffer;
510
+
511
+ #define UV_SIGNAL_PRIVATE_FIELDS \
512
+ /* empty */
513
+
514
+ int uv_utf16_to_utf8(const WCHAR* utf16Buffer, size_t utf16Size,
515
+ char* utf8Buffer, size_t utf8Size);
516
+ int uv_utf8_to_utf16(const char* utf8Buffer, WCHAR* utf16Buffer,
517
+ size_t utf16Size);