2000-06-11 19:40:09 +08:00
|
|
|
# Macros that test various C library quirks
|
2010-09-21 04:08:53 +08:00
|
|
|
# config/c-library.m4
|
2000-06-11 19:40:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
# PGAC_VAR_INT_TIMEZONE
|
|
|
|
# ---------------------
|
|
|
|
# Check if the global variable `timezone' exists. If so, define
|
|
|
|
# HAVE_INT_TIMEZONE.
|
|
|
|
AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
|
|
|
|
[AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
|
2015-07-03 00:21:23 +08:00
|
|
|
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>
|
2001-01-11 01:07:18 +08:00
|
|
|
int res;],
|
2004-09-09 03:43:12 +08:00
|
|
|
[#ifndef __CYGWIN__
|
|
|
|
res = timezone / 60;
|
|
|
|
#else
|
|
|
|
res = _timezone / 60;
|
2015-07-03 00:21:23 +08:00
|
|
|
#endif])],
|
2000-06-11 19:40:09 +08:00
|
|
|
[pgac_cv_var_int_timezone=yes],
|
|
|
|
[pgac_cv_var_int_timezone=no])])
|
|
|
|
if test x"$pgac_cv_var_int_timezone" = xyes ; then
|
2013-06-16 02:11:43 +08:00
|
|
|
AC_DEFINE(HAVE_INT_TIMEZONE, 1,
|
|
|
|
[Define to 1 if you have the global variable 'int timezone'.])
|
2000-06-11 19:40:09 +08:00
|
|
|
fi])# PGAC_VAR_INT_TIMEZONE
|
|
|
|
|
|
|
|
|
2003-05-23 00:39:30 +08:00
|
|
|
# PGAC_STRUCT_TIMEZONE
|
|
|
|
# ------------------
|
|
|
|
# Figure out how to get the current timezone. If `struct tm' has a
|
|
|
|
# `tm_zone' member, define `HAVE_TM_ZONE'. Also, if the
|
|
|
|
# external array `tzname' is found, define `HAVE_TZNAME'.
|
|
|
|
# This is the same as the standard macro AC_STRUCT_TIMEZONE, except that
|
|
|
|
# tzname[] is checked for regardless of whether we find tm_zone.
|
|
|
|
AC_DEFUN([PGAC_STRUCT_TIMEZONE],
|
2012-05-15 11:06:48 +08:00
|
|
|
[AC_REQUIRE([AC_STRUCT_TM])dnl
|
|
|
|
AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
|
2003-05-23 00:39:30 +08:00
|
|
|
#include <$ac_cv_struct_tm>
|
|
|
|
])
|
|
|
|
if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
|
|
|
|
AC_DEFINE(HAVE_TM_ZONE, 1,
|
|
|
|
[Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
|
|
|
|
`HAVE_STRUCT_TM_TM_ZONE' instead.])
|
|
|
|
fi
|
|
|
|
AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
|
2015-07-03 00:21:23 +08:00
|
|
|
[AC_LINK_IFELSE([AC_LANG_PROGRAM(
|
|
|
|
[[#include <time.h>
|
2003-05-23 00:39:30 +08:00
|
|
|
#ifndef tzname /* For SGI. */
|
|
|
|
extern char *tzname[]; /* RS6000 and others reject char **tzname. */
|
|
|
|
#endif
|
2015-07-03 00:21:23 +08:00
|
|
|
]],
|
|
|
|
[atoi(*tzname);])], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
|
2003-05-23 00:39:30 +08:00
|
|
|
if test $ac_cv_var_tzname = yes; then
|
|
|
|
AC_DEFINE(HAVE_TZNAME, 1,
|
|
|
|
[Define to 1 if you have the external array `tzname'.])
|
|
|
|
fi
|
|
|
|
])# PGAC_STRUCT_TIMEZONE
|
|
|
|
|
|
|
|
|
2000-06-11 19:40:09 +08:00
|
|
|
# PGAC_FUNC_GETTIMEOFDAY_1ARG
|
|
|
|
# ---------------------------
|
|
|
|
# Check if gettimeofday() has only one arguments. (Normal is two.)
|
|
|
|
# If so, define GETTIMEOFDAY_1ARG.
|
|
|
|
AC_DEFUN([PGAC_FUNC_GETTIMEOFDAY_1ARG],
|
|
|
|
[AC_CACHE_CHECK(whether gettimeofday takes only one argument,
|
|
|
|
pgac_cv_func_gettimeofday_1arg,
|
2015-07-03 00:21:23 +08:00
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/time.h>],
|
2000-06-11 19:40:09 +08:00
|
|
|
[struct timeval *tp;
|
|
|
|
struct timezone *tzp;
|
2015-07-03 00:21:23 +08:00
|
|
|
gettimeofday(tp,tzp);])],
|
2000-06-11 19:40:09 +08:00
|
|
|
[pgac_cv_func_gettimeofday_1arg=no],
|
|
|
|
[pgac_cv_func_gettimeofday_1arg=yes])])
|
|
|
|
if test x"$pgac_cv_func_gettimeofday_1arg" = xyes ; then
|
2013-06-16 02:11:43 +08:00
|
|
|
AC_DEFINE(GETTIMEOFDAY_1ARG, 1,
|
|
|
|
[Define to 1 if gettimeofday() takes only 1 argument.])
|
2003-04-07 06:45:23 +08:00
|
|
|
fi
|
|
|
|
AH_VERBATIM(GETTIMEOFDAY_1ARG_,
|
|
|
|
[@%:@ifdef GETTIMEOFDAY_1ARG
|
|
|
|
@%:@ define gettimeofday(a,b) gettimeofday(a)
|
|
|
|
@%:@endif])dnl
|
|
|
|
])# PGAC_FUNC_GETTIMEOFDAY_1ARG
|
2000-06-11 19:40:09 +08:00
|
|
|
|
|
|
|
|
2004-06-08 06:39:45 +08:00
|
|
|
# PGAC_FUNC_STRERROR_R_INT
|
|
|
|
# ---------------------------
|
|
|
|
# Check if strerror_r() returns an int (SUSv3) rather than a char * (GNU libc)
|
|
|
|
# If so, define STRERROR_R_INT
|
|
|
|
AC_DEFUN([PGAC_FUNC_STRERROR_R_INT],
|
|
|
|
[AC_CACHE_CHECK(whether strerror_r returns int,
|
2008-08-21 21:53:28 +08:00
|
|
|
pgac_cv_func_strerror_r_int,
|
2015-07-03 00:21:23 +08:00
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <string.h>],
|
2004-12-17 01:48:29 +08:00
|
|
|
[#ifndef _AIX
|
|
|
|
int strerror_r(int, char *, size_t);
|
|
|
|
#else
|
|
|
|
/* Older AIX has 'int' for the third argument so we don't test the args. */
|
|
|
|
int strerror_r();
|
2015-07-03 00:21:23 +08:00
|
|
|
#endif])],
|
2008-08-21 21:53:28 +08:00
|
|
|
[pgac_cv_func_strerror_r_int=yes],
|
|
|
|
[pgac_cv_func_strerror_r_int=no])])
|
|
|
|
if test x"$pgac_cv_func_strerror_r_int" = xyes ; then
|
2013-06-16 02:11:43 +08:00
|
|
|
AC_DEFINE(STRERROR_R_INT, 1,
|
|
|
|
[Define to 1 if strerror_r() returns a int.])
|
2004-06-08 06:39:45 +08:00
|
|
|
fi
|
|
|
|
])# PGAC_FUNC_STRERROR_R_INT
|
|
|
|
|
|
|
|
|
2000-06-11 19:40:09 +08:00
|
|
|
# PGAC_UNION_SEMUN
|
|
|
|
# ----------------
|
|
|
|
# Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
|
|
|
|
# If it doesn't then one could define it as
|
|
|
|
# union semun { int val; struct semid_ds *buf; unsigned short *array; }
|
|
|
|
AC_DEFUN([PGAC_UNION_SEMUN],
|
2002-03-30 08:59:52 +08:00
|
|
|
[AC_CHECK_TYPES([union semun], [], [],
|
2002-03-30 01:32:55 +08:00
|
|
|
[#include <sys/types.h>
|
2000-06-11 19:40:09 +08:00
|
|
|
#include <sys/ipc.h>
|
2002-03-30 01:32:55 +08:00
|
|
|
#include <sys/sem.h>])])# PGAC_UNION_SEMUN
|
2000-06-11 19:40:09 +08:00
|
|
|
|
|
|
|
|
2000-09-27 23:17:57 +08:00
|
|
|
# PGAC_STRUCT_SOCKADDR_UN
|
|
|
|
# -----------------------
|
2003-06-12 15:36:51 +08:00
|
|
|
# If `struct sockaddr_un' exists, define HAVE_UNIX_SOCKETS.
|
|
|
|
# (Requires test for <sys/un.h>!)
|
2000-09-27 23:17:57 +08:00
|
|
|
AC_DEFUN([PGAC_STRUCT_SOCKADDR_UN],
|
2012-05-15 03:51:21 +08:00
|
|
|
[AC_CHECK_TYPE([struct sockaddr_un], [AC_DEFINE(HAVE_UNIX_SOCKETS, 1, [Define to 1 if you have unix sockets.])], [],
|
2002-03-30 01:32:55 +08:00
|
|
|
[#include <sys/types.h>
|
2000-10-02 11:58:31 +08:00
|
|
|
#ifdef HAVE_SYS_UN_H
|
2000-09-27 23:17:57 +08:00
|
|
|
#include <sys/un.h>
|
2002-03-30 01:32:55 +08:00
|
|
|
#endif
|
|
|
|
])])# PGAC_STRUCT_SOCKADDR_UN
|
2000-09-27 23:17:57 +08:00
|
|
|
|
|
|
|
|
2003-06-12 15:36:51 +08:00
|
|
|
# PGAC_STRUCT_SOCKADDR_STORAGE
|
|
|
|
# ----------------------------
|
2003-07-24 07:30:41 +08:00
|
|
|
# If `struct sockaddr_storage' exists, define HAVE_STRUCT_SOCKADDR_STORAGE.
|
|
|
|
# If it is missing then one could define it.
|
2003-06-12 15:36:51 +08:00
|
|
|
AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE],
|
|
|
|
[AC_CHECK_TYPES([struct sockaddr_storage], [], [],
|
2003-06-13 00:05:10 +08:00
|
|
|
[#include <sys/types.h>
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
2003-06-12 15:36:51 +08:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
|
|
|
])])# PGAC_STRUCT_SOCKADDR_STORAGE
|
|
|
|
|
2003-07-24 07:30:41 +08:00
|
|
|
# PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
|
2003-06-24 07:52:00 +08:00
|
|
|
# --------------------------------------
|
2003-07-24 07:30:41 +08:00
|
|
|
# Check the members of `struct sockaddr_storage'. We need to know about
|
|
|
|
# ss_family and ss_len. (Some platforms follow RFC 2553 and call them
|
|
|
|
# __ss_family and __ss_len.) We also check struct sockaddr's sa_len;
|
|
|
|
# if we have to define our own `struct sockaddr_storage', this tells us
|
|
|
|
# whether we need to provide an ss_len field.
|
|
|
|
AC_DEFUN([PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS],
|
2003-06-24 07:52:00 +08:00
|
|
|
[AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family,
|
2003-07-24 07:30:41 +08:00
|
|
|
struct sockaddr_storage.__ss_family,
|
|
|
|
struct sockaddr_storage.ss_len,
|
|
|
|
struct sockaddr_storage.__ss_len,
|
|
|
|
struct sockaddr.sa_len], [], [],
|
2003-06-24 07:52:00 +08:00
|
|
|
[#include <sys/types.h>
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
2003-07-24 07:30:41 +08:00
|
|
|
])])# PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
|
2003-06-24 07:52:00 +08:00
|
|
|
|
2003-06-12 15:36:51 +08:00
|
|
|
|
2003-04-02 08:49:28 +08:00
|
|
|
# PGAC_STRUCT_ADDRINFO
|
|
|
|
# -----------------------
|
|
|
|
# If `struct addrinfo' exists, define HAVE_STRUCT_ADDRINFO.
|
|
|
|
AC_DEFUN([PGAC_STRUCT_ADDRINFO],
|
|
|
|
[AC_CHECK_TYPES([struct addrinfo], [], [],
|
2003-04-13 07:25:42 +08:00
|
|
|
[#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
2003-04-02 08:49:28 +08:00
|
|
|
#include <netdb.h>
|
|
|
|
])])# PGAC_STRUCT_ADDRINFO
|
|
|
|
|
|
|
|
|
2014-08-21 14:56:44 +08:00
|
|
|
# PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
|
2003-01-29 05:57:12 +08:00
|
|
|
# ---------------------------------------
|
2014-08-21 14:56:44 +08:00
|
|
|
# Determine which length modifier snprintf uses for long long int. We
|
|
|
|
# handle ll, q, and I64. The result is in shell variable
|
|
|
|
# LONG_LONG_INT_MODIFIER.
|
2004-10-05 02:14:18 +08:00
|
|
|
#
|
|
|
|
# MinGW uses '%I64d', though gcc throws an warning with -Wall,
|
|
|
|
# while '%lld' doesn't generate a warning, but doesn't work.
|
|
|
|
#
|
2014-08-21 14:56:44 +08:00
|
|
|
AC_DEFUN([PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER],
|
|
|
|
[AC_MSG_CHECKING([snprintf length modifier for long long int])
|
|
|
|
AC_CACHE_VAL(pgac_cv_snprintf_long_long_int_modifier,
|
|
|
|
[for pgac_modifier in 'll' 'q' 'I64'; do
|
2015-07-03 00:21:23 +08:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
|
2004-12-17 01:48:29 +08:00
|
|
|
typedef long long int ac_int64;
|
2014-08-21 14:56:44 +08:00
|
|
|
#define INT64_FORMAT "%${pgac_modifier}d"
|
2003-01-29 05:57:12 +08:00
|
|
|
|
2004-12-17 01:48:29 +08:00
|
|
|
ac_int64 a = 20000001;
|
|
|
|
ac_int64 b = 40000005;
|
2003-01-29 05:57:12 +08:00
|
|
|
|
|
|
|
int does_int64_snprintf_work()
|
|
|
|
{
|
2004-12-17 01:48:29 +08:00
|
|
|
ac_int64 c;
|
2003-01-29 05:57:12 +08:00
|
|
|
char buf[100];
|
|
|
|
|
2004-12-17 01:48:29 +08:00
|
|
|
if (sizeof(ac_int64) != 8)
|
2003-01-29 05:57:12 +08:00
|
|
|
return 0; /* doesn't look like the right size */
|
|
|
|
|
|
|
|
c = a * b;
|
|
|
|
snprintf(buf, 100, INT64_FORMAT, c);
|
|
|
|
if (strcmp(buf, "800000140000005") != 0)
|
|
|
|
return 0; /* either multiply or snprintf is busted */
|
|
|
|
return 1;
|
|
|
|
}
|
2016-08-31 00:00:00 +08:00
|
|
|
|
|
|
|
int
|
2003-01-29 05:57:12 +08:00
|
|
|
main() {
|
2016-08-31 00:00:00 +08:00
|
|
|
return (! does_int64_snprintf_work());
|
2015-07-03 00:21:23 +08:00
|
|
|
}]])],
|
2014-08-21 14:56:44 +08:00
|
|
|
[pgac_cv_snprintf_long_long_int_modifier=$pgac_modifier; break],
|
2003-01-29 05:57:12 +08:00
|
|
|
[],
|
2014-08-21 14:56:44 +08:00
|
|
|
[pgac_cv_snprintf_long_long_int_modifier=cross; break])
|
2003-01-29 05:57:12 +08:00
|
|
|
done])dnl AC_CACHE_VAL
|
|
|
|
|
2014-08-21 14:56:44 +08:00
|
|
|
LONG_LONG_INT_MODIFIER=''
|
2003-01-29 05:57:12 +08:00
|
|
|
|
2014-08-21 14:56:44 +08:00
|
|
|
case $pgac_cv_snprintf_long_long_int_modifier in
|
2003-01-29 05:57:12 +08:00
|
|
|
cross) AC_MSG_RESULT([cannot test (not on host machine)]);;
|
2014-08-21 14:56:44 +08:00
|
|
|
?*) AC_MSG_RESULT([$pgac_cv_snprintf_long_long_int_modifier])
|
|
|
|
LONG_LONG_INT_MODIFIER=$pgac_cv_snprintf_long_long_int_modifier;;
|
2003-01-29 05:57:12 +08:00
|
|
|
*) AC_MSG_RESULT(none);;
|
2014-08-21 14:56:44 +08:00
|
|
|
esac])# PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
|
2005-02-22 11:56:22 +08:00
|
|
|
|
|
|
|
|
2014-01-24 06:18:23 +08:00
|
|
|
# PGAC_FUNC_SNPRINTF_ARG_CONTROL
|
2005-02-22 11:56:22 +08:00
|
|
|
# ---------------------------------------
|
2014-01-24 06:18:23 +08:00
|
|
|
# Determine if snprintf supports %1$ argument selection, e.g. %5$ selects
|
|
|
|
# the fifth argument after the printf format string.
|
2005-02-22 11:56:22 +08:00
|
|
|
# This is not in the C99 standard, but in the Single Unix Specification (SUS).
|
2005-02-24 09:34:45 +08:00
|
|
|
# It is used in our language translation strings.
|
2005-02-22 11:56:22 +08:00
|
|
|
#
|
2014-01-24 06:18:23 +08:00
|
|
|
AC_DEFUN([PGAC_FUNC_SNPRINTF_ARG_CONTROL],
|
|
|
|
[AC_MSG_CHECKING([whether snprintf supports argument control])
|
|
|
|
AC_CACHE_VAL(pgac_cv_snprintf_arg_control,
|
2015-07-03 00:21:23 +08:00
|
|
|
[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
|
2005-02-24 09:34:45 +08:00
|
|
|
#include <string.h>
|
2005-02-22 11:56:22 +08:00
|
|
|
|
2005-02-24 09:34:45 +08:00
|
|
|
int main()
|
2005-02-22 11:56:22 +08:00
|
|
|
{
|
|
|
|
char buf[100];
|
|
|
|
|
|
|
|
/* can it swap arguments? */
|
2005-02-24 09:34:45 +08:00
|
|
|
snprintf(buf, 100, "%2\$d %1\$d", 3, 4);
|
|
|
|
if (strcmp(buf, "4 3") != 0)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
2015-07-03 00:21:23 +08:00
|
|
|
}]])],
|
2014-01-24 06:18:23 +08:00
|
|
|
[pgac_cv_snprintf_arg_control=yes],
|
|
|
|
[pgac_cv_snprintf_arg_control=no],
|
|
|
|
[pgac_cv_snprintf_arg_control=cross])
|
2005-02-22 11:56:22 +08:00
|
|
|
])dnl AC_CACHE_VAL
|
2014-01-24 06:18:23 +08:00
|
|
|
AC_MSG_RESULT([$pgac_cv_snprintf_arg_control])
|
|
|
|
])# PGAC_FUNC_SNPRINTF_ARG_CONTROL
|
|
|
|
|
|
|
|
# PGAC_FUNC_SNPRINTF_SIZE_T_SUPPORT
|
|
|
|
# ---------------------------------------
|
|
|
|
# Determine if snprintf supports the z length modifier for printing
|
|
|
|
# size_t-sized variables. That's supported by C99 and POSIX but not
|
|
|
|
# all platforms play ball, so we must test whether it's working.
|
|
|
|
#
|
|
|
|
AC_DEFUN([PGAC_FUNC_SNPRINTF_SIZE_T_SUPPORT],
|
|
|
|
[AC_MSG_CHECKING([whether snprintf supports the %z modifier])
|
|
|
|
AC_CACHE_VAL(pgac_cv_snprintf_size_t_support,
|
2015-07-03 00:21:23 +08:00
|
|
|
[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
|
2014-01-24 06:18:23 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
char bufz[100];
|
|
|
|
char buf64[100];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print the largest unsigned number fitting in a size_t using both %zu
|
|
|
|
* and the previously-determined format for 64-bit integers. Note that
|
|
|
|
* we don't run this code unless we know snprintf handles 64-bit ints.
|
|
|
|
*/
|
|
|
|
bufz[0] = '\0'; /* in case snprintf fails to emit anything */
|
|
|
|
snprintf(bufz, sizeof(bufz), "%zu", ~((size_t) 0));
|
2014-09-18 15:59:10 +08:00
|
|
|
snprintf(buf64, sizeof(buf64), "%" INT64_MODIFIER "u",
|
|
|
|
(unsigned PG_INT64_TYPE) ~((size_t) 0));
|
2014-01-24 06:18:23 +08:00
|
|
|
if (strcmp(bufz, buf64) != 0)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
2015-07-03 00:21:23 +08:00
|
|
|
}]])],
|
2014-01-24 06:18:23 +08:00
|
|
|
[pgac_cv_snprintf_size_t_support=yes],
|
|
|
|
[pgac_cv_snprintf_size_t_support=no],
|
|
|
|
[pgac_cv_snprintf_size_t_support=cross])
|
|
|
|
])dnl AC_CACHE_VAL
|
|
|
|
AC_MSG_RESULT([$pgac_cv_snprintf_size_t_support])
|
|
|
|
])# PGAC_FUNC_SNPRINTF_SIZE_T_SUPPORT
|
2011-02-09 05:04:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
# PGAC_TYPE_LOCALE_T
|
|
|
|
# ------------------
|
Refer to OS X as "macOS", except for the port name which is still "darwin".
We weren't terribly consistent about whether to call Apple's OS "OS X"
or "Mac OS X", and the former is probably confusing to people who aren't
Apple users. Now that Apple has rebranded it "macOS", follow their lead
to establish a consistent naming pattern. Also, avoid the use of the
ancient project name "Darwin", except as the port code name which does not
seem desirable to change. (In short, this patch touches documentation and
comments, but no actual code.)
I didn't touch contrib/start-scripts/osx/, either. I suspect those are
obsolete and due for a rewrite, anyway.
I dithered about whether to apply this edit to old release notes, but
those were responsible for quite a lot of the inconsistencies, so I ended
up changing them too. Anyway, Apple's being ahistorical about this,
so why shouldn't we be?
2016-09-26 03:40:57 +08:00
|
|
|
# Check for the locale_t type and find the right header file. macOS
|
|
|
|
# needs xlocale.h; standard is locale.h, but glibc also has an
|
2011-02-09 05:04:18 +08:00
|
|
|
# xlocale.h file that we should not use.
|
|
|
|
#
|
|
|
|
AC_DEFUN([PGAC_TYPE_LOCALE_T],
|
|
|
|
[AC_CACHE_CHECK([for locale_t], pgac_cv_type_locale_t,
|
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
|
|
|
[#include <locale.h>
|
|
|
|
locale_t x;],
|
|
|
|
[])],
|
|
|
|
[pgac_cv_type_locale_t=yes],
|
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
|
|
|
[#include <xlocale.h>
|
|
|
|
locale_t x;],
|
|
|
|
[])],
|
|
|
|
[pgac_cv_type_locale_t='yes (in xlocale.h)'],
|
|
|
|
[pgac_cv_type_locale_t=no])])])
|
|
|
|
if test "$pgac_cv_type_locale_t" != no; then
|
|
|
|
AC_DEFINE(HAVE_LOCALE_T, 1,
|
|
|
|
[Define to 1 if the system has the type `locale_t'.])
|
|
|
|
fi
|
|
|
|
if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
|
|
|
|
AC_DEFINE(LOCALE_T_IN_XLOCALE, 1,
|
|
|
|
[Define to 1 if `locale_t' requires <xlocale.h>.])
|
Cope if platform declares mbstowcs_l(), but not locale_t, in <xlocale.h>.
Previously, we included <xlocale.h> only if necessary to get the definition
of type locale_t. According to notes in PGAC_TYPE_LOCALE_T, this is
important because on some versions of glibc that file supplies an
incompatible declaration of locale_t. (This info may be obsolete, because
on my RHEL6 box that seems to be the *only* definition of locale_t; but
there may still be glibc's in the wild for which it's a live concern.)
It turns out though that on FreeBSD and maybe other BSDen, you can get
locale_t from stdlib.h or locale.h but mbstowcs_l() and friends only from
<xlocale.h>. This was leaving us compiling calls to mbstowcs_l() and
friends with no visible prototype, which causes a warning and could
possibly cause actual trouble, since it's not declared to return int.
Hence, adjust the configure checks so that we'll include <xlocale.h>
either if it's necessary to get type locale_t or if it's necessary to
get a declaration of mbstowcs_l().
Report and patch by Aleksander Alekseev, somewhat whacked around by me.
Back-patch to all supported branches, since we have been using
mbstowcs_l() since 9.1.
2016-03-16 01:19:57 +08:00
|
|
|
fi])# PGAC_TYPE_LOCALE_T
|
|
|
|
|
|
|
|
|
|
|
|
# PGAC_FUNC_WCSTOMBS_L
|
|
|
|
# --------------------
|
|
|
|
# Try to find a declaration for wcstombs_l(). It might be in stdlib.h
|
|
|
|
# (following the POSIX requirement for wcstombs()), or in locale.h, or in
|
|
|
|
# xlocale.h. If it's in the latter, define WCSTOMBS_L_IN_XLOCALE.
|
|
|
|
#
|
|
|
|
AC_DEFUN([PGAC_FUNC_WCSTOMBS_L],
|
|
|
|
[AC_CACHE_CHECK([for wcstombs_l declaration], pgac_cv_func_wcstombs_l,
|
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
|
|
|
[#include <stdlib.h>
|
|
|
|
#include <locale.h>],
|
|
|
|
[#ifndef wcstombs_l
|
|
|
|
(void) wcstombs_l;
|
|
|
|
#endif])],
|
|
|
|
[pgac_cv_func_wcstombs_l='yes'],
|
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
|
|
|
[#include <stdlib.h>
|
|
|
|
#include <locale.h>
|
|
|
|
#include <xlocale.h>],
|
|
|
|
[#ifndef wcstombs_l
|
|
|
|
(void) wcstombs_l;
|
|
|
|
#endif])],
|
|
|
|
[pgac_cv_func_wcstombs_l='yes (in xlocale.h)'],
|
|
|
|
[pgac_cv_func_wcstombs_l='no'])])])
|
|
|
|
if test "$pgac_cv_func_wcstombs_l" = 'yes (in xlocale.h)'; then
|
|
|
|
AC_DEFINE(WCSTOMBS_L_IN_XLOCALE, 1,
|
|
|
|
[Define to 1 if `wcstombs_l' requires <xlocale.h>.])
|
|
|
|
fi])# PGAC_FUNC_WCSTOMBS_L
|