Skip to content

Commit bd78a42

Browse files
authored
Merge pull request #10097 from kareem-wolfssl/gh9936
Define HAVE_LIMITS_H in options.h rather than config.h.
2 parents 4b8fd23 + 1b78eff commit bd78a42

5 files changed

Lines changed: 23 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
113113
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
114114
check_include_file("unistd.h" HAVE_UNISTD_H)
115115

116+
# types.h depends on HAVE_LIMITS_H, and it is defined in options.h (rather than
117+
# config.h) so that applications consuming wolfSSL headers see it. The in-tree
118+
# build, however, is configured through config.h/compile definitions and does
119+
# not include options.h, so define it here as well.
120+
if(HAVE_LIMITS_H)
121+
add_definitions("-DHAVE_LIMITS_H")
122+
endif()
123+
116124
include(CheckFunctionExists)
117125

118126
# TODO: Also check if these functions are declared by the

cmake/config.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
/* Define to 1 if you have the `gmtime_r' function. */
2020
#cmakedefine HAVE_GMTIME_R @HAVE_GMTIME_R@
2121

22-
/* Define to 1 if you have the <limits.h> header file. */
23-
#cmakedefine HAVE_LIMITS_H @HAVE_LIMITS_H@
24-
2522
/* Define to 1 if you have the <pcap/pcap.h> header file. */
2623
#cmakedefine HAVE_PCAP_PCAP_H @HAVE_PCAP_PCAP_H@
2724

cmake/options.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ extern "C" {
3838
#undef _POSIX_THREADS
3939
#cmakedefine _POSIX_THREADS
4040
#endif
41+
/* Since types.h depends on HAVE_LIMITS_H, we must define it in options.h. */
42+
#undef HAVE_LIMITS_H
43+
#cmakedefine HAVE_LIMITS_H @HAVE_LIMITS_H@
4144
#undef ASIO_USE_WOLFSSL
4245
#cmakedefine ASIO_USE_WOLFSSL
4346
#undef BOOST_ASIO_USE_WOLFSSL

configure.ac

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ then
204204
fi
205205
fi
206206

207-
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stddef.h time.h sys/ioctl.h sys/socket.h sys/time.h errno.h sys/un.h ctype.h sys/random.h])
207+
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stddef.h time.h sys/ioctl.h sys/socket.h sys/time.h errno.h sys/un.h ctype.h sys/random.h])
208+
# Special case: Since types.h depends on HAVE_LIMITS_H, we must define it in options.h.
209+
AC_CHECK_HEADER([limits.h], [AM_CPPFLAGS="$AM_CPPFLAGS -DHAVE_LIMITS_H=1"], [])
208210
AC_CHECK_LIB([network],[socket])
209211
AC_C_BIGENDIAN
210212
AC_C___ATOMIC

wolfssl/wolfcrypt/types.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ typedef const char wcchar[];
231231
(ULONG_MAX == 0xffffffffUL)
232232
#define SIZEOF_LONG 4
233233
#endif
234+
/* On LP64 (e.g. 64-bit Linux/macOS) long is 8 bytes. Detect it from the
235+
* target's own limits.h so CTC_SETTINGS matches the library, which gets
236+
* SIZEOF_LONG=8 from config.h. This must be derived per-target (not
237+
* baked into options.h), so LLP64 targets such as Windows correctly get
238+
* SIZEOF_LONG=4 from the branch above. */
239+
#if !defined(SIZEOF_LONG) && defined(ULONG_MAX) && \
240+
(ULONG_MAX == 0xffffffffffffffffULL)
241+
#define SIZEOF_LONG 8
242+
#endif
234243
#if !defined(SIZEOF_LONG_LONG) && defined(ULLONG_MAX) && \
235244
(ULLONG_MAX == 0xffffffffffffffffULL)
236245
#define SIZEOF_LONG_LONG 8

0 commit comments

Comments
 (0)