1 # Macros that test various C library quirks
2 # $Header: /cvsroot/pgsql/config/c-library.m4,v 1.22 2003/06/23 23:51:59 momjian Exp $
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_TRY_LINK([#include <time.h>
13 [res = timezone / 60;],
14 [pgac_cv_var_int_timezone=yes],
15 [pgac_cv_var_int_timezone=no])])
16 if test x"$pgac_cv_var_int_timezone" = xyes ; then
17 AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global variable 'int timezone'.])
18 fi])# PGAC_VAR_INT_TIMEZONE
21 # PGAC_STRUCT_TIMEZONE
23 # Figure out how to get the current timezone. If `struct tm' has a
24 # `tm_zone' member, define `HAVE_TM_ZONE'. Also, if the
25 # external array `tzname' is found, define `HAVE_TZNAME'.
26 # This is the same as the standard macro AC_STRUCT_TIMEZONE, except that
27 # tzname[] is checked for regardless of whether we find tm_zone.
28 AC_DEFUN([PGAC_STRUCT_TIMEZONE],
29 [AC_REQUIRE([AC_STRUCT_TM])dnl
30 AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
31 #include <$ac_cv_struct_tm>
33 if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
34 AC_DEFINE(HAVE_TM_ZONE, 1,
35 [Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
36 `HAVE_STRUCT_TM_TM_ZONE' instead.])
38 AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
41 #ifndef tzname /* For SGI. */
42 extern char *tzname[]; /* RS6000 and others reject char **tzname. */
45 [atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
46 if test $ac_cv_var_tzname = yes; then
47 AC_DEFINE(HAVE_TZNAME, 1,
48 [Define to 1 if you have the external array `tzname'.])
50 ])# PGAC_STRUCT_TIMEZONE
53 # PGAC_FUNC_GETTIMEOFDAY_1ARG
54 # ---------------------------
55 # Check if gettimeofday() has only one arguments. (Normal is two.)
56 # If so, define GETTIMEOFDAY_1ARG.
57 AC_DEFUN([PGAC_FUNC_GETTIMEOFDAY_1ARG],
58 [AC_CACHE_CHECK(whether gettimeofday takes only one argument,
59 pgac_cv_func_gettimeofday_1arg,
60 [AC_TRY_COMPILE([#include <sys/time.h>],
63 gettimeofday(tp,tzp);],
64 [pgac_cv_func_gettimeofday_1arg=no],
65 [pgac_cv_func_gettimeofday_1arg=yes])])
66 if test x"$pgac_cv_func_gettimeofday_1arg" = xyes ; then
67 AC_DEFINE(GETTIMEOFDAY_1ARG,, [Define to 1 if gettimeofday() takes only 1 argument.])
69 AH_VERBATIM(GETTIMEOFDAY_1ARG_,
70 [@%:@ifdef GETTIMEOFDAY_1ARG
71 @%:@ define gettimeofday(a,b) gettimeofday(a)
73 ])# PGAC_FUNC_GETTIMEOFDAY_1ARG
78 # Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
79 # If it doesn't then one could define it as
80 # union semun { int val; struct semid_ds *buf; unsigned short *array; }
81 AC_DEFUN([PGAC_UNION_SEMUN],
82 [AC_CHECK_TYPES([union semun], [], [],
83 [#include <sys/types.h>
85 #include <sys/sem.h>])])# PGAC_UNION_SEMUN
88 # PGAC_STRUCT_SOCKADDR_UN
89 # -----------------------
90 # If `struct sockaddr_un' exists, define HAVE_UNIX_SOCKETS.
91 # (Requires test for <sys/un.h>!)
92 AC_DEFUN([PGAC_STRUCT_SOCKADDR_UN],
93 [AC_CHECK_TYPES([struct sockaddr_un], [AC_DEFINE(HAVE_UNIX_SOCKETS, 1, [Define to 1 if you have unix sockets.])], [],
94 [#include <sys/types.h>
98 ])])# PGAC_STRUCT_SOCKADDR_UN
101 # PGAC_STRUCT_SOCKADDR_STORAGE
102 # ----------------------------
103 # If `struct sockaddr_storage' exists, define HAVE_STRUCT_SOCKADDR_STORAGE. If
104 # it is missing then one could define it.
105 AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE],
106 [AC_CHECK_TYPES([struct sockaddr_storage], [], [],
107 [#include <sys/types.h>
108 #ifdef HAVE_SYS_SOCKET_H
109 #include <sys/socket.h>
111 ])])# PGAC_STRUCT_SOCKADDR_STORAGE
113 # PGAC_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
114 # --------------------------------------
115 # This checks if the struct sockaddr has a proper ss_family and not an
116 # __ss_family as rfc2553 defined.
117 AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE_SS_FAMILY],
118 [AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family,
119 struct sockaddr_storage.__ss_family], [], [],
120 [#include <sys/types.h>
121 #ifdef HAVE_SYS_SOCKET_H
122 #include <sys/socket.h>
124 ])])# PGAC_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
127 # PGAC_STRUCT_ADDRINFO
128 # -----------------------
129 # If `struct addrinfo' exists, define HAVE_STRUCT_ADDRINFO.
130 AC_DEFUN([PGAC_STRUCT_ADDRINFO],
131 [AC_CHECK_TYPES([struct addrinfo], [], [],
132 [#include <sys/types.h>
133 #include <sys/socket.h>
135 ])])# PGAC_STRUCT_ADDRINFO
138 # PGAC_FUNC_POSIX_SIGNALS
139 # -----------------------
140 # Check to see if the machine has the POSIX signal interface. Define
141 # HAVE_POSIX_SIGNALS if so. Also set the output variable HAVE_POSIX_SIGNALS
144 # Note that this test only compiles a test program, it doesn't check
145 # whether the routines actually work. If that becomes a problem, make
147 AC_DEFUN([PGAC_FUNC_POSIX_SIGNALS],
148 [AC_CACHE_CHECK(for POSIX signal interface, pgac_cv_func_posix_signals,
149 [AC_TRY_LINK([#include <signal.h>
151 [struct sigaction act, oact;
152 sigemptyset(&act.sa_mask);
153 act.sa_flags = SA_RESTART;
154 sigaction(0, &act, &oact);],
155 [pgac_cv_func_posix_signals=yes],
156 [pgac_cv_func_posix_signals=no])])
157 if test x"$pgac_cv_func_posix_signals" = xyes ; then
158 AC_DEFINE(HAVE_POSIX_SIGNALS,, [Define to 1 if you have the POSIX signal interface.])
160 HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
161 AC_SUBST(HAVE_POSIX_SIGNALS)])# PGAC_FUNC_POSIX_SIGNALS
164 # PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT
165 # ---------------------------------------
166 # Determine which format snprintf uses for long long int. We handle
167 # %lld, %qd, %I64d. The result is in shell variable
168 # LONG_LONG_INT_FORMAT.
169 AC_DEFUN([PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT],
170 [AC_MSG_CHECKING([snprintf format for long long int])
171 AC_CACHE_VAL(pgac_cv_snprintf_long_long_int_format,
172 [for pgac_format in '%lld' '%qd' '%I64d'; do
173 AC_TRY_RUN([#include <stdio.h>
174 typedef long long int int64;
175 #define INT64_FORMAT "$pgac_format"
180 int does_int64_snprintf_work()
185 if (sizeof(int64) != 8)
186 return 0; /* doesn't look like the right size */
189 snprintf(buf, 100, INT64_FORMAT, c);
190 if (strcmp(buf, "800000140000005") != 0)
191 return 0; /* either multiply or snprintf is busted */
195 exit(! does_int64_snprintf_work());
197 [pgac_cv_snprintf_long_long_int_format=$pgac_format; break],
199 [pgac_cv_snprintf_long_long_int_format=cross; break])
200 done])dnl AC_CACHE_VAL
202 LONG_LONG_INT_FORMAT=''
204 case $pgac_cv_snprintf_long_long_int_format in
205 cross) AC_MSG_RESULT([cannot test (not on host machine)]);;
206 ?*) AC_MSG_RESULT([$pgac_cv_snprintf_long_long_int_format])
207 LONG_LONG_INT_FORMAT=$pgac_cv_snprintf_long_long_int_format;;
208 *) AC_MSG_RESULT(none);;
209 esac])# PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT