xcrypt 0.1.0

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 (199) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +106 -0
  3. data/ext/libxcrypt/AUTHORS +38 -0
  4. data/ext/libxcrypt/COPYING.LIB +502 -0
  5. data/ext/libxcrypt/ChangeLog +239 -0
  6. data/ext/libxcrypt/INSTALL +380 -0
  7. data/ext/libxcrypt/LICENSING +152 -0
  8. data/ext/libxcrypt/Makefile.am +704 -0
  9. data/ext/libxcrypt/Makefile.in +4110 -0
  10. data/ext/libxcrypt/NEWS +630 -0
  11. data/ext/libxcrypt/README +1 -0
  12. data/ext/libxcrypt/README.md +179 -0
  13. data/ext/libxcrypt/THANKS +13 -0
  14. data/ext/libxcrypt/TODO +1 -0
  15. data/ext/libxcrypt/TODO.md +100 -0
  16. data/ext/libxcrypt/aclocal.m4 +2617 -0
  17. data/ext/libxcrypt/autogen.sh +33 -0
  18. data/ext/libxcrypt/autom4te.cache/output.0 +19884 -0
  19. data/ext/libxcrypt/autom4te.cache/output.1 +19884 -0
  20. data/ext/libxcrypt/autom4te.cache/output.2 +19884 -0
  21. data/ext/libxcrypt/autom4te.cache/output.3 +19885 -0
  22. data/ext/libxcrypt/autom4te.cache/requests +714 -0
  23. data/ext/libxcrypt/autom4te.cache/traces.0 +4088 -0
  24. data/ext/libxcrypt/autom4te.cache/traces.1 +1060 -0
  25. data/ext/libxcrypt/autom4te.cache/traces.2 +4088 -0
  26. data/ext/libxcrypt/autom4te.cache/traces.3 +1060 -0
  27. data/ext/libxcrypt/build-aux/ci/ci-log-dependency-versions +79 -0
  28. data/ext/libxcrypt/build-aux/ci/ci-log-logfiles +22 -0
  29. data/ext/libxcrypt/build-aux/ci/clang-gcov-wrapper +2 -0
  30. data/ext/libxcrypt/build-aux/ci/configure-wrapper +10 -0
  31. data/ext/libxcrypt/build-aux/ci/summarize-coverage +24 -0
  32. data/ext/libxcrypt/build-aux/m4/ax_append_compile_flags.m4 +46 -0
  33. data/ext/libxcrypt/build-aux/m4/ax_append_flag.m4 +50 -0
  34. data/ext/libxcrypt/build-aux/m4/ax_check_compile_flag.m4 +53 -0
  35. data/ext/libxcrypt/build-aux/m4/ax_check_vscript.m4 +142 -0
  36. data/ext/libxcrypt/build-aux/m4/ax_gcc_func_attribute.m4 +246 -0
  37. data/ext/libxcrypt/build-aux/m4/ax_require_defined.m4 +37 -0
  38. data/ext/libxcrypt/build-aux/m4/ax_valgrind_check.m4 +239 -0
  39. data/ext/libxcrypt/build-aux/m4/libtool.m4 +8488 -0
  40. data/ext/libxcrypt/build-aux/m4/ltoptions.m4 +467 -0
  41. data/ext/libxcrypt/build-aux/m4/ltsugar.m4 +124 -0
  42. data/ext/libxcrypt/build-aux/m4/ltversion.m4 +24 -0
  43. data/ext/libxcrypt/build-aux/m4/lt~obsolete.m4 +99 -0
  44. data/ext/libxcrypt/build-aux/m4/pkg_compat.m4 +88 -0
  45. data/ext/libxcrypt/build-aux/m4/zw_alignment.m4 +90 -0
  46. data/ext/libxcrypt/build-aux/m4/zw_automodern.m4 +307 -0
  47. data/ext/libxcrypt/build-aux/m4/zw_detect_asan.m4 +24 -0
  48. data/ext/libxcrypt/build-aux/m4/zw_endianness.m4 +152 -0
  49. data/ext/libxcrypt/build-aux/m4/zw_ld_wrap.m4 +47 -0
  50. data/ext/libxcrypt/build-aux/m4/zw_prog_perl.m4 +40 -0
  51. data/ext/libxcrypt/build-aux/m4/zw_simple_warnings.m4 +150 -0
  52. data/ext/libxcrypt/build-aux/m4/zw_static_assert.m4 +68 -0
  53. data/ext/libxcrypt/build-aux/m4-autogen/compile +364 -0
  54. data/ext/libxcrypt/build-aux/m4-autogen/config.guess +1815 -0
  55. data/ext/libxcrypt/build-aux/m4-autogen/config.sub +2354 -0
  56. data/ext/libxcrypt/build-aux/m4-autogen/depcomp +792 -0
  57. data/ext/libxcrypt/build-aux/m4-autogen/install-sh +541 -0
  58. data/ext/libxcrypt/build-aux/m4-autogen/ltmain.sh +11524 -0
  59. data/ext/libxcrypt/build-aux/m4-autogen/missing +236 -0
  60. data/ext/libxcrypt/build-aux/m4-autogen/test-driver +160 -0
  61. data/ext/libxcrypt/build-aux/scripts/BuildCommon.pm +712 -0
  62. data/ext/libxcrypt/build-aux/scripts/check-perlcritic-config +76 -0
  63. data/ext/libxcrypt/build-aux/scripts/compute-symver-floor +116 -0
  64. data/ext/libxcrypt/build-aux/scripts/expand-selected-hashes +80 -0
  65. data/ext/libxcrypt/build-aux/scripts/gen-crypt-h +131 -0
  66. data/ext/libxcrypt/build-aux/scripts/gen-crypt-hashes-h +141 -0
  67. data/ext/libxcrypt/build-aux/scripts/gen-crypt-symbol-vers-h +150 -0
  68. data/ext/libxcrypt/build-aux/scripts/gen-libcrypt-map +67 -0
  69. data/ext/libxcrypt/build-aux/scripts/move-if-change +84 -0
  70. data/ext/libxcrypt/build-aux/scripts/skip-if-exec-format-error +78 -0
  71. data/ext/libxcrypt/codecov.yml +4 -0
  72. data/ext/libxcrypt/config.h.in +303 -0
  73. data/ext/libxcrypt/configure +19885 -0
  74. data/ext/libxcrypt/configure.ac +549 -0
  75. data/ext/libxcrypt/doc/crypt.3 +512 -0
  76. data/ext/libxcrypt/doc/crypt.5 +343 -0
  77. data/ext/libxcrypt/doc/crypt_checksalt.3 +106 -0
  78. data/ext/libxcrypt/doc/crypt_gensalt.3 +285 -0
  79. data/ext/libxcrypt/doc/crypt_gensalt_ra.3 +1 -0
  80. data/ext/libxcrypt/doc/crypt_gensalt_rn.3 +1 -0
  81. data/ext/libxcrypt/doc/crypt_preferred_method.3 +68 -0
  82. data/ext/libxcrypt/doc/crypt_r.3 +1 -0
  83. data/ext/libxcrypt/doc/crypt_ra.3 +1 -0
  84. data/ext/libxcrypt/doc/crypt_rn.3 +1 -0
  85. data/ext/libxcrypt/lib/alg-des-tables.c +3858 -0
  86. data/ext/libxcrypt/lib/alg-des.c +269 -0
  87. data/ext/libxcrypt/lib/alg-des.h +74 -0
  88. data/ext/libxcrypt/lib/alg-gost3411-2012-const.h +313 -0
  89. data/ext/libxcrypt/lib/alg-gost3411-2012-core.c +238 -0
  90. data/ext/libxcrypt/lib/alg-gost3411-2012-core.h +51 -0
  91. data/ext/libxcrypt/lib/alg-gost3411-2012-hmac.c +78 -0
  92. data/ext/libxcrypt/lib/alg-gost3411-2012-hmac.h +46 -0
  93. data/ext/libxcrypt/lib/alg-gost3411-2012-precalc.h +1426 -0
  94. data/ext/libxcrypt/lib/alg-gost3411-2012-ref.h +67 -0
  95. data/ext/libxcrypt/lib/alg-hmac-sha1.c +140 -0
  96. data/ext/libxcrypt/lib/alg-hmac-sha1.h +35 -0
  97. data/ext/libxcrypt/lib/alg-md4.c +270 -0
  98. data/ext/libxcrypt/lib/alg-md4.h +43 -0
  99. data/ext/libxcrypt/lib/alg-md5.c +291 -0
  100. data/ext/libxcrypt/lib/alg-md5.h +43 -0
  101. data/ext/libxcrypt/lib/alg-sha1.c +288 -0
  102. data/ext/libxcrypt/lib/alg-sha1.h +34 -0
  103. data/ext/libxcrypt/lib/alg-sha256.c +630 -0
  104. data/ext/libxcrypt/lib/alg-sha256.h +123 -0
  105. data/ext/libxcrypt/lib/alg-sha512.c +311 -0
  106. data/ext/libxcrypt/lib/alg-sha512.h +81 -0
  107. data/ext/libxcrypt/lib/alg-sm3-hmac.c +113 -0
  108. data/ext/libxcrypt/lib/alg-sm3-hmac.h +42 -0
  109. data/ext/libxcrypt/lib/alg-sm3.c +449 -0
  110. data/ext/libxcrypt/lib/alg-sm3.h +63 -0
  111. data/ext/libxcrypt/lib/alg-yescrypt-common.c +713 -0
  112. data/ext/libxcrypt/lib/alg-yescrypt-opt.c +1568 -0
  113. data/ext/libxcrypt/lib/alg-yescrypt-platform.c +106 -0
  114. data/ext/libxcrypt/lib/alg-yescrypt.h +360 -0
  115. data/ext/libxcrypt/lib/byteorder.h +164 -0
  116. data/ext/libxcrypt/lib/crypt-bcrypt.c +1061 -0
  117. data/ext/libxcrypt/lib/crypt-des-obsolete.c +215 -0
  118. data/ext/libxcrypt/lib/crypt-des.c +491 -0
  119. data/ext/libxcrypt/lib/crypt-gensalt-static.c +40 -0
  120. data/ext/libxcrypt/lib/crypt-gost-yescrypt.c +182 -0
  121. data/ext/libxcrypt/lib/crypt-md5.c +232 -0
  122. data/ext/libxcrypt/lib/crypt-nthash.c +134 -0
  123. data/ext/libxcrypt/lib/crypt-obsolete.h +40 -0
  124. data/ext/libxcrypt/lib/crypt-pbkdf1-sha1.c +260 -0
  125. data/ext/libxcrypt/lib/crypt-port.h +514 -0
  126. data/ext/libxcrypt/lib/crypt-scrypt.c +247 -0
  127. data/ext/libxcrypt/lib/crypt-sha256.c +308 -0
  128. data/ext/libxcrypt/lib/crypt-sha512.c +323 -0
  129. data/ext/libxcrypt/lib/crypt-sm3-yescrypt.c +189 -0
  130. data/ext/libxcrypt/lib/crypt-sm3.c +308 -0
  131. data/ext/libxcrypt/lib/crypt-static.c +44 -0
  132. data/ext/libxcrypt/lib/crypt-sunmd5.c +314 -0
  133. data/ext/libxcrypt/lib/crypt-yescrypt.c +177 -0
  134. data/ext/libxcrypt/lib/crypt.c +421 -0
  135. data/ext/libxcrypt/lib/crypt.h.in +249 -0
  136. data/ext/libxcrypt/lib/gen-des-tables.c +363 -0
  137. data/ext/libxcrypt/lib/hashes.conf +59 -0
  138. data/ext/libxcrypt/lib/libcrypt.map.in +48 -0
  139. data/ext/libxcrypt/lib/libcrypt.minver +97 -0
  140. data/ext/libxcrypt/lib/libxcrypt.pc.in +15 -0
  141. data/ext/libxcrypt/lib/util-base64.c +26 -0
  142. data/ext/libxcrypt/lib/util-gensalt-sha.c +88 -0
  143. data/ext/libxcrypt/lib/util-get-random-bytes.c +154 -0
  144. data/ext/libxcrypt/lib/util-make-failure-token.c +48 -0
  145. data/ext/libxcrypt/lib/util-xbzero.c +43 -0
  146. data/ext/libxcrypt/lib/util-xstrcpy.c +42 -0
  147. data/ext/libxcrypt/lib/xcrypt.h.in +58 -0
  148. data/ext/libxcrypt/libxcrypt.spec.rpkg +481 -0
  149. data/ext/libxcrypt/rpkg.conf +2 -0
  150. data/ext/libxcrypt/rpkg.macros +86 -0
  151. data/ext/libxcrypt/test/TestCommon.pm +326 -0
  152. data/ext/libxcrypt/test/alg-des.c +80 -0
  153. data/ext/libxcrypt/test/alg-gost3411-2012-hmac.c +90 -0
  154. data/ext/libxcrypt/test/alg-gost3411-2012.c +191 -0
  155. data/ext/libxcrypt/test/alg-hmac-sha1.c +187 -0
  156. data/ext/libxcrypt/test/alg-md4.c +111 -0
  157. data/ext/libxcrypt/test/alg-md5.c +134 -0
  158. data/ext/libxcrypt/test/alg-pbkdf-hmac-sha256.c +269 -0
  159. data/ext/libxcrypt/test/alg-sha1.c +111 -0
  160. data/ext/libxcrypt/test/alg-sha256.c +141 -0
  161. data/ext/libxcrypt/test/alg-sha512.c +170 -0
  162. data/ext/libxcrypt/test/alg-sm3-hmac.c +149 -0
  163. data/ext/libxcrypt/test/alg-sm3.c +168 -0
  164. data/ext/libxcrypt/test/alg-yescrypt.c +466 -0
  165. data/ext/libxcrypt/test/badsalt.c +726 -0
  166. data/ext/libxcrypt/test/badsetting.c +350 -0
  167. data/ext/libxcrypt/test/byteorder.c +254 -0
  168. data/ext/libxcrypt/test/checksalt.c +265 -0
  169. data/ext/libxcrypt/test/compile-strong-alias.c +43 -0
  170. data/ext/libxcrypt/test/crypt-badargs.c +392 -0
  171. data/ext/libxcrypt/test/crypt-gost-yescrypt.c +149 -0
  172. data/ext/libxcrypt/test/crypt-nested-call.c +180 -0
  173. data/ext/libxcrypt/test/crypt-sm3-yescrypt.c +149 -0
  174. data/ext/libxcrypt/test/crypt-too-long-phrase.c +157 -0
  175. data/ext/libxcrypt/test/des-cases.h +196 -0
  176. data/ext/libxcrypt/test/des-obsolete.c +206 -0
  177. data/ext/libxcrypt/test/des-obsolete_r.c +207 -0
  178. data/ext/libxcrypt/test/explicit-bzero.c +334 -0
  179. data/ext/libxcrypt/test/gensalt-bcrypt_x.c +54 -0
  180. data/ext/libxcrypt/test/gensalt-extradata.c +246 -0
  181. data/ext/libxcrypt/test/gensalt-nested-call.c +126 -0
  182. data/ext/libxcrypt/test/gensalt-nthash.c +65 -0
  183. data/ext/libxcrypt/test/gensalt.c +599 -0
  184. data/ext/libxcrypt/test/getrandom-fallbacks.c +295 -0
  185. data/ext/libxcrypt/test/getrandom-interface.c +211 -0
  186. data/ext/libxcrypt/test/ka-table-gen.py +945 -0
  187. data/ext/libxcrypt/test/ka-table.inc +5849 -0
  188. data/ext/libxcrypt/test/ka-tester.c +240 -0
  189. data/ext/libxcrypt/test/preferred-method.c +133 -0
  190. data/ext/libxcrypt/test/short-outbuf.c +119 -0
  191. data/ext/libxcrypt/test/special-char-salt.c +1160 -0
  192. data/ext/libxcrypt/test/symbols-compat.pl +137 -0
  193. data/ext/libxcrypt/test/symbols-renames.pl +107 -0
  194. data/ext/libxcrypt/test/symbols-static.pl +87 -0
  195. data/ext/xcrypt/xcrypt.c +9 -0
  196. data/lib/xcrypt/ffi.rb +76 -0
  197. data/lib/xcrypt/version.rb +5 -0
  198. data/lib/xcrypt.rb +89 -0
  199. metadata +267 -0
