racer 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (336) hide show
  1. data/LICENSE +22 -0
  2. data/bin/racer +33 -0
  3. data/ext/libuv/AUTHORS +45 -0
  4. data/ext/libuv/LICENSE +42 -0
  5. data/ext/libuv/Makefile +119 -0
  6. data/ext/libuv/README.md +88 -0
  7. data/ext/libuv/build/gcc_version.py +20 -0
  8. data/ext/libuv/common.gypi +176 -0
  9. data/ext/libuv/config-mingw.mk +61 -0
  10. data/ext/libuv/config-unix.mk +171 -0
  11. data/ext/libuv/gyp_uv +64 -0
  12. data/ext/libuv/include/ares.h +591 -0
  13. data/ext/libuv/include/ares_version.h +24 -0
  14. data/ext/libuv/include/uv-private/eio.h +403 -0
  15. data/ext/libuv/include/uv-private/ev.h +838 -0
  16. data/ext/libuv/include/uv-private/ngx-queue.h +108 -0
  17. data/ext/libuv/include/uv-private/tree.h +768 -0
  18. data/ext/libuv/include/uv-private/uv-unix.h +310 -0
  19. data/ext/libuv/include/uv-private/uv-win.h +510 -0
  20. data/ext/libuv/include/uv.h +1796 -0
  21. data/ext/libuv/src/ares/AUTHORS +37 -0
  22. data/ext/libuv/src/ares/CHANGES +1218 -0
  23. data/ext/libuv/src/ares/CMakeLists.txt +22 -0
  24. data/ext/libuv/src/ares/NEWS +21 -0
  25. data/ext/libuv/src/ares/README +60 -0
  26. data/ext/libuv/src/ares/README.cares +13 -0
  27. data/ext/libuv/src/ares/README.msvc +142 -0
  28. data/ext/libuv/src/ares/README.node +21 -0
  29. data/ext/libuv/src/ares/RELEASE-NOTES +26 -0
  30. data/ext/libuv/src/ares/TODO +23 -0
  31. data/ext/libuv/src/ares/ares__close_sockets.c +66 -0
  32. data/ext/libuv/src/ares/ares__get_hostent.c +263 -0
  33. data/ext/libuv/src/ares/ares__read_line.c +71 -0
  34. data/ext/libuv/src/ares/ares__timeval.c +111 -0
  35. data/ext/libuv/src/ares/ares_cancel.c +63 -0
  36. data/ext/libuv/src/ares/ares_data.c +190 -0
  37. data/ext/libuv/src/ares/ares_data.h +65 -0
  38. data/ext/libuv/src/ares/ares_destroy.c +105 -0
  39. data/ext/libuv/src/ares/ares_dns.h +90 -0
  40. data/ext/libuv/src/ares/ares_expand_name.c +200 -0
  41. data/ext/libuv/src/ares/ares_expand_string.c +75 -0
  42. data/ext/libuv/src/ares/ares_fds.c +63 -0
  43. data/ext/libuv/src/ares/ares_free_hostent.c +42 -0
  44. data/ext/libuv/src/ares/ares_free_string.c +25 -0
  45. data/ext/libuv/src/ares/ares_getenv.c +30 -0
  46. data/ext/libuv/src/ares/ares_getenv.h +26 -0
  47. data/ext/libuv/src/ares/ares_gethostbyaddr.c +301 -0
  48. data/ext/libuv/src/ares/ares_gethostbyname.c +523 -0
  49. data/ext/libuv/src/ares/ares_getnameinfo.c +427 -0
  50. data/ext/libuv/src/ares/ares_getopt.c +122 -0
  51. data/ext/libuv/src/ares/ares_getopt.h +53 -0
  52. data/ext/libuv/src/ares/ares_getsock.c +72 -0
  53. data/ext/libuv/src/ares/ares_init.c +1809 -0
  54. data/ext/libuv/src/ares/ares_iphlpapi.h +221 -0
  55. data/ext/libuv/src/ares/ares_ipv6.h +78 -0
  56. data/ext/libuv/src/ares/ares_library_init.c +142 -0
  57. data/ext/libuv/src/ares/ares_library_init.h +42 -0
  58. data/ext/libuv/src/ares/ares_llist.c +86 -0
  59. data/ext/libuv/src/ares/ares_llist.h +42 -0
  60. data/ext/libuv/src/ares/ares_mkquery.c +195 -0
  61. data/ext/libuv/src/ares/ares_nowarn.c +181 -0
  62. data/ext/libuv/src/ares/ares_nowarn.h +55 -0
  63. data/ext/libuv/src/ares/ares_options.c +248 -0
  64. data/ext/libuv/src/ares/ares_parse_a_reply.c +263 -0
  65. data/ext/libuv/src/ares/ares_parse_aaaa_reply.c +259 -0
  66. data/ext/libuv/src/ares/ares_parse_mx_reply.c +170 -0
  67. data/ext/libuv/src/ares/ares_parse_ns_reply.c +182 -0
  68. data/ext/libuv/src/ares/ares_parse_ptr_reply.c +217 -0
  69. data/ext/libuv/src/ares/ares_parse_srv_reply.c +179 -0
  70. data/ext/libuv/src/ares/ares_parse_txt_reply.c +201 -0
  71. data/ext/libuv/src/ares/ares_platform.c +11035 -0
  72. data/ext/libuv/src/ares/ares_platform.h +43 -0
  73. data/ext/libuv/src/ares/ares_private.h +355 -0
  74. data/ext/libuv/src/ares/ares_process.c +1295 -0
  75. data/ext/libuv/src/ares/ares_query.c +183 -0
  76. data/ext/libuv/src/ares/ares_rules.h +144 -0
  77. data/ext/libuv/src/ares/ares_search.c +321 -0
  78. data/ext/libuv/src/ares/ares_send.c +134 -0
  79. data/ext/libuv/src/ares/ares_setup.h +199 -0
  80. data/ext/libuv/src/ares/ares_strcasecmp.c +66 -0
  81. data/ext/libuv/src/ares/ares_strcasecmp.h +30 -0
  82. data/ext/libuv/src/ares/ares_strdup.c +42 -0
  83. data/ext/libuv/src/ares/ares_strdup.h +26 -0
  84. data/ext/libuv/src/ares/ares_strerror.c +56 -0
  85. data/ext/libuv/src/ares/ares_timeout.c +80 -0
  86. data/ext/libuv/src/ares/ares_version.c +11 -0
  87. data/ext/libuv/src/ares/ares_writev.c +79 -0
  88. data/ext/libuv/src/ares/ares_writev.h +36 -0
  89. data/ext/libuv/src/ares/bitncmp.c +59 -0
  90. data/ext/libuv/src/ares/bitncmp.h +26 -0
  91. data/ext/libuv/src/ares/config_cygwin/ares_config.h +512 -0
  92. data/ext/libuv/src/ares/config_darwin/ares_config.h +512 -0
  93. data/ext/libuv/src/ares/config_freebsd/ares_config.h +512 -0
  94. data/ext/libuv/src/ares/config_linux/ares_config.h +512 -0
  95. data/ext/libuv/src/ares/config_netbsd/ares_config.h +512 -0
  96. data/ext/libuv/src/ares/config_openbsd/ares_config.h +512 -0
  97. data/ext/libuv/src/ares/config_sunos/ares_config.h +512 -0
  98. data/ext/libuv/src/ares/config_win32/ares_config.h +369 -0
  99. data/ext/libuv/src/ares/get_ver.awk +35 -0
  100. data/ext/libuv/src/ares/inet_net_pton.c +451 -0
  101. data/ext/libuv/src/ares/inet_net_pton.h +31 -0
  102. data/ext/libuv/src/ares/inet_ntop.c +208 -0
  103. data/ext/libuv/src/ares/inet_ntop.h +26 -0
  104. data/ext/libuv/src/ares/nameser.h +203 -0
  105. data/ext/libuv/src/ares/setup_once.h +504 -0
  106. data/ext/libuv/src/ares/windows_port.c +22 -0
  107. data/ext/libuv/src/cares.c +225 -0
  108. data/ext/libuv/src/fs-poll.c +237 -0
  109. data/ext/libuv/src/unix/async.c +119 -0
  110. data/ext/libuv/src/unix/core.c +647 -0
  111. data/ext/libuv/src/unix/cygwin.c +84 -0
  112. data/ext/libuv/src/unix/darwin.c +341 -0
  113. data/ext/libuv/src/unix/dl.c +83 -0
  114. data/ext/libuv/src/unix/eio/Changes +63 -0
  115. data/ext/libuv/src/unix/eio/LICENSE +36 -0
  116. data/ext/libuv/src/unix/eio/Makefile.am +15 -0
  117. data/ext/libuv/src/unix/eio/aclocal.m4 +8957 -0
  118. data/ext/libuv/src/unix/eio/autogen.sh +3 -0
  119. data/ext/libuv/src/unix/eio/config.h.in +86 -0
  120. data/ext/libuv/src/unix/eio/config_cygwin.h +80 -0
  121. data/ext/libuv/src/unix/eio/config_darwin.h +141 -0
  122. data/ext/libuv/src/unix/eio/config_freebsd.h +81 -0
  123. data/ext/libuv/src/unix/eio/config_linux.h +94 -0
  124. data/ext/libuv/src/unix/eio/config_netbsd.h +81 -0
  125. data/ext/libuv/src/unix/eio/config_openbsd.h +137 -0
  126. data/ext/libuv/src/unix/eio/config_sunos.h +84 -0
  127. data/ext/libuv/src/unix/eio/configure.ac +22 -0
  128. data/ext/libuv/src/unix/eio/demo.c +194 -0
  129. data/ext/libuv/src/unix/eio/ecb.h +370 -0
  130. data/ext/libuv/src/unix/eio/eio.3 +3428 -0
  131. data/ext/libuv/src/unix/eio/eio.c +2593 -0
  132. data/ext/libuv/src/unix/eio/eio.pod +969 -0
  133. data/ext/libuv/src/unix/eio/libeio.m4 +195 -0
  134. data/ext/libuv/src/unix/eio/xthread.h +164 -0
  135. data/ext/libuv/src/unix/error.c +104 -0
  136. data/ext/libuv/src/unix/ev/Changes +388 -0
  137. data/ext/libuv/src/unix/ev/LICENSE +36 -0
  138. data/ext/libuv/src/unix/ev/Makefile.am +18 -0
  139. data/ext/libuv/src/unix/ev/Makefile.in +771 -0
  140. data/ext/libuv/src/unix/ev/README +58 -0
  141. data/ext/libuv/src/unix/ev/aclocal.m4 +8957 -0
  142. data/ext/libuv/src/unix/ev/autogen.sh +6 -0
  143. data/ext/libuv/src/unix/ev/config.guess +1526 -0
  144. data/ext/libuv/src/unix/ev/config.h.in +125 -0
  145. data/ext/libuv/src/unix/ev/config.sub +1658 -0
  146. data/ext/libuv/src/unix/ev/config_cygwin.h +123 -0
  147. data/ext/libuv/src/unix/ev/config_darwin.h +122 -0
  148. data/ext/libuv/src/unix/ev/config_freebsd.h +120 -0
  149. data/ext/libuv/src/unix/ev/config_linux.h +141 -0
  150. data/ext/libuv/src/unix/ev/config_netbsd.h +120 -0
  151. data/ext/libuv/src/unix/ev/config_openbsd.h +126 -0
  152. data/ext/libuv/src/unix/ev/config_sunos.h +122 -0
  153. data/ext/libuv/src/unix/ev/configure +13037 -0
  154. data/ext/libuv/src/unix/ev/configure.ac +18 -0
  155. data/ext/libuv/src/unix/ev/depcomp +630 -0
  156. data/ext/libuv/src/unix/ev/ev++.h +816 -0
  157. data/ext/libuv/src/unix/ev/ev.3 +5311 -0
  158. data/ext/libuv/src/unix/ev/ev.c +3925 -0
  159. data/ext/libuv/src/unix/ev/ev.pod +5243 -0
  160. data/ext/libuv/src/unix/ev/ev_epoll.c +266 -0
  161. data/ext/libuv/src/unix/ev/ev_kqueue.c +235 -0
  162. data/ext/libuv/src/unix/ev/ev_poll.c +148 -0
  163. data/ext/libuv/src/unix/ev/ev_port.c +179 -0
  164. data/ext/libuv/src/unix/ev/ev_select.c +310 -0
  165. data/ext/libuv/src/unix/ev/ev_vars.h +203 -0
  166. data/ext/libuv/src/unix/ev/ev_win32.c +153 -0
  167. data/ext/libuv/src/unix/ev/ev_wrap.h +196 -0
  168. data/ext/libuv/src/unix/ev/event.c +402 -0
  169. data/ext/libuv/src/unix/ev/event.h +170 -0
  170. data/ext/libuv/src/unix/ev/install-sh +294 -0
  171. data/ext/libuv/src/unix/ev/libev.m4 +39 -0
  172. data/ext/libuv/src/unix/ev/ltmain.sh +8413 -0
  173. data/ext/libuv/src/unix/ev/missing +336 -0
  174. data/ext/libuv/src/unix/ev/mkinstalldirs +111 -0
  175. data/ext/libuv/src/unix/freebsd.c +312 -0
  176. data/ext/libuv/src/unix/fs.c +699 -0
  177. data/ext/libuv/src/unix/internal.h +180 -0
  178. data/ext/libuv/src/unix/kqueue.c +122 -0
  179. data/ext/libuv/src/unix/linux/core.c +474 -0
  180. data/ext/libuv/src/unix/linux/inotify.c +209 -0
  181. data/ext/libuv/src/unix/linux/syscalls.c +268 -0
  182. data/ext/libuv/src/unix/linux/syscalls.h +93 -0
  183. data/ext/libuv/src/unix/loop-watcher.c +63 -0
  184. data/ext/libuv/src/unix/loop.c +81 -0
  185. data/ext/libuv/src/unix/netbsd.c +108 -0
  186. data/ext/libuv/src/unix/openbsd.c +295 -0
  187. data/ext/libuv/src/unix/pipe.c +261 -0
  188. data/ext/libuv/src/unix/poll.c +116 -0
  189. data/ext/libuv/src/unix/process.c +447 -0
  190. data/ext/libuv/src/unix/stream.c +1026 -0
  191. data/ext/libuv/src/unix/sunos.c +483 -0
  192. data/ext/libuv/src/unix/tcp.c +328 -0
  193. data/ext/libuv/src/unix/thread.c +211 -0
  194. data/ext/libuv/src/unix/timer.c +138 -0
  195. data/ext/libuv/src/unix/tty.c +146 -0
  196. data/ext/libuv/src/unix/udp.c +661 -0
  197. data/ext/libuv/src/unix/uv-eio.c +107 -0
  198. data/ext/libuv/src/unix/uv-eio.h +13 -0
  199. data/ext/libuv/src/uv-common.c +384 -0
  200. data/ext/libuv/src/uv-common.h +171 -0
  201. data/ext/libuv/src/win/async.c +130 -0
  202. data/ext/libuv/src/win/core.c +283 -0
  203. data/ext/libuv/src/win/dl.c +86 -0
  204. data/ext/libuv/src/win/error.c +150 -0
  205. data/ext/libuv/src/win/fs-event.c +512 -0
  206. data/ext/libuv/src/win/fs.c +1856 -0
  207. data/ext/libuv/src/win/getaddrinfo.c +365 -0
  208. data/ext/libuv/src/win/handle-inl.h +145 -0
  209. data/ext/libuv/src/win/handle.c +150 -0
  210. data/ext/libuv/src/win/internal.h +337 -0
  211. data/ext/libuv/src/win/loop-watcher.c +123 -0
  212. data/ext/libuv/src/win/pipe.c +1675 -0
  213. data/ext/libuv/src/win/poll.c +618 -0
  214. data/ext/libuv/src/win/process-stdio.c +479 -0
  215. data/ext/libuv/src/win/process.c +1013 -0
  216. data/ext/libuv/src/win/req-inl.h +225 -0
  217. data/ext/libuv/src/win/req.c +25 -0
  218. data/ext/libuv/src/win/stream-inl.h +69 -0
  219. data/ext/libuv/src/win/stream.c +167 -0
  220. data/ext/libuv/src/win/tcp.c +1400 -0
  221. data/ext/libuv/src/win/thread.c +372 -0
  222. data/ext/libuv/src/win/threadpool.c +74 -0
  223. data/ext/libuv/src/win/timer.c +226 -0
  224. data/ext/libuv/src/win/tty.c +1801 -0
  225. data/ext/libuv/src/win/udp.c +718 -0
  226. data/ext/libuv/src/win/util.c +864 -0
  227. data/ext/libuv/src/win/winapi.c +132 -0
  228. data/ext/libuv/src/win/winapi.h +4443 -0
  229. data/ext/libuv/src/win/winsock.c +557 -0
  230. data/ext/libuv/src/win/winsock.h +171 -0
  231. data/ext/libuv/test/benchmark-ares.c +117 -0
  232. data/ext/libuv/test/benchmark-fs-stat.c +164 -0
  233. data/ext/libuv/test/benchmark-getaddrinfo.c +94 -0
  234. data/ext/libuv/test/benchmark-list.h +114 -0
  235. data/ext/libuv/test/benchmark-loop-count.c +88 -0
  236. data/ext/libuv/test/benchmark-million-timers.c +65 -0
  237. data/ext/libuv/test/benchmark-ping-pongs.c +213 -0
  238. data/ext/libuv/test/benchmark-pound.c +324 -0
  239. data/ext/libuv/test/benchmark-pump.c +462 -0
  240. data/ext/libuv/test/benchmark-sizes.c +42 -0
  241. data/ext/libuv/test/benchmark-spawn.c +162 -0
  242. data/ext/libuv/test/benchmark-tcp-write-batch.c +140 -0
  243. data/ext/libuv/test/benchmark-thread.c +64 -0
  244. data/ext/libuv/test/benchmark-udp-packet-storm.c +247 -0
  245. data/ext/libuv/test/blackhole-server.c +118 -0
  246. data/ext/libuv/test/dns-server.c +321 -0
  247. data/ext/libuv/test/echo-server.c +378 -0
  248. data/ext/libuv/test/fixtures/empty_file +0 -0
  249. data/ext/libuv/test/fixtures/load_error.node +1 -0
  250. data/ext/libuv/test/run-benchmarks.c +64 -0
  251. data/ext/libuv/test/run-tests.c +138 -0
  252. data/ext/libuv/test/runner-unix.c +290 -0
  253. data/ext/libuv/test/runner-unix.h +36 -0
  254. data/ext/libuv/test/runner-win.c +285 -0
  255. data/ext/libuv/test/runner-win.h +42 -0
  256. data/ext/libuv/test/runner.c +326 -0
  257. data/ext/libuv/test/runner.h +159 -0
  258. data/ext/libuv/test/task.h +109 -0
  259. data/ext/libuv/test/test-async.c +118 -0
  260. data/ext/libuv/test/test-callback-order.c +76 -0
  261. data/ext/libuv/test/test-callback-stack.c +203 -0
  262. data/ext/libuv/test/test-connection-fail.c +148 -0
  263. data/ext/libuv/test/test-counters-init.c +215 -0
  264. data/ext/libuv/test/test-cwd-and-chdir.c +64 -0
  265. data/ext/libuv/test/test-delayed-accept.c +197 -0
  266. data/ext/libuv/test/test-dlerror.c +58 -0
  267. data/ext/libuv/test/test-error.c +59 -0
  268. data/ext/libuv/test/test-fail-always.c +29 -0
  269. data/ext/libuv/test/test-fs-event.c +442 -0
  270. data/ext/libuv/test/test-fs-poll.c +146 -0
  271. data/ext/libuv/test/test-fs.c +1843 -0
  272. data/ext/libuv/test/test-get-currentexe.c +63 -0
  273. data/ext/libuv/test/test-get-loadavg.c +36 -0
  274. data/ext/libuv/test/test-get-memory.c +38 -0
  275. data/ext/libuv/test/test-getaddrinfo.c +122 -0
  276. data/ext/libuv/test/test-gethostbyname.c +189 -0
  277. data/ext/libuv/test/test-getsockname.c +342 -0
  278. data/ext/libuv/test/test-hrtime.c +54 -0
  279. data/ext/libuv/test/test-idle.c +81 -0
  280. data/ext/libuv/test/test-ipc-send-recv.c +209 -0
  281. data/ext/libuv/test/test-ipc.c +620 -0
  282. data/ext/libuv/test/test-list.h +421 -0
  283. data/ext/libuv/test/test-loop-handles.c +336 -0
  284. data/ext/libuv/test/test-multiple-listen.c +102 -0
  285. data/ext/libuv/test/test-mutexes.c +63 -0
  286. data/ext/libuv/test/test-pass-always.c +28 -0
  287. data/ext/libuv/test/test-ping-pong.c +253 -0
  288. data/ext/libuv/test/test-pipe-bind-error.c +140 -0
  289. data/ext/libuv/test/test-pipe-connect-error.c +96 -0
  290. data/ext/libuv/test/test-platform-output.c +87 -0
  291. data/ext/libuv/test/test-poll-close.c +77 -0
  292. data/ext/libuv/test/test-poll.c +573 -0
  293. data/ext/libuv/test/test-process-title.c +42 -0
  294. data/ext/libuv/test/test-ref.c +338 -0
  295. data/ext/libuv/test/test-run-once.c +48 -0
  296. data/ext/libuv/test/test-semaphore.c +111 -0
  297. data/ext/libuv/test/test-shutdown-close.c +103 -0
  298. data/ext/libuv/test/test-shutdown-eof.c +183 -0
  299. data/ext/libuv/test/test-spawn.c +847 -0
  300. data/ext/libuv/test/test-stdio-over-pipes.c +246 -0
  301. data/ext/libuv/test/test-tcp-bind-error.c +191 -0
  302. data/ext/libuv/test/test-tcp-bind6-error.c +154 -0
  303. data/ext/libuv/test/test-tcp-close-while-connecting.c +80 -0
  304. data/ext/libuv/test/test-tcp-close.c +129 -0
  305. data/ext/libuv/test/test-tcp-connect-error-after-write.c +95 -0
  306. data/ext/libuv/test/test-tcp-connect-error.c +70 -0
  307. data/ext/libuv/test/test-tcp-connect-timeout.c +85 -0
  308. data/ext/libuv/test/test-tcp-connect6-error.c +68 -0
  309. data/ext/libuv/test/test-tcp-flags.c +51 -0
  310. data/ext/libuv/test/test-tcp-shutdown-after-write.c +131 -0
  311. data/ext/libuv/test/test-tcp-write-error.c +168 -0
  312. data/ext/libuv/test/test-tcp-write-to-half-open-connection.c +135 -0
  313. data/ext/libuv/test/test-tcp-writealot.c +170 -0
  314. data/ext/libuv/test/test-thread.c +183 -0
  315. data/ext/libuv/test/test-threadpool.c +57 -0
  316. data/ext/libuv/test/test-timer-again.c +141 -0
  317. data/ext/libuv/test/test-timer.c +152 -0
  318. data/ext/libuv/test/test-tty.c +110 -0
  319. data/ext/libuv/test/test-udp-dgram-too-big.c +86 -0
  320. data/ext/libuv/test/test-udp-ipv6.c +156 -0
  321. data/ext/libuv/test/test-udp-multicast-join.c +139 -0
  322. data/ext/libuv/test/test-udp-multicast-ttl.c +86 -0
  323. data/ext/libuv/test/test-udp-options.c +86 -0
  324. data/ext/libuv/test/test-udp-send-and-recv.c +208 -0
  325. data/ext/libuv/test/test-util.c +97 -0
  326. data/ext/libuv/test/test-walk-handles.c +77 -0
  327. data/ext/libuv/uv.gyp +452 -0
  328. data/ext/libuv/vcbuild.bat +105 -0
  329. data/ext/racer/extconf.rb +20 -0
  330. data/ext/racer/http_parser.c +2059 -0
  331. data/ext/racer/http_parser.h +318 -0
  332. data/ext/racer/mkmf.log +22 -0
  333. data/ext/racer/racer.c +551 -0
  334. data/lib/racer.rb +2 -0
  335. data/lib/racer/version.rb +3 -0
  336. metadata +382 -0
