diff options
| author | William Ahern <william+ubuntu@25thandClement.com> | 2016-10-19 13:24:50 -0700 |
|---|---|---|
| committer | William Ahern <william+ubuntu@25thandClement.com> | 2016-10-19 13:24:50 -0700 |
| commit | 6e9ce5c2b3adfc52030815c43439f4890f31c32c (patch) | |
| tree | ebffcc6761d18d090da01f755eae781a4041c6e8 | |
| parent | ed41847aea5553e67e7df58723dd863c2110b6ae (diff) | |
| parent | 5949f01087291c0a6431f90264fc9795b133867f (diff) | |
| download | luaossl-6e9ce5c2b3adfc52030815c43439f4890f31c32c.tar.gz luaossl-6e9ce5c2b3adfc52030815c43439f4890f31c32c.tar.bz2 luaossl-6e9ce5c2b3adfc52030815c43439f4890f31c32c.zip | |
Merge branch 'oerdnj-master'
| -rw-r--r-- | GNUmakefile | 3 | ||||
| -rw-r--r-- | config.h.guess | 874 | ||||
| -rw-r--r-- | src/GNUmakefile | 6 | ||||
| -rw-r--r-- | src/openssl.c | 75 |
4 files changed, 927 insertions, 31 deletions
diff --git a/GNUmakefile b/GNUmakefile index 2955d86..c58686c 100644 --- a/GNUmakefile +++ b/GNUmakefile | |||
| @@ -133,6 +133,9 @@ endif | |||
| 133 | # | 133 | # |
| 134 | include $(d)/src/GNUmakefile | 134 | include $(d)/src/GNUmakefile |
| 135 | 135 | ||
| 136 | $(d)/config.h: $(d)/config.h.guess | ||
| 137 | $(CP) $< $@ | ||
| 138 | |||
| 136 | 139 | ||
| 137 | # | 140 | # |
| 138 | # C L E A N R U L E S | 141 | # C L E A N R U L E S |
diff --git a/config.h.guess b/config.h.guess new file mode 100644 index 0000000..c40f6bf --- /dev/null +++ b/config.h.guess | |||
| @@ -0,0 +1,874 @@ | |||
| 1 | /* ========================================================================== | ||
| 2 | * config.h.guess - Preprocessor-based feature detection | ||
| 3 | * -------------------------------------------------------------------------- | ||
| 4 | * Copyright (c) 2015-2016 William Ahern | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 7 | * copy of this software and associated documentation files (the | ||
| 8 | * "Software"), to deal in the Software without restriction, including | ||
| 9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
| 10 | * distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 11 | * persons to whom the Software is furnished to do so, subject to the | ||
| 12 | * following conditions: | ||
| 13 | * | ||
| 14 | * The above copyright notice and this permission notice shall be included | ||
| 15 | * in all copies or substantial portions of the Software. | ||
| 16 | * | ||
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
| 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 20 | * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 21 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 23 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 24 | * ========================================================================== | ||
| 25 | */ | ||
| 26 | #ifndef CONFIG_H_GUESS | ||
| 27 | #define CONFIG_H_GUESS | ||
| 28 | |||
| 29 | /* | ||
| 30 | * A U T O G U E S S V E R S I O N | ||
| 31 | * | ||
| 32 | * Change AG_VENDOR if maintaining a fork. | ||
| 33 | * | ||
| 34 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 35 | |||
| 36 | #define AG_VENDOR "william+autoguess@25thandClement.com" | ||
| 37 | #define AG_VERSION 20161019L | ||
| 38 | |||
| 39 | |||
| 40 | /* | ||
| 41 | * C O M P I L E R V E N D O R / V E R S I O N D E T E C T I O N | ||
| 42 | * | ||
| 43 | * See http://sourceforge.net/p/predef/wiki/Compilers/ | ||
| 44 | * | ||
| 45 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 46 | |||
| 47 | #define AG_GNUC_2VER(M, m, p) (((M) * 10000) + ((m) * 100) + (p)) | ||
| 48 | #define AG_GNUC_PREREQ(M, m, p) (__GNUC__ > 0 && AG_GNUC_2VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) >= AG_GNUC_2VER((M), (m), (p))) | ||
| 49 | |||
| 50 | #define AG_MSC_2VER(M, m, p) ((((M) + 6) * 10000000) + ((m) * 1000000) + (p)) | ||
| 51 | #define AG_MSC_PREREQ(M, m, p) (_MSC_VER_FULL > 0 && _MSC_VER_FULL >= AG_MSC_2VER((M), (m), (p))) | ||
| 52 | |||
| 53 | #define AG_SUNPRO_PREREQ(M, m, p) (__SUNPRO_C > 0 && __SUNPRO_C >= 0x ## M ## m ## p) | ||
| 54 | |||
| 55 | |||
| 56 | /* | ||
| 57 | * C O M P I L E R / L A N G U A G E F E A T U R E D E T E C T I O N | ||
| 58 | * | ||
| 59 | * NOTE: The has_ and test_ macros are separate because if the test | ||
| 60 | * expression uses the preprocessor "defined" operator the operand | ||
| 61 | * identifier may be replaced before the expression is evaluated. Most tests | ||
| 62 | * will only use arithmetic operations, but if this is not possible then the | ||
| 63 | * test must be written inline, for example | ||
| 64 | * | ||
| 65 | * #if has_attribute(x) || (!HAVE_C___HAS_ATTRIBUTE && defined FOO) | ||
| 66 | * #define HAVE___ATTRIBUTE___X | ||
| 67 | * #endif | ||
| 68 | * | ||
| 69 | * NOTE: Solaris Studio 12.4 supports __has_attribute, but we must enclose | ||
| 70 | * it in parentheses because the expansion results in a token sequence that | ||
| 71 | * chokes the compiler: __has_attribute(nonnull) becomes | ||
| 72 | * __has_attribute__ (nonnull), with a literal space between the preprocessor | ||
| 73 | * identifier and the open parenthesis. | ||
| 74 | * | ||
| 75 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 76 | |||
| 77 | #if defined __has_attribute | ||
| 78 | #define ag_has_attribute(a) __has_attribute(a) | ||
| 79 | #define ag_test_attribute(a, E) (ag_has_attribute(a)) | ||
| 80 | #else | ||
| 81 | #define ag_has_attribute(a) 0 | ||
| 82 | #define ag_test_attribute(a, E) (E) | ||
| 83 | #endif | ||
| 84 | |||
| 85 | #if defined __has_extension | ||
| 86 | #define ag_has_extension(x) __has_extension(x) | ||
| 87 | #define ag_test_extension(x, E) (ag_has_extension(x)) | ||
| 88 | #else | ||
| 89 | #define ag_has_extension(x) 0 | ||
| 90 | #define ag_test_extension(x, E) (E) | ||
| 91 | #endif | ||
| 92 | |||
| 93 | #if defined __has_include | ||
| 94 | #define ag_has_include(p) __has_include(p) | ||
| 95 | #define ag_test_include(p, E) (ag_has_include(p)) | ||
| 96 | #else | ||
| 97 | #define ag_has_include(p) 0 | ||
| 98 | #define ag_test_include(p, E) (E) | ||
| 99 | #endif | ||
| 100 | |||
| 101 | #if defined __has_builtin | ||
| 102 | #define ag_has_builtin(f) __has_builtin(f) | ||
| 103 | #define ag_test_builtin(f, E) (ag_has_builtin(f)) | ||
| 104 | #else | ||
| 105 | #define ag_has_builtin(f) 0 | ||
| 106 | #define ag_test_builtin(f, E) (E) | ||
| 107 | #endif | ||
| 108 | |||
| 109 | #ifndef HAVE_C___ATTRIBUTE__ | ||
| 110 | #define HAVE_C___ATTRIBUTE__ (__GNUC__ || AG_SUNPRO_PREREQ(5,9,0)) | ||
| 111 | #endif | ||
| 112 | |||
| 113 | #ifndef HAVE_C___ATTRIBUTE___CONSTRUCTOR | ||
| 114 | #define HAVE_C___ATTRIBUTE___CONSTRUCTOR ag_test_attribute(constructor, __GNUC__) | ||
| 115 | #endif | ||
| 116 | |||
| 117 | #ifndef HAVE_C___ATTRIBUTE___NONNULL | ||
| 118 | #define HAVE_C___ATTRIBUTE___NONNULL ag_test_attribute(nonnull, AG_GNUC_PREREQ(3,3,1)) | ||
| 119 | #endif | ||
| 120 | |||
| 121 | #ifndef HAVE_C___ATTRIBUTE___UNUSED | ||
| 122 | #define HAVE_C___ATTRIBUTE___UNUSED ag_test_attribute(unused, __GNUC__) | ||
| 123 | #endif | ||
| 124 | |||
| 125 | #ifndef HAVE_C___ATTRIBUTE___USED | ||
| 126 | #define HAVE_C___ATTRIBUTE___USED ag_test_attribute(used, __GNUC__) | ||
| 127 | #endif | ||
| 128 | |||
| 129 | #ifndef HAVE_C___ATTRIBUTE___VISIBILITY | ||
| 130 | #define HAVE_C___ATTRIBUTE___VISIBILITY ag_test_attribute(visibility, __GNUC__) | ||
| 131 | #endif | ||
| 132 | |||
| 133 | #ifndef HAVE_C___HAS_EXTENSION | ||
| 134 | #define HAVE_C___HAS_EXTENSION (defined __has_extension) | ||
| 135 | #endif | ||
| 136 | |||
| 137 | #ifndef HAVE_C___HAS_INCLUDE | ||
| 138 | #define HAVE_C___HAS_INCLUDE (defined __has_include) | ||
| 139 | #endif | ||
| 140 | |||
| 141 | #ifndef HAVE_C___EXTENSION__ | ||
| 142 | #define HAVE_C___EXTENSION__ (__GNUC__) | ||
| 143 | #endif | ||
| 144 | |||
| 145 | #ifndef HAVE_C___TYPEOF | ||
| 146 | #define HAVE_C___TYPEOF (_MSC_VER || __GNUC__ || AG_SUNPRO_PREREQ(5,9,0)) | ||
| 147 | #endif | ||
| 148 | |||
| 149 | #ifndef HAVE_C___TYPEOF__ | ||
| 150 | #define HAVE_C___TYPEOF__ (__GNUC__ || __xlc__ || AG_SUNPRO_PREREQ(5,9,0)) | ||
| 151 | #endif | ||
| 152 | |||
| 153 | #ifndef HAVE_C__GENERIC | ||
| 154 | #define HAVE_C__GENERIC ag_test_extension(c_generic_selections, (AG_GNUC_PREREQ(4,9,0) || __STDC_VERSION__ >= 201112L)) | ||
| 155 | #endif | ||
| 156 | |||
| 157 | #ifndef HAVE_C_STATEMENT_EXPRESSION | ||
| 158 | #define HAVE_C_STATEMENT_EXPRESSION (__GNUC__ || AG_SUNPRO_PREREQ(5,9,0)) | ||
| 159 | #endif | ||
| 160 | |||
| 161 | #ifndef HAVE_C_TYPEOF | ||
| 162 | #define HAVE_C_TYPEOF (__GNUC__ || __xlc__ || AG_SUNPRO_PREREQ(5,9,0)) | ||
| 163 | #endif | ||
| 164 | |||
| 165 | #ifndef HAVE___ATOMIC_FETCH_ADD | ||
| 166 | #define HAVE___ATOMIC_FETCH_ADD (defined __ATOMIC_RELAXED) | ||
| 167 | #endif | ||
| 168 | |||
| 169 | #ifndef HAVE___ATOMIC_FETCH_SUB | ||
| 170 | #define HAVE___ATOMIC_FETCH_SUB HAVE___ATOMIC_FETCH_ADD | ||
| 171 | #endif | ||
| 172 | |||
| 173 | #ifndef HAVE___BUILTIN_CHOOSE_EXPR | ||
| 174 | #define HAVE___BUILTIN_CHOOSE_EXPR (AG_GNUC_PREREQ(3,1,1) || __clang__) | ||
| 175 | #endif | ||
| 176 | |||
| 177 | #ifndef HAVE___BUILTIN_EXPECT | ||
| 178 | #define HAVE___BUILTIN_EXPECT ag_test_builtin(__builtin_expect, __GNUC__) | ||
| 179 | #endif | ||
| 180 | |||
| 181 | #ifndef HAVE___BUILTIN_NAN | ||
| 182 | #define HAVE___BUILTIN_NAN ag_test_builtin(__builtin_nan, AG_GNUC_PREREQ(3,3,1)) | ||
| 183 | #endif | ||
| 184 | |||
| 185 | #ifndef HAVE___BUILTIN_TRAP | ||
| 186 | #define HAVE___BUILTIN_TRAP ag_test_builtin(__builtin_trap, AG_GNUC_PREREQ(3,3,1)) | ||
| 187 | #endif | ||
| 188 | |||
| 189 | #ifndef HAVE___BUILTIN_TYPES_COMPATIBLE_P | ||
| 190 | #define HAVE___BUILTIN_TYPES_COMPATIBLE_P (AG_GNUC_PREREQ(3,1,1) || __clang__) | ||
| 191 | #endif | ||
| 192 | |||
| 193 | #ifndef HAVE___BUILTIN_UNREACHABLE | ||
| 194 | #define HAVE___BUILTIN_UNREACHABLE ag_test_builtin(__builtin_unreachable, AG_GNUC_PREREQ(4,5,0)) | ||
| 195 | #endif | ||
| 196 | |||
| 197 | #ifndef HAVE__STATIC_ASSERT | ||
| 198 | #define HAVE__STATIC_ASSERT ag_test_extension(c_static_assert, (AG_GNUC_PREREQ(4,6,0) || __C11FEATURES__ || __STDC_VERSION__ >= 201112L)) | ||
| 199 | #endif | ||
| 200 | |||
| 201 | |||
| 202 | /* | ||
| 203 | * S Y S T E M E X T E N S I O N S | ||
| 204 | * | ||
| 205 | * We must set these before including any headers for feature detection. | ||
| 206 | * | ||
| 207 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 208 | |||
| 209 | #if AG_USE_SYSTEM_EXTENSIONS | ||
| 210 | |||
| 211 | /* Solaris */ | ||
| 212 | #ifndef __EXTENSIONS__ | ||
| 213 | #define __EXTENSIONS__ 1 | ||
| 214 | #endif | ||
| 215 | |||
| 216 | /* AIX */ | ||
| 217 | #ifndef _ALL_SOURCE | ||
| 218 | #define _ALL_SOURCE 1 | ||
| 219 | #endif | ||
| 220 | |||
| 221 | #ifndef _GNU_SOURCE | ||
| 222 | #define _GNU_SOURCE 1 | ||
| 223 | #endif | ||
| 224 | |||
| 225 | #ifndef _MINIX | ||
| 226 | #define _MINIX 1 | ||
| 227 | #endif | ||
| 228 | |||
| 229 | /* Solaris */ | ||
| 230 | #ifndef _POSIX_PTHREAD_SEMANTICS | ||
| 231 | #define _POSIX_PTHREAD_SEMANTICS 1 | ||
| 232 | #endif | ||
| 233 | |||
| 234 | #endif /* AG_USE_SYSTEM_EXTENSIONS */ | ||
| 235 | |||
| 236 | #if AG_SYS_LARGEFILE | ||
| 237 | |||
| 238 | /* NOTE: BSDs and musl-libc always provide a 64-bit file API */ | ||
| 239 | |||
| 240 | /* Apple */ | ||
| 241 | #ifndef _DARWIN_USE_64_BIT_INODE | ||
| 242 | #define _DARWIN_USE_64_BIT_INODE 1 | ||
| 243 | #endif | ||
| 244 | |||
| 245 | /* Solaris and glibc (per Large File Summit recommendation) */ | ||
| 246 | #ifndef _FILE_OFFSET_BITS | ||
| 247 | #define _FILE_OFFSET_BITS 64 | ||
| 248 | #endif | ||
| 249 | |||
| 250 | /* AIX */ | ||
| 251 | #ifndef _LARGE_FILES | ||
| 252 | #define _LARGE_FILES 1 | ||
| 253 | #endif | ||
| 254 | |||
| 255 | #endif /* AG_SYS_LARGEFILE */ | ||
| 256 | |||
| 257 | |||
| 258 | /* | ||
| 259 | * S Y S T E M D E T E C T I O N (S T A G E 0) | ||
| 260 | * | ||
| 261 | * Define HAVE_FOO macros as arithmetic truth values for any predefined | ||
| 262 | * system macros which have truth values solely based on whether they're | ||
| 263 | * defined. | ||
| 264 | * | ||
| 265 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 266 | |||
| 267 | /* NOTE: None so far. See stage 3 below. */ | ||
| 268 | |||
| 269 | |||
| 270 | /* | ||
| 271 | * S Y S T E M D E T E C T I O N (S T A G E 1) | ||
| 272 | * | ||
| 273 | * Include any headers necessary for minimal libc feature checking, defining | ||
| 274 | * any prerequisite feature macros. | ||
| 275 | * | ||
| 276 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 277 | |||
| 278 | /* | ||
| 279 | * NOTE: <limits.h> will indirectly include <features.h>, <standards.h>, | ||
| 280 | * <sys/cdefs.h>, <sys/feature_tests.h>, <sys/featuretest.h>, and similar | ||
| 281 | * system headers which define most of what we care about. Among the typical | ||
| 282 | * feature macros, we also get _DTRACE_VERSION. | ||
| 283 | */ | ||
| 284 | #include <limits.h> | ||
| 285 | |||
| 286 | #ifndef AG_MUSL_MAYBE | ||
| 287 | #define AG_MUSL_MAYBE (__linux__ && !__GLIBC__ && !__BIONIC__) | ||
| 288 | #endif | ||
| 289 | |||
| 290 | #ifndef HAVE_SYS_PARAM_H | ||
| 291 | #define HAVE_SYS_PARAM_H ag_test_include(<sys/param.h>, !AG_MUSL_MAYBE) | ||
| 292 | #endif | ||
| 293 | |||
| 294 | /* | ||
| 295 | * NOTE: Conditionally load <sys/param.h> so we don't unnecessarily pollute | ||
| 296 | * the namespace. | ||
| 297 | */ | ||
| 298 | #if HAVE_SYS_PARAM_H && !__linux__ && !__sun && !_AIX | ||
| 299 | #include <sys/param.h> /* __FreeBSD_version __NetBSD_Prereq__ BSD OpenBSD */ | ||
| 300 | #endif | ||
| 301 | |||
| 302 | #include <fcntl.h> /* F_DUPFD_CLOEXEC */ | ||
| 303 | |||
| 304 | |||
| 305 | /* | ||
| 306 | * S Y S T E M D E T E C T I O N (S T A G E 2) | ||
| 307 | * | ||
| 308 | * Macros which determine libc vendor and version. | ||
| 309 | * | ||
| 310 | * See http://sourceforge.net/p/predef/wiki/Libraries/ | ||
| 311 | * | ||
| 312 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 313 | |||
| 314 | #define AG_AIX_PREREQ(M, m) (_AIX # M # m) | ||
| 315 | |||
| 316 | #if defined __GLIBC_PREREQ && !defined __UCLIBC__ | ||
| 317 | #define AG_GLIBC_PREREQ(M, m) (__GLIBC_PREREQ(M, m)) | ||
| 318 | #else | ||
| 319 | #define AG_GLIBC_PREREQ(M, m) 0 | ||
| 320 | #endif | ||
| 321 | |||
| 322 | #define AG_FREEBSD_2VER(M, m, p) (((M) * 100000) + ((m) * 1000) + (p)) | ||
| 323 | #define AG_FREEBSD_PREREQ(M, m, p) (__FreeBSD__ > 0 && __FreeBSD_version >= AG_FREEBSD_2VER((M), (m), (p))) | ||
| 324 | |||
| 325 | #define AG_IPHONE_2VER(M, m) (((M) * 10000) + ((m) * 100)) | ||
| 326 | #if defined __IPHONE_OS_VERSION_MIN_REQUIRED | ||
| 327 | #define AG_IPHONE_PREREQ(M, m) (AG_IPHONE_2VER((M), (m)) <= __IPHONE_OS_VERSION_MIN_REQUIRED) | ||
| 328 | #else | ||
| 329 | #define AG_IPHONE_PREREQ(M, m) 0 | ||
| 330 | #endif | ||
| 331 | |||
| 332 | #if defined __NetBSD_Prereq__ | ||
| 333 | #define AG_NETBSD_PREREQ(M, m, p) (!__minix && __NetBSD_Prereq__(M, m, p)) | ||
| 334 | #else | ||
| 335 | #define AG_NETBSD_PREREQ(M, m, p) 0 | ||
| 336 | #endif | ||
| 337 | |||
| 338 | #define AG_MACOS_2VER_10_9(M, m, p) (((M) * 100) + ((m) * 10)) | ||
| 339 | #define AG_MACOS_2VER_10_10(M, m, p) (((M) * 10000) + ((m) * 100) + (p)) | ||
| 340 | #define AG_MACOS_PREREQ_10_10(M, m, p) (((M) > 10 || ((M) == 10 && (m) >= 10)) && AG_MACOS_2VER_10_10((M), (m), (p)) <= __MAC_OS_X_VERSION_MIN_REQUIRED) | ||
| 341 | #define AG_MACOS_PREREQ_10_9(M, m, p) (((M) == 10 && (m) < 10) && AG_MACOS_2VER_10_9((M), (m), (p)) <= __MAC_OS_X_VERSION_MIN_REQUIRED) | ||
| 342 | #if defined __MAC_OS_X_VERSION_MIN_REQUIRED | ||
| 343 | #define AG_MACOS_PREREQ(M, m, p) (AG_MACOS_PREREQ_10_10((M), (m), (p)) || AG_MACOS_PREREQ_10_9((M), (m), (p))) | ||
| 344 | #else | ||
| 345 | #define AG_MACOS_PREREQ(M, m, p) 0 | ||
| 346 | #endif | ||
| 347 | |||
| 348 | #define AG_OPENBSD_PREREQ_0_0 (__OpenBSD__) | ||
| 349 | #define AG_OPENBSD_PREREQ_5_5 (OpenBSD >= 201405) | ||
| 350 | #define AG_OPENBSD_PREREQ_5_7 (OpenBSD >= 201505) | ||
| 351 | #define AG_OPENBSD_PREREQ(M, m) (AG_OPENBSD_PREREQ_ ## M ## _ ## m) | ||
| 352 | |||
| 353 | #define AG_SUNOS_PREREQ_5_10 (__sun && _DTRACE_VERSION) | ||
| 354 | #define AG_SUNOS_PREREQ_5_11 (__sun && F_DUPFD_CLOEXEC) | ||
| 355 | #define AG_SUNOS_PREREQ(M, m) (AG_SUNOS_PREREQ_ ## M ## _ ## m) | ||
| 356 | |||
| 357 | #define AG_UCLIBC_2VER(M, m, p) (((M) * 10000) + ((m) * 100) + (p)) | ||
| 358 | #if defined __UCLIBC__ | ||
| 359 | #define AG_UCLIBC_PREREQ(M, m, p) (AG_UCLIBC_2VER(__UCLIBC_MAJOR__, __UCLIBC_MINOR__, __UCLIBC_SUBLEVEL__) >= AG_UCLIBC_2VER((M), (m), (p))) | ||
| 360 | #else | ||
| 361 | #define AG_UCLIBC_PREREQ(M, m, p) 0 | ||
| 362 | #endif | ||
| 363 | |||
| 364 | |||
| 365 | /* | ||
| 366 | * S Y S T E M D E T E C T I O N (S T A G E 3) | ||
| 367 | * | ||
| 368 | * Define HAVE_FOO macros as arithmetic truth values for any system macros | ||
| 369 | * which have a truth value solely based on whether they're defined. | ||
| 370 | * | ||
| 371 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 372 | |||
| 373 | #ifndef HAVE___EXTENSIONS__ | ||
| 374 | #ifdef __EXTENSIONS__ | ||
| 375 | #define HAVE___EXTENSIONS__ 1 | ||
| 376 | #endif | ||
| 377 | #endif | ||
| 378 | |||
| 379 | #ifndef HAVE__ALL_SOURCE | ||
| 380 | #ifdef _ALL_SOURCE | ||
| 381 | #define HAVE__ALL_SOURCE 1 | ||
| 382 | #endif | ||
| 383 | #endif | ||
| 384 | |||
| 385 | #ifndef HAVE__GNU_SOURCE | ||
| 386 | #ifdef _GNU_SOURCE | ||
| 387 | #define HAVE__GNU_SOURCE 1 | ||
| 388 | #endif | ||
| 389 | #endif | ||
| 390 | |||
| 391 | #ifndef HAVE__MINIX | ||
| 392 | #if defined _MINIX || (defined __minix && defined _NETBSD_SOURCE) | ||
| 393 | #define HAVE__MINIX 1 | ||
| 394 | #endif | ||
| 395 | #endif | ||
| 396 | |||
| 397 | #ifndef HAVE__POSIX_PTHREAD_SEMANTICS | ||
| 398 | #ifdef _POSIX_PTHREAD_SEMANTICS | ||
| 399 | #define HAVE__POSIX_PTHREAD_SEMANTICS 1 | ||
| 400 | #endif | ||
| 401 | #endif | ||
| 402 | |||
| 403 | #ifndef HAVE__REENTRANT | ||
| 404 | #ifdef _REENTRANT | ||
| 405 | #define HAVE__REENTRANT 1 | ||
| 406 | #endif | ||
| 407 | #endif | ||
| 408 | |||
| 409 | |||
| 410 | /* | ||
| 411 | * H E A D E R D E T E C T I O N | ||
| 412 | * | ||
| 413 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 414 | |||
| 415 | #ifndef HAVE_DLFCN_H | ||
| 416 | #define HAVE_DLFCN_H ag_test_include(<dlfcn.h>, 1) | ||
| 417 | #endif | ||
| 418 | |||
| 419 | #ifndef HAVE_IFADDRS_H | ||
| 420 | #define HAVE_IFADDRS_H_ (!_AIX && (!__sun || AG_SUNOS_PREREQ(5,11))) | ||
| 421 | #define HAVE_IFADDRS_H ag_test_include(<ifaddrs.h>, HAVE_IFADDRS_H_) | ||
| 422 | #endif | ||
| 423 | |||
| 424 | #ifndef HAVE_INTTYPES_H | ||
| 425 | #define HAVE_INTTYPES_H 1 | ||
| 426 | #endif | ||
| 427 | |||
| 428 | #ifndef HAVE_MACH_CLOCK_H | ||
| 429 | #define HAVE_MACH_CLOCK_H ag_test_include(<mach/clock.h>, __APPLE__) | ||
| 430 | #endif | ||
| 431 | |||
| 432 | #ifndef HAVE_MACH_MACH_H | ||
| 433 | #define HAVE_MACH_MACH_H ag_test_include(<mach/mach.h>, __APPLE__) | ||
| 434 | #endif | ||
| 435 | |||
| 436 | #ifndef HAVE_MACH_MACH_TIME_H | ||
| 437 | #define HAVE_MACH_MACH_TIME_H ag_test_include(<mach/mach_time.h>, __APPLE__) | ||
| 438 | #endif | ||
| 439 | |||
| 440 | #ifndef HAVE_MEMORY_H | ||
| 441 | #define HAVE_MEMORY_H 1 | ||
| 442 | #endif | ||
| 443 | |||
| 444 | #ifndef HAVE_PORT_H | ||
| 445 | #define HAVE_PORT_H ag_test_include(<port.h>, AG_SUNOS_PREREQ(5,10)) | ||
| 446 | #endif | ||
| 447 | |||
| 448 | /* TODO: Maybe test _POSIX_THREADS from <unistd.h>. */ | ||
| 449 | #ifndef HAVE_PTHREAD_H | ||
| 450 | #define HAVE_PTHREAD_H ag_test_include(<pthread.h>, !__minix) | ||
| 451 | #endif | ||
| 452 | |||
| 453 | #ifndef HAVE_STDINT_H | ||
| 454 | #define HAVE_STDINT_H 1 | ||
| 455 | #endif | ||
| 456 | |||
| 457 | #ifndef HAVE_STDLIB_H | ||
| 458 | #define HAVE_STDLIB_H 1 | ||
| 459 | #endif | ||
| 460 | |||
| 461 | #ifndef HAVE_STRING_H | ||
| 462 | #define HAVE_STRING_H 1 | ||
| 463 | #endif | ||
| 464 | |||
| 465 | #ifndef HAVE_STRINGS_H | ||
| 466 | #define HAVE_STRINGS_H 1 | ||
| 467 | #endif | ||
| 468 | |||
| 469 | #ifndef HAVE_SYS_AUXV_H | ||
| 470 | #define HAVE_SYS_AUXV_H_ (AG_GLIBC_PREREQ(2,16) || (!AG_GLIBC_PREREQ(0,0) && __linux__) || __sun) | ||
| 471 | #define HAVE_SYS_AUXV_H ag_test_include(<sys/auxv.h>, HAVE_SYS_AUXV_H_) | ||
| 472 | #endif | ||
| 473 | |||
| 474 | #ifndef HAVE_SYS_EPOLL_H | ||
| 475 | #define HAVE_SYS_EPOLL_H ag_test_include(<sys/epoll.h>, __linux__) | ||
| 476 | #endif | ||
| 477 | |||
| 478 | #ifndef HAVE_SYS_EVENT_H | ||
| 479 | #define HAVE_SYS_EVENT_H ag_test_include(<sys/event.h>, BSD) | ||
| 480 | #endif | ||
| 481 | |||
| 482 | #ifndef HAVE_SYS_EVENTFD_H | ||
| 483 | #define HAVE_SYS_EVENTFD_H_ (AG_GLIBC_PREREQ(2,8) || (!AG_GLIBC_PREREQ(0,0) && __linux__) || defined EFD_CLOEXEC) | ||
| 484 | #define HAVE_SYS_EVENTFD_H ag_test_include(<sys/eventfd.h>, HAVE_SYS_EVENTFD_H_) | ||
| 485 | #endif | ||
| 486 | |||
| 487 | #ifndef HAVE_SYS_INOTIFY_H | ||
| 488 | #define HAVE_SYS_INOTIFY_H ag_test_include(<sys/inotify.h>, __linux__) | ||
| 489 | #endif | ||
| 490 | |||
| 491 | #ifndef HAVE_SYS_SIGNALFD_H | ||
| 492 | #define HAVE_SYS_SIGNALFD_H_ (AG_GLIBC_PREREQ(2,8) || (!AG_GLIBC_PREREQ(0,0) && __linux__) || defined SFD_CLOEXEC) | ||
| 493 | #define HAVE_SYS_SIGNALFD_H ag_test_include(<sys/signalfd.h>, HAVE_SYS_SIGNALFD_H_) | ||
| 494 | #endif | ||
| 495 | |||
| 496 | #ifndef HAVE_SYS_SOCKIO_H | ||
| 497 | #define HAVE_SYS_SOCKIO_H ag_test_include(<sys/sockio.h>, (__sun || BSD)) | ||
| 498 | #endif | ||
| 499 | |||
| 500 | #ifndef HAVE_SYS_STAT_H | ||
| 501 | #define HAVE_SYS_STAT_H 1 | ||
| 502 | #endif | ||
| 503 | |||
| 504 | #ifndef HAVE_SYS_SYSCALL_H | ||
| 505 | #define HAVE_SYS_SYSCALL_H_ (BSD || __linux__ || __sun) | ||
| 506 | #define HAVE_SYS_SYSCALL_H ag_test_include(<sys/syscall.h>, HAVE_SYS_SYSCALL_H_) | ||
| 507 | #endif | ||
| 508 | |||
| 509 | #ifndef HAVE_SYS_SYSCTL_H | ||
| 510 | #define HAVE_SYS_SYSCTL_H ag_test_include(<sys/sysctl.h>, (BSD || __GLIBC__)) | ||
| 511 | #endif | ||
| 512 | |||
| 513 | #ifndef HAVE_SYS_TIMERFD_H | ||
| 514 | #define HAVE_SYS_TIMERFD_H_ (AG_GLIBC_PREREQ(2,8) || (!AG_GLIBC_PREREQ(0,0) && __linux__) || defined TFD_CLOEXEC) | ||
| 515 | #define HAVE_SYS_TIMERFD_H ag_test_include(<sys/timerfd.h>, HAVE_SYS_TIMERFD_H_) | ||
| 516 | #endif | ||
| 517 | |||
| 518 | #ifndef HAVE_SYS_TYPES_H | ||
| 519 | #define HAVE_SYS_TYPES_H 1 | ||
| 520 | #endif | ||
| 521 | |||
| 522 | #ifndef HAVE_UNISTD_H | ||
| 523 | #define HAVE_UNISTD_H 1 | ||
| 524 | #endif | ||
| 525 | |||
| 526 | |||
| 527 | /* | ||
| 528 | * T Y P E D E T E C T I O N | ||
| 529 | * | ||
| 530 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 531 | |||
| 532 | #ifndef HAVE_CLOCKID_T | ||
| 533 | #define HAVE_CLOCKID_T (defined CLOCK_MONOTONIC) | ||
| 534 | #endif | ||
| 535 | |||
| 536 | #ifndef HAVE_STRUCT_SOCKADDR_SA_LEN | ||
| 537 | #define HAVE_STRUCT_SOCKADDR_SA_LEN (!__linux__ && !__sun) | ||
| 538 | #endif | ||
| 539 | |||
| 540 | #ifndef HAVE_STRUCT_STAT_ST_ATIM | ||
| 541 | #define HAVE_STRUCT_STAT_ST_ATIM (defined st_atime && ((!__APPLE__ && (!__NetBSD__ || AG_NETBSD_PREREQ(7,0,0))) || !HAVE_STRUCT_STAT_ST_ATIMESPEC)) | ||
| 542 | #endif | ||
| 543 | |||
| 544 | #ifndef HAVE_STRUCT_STAT_ST_CTIM | ||
| 545 | #define HAVE_STRUCT_STAT_ST_CTIM HAVE_STRUCT_STAT_ST_ATIM | ||
| 546 | #endif | ||
| 547 | |||
| 548 | #ifndef HAVE_STRUCT_STAT_ST_MTIM | ||
| 549 | #define HAVE_STRUCT_STAT_ST_MTIM HAVE_STRUCT_STAT_ST_ATIM | ||
| 550 | #endif | ||
| 551 | |||
| 552 | #ifndef HAVE_STRUCT_STAT_ST_ATIMESPEC | ||
| 553 | #define HAVE_STRUCT_STAT_ST_ATIMESPEC (__APPLE__ || defined st_atimespec || defined st_atimensec) | ||
| 554 | #endif | ||
| 555 | |||
| 556 | #ifndef HAVE_STRUCT_STAT_ST_CTIMESPEC | ||
| 557 | #define HAVE_STRUCT_STAT_ST_CTIMESPEC HAVE_STRUCT_STAT_ST_ATIMESPEC | ||
| 558 | #endif | ||
| 559 | |||
| 560 | #ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC | ||
| 561 | #define HAVE_STRUCT_STAT_ST_MTIMESPEC HAVE_STRUCT_STAT_ST_ATIMESPEC | ||
| 562 | #endif | ||
| 563 | |||
| 564 | #ifndef HAVE_STRUCT_STAT_ST_BLOCKS | ||
| 565 | #define HAVE_STRUCT_STAT_ST_BLOCKS 1 | ||
| 566 | #endif | ||
| 567 | |||
| 568 | #ifndef HAVE_STRUCT_STAT_ST_BLKSIZE | ||
| 569 | #define HAVE_STRUCT_STAT_ST_BLKSIZE 1 | ||
| 570 | #endif | ||
| 571 | |||
| 572 | #ifndef HAVE_STRUCT_STAT_ST_RDEV | ||
| 573 | #define HAVE_STRUCT_STAT_ST_RDEV 1 | ||
| 574 | #endif | ||
| 575 | |||
| 576 | |||
| 577 | /* | ||
| 578 | * D E C L A R A T I O N D E T E C T I O N | ||
| 579 | * | ||
| 580 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 581 | |||
| 582 | #ifndef HAVE___DECL_LIBC_ENABLE_SECURE | ||
| 583 | #define HAVE___DECL_LIBC_ENABLE_SECURE 0 | ||
| 584 | #endif | ||
| 585 | |||
| 586 | #ifndef HAVE_DECL_CLOCK_GETTIME | ||
| 587 | #define HAVE_DECL_CLOCK_GETTIME HAVE_DECL_CLOCK_MONOTONIC | ||
| 588 | #endif | ||
| 589 | |||
| 590 | #ifndef HAVE_DECL_CLOCK_MONOTONIC | ||
| 591 | #define HAVE_DECL_CLOCK_MONOTONIC (defined CLOCK_MONOTONIC) | ||
| 592 | #endif | ||
| 593 | |||
| 594 | #ifndef HAVE_DECL_CLOCK_REALTIME | ||
| 595 | #define HAVE_DECL_CLOCK_REALTIME (defined CLOCK_REALTIME) | ||
| 596 | #endif | ||
| 597 | |||
| 598 | #ifndef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME | ||
| 599 | #define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME (__linux__ && HAVE__GNU_SOURCE) | ||
| 600 | #endif | ||
| 601 | |||
| 602 | #ifndef HAVE_DECL_PTHREAD_MUTEX_ROBUST | ||
| 603 | #define HAVE_DECL_PTHREAD_MUTEX_ROBUST (defined PTHREAD_MUTEX_ROBUST || AG_GLIBC_PREREQ(2,12)) | ||
| 604 | #endif | ||
| 605 | |||
| 606 | #ifndef HAVE_DECL_RANDOM_UUID | ||
| 607 | #define HAVE_DECL_RANDOM_UUID (HAVE_SYS_SYSCTL_H && defined __linux__) /* RANDOM_UUID is an enum, not macro */ | ||
| 608 | #endif | ||
| 609 | |||
| 610 | #ifndef HAVE_DECL_STRERROR_R | ||
| 611 | #define HAVE_DECL_STRERROR_R 1 | ||
| 612 | #endif | ||
| 613 | |||
| 614 | #ifndef HAVE_DECL_SYS_SIGLIST | ||
| 615 | #define HAVE_DECL_SYS_SIGLIST (!AG_MUSL_MAYBE && !__sun && !_AIX) | ||
| 616 | #endif | ||
| 617 | |||
| 618 | #ifndef HAVE_DECL_SYS_GETRANDOM | ||
| 619 | #define HAVE_DECL_SYS_GETRANDOM (defined SYS_getrandom) | ||
| 620 | #endif | ||
| 621 | |||
| 622 | |||
| 623 | /* | ||
| 624 | * V A R I A B L E D E T E C T I O N | ||
| 625 | * | ||
| 626 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 627 | |||
| 628 | #ifndef HAVE___LIBC_ENABLE_SECURE | ||
| 629 | #define HAVE___LIBC_ENABLE_SECURE AG_GLIBC_PREREQ(2,1) /* added to glibc between 2.0.98 and 2.0.99 */ | ||
| 630 | #endif | ||
| 631 | |||
| 632 | #ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME | ||
| 633 | #define HAVE_PROGRAM_INVOCATION_SHORT_NAME (__linux__) | ||
| 634 | #endif | ||
| 635 | |||
| 636 | #ifndef HAVE_SYS_SIGLIST | ||
| 637 | #define HAVE_SYS_SIGLIST HAVE_DECL_SYS_SIGLIST | ||
| 638 | #endif | ||
| 639 | |||
| 640 | |||
| 641 | /* | ||
| 642 | * F U N C T I O N D E T E C T I O N | ||
| 643 | * | ||
| 644 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
| 645 | |||
| 646 | #ifndef HAVE_ACCEPT4 | ||
| 647 | #define HAVE_ACCEPT4 (defined SOCK_CLOEXEC && !__NetBSD__) | ||
| 648 | #endif | ||
| 649 | |||
| 650 | #ifndef HAVE_ARC4RANDOM | ||
| 651 | #define HAVE_ARC4RANDOM \ | ||
| 652 | (__APPLE__ || __DragonFly__ || __FreeBSD__ || __NetBSD__ || \ | ||
| 653 | __OpenBSD__ || __minix) | ||
| 654 | #endif | ||
| 655 | |||
| 656 | #ifndef HAVE_ARC4RANDOM_ADDRANDOM | ||
| 657 | #define HAVE_ARC4RANDOM_ADDRANDOM (HAVE_ARC4RANDOM && !AG_OPENBSD_PREREQ(5,5)) | ||
| 658 | #endif | ||
| 659 | |||
| 660 | #ifndef HAVE_ARC4RANDOM_STIR | ||
| 661 | #define HAVE_ARC4RANDOM_STIR HAVE_ARC4RANDOM_ADDRANDOM | ||
| 662 | #endif | ||
| 663 | |||
| 664 | #ifndef HAVE_CLOCK_GETTIME | ||
| 665 | #define HAVE_CLOCK_GETTIME (!__APPLE__ || AG_MACOS_PREREQ(10,12,0)) | ||
| 666 | #endif | ||
| 667 | |||
| 668 | #ifndef HAVE_DLADDR | ||
| 669 | #define HAVE_DLADDR (HAVE_DLOPEN && !_AIX && ((!__GLIBC__ && !AG_MUSL_MAYBE) || HAVE__GNU_SOURCE)) | ||
| 670 | #endif | ||
| 671 | |||
| 672 | #ifndef HAVE_DLOPEN | ||
| 673 | #define HAVE_DLOPEN HAVE_DLFCN_H | ||
| 674 | #endif | ||
| 675 | |||
| 676 | #ifndef HAVE_DLSYM | ||
| 677 | #define HAVE_DLSYM HAVE_DLOPEN | ||
| 678 | #endif | ||
| 679 | |||
| 680 | #ifndef HAVE_DUP2 | ||
| 681 | #define HAVE_DUP2 1 | ||
| 682 | #endif | ||
| 683 | |||
| 684 | #ifndef HAVE_DUP3 | ||
| 685 | #define HAVE_DUP3 (AG_GLIBC_PREREQ(2,9) || AG_FREEBSD_PREREQ(10,0,0) || AG_NETBSD_PREREQ(6,0,0) || AG_UCLIBC_PREREQ(0,9,34) || AG_MUSL_MAYBE || __BIONIC__ || AG_OPENBSD_PREREQ(5,7)) | ||
| 686 | #endif | ||
| 687 | |||
| 688 | #ifndef HAVE_FDOPENDIR | ||
| 689 | #define HAVE_FDOPENDIR ( \ | ||
| 690 | (!__APPLE__ || AG_MACOS_PREREQ(10,10,0) || AG_IPHONE_PREREQ(8,0)) \ | ||
| 691 | && (!__NetBSD__ || AG_NETBSD_PREREQ(6,0,0)) \ | ||
| 692 | ) | ||
| 693 | #endif | ||
| 694 | |||
| 695 | #ifndef HAVE_EPOLL_CREATE | ||
| 696 | #define HAVE_EPOLL_CREATE HAVE_SYS_EPOLL_H | ||
| 697 | #endif | ||
| 698 | |||
| 699 | #if HAVE_SYS_EPOLL_H | ||
| 700 | #include <sys/epoll.h> | ||
| 701 | #endif | ||
| 702 | |||
| 703 | #ifndef HAVE_EPOLL_CREATE1 | ||
| 704 | #define HAVE_EPOLL_CREATE1 (HAVE_EPOLL_CREATE && (defined EPOLL_CLOEXEC || AG_GLIBC_PREREQ(2,9))) | ||
| 705 | #endif | ||
| 706 | |||
| 707 | #ifndef HAVE_EPOLL_CTL | ||
| 708 | #define HAVE_EPOLL_CTL HAVE_EPOLL_CREATE | ||
| 709 | #endif | ||
| 710 | |||
| 711 | #ifndef HAVE_EPOLL_PWAIT | ||
| 712 | #define HAVE_EPOLL_PWAIT (HAVE_EPOLL_WAIT && (AG_GLIBC_PREREQ(2,6) || (!AG_GLIBC_PREREQ(0,0) && defined EPOLL_CLOEXEC))) | ||
| 713 | #endif | ||
| 714 | |||
| 715 | #ifndef HAVE_EPOLL_WAIT | ||
| 716 | #define HAVE_EPOLL_WAIT HAVE_EPOLL_CREATE | ||
| 717 | #endif | ||
| 718 | |||
| 719 | #ifndef HAVE_EVENTFD | ||
| 720 | #define HAVE_EVENTFD HAVE_SYS_EVENTFD_H | ||
| 721 | #endif | ||
| 722 | |||
| 723 | #ifndef HAVE_GETAUXVAL | ||
| 724 | #define HAVE_GETAUXVAL (HAVE_SYS_AUXV_H && !__sun) | ||
| 725 | #endif | ||
| 726 | |||
| 727 | #ifndef HAVE_GETENV_R | ||
| 728 | #define HAVE_GETENV_R (AG_NETBSD_PREREQ(4,0,0) || __minix) | ||
| 729 | #endif | ||
| 730 | |||
| 731 | #ifndef HAVE_GETEXECNAME | ||
| 732 | #define HAVE_GETEXECNAME (__sun) | ||
| 733 | #endif | ||
| 734 | |||
| 735 | #ifndef HAVE_GETIFADDRS | ||
| 736 | #define HAVE_GETIFADDRS (HAVE_IFADDRS_H && !__sun) | ||
| 737 | #endif | ||
| 738 | |||
| 739 | #ifndef HAVE_GETPROGNAME | ||
| 740 | #define HAVE_GETPROGNAME (HAVE_ARC4RANDOM || AG_SUNOS_PREREQ(5,11)) | ||
| 741 | #endif | ||
| 742 | |||
| 743 | #ifndef HAVE_INOTIFY_INIT | ||
| 744 | #define HAVE_INOTIFY_INIT HAVE_SYS_INOTIFY_H | ||
| 745 | #endif | ||
| 746 | |||
| 747 | #ifndef HAVE_INOTIFY_INIT1 | ||
| 748 | #define HAVE_INOTIFY_INIT1 (HAVE_INOTIFY_INIT && defined IN_CLOEXEC) | ||
| 749 | #endif | ||
| 750 | |||
| 751 | #ifndef HAVE_ISSETUGID | ||
| 752 | #define HAVE_ISSETUGID ((!__linux__ || (AG_MUSL_MAYBE && HAVE__GNU_SOURCE)) && !_AIX) | ||
| 753 | #endif | ||
| 754 | |||
| 755 | #if HAVE_SYS_EVENT_H | ||
| 756 | #include <sys/event.h> | ||
| 757 | #endif | ||
| 758 | |||
| 759 | #ifndef HAVE_KEVENT | ||
| 760 | #define HAVE_KEVENT (defined EV_SET) | ||
| 761 | #endif | ||
| 762 | |||
| 763 | #ifndef HAVE_KQUEUE | ||
| 764 | #define HAVE_KQUEUE HAVE_KEVENT | ||
| 765 | #endif | ||
| 766 | |||
| 767 | #ifndef HAVE_KQUEUE1 | ||
| 768 | #define HAVE_KQUEUE1 (HAVE_KQUEUE && AG_NETBSD_PREREQ(6,0,0)) | ||
| 769 | #endif | ||
| 770 | |||
| 771 | #ifndef HAVE_OPENAT | ||
| 772 | #define HAVE_OPENAT \ | ||
| 773 | ((!__APPLE__ || AG_MACOS_PREREQ(10,10,0) || AG_IPHONE_PREREQ(8,0)) \ | ||
| 774 | && (!__NetBSD__ || AG_NETBSD_PREREQ(7,0,0))) | ||
| 775 | #endif | ||
| 776 | |||
| 777 | #ifndef HAVE_PACCEPT | ||
| 778 | #define HAVE_PACCEPT AG_NETBSD_PREREQ(6,0,0) | ||
| 779 | #endif | ||
| 780 | |||
| 781 | #ifndef HAVE_PIPE2 | ||
| 782 | #define HAVE_PIPE2 (AG_GLIBC_PREREQ(2,9) || AG_FREEBSD_PREREQ(10,0,0) || AG_NETBSD_PREREQ(6,0,0) || AG_UCLIBC_PREREQ(0,9,32) || AG_MUSL_MAYBE || __BIONIC__ || AG_OPENBSD_PREREQ(5,7)) | ||
| 783 | #endif | ||
| 784 | |||
| 785 | #ifndef HAVE_PORT_ALERT | ||
| 786 | #define HAVE_PORT_ALERT HAVE_PORT_CREATE | ||
| 787 | #endif | ||
| 788 | |||
| 789 | #ifndef HAVE_PORT_ASSOCIATE | ||
| 790 | #define HAVE_PORT_ASSOCIATE HAVE_PORT_CREATE | ||
| 791 | #endif | ||
| 792 | |||
| 793 | #ifndef HAVE_PORT_CREATE | ||
| 794 | #define HAVE_PORT_CREATE HAVE_PORT_H | ||
| 795 | #endif | ||
| 796 | |||
| 797 | #ifndef HAVE_PORT_DISSOCIATE | ||
| 798 | #define HAVE_PORT_DISSOCIATE HAVE_PORT_CREATE | ||
| 799 | #endif | ||
| 800 | |||
| 801 | #ifndef HAVE_PORT_GET | ||
| 802 | #define HAVE_PORT_GET HAVE_PORT_CREATE | ||
| 803 | #endif | ||
| 804 | |||
| 805 | #ifndef HAVE_PORT_GETN | ||
| 806 | #define HAVE_PORT_GETN HAVE_PORT_CREATE | ||
| 807 | #endif | ||
| 808 | |||
| 809 | #ifndef HAVE_PORT_SEND | ||
| 810 | #define HAVE_PORT_SEND HAVE_PORT_CREATE | ||
| 811 | #endif | ||
| 812 | |||
| 813 | #ifndef HAVE_PORT_SENDN | ||
| 814 | #define HAVE_PORT_SENDN HAVE_PORT_CREATE | ||
| 815 | #endif | ||
| 816 | |||
| 817 | #ifndef HAVE_POSIX_FADVISE | ||
| 818 | #define HAVE_POSIX_FADVISE (defined POSIX_FADV_NORMAL || AG_GLIBC_PREREQ(2,2) || __sun || AG_MUSL_MAYBE || AG_FREEBSD_PREREQ(9,0,0)) | ||
| 819 | #endif | ||
| 820 | |||
| 821 | #ifndef HAVE_POSIX_FALLOCATE | ||
| 822 | #define HAVE_POSIX_FALLOCATE (_AIX || AG_FREEBSD_PREREQ(9,0,0) || AG_GLIBC_PREREQ(2,2) || AG_MUSL_MAYBE || AG_NETBSD_PREREQ(7,0,0) || __sun) | ||
| 823 | #endif | ||
| 824 | |||
| 825 | #ifndef HAVE_SIGNALFD | ||
| 826 | #define HAVE_SIGNALFD HAVE_SYS_SIGNALFD_H | ||
| 827 | #endif | ||
| 828 | |||
| 829 | #ifndef HAVE_SIGTIMEDWAIT | ||
| 830 | #define HAVE_SIGTIMEDWAIT (!__APPLE__ && !__OpenBSD__) | ||
| 831 | #endif | ||
| 832 | |||
| 833 | #ifndef HAVE_SIGWAIT | ||
| 834 | #define HAVE_SIGWAIT (!__minix) | ||
| 835 | #endif | ||
| 836 | |||
| 837 | #ifndef HAVE_STATIC_ASSERT | ||
| 838 | #if AG_GLIBC_PREREQ(0,0) && !HAVE__STATIC_ASSERT | ||
| 839 | #define HAVE_STATIC_ASSERT 0 /* glibc doesn't check GCC version */ | ||
| 840 | #else | ||
| 841 | #define HAVE_STATIC_ASSERT (defined static_assert) | ||
| 842 | #endif | ||
| 843 | #endif | ||
| 844 | |||
| 845 | #ifndef HAVE_STRERROR_R | ||
| 846 | #define HAVE_STRERROR_R 1 | ||
| 847 | #endif | ||
| 848 | |||
| 849 | #ifndef HAVE_SYSCALL | ||
| 850 | #define HAVE_SYSCALL HAVE_SYS_SYSCALL_H | ||
| 851 | #endif | ||
| 852 | |||
| 853 | #ifndef HAVE_SYSCTL | ||
| 854 | #define HAVE_SYSCTL HAVE_SYS_SYSCTL_H | ||
| 855 | #endif | ||
| 856 | |||
| 857 | #ifndef HAVE_TIMERFD_CREATE | ||
| 858 | #define HAVE_TIMERFD_CREATE HAVE_SYS_TIMERFD_H | ||
| 859 | #endif | ||
| 860 | |||
| 861 | #ifndef HAVE_TIMERFD_GETTIME | ||
| 862 | #define HAVE_TIMERFD_GETTIME HAVE_TIMERFD_CREATE | ||
| 863 | #endif | ||
| 864 | |||
| 865 | #ifndef HAVE_TIMERFD_SETTIME | ||
| 866 | #define HAVE_TIMERFD_SETTIME HAVE_TIMERFD_CREATE | ||
| 867 | #endif | ||
| 868 | |||
| 869 | #ifndef STRERROR_R_CHAR_P | ||
| 870 | #define STRERROR_R_CHAR_P ((AG_GLIBC_PREREQ(0,0) || AG_UCLIBC_PREREQ(0,0,0)) && (HAVE__GNU_SOURCE || !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600))) | ||
| 871 | #endif | ||
| 872 | |||
| 873 | |||
| 874 | #endif /* CONFIG_H_GUESS */ | ||
diff --git a/src/GNUmakefile b/src/GNUmakefile index 34d9cd2..e7cb54d 100644 --- a/src/GNUmakefile +++ b/src/GNUmakefile | |||
| @@ -20,7 +20,7 @@ OS_$(d) = $(shell $(d)/../mk/vendor.os) | |||
| 20 | CC_$(d) = $(shell env CC="$(CC) "$(d)/../mk/vendor.cc) | 20 | CC_$(d) = $(shell env CC="$(CC) "$(d)/../mk/vendor.cc) |
| 21 | LUAPATH_$(d) = $(shell env CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" $(<D)/../mk/luapath -krxm3 -I$(DESTDIR)$(includedir) -I/usr/include -I/usr/local/include -P$(DESTDIR)$(bindir) -P$(bindir) -L$(DESTDIR)$(libdir) -L$(libdir) -v$(1) $(2)) | 21 | LUAPATH_$(d) = $(shell env CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" $(<D)/../mk/luapath -krxm3 -I$(DESTDIR)$(includedir) -I/usr/include -I/usr/local/include -P$(DESTDIR)$(bindir) -P$(bindir) -L$(DESTDIR)$(libdir) -L$(libdir) -v$(1) $(2)) |
| 22 | 22 | ||
| 23 | CPPFLAGS_$(d) = $(CPPFLAGS_$(abspath $(@D)/../..)) -DLUA_COMPAT_APIINTCASTS | 23 | CPPFLAGS_$(d) = $(CPPFLAGS_$(abspath $(@D)/../..)) -DLUA_COMPAT_APIINTCASTS -DHAVE_CONFIG_H |
| 24 | CFLAGS_$(d) = $(CFLAGS_$(abspath $(@D)/../..)) | 24 | CFLAGS_$(d) = $(CFLAGS_$(abspath $(@D)/../..)) |
| 25 | LDFLAGS_$(d) = $(LDFLAGS_$(abspath $(@D)/../..)) | 25 | LDFLAGS_$(d) = $(LDFLAGS_$(abspath $(@D)/../..)) |
| 26 | SOFLAGS_$(d) = $(SOFLAGS_$(abspath $(@D)/../..)) | 26 | SOFLAGS_$(d) = $(SOFLAGS_$(abspath $(@D)/../..)) |
| @@ -41,6 +41,8 @@ endif | |||
| 41 | # | 41 | # |
| 42 | # C O M P I L A T I O N R U L E S | 42 | # C O M P I L A T I O N R U L E S |
| 43 | # | 43 | # |
| 44 | $(d)/config.h: $(abspath $(d)/..)/config.h | ||
| 45 | $(CP) $< $@ | ||
| 44 | 46 | ||
| 45 | define BUILD_$(d) | 47 | define BUILD_$(d) |
| 46 | 48 | ||
| @@ -49,7 +51,7 @@ define BUILD_$(d) | |||
| 49 | $$(d)/$(1)/openssl.so: $$(d)/$(1)/openssl.o | 51 | $$(d)/$(1)/openssl.so: $$(d)/$(1)/openssl.o |
| 50 | $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(SOFLAGS) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS) | 52 | $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(SOFLAGS) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS) |
| 51 | 53 | ||
| 52 | $$(d)/$(1)/openssl.o: $$(d)/openssl.c $$(d)/compat52.h | 54 | $$(d)/$(1)/openssl.o: $$(d)/openssl.c $$(d)/compat52.h $$(d)/config.h |
| 53 | test "$$(notdir $$(@D))" = "$$(call LUAPATH_$$(<D), $$(notdir $$(@D)), version)" | 55 | test "$$(notdir $$(@D))" = "$$(call LUAPATH_$$(<D), $$(notdir $$(@D)), version)" |
| 54 | $$(MKDIR) -p $$(@D) | 56 | $$(MKDIR) -p $$(@D) |
| 55 | $$(CC) $$(CFLAGS_$$(<D)) $$(CFLAGS) $$(call LUAPATH_$$(<D), $$(notdir $$(@D)), cppflags) $$(CPPFLAGS_$$(<D)) $$(CPPFLAGS) -c -o $$@ $$< | 57 | $$(CC) $$(CFLAGS_$$(<D)) $$(CFLAGS) $$(call LUAPATH_$$(<D), $$(notdir $$(@D)), cppflags) $$(CPPFLAGS_$$(<D)) $$(CPPFLAGS) -c -o $$@ $$< |
diff --git a/src/openssl.c b/src/openssl.c index d8eebb5..78dbd65 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
| @@ -23,6 +23,10 @@ | |||
| 23 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | 23 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | * ========================================================================== | 24 | * ========================================================================== |
| 25 | */ | 25 | */ |
| 26 | #if HAVE_CONFIG_H | ||
| 27 | #include "config.h" | ||
| 28 | #endif | ||
| 29 | |||
| 26 | #include <limits.h> /* INT_MAX INT_MIN LLONG_MAX LLONG_MIN UCHAR_MAX ULLONG_MAX */ | 30 | #include <limits.h> /* INT_MAX INT_MIN LLONG_MAX LLONG_MIN UCHAR_MAX ULLONG_MAX */ |
| 27 | #include <stdint.h> /* uintptr_t */ | 31 | #include <stdint.h> /* uintptr_t */ |
| 28 | #include <string.h> /* memset(3) strerror_r(3) */ | 32 | #include <string.h> /* memset(3) strerror_r(3) */ |
| @@ -79,10 +83,6 @@ | |||
| 79 | #define LIBRESSL_PREREQ(M, m, p) \ | 83 | #define LIBRESSL_PREREQ(M, m, p) \ |
| 80 | (LIBRESSL_VERSION_NUMBER >= (((M) << 28) | ((m) << 20) | ((p) << 12))) | 84 | (LIBRESSL_VERSION_NUMBER >= (((M) << 28) | ((m) << 20) | ((p) << 12))) |
| 81 | 85 | ||
| 82 | #ifndef HAVE_DLADDR | ||
| 83 | #define HAVE_DLADDR (!defined _AIX) /* TODO: https://root.cern.ch/drupal/content/aix-and-dladdr */ | ||
| 84 | #endif | ||
| 85 | |||
| 86 | #ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS | 86 | #ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS |
| 87 | #define HAVE_SSL_CTX_SET_ALPN_PROTOS OPENSSL_PREREQ(1, 0, 2) | 87 | #define HAVE_SSL_CTX_SET_ALPN_PROTOS OPENSSL_PREREQ(1, 0, 2) |
| 88 | #endif | 88 | #endif |
| @@ -7811,49 +7811,61 @@ static struct randL_state *randL_getstate(lua_State *L) { | |||
| 7811 | return lua_touserdata(L, lua_upvalueindex(1)); | 7811 | return lua_touserdata(L, lua_upvalueindex(1)); |
| 7812 | } /* randL_getstate() */ | 7812 | } /* randL_getstate() */ |
| 7813 | 7813 | ||
| 7814 | #ifndef HAVE_SYS_SYSCTL_H | 7814 | #if HAVE_SYS_SYSCALL_H |
| 7815 | #define HAVE_SYS_SYSCTL_H (BSD || __GLIBC__) | 7815 | #include <sys/syscall.h> /* SYS_getrandom syscall(2) */ |
| 7816 | #endif | 7816 | #endif |
| 7817 | 7817 | ||
| 7818 | #if HAVE_SYS_SYSCTL_H | 7818 | #if HAVE_SYS_SYSCTL_H |
| 7819 | #include <sys/sysctl.h> /* CTL_KERN KERN_RANDOM RANDOM_UUID KERN_URND KERN_ARND sysctl(2) */ | 7819 | #include <sys/sysctl.h> /* CTL_KERN KERN_RANDOM RANDOM_UUID sysctl(2) */ |
| 7820 | #endif | ||
| 7821 | |||
| 7822 | #ifndef HAVE_RANDOM_UUID | ||
| 7823 | #define HAVE_RANDOM_UUID (HAVE_SYS_SYSCTL_H && defined __linux) /* RANDOM_UUID is an enum, not macro */ | ||
| 7824 | #endif | ||
| 7825 | |||
| 7826 | #ifndef HAVE_KERN_URND | ||
| 7827 | #define HAVE_KERN_URND (defined KERN_URND) | ||
| 7828 | #endif | ||
| 7829 | |||
| 7830 | #ifndef HAVE_KERN_ARND | ||
| 7831 | #define HAVE_KERN_ARND (defined KERN_ARND) | ||
| 7832 | #endif | 7820 | #endif |
| 7833 | 7821 | ||
| 7834 | static int randL_stir(struct randL_state *st, unsigned rqstd) { | 7822 | static int randL_stir(struct randL_state *st, unsigned rqstd) { |
| 7835 | unsigned count = 0; | 7823 | unsigned count = 0; |
| 7836 | int error; | 7824 | int error; |
| 7837 | unsigned char data[256]; | 7825 | unsigned char data[256]; |
| 7838 | #if HAVE_RANDOM_UUID || HAVE_KERN_URND || HAVE_KERN_ARND | 7826 | |
| 7839 | #if HAVE_RANDOM_UUID | 7827 | #if HAVE_ARC4RANDOM |
| 7840 | int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID }; | 7828 | while (count < rqstd) { |
| 7841 | #elif HAVE_KERN_URND | 7829 | size_t n = MIN(rqstd - count, sizeof data); |
| 7842 | int mib[] = { CTL_KERN, KERN_URND }; | 7830 | |
| 7843 | #else | 7831 | arc4random(data, n); |
| 7844 | int mib[] = { CTL_KERN, KERN_ARND }; | 7832 | |
| 7833 | RAND_seed(data, n); | ||
| 7834 | |||
| 7835 | count += n; | ||
| 7836 | } | ||
| 7837 | #endif | ||
| 7838 | |||
| 7839 | #if HAVE_SYSCALL && HAVE_DECL_SYS_GETRANDOM | ||
| 7840 | while (count < rqstd) { | ||
| 7841 | size_t lim = MIN(rqstd - count, sizeof data); | ||
| 7842 | int n; | ||
| 7843 | |||
| 7844 | n = syscall(SYS_getrandom, data, lim, 0); | ||
| 7845 | |||
| 7846 | if (n == -1) { | ||
| 7847 | break; | ||
| 7848 | } | ||
| 7849 | |||
| 7850 | RAND_seed(data, n); | ||
| 7851 | |||
| 7852 | count += n; | ||
| 7853 | } | ||
| 7845 | #endif | 7854 | #endif |
| 7846 | 7855 | ||
| 7856 | #if HAVE_SYS_SYSCTL_H && HAVE_DECL_RANDOM_UUID | ||
| 7847 | while (count < rqstd) { | 7857 | while (count < rqstd) { |
| 7858 | int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID }; | ||
| 7848 | size_t n = MIN(rqstd - count, sizeof data); | 7859 | size_t n = MIN(rqstd - count, sizeof data); |
| 7849 | 7860 | ||
| 7850 | if (0 != sysctl(mib, countof(mib), data, &n, (void *)0, 0)) | 7861 | if (0 != sysctl(mib, countof(mib), data, &n, (void *)0, 0)) |
| 7851 | break; | 7862 | break; |
| 7852 | 7863 | ||
| 7853 | RAND_add(data, n, n); | 7864 | RAND_seed(data, n); |
| 7854 | 7865 | ||
| 7855 | count += n; | 7866 | count += n; |
| 7856 | } | 7867 | } |
| 7868 | |||
| 7857 | #endif | 7869 | #endif |
| 7858 | 7870 | ||
| 7859 | if (count < rqstd) { | 7871 | if (count < rqstd) { |
| @@ -7884,7 +7896,7 @@ static int randL_stir(struct randL_state *st, unsigned rqstd) { | |||
| 7884 | 7896 | ||
| 7885 | goto error; | 7897 | goto error; |
| 7886 | default: | 7898 | default: |
| 7887 | RAND_add(data, n, n); | 7899 | RAND_seed(data, n); |
| 7888 | 7900 | ||
| 7889 | count += n; | 7901 | count += n; |
| 7890 | } | 7902 | } |
| @@ -7922,7 +7934,12 @@ error:; | |||
| 7922 | #elif defined __sun | 7934 | #elif defined __sun |
| 7923 | /* | 7935 | /* |
| 7924 | * NOTE: Linux requires -lrt for clock_gettime, and in any event | 7936 | * NOTE: Linux requires -lrt for clock_gettime, and in any event |
| 7925 | * already has RANDOM_UUID. The BSDs have KERN_URND and KERN_ARND. | 7937 | * should have RANDOM_UUID or getrandom. (Though, some middle-aged |
| 7938 | * kernels might have neither). The BSDs have arc4random which | ||
| 7939 | * should be using KERN_URND, KERN_ARND, and more recently | ||
| 7940 | * getentropy. (Though, again, some older BSD kernels used an | ||
| 7941 | * arc4random implementation that opened /dev/urandom.) | ||
| 7942 | * | ||
| 7926 | * Just do this for Solaris to keep things simple. We've already | 7943 | * Just do this for Solaris to keep things simple. We've already |
| 7927 | * crossed the line of what can be reasonably accomplished on | 7944 | * crossed the line of what can be reasonably accomplished on |
| 7928 | * unreasonable platforms. | 7945 | * unreasonable platforms. |
