1 # Macros that test various C library quirks
5 # PGAC_VAR_INT_TIMEZONE
6 # ---------------------
7 # Check if the global variable `timezone' exists. If so, define
9 AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
10 [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
11 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>
18 [pgac_cv_var_int_timezone=yes],
19 [pgac_cv_var_int_timezone=no])])
20 if test x"$pgac_cv_var_int_timezone" = xyes ; then
21 AC_DEFINE(HAVE_INT_TIMEZONE, 1,
22 [Define to 1 if you have the global variable 'int timezone'.])
23 fi])# PGAC_VAR_INT_TIMEZONE
26 # PGAC_STRUCT_TIMEZONE
28 # Figure out how to get the current timezone. If `struct tm' has a
29 # `tm_zone' member, define `HAVE_STRUCT_TM_TM_ZONE'. Unlike the
30 # standard macro AC_STRUCT_TIMEZONE, we don't check for `tzname[]' if
31 # not found, since we don't use it. (We use `int timezone' as a
33 AC_DEFUN([PGAC_STRUCT_TIMEZONE],
34 [AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
37 ])# PGAC_STRUCT_TIMEZONE
40 # PGAC_FUNC_STRERROR_R_INT
41 # ---------------------------
42 # Check if strerror_r() returns int (POSIX) rather than char * (GNU libc).
43 # If so, define STRERROR_R_INT.
44 # The result is uncertain if strerror_r() isn't provided,
45 # but we don't much care.
46 AC_DEFUN([PGAC_FUNC_STRERROR_R_INT],
47 [AC_CACHE_CHECK(whether strerror_r returns int,
48 pgac_cv_func_strerror_r_int,
49 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <string.h>],
51 switch (strerror_r(1, buf, sizeof(buf)))
52 { case 0: break; default: break; }
54 [pgac_cv_func_strerror_r_int=yes],
55 [pgac_cv_func_strerror_r_int=no])])
56 if test x"$pgac_cv_func_strerror_r_int" = xyes ; then
57 AC_DEFINE(STRERROR_R_INT, 1,
58 [Define to 1 if strerror_r() returns int.])
60 ])# PGAC_FUNC_STRERROR_R_INT
65 # Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
66 # If it doesn't then one could define it as
67 # union semun { int val; struct semid_ds *buf; unsigned short *array; }
68 AC_DEFUN([PGAC_UNION_SEMUN],
69 [AC_CHECK_TYPES([union semun], [], [],
70 [#include <sys/types.h>
73 ])])# PGAC_UNION_SEMUN
76 # PGAC_STRUCT_SOCKADDR_MEMBERS
77 # ----------------------------
78 # Check if struct sockaddr and subtypes have 4.4BSD-style length.
79 AC_DEFUN([PGAC_STRUCT_SOCKADDR_SA_LEN],
80 [AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [],
81 [#include <sys/types.h>
82 #include <sys/socket.h>
83 ])])# PGAC_STRUCT_SOCKADDR_MEMBERS
88 # Check for the locale_t type and find the right header file. macOS
89 # needs xlocale.h; standard is locale.h, but glibc <= 2.25 also had an
90 # xlocale.h file that we should not use, so we check the standard
92 AC_DEFUN([PGAC_TYPE_LOCALE_T],
93 [AC_CACHE_CHECK([for locale_t], pgac_cv_type_locale_t,
94 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
98 [pgac_cv_type_locale_t=yes],
99 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
100 [#include <xlocale.h>
103 [pgac_cv_type_locale_t='yes (in xlocale.h)'],
104 [pgac_cv_type_locale_t=no])])])
105 if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
106 AC_DEFINE(LOCALE_T_IN_XLOCALE, 1,
107 [Define to 1 if `locale_t' requires <xlocale.h>.])
108 fi])# PGAC_TYPE_LOCALE_T
111 # PGAC_FUNC_WCSTOMBS_L
112 # --------------------
113 # Try to find a declaration for wcstombs_l(). It might be in stdlib.h
114 # (following the POSIX requirement for wcstombs()), or in locale.h, or in
115 # xlocale.h. If it's in the latter, define WCSTOMBS_L_IN_XLOCALE.
117 AC_DEFUN([PGAC_FUNC_WCSTOMBS_L],
118 [AC_CACHE_CHECK([for wcstombs_l declaration], pgac_cv_func_wcstombs_l,
119 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
121 #include <locale.h>],
125 [pgac_cv_func_wcstombs_l='yes'],
126 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
129 #include <xlocale.h>],
133 [pgac_cv_func_wcstombs_l='yes (in xlocale.h)'],
134 [pgac_cv_func_wcstombs_l='no'])])])
135 if test "$pgac_cv_func_wcstombs_l" = 'yes (in xlocale.h)'; then
136 AC_DEFINE(WCSTOMBS_L_IN_XLOCALE, 1,
137 [Define to 1 if `wcstombs_l' requires <xlocale.h>.])
138 fi])# PGAC_FUNC_WCSTOMBS_L