Release notes for 15.4, 14.9, 13.12, 12.16, 11.21.
[pgsql.git] / config / c-library.m4
blob6f2b0fbb4e6ec9484302916984a276e53d821313
1 # Macros that test various C library quirks
2 # config/c-library.m4
5 # PGAC_VAR_INT_TIMEZONE
6 # ---------------------
7 # Check if the global variable `timezone' exists. If so, define
8 # HAVE_INT_TIMEZONE.
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>
12 int res;],
13   [#ifndef __CYGWIN__
14 res = timezone / 60;
15 #else
16 res = _timezone / 60;
17 #endif])],
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
27 # ------------------
28 # Figure out how to get the current timezone.  If `struct tm' has a
29 # `tm_zone' member, define `HAVE_TM_ZONE'.  Also, if the
30 # external array `tzname' is found, define `HAVE_TZNAME'.
31 # This is the same as the standard macro AC_STRUCT_TIMEZONE, except that
32 # tzname[] is checked for regardless of whether we find tm_zone.
33 AC_DEFUN([PGAC_STRUCT_TIMEZONE],
34 [AC_REQUIRE([AC_STRUCT_TM])dnl
35 AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
36 #include <$ac_cv_struct_tm>
38 if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
39   AC_DEFINE(HAVE_TM_ZONE, 1,
40             [Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
41              `HAVE_STRUCT_TM_TM_ZONE' instead.])
43 AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
44 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
45 [[#include <stdlib.h>
46 #include <time.h>
47 #ifndef tzname /* For SGI.  */
48 extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
49 #endif
50 ]],
51 [atoi(*tzname);])], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
52 if test $ac_cv_var_tzname = yes; then
53     AC_DEFINE(HAVE_TZNAME, 1,
54               [Define to 1 if you have the external array `tzname'.])
56 ])# PGAC_STRUCT_TIMEZONE
59 # PGAC_FUNC_GETTIMEOFDAY_1ARG
60 # ---------------------------
61 # Check if gettimeofday() has only one arguments. (Normal is two.)
62 # If so, define GETTIMEOFDAY_1ARG.
63 AC_DEFUN([PGAC_FUNC_GETTIMEOFDAY_1ARG],
64 [AC_CACHE_CHECK(whether gettimeofday takes only one argument,
65 pgac_cv_func_gettimeofday_1arg,
66 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/time.h>],
67 [struct timeval *tp;
68 struct timezone *tzp;
69 gettimeofday(tp,tzp);])],
70 [pgac_cv_func_gettimeofday_1arg=no],
71 [pgac_cv_func_gettimeofday_1arg=yes])])
72 if test x"$pgac_cv_func_gettimeofday_1arg" = xyes ; then
73   AC_DEFINE(GETTIMEOFDAY_1ARG, 1,
74             [Define to 1 if gettimeofday() takes only 1 argument.])
76 AH_VERBATIM(GETTIMEOFDAY_1ARG_,
77 [@%:@ifdef GETTIMEOFDAY_1ARG
78 @%:@ define gettimeofday(a,b) gettimeofday(a)
79 @%:@endif])dnl
80 ])# PGAC_FUNC_GETTIMEOFDAY_1ARG
83 # PGAC_FUNC_STRERROR_R_INT
84 # ---------------------------
85 # Check if strerror_r() returns int (POSIX) rather than char * (GNU libc).
86 # If so, define STRERROR_R_INT.
87 # The result is uncertain if strerror_r() isn't provided,
88 # but we don't much care.
89 AC_DEFUN([PGAC_FUNC_STRERROR_R_INT],
90 [AC_CACHE_CHECK(whether strerror_r returns int,
91 pgac_cv_func_strerror_r_int,
92 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <string.h>],
93 [[char buf[100];
94   switch (strerror_r(1, buf, sizeof(buf)))
95   { case 0: break; default: break; }
96 ]])],
97 [pgac_cv_func_strerror_r_int=yes],
98 [pgac_cv_func_strerror_r_int=no])])
99 if test x"$pgac_cv_func_strerror_r_int" = xyes ; then
100   AC_DEFINE(STRERROR_R_INT, 1,
101             [Define to 1 if strerror_r() returns int.])
103 ])# PGAC_FUNC_STRERROR_R_INT
106 # PGAC_UNION_SEMUN
107 # ----------------
108 # Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
109 # If it doesn't then one could define it as
110 # union semun { int val; struct semid_ds *buf; unsigned short *array; }
111 AC_DEFUN([PGAC_UNION_SEMUN],
112 [AC_CHECK_TYPES([union semun], [], [],
113 [#include <sys/types.h>
114 #ifdef HAVE_SYS_IPC_H
115 #include <sys/ipc.h>
116 #endif
117 #ifdef HAVE_SYS_SEM_H
118 #include <sys/sem.h>
119 #endif])])# PGAC_UNION_SEMUN
122 # PGAC_STRUCT_SOCKADDR_UN
123 # -----------------------
124 # If `struct sockaddr_un' exists, define HAVE_UNIX_SOCKETS.
125 # (Requires test for <sys/un.h>!)
126 AC_DEFUN([PGAC_STRUCT_SOCKADDR_UN],
127 [AC_CHECK_TYPE([struct sockaddr_un], [AC_DEFINE(HAVE_UNIX_SOCKETS, 1, [Define to 1 if you have unix sockets.])], [],
128 [#include <sys/types.h>
129 #ifdef HAVE_SYS_UN_H
130 #include <sys/un.h>
131 #endif
132 ])])# PGAC_STRUCT_SOCKADDR_UN
135 # PGAC_STRUCT_SOCKADDR_STORAGE
136 # ----------------------------
137 # If `struct sockaddr_storage' exists, define HAVE_STRUCT_SOCKADDR_STORAGE.
138 # If it is missing then one could define it.
139 AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE],
140 [AC_CHECK_TYPES([struct sockaddr_storage], [], [],
141 [#include <sys/types.h>
142 #include <sys/socket.h>
143 ])])# PGAC_STRUCT_SOCKADDR_STORAGE
145 # PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
146 # --------------------------------------
147 # Check the members of `struct sockaddr_storage'.  We need to know about
148 # ss_family and ss_len.  (Some platforms follow RFC 2553 and call them
149 # __ss_family and __ss_len.)  We also check struct sockaddr's sa_len;
150 # if we have to define our own `struct sockaddr_storage', this tells us
151 # whether we need to provide an ss_len field.
152 AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS],
153 [AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family,
154                    struct sockaddr_storage.__ss_family,
155                    struct sockaddr_storage.ss_len,
156                    struct sockaddr_storage.__ss_len,
157                    struct sockaddr.sa_len], [], [],
158 [#include <sys/types.h>
159 #include <sys/socket.h>
160 ])])# PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
163 # PGAC_STRUCT_ADDRINFO
164 # -----------------------
165 # If `struct addrinfo' exists, define HAVE_STRUCT_ADDRINFO.
166 AC_DEFUN([PGAC_STRUCT_ADDRINFO],
167 [AC_CHECK_TYPES([struct addrinfo], [], [],
168 [#include <sys/types.h>
169 #include <sys/socket.h>
170 #include <netdb.h>
171 ])])# PGAC_STRUCT_ADDRINFO
174 # PGAC_TYPE_LOCALE_T
175 # ------------------
176 # Check for the locale_t type and find the right header file.  macOS
177 # needs xlocale.h; standard is locale.h, but glibc also has an
178 # xlocale.h file that we should not use.
180 AC_DEFUN([PGAC_TYPE_LOCALE_T],
181 [AC_CACHE_CHECK([for locale_t], pgac_cv_type_locale_t,
182 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
183 [#include <locale.h>
184 locale_t x;],
185 [])],
186 [pgac_cv_type_locale_t=yes],
187 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
188 [#include <xlocale.h>
189 locale_t x;],
190 [])],
191 [pgac_cv_type_locale_t='yes (in xlocale.h)'],
192 [pgac_cv_type_locale_t=no])])])
193 if test "$pgac_cv_type_locale_t" != no; then
194   AC_DEFINE(HAVE_LOCALE_T, 1,
195             [Define to 1 if the system has the type `locale_t'.])
197 if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
198   AC_DEFINE(LOCALE_T_IN_XLOCALE, 1,
199             [Define to 1 if `locale_t' requires <xlocale.h>.])
200 fi])# PGAC_TYPE_LOCALE_T
203 # PGAC_FUNC_WCSTOMBS_L
204 # --------------------
205 # Try to find a declaration for wcstombs_l().  It might be in stdlib.h
206 # (following the POSIX requirement for wcstombs()), or in locale.h, or in
207 # xlocale.h.  If it's in the latter, define WCSTOMBS_L_IN_XLOCALE.
209 AC_DEFUN([PGAC_FUNC_WCSTOMBS_L],
210 [AC_CACHE_CHECK([for wcstombs_l declaration], pgac_cv_func_wcstombs_l,
211 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
212 [#include <stdlib.h>
213 #include <locale.h>],
214 [#ifndef wcstombs_l
215 (void) wcstombs_l;
216 #endif])],
217 [pgac_cv_func_wcstombs_l='yes'],
218 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
219 [#include <stdlib.h>
220 #include <locale.h>
221 #include <xlocale.h>],
222 [#ifndef wcstombs_l
223 (void) wcstombs_l;
224 #endif])],
225 [pgac_cv_func_wcstombs_l='yes (in xlocale.h)'],
226 [pgac_cv_func_wcstombs_l='no'])])])
227 if test "$pgac_cv_func_wcstombs_l" = 'yes (in xlocale.h)'; then
228   AC_DEFINE(WCSTOMBS_L_IN_XLOCALE, 1,
229             [Define to 1 if `wcstombs_l' requires <xlocale.h>.])
230 fi])# PGAC_FUNC_WCSTOMBS_L