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_GETTIMEOFDAY_1ARG
41 # ---------------------------
42 # Check if gettimeofday() has only one arguments. (Normal is two.)
43 # If so, define GETTIMEOFDAY_1ARG.
44 AC_DEFUN([PGAC_FUNC_GETTIMEOFDAY_1ARG],
45 [AC_CACHE_CHECK(whether gettimeofday takes only one argument,
46 pgac_cv_func_gettimeofday_1arg,
47 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/time.h>],
50 gettimeofday(tp,tzp);])],
51 [pgac_cv_func_gettimeofday_1arg=no],
52 [pgac_cv_func_gettimeofday_1arg=yes])])
53 if test x"$pgac_cv_func_gettimeofday_1arg" = xyes ; then
54 AC_DEFINE(GETTIMEOFDAY_1ARG, 1,
55 [Define to 1 if gettimeofday() takes only 1 argument.])
57 AH_VERBATIM(GETTIMEOFDAY_1ARG_,
58 [@%:@ifdef GETTIMEOFDAY_1ARG
59 @%:@ define gettimeofday(a,b) gettimeofday(a)
61 ])# PGAC_FUNC_GETTIMEOFDAY_1ARG
64 # PGAC_FUNC_STRERROR_R_INT
65 # ---------------------------
66 # Check if strerror_r() returns int (POSIX) rather than char * (GNU libc).
67 # If so, define STRERROR_R_INT.
68 # The result is uncertain if strerror_r() isn't provided,
69 # but we don't much care.
70 AC_DEFUN([PGAC_FUNC_STRERROR_R_INT],
71 [AC_CACHE_CHECK(whether strerror_r returns int,
72 pgac_cv_func_strerror_r_int,
73 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <string.h>],
75 switch (strerror_r(1, buf, sizeof(buf)))
76 { case 0: break; default: break; }
78 [pgac_cv_func_strerror_r_int=yes],
79 [pgac_cv_func_strerror_r_int=no])])
80 if test x"$pgac_cv_func_strerror_r_int" = xyes ; then
81 AC_DEFINE(STRERROR_R_INT, 1,
82 [Define to 1 if strerror_r() returns int.])
84 ])# PGAC_FUNC_STRERROR_R_INT
89 # Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
90 # If it doesn't then one could define it as
91 # union semun { int val; struct semid_ds *buf; unsigned short *array; }
92 AC_DEFUN([PGAC_UNION_SEMUN],
93 [AC_CHECK_TYPES([union semun], [], [],
94 [#include <sys/types.h>
100 #endif])])# PGAC_UNION_SEMUN
103 # PGAC_STRUCT_SOCKADDR_UN
104 # -----------------------
105 # If `struct sockaddr_un' exists, define HAVE_STRUCT_SOCKADDR_UN.
106 # If it is missing then one could define it.
107 # (Requires test for <sys/un.h>!)
108 AC_DEFUN([PGAC_STRUCT_SOCKADDR_UN],
109 [AC_CHECK_TYPES([struct sockaddr_un], [], [],
110 [#include <sys/types.h>
114 ])])# PGAC_STRUCT_SOCKADDR_UN
117 # PGAC_STRUCT_SOCKADDR_STORAGE
118 # ----------------------------
119 # If `struct sockaddr_storage' exists, define HAVE_STRUCT_SOCKADDR_STORAGE.
120 # If it is missing then one could define it.
121 AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE],
122 [AC_CHECK_TYPES([struct sockaddr_storage], [], [],
123 [#include <sys/types.h>
124 #include <sys/socket.h>
125 ])])# PGAC_STRUCT_SOCKADDR_STORAGE
127 # PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
128 # --------------------------------------
129 # Check the members of `struct sockaddr_storage'. We need to know about
130 # ss_family and ss_len. (Some platforms follow RFC 2553 and call them
131 # __ss_family and __ss_len.) We also check struct sockaddr's sa_len;
132 # if we have to define our own `struct sockaddr_storage', this tells us
133 # whether we need to provide an ss_len field.
134 AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS],
135 [AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family,
136 struct sockaddr_storage.__ss_family,
137 struct sockaddr_storage.ss_len,
138 struct sockaddr_storage.__ss_len,
139 struct sockaddr.sa_len], [], [],
140 [#include <sys/types.h>
141 #include <sys/socket.h>
142 ])])# PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
145 # PGAC_STRUCT_ADDRINFO
146 # -----------------------
147 # If `struct addrinfo' exists, define HAVE_STRUCT_ADDRINFO.
148 AC_DEFUN([PGAC_STRUCT_ADDRINFO],
149 [AC_CHECK_TYPES([struct addrinfo], [], [],
150 [#include <sys/types.h>
151 #include <sys/socket.h>
153 ])])# PGAC_STRUCT_ADDRINFO
158 # Check for the locale_t type and find the right header file. macOS
159 # needs xlocale.h; standard is locale.h, but glibc also has an
160 # xlocale.h file that we should not use.
162 AC_DEFUN([PGAC_TYPE_LOCALE_T],
163 [AC_CACHE_CHECK([for locale_t], pgac_cv_type_locale_t,
164 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
168 [pgac_cv_type_locale_t=yes],
169 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
170 [#include <xlocale.h>
173 [pgac_cv_type_locale_t='yes (in xlocale.h)'],
174 [pgac_cv_type_locale_t=no])])])
175 if test "$pgac_cv_type_locale_t" != no; then
176 AC_DEFINE(HAVE_LOCALE_T, 1,
177 [Define to 1 if the system has the type `locale_t'.])
179 if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
180 AC_DEFINE(LOCALE_T_IN_XLOCALE, 1,
181 [Define to 1 if `locale_t' requires <xlocale.h>.])
182 fi])# PGAC_TYPE_LOCALE_T
185 # PGAC_FUNC_WCSTOMBS_L
186 # --------------------
187 # Try to find a declaration for wcstombs_l(). It might be in stdlib.h
188 # (following the POSIX requirement for wcstombs()), or in locale.h, or in
189 # xlocale.h. If it's in the latter, define WCSTOMBS_L_IN_XLOCALE.
191 AC_DEFUN([PGAC_FUNC_WCSTOMBS_L],
192 [AC_CACHE_CHECK([for wcstombs_l declaration], pgac_cv_func_wcstombs_l,
193 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
195 #include <locale.h>],
199 [pgac_cv_func_wcstombs_l='yes'],
200 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
203 #include <xlocale.h>],
207 [pgac_cv_func_wcstombs_l='yes (in xlocale.h)'],
208 [pgac_cv_func_wcstombs_l='no'])])])
209 if test "$pgac_cv_func_wcstombs_l" = 'yes (in xlocale.h)'; then
210 AC_DEFINE(WCSTOMBS_L_IN_XLOCALE, 1,
211 [Define to 1 if `wcstombs_l' requires <xlocale.h>.])
212 fi])# PGAC_FUNC_WCSTOMBS_L