@@ -0,0 +1,24 @@
1
+
2
+ #ifndef ARES__VERSION_H
3
+ #define ARES__VERSION_H
4
+
5
+ /* This is the global package copyright */
6
+ #define ARES_COPYRIGHT "2004 - 2010 Daniel Stenberg, <daniel@haxx.se>."
7
+
8
+ #define ARES_VERSION_MAJOR 1
9
+ #define ARES_VERSION_MINOR 7
10
+ #define ARES_VERSION_PATCH 5
11
+ #define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
12
+ (ARES_VERSION_MINOR<<8)|\
13
+ (ARES_VERSION_PATCH))
14
+ #define ARES_VERSION_STR "1.7.5-DEV"
15
+
16
+ #if (ARES_VERSION >= 0x010700)
17
+ # define CARES_HAVE_ARES_LIBRARY_INIT 1
18
+ # define CARES_HAVE_ARES_LIBRARY_CLEANUP 1
19
+ #else
20
+ # undef CARES_HAVE_ARES_LIBRARY_INIT
21
+ # undef CARES_HAVE_ARES_LIBRARY_CLEANUP
22
+ #endif
23
+
24
+ #endif
@@ -0,0 +1,403 @@
1
+ /*
2
+ * libeio API header
3
+ *
4
+ * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libeio@schmorp.de>
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without modifica-
8
+ * tion, are permitted provided that the following conditions are met:
9
+ *
10
+ * 1. Redistributions of source code must retain the above copyright notice,
11
+ * this list of conditions and the following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above copyright
14
+ * notice, this list of conditions and the following disclaimer in the
15
+ * documentation and/or other materials provided with the distribution.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
19
+ * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
21
+ * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
25
+ * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
26
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ *
28
+ * Alternatively, the contents of this file may be used under the terms of
29
+ * the GNU General Public License ("GPL") version 2 or any later version,
30
+ * in which case the provisions of the GPL are applicable instead of
31
+ * the above. If you wish to allow the use of your version of this file
32
+ * only under the terms of the GPL and not to allow others to use your
33
+ * version of this file under the BSD license, indicate your decision
34
+ * by deleting the provisions above and replace them with the notice
35
+ * and other provisions required by the GPL. If you do not delete the
36
+ * provisions above, a recipient may use your version of this file under
37
+ * either the BSD or the GPL.
38
+ */
39
+
40
+ #ifndef EIO_H_
41
+ #define EIO_H_
42
+
43
+ #ifdef __cplusplus
44
+ extern "C" {
45
+ #endif
46
+
47
+ #include <stddef.h>
48
+ #include <signal.h>
49
+ #include <sys/types.h>
50
+
51
+ typedef struct eio_req eio_req;
52
+ typedef struct eio_dirent eio_dirent;
53
+
54
+ typedef int (*eio_cb)(eio_req *req);
55
+
56
+ #ifndef EIO_REQ_MEMBERS
57
+ # define EIO_REQ_MEMBERS
58
+ #endif
59
+
60
+ #ifndef EIO_STRUCT_STAT
61
+ # ifdef _WIN32
62
+ # define EIO_STRUCT_STAT struct _stati64
63
+ # define EIO_STRUCT_STATI64
64
+ # else
65
+ # define EIO_STRUCT_STAT struct stat
66
+ # endif
67
+ #endif
68
+
69
+ #ifdef _WIN32
70
+ typedef int eio_uid_t;
71
+ typedef int eio_gid_t;
72
+ typedef int eio_mode_t;
73
+ #ifdef __MINGW32__ /* no intptr_t */
74
+ typedef ssize_t eio_ssize_t;
75
+ #else
76
+ typedef intptr_t eio_ssize_t; /* or SSIZE_T */
77
+ #endif
78
+ #if __GNUC__
79
+ typedef long long eio_ino_t;
80
+ #else
81
+ typedef __int64 eio_ino_t; /* unsigned not supported by msvc */
82
+ #endif
83
+ #else
84
+ typedef uid_t eio_uid_t;
85
+ typedef gid_t eio_gid_t;
86
+ typedef ssize_t eio_ssize_t;
87
+ typedef ino_t eio_ino_t;
88
+ typedef mode_t eio_mode_t;
89
+ #endif
90
+
91
+ #ifndef EIO_STRUCT_STATVFS
92
+ # define EIO_STRUCT_STATVFS struct statvfs
93
+ #endif
94
+
95
+ /* for readdir */
96
+
97
+ /* eio_readdir flags */
98
+ enum
99
+ {
100
+ EIO_READDIR_DENTS = 0x01, /* ptr2 contains eio_dirents, not just the (unsorted) names */
101
+ EIO_READDIR_DIRS_FIRST = 0x02, /* dirents gets sorted into a good stat() ing order to find directories first */
102
+ EIO_READDIR_STAT_ORDER = 0x04, /* dirents gets sorted into a good stat() ing order to quickly stat all files */
103
+ EIO_READDIR_FOUND_UNKNOWN = 0x80, /* set by eio_readdir when *_ARRAY was set and any TYPE=UNKNOWN's were found */
104
+
105
+ EIO_READDIR_CUSTOM1 = 0x100, /* for use by apps */
106
+ EIO_READDIR_CUSTOM2 = 0x200 /* for use by apps */
107
+ };
108
+
109
+ /* using "typical" values in the hope that the compiler will do something sensible */
110
+ enum eio_dtype
111
+ {
112
+ EIO_DT_UNKNOWN = 0,
113
+ EIO_DT_FIFO = 1,
114
+ EIO_DT_CHR = 2,
115
+ EIO_DT_MPC = 3, /* multiplexed char device (v7+coherent) */
116
+ EIO_DT_DIR = 4,
117
+ EIO_DT_NAM = 5, /* xenix special named file */
118
+ EIO_DT_BLK = 6,
119
+ EIO_DT_MPB = 7, /* multiplexed block device (v7+coherent) */
120
+ EIO_DT_REG = 8,
121
+ EIO_DT_NWK = 9, /* HP-UX network special */
122
+ EIO_DT_CMP = 9, /* VxFS compressed */
123
+ EIO_DT_LNK = 10,
124
+ /* DT_SHAD = 11,*/
125
+ EIO_DT_SOCK = 12,
126
+ EIO_DT_DOOR = 13, /* solaris door */
127
+ EIO_DT_WHT = 14,
128
+ EIO_DT_MAX = 15 /* highest DT_VALUE ever, hopefully */
129
+ };
130
+
131
+ struct eio_dirent
132
+ {
133
+ int nameofs; /* offset of null-terminated name string in (char *)req->ptr2 */
134
+ unsigned short namelen; /* size of filename without trailing 0 */
135
+ unsigned char type; /* one of EIO_DT_* */
136
+ signed char score; /* internal use */
137
+ eio_ino_t inode; /* the inode number, if available, otherwise unspecified */
138
+ };
139
+
140
+ /* eio_msync flags */
141
+ enum
142
+ {
143
+ EIO_MS_ASYNC = 1,
144
+ EIO_MS_INVALIDATE = 2,
145
+ EIO_MS_SYNC = 4
146
+ };
147
+
148
+ /* eio_mtouch flags */
149
+ enum
150
+ {
151
+ EIO_MT_MODIFY = 1
152
+ };
153
+
154
+ /* eio_sync_file_range flags */
155
+ enum
156
+ {
157
+ EIO_SYNC_FILE_RANGE_WAIT_BEFORE = 1,
158
+ EIO_SYNC_FILE_RANGE_WRITE = 2,
159
+ EIO_SYNC_FILE_RANGE_WAIT_AFTER = 4
160
+ };
161
+
162
+ /* eio_fallocate flags */
163
+ enum
164
+ {
165
+ EIO_FALLOC_FL_KEEP_SIZE = 1 /* MUST match the value in linux/falloc.h */
166
+ };
167
+
168
+ /* timestamps and differences - feel free to use double in your code directly */
169
+ typedef double eio_tstamp;
170
+
171
+ /* the eio request structure */
172
+ enum
173
+ {
174
+ EIO_CUSTOM,
175
+ EIO_OPEN, EIO_CLOSE, EIO_DUP2,
176
+ EIO_READ, EIO_WRITE,
177
+ EIO_READAHEAD, EIO_SENDFILE,
178
+ EIO_STAT, EIO_LSTAT, EIO_FSTAT,
179
+ EIO_STATVFS, EIO_FSTATVFS,
180
+ EIO_TRUNCATE, EIO_FTRUNCATE,
181
+ EIO_UTIME, EIO_FUTIME,
182
+ EIO_CHMOD, EIO_FCHMOD,
183
+ EIO_CHOWN, EIO_FCHOWN,
184
+ EIO_SYNC, EIO_FSYNC, EIO_FDATASYNC, EIO_SYNCFS,
185
+ EIO_MSYNC, EIO_MTOUCH, EIO_SYNC_FILE_RANGE, EIO_FALLOCATE,
186
+ EIO_MLOCK, EIO_MLOCKALL,
187
+ EIO_UNLINK, EIO_RMDIR, EIO_MKDIR, EIO_RENAME,
188
+ EIO_MKNOD, EIO_READDIR,
189
+ EIO_LINK, EIO_SYMLINK, EIO_READLINK, EIO_REALPATH,
190
+ EIO_GROUP, EIO_NOP,
191
+ EIO_BUSY
192
+ };
193
+
194
+ /* mlockall constants */
195
+ enum
196
+ {
197
+ EIO_MCL_CURRENT = 1,
198
+ EIO_MCL_FUTURE = 2
199
+ };
200
+
201
+ /* request priorities */
202
+
203
+ enum {
204
+ EIO_PRI_MIN = -4,
205
+ EIO_PRI_MAX = 4,
206
+ EIO_PRI_DEFAULT = 0
207
+ };
208
+
209
+ #define ETP_PRI_MIN EIO_PRI_MIN
210
+ #define ETP_PRI_MAX EIO_PRI_MAX
211
+
212
+ #define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1)
213
+
214
+ #define ETP_REQ eio_req
215
+
216
+ /*
217
+ * a somewhat faster data structure might be nice, but
218
+ * with 8 priorities this actually needs <20 insns
219
+ * per shift, the most expensive operation.
220
+ */
221
+ typedef struct {
222
+ ETP_REQ *qs[ETP_NUM_PRI], *qe[ETP_NUM_PRI]; /* qstart, qend */
223
+ int size;
224
+ } etp_reqq;
225
+
226
+ typedef struct {
227
+ etp_reqq res_queue; /* queue of outstanding responses for this channel */
228
+ void *data; /* use this for what you want */
229
+ } eio_channel;
230
+
231
+ /* eio request structure */
232
+ /* this structure is mostly read-only */
233
+ /* when initialising it, all members must be zero-initialised */
234
+ struct eio_req
235
+ {
236
+ eio_req volatile *next; /* private ETP */
237
+
238
+ eio_ssize_t result; /* result of syscall, e.g. result = read (... */
239
+ off_t offs; /* read, write, truncate, readahead, sync_file_range, fallocate: file offset, mknod: dev_t */
240
+ size_t size; /* read, write, readahead, sendfile, msync, mlock, sync_file_range, fallocate: length */
241
+ void *ptr1; /* all applicable requests: pathname, old name; readdir: optional eio_dirents */
242
+ void *ptr2; /* all applicable requests: new name or memory buffer; readdir: name strings */
243
+ eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */
244
+ eio_tstamp nv2; /* utime, futime: mtime */
245
+
246
+ int type; /* EIO_xxx constant ETP */
247
+ int int1; /* all applicable requests: file descriptor; sendfile: output fd; open, msync, mlockall, readdir: flags */
248
+ long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode, sync_file_range, fallocate: flags */
249
+ long int3; /* chown, fchown: gid */
250
+ int errorno; /* errno value on syscall return */
251
+
252
+ eio_channel *channel; /* data used to direct poll callbacks arising from this req */
253
+
254
+ #if __i386 || __amd64
255
+ unsigned char cancelled;
256
+ #else
257
+ sig_atomic_t cancelled;
258
+ #endif
259
+
260
+ unsigned char flags; /* private */
261
+ signed char pri; /* the priority */
262
+
263
+ void *data;
264
+ eio_cb finish;
265
+ void (*destroy)(eio_req *req); /* called when request no longer needed */
266
+ void (*feed)(eio_req *req); /* only used for group requests */
267
+
268
+ EIO_REQ_MEMBERS
269
+
270
+ eio_req *grp, *grp_prev, *grp_next, *grp_first; /* private */
271
+ };
272
+
273
+ /* _private_ request flags */
274
+ enum {
275
+ EIO_FLAG_PTR1_FREE = 0x01, /* need to free(ptr1) */
276
+ EIO_FLAG_PTR2_FREE = 0x02, /* need to free(ptr2) */
277
+ EIO_FLAG_GROUPADD = 0x04 /* some request was added to the group */
278
+ };
279
+
280
+ /* undocumented/unsupported/private helper */
281
+ /*void eio_page_align (void **addr, size_t *length);*/
282
+
283
+ /* returns < 0 on error, errno set
284
+ * need_poll, if non-zero, will be called when results are available
285
+ * and eio_poll_cb needs to be invoked (it MUST NOT call eio_poll_cb itself).
286
+ * done_poll is called when the need to poll is gone.
287
+ */
288
+ int eio_init (void (*want_poll)(eio_channel *), void (*done_poll)(eio_channel *));
289
+
290
+ /* initialises a channel */
291
+ void eio_channel_init(eio_channel *, void *data);
292
+
293
+ /* must be called regularly to handle pending requests */
294
+ /* returns 0 if all requests were handled, -1 if not, or the value of EIO_FINISH if != 0 */
295
+ int eio_poll (eio_channel *channel);
296
+
297
+ /* stop polling if poll took longer than duration seconds */
298
+ void eio_set_max_poll_time (eio_tstamp nseconds);
299
+ /* do not handle more then count requests in one call to eio_poll_cb */
300
+ void eio_set_max_poll_reqs (unsigned int nreqs);
301
+
302
+ /* set minimum required number
303
+ * maximum wanted number
304
+ * or maximum idle number of threads */
305
+ void eio_set_min_parallel (unsigned int nthreads);
306
+ void eio_set_max_parallel (unsigned int nthreads);
307
+ void eio_set_max_idle (unsigned int nthreads);
308
+ void eio_set_idle_timeout (unsigned int seconds);
309
+
310
+ unsigned int eio_nreqs (void); /* number of requests in-flight */
311
+ unsigned int eio_nready (void); /* number of not-yet handled requests */
312
+ unsigned int eio_npending (void); /* number of finished but unhandled requests */
313
+ unsigned int eio_nthreads (void); /* number of worker threads in use currently */
314
+
315
+ /*****************************************************************************/
316
+ /* convenience wrappers */
317
+
318
+ #ifndef EIO_NO_WRAPPERS
319
+ eio_req *eio_nop (int pri, eio_cb cb, void *data, eio_channel *channel); /* does nothing except go through the whole process */
320
+ eio_req *eio_busy (eio_tstamp delay, int pri, eio_cb cb, void *data, eio_channel *channel); /* ties a thread for this long, simulating busyness */
321
+ eio_req *eio_sync (int pri, eio_cb cb, void *data, eio_channel *channel);
322
+ eio_req *eio_fsync (int fd, int pri, eio_cb cb, void *data, eio_channel *channel);
323
+ eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data, eio_channel *channel);
324
+ eio_req *eio_syncfs (int fd, int pri, eio_cb cb, void *data, eio_channel *channel);
325
+ eio_req *eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data, eio_channel *channel);
326
+ eio_req *eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data, eio_channel *channel);
327
+ eio_req *eio_mlock (void *addr, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel);
328
+ eio_req *eio_mlockall (int flags, int pri, eio_cb cb, void *data, eio_channel *channel);
329
+ eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data, eio_channel *channel);
330
+ eio_req *eio_fallocate (int fd, int mode, off_t offset, size_t len, int pri, eio_cb cb, void *data, eio_channel *channel);
331
+ eio_req *eio_close (int fd, int pri, eio_cb cb, void *data, eio_channel *channel);
332
+ eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel);
333
+ eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel);
334
+ eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel);
335
+ eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */
336
+ eio_req *eio_fstatvfs (int fd, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */
337
+ eio_req *eio_futime (int fd, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data, eio_channel *channel);
338
+ eio_req *eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel);
339
+ eio_req *eio_fchmod (int fd, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel);
340
+ eio_req *eio_fchown (int fd, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data, eio_channel *channel);
341
+ eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data, eio_channel *channel);
342
+ eio_req *eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel);
343
+ eio_req *eio_open (const char *path, int flags, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel);
344
+ eio_req *eio_utime (const char *path, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data, eio_channel *channel);
345
+ eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel);
346
+ eio_req *eio_chown (const char *path, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data, eio_channel *channel);
347
+ eio_req *eio_chmod (const char *path, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel);
348
+ eio_req *eio_mkdir (const char *path, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel);
349
+ eio_req *eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *data, eio_channel *channel); /* result=ptr2 allocated dynamically */
350
+ eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel);
351
+ eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel);
352
+ eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* result=ptr2 allocated dynamically */
353
+ eio_req *eio_realpath (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* result=ptr2 allocated dynamically */
354
+ eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */
355
+ eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */
356
+ eio_req *eio_statvfs (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */
357
+ eio_req *eio_mknod (const char *path, eio_mode_t mode, dev_t dev, int pri, eio_cb cb, void *data, eio_channel *channel);
358
+ eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel);
359
+ eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel);
360
+ eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel);
361
+ eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data, eio_channel *channel);
362
+ #endif
363
+
364
+ /*****************************************************************************/
365
+ /* groups */
366
+
367
+ eio_req *eio_grp (eio_cb cb, void *data, eio_channel *channel);
368
+ void eio_grp_feed (eio_req *grp, void (*feed)(eio_req *req), int limit);
369
+ void eio_grp_limit (eio_req *grp, int limit);
370
+ void eio_grp_add (eio_req *grp, eio_req *req);
371
+ void eio_grp_cancel (eio_req *grp); /* cancels all sub requests but not the group */
372
+
373
+ /*****************************************************************************/
374
+ /* request api */
375
+
376
+ /* true if the request was cancelled, useful in the invoke callback */
377
+ #define EIO_CANCELLED(req) ((req)->cancelled)
378
+
379
+ #define EIO_RESULT(req) ((req)->result)
380
+ /* returns a pointer to the result buffer allocated by eio */
381
+ #define EIO_BUF(req) ((req)->ptr2)
382
+ #define EIO_STAT_BUF(req) ((EIO_STRUCT_STAT *)EIO_BUF(req))
383
+ #define EIO_STATVFS_BUF(req) ((EIO_STRUCT_STATVFS *)EIO_BUF(req))
384
+ #define EIO_PATH(req) ((char *)(req)->ptr1)
385
+
386
+ /* submit a request for execution */
387
+ void eio_submit (eio_req *req);
388
+ /* cancel a request as soon fast as possible, if possible */
389
+ void eio_cancel (eio_req *req);
390
+
391
+ /*****************************************************************************/
392
+ /* convenience functions */
393
+
394
+ eio_ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count);
395
+ eio_ssize_t eio__pread (int fd, void *buf, size_t count, off_t offset);
396
+ eio_ssize_t eio__pwrite (int fd, void *buf, size_t count, off_t offset);
397
+
398
+ #ifdef __cplusplus
399
+ }
400
+ #endif
401
+
402
+ #endif
403
+
@@ -0,0 +1,838 @@
1
+ /*
2
+ * libev native API header
3
+ *
4
+ * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without modifica-
8
+ * tion, are permitted provided that the following conditions are met:
9
+ *
10
+ * 1. Redistributions of source code must retain the above copyright notice,
11
+ * this list of conditions and the following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above copyright
14
+ * notice, this list of conditions and the following disclaimer in the
15
+ * documentation and/or other materials provided with the distribution.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
19
+ * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
21
+ * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
25
+ * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
26
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ *
28
+ * Alternatively, the contents of this file may be used under the terms of
29
+ * the GNU General Public License ("GPL") version 2 or any later version,
30
+ * in which case the provisions of the GPL are applicable instead of
31
+ * the above. If you wish to allow the use of your version of this file
32
+ * only under the terms of the GPL and not to allow others to use your
33
+ * version of this file under the BSD license, indicate your decision
34
+ * by deleting the provisions above and replace them with the notice
35
+ * and other provisions required by the GPL. If you do not delete the
36
+ * provisions above, a recipient may use your version of this file under
37
+ * either the BSD or the GPL.
38
+ */
39
+
40
+ #ifndef EV_H_
41
+ #define EV_H_
42
+
43
+ #ifdef __cplusplus
44
+ # define EV_CPP(x) x
45
+ #else
46
+ # define EV_CPP(x)
47
+ #endif
48
+
49
+ EV_CPP(extern "C" {)
50
+
51
+ #ifdef __GNUC__
52
+ # define EV_MAYBE_UNUSED __attribute__ ((unused))
53
+ #else
54
+ # define EV_MAYBE_UNUSED
55
+ #endif
56
+
57
+ /*****************************************************************************/
58
+
59
+ /* pre-4.0 compatibility */
60
+ #ifndef EV_COMPAT3
61
+ # define EV_COMPAT3 1
62
+ #endif
63
+
64
+ #ifndef EV_FEATURES
65
+ # define EV_FEATURES 0x7f
66
+ #endif
67
+
68
+ #define EV_FEATURE_CODE ((EV_FEATURES) & 1)
69
+ #define EV_FEATURE_DATA ((EV_FEATURES) & 2)
70
+ #define EV_FEATURE_CONFIG ((EV_FEATURES) & 4)
71
+ #define EV_FEATURE_API ((EV_FEATURES) & 8)
72
+ #define EV_FEATURE_WATCHERS ((EV_FEATURES) & 16)
73
+ #define EV_FEATURE_BACKENDS ((EV_FEATURES) & 32)
74
+ #define EV_FEATURE_OS ((EV_FEATURES) & 64)
75
+
76
+ /* these priorities are inclusive, higher priorities will be invoked earlier */
77
+ #ifndef EV_MINPRI
78
+ # define EV_MINPRI (EV_FEATURE_CONFIG ? -2 : 0)
79
+ #endif
80
+ #ifndef EV_MAXPRI
81
+ # define EV_MAXPRI (EV_FEATURE_CONFIG ? +2 : 0)
82
+ #endif
83
+
84
+ #ifndef EV_MULTIPLICITY
85
+ # define EV_MULTIPLICITY EV_FEATURE_CONFIG
86
+ #endif
87
+
88
+ #ifndef EV_PERIODIC_ENABLE
89
+ # define EV_PERIODIC_ENABLE EV_FEATURE_WATCHERS
90
+ #endif
91
+
92
+ #ifndef EV_STAT_ENABLE
93
+ # define EV_STAT_ENABLE EV_FEATURE_WATCHERS
94
+ #endif
95
+
96
+ #ifndef EV_PREPARE_ENABLE
97
+ # define EV_PREPARE_ENABLE EV_FEATURE_WATCHERS
98
+ #endif
99
+
100
+ #ifndef EV_CHECK_ENABLE
101
+ # define EV_CHECK_ENABLE EV_FEATURE_WATCHERS
102
+ #endif
103
+
104
+ #ifndef EV_IDLE_ENABLE
105
+ # define EV_IDLE_ENABLE EV_FEATURE_WATCHERS
106
+ #endif
107
+
108
+ #ifndef EV_FORK_ENABLE
109
+ # define EV_FORK_ENABLE EV_FEATURE_WATCHERS
110
+ #endif
111
+
112
+ #ifndef EV_CLEANUP_ENABLE
113
+ # define EV_CLEANUP_ENABLE EV_FEATURE_WATCHERS
114
+ #endif
115
+
116
+ #ifndef EV_SIGNAL_ENABLE
117
+ # define EV_SIGNAL_ENABLE EV_FEATURE_WATCHERS
118
+ #endif
119
+
120
+ #ifndef EV_CHILD_ENABLE
121
+ # ifdef _WIN32
122
+ # define EV_CHILD_ENABLE 0
123
+ # else
124
+ # define EV_CHILD_ENABLE EV_FEATURE_WATCHERS
125
+ #endif
126
+ #endif
127
+
128
+ #ifndef EV_ASYNC_ENABLE
129
+ # define EV_ASYNC_ENABLE EV_FEATURE_WATCHERS
130
+ #endif
131
+
132
+ #ifndef EV_EMBED_ENABLE
133
+ # define EV_EMBED_ENABLE EV_FEATURE_WATCHERS
134
+ #endif
135
+
136
+ #ifndef EV_WALK_ENABLE
137
+ # define EV_WALK_ENABLE 0 /* not yet */
138
+ #endif
139
+
140
+ /*****************************************************************************/
141
+
142
+ #if EV_CHILD_ENABLE && !EV_SIGNAL_ENABLE
143
+ # undef EV_SIGNAL_ENABLE
144
+ # define EV_SIGNAL_ENABLE 1
145
+ #endif
146
+
147
+ /*****************************************************************************/
148
+
149
+ typedef double ev_tstamp;
150
+
151
+ #ifndef EV_ATOMIC_T
152
+ # include <signal.h>
153
+ # define EV_ATOMIC_T sig_atomic_t volatile
154
+ #endif
155
+
156
+ #if EV_STAT_ENABLE
157
+ # ifdef _WIN32
158
+ # include <time.h>
159
+ # include <sys/types.h>
160
+ # endif
161
+ # include <sys/stat.h>
162
+ #endif
163
+
164
+ /* support multiple event loops? */
165
+ #if EV_MULTIPLICITY
166
+ struct ev_loop;
167
+ # define EV_P struct ev_loop *loop /* a loop as sole parameter in a declaration */
168
+ # define EV_P_ EV_P, /* a loop as first of multiple parameters */
169
+ # define EV_A loop /* a loop as sole argument to a function call */
170
+ # define EV_A_ EV_A, /* a loop as first of multiple arguments */
171
+ # define EV_DEFAULT_UC ev_default_loop_uc_ () /* the default loop, if initialised, as sole arg */
172
+ # define EV_DEFAULT_UC_ EV_DEFAULT_UC, /* the default loop as first of multiple arguments */
173
+ # define EV_DEFAULT ev_default_loop (0) /* the default loop as sole arg */
174
+ # define EV_DEFAULT_ EV_DEFAULT, /* the default loop as first of multiple arguments */
175
+ #else
176
+ # define EV_P void
177
+ # define EV_P_
178
+ # define EV_A
179
+ # define EV_A_
180
+ # define EV_DEFAULT
181
+ # define EV_DEFAULT_
182
+ # define EV_DEFAULT_UC
183
+ # define EV_DEFAULT_UC_
184
+ # undef EV_EMBED_ENABLE
185
+ #endif
186
+
187
+ /* EV_INLINE is used for functions in header files */
188
+ #if __STDC_VERSION__ >= 199901L && __GNUC__ >= 3
189
+ # define EV_INLINE static inline
190
+ #else
191
+ # define EV_INLINE static
192
+ #endif
193
+
194
+ /* EV_PROTOTYPES can be used to switch of prototype declarations */
195
+ #ifndef EV_PROTOTYPES
196
+ # define EV_PROTOTYPES 1
197
+ #endif
198
+
199
+ /*****************************************************************************/
200
+
201
+ #define EV_VERSION_MAJOR 4
202
+ #define EV_VERSION_MINOR 4
203
+
204
+ /* eventmask, revents, events... */
205
+ enum {
206
+ EV_UNDEF = -1, /* guaranteed to be invalid */
207
+ EV_NONE = 0x00, /* no events */
208
+ EV_READ = 0x01, /* ev_io detected read will not block */
209
+ EV_WRITE = 0x02, /* ev_io detected write will not block */
210
+ EV_LIBUV_KQUEUE_HACK = 0x40,
211
+ EV__IOFDSET = 0x80, /* internal use only */
212
+ EV_IO = EV_READ, /* alias for type-detection */
213
+ EV_TIMER = 0x00000100, /* timer timed out */
214
+ #if EV_COMPAT3
215
+ EV_TIMEOUT = EV_TIMER, /* pre 4.0 API compatibility */
216
+ #endif
217
+ EV_PERIODIC = 0x00000200, /* periodic timer timed out */
218
+ EV_SIGNAL = 0x00000400, /* signal was received */
219
+ EV_CHILD = 0x00000800, /* child/pid had status change */
220
+ EV_STAT = 0x00001000, /* stat data changed */
221
+ EV_IDLE = 0x00002000, /* event loop is idling */
222
+ EV_PREPARE = 0x00004000, /* event loop about to poll */
223
+ EV_CHECK = 0x00008000, /* event loop finished poll */
224
+ EV_EMBED = 0x00010000, /* embedded event loop needs sweep */
225
+ EV_FORK = 0x00020000, /* event loop resumed in child */
226
+ EV_CLEANUP = 0x00040000, /* event loop resumed in child */
227
+ EV_ASYNC = 0x00080000, /* async intra-loop signal */
228
+ EV_CUSTOM = 0x01000000, /* for use by user code */
229
+ EV_ERROR = (-2147483647 - 1) /* sent when an error occurs */
230
+ };
231
+
232
+ /* can be used to add custom fields to all watchers, while losing binary compatibility */
233
+ #ifndef EV_COMMON
234
+ # define EV_COMMON void *data;
235
+ #endif
236
+
237
+ #ifndef EV_CB_DECLARE
238
+ # define EV_CB_DECLARE(type) void (*cb)(EV_P_ struct type *w, int revents);
239
+ #endif
240
+ #ifndef EV_CB_INVOKE
241
+ # define EV_CB_INVOKE(watcher,revents) (watcher)->cb (EV_A_ (watcher), (revents))
242
+ #endif
243
+
244
+ /* not official, do not use */
245
+ #define EV_CB(type,name) void name (EV_P_ struct ev_ ## type *w, int revents)
246
+
247
+ /*
248
+ * struct member types:
249
+ * private: you may look at them, but not change them,
250
+ * and they might not mean anything to you.
251
+ * ro: can be read anytime, but only changed when the watcher isn't active.
252
+ * rw: can be read and modified anytime, even when the watcher is active.
253
+ *
254
+ * some internal details that might be helpful for debugging:
255
+ *
256
+ * active is either 0, which means the watcher is not active,
257
+ * or the array index of the watcher (periodics, timers)
258
+ * or the array index + 1 (most other watchers)
259
+ * or simply 1 for watchers that aren't in some array.
260
+ * pending is either 0, in which case the watcher isn't,
261
+ * or the array index + 1 in the pendings array.
262
+ */
263
+
264
+ #if EV_MINPRI == EV_MAXPRI
265
+ # define EV_DECL_PRIORITY
266
+ #elif !defined (EV_DECL_PRIORITY)
267
+ # define EV_DECL_PRIORITY int priority;
268
+ #endif
269
+
270
+ /* shared by all watchers */
271
+ #define EV_WATCHER(type) \
272
+ int active; /* private */ \
273
+ int pending; /* private */ \
274
+ EV_DECL_PRIORITY /* private */ \
275
+ EV_COMMON /* rw */ \
276
+ EV_CB_DECLARE (type) /* private */
277
+
278
+ #define EV_WATCHER_LIST(type) \
279
+ EV_WATCHER (type) \
280
+ struct ev_watcher_list *next; /* private */
281
+
282
+ #define EV_WATCHER_TIME(type) \
283
+ EV_WATCHER (type) \
284
+ ev_tstamp at; /* private */
285
+
286
+ /* base class, nothing to see here unless you subclass */
287
+ typedef struct ev_watcher
288
+ {
289
+ EV_WATCHER (ev_watcher)
290
+ } ev_watcher;
291
+
292
+ /* base class, nothing to see here unless you subclass */
293
+ typedef struct ev_watcher_list
294
+ {
295
+ EV_WATCHER_LIST (ev_watcher_list)
296
+ } ev_watcher_list;
297
+
298
+ /* base class, nothing to see here unless you subclass */
299
+ typedef struct ev_watcher_time
300
+ {
301
+ EV_WATCHER_TIME (ev_watcher_time)
302
+ } ev_watcher_time;
303
+
304
+ /* invoked when fd is either EV_READable or EV_WRITEable */
305
+ /* revent EV_READ, EV_WRITE */
306
+ typedef struct ev_io
307
+ {
308
+ EV_WATCHER_LIST (ev_io)
309
+
310
+ int fd; /* ro */
311
+ int events; /* ro */
312
+ } ev_io;
313
+
314
+ /* invoked after a specific time, repeatable (based on monotonic clock) */
315
+ /* revent EV_TIMEOUT */
316
+ typedef struct ev_timer
317
+ {
318
+ EV_WATCHER_TIME (ev_timer)
319
+
320
+ ev_tstamp repeat; /* rw */
321
+ } ev_timer;
322
+
323
+ /* invoked at some specific time, possibly repeating at regular intervals (based on UTC) */
324
+ /* revent EV_PERIODIC */
325
+ typedef struct ev_periodic
326
+ {
327
+ EV_WATCHER_TIME (ev_periodic)
328
+
329
+ ev_tstamp offset; /* rw */
330
+ ev_tstamp interval; /* rw */
331
+ ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now); /* rw */
332
+ } ev_periodic;
333
+
334
+ /* invoked when the given signal has been received */
335
+ /* revent EV_SIGNAL */
336
+ typedef struct ev_signal
337
+ {
338
+ EV_WATCHER_LIST (ev_signal)
339
+
340
+ int signum; /* ro */
341
+ } ev_signal;
342
+
343
+ /* invoked when sigchld is received and waitpid indicates the given pid */
344
+ /* revent EV_CHILD */
345
+ /* does not support priorities */
346
+ typedef struct ev_child
347
+ {
348
+ EV_WATCHER_LIST (ev_child)
349
+
350
+ int flags; /* private */
351
+ int pid; /* ro */
352
+ int rpid; /* rw, holds the received pid */
353
+ int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */
354
+ } ev_child;
355
+
356
+ #if EV_STAT_ENABLE
357
+ /* st_nlink = 0 means missing file or other error */
358
+ # ifdef _WIN32
359
+ typedef struct _stati64 ev_statdata;
360
+ # else
361
+ typedef struct stat ev_statdata;
362
+ # endif
363
+
364
+ /* invoked each time the stat data changes for a given path */
365
+ /* revent EV_STAT */
366
+ typedef struct ev_stat
367
+ {
368
+ EV_WATCHER_LIST (ev_stat)
369
+
370
+ ev_timer timer; /* private */
371
+ ev_tstamp interval; /* ro */
372
+ const char *path; /* ro */
373
+ ev_statdata prev; /* ro */
374
+ ev_statdata attr; /* ro */
375
+
376
+ int wd; /* wd for inotify, fd for kqueue */
377
+ } ev_stat;
378
+ #endif
379
+
380
+ #if EV_IDLE_ENABLE
381
+ /* invoked when the nothing else needs to be done, keeps the process from blocking */
382
+ /* revent EV_IDLE */
383
+ typedef struct ev_idle
384
+ {
385
+ EV_WATCHER (ev_idle)
386
+ } ev_idle;
387
+ #endif
388
+
389
+ /* invoked for each run of the mainloop, just before the blocking call */
390
+ /* you can still change events in any way you like */
391
+ /* revent EV_PREPARE */
392
+ typedef struct ev_prepare
393
+ {
394
+ EV_WATCHER (ev_prepare)
395
+ } ev_prepare;
396
+
397
+ /* invoked for each run of the mainloop, just after the blocking call */
398
+ /* revent EV_CHECK */
399
+ typedef struct ev_check
400
+ {
401
+ EV_WATCHER (ev_check)
402
+ } ev_check;
403
+
404
+ #if EV_FORK_ENABLE
405
+ /* the callback gets invoked before check in the child process when a fork was detected */
406
+ /* revent EV_FORK */
407
+ typedef struct ev_fork
408
+ {
409
+ EV_WATCHER (ev_fork)
410
+ } ev_fork;
411
+ #endif
412
+
413
+ #if EV_CLEANUP_ENABLE
414
+ /* is invoked just before the loop gets destroyed */
415
+ /* revent EV_CLEANUP */
416
+ typedef struct ev_cleanup
417
+ {
418
+ EV_WATCHER (ev_cleanup)
419
+ } ev_cleanup;
420
+ #endif
421
+
422
+ #if EV_EMBED_ENABLE
423
+ /* used to embed an event loop inside another */
424
+ /* the callback gets invoked when the event loop has handled events, and can be 0 */
425
+ typedef struct ev_embed
426
+ {
427
+ EV_WATCHER (ev_embed)
428
+
429
+ struct ev_loop *other; /* ro */
430
+ ev_io io; /* private */
431
+ ev_prepare prepare; /* private */
432
+ ev_check check; /* unused */
433
+ ev_timer timer; /* unused */
434
+ ev_periodic periodic; /* unused */
435
+ ev_idle idle; /* unused */
436
+ ev_fork fork; /* private */
437
+ #if EV_CLEANUP_ENABLE
438
+ ev_cleanup cleanup; /* unused */
439
+ #endif
440
+ } ev_embed;
441
+ #endif
442
+
443
+ #if EV_ASYNC_ENABLE
444
+ /* invoked when somebody calls ev_async_send on the watcher */
445
+ /* revent EV_ASYNC */
446
+ typedef struct ev_async
447
+ {
448
+ EV_WATCHER (ev_async)
449
+
450
+ EV_ATOMIC_T sent; /* private */
451
+ } ev_async;
452
+
453
+ # define ev_async_pending(w) (+(w)->sent)
454
+ #endif
455
+
456
+ /* the presence of this union forces similar struct layout */
457
+ union ev_any_watcher
458
+ {
459
+ struct ev_watcher w;
460
+ struct ev_watcher_list wl;
461
+
462
+ struct ev_io io;
463
+ struct ev_timer timer;
464
+ struct ev_periodic periodic;
465
+ struct ev_signal signal;
466
+ struct ev_child child;
467
+ #if EV_STAT_ENABLE
468
+ struct ev_stat stat;
469
+ #endif
470
+ #if EV_IDLE_ENABLE
471
+ struct ev_idle idle;
472
+ #endif
473
+ struct ev_prepare prepare;
474
+ struct ev_check check;
475
+ #if EV_FORK_ENABLE
476
+ struct ev_fork fork;
477
+ #endif
478
+ #if EV_CLEANUP_ENABLE
479
+ struct ev_cleanup cleanup;
480
+ #endif
481
+ #if EV_EMBED_ENABLE
482
+ struct ev_embed embed;
483
+ #endif
484
+ #if EV_ASYNC_ENABLE
485
+ struct ev_async async;
486
+ #endif
487
+ };
488
+
489
+ /* flag bits for ev_default_loop and ev_loop_new */
490
+ enum {
491
+ /* the default */
492
+ EVFLAG_AUTO = 0x00000000U, /* not quite a mask */
493
+ /* flag bits */
494
+ EVFLAG_NOENV = 0x01000000U, /* do NOT consult environment */
495
+ EVFLAG_FORKCHECK = 0x02000000U, /* check for a fork in each iteration */
496
+ /* debugging/feature disable */
497
+ EVFLAG_NOINOTIFY = 0x00100000U, /* do not attempt to use inotify */
498
+ #if EV_COMPAT3
499
+ EVFLAG_NOSIGFD = 0, /* compatibility to pre-3.9 */
500
+ #endif
501
+ EVFLAG_SIGNALFD = 0x00200000U, /* attempt to use signalfd */
502
+ EVFLAG_NOSIGMASK = 0x00400000U /* avoid modifying the signal mask */
503
+ };
504
+
505
+ /* method bits to be ored together */
506
+ enum {
507
+ EVBACKEND_SELECT = 0x00000001U, /* about anywhere */
508
+ EVBACKEND_POLL = 0x00000002U, /* !win */
509
+ EVBACKEND_EPOLL = 0x00000004U, /* linux */
510
+ EVBACKEND_KQUEUE = 0x00000008U, /* bsd */
511
+ EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */
512
+ EVBACKEND_PORT = 0x00000020U, /* solaris 10 */
513
+ EVBACKEND_ALL = 0x0000003FU, /* all known backends */
514
+ EVBACKEND_MASK = 0x0000FFFFU /* all future backends */
515
+ };
516
+
517
+ #if EV_PROTOTYPES
518
+ int ev_version_major (void);
519
+ int ev_version_minor (void);
520
+
521
+ unsigned int ev_supported_backends (void);
522
+ unsigned int ev_recommended_backends (void);
523
+ unsigned int ev_embeddable_backends (void);
524
+
525
+ ev_tstamp ev_time (void);
526
+ void ev_sleep (ev_tstamp delay); /* sleep for a while */
527
+
528
+ /* Sets the allocation function to use, works like realloc.
529
+ * It is used to allocate and free memory.
530
+ * If it returns zero when memory needs to be allocated, the library might abort
531
+ * or take some potentially destructive action.
532
+ * The default is your system realloc function.
533
+ */
534
+ void ev_set_allocator (void *(*cb)(void *ptr, long size));
535
+
536
+ /* set the callback function to call on a
537
+ * retryable syscall error
538
+ * (such as failed select, poll, epoll_wait)
539
+ */
540
+ void ev_set_syserr_cb (void (*cb)(const char *msg));
541
+
542
+ #if EV_MULTIPLICITY
543
+
544
+ /* the default loop is the only one that handles signals and child watchers */
545
+ /* you can call this as often as you like */
546
+ struct ev_loop *ev_default_loop (unsigned int flags EV_CPP (= 0));
547
+
548
+ EV_INLINE struct ev_loop *
549
+ EV_MAYBE_UNUSED ev_default_loop_uc_ (void)
550
+ {
551
+ extern struct ev_loop *ev_default_loop_ptr;
552
+
553
+ return ev_default_loop_ptr;
554
+ }
555
+
556
+ EV_INLINE int
557
+ EV_MAYBE_UNUSED ev_is_default_loop (EV_P)
558
+ {
559
+ return EV_A == EV_DEFAULT_UC;
560
+ }
561
+
562
+ /* create and destroy alternative loops that don't handle signals */
563
+ struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0));
564
+
565
+ int ev_loop_refcount (EV_P);
566
+
567
+ ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */
568
+
569
+ #else
570
+
571
+ int ev_default_loop (unsigned int flags EV_CPP (= 0)); /* returns true when successful */
572
+
573
+ EV_INLINE ev_tstamp
574
+ ev_now (void)
575
+ {
576
+ extern ev_tstamp ev_rt_now;
577
+
578
+ return ev_rt_now;
579
+ }
580
+
581
+ /* looks weird, but ev_is_default_loop (EV_A) still works if this exists */
582
+ EV_INLINE int
583
+ ev_is_default_loop (void)
584
+ {
585
+ return 1;
586
+ }
587
+
588
+ #endif /* multiplicity */
589
+
590
+ /* destroy event loops, also works for the default loop */
591
+ void ev_loop_destroy (EV_P);
592
+
593
+ /* this needs to be called after fork, to duplicate the loop */
594
+ /* when you want to re-use it in the child */
595
+ /* you can call it in either the parent or the child */
596
+ /* you can actually call it at any time, anywhere :) */
597
+ void ev_loop_fork (EV_P);
598
+
599
+ unsigned int ev_backend (EV_P); /* backend in use by loop */
600
+
601
+ void ev_now_update (EV_P); /* update event loop time */
602
+
603
+ #if EV_WALK_ENABLE
604
+ /* walk (almost) all watchers in the loop of a given type, invoking the */
605
+ /* callback on every such watcher. The callback might stop the watcher, */
606
+ /* but do nothing else with the loop */
607
+ void ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w));
608
+ #endif
609
+
610
+ #endif /* prototypes */
611
+
612
+ /* ev_run flags values */
613
+ enum {
614
+ EVRUN_NOWAIT = 1, /* do not block/wait */
615
+ EVRUN_ONCE = 2 /* block *once* only */
616
+ };
617
+
618
+ /* ev_break how values */
619
+ enum {
620
+ EVBREAK_CANCEL = 0, /* undo unloop */
621
+ EVBREAK_ONE = 1, /* unloop once */
622
+ EVBREAK_ALL = 2 /* unloop all loops */
623
+ };
624
+
625
+ #if EV_PROTOTYPES
626
+ void ev_run (EV_P_ int flags EV_CPP (= 0));
627
+ void ev_break (EV_P_ int how EV_CPP (= EVBREAK_ONE)); /* break out of the loop */
628
+
629
+ /*
630
+ * ref/unref can be used to add or remove a refcount on the mainloop. every watcher
631
+ * keeps one reference. if you have a long-running watcher you never unregister that
632
+ * should not keep ev_loop from running, unref() after starting, and ref() before stopping.
633
+ */
634
+ void ev_ref (EV_P);
635
+ void ev_unref (EV_P);
636
+
637
+ /*
638
+ * convenience function, wait for a single event, without registering an event watcher
639
+ * if timeout is < 0, do wait indefinitely
640
+ */
641
+ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg);
642
+
643
+ # if EV_FEATURE_API
644
+ unsigned int ev_iteration (EV_P); /* number of loop iterations */
645
+ unsigned int ev_depth (EV_P); /* #ev_loop enters - #ev_loop leaves */
646
+ void ev_verify (EV_P); /* abort if loop data corrupted */
647
+
648
+ void ev_set_io_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */
649
+ void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */
650
+
651
+ /* advanced stuff for threading etc. support, see docs */
652
+ void ev_set_userdata (EV_P_ void *data);
653
+ void *ev_userdata (EV_P);
654
+ void ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P));
655
+ void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P));
656
+
657
+ unsigned int ev_pending_count (EV_P); /* number of pending events, if any */
658
+ void ev_invoke_pending (EV_P); /* invoke all pending watchers */
659
+
660
+ /*
661
+ * stop/start the timer handling.
662
+ */
663
+ void ev_suspend (EV_P);
664
+ void ev_resume (EV_P);
665
+ #endif
666
+
667
+ #endif
668
+
669
+ /* these may evaluate ev multiple times, and the other arguments at most once */
670
+ /* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */
671
+ #define ev_init(ev,cb_) do { \
672
+ ((ev_watcher *)(void *)(ev))->active = \
673
+ ((ev_watcher *)(void *)(ev))->pending = 0; \
674
+ ev_set_priority ((ev), 0); \
675
+ ev_set_cb ((ev), cb_); \
676
+ } while (0)
677
+
678
+ #define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_) | EV__IOFDSET; } while (0)
679
+ #define ev_timer_set(ev,after_,repeat_) do { ((ev_watcher_time *)(ev))->at = (after_); (ev)->repeat = (repeat_); } while (0)
680
+ #define ev_periodic_set(ev,ofs_,ival_,rcb_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb = (rcb_); } while (0)
681
+ #define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0)
682
+ #define ev_child_set(ev,pid_,trace_) do { (ev)->pid = (pid_); (ev)->flags = !!(trace_); } while (0)
683
+ #define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); (ev)->wd = -2; } while (0)
684
+ #define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */
685
+ #define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */
686
+ #define ev_check_set(ev) /* nop, yes, this is a serious in-joke */
687
+ #define ev_embed_set(ev,other_) do { (ev)->other = (other_); } while (0)
688
+ #define ev_fork_set(ev) /* nop, yes, this is a serious in-joke */
689
+ #define ev_cleanup_set(ev) /* nop, yes, this is a serious in-joke */
690
+ #define ev_async_set(ev) /* nop, yes, this is a serious in-joke */
691
+
692
+ #define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0)
693
+ #define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } while (0)
694
+ #define ev_periodic_init(ev,cb,ofs,ival,rcb) do { ev_init ((ev), (cb)); ev_periodic_set ((ev),(ofs),(ival),(rcb)); } while (0)
695
+ #define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0)
696
+ #define ev_child_init(ev,cb,pid,trace) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid),(trace)); } while (0)
697
+ #define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_stat_set ((ev),(path),(interval)); } while (0)
698
+ #define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0)
699
+ #define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0)
700
+ #define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0)
701
+ #define ev_embed_init(ev,cb,other) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(other)); } while (0)
702
+ #define ev_fork_init(ev,cb) do { ev_init ((ev), (cb)); ev_fork_set ((ev)); } while (0)
703
+ #define ev_cleanup_init(ev,cb) do { ev_init ((ev), (cb)); ev_cleanup_set ((ev)); } while (0)
704
+ #define ev_async_init(ev,cb) do { ev_init ((ev), (cb)); ev_async_set ((ev)); } while (0)
705
+
706
+ #define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */
707
+ #define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
708
+
709
+ #define ev_cb(ev) (ev)->cb /* rw */
710
+
711
+ #if EV_MINPRI == EV_MAXPRI
712
+ # define ev_priority(ev) ((ev), EV_MINPRI)
713
+ # define ev_set_priority(ev,pri) ((ev), (pri))
714
+ #else
715
+ # define ev_priority(ev) (+(((ev_watcher *)(void *)(ev))->priority))
716
+ # define ev_set_priority(ev,pri) ( (ev_watcher *)(void *)(ev))->priority = (pri)
717
+ #endif
718
+
719
+ #define ev_periodic_at(ev) (+((ev_watcher_time *)(ev))->at)
720
+
721
+ #ifndef ev_set_cb
722
+ # define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_)
723
+ #endif
724
+
725
+ /* stopping (enabling, adding) a watcher does nothing if it is already running */
726
+ /* stopping (disabling, deleting) a watcher does nothing unless its already running */
727
+ #if EV_PROTOTYPES
728
+
729
+ /* feeds an event into a watcher as if the event actually occured */
730
+ /* accepts any ev_watcher type */
731
+ void ev_feed_event (EV_P_ void *w, int revents);
732
+ void ev_feed_fd_event (EV_P_ int fd, int revents);
733
+ #if EV_SIGNAL_ENABLE
734
+ void ev_feed_signal (int signum);
735
+ void ev_feed_signal_event (EV_P_ int signum);
736
+ #endif
737
+ void ev_invoke (EV_P_ void *w, int revents);
738
+ int ev_clear_pending (EV_P_ void *w);
739
+
740
+ void ev_io_start (EV_P_ ev_io *w);
741
+ void ev_io_stop (EV_P_ ev_io *w);
742
+
743
+ void ev_timer_start (EV_P_ ev_timer *w);
744
+ void ev_timer_stop (EV_P_ ev_timer *w);
745
+ /* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */
746
+ void ev_timer_again (EV_P_ ev_timer *w);
747
+ /* return remaining time */
748
+ ev_tstamp ev_timer_remaining (EV_P_ ev_timer *w);
749
+
750
+ #if EV_PERIODIC_ENABLE
751
+ void ev_periodic_start (EV_P_ ev_periodic *w);
752
+ void ev_periodic_stop (EV_P_ ev_periodic *w);
753
+ void ev_periodic_again (EV_P_ ev_periodic *w);
754
+ #endif
755
+
756
+ /* only supported in the default loop */
757
+ #if EV_SIGNAL_ENABLE
758
+ void ev_signal_start (EV_P_ ev_signal *w);
759
+ void ev_signal_stop (EV_P_ ev_signal *w);
760
+ #endif
761
+
762
+ /* only supported in the default loop */
763
+ # if EV_CHILD_ENABLE
764
+ void ev_child_start (EV_P_ ev_child *w);
765
+ void ev_child_stop (EV_P_ ev_child *w);
766
+ # endif
767
+
768
+ # if EV_STAT_ENABLE
769
+ void ev_stat_start (EV_P_ ev_stat *w);
770
+ void ev_stat_stop (EV_P_ ev_stat *w);
771
+ void ev_stat_stat (EV_P_ ev_stat *w);
772
+ # endif
773
+
774
+ # if EV_IDLE_ENABLE
775
+ void ev_idle_start (EV_P_ ev_idle *w);
776
+ void ev_idle_stop (EV_P_ ev_idle *w);
777
+ # endif
778
+
779
+ #if EV_PREPARE_ENABLE
780
+ void ev_prepare_start (EV_P_ ev_prepare *w);
781
+ void ev_prepare_stop (EV_P_ ev_prepare *w);
782
+ #endif
783
+
784
+ #if EV_CHECK_ENABLE
785
+ void ev_check_start (EV_P_ ev_check *w);
786
+ void ev_check_stop (EV_P_ ev_check *w);
787
+ #endif
788
+
789
+ # if EV_FORK_ENABLE
790
+ void ev_fork_start (EV_P_ ev_fork *w);
791
+ void ev_fork_stop (EV_P_ ev_fork *w);
792
+ # endif
793
+
794
+ # if EV_CLEANUP_ENABLE
795
+ void ev_cleanup_start (EV_P_ ev_cleanup *w);
796
+ void ev_cleanup_stop (EV_P_ ev_cleanup *w);
797
+ # endif
798
+
799
+ # if EV_EMBED_ENABLE
800
+ /* only supported when loop to be embedded is in fact embeddable */
801
+ void ev_embed_start (EV_P_ ev_embed *w);
802
+ void ev_embed_stop (EV_P_ ev_embed *w);
803
+ void ev_embed_sweep (EV_P_ ev_embed *w);
804
+ # endif
805
+
806
+ # if EV_ASYNC_ENABLE
807
+ void ev_async_start (EV_P_ ev_async *w);
808
+ void ev_async_stop (EV_P_ ev_async *w);
809
+ void ev_async_send (EV_P_ ev_async *w);
810
+ # endif
811
+
812
+ #if EV_COMPAT3
813
+ #define EVLOOP_NONBLOCK EVRUN_NOWAIT
814
+ #define EVLOOP_ONESHOT EVRUN_ONCE
815
+ #define EVUNLOOP_CANCEL EVBREAK_CANCEL
816
+ #define EVUNLOOP_ONE EVBREAK_ONE
817
+ #define EVUNLOOP_ALL EVBREAK_ALL
818
+ #if EV_PROTOTYPES
819
+ EV_INLINE void EV_MAYBE_UNUSED ev_loop (EV_P_ int flags) { ev_run (EV_A_ flags); }
820
+ EV_INLINE void EV_MAYBE_UNUSED ev_unloop (EV_P_ int how ) { ev_break (EV_A_ how ); }
821
+ EV_INLINE void EV_MAYBE_UNUSED ev_default_destroy (void) { ev_loop_destroy (EV_DEFAULT); }
822
+ EV_INLINE void EV_MAYBE_UNUSED ev_default_fork (void) { ev_loop_fork (EV_DEFAULT); }
823
+ #if EV_FEATURE_API
824
+ EV_INLINE unsigned int EV_MAYBE_UNUSED ev_loop_count (EV_P) { return ev_iteration (EV_A); }
825
+ EV_INLINE unsigned int EV_MAYBE_UNUSED ev_loop_depth (EV_P) { return ev_depth (EV_A); }
826
+ EV_INLINE void EV_MAYBE_UNUSED ev_loop_verify (EV_P) { ev_verify (EV_A); }
827
+ #endif
828
+ #endif
829
+ #else
830
+ typedef struct ev_loop ev_loop;
831
+ #endif
832
+
833
+ #endif
834
+
835
+ EV_CPP(})
836
+
837
+ #endif
838
+