diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-10-29 16:16:42 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-10-29 16:16:42 +0200 |
commit | 747271e97b5500d0a9fdfc641b36a199e313c3f0 (patch) | |
tree | 81963032bdd0ebf559c9bc6d867358bef46dd392 /libpkgconf/libpkgconf | |
parent | fe1ec4b914982e1918bf36b97419a9bfa59b28e1 (diff) |
Adjust _POSIX_C_SOURCE definition to work around musl bug
Diffstat (limited to 'libpkgconf/libpkgconf')
-rw-r--r-- | libpkgconf/libpkgconf/buildfile | 26 | ||||
-rw-r--r-- | libpkgconf/libpkgconf/config.h.in | 10 |
2 files changed, 17 insertions, 19 deletions
diff --git a/libpkgconf/libpkgconf/buildfile b/libpkgconf/libpkgconf/buildfile index c29bc53..a9b6e9c 100644 --- a/libpkgconf/libpkgconf/buildfile +++ b/libpkgconf/libpkgconf/buildfile @@ -95,25 +95,21 @@ elif $clang_msvc # if! $windows { - # Upstream package compiles the source files with -std=gnu99 option to allow - # some GNU deviations from the ISO C99 standard. We will compile with - # -std=c9x option (is implied by c.std=99 in root.build) and define - # _GNU_SOURCE for the source files that require such deviations. This macro - # also re-enables definitions of POSIX macros (specifically PATH_MAX) that - # are disabled by -std=c9x. + # The upstream package compiles the source files with -std=gnu99 option to + # allow some GNU deviations from the ISO C99 standard. We will compile with + # the -std=c99 option (via c.std=99 in root.build) and define + # _POSIX_C_SOURCE=200809L for all as well as _GNU_SOURCE for some source + # files (those that require GNU extension). These macros also re-enable + # definitions of POSIX macros (specifically PATH_MAX) that are disabled by + # -std=c99. # # Note that on FreeBSD and MacOS -D_POSIX_C_SOURCE disables declarations of - # strndup(), strlcpy() and alike, that are not POSIX. Not very consistent - # given that they are also not C99. Luckily, -std=c9x doesn't disable - # PATH_MAX on these OSes, so we just don't define the macro for them. - # - # @@ It all becomes a bit hairy. Should we just undefine the corresponding - # HAVE_* macros in config.h, so the custom function implementations are - # picked up? Alternatively, can we stop specifying the C standard and - # defining _POSIX_C_SOURCE macro altogether? + # strlcpy() and alike which are not POSIX. Not very consistent given that + # they are also not C99. Luckily, -std=c99 doesn't disable PATH_MAX on these + # platforms, so we just don't define this macro for them. # if! ($bsd || $macos) - c.poptions += -D_POSIX_C_SOURCE=200112L + c.poptions += -D_POSIX_C_SOURCE=200809L obj{client fragment path personality pkg queue tuple}: \ c.poptions += -D_GNU_SOURCE diff --git a/libpkgconf/libpkgconf/config.h.in b/libpkgconf/libpkgconf/config.h.in index ac5b1fa..3005e5a 100644 --- a/libpkgconf/libpkgconf/config.h.in +++ b/libpkgconf/libpkgconf/config.h.in @@ -19,13 +19,15 @@ #define PACKAGE_VERSION "$PACKAGE_VERSION$" /* - * strndup() is not present on Windows, for gcc and clang if compile with - * -std=C99, except for FreeBSD and MacOS. + * strndup() is not present on Windows while strl*() are only present on + * FreeBSD and MacOS. * - * strl*() are only present on FreeBSD and MacOS. */ -#if defined(__FreeBSD__) || defined(__APPLE__) +#if !defined(_WIN32) # define HAVE_STRNDUP 1 +#endif + +#if defined(__FreeBSD__) || defined(__APPLE__) # define HAVE_STRLCPY 1 # define HAVE_STRLCAT 1 #endif |