Skip to content

Commit 24f77d9

Browse files
committed
Reapply "recipes ask whether a header is there instead of inferring it from the platform"
This reverts commit 75f5313.
1 parent 75f5313 commit 24f77d9

2 files changed

Lines changed: 93 additions & 17 deletions

File tree

‎pkgs/c/compat.c-ares.lua‎

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,9 @@ package = {
10301030
#define HAVE_BOOL_T
10311031
10321032
/* Define to 1 if you have the clock_gettime function and monotonic timer. */
1033-
/* #undef HAVE_CLOCK_GETTIME_MONOTONIC */
1033+
#if __has_include(<time.h>) && !defined(_WIN32)
1034+
#define HAVE_CLOCK_GETTIME_MONOTONIC 1
1035+
#endif
10341036
10351037
/* Define to 1 if you have the closesocket function. */
10361038
#define HAVE_CLOSESOCKET
@@ -1087,7 +1089,12 @@ package = {
10871089
/* #undef HAVE_GETSERVBYPORT_R */
10881090
10891091
/* Define to 1 if you have the `gettimeofday' function. */
1090-
/* #undef HAVE_GETTIMEOFDAY */
1092+
/* SUB-SECOND TIME. `ares_timeval.c:93` refuses a configuration that names no
1093+
* source of it, and the Win32 one (`GetTickCount64`) needs `windows.h`. A
1094+
* POSIX-presenting target has `clock_gettime`, which `time.h` declares. */
1095+
#if __has_include(<time.h>) && !defined(_WIN32)
1096+
#define HAVE_GETTIMEOFDAY 1
1097+
#endif
10911098
10921099
/* Define to 1 if you have the `if_indextoname' function. */
10931100
/* #undef HAVE_IF_INDEXTONAME */
@@ -1205,10 +1212,22 @@ package = {
12051212
#define HAVE_STDLIB_H
12061213
12071214
/* Define to 1 if you have the strcasecmp function. */
1208-
/* #undef HAVE_STRCASECMP */
1215+
/* WIN32 CRT NAMES vs POSIX NAMES, decided by what the C environment
1216+
* presents rather than by the platform. This block is the Windows branch of a
1217+
* recipe that branches on the PLATFORM; over openkal the target is PE and the
1218+
* C environment is POSIX, so the CRT spellings are the ones that are absent.
1219+
* `__has_builtin` cannot answer for library functions, so these ask the same
1220+
* question the headers do: `strings.h` carries the POSIX pair. */
1221+
#if __has_include(<strings.h>)
1222+
#define HAVE_STRCASECMP 1
1223+
#define HAVE_STRNCASECMP 1
1224+
#endif
1225+
/* #undef HAVE_STRCASECMP_ORIGINAL */
12091226
12101227
/* Define to 1 if you have the strcmpi function. */
1228+
#if !__has_include(<strings.h>)
12111229
#define HAVE_STRCMPI
1230+
#endif
12121231
12131232
/* Define to 1 if you have the strdup function. */
12141233
#define HAVE_STRDUP
@@ -1229,7 +1248,9 @@ package = {
12291248
/* #undef HAVE_STRNCMPI */
12301249
12311250
/* Define to 1 if you have the strnicmp function. */
1251+
#if !__has_include(<strings.h>)
12321252
#define HAVE_STRNICMP
1253+
#endif
12331254
12341255
/* Define to 1 if you have the <stropts.h> header file. */
12351256
/* #undef HAVE_STROPTS_H */
@@ -1276,23 +1297,42 @@ package = {
12761297
/* Define to 1 if you have the <time.h> header file. */
12771298
#define HAVE_TIME_H
12781299
1279-
/* Define to 1 if you have the <unistd.h> header file. */
1280-
/* #undef HAVE_UNISTD_H */
1281-
1282-
/* Define to 1 if you have the windows.h header file. */
1300+
/* THESE ASK WHETHER A HEADER IS THERE, SO THEY ASK THE COMPILER.
1301+
*
1302+
* This block is the Windows branch of a recipe that branches on the PLATFORM,
1303+
* and it used to define all four unconditionally. That was true of every
1304+
* Windows target this index had until a C library began presenting POSIX on
1305+
* one: over openkal the target is still PE, still Win64, and there is no
1306+
* `windows.h` --- `ares_setup.h:81` then reached for it and this repository's
1307+
* own compatibility measurement recorded
1308+
*
1309+
* ares_setup.h:81:12: fatal error: 'windows.h' file not found
1310+
*
1311+
* `__has_include` is standard C and asks the question actually being asked.
1312+
* `HAVE_UNISTD_H` gets the same treatment for the same reason, from the other
1313+
* side: a POSIX-presenting Windows target HAS it. */
1314+
#if __has_include(<unistd.h>)
1315+
#define HAVE_UNISTD_H 1
1316+
#endif
1317+
1318+
#if __has_include(<windows.h>)
12831319
#define HAVE_WINDOWS_H
1320+
#endif
12841321
1285-
/* Define to 1 if you have the winsock2.h header file. */
1322+
#if __has_include(<winsock2.h>)
12861323
#define HAVE_WINSOCK2_H
1324+
#endif
12871325
1288-
/* Define to 1 if you have the winsock.h header file. */
1326+
#if __has_include(<winsock.h>)
12891327
#define HAVE_WINSOCK_H
1328+
#endif
12901329
12911330
/* Define to 1 if you have the writev function. */
12921331
/* #undef HAVE_WRITEV */
12931332
1294-
/* Define to 1 if you have the ws2tcpip.h header file. */
1333+
#if __has_include(<ws2tcpip.h>)
12951334
#define HAVE_WS2TCPIP_H
1335+
#endif
12961336
12971337
/* Define if __system_property_get exists. */
12981338
/* #undef HAVE___SYSTEM_PROPERTY_GET */

‎pkgs/c/compat.curl.lua‎

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,20 +248,56 @@ package = {
248248
#if defined(__linux__)
249249
250250
#define CURL_OS "Linux"
251-
/* glibc's strerror_r returns char*, not int — curl needs to know which */
251+
252+
/* `__linux__` ANSWERS "WHICH KERNEL", NOT "WHICH USERSPACE IS INSTALLED", and
253+
* this block used to read it as the second. Every entry below that names a
254+
* HEADER now asks whether that header is reachable, which is the question
255+
* being asked and is standard C; every entry that names a GLIBC extension
256+
* asks for glibc.
257+
*
258+
* Measured: over openkal-musl on x86_64-linux-gnu the kernel is Linux, so
259+
* `__linux__` is correct, and `#define HAVE_LINUX_TCP_H 1` then sent
260+
* `lib/setopt.c:31` to a uapi header that C library does not carry ---
261+
* `fatal error: 'linux/tcp.h' file not found`, one of the failures in this
262+
* repository's own compatibility measurement. */
263+
#if __has_include(<linux/tcp.h>)
264+
#define HAVE_LINUX_TCP_H 1
265+
#endif
266+
/* `__has_include` ANSWERS ABOUT THE HEADER, NOT ABOUT THE FUNCTION, and those
267+
* two come apart here. openkal-musl CARRIES `sys/eventfd.h` and declares
268+
* `eventfd` absent in its `[c-abi-absent]` table, so defining `HAVE_EVENTFD`
269+
* from the header's presence produced a link that mcpp explained by name:
270+
*
271+
* the C library in this graph (musl) declares that it does not supply
272+
* the following, and the link has just asked for it:
273+
* eventfd as timerfd_create
274+
*
275+
* Neither is declared: curl has a poll-based path and takes it. A header
276+
* test cannot stand in for a symbol test. */
277+
#if __has_include(<termio.h>)
278+
#define HAVE_TERMIO_H 1
279+
#endif
280+
#if __has_include(<sys/xattr.h>)
281+
#define HAVE_FSETXATTR 1
282+
#define HAVE_FSETXATTR_5 1
283+
#endif
284+
285+
/* WHICH `strerror_r`, AND EXACTLY ONE OF THEM. glibc's returns `char*`,
286+
* POSIX's returns `int`, and `strerr.c:30` refuses a configuration that names
287+
* neither or both. Asking `__linux__` answered "glibc" for musl, which is the
288+
* wrong one; leaving it out answered "neither", which is also refused. */
289+
#if defined(__GLIBC__)
252290
#define HAVE_GLIBC_STRERROR_R 1
291+
#else
292+
#define HAVE_POSIX_STRERROR_R 1
293+
#endif
294+
253295
#define HAVE_GETHOSTBYNAME_R 1
254296
#define HAVE_GETHOSTBYNAME_R_6 1
255297
#define HAVE_ACCEPT4 1
256298
#define HAVE_PIPE2 1
257-
#define HAVE_EVENTFD 1
258-
#define HAVE_SYS_EVENTFD_H 1
259299
#define HAVE_SENDMMSG 1
260300
#define HAVE_MEMRCHR 1
261-
#define HAVE_FSETXATTR 1
262-
#define HAVE_FSETXATTR_5 1
263-
#define HAVE_LINUX_TCP_H 1
264-
#define HAVE_TERMIO_H 1
265301
#define HAVE_CLOCK_GETTIME_MONOTONIC_RAW 1
266302
/* Debian/Fedora layout; overridable at runtime with CURLOPT_CAINFO or the
267303
* SSL_CERT_FILE environment variable. */

0 commit comments

Comments
 (0)