uringmachine 0.16 → 0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.gitmodules +4 -0
  4. data/CHANGELOG.md +8 -0
  5. data/TODO.md +12 -3
  6. data/examples/bm_send.rb +86 -0
  7. data/ext/um/um.c +28 -1
  8. data/ext/um/um.h +3 -0
  9. data/ext/um/um_class.c +17 -0
  10. data/ext/um/um_utils.c +38 -15
  11. data/lib/uringmachine/version.rb +1 -1
  12. data/test/test_um.rb +76 -0
  13. data/vendor/libressl/.github/scripts/changelog.sh +74 -0
  14. data/vendor/libressl/.github/workflows/android.yml +35 -0
  15. data/vendor/libressl/.github/workflows/cifuzz.yml +33 -0
  16. data/vendor/libressl/.github/workflows/cmake-config.yml +98 -0
  17. data/vendor/libressl/.github/workflows/coverity.yml +69 -0
  18. data/vendor/libressl/.github/workflows/emscripten.yml +71 -0
  19. data/vendor/libressl/.github/workflows/fedora-rawhide.yml +39 -0
  20. data/vendor/libressl/.github/workflows/freebsd.yml +71 -0
  21. data/vendor/libressl/.github/workflows/linux.yml +71 -0
  22. data/vendor/libressl/.github/workflows/macos.yml +37 -0
  23. data/vendor/libressl/.github/workflows/release.yml +81 -0
  24. data/vendor/libressl/.github/workflows/rust-openssl.yml +47 -0
  25. data/vendor/libressl/.github/workflows/solaris.yml +37 -0
  26. data/vendor/libressl/.github/workflows/windows.yml +70 -0
  27. data/vendor/libressl/.gitignore +333 -0
  28. data/vendor/libressl/CMakeLists.txt +581 -0
  29. data/vendor/libressl/COPYING +133 -0
  30. data/vendor/libressl/ChangeLog +3280 -0
  31. data/vendor/libressl/FindLibreSSL.cmake +232 -0
  32. data/vendor/libressl/LibreSSLConfig.cmake.in +36 -0
  33. data/vendor/libressl/Makefile.am +60 -0
  34. data/vendor/libressl/Makefile.am.common +20 -0
  35. data/vendor/libressl/OPENBSD_BRANCH +1 -0
  36. data/vendor/libressl/README.md +238 -0
  37. data/vendor/libressl/README.mingw.md +43 -0
  38. data/vendor/libressl/apps/CMakeLists.txt +18 -0
  39. data/vendor/libressl/apps/Makefile.am +5 -0
  40. data/vendor/libressl/apps/nc/CMakeLists.txt +67 -0
  41. data/vendor/libressl/apps/nc/Makefile.am +64 -0
  42. data/vendor/libressl/apps/nc/compat/accept4.c +17 -0
  43. data/vendor/libressl/apps/nc/compat/readpassphrase.c +205 -0
  44. data/vendor/libressl/apps/nc/compat/socket.c +29 -0
  45. data/vendor/libressl/apps/nc/compat/sys/socket.h +30 -0
  46. data/vendor/libressl/apps/ocspcheck/CMakeLists.txt +44 -0
  47. data/vendor/libressl/apps/ocspcheck/Makefile.am +45 -0
  48. data/vendor/libressl/apps/ocspcheck/compat/.gitignore +0 -0
  49. data/vendor/libressl/apps/openssl/CMakeLists.txt +97 -0
  50. data/vendor/libressl/apps/openssl/Makefile.am +108 -0
  51. data/vendor/libressl/apps/openssl/apps_win.c +138 -0
  52. data/vendor/libressl/apps/openssl/certhash_win.c +13 -0
  53. data/vendor/libressl/apps/openssl/compat/clock_gettime_osx.c +26 -0
  54. data/vendor/libressl/apps/openssl/compat/poll_win.c +329 -0
  55. data/vendor/libressl/appveyor.yml +53 -0
  56. data/vendor/libressl/autogen.sh +15 -0
  57. data/vendor/libressl/check-release.sh +86 -0
  58. data/vendor/libressl/cmake_export_symbol.cmake +71 -0
  59. data/vendor/libressl/cmake_uninstall.cmake.in +36 -0
  60. data/vendor/libressl/config +17 -0
  61. data/vendor/libressl/configure.ac +165 -0
  62. data/vendor/libressl/crypto/CMakeLists.txt +863 -0
  63. data/vendor/libressl/crypto/Makefile.am +962 -0
  64. data/vendor/libressl/crypto/Makefile.am.arc4random +46 -0
  65. data/vendor/libressl/crypto/Makefile.am.elf-mips +14 -0
  66. data/vendor/libressl/crypto/Makefile.am.elf-mips64 +14 -0
  67. data/vendor/libressl/crypto/Makefile.am.elf-x86_64 +35 -0
  68. data/vendor/libressl/crypto/Makefile.am.macosx-x86_64 +35 -0
  69. data/vendor/libressl/crypto/Makefile.am.masm-x86_64 +22 -0
  70. data/vendor/libressl/crypto/Makefile.am.mingw64-x86_64 +23 -0
  71. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_darwin.c +60 -0
  72. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_linux.c +62 -0
  73. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_none.c +26 -0
  74. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_windows.c +36 -0
  75. data/vendor/libressl/crypto/arch/loongarch64/crypto_arch.h +21 -0
  76. data/vendor/libressl/crypto/arch/mips/crypto_arch.h +21 -0
  77. data/vendor/libressl/crypto/bn/arch/loongarch64/bn_arch.h +23 -0
  78. data/vendor/libressl/crypto/bn/arch/mips/bn_arch.h +24 -0
  79. data/vendor/libressl/crypto/compat/.gitignore +31 -0
  80. data/vendor/libressl/crypto/compat/arc4random.h +41 -0
  81. data/vendor/libressl/crypto/compat/b_win.c +55 -0
  82. data/vendor/libressl/crypto/compat/bsd-asprintf.c +96 -0
  83. data/vendor/libressl/crypto/compat/crypto_lock_win.c +56 -0
  84. data/vendor/libressl/crypto/compat/explicit_bzero_win.c +13 -0
  85. data/vendor/libressl/crypto/compat/freezero.c +32 -0
  86. data/vendor/libressl/crypto/compat/getdelim.c +78 -0
  87. data/vendor/libressl/crypto/compat/getline.c +40 -0
  88. data/vendor/libressl/crypto/compat/getopt_long.c +528 -0
  89. data/vendor/libressl/crypto/compat/getpagesize.c +18 -0
  90. data/vendor/libressl/crypto/compat/getprogname_linux.c +23 -0
  91. data/vendor/libressl/crypto/compat/getprogname_unimpl.c +7 -0
  92. data/vendor/libressl/crypto/compat/getprogname_windows.c +13 -0
  93. data/vendor/libressl/crypto/compat/posix_win.c +296 -0
  94. data/vendor/libressl/crypto/compat/syslog_r.c +19 -0
  95. data/vendor/libressl/crypto/compat/ui_openssl_win.c +334 -0
  96. data/vendor/libressl/dist.sh +22 -0
  97. data/vendor/libressl/gen-coverage-report.sh +58 -0
  98. data/vendor/libressl/gen-openbsd-tags.sh +20 -0
  99. data/vendor/libressl/include/CMakeLists.txt +61 -0
  100. data/vendor/libressl/include/Makefile.am +79 -0
  101. data/vendor/libressl/include/arch/loongarch64/opensslconf.h +150 -0
  102. data/vendor/libressl/include/arch/mips/opensslconf.h +150 -0
  103. data/vendor/libressl/include/compat/arpa/inet.h +15 -0
  104. data/vendor/libressl/include/compat/arpa/nameser.h +25 -0
  105. data/vendor/libressl/include/compat/cet.h +19 -0
  106. data/vendor/libressl/include/compat/dirent.h +17 -0
  107. data/vendor/libressl/include/compat/dirent_msvc.h +611 -0
  108. data/vendor/libressl/include/compat/endian.h +161 -0
  109. data/vendor/libressl/include/compat/err.h +95 -0
  110. data/vendor/libressl/include/compat/fcntl.h +32 -0
  111. data/vendor/libressl/include/compat/getopt.h +50 -0
  112. data/vendor/libressl/include/compat/limits.h +25 -0
  113. data/vendor/libressl/include/compat/netdb.h +10 -0
  114. data/vendor/libressl/include/compat/netinet/in.h +19 -0
  115. data/vendor/libressl/include/compat/netinet/ip.h +49 -0
  116. data/vendor/libressl/include/compat/netinet/tcp.h +10 -0
  117. data/vendor/libressl/include/compat/poll.h +63 -0
  118. data/vendor/libressl/include/compat/pthread.h +122 -0
  119. data/vendor/libressl/include/compat/readpassphrase.h +44 -0
  120. data/vendor/libressl/include/compat/resolv.h +24 -0
  121. data/vendor/libressl/include/compat/stdint.h +31 -0
  122. data/vendor/libressl/include/compat/stdio.h +65 -0
  123. data/vendor/libressl/include/compat/stdlib.h +57 -0
  124. data/vendor/libressl/include/compat/string.h +98 -0
  125. data/vendor/libressl/include/compat/sys/_null.h +18 -0
  126. data/vendor/libressl/include/compat/sys/ioctl.h +11 -0
  127. data/vendor/libressl/include/compat/sys/mman.h +19 -0
  128. data/vendor/libressl/include/compat/sys/param.h +15 -0
  129. data/vendor/libressl/include/compat/sys/queue.h +536 -0
  130. data/vendor/libressl/include/compat/sys/select.h +10 -0
  131. data/vendor/libressl/include/compat/sys/socket.h +18 -0
  132. data/vendor/libressl/include/compat/sys/stat.h +129 -0
  133. data/vendor/libressl/include/compat/sys/time.h +37 -0
  134. data/vendor/libressl/include/compat/sys/tree.h +1006 -0
  135. data/vendor/libressl/include/compat/sys/types.h +69 -0
  136. data/vendor/libressl/include/compat/sys/uio.h +17 -0
  137. data/vendor/libressl/include/compat/syslog.h +38 -0
  138. data/vendor/libressl/include/compat/time.h +59 -0
  139. data/vendor/libressl/include/compat/unistd.h +83 -0
  140. data/vendor/libressl/include/compat/win32netcompat.h +57 -0
  141. data/vendor/libressl/include/openssl/Makefile.am.tpl +45 -0
  142. data/vendor/libressl/libcrypto.pc.in +28 -0
  143. data/vendor/libressl/libressl.pub +2 -0
  144. data/vendor/libressl/libssl.pc.in +28 -0
  145. data/vendor/libressl/libtls.pc.in +28 -0
  146. data/vendor/libressl/m4/ax_add_fortify_source.m4 +80 -0
  147. data/vendor/libressl/m4/ax_check_compile_flag.m4 +53 -0
  148. data/vendor/libressl/m4/check-hardening-options.m4 +110 -0
  149. data/vendor/libressl/m4/check-libc.m4 +189 -0
  150. data/vendor/libressl/m4/check-os-options.m4 +181 -0
  151. data/vendor/libressl/m4/disable-compiler-warnings.m4 +44 -0
  152. data/vendor/libressl/man/CMakeLists.txt +26 -0
  153. data/vendor/libressl/man/links +2780 -0
  154. data/vendor/libressl/man/update_links.sh +25 -0
  155. data/vendor/libressl/openssl.pc.in +11 -0
  156. data/vendor/libressl/patches/bn_shift.patch +34 -0
  157. data/vendor/libressl/patches/crypto_arch.h.patch +34 -0
  158. data/vendor/libressl/patches/crypto_namespace.h.patch +22 -0
  159. data/vendor/libressl/patches/netcat.c.patch +178 -0
  160. data/vendor/libressl/patches/openssl.c.patch +12 -0
  161. data/vendor/libressl/patches/opensslfeatures.h.patch +49 -0
  162. data/vendor/libressl/patches/patch-amd64-crypto-cpu-caps.c.patch +20 -0
  163. data/vendor/libressl/patches/patch-i386-crypto-cpu-caps.c.patch +20 -0
  164. data/vendor/libressl/patches/speed.c.patch +114 -0
  165. data/vendor/libressl/patches/ssl_namespace.h.patch +21 -0
  166. data/vendor/libressl/patches/tls.h.patch +16 -0
  167. data/vendor/libressl/patches/tls_config.c.patch +15 -0
  168. data/vendor/libressl/patches/win32_amd64_bn_arch.h.patch +28 -0
  169. data/vendor/libressl/patches/windows_headers.patch +80 -0
  170. data/vendor/libressl/scripts/config.guess +1774 -0
  171. data/vendor/libressl/scripts/config.sub +1907 -0
  172. data/vendor/libressl/scripts/i686-w64-mingw32.cmake +9 -0
  173. data/vendor/libressl/scripts/test +210 -0
  174. data/vendor/libressl/scripts/wrap-compiler-for-flag-check +31 -0
  175. data/vendor/libressl/scripts/x86_64-w64-mingw32.cmake +9 -0
  176. data/vendor/libressl/ssl/CMakeLists.txt +183 -0
  177. data/vendor/libressl/ssl/Makefile.am +187 -0
  178. data/vendor/libressl/tests/CMakeLists.txt +970 -0
  179. data/vendor/libressl/tests/Makefile.am +944 -0
  180. data/vendor/libressl/tests/aeadtest.sh +30 -0
  181. data/vendor/libressl/tests/arc4randomforktest.sh +21 -0
  182. data/vendor/libressl/tests/asn1time_small.test +10 -0
  183. data/vendor/libressl/tests/cmake/CMakeLists.txt +52 -0
  184. data/vendor/libressl/tests/cmake/crypto.c +7 -0
  185. data/vendor/libressl/tests/cmake/ssl.c +6 -0
  186. data/vendor/libressl/tests/cmake/tls.c +6 -0
  187. data/vendor/libressl/tests/compat/pipe2.c +186 -0
  188. data/vendor/libressl/tests/dtlstest.sh +28 -0
  189. data/vendor/libressl/tests/evptest.sh +22 -0
  190. data/vendor/libressl/tests/keypairtest.sh +27 -0
  191. data/vendor/libressl/tests/mlkem_tests.sh +39 -0
  192. data/vendor/libressl/tests/ocsptest.bat +25 -0
  193. data/vendor/libressl/tests/ocsptest.sh +23 -0
  194. data/vendor/libressl/tests/openssl.cnf +29 -0
  195. data/vendor/libressl/tests/optionstest.c +381 -0
  196. data/vendor/libressl/tests/pidwraptest.c +85 -0
  197. data/vendor/libressl/tests/pidwraptest.sh +26 -0
  198. data/vendor/libressl/tests/quictest.bat +27 -0
  199. data/vendor/libressl/tests/quictest.sh +30 -0
  200. data/vendor/libressl/tests/renegotiation_test.bat +27 -0
  201. data/vendor/libressl/tests/renegotiation_test.sh +30 -0
  202. data/vendor/libressl/tests/rfc5280time_small.test +10 -0
  203. data/vendor/libressl/tests/servertest.bat +27 -0
  204. data/vendor/libressl/tests/servertest.sh +30 -0
  205. data/vendor/libressl/tests/shutdowntest.bat +27 -0
  206. data/vendor/libressl/tests/shutdowntest.sh +30 -0
  207. data/vendor/libressl/tests/ssltest.bat +32 -0
  208. data/vendor/libressl/tests/ssltest.sh +48 -0
  209. data/vendor/libressl/tests/testdsa.bat +47 -0
  210. data/vendor/libressl/tests/testdsa.sh +57 -0
  211. data/vendor/libressl/tests/testenc.bat +85 -0
  212. data/vendor/libressl/tests/testenc.sh +93 -0
  213. data/vendor/libressl/tests/testrsa.bat +47 -0
  214. data/vendor/libressl/tests/testrsa.sh +57 -0
  215. data/vendor/libressl/tests/testssl.bat +171 -0
  216. data/vendor/libressl/tests/tlstest.bat +27 -0
  217. data/vendor/libressl/tests/tlstest.sh +28 -0
  218. data/vendor/libressl/tls/CMakeLists.txt +125 -0
  219. data/vendor/libressl/tls/Makefile.am +76 -0
  220. data/vendor/libressl/tls/compat/ftruncate.c +17 -0
  221. data/vendor/libressl/tls/compat/pread.c +29 -0
  222. data/vendor/libressl/tls/compat/pwrite.c +29 -0
  223. data/vendor/libressl/update.sh +460 -0
  224. data/vendor/liburing/.github/workflows/ci.yml +8 -0
  225. data/vendor/liburing/configure +23 -2
  226. data/vendor/liburing/examples/helpers.c +1 -1
  227. data/vendor/liburing/examples/helpers.h +1 -1
  228. data/vendor/liburing/examples/reg-wait.c +3 -3
  229. data/vendor/liburing/examples/zcrx.c +5 -5
  230. data/vendor/liburing/liburing.spec +1 -1
  231. data/vendor/liburing/src/include/liburing/io_uring.h +16 -0
  232. data/vendor/liburing/src/include/liburing.h +20 -4
  233. data/vendor/liburing/src/lib.h +2 -4
  234. data/vendor/liburing/src/liburing-ffi.map +7 -0
  235. data/vendor/liburing/src/liburing.map +7 -0
  236. data/vendor/liburing/src/register.c +5 -0
  237. data/vendor/liburing/src/sanitize.c +5 -4
  238. data/vendor/liburing/src/setup.c +43 -28
  239. data/vendor/liburing/test/Makefile +7 -0
  240. data/vendor/liburing/test/cmd-discard.c +2 -2
  241. data/vendor/liburing/test/evfd-short-read.c +84 -0
  242. data/vendor/liburing/test/fdinfo-sqpoll.c +117 -0
  243. data/vendor/liburing/test/fdinfo.c +1 -1
  244. data/vendor/liburing/test/fixed-buf-merge.c +2 -2
  245. data/vendor/liburing/test/futex-kill.c +135 -0
  246. data/vendor/liburing/test/helpers.c +1 -1
  247. data/vendor/liburing/test/helpers.h +1 -1
  248. data/vendor/liburing/test/init-mem.c +50 -12
  249. data/vendor/liburing/test/io_uring_passthrough.c +25 -6
  250. data/vendor/liburing/test/msg-ring.c +123 -9
  251. data/vendor/liburing/test/recv-bundle-short-ooo.c +16 -1
  252. data/vendor/liburing/test/recv-inc-ooo.c +411 -0
  253. data/vendor/liburing/test/recv-mshot-fair.c +513 -0
  254. data/vendor/liburing/test/reg-wait.c +14 -14
  255. data/vendor/liburing/test/send-zerocopy.c +4 -4
  256. data/vendor/liburing/test/timerfd-short-read.c +81 -0
  257. data/vendor/liburing/test/timestamp.c +382 -0
  258. data/vendor/liburing/test/zcrx.c +22 -22
  259. metadata +222 -2
