Check sizeof long using the more portable LONG_BIT.#2214
Conversation
The previous attempt (reverted with commit 272613d ) used macro SIZEOF_LONG which was not a system include, but internal to cURL, defined from configure.ac AC_CHECK_SIZEOF(long). Using LONG_BIT is more portable. Even LONG_BIT though requires pulling in <limits.h> and _XOPEN_SOURCE to be defined. We include <limits.h> only inside the specific ifdef in order to avoid affecting other platforms that already work.
|
This is another attempt after #2186 was reverted, and seems to work on all our buildslaves, including the previously broken AIX and HP-UX. |
|
limits.h is guarded in curl source by HAVE_LIMITS_H so it apparently isn't always available. reviewing c89 I see it should always be available even in the most strict implementations, so i put in #2215 to address that. however even if that is approved i don't think we should define _XOPEN_SOURCE in curl/system.h. note your commit is currently missing xopen define. i think it would be better as |
|
oops I meant 64-bit __LONG_MAX not LONG LONG to check if long is 64-bits. |
|
Thanks. Indeed I forgot the guard for including limits.h, I can add it if #2215 is not to be merged. On the other hand I did not define _XOPEN_SOURCE on purpose, as that would be very intrusive. Nevertheless LONG_BIT was defined on the not-so-recent UNIX hosts I tested it on (AIX 5.3, HP-UX 11.23). IMO the clear way would be to include
I'll submit a new pull request for this then, feel free to close this one. |
|
See #2216 |
The previous attempt (reverted with commit
272613d ) used macro SIZEOF_LONG which was
not a system include, but internal to cURL, defined from configure.ac
AC_CHECK_SIZEOF(long). Using LONG_BIT is more portable.
Even LONG_BIT though requires pulling in <limits.h> and _XOPEN_SOURCE to be
defined. We include <limits.h> only inside the specific ifdef in order to
avoid affecting other platforms that already work.