| 1 |
dnl Check whether limits.h has needed features. |
| 2 |
|
| 3 |
dnl Copyright 2016-2024 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
|
| 8 |
dnl From Paul Eggert. |
| 9 |
|
| 10 |
AC_DEFUN_ONCE([gl_LIMITS_H], |
| 11 |
[ |
| 12 |
gl_CHECK_NEXT_HEADERS([limits.h]) |
| 13 |
|
| 14 |
AC_CACHE_CHECK([whether limits.h has WORD_BIT, BOOL_WIDTH etc.], |
| 15 |
[gl_cv_header_limits_width], |
| 16 |
[AC_COMPILE_IFELSE( |
| 17 |
[AC_LANG_PROGRAM( |
| 18 |
[[#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ |
| 19 |
#define __STDC_WANT_IEC_60559_BFP_EXT__ 1 |
| 20 |
#endif |
| 21 |
#include <limits.h> |
| 22 |
long long llm = LLONG_MAX; |
| 23 |
int wb = WORD_BIT; |
| 24 |
int ullw = ULLONG_WIDTH; |
| 25 |
int bw = BOOL_WIDTH; |
| 26 |
int bm = BOOL_MAX; |
| 27 |
int mblm = MB_LEN_MAX; |
| 28 |
]])], |
| 29 |
[gl_cv_header_limits_width=yes], |
| 30 |
[gl_cv_header_limits_width=no])]) |
| 31 |
GL_GENERATE_LIMITS_H=true |
| 32 |
AS_IF([test "$gl_cv_header_limits_width" = yes], |
| 33 |
[AC_CACHE_CHECK([whether limits.h has SSIZE_MAX], |
| 34 |
[gl_cv_header_limits_ssize_max], |
| 35 |
[AC_COMPILE_IFELSE( |
| 36 |
[AC_LANG_SOURCE( |
| 37 |
[[#include <limits.h> |
| 38 |
#ifndef SSIZE_MAX |
| 39 |
#error "SSIZE_MAX is not defined" |
| 40 |
#endif |
| 41 |
]])], |
| 42 |
[gl_cv_header_limits_ssize_max=yes], |
| 43 |
[gl_cv_header_limits_ssize_max=no])]) |
| 44 |
if test "$gl_cv_header_limits_ssize_max" = yes; then |
| 45 |
GL_GENERATE_LIMITS_H=false |
| 46 |
fi]) |
| 47 |
]) |
| 48 |
|
| 49 |
dnl Unconditionally enables the replacement of <limits.h>. |
| 50 |
AC_DEFUN([gl_REPLACE_LIMITS_H], |
| 51 |
[ |
| 52 |
AC_REQUIRE([gl_LIMITS_H]) |
| 53 |
GL_GENERATE_LIMITS_H=true |
| 54 |
]) |