diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-03-19 01:41:03 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-03-19 01:41:54 -0700 |
commit | 5710ec495d98d89d3a7c0722786081fee908b43e (patch) | |
tree | 2dedd8017abe008f5455e1c3b4e87e81f84af740 /ftmacros.h | |
parent | baffaf4364f5595fa86d4a67f687ce293ef1aca3 (diff) | |
download | libpcap-5710ec495d98d89d3a7c0722786081fee908b43e.tar.gz |
Make sure asprintf() is declared if it's present.
GNU libc is a pain. If you don't define _GNU_SOURCE, it doesn't declare
asprintf(). If you *do* define _GNU_SOURCE, the strerror_r() it
declares isn't POSIX-compliant.
We use asprintf() if present, so we need it to be declared; define
_GNU_SOURCE in ftmacros.h.
At configuration time, if we have strerror_r(), check whether it's
GNU-style or POSIX-style, and define different #defines for those two
cases. Handle GNU-style strerror_r() and POSIX-style strerror_r()
differently in pcap_fmt_errmsg_for_errno().
Make sure everything that uses asprintf() includes ftmacros.h before
including stdio.h.
Diffstat (limited to 'ftmacros.h')
-rw-r--r-- | ftmacros.h | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -85,20 +85,14 @@ */ #elif defined(__linux__) || defined(linux) || defined(__linux) /* - * We can't turn _GNU_SOURCE on because some versions of GNU Libc - * will give the GNU version of strerror_r(), which returns a - * string pointer and doesn't necessarily fill in the buffer, - * rather than the standard version of strerror_r(), which - * returns 0 or an errno and always fills in the buffer. We - * require both of the latter behaviors. + * Turn on _GNU_SOURCE to get everything GNU libc has to offer, + * including asprintf(). * - * So we try turning everything else on that we can. This includes - * defining _XOPEN_SOURCE as 600, because we want to force crypt() - * to be declared on systems that use GNU libc, such as most Linux - * distributions. + * Unfortunately, one thing it has to offer is a strerror_r() + * that's not POSIX-compliant, but we deal with that in + * pcap_fmt_errmsg_for_errno(). */ - #define _POSIX_C_SOURCE 200809L - #define _XOPEN_SOURCE 600 + #define _GNU_SOURCE /* * We turn on both _DEFAULT_SOURCE and _BSD_SOURCE to try to get |