@@ -0,0 +1,152 @@
1
+ dnl Written by Zack Weinberg <zackw at panix.com> in 2018.
2
+ dnl To the extent possible under law, Zack Weinberg has waived all
3
+ dnl copyright and related or neighboring rights to this work.
4
+ dnl
5
+ dnl See https://creativecommons.org/publicdomain/zero/1.0/ for further
6
+ dnl details.
7
+ dnl
8
+ dnl This macro is like AC_C_BIGENDIAN, but it doesn't try to determine
9
+ dnl a final value at configure time. Instead, it probes for a set of
10
+ dnl headers and compile-time macros that may or may not be available,
11
+ dnl and uses them to guide preprocessor logic that makes the final
12
+ dnl determination. This works better with MacOS "universal binaries",
13
+ dnl which may involve compiling the program twice under opposite
14
+ dnl endiannesses; no fixed byte-order macro is correct in that case,
15
+ dnl but the compiler's built-ins will be. This approach is also
16
+ dnl friendlier to cross-compilation.
17
+ dnl
18
+ dnl This is the preprocessor logic that should be put in an appropriate
19
+ dnl location, after including config.h:
20
+ dnl
21
+ dnl #include <limits.h>
22
+ dnl #ifdef HAVE_ENDIAN_H
23
+ dnl #include <endian.h>
24
+ dnl #endif
25
+ dnl #ifdef HAVE_SYS_ENDIAN_H
26
+ dnl #include <sys/endian.h>
27
+ dnl #endif
28
+ dnl #ifdef HAVE_SYS_PARAM_H
29
+ dnl #include <sys/param.h>
30
+ dnl #endif
31
+ dnl
32
+ dnl #if ENDIANNESS_IS_BIG
33
+ dnl # define ENDIAN_BIG
34
+ dnl #elif ENDIANNESS_IS_LITTLE
35
+ dnl # define ENDIAN_LITTLE
36
+ dnl #elif ENDIANNESS_IS_PDP
37
+ dnl # define ENDIAN_PDP
38
+ dnl #else
39
+ dnl # error "Unable to determine byte order"
40
+ dnl #endif
41
+ dnl ------------------------------------------------
42
+
43
+ dnl There's no good way to implement this macro as a _shell_ loop, but we
44
+ dnl can reasonably implement it as an _m4_ loop that expands to a sequence
45
+ dnl of conditionals. Actually two sequences of conditionals, one inside
46
+ dnl AC_CACHE_CHECK and one outside.
47
+
48
+ m4_define([zw_C_ENDIANNESS_options], [
49
+ [ [BYTE_ORDER and xxx_ENDIAN],
50
+ [defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN && BIG_ENDIAN != LITTLE_ENDIAN],
51
+ [BYTE_ORDER == BIG_ENDIAN],
52
+ [BYTE_ORDER == LITTLE_ENDIAN],
53
+ [BYTE_ORDER == PDP_ENDIAN],
54
+ ],
55
+ [ [__BYTE_ORDER and __xxx_ENDIAN],
56
+ [defined __BYTE_ORDER && defined __BIG_ENDIAN && defined __LITTLE_ENDIAN && __BIG_ENDIAN != __LITTLE_ENDIAN],
57
+ [__BYTE_ORDER == __BIG_ENDIAN],
58
+ [__BYTE_ORDER == __LITTLE_ENDIAN],
59
+ [__BYTE_ORDER == __PDP_ENDIAN],
60
+ ],
61
+ [ [__BYTE_ORDER__ and __xxx_ENDIAN__],
62
+ [defined __BYTE_ORDER__ && defined __BIG_ENDIAN__ && defined __LITTLE_ENDIAN__ && __BIG_ENDIAN__ != __LITTLE_ENDIAN__],
63
+ [__BYTE_ORDER__ == __BIG_ENDIAN__],
64
+ [__BYTE_ORDER__ == __LITTLE_ENDIAN__],
65
+ [__BYTE_ORDER__ == __PDP_ENDIAN__],
66
+ ],
67
+ [ [__BYTE_ORDER__ and __ORDER_xxx_ENDIAN__],
68
+ [defined __BYTE_ORDER__ && defined __ORDER_BIG_ENDIAN__ && defined __ORDER_LITTLE_ENDIAN__ && __ORDER_BIG_ENDIAN__ != __ORDER_LITTLE_ENDIAN__],
69
+ [__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__],
70
+ [__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__],
71
+ [__BYTE_ORDER__ == __ORDER_PDP_ENDIAN__],
72
+ ],
73
+ [ [_BIG_ENDIAN and _LITTLE_ENDIAN],
74
+ [(defined _BIG_ENDIAN) != (defined _LITTLE_ENDIAN)],
75
+ [defined _BIG_ENDIAN], [defined _LITTLE_ENDIAN], [0],
76
+ ],
77
+ [ [__BIG_ENDIAN__ and __LITTLE_ENDIAN__],
78
+ [(defined __BIG_ENDIAN__) != (defined __LITTLE_ENDIAN__)],
79
+ [defined __BIG_ENDIAN__], [defined __LITTLE_ENDIAN__], [0],
80
+ ],
81
+ [ [__ARMEB__ and __ARMEL__],
82
+ [(defined __ARMEB__) != (defined __ARMEL__)],
83
+ [defined __ARMEB__], [defined __ARMEL__], [0],
84
+ ],
85
+ [ [__THUMBEB__ and __THUMBEL__],
86
+ [(defined __THUMBEB__) != (defined __THUMBEL__)],
87
+ [defined __THUMBEB__], [defined __THUMBEL__], [0],
88
+ ],
89
+ [ [__AARCH64EB__ and __AARCH64EL__],
90
+ [(defined __AARCH64EB__) != (defined __AARCH64EL__)],
91
+ [defined __AARCH64EB__], [defined __AARCH64EL__], [0],
92
+ ],
93
+ [ [__MIPSEB__ and __MIPSEL__],
94
+ [(defined __MIPSEB__) != (defined __MIPSEL__)],
95
+ [defined __MIPSEB__], [defined __MIPSEL__], [0],
96
+ ],
97
+ [ [__MIPSEB and __MIPSEL],
98
+ [(defined __MIPSEB) != (defined __MIPSEL)],
99
+ [defined __MIPSEB], [defined __MIPSEL], [0],
100
+ ],
101
+ [ [_MIPSEB and _MIPSEL],
102
+ [(defined _MIPSEB) != (defined _MIPSEL)],
103
+ [defined _MIPSEB], [defined _MIPSEL], [0],
104
+ ]
105
+ ])
106
+
107
+ m4_define([zw_C_ENDIANNESS_test_one], [
108
+ if test "$[]ac_cv_c_byte_order_macros" = unknown; then
109
+ AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
110
+ #include <limits.h>
111
+ #ifdef HAVE_ENDIAN_H
112
+ #include <endian.h>
113
+ #endif
114
+ #ifdef HAVE_SYS_ENDIAN_H
115
+ #include <sys/endian.h>
116
+ #endif
117
+ #ifdef HAVE_SYS_PARAM_H
118
+ #include <sys/param.h>
119
+ #endif
120
+ #if !($2)
121
+ #error fail
122
+ #endif
123
+ ]])],
124
+ [ac_cv_c_byte_order_macros="$1"])
125
+ fi])
126
+
127
+ m4_define([zw_C_ENDIANNESS_case_one],
128
+ [["$1"], [
129
+ zw_C_ENDIANNESS_IS_BIG="($3)"
130
+ zw_C_ENDIANNESS_IS_LIT="($4)"
131
+ zw_C_ENDIANNESS_IS_PDP="($5)"]])
132
+
133
+ AC_DEFUN([zw_C_ENDIANNESS], [
134
+ AC_REQUIRE([AC_PROG_CC])
135
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
136
+ AC_CHECK_HEADERS_ONCE([endian.h sys/endian.h sys/param.h])
137
+ AC_CACHE_CHECK([for byte order macros],
138
+ [ac_cv_c_byte_order_macros], [
139
+ ac_cv_c_byte_order_macros=unknown
140
+ m4_map([zw_C_ENDIANNESS_test_one], [zw_C_ENDIANNESS_options])])
141
+
142
+ AS_CASE([$ac_cv_c_byte_order_macros],
143
+ m4_map_sep([zw_C_ENDIANNESS_case_one], [,], [zw_C_ENDIANNESS_options]),
144
+ [AC_MSG_ERROR([unable to determine byte order at compile time])])
145
+
146
+ AC_DEFINE_UNQUOTED([ENDIANNESS_IS_BIG], [$zw_C_ENDIANNESS_IS_BIG],
147
+ [Define as an @%:@if expression that is true when compiling for a big-endian CPU.])
148
+ AC_DEFINE_UNQUOTED([ENDIANNESS_IS_LITTLE], [$zw_C_ENDIANNESS_IS_LIT],
149
+ [Define as an @%:@if expression that is true when compiling for a little-endian CPU.])
150
+ AC_DEFINE_UNQUOTED([ENDIANNESS_IS_PDP], [$zw_C_ENDIANNESS_IS_PDP],
151
+ [Define as an @%:@if expression that is true when compiling for a PDP-endian CPU.])
152
+ ])
@@ -0,0 +1,47 @@
1
+ dnl Written by Zack Weinberg <zackw at panix.com> in 2018.
2
+ dnl To the extent possible under law, Zack Weinberg has waived all
3
+ dnl copyright and related or neighboring rights to this work.
4
+ dnl
5
+ dnl See https://creativecommons.org/publicdomain/zero/1.0/ for further
6
+ dnl details.
7
+ dnl
8
+ dnl Find out whether ld --wrap is supported.
9
+ AC_DEFUN([zw_PROG_LD_WRAP],
10
+ [AC_REQUIRE([AC_PROG_CC])
11
+ AC_CACHE_CHECK([for ld --wrap], [zw_cv_prog_ld_wrap],
12
+ [save_LDFLAGS="$LDFLAGS"
13
+ save_LIBS="$LIBS"
14
+ LDFLAGS=""
15
+ LIBS=""
16
+ AC_COMPILE_IFELSE(
17
+ [AC_LANG_SOURCE([[
18
+ extern void bar(void);
19
+ void foo(void) { bar(); }
20
+ ]])],
21
+ [mv conftest.$OBJEXT conftest2.$OBJEXT
22
+ LDFLAGS="-Wl,--wrap,bar"
23
+ LIBS="conftest2.$OBJEXT"
24
+ AC_LINK_IFELSE(
25
+ [AC_LANG_PROGRAM([[
26
+ extern void foo(void);
27
+ void __wrap_bar(void) {}
28
+ ]], [[
29
+ foo();
30
+ ]])],
31
+ [zw_cv_prog_ld_wrap=yes],
32
+ [zw_cv_prog_ld_wrap=no])
33
+ rm -f conftest2.$OBJEXT
34
+ ],
35
+ [zw_cv_prog_ld_wrap=no])
36
+ LDFLAGS="$save_LDFLAGS"
37
+ LIBS="$save_LIBS"])
38
+ if test x$zw_cv_prog_ld_wrap = xyes; then
39
+ have_ld_wrap=yes
40
+ AC_DEFINE([HAVE_LD_WRAP], 1,
41
+ [Define to 1 if -Wl,--wrap,SYMBOL can be used to intercept
42
+ calls to SYMBOL at link time.])
43
+ else
44
+ have_ld_wrap=no
45
+ fi
46
+ AM_CONDITIONAL([HAVE_LD_WRAP], [test $have_ld_wrap = yes])
47
+ ])
@@ -0,0 +1,40 @@
1
+ # zw_prog_perl.m4 -*- autoconf -*-
2
+ # serial 1
3
+ #
4
+ # inspired by, but shares no code with, ax_prog_perl_version.m4 by
5
+ # Franceso Salvestrini
6
+ #
7
+ # SYNOPSIS
8
+ #
9
+ # zw_PROG_PERL([VERSION], [ACTION-IF-TRUE],
10
+ # [ACTION-IF-FALSE = (error out)])
11
+ #
12
+ # DESCRIPTION
13
+ #
14
+ # Locate a Perl interpreter, and then verify that its version number
15
+ # is greater than or equal to VERSION. If it is, set output variable
16
+ # PERL to the absolute path of that interpreter, and execute
17
+ # ACTION-IF-TRUE, if present. Otherwise, execute ACTION-IF-FALSE.
18
+ # If ACTION-IF-FALSE is not present it defaults to issuing an error
19
+ # and stopping the configuration process.
20
+ #
21
+ # LICENSE
22
+ #
23
+ # Copyright (c) 2020 Zack Weinberg <zackw@panix.com>
24
+ #
25
+ # Copying and distribution of this file, with or without modification, are
26
+ # permitted in any medium without royalty provided the copyright notice
27
+ # and this notice are preserved. This file is offered as-is, without any
28
+ # warranty.
29
+
30
+ #serial 13
31
+
32
+ AC_DEFUN([zw_PROG_PERL],
33
+ [AC_PATH_PROG([PERL], [perl])
34
+ AC_MSG_CHECKING([whether $PERL is version $1 or later])
35
+ _AS_ECHO_LOG([$PERL -e 'use v$1;'])
36
+ AS_IF(["$PERL" -e 'use v$1;' >&AS_MESSAGE_LOG_FD 2>&1],
37
+ [AC_MSG_RESULT([yes])m4_ifnblank([$2], [
38
+ $2])],
39
+ [AC_MSG_RESULT([no])
40
+ m4_default([$3], [AC_MSG_ERROR([Perl version $1 or later is required])])])])
@@ -0,0 +1,150 @@
1
+ # serial 1
2
+ dnl Copyright 2017 Zack Weinberg <zackw at panix.com>.
3
+ dnl Partially based on Autoconf, copyright 1992-2017 Free Software Foundation.
4
+ dnl
5
+ dnl This program is free software; you can redistribute it and/or
6
+ dnl modify it under the terms of the GNU General Public License as
7
+ dnl published by the Free Software Foundation, either version 3 of the
8
+ dnl License, or (at your option) any later version.
9
+ dnl
10
+ dnl This program is distributed in the hope that it will be useful,
11
+ dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ dnl GNU General Public License for more details.
14
+ dnl
15
+ dnl Under Section 7 of GPL version 3, you are granted additional
16
+ dnl permissions described in the Autoconf Configure Script Exception,
17
+ dnl version 3.0, as published by the Free Software Foundation.
18
+ dnl
19
+ dnl Because only two files in this source tree are released
20
+ dnl under GPLv3 with exceptions, neither the GPLv3 nor the exception are
21
+ dnl distributed with this source tree. Copies can be retrieved from
22
+ dnl https://www.gnu.org/licenses/
23
+ dnl
24
+ dnl Autoconf core has no good way of enabling compiler warnings.
25
+ dnl This is a cut-down version of the elaborate thing in the extras
26
+ dnl archive, which we do not need nearly all of.
27
+ dnl
28
+ dnl Partly based on:
29
+ dnl https://www.gnu.org/software/autoconf-archive/ax_compiler_flags_cflags.html
30
+
31
+ AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
32
+
33
+ AC_DEFUN([zw_SIMPLE_ENABLE_WARNINGS],
34
+ [
35
+ AC_ARG_ENABLE(
36
+ [werror],
37
+ AS_HELP_STRING(
38
+ [--disable-werror],
39
+ [do not treat all warnings as errors]
40
+ ),
41
+ [case "${enableval}" in
42
+ yes) warnings_are_errors=true ;;
43
+ no) warnings_are_errors=false ;;
44
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-werror]) ;;
45
+ esac],
46
+ [warnings_are_errors=true]
47
+ )
48
+
49
+ # Always pass -Werror=unknown-warning-option to get Clang to fail
50
+ # on bad flags, otherwise they are always appended to the
51
+ # warn_cflags variable, and Clang warns on them for every
52
+ # compilation unit. If this is passed to GCC, it will explode, so
53
+ # the flag must be enabled conditionally.
54
+ AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
55
+ ax_compiler_flags_test="-Werror=unknown-warning-option"
56
+ ],[
57
+ ax_compiler_flags_test=""
58
+ ])
59
+
60
+ # Don't enable -pedantic if we don't have C11, or we may get junk
61
+ # warnings about static_assert.
62
+ ax_candidate_warnings="dnl
63
+ -Wall dnl
64
+ -Wextra dnl
65
+ -Walloc-zero dnl
66
+ -Walloca dnl
67
+ -Wbad-function-cast dnl
68
+ -Wcast-align dnl
69
+ -Wcast-qual dnl
70
+ -Wconversion dnl
71
+ -Wformat=2 dnl
72
+ -Wformat-overflow=2 dnl
73
+ -Wformat-signedness dnl
74
+ -Wformat-truncation=1 dnl
75
+ -Wlogical-op dnl
76
+ -Wmissing-declarations dnl
77
+ -Wmissing-prototypes dnl
78
+ -Wnested-externs dnl
79
+ -Wnull-dereference dnl
80
+ -Wold-style-definition dnl
81
+ -Wpointer-arith dnl
82
+ -Wrestrict dnl
83
+ -Wshadow dnl
84
+ -Wstrict-overflow=2 dnl
85
+ -Wstrict-prototypes dnl
86
+ -Wundef dnl
87
+ -Wvla dnl
88
+ -Wwrite-strings dnl
89
+ "
90
+ if test x$ac_prog_cc_stdc = xc11; then
91
+ ax_candidate_warnings="$ax_candidate_warnings -Wpedantic"
92
+ fi
93
+ if test x$warnings_are_errors = xtrue; then
94
+ ax_candidate_warnings="$ax_candidate_warnings -Werror"
95
+ fi
96
+
97
+ # If we are building for OSX, turn -Wdeprecated-declarations off.
98
+ # Apple is a little too trigger-happy with deprecations.
99
+ case "$host_os" in
100
+ (*darwin*)
101
+ ax_candidate_warnings="$ax_candidate_warnings -Wno-deprecated-declarations"
102
+ ;;
103
+ esac
104
+
105
+ AX_APPEND_COMPILE_FLAGS(
106
+ [$ax_candidate_warnings], [WARN_CFLAGS],
107
+ [$ax_compiler_flags_test])
108
+
109
+ AC_SUBST(WARN_CFLAGS)
110
+
111
+ if test $cross_compiling = yes; then
112
+ # Repeat the above logic for the build compiler.
113
+
114
+ save_cross_compiling=$cross_compiling
115
+ save_ac_tool_prefix=$ac_tool_prefix
116
+ save_CC="$CC"
117
+ save_CFLAGS="$CFLAGS"
118
+ save_CPPFLAGS="$CPPFLAGS"
119
+ save_LDFLAGS="$LDFLAGS"
120
+
121
+ cross_compiling=no
122
+ ac_tool_prefix=
123
+ CC="$CC_FOR_BUILD"
124
+ CFLAGS="$CFLAGS_FOR_BUILD"
125
+ CPPFLAGS="$CPPFLAGS_FOR_BUILD"
126
+ LDFLAGS="$LDFLAGS_FOR_BUILD"
127
+
128
+ pushdef([_AC_LANG_ABBREV],[build_c])
129
+
130
+ AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
131
+ ax_compiler_flags_test="-Werror=unknown-warning-option"
132
+ ],[
133
+ ax_compiler_flags_test=""
134
+ ])
135
+ AX_APPEND_COMPILE_FLAGS(
136
+ [$ax_candidate_warnings], [WARN_CFLAGS_FOR_BUILD],
137
+ [$ax_compiler_flags_test])
138
+
139
+ popdef([_AC_LANG_ABBREV])
140
+
141
+ AC_SUBST(WARN_CFLAGS_FOR_BUILD)
142
+
143
+ cross_compiling=$save_cross_compiling
144
+ ac_tool_prefix=$save_ac_tool_prefix
145
+ CC="$save_CC"
146
+ CFLAGS="$save_CFLAGS"
147
+ CPPFLAGS="$save_CPPFLAGS"
148
+ LDFLAGS="$save_LDFLAGS"
149
+ fi # cross_compiling
150
+ ])
@@ -0,0 +1,68 @@
1
+ dnl Written by Zack Weinberg <zackw at panix.com> in 2017.
2
+ dnl To the extent possible under law, Zack Weinberg has waived all
3
+ dnl copyright and related or neighboring rights to this work.
4
+ dnl
5
+ dnl See https://creativecommons.org/publicdomain/zero/1.0/ for further
6
+ dnl details.
7
+ dnl
8
+ dnl Check for static_assert in <assert.h>; failing that, check for intrinsic
9
+ dnl support for C11 _Static_assert.
10
+ dnl assert.h itself is in C89 and does not need to be probed for;
11
+ dnl moreover, AC_PROG_CC's check for C11 includes _Static_assert (but not
12
+ dnl static_assert).
13
+ dnl Some logic borrowed from gnulib's assert_h.m4.
14
+ dnl 2*2 != 7 is tested in honor of Stanisław Lem.
15
+ AC_DEFUN([zw_C_STATIC_ASSERT],
16
+ [AC_REQUIRE([AC_PROG_CC])
17
+ AC_CACHE_CHECK([for static_assert in assert.h],
18
+ [zw_cv_c_assert_h_static_assert],
19
+ [AC_COMPILE_IFELSE(
20
+ [AC_LANG_PROGRAM([[
21
+ #undef NDEBUG
22
+ #include <assert.h>
23
+ static_assert(2 + 2 == 4, "arithmetic does not work");
24
+ ]], [[
25
+ static_assert(sizeof (char) == 1, "sizeof does not work");
26
+ ]])],
27
+ [static_assert_true=yes],
28
+ [static_assert_true=no])
29
+ AC_COMPILE_IFELSE(
30
+ [AC_LANG_PROGRAM([[
31
+ #undef NDEBUG
32
+ #include <assert.h>
33
+ static_assert(2 * 2 == 7, "this assertion should fail");
34
+ ]])],
35
+ [static_assert_false=no],
36
+ [static_assert_false=yes])
37
+ AS_IF([test $static_assert_false$static_assert_true = yesyes],
38
+ [zw_cv_c_assert_h_static_assert=yes],
39
+ [zw_cv_c_assert_h_static_assert=no])])
40
+ AS_IF([test $zw_cv_c_assert_h_static_assert = yes],
41
+ [AC_DEFINE([HAVE_STATIC_ASSERT_IN_ASSERT_H], 1,
42
+ [Define if <assert.h> defines static_assert.])],
43
+ [AC_CACHE_CHECK([for _Static_assert],
44
+ [zw_cv_c__Static_assert],
45
+ [AS_IF([test x$ac_prog_cc_stdc = xc11],
46
+ [zw_cv_c__Static_assert=yes],
47
+ [AC_COMPILE_IFELSE(
48
+ [AC_LANG_PROGRAM([[
49
+ _Static_assert(2 + 2 == 4, "arithmetic does not work");
50
+ ]], [[
51
+ _Static_assert(sizeof (char) == 1, "sizeof does not work");
52
+ ]])],
53
+ [_Static_assert_true=yes],
54
+ [_Static_assert_true=no])
55
+ AC_COMPILE_IFELSE(
56
+ [AC_LANG_PROGRAM([[
57
+ _Static_assert(2 * 2 == 7, "this assertion should fail");
58
+ ]])],
59
+ [_Static_assert_false=no],
60
+ [_Static_assert_false=yes])
61
+ AS_IF([test $static_assert_false$static_assert_true = yesyes],
62
+ [zw_cv_c__Static_assert=yes],
63
+ [zw_cv_c__Static_assert=no])])])
64
+ AS_IF([test $zw_cv_c__Static_assert = yes],
65
+ [AC_DEFINE([HAVE__STATIC_ASSERT], 1,
66
+ [Define if the compiler supports the _Static_assert intrinsic.])])
67
+ ])
68
+ ])