]> granicus.if.org Git - postgresql/blob - config/c-library.m4
Remove references to sa_family_t, except when SOCKADDR_STORAGE requires
[postgresql] / config / c-library.m4
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 $
3
4
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_TRY_LINK([#include <time.h>
12 int res;],
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
19
20
21 # PGAC_STRUCT_TIMEZONE
22 # ------------------
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>
32 ])
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.])
37 fi
38 AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
39 [AC_TRY_LINK(
40 [#include <time.h>
41 #ifndef tzname /* For SGI.  */
42 extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
43 #endif
44 ],
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'.])
49 fi
50 ])# PGAC_STRUCT_TIMEZONE
51
52
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>],
61 [struct timeval *tp;
62 struct timezone *tzp;
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.])
68 fi
69 AH_VERBATIM(GETTIMEOFDAY_1ARG_,
70 [@%:@ifdef GETTIMEOFDAY_1ARG
71 @%:@ define gettimeofday(a,b) gettimeofday(a)
72 @%:@endif])dnl
73 ])# PGAC_FUNC_GETTIMEOFDAY_1ARG
74
75
76 # PGAC_UNION_SEMUN
77 # ----------------
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>
84 #include <sys/ipc.h>
85 #include <sys/sem.h>])])# PGAC_UNION_SEMUN
86
87
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>
95 #ifdef HAVE_SYS_UN_H
96 #include <sys/un.h>
97 #endif
98 ])])# PGAC_STRUCT_SOCKADDR_UN
99
100
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>
110 #endif
111 ])])# PGAC_STRUCT_SOCKADDR_STORAGE
112
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>
123 #endif
124 ])])# PGAC_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
125
126
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>
134 #include <netdb.h>
135 ])])# PGAC_STRUCT_ADDRINFO
136
137
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
142 # to yes or no.
143 #
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
146 # a fancier check.
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>
150 ],
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.])
159 fi
160 HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
161 AC_SUBST(HAVE_POSIX_SIGNALS)])# PGAC_FUNC_POSIX_SIGNALS
162
163
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"
176
177 int64 a = 20000001;
178 int64 b = 40000005;
179
180 int does_int64_snprintf_work()
181 {
182   int64 c;
183   char buf[100];
184
185   if (sizeof(int64) != 8)
186     return 0;                   /* doesn't look like the right size */
187
188   c = a * b;
189   snprintf(buf, 100, INT64_FORMAT, c);
190   if (strcmp(buf, "800000140000005") != 0)
191     return 0;                   /* either multiply or snprintf is busted */
192   return 1;
193 }
194 main() {
195   exit(! does_int64_snprintf_work());
196 }],
197 [pgac_cv_snprintf_long_long_int_format=$pgac_format; break],
198 [],
199 [pgac_cv_snprintf_long_long_int_format=cross; break])
200 done])dnl AC_CACHE_VAL
201
202 LONG_LONG_INT_FORMAT=''
203
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