@@ -0,0 +1,536 @@
1
+ /* $OpenBSD: queue.h,v 1.45 2018/07/12 14:22:54 sashan Exp $ */
2
+ /* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */
3
+
4
+ /*
5
+ * Copyright (c) 1991, 1993
6
+ * The Regents of the University of California. All rights reserved.
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without
9
+ * modification, are permitted provided that the following conditions
10
+ * are met:
11
+ * 1. Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
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
+ * 3. Neither the name of the University nor the names of its contributors
17
+ * may be used to endorse or promote products derived from this software
18
+ * without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ *
32
+ * @(#)queue.h 8.5 (Berkeley) 8/20/94
33
+ */
34
+
35
+ #ifndef _SYS_QUEUE_H_
36
+ #define _SYS_QUEUE_H_
37
+
38
+ #include <sys/_null.h>
39
+
40
+ /*
41
+ * This file defines five types of data structures: singly-linked lists,
42
+ * lists, simple queues, tail queues and XOR simple queues.
43
+ *
44
+ *
45
+ * A singly-linked list is headed by a single forward pointer. The elements
46
+ * are singly linked for minimum space and pointer manipulation overhead at
47
+ * the expense of O(n) removal for arbitrary elements. New elements can be
48
+ * added to the list after an existing element or at the head of the list.
49
+ * Elements being removed from the head of the list should use the explicit
50
+ * macro for this purpose for optimum efficiency. A singly-linked list may
51
+ * only be traversed in the forward direction. Singly-linked lists are ideal
52
+ * for applications with large datasets and few or no removals or for
53
+ * implementing a LIFO queue.
54
+ *
55
+ * A list is headed by a single forward pointer (or an array of forward
56
+ * pointers for a hash table header). The elements are doubly linked
57
+ * so that an arbitrary element can be removed without a need to
58
+ * traverse the list. New elements can be added to the list before
59
+ * or after an existing element or at the head of the list. A list
60
+ * may only be traversed in the forward direction.
61
+ *
62
+ * A simple queue is headed by a pair of pointers, one to the head of the
63
+ * list and the other to the tail of the list. The elements are singly
64
+ * linked to save space, so elements can only be removed from the
65
+ * head of the list. New elements can be added to the list before or after
66
+ * an existing element, at the head of the list, or at the end of the
67
+ * list. A simple queue may only be traversed in the forward direction.
68
+ *
69
+ * A tail queue is headed by a pair of pointers, one to the head of the
70
+ * list and the other to the tail of the list. The elements are doubly
71
+ * linked so that an arbitrary element can be removed without a need to
72
+ * traverse the list. New elements can be added to the list before or
73
+ * after an existing element, at the head of the list, or at the end of
74
+ * the list. A tail queue may be traversed in either direction.
75
+ *
76
+ * An XOR simple queue is used in the same way as a regular simple queue.
77
+ * The difference is that the head structure also includes a "cookie" that
78
+ * is XOR'd with the queue pointer (first, last or next) to generate the
79
+ * real pointer value.
80
+ *
81
+ * For details on the use of these macros, see the queue(3) manual page.
82
+ */
83
+
84
+ #if defined(QUEUE_MACRO_DEBUG) || (defined(_KERNEL) && defined(DIAGNOSTIC))
85
+ #define _Q_INVALID ((void *)-1)
86
+ #define _Q_INVALIDATE(a) (a) = _Q_INVALID
87
+ #else
88
+ #define _Q_INVALIDATE(a)
89
+ #endif
90
+
91
+ /*
92
+ * Singly-linked List definitions.
93
+ */
94
+ #define SLIST_HEAD(name, type) \
95
+ struct name { \
96
+ struct type *slh_first; /* first element */ \
97
+ }
98
+
99
+ #define SLIST_HEAD_INITIALIZER(head) \
100
+ { NULL }
101
+
102
+ #define SLIST_ENTRY(type) \
103
+ struct { \
104
+ struct type *sle_next; /* next element */ \
105
+ }
106
+
107
+ /*
108
+ * Singly-linked List access methods.
109
+ */
110
+ #define SLIST_FIRST(head) ((head)->slh_first)
111
+ #define SLIST_END(head) NULL
112
+ #define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head))
113
+ #define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
114
+
115
+ #define SLIST_FOREACH(var, head, field) \
116
+ for((var) = SLIST_FIRST(head); \
117
+ (var) != SLIST_END(head); \
118
+ (var) = SLIST_NEXT(var, field))
119
+
120
+ #define SLIST_FOREACH_SAFE(var, head, field, tvar) \
121
+ for ((var) = SLIST_FIRST(head); \
122
+ (var) && ((tvar) = SLIST_NEXT(var, field), 1); \
123
+ (var) = (tvar))
124
+
125
+ /*
126
+ * Singly-linked List functions.
127
+ */
128
+ #define SLIST_INIT(head) { \
129
+ SLIST_FIRST(head) = SLIST_END(head); \
130
+ }
131
+
132
+ #define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
133
+ (elm)->field.sle_next = (slistelm)->field.sle_next; \
134
+ (slistelm)->field.sle_next = (elm); \
135
+ } while (0)
136
+
137
+ #define SLIST_INSERT_HEAD(head, elm, field) do { \
138
+ (elm)->field.sle_next = (head)->slh_first; \
139
+ (head)->slh_first = (elm); \
140
+ } while (0)
141
+
142
+ #define SLIST_REMOVE_AFTER(elm, field) do { \
143
+ (elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
144
+ } while (0)
145
+
146
+ #define SLIST_REMOVE_HEAD(head, field) do { \
147
+ (head)->slh_first = (head)->slh_first->field.sle_next; \
148
+ } while (0)
149
+
150
+ #define SLIST_REMOVE(head, elm, type, field) do { \
151
+ if ((head)->slh_first == (elm)) { \
152
+ SLIST_REMOVE_HEAD((head), field); \
153
+ } else { \
154
+ struct type *curelm = (head)->slh_first; \
155
+ \
156
+ while (curelm->field.sle_next != (elm)) \
157
+ curelm = curelm->field.sle_next; \
158
+ curelm->field.sle_next = \
159
+ curelm->field.sle_next->field.sle_next; \
160
+ } \
161
+ _Q_INVALIDATE((elm)->field.sle_next); \
162
+ } while (0)
163
+
164
+ /*
165
+ * List definitions.
166
+ */
167
+ #define LIST_HEAD(name, type) \
168
+ struct name { \
169
+ struct type *lh_first; /* first element */ \
170
+ }
171
+
172
+ #define LIST_HEAD_INITIALIZER(head) \
173
+ { NULL }
174
+
175
+ #define LIST_ENTRY(type) \
176
+ struct { \
177
+ struct type *le_next; /* next element */ \
178
+ struct type **le_prev; /* address of previous next element */ \
179
+ }
180
+
181
+ /*
182
+ * List access methods.
183
+ */
184
+ #define LIST_FIRST(head) ((head)->lh_first)
185
+ #define LIST_END(head) NULL
186
+ #define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head))
187
+ #define LIST_NEXT(elm, field) ((elm)->field.le_next)
188
+
189
+ #define LIST_FOREACH(var, head, field) \
190
+ for((var) = LIST_FIRST(head); \
191
+ (var)!= LIST_END(head); \
192
+ (var) = LIST_NEXT(var, field))
193
+
194
+ #define LIST_FOREACH_SAFE(var, head, field, tvar) \
195
+ for ((var) = LIST_FIRST(head); \
196
+ (var) && ((tvar) = LIST_NEXT(var, field), 1); \
197
+ (var) = (tvar))
198
+
199
+ /*
200
+ * List functions.
201
+ */
202
+ #define LIST_INIT(head) do { \
203
+ LIST_FIRST(head) = LIST_END(head); \
204
+ } while (0)
205
+
206
+ #define LIST_INSERT_AFTER(listelm, elm, field) do { \
207
+ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
208
+ (listelm)->field.le_next->field.le_prev = \
209
+ &(elm)->field.le_next; \
210
+ (listelm)->field.le_next = (elm); \
211
+ (elm)->field.le_prev = &(listelm)->field.le_next; \
212
+ } while (0)
213
+
214
+ #define LIST_INSERT_BEFORE(listelm, elm, field) do { \
215
+ (elm)->field.le_prev = (listelm)->field.le_prev; \
216
+ (elm)->field.le_next = (listelm); \
217
+ *(listelm)->field.le_prev = (elm); \
218
+ (listelm)->field.le_prev = &(elm)->field.le_next; \
219
+ } while (0)
220
+
221
+ #define LIST_INSERT_HEAD(head, elm, field) do { \
222
+ if (((elm)->field.le_next = (head)->lh_first) != NULL) \
223
+ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
224
+ (head)->lh_first = (elm); \
225
+ (elm)->field.le_prev = &(head)->lh_first; \
226
+ } while (0)
227
+
228
+ #define LIST_REMOVE(elm, field) do { \
229
+ if ((elm)->field.le_next != NULL) \
230
+ (elm)->field.le_next->field.le_prev = \
231
+ (elm)->field.le_prev; \
232
+ *(elm)->field.le_prev = (elm)->field.le_next; \
233
+ _Q_INVALIDATE((elm)->field.le_prev); \
234
+ _Q_INVALIDATE((elm)->field.le_next); \
235
+ } while (0)
236
+
237
+ #define LIST_REPLACE(elm, elm2, field) do { \
238
+ if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
239
+ (elm2)->field.le_next->field.le_prev = \
240
+ &(elm2)->field.le_next; \
241
+ (elm2)->field.le_prev = (elm)->field.le_prev; \
242
+ *(elm2)->field.le_prev = (elm2); \
243
+ _Q_INVALIDATE((elm)->field.le_prev); \
244
+ _Q_INVALIDATE((elm)->field.le_next); \
245
+ } while (0)
246
+
247
+ /*
248
+ * Simple queue definitions.
249
+ */
250
+ #define SIMPLEQ_HEAD(name, type) \
251
+ struct name { \
252
+ struct type *sqh_first; /* first element */ \
253
+ struct type **sqh_last; /* addr of last next element */ \
254
+ }
255
+
256
+ #define SIMPLEQ_HEAD_INITIALIZER(head) \
257
+ { NULL, &(head).sqh_first }
258
+
259
+ #define SIMPLEQ_ENTRY(type) \
260
+ struct { \
261
+ struct type *sqe_next; /* next element */ \
262
+ }
263
+
264
+ /*
265
+ * Simple queue access methods.
266
+ */
267
+ #define SIMPLEQ_FIRST(head) ((head)->sqh_first)
268
+ #define SIMPLEQ_END(head) NULL
269
+ #define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
270
+ #define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
271
+
272
+ #define SIMPLEQ_FOREACH(var, head, field) \
273
+ for((var) = SIMPLEQ_FIRST(head); \
274
+ (var) != SIMPLEQ_END(head); \
275
+ (var) = SIMPLEQ_NEXT(var, field))
276
+
277
+ #define SIMPLEQ_FOREACH_SAFE(var, head, field, tvar) \
278
+ for ((var) = SIMPLEQ_FIRST(head); \
279
+ (var) && ((tvar) = SIMPLEQ_NEXT(var, field), 1); \
280
+ (var) = (tvar))
281
+
282
+ /*
283
+ * Simple queue functions.
284
+ */
285
+ #define SIMPLEQ_INIT(head) do { \
286
+ (head)->sqh_first = NULL; \
287
+ (head)->sqh_last = &(head)->sqh_first; \
288
+ } while (0)
289
+
290
+ #define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
291
+ if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
292
+ (head)->sqh_last = &(elm)->field.sqe_next; \
293
+ (head)->sqh_first = (elm); \
294
+ } while (0)
295
+
296
+ #define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
297
+ (elm)->field.sqe_next = NULL; \
298
+ *(head)->sqh_last = (elm); \
299
+ (head)->sqh_last = &(elm)->field.sqe_next; \
300
+ } while (0)
301
+
302
+ #define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
303
+ if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
304
+ (head)->sqh_last = &(elm)->field.sqe_next; \
305
+ (listelm)->field.sqe_next = (elm); \
306
+ } while (0)
307
+
308
+ #define SIMPLEQ_REMOVE_HEAD(head, field) do { \
309
+ if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
310
+ (head)->sqh_last = &(head)->sqh_first; \
311
+ } while (0)
312
+
313
+ #define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \
314
+ if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \
315
+ == NULL) \
316
+ (head)->sqh_last = &(elm)->field.sqe_next; \
317
+ } while (0)
318
+
319
+ #define SIMPLEQ_CONCAT(head1, head2) do { \
320
+ if (!SIMPLEQ_EMPTY((head2))) { \
321
+ *(head1)->sqh_last = (head2)->sqh_first; \
322
+ (head1)->sqh_last = (head2)->sqh_last; \
323
+ SIMPLEQ_INIT((head2)); \
324
+ } \
325
+ } while (0)
326
+
327
+ /*
328
+ * XOR Simple queue definitions.
329
+ */
330
+ #define XSIMPLEQ_HEAD(name, type) \
331
+ struct name { \
332
+ struct type *sqx_first; /* first element */ \
333
+ struct type **sqx_last; /* addr of last next element */ \
334
+ unsigned long sqx_cookie; \
335
+ }
336
+
337
+ #define XSIMPLEQ_ENTRY(type) \
338
+ struct { \
339
+ struct type *sqx_next; /* next element */ \
340
+ }
341
+
342
+ /*
343
+ * XOR Simple queue access methods.
344
+ */
345
+ #define XSIMPLEQ_XOR(head, ptr) ((__typeof(ptr))((head)->sqx_cookie ^ \
346
+ (unsigned long)(ptr)))
347
+ #define XSIMPLEQ_FIRST(head) XSIMPLEQ_XOR(head, ((head)->sqx_first))
348
+ #define XSIMPLEQ_END(head) NULL
349
+ #define XSIMPLEQ_EMPTY(head) (XSIMPLEQ_FIRST(head) == XSIMPLEQ_END(head))
350
+ #define XSIMPLEQ_NEXT(head, elm, field) XSIMPLEQ_XOR(head, ((elm)->field.sqx_next))
351
+
352
+
353
+ #define XSIMPLEQ_FOREACH(var, head, field) \
354
+ for ((var) = XSIMPLEQ_FIRST(head); \
355
+ (var) != XSIMPLEQ_END(head); \
356
+ (var) = XSIMPLEQ_NEXT(head, var, field))
357
+
358
+ #define XSIMPLEQ_FOREACH_SAFE(var, head, field, tvar) \
359
+ for ((var) = XSIMPLEQ_FIRST(head); \
360
+ (var) && ((tvar) = XSIMPLEQ_NEXT(head, var, field), 1); \
361
+ (var) = (tvar))
362
+
363
+ /*
364
+ * XOR Simple queue functions.
365
+ */
366
+ #define XSIMPLEQ_INIT(head) do { \
367
+ arc4random_buf(&(head)->sqx_cookie, sizeof((head)->sqx_cookie)); \
368
+ (head)->sqx_first = XSIMPLEQ_XOR(head, NULL); \
369
+ (head)->sqx_last = XSIMPLEQ_XOR(head, &(head)->sqx_first); \
370
+ } while (0)
371
+
372
+ #define XSIMPLEQ_INSERT_HEAD(head, elm, field) do { \
373
+ if (((elm)->field.sqx_next = (head)->sqx_first) == \
374
+ XSIMPLEQ_XOR(head, NULL)) \
375
+ (head)->sqx_last = XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \
376
+ (head)->sqx_first = XSIMPLEQ_XOR(head, (elm)); \
377
+ } while (0)
378
+
379
+ #define XSIMPLEQ_INSERT_TAIL(head, elm, field) do { \
380
+ (elm)->field.sqx_next = XSIMPLEQ_XOR(head, NULL); \
381
+ *(XSIMPLEQ_XOR(head, (head)->sqx_last)) = XSIMPLEQ_XOR(head, (elm)); \
382
+ (head)->sqx_last = XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \
383
+ } while (0)
384
+
385
+ #define XSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
386
+ if (((elm)->field.sqx_next = (listelm)->field.sqx_next) == \
387
+ XSIMPLEQ_XOR(head, NULL)) \
388
+ (head)->sqx_last = XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \
389
+ (listelm)->field.sqx_next = XSIMPLEQ_XOR(head, (elm)); \
390
+ } while (0)
391
+
392
+ #define XSIMPLEQ_REMOVE_HEAD(head, field) do { \
393
+ if (((head)->sqx_first = XSIMPLEQ_XOR(head, \
394
+ (head)->sqx_first)->field.sqx_next) == XSIMPLEQ_XOR(head, NULL)) \
395
+ (head)->sqx_last = XSIMPLEQ_XOR(head, &(head)->sqx_first); \
396
+ } while (0)
397
+
398
+ #define XSIMPLEQ_REMOVE_AFTER(head, elm, field) do { \
399
+ if (((elm)->field.sqx_next = XSIMPLEQ_XOR(head, \
400
+ (elm)->field.sqx_next)->field.sqx_next) \
401
+ == XSIMPLEQ_XOR(head, NULL)) \
402
+ (head)->sqx_last = \
403
+ XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \
404
+ } while (0)
405
+
406
+
407
+ /*
408
+ * Tail queue definitions.
409
+ */
410
+ #define TAILQ_HEAD(name, type) \
411
+ struct name { \
412
+ struct type *tqh_first; /* first element */ \
413
+ struct type **tqh_last; /* addr of last next element */ \
414
+ }
415
+
416
+ #define TAILQ_HEAD_INITIALIZER(head) \
417
+ { NULL, &(head).tqh_first }
418
+
419
+ #define TAILQ_ENTRY(type) \
420
+ struct { \
421
+ struct type *tqe_next; /* next element */ \
422
+ struct type **tqe_prev; /* address of previous next element */ \
423
+ }
424
+
425
+ /*
426
+ * Tail queue access methods.
427
+ */
428
+ #define TAILQ_FIRST(head) ((head)->tqh_first)
429
+ #define TAILQ_END(head) NULL
430
+ #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
431
+ #define TAILQ_LAST(head, headname) \
432
+ (*(((struct headname *)((head)->tqh_last))->tqh_last))
433
+ /* XXX */
434
+ #define TAILQ_PREV(elm, headname, field) \
435
+ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
436
+ #define TAILQ_EMPTY(head) \
437
+ (TAILQ_FIRST(head) == TAILQ_END(head))
438
+
439
+ #define TAILQ_FOREACH(var, head, field) \
440
+ for((var) = TAILQ_FIRST(head); \
441
+ (var) != TAILQ_END(head); \
442
+ (var) = TAILQ_NEXT(var, field))
443
+
444
+ #define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
445
+ for ((var) = TAILQ_FIRST(head); \
446
+ (var) != TAILQ_END(head) && \
447
+ ((tvar) = TAILQ_NEXT(var, field), 1); \
448
+ (var) = (tvar))
449
+
450
+
451
+ #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
452
+ for((var) = TAILQ_LAST(head, headname); \
453
+ (var) != TAILQ_END(head); \
454
+ (var) = TAILQ_PREV(var, headname, field))
455
+
456
+ #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
457
+ for ((var) = TAILQ_LAST(head, headname); \
458
+ (var) != TAILQ_END(head) && \
459
+ ((tvar) = TAILQ_PREV(var, headname, field), 1); \
460
+ (var) = (tvar))
461
+
462
+ /*
463
+ * Tail queue functions.
464
+ */
465
+ #define TAILQ_INIT(head) do { \
466
+ (head)->tqh_first = NULL; \
467
+ (head)->tqh_last = &(head)->tqh_first; \
468
+ } while (0)
469
+
470
+ #define TAILQ_INSERT_HEAD(head, elm, field) do { \
471
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
472
+ (head)->tqh_first->field.tqe_prev = \
473
+ &(elm)->field.tqe_next; \
474
+ else \
475
+ (head)->tqh_last = &(elm)->field.tqe_next; \
476
+ (head)->tqh_first = (elm); \
477
+ (elm)->field.tqe_prev = &(head)->tqh_first; \
478
+ } while (0)
479
+
480
+ #define TAILQ_INSERT_TAIL(head, elm, field) do { \
481
+ (elm)->field.tqe_next = NULL; \
482
+ (elm)->field.tqe_prev = (head)->tqh_last; \
483
+ *(head)->tqh_last = (elm); \
484
+ (head)->tqh_last = &(elm)->field.tqe_next; \
485
+ } while (0)
486
+
487
+ #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
488
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
489
+ (elm)->field.tqe_next->field.tqe_prev = \
490
+ &(elm)->field.tqe_next; \
491
+ else \
492
+ (head)->tqh_last = &(elm)->field.tqe_next; \
493
+ (listelm)->field.tqe_next = (elm); \
494
+ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
495
+ } while (0)
496
+
497
+ #define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
498
+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
499
+ (elm)->field.tqe_next = (listelm); \
500
+ *(listelm)->field.tqe_prev = (elm); \
501
+ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
502
+ } while (0)
503
+
504
+ #define TAILQ_REMOVE(head, elm, field) do { \
505
+ if (((elm)->field.tqe_next) != NULL) \
506
+ (elm)->field.tqe_next->field.tqe_prev = \
507
+ (elm)->field.tqe_prev; \
508
+ else \
509
+ (head)->tqh_last = (elm)->field.tqe_prev; \
510
+ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
511
+ _Q_INVALIDATE((elm)->field.tqe_prev); \
512
+ _Q_INVALIDATE((elm)->field.tqe_next); \
513
+ } while (0)
514
+
515
+ #define TAILQ_REPLACE(head, elm, elm2, field) do { \
516
+ if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
517
+ (elm2)->field.tqe_next->field.tqe_prev = \
518
+ &(elm2)->field.tqe_next; \
519
+ else \
520
+ (head)->tqh_last = &(elm2)->field.tqe_next; \
521
+ (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
522
+ *(elm2)->field.tqe_prev = (elm2); \
523
+ _Q_INVALIDATE((elm)->field.tqe_prev); \
524
+ _Q_INVALIDATE((elm)->field.tqe_next); \
525
+ } while (0)
526
+
527
+ #define TAILQ_CONCAT(head1, head2, field) do { \
528
+ if (!TAILQ_EMPTY(head2)) { \
529
+ *(head1)->tqh_last = (head2)->tqh_first; \
530
+ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
531
+ (head1)->tqh_last = (head2)->tqh_last; \
532
+ TAILQ_INIT((head2)); \
533
+ } \
534
+ } while (0)
535
+
536
+ #endif /* !_SYS_QUEUE_H_ */
@@ -0,0 +1,10 @@
1
+ /*
2
+ * Public domain
3
+ * sys/select.h compatibility shim
4
+ */
5
+
6
+ #ifndef _WIN32
7
+ #include_next <sys/select.h>
8
+ #else
9
+ #include <win32netcompat.h>
10
+ #endif
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Public domain
3
+ * sys/socket.h compatibility shim
4
+ */
5
+
6
+ #ifndef _WIN32
7
+ #include_next <sys/socket.h>
8
+ #else
9
+ #include <win32netcompat.h>
10
+ #endif
11
+
12
+ #if !defined(SOCK_NONBLOCK) || !defined(SOCK_CLOEXEC)
13
+ #define NEED_SOCKET_FLAGS
14
+ #define SOCK_CLOEXEC 0x8000 /* set FD_CLOEXEC */
15
+ #define SOCK_NONBLOCK 0x4000 /* set O_NONBLOCK */
16
+ int bsd_socketpair(int domain, int type, int protocol, int socket_vector[2]);
17
+ #define socketpair(d,t,p,sv) bsd_socketpair(d,t,p,sv)
18
+ #endif
@@ -0,0 +1,129 @@
1
+ /*
2
+ * Public domain
3
+ * sys/stat.h compatibility shim
4
+ */
5
+
6
+ #ifndef LIBCRYPTOCOMPAT_SYS_STAT_H
7
+ #define LIBCRYPTOCOMPAT_SYS_STAT_H
8
+
9
+ #ifndef _MSC_VER
10
+ #include_next <sys/stat.h>
11
+
12
+ /* for old MinGW */
13
+ #ifndef S_IRWXU
14
+ #define S_IRWXU 0
15
+ #endif
16
+ #ifndef S_IRWXG
17
+ #define S_IRWXG 0
18
+ #endif
19
+ #ifndef S_IRGRP
20
+ #define S_IRGRP 0
21
+ #endif
22
+ #ifndef S_IRWXO
23
+ #define S_IRWXO 0
24
+ #endif
25
+ #ifndef S_IROTH
26
+ #define S_IROTH 0
27
+ #endif
28
+
29
+ #else
30
+
31
+ #include <windows.h>
32
+ #if _MSC_VER >= 1900
33
+ #include <../ucrt/sys/stat.h>
34
+ #else
35
+ #include <../include/sys/stat.h>
36
+ #endif
37
+
38
+ /* File type and permission flags for stat() */
39
+ #if !defined(S_IFMT)
40
+ # define S_IFMT _S_IFMT /* File type mask */
41
+ #endif
42
+ #if !defined(S_IFDIR)
43
+ # define S_IFDIR _S_IFDIR /* Directory */
44
+ #endif
45
+ #if !defined(S_IFCHR)
46
+ # define S_IFCHR _S_IFCHR /* Character device */
47
+ #endif
48
+ #if !defined(S_IFFIFO)
49
+ # define S_IFFIFO _S_IFFIFO /* Pipe */
50
+ #endif
51
+ #if !defined(S_IFREG)
52
+ # define S_IFREG _S_IFREG /* Regular file */
53
+ #endif
54
+ #if !defined(S_IREAD)
55
+ # define S_IREAD _S_IREAD /* Read permission */
56
+ #endif
57
+ #if !defined(S_IWRITE)
58
+ # define S_IWRITE _S_IWRITE /* Write permission */
59
+ #endif
60
+ #if !defined(S_IEXEC)
61
+ # define S_IEXEC _S_IEXEC /* Execute permission */
62
+ #endif
63
+ #if !defined(S_IFIFO)
64
+ # define S_IFIFO _S_IFIFO /* Pipe */
65
+ #endif
66
+ #if !defined(S_IFBLK)
67
+ # define S_IFBLK 0 /* Block device */
68
+ #endif
69
+ #if !defined(S_IFLNK)
70
+ # define S_IFLNK 0 /* Link */
71
+ #endif
72
+ #if !defined(S_IFSOCK)
73
+ # define S_IFSOCK 0 /* Socket */
74
+ #endif
75
+
76
+ #if defined(_MSC_VER)
77
+ # define S_IRWXU 0 /* RWX user */
78
+ # define S_IRUSR S_IREAD /* Read user */
79
+ # define S_IWUSR S_IWRITE /* Write user */
80
+ # define S_IXUSR 0 /* Execute user */
81
+ # define S_IRWXG 0 /* RWX group */
82
+ # define S_IRGRP 0 /* Read group */
83
+ # define S_IWGRP 0 /* Write group */
84
+ # define S_IXGRP 0 /* Execute group */
85
+ # define S_IRWXO 0 /* RWX others */
86
+ # define S_IROTH 0 /* Read others */
87
+ # define S_IWOTH 0 /* Write others */
88
+ # define S_IXOTH 0 /* Execute others */
89
+ #endif
90
+
91
+ /* File type flags for d_type */
92
+ #define DT_UNKNOWN 0
93
+ #define DT_REG S_IFREG
94
+ #define DT_DIR S_IFDIR
95
+ #define DT_FIFO S_IFIFO
96
+ #define DT_SOCK S_IFSOCK
97
+ #define DT_CHR S_IFCHR
98
+ #define DT_BLK S_IFBLK
99
+ #define DT_LNK S_IFLNK
100
+
101
+ /* Macros for converting between st_mode and d_type */
102
+ #define IFTODT(mode) ((mode) & S_IFMT)
103
+ #define DTTOIF(type) (type)
104
+
105
+ /*
106
+ * File type macros. Note that block devices, sockets and links cannot be
107
+ * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
108
+ * only defined for compatibility. These macros should always return false
109
+ * on Windows.
110
+ */
111
+ #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
112
+ #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
113
+ #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
114
+ #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
115
+ #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
116
+ #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
117
+ #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
118
+
119
+ #endif
120
+
121
+ #ifdef _WIN32
122
+ int libressl_fstat(int fd, struct stat *statbuf);
123
+
124
+ #ifndef NO_REDEF_POSIX_FUNCTIONS
125
+ #define fstat(fd, statbuf) libressl_fstat(fd, statbuf)
126
+ #endif
127
+ #endif
128
+
129
+ #endif