Skip to content

Commit 9c2a6c5

Browse files
committed
Simplify checking for xlocale.h
Instead of XXX_IN_XLOCALE_H for several features XXX, let's just include <xlocale.h> if HAVE_XLOCALE_H. The reason for the extra complication was apparently that some old glibc systems also had an <xlocale.h>, and you weren't supposed to include it directly, but it's gone now (as far as I can tell it was harmless to do so anyway). Author: Thomas Munro <thomas.munro@gmail.com> Discussion: https://postgr.es/m/CWZBBRR6YA8D.8EHMDRGLCKCD%40neon.tech
1 parent ee48591 commit 9c2a6c5

File tree

9 files changed

+9
-209
lines changed

9 files changed

+9
-209
lines changed

config/c-library.m4

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -81,58 +81,3 @@ AC_DEFUN([PGAC_STRUCT_SOCKADDR_SA_LEN],
8181
[#include <sys/types.h>
8282
#include <sys/socket.h>
8383
])])# PGAC_STRUCT_SOCKADDR_MEMBERS
84-
85-
86-
# PGAC_TYPE_LOCALE_T
87-
# ------------------
88-
# Check for the locale_t type and find the right header file. macOS
89-
# needs xlocale.h; standard is locale.h, but glibc <= 2.25 also had an
90-
# xlocale.h file that we should not use, so we check the standard
91-
# header first.
92-
AC_DEFUN([PGAC_TYPE_LOCALE_T],
93-
[AC_CACHE_CHECK([for locale_t], pgac_cv_type_locale_t,
94-
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
95-
[#include <locale.h>
96-
locale_t x;],
97-
[])],
98-
[pgac_cv_type_locale_t=yes],
99-
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
100-
[#include <xlocale.h>
101-
locale_t x;],
102-
[])],
103-
[pgac_cv_type_locale_t='yes (in xlocale.h)'],
104-
[pgac_cv_type_locale_t=no])])])
105-
if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
106-
AC_DEFINE(LOCALE_T_IN_XLOCALE, 1,
107-
[Define to 1 if `locale_t' requires <xlocale.h>.])
108-
fi])# PGAC_TYPE_LOCALE_T
109-
110-
111-
# PGAC_FUNC_WCSTOMBS_L
112-
# --------------------
113-
# Try to find a declaration for wcstombs_l(). It might be in stdlib.h
114-
# (following the POSIX requirement for wcstombs()), or in locale.h, or in
115-
# xlocale.h. If it's in the latter, define WCSTOMBS_L_IN_XLOCALE.
116-
#
117-
AC_DEFUN([PGAC_FUNC_WCSTOMBS_L],
118-
[AC_CACHE_CHECK([for wcstombs_l declaration], pgac_cv_func_wcstombs_l,
119-
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
120-
[#include <stdlib.h>
121-
#include <locale.h>],
122-
[#ifndef wcstombs_l
123-
(void) wcstombs_l;
124-
#endif])],
125-
[pgac_cv_func_wcstombs_l='yes'],
126-
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
127-
[#include <stdlib.h>
128-
#include <locale.h>
129-
#include <xlocale.h>],
130-
[#ifndef wcstombs_l
131-
(void) wcstombs_l;
132-
#endif])],
133-
[pgac_cv_func_wcstombs_l='yes (in xlocale.h)'],
134-
[pgac_cv_func_wcstombs_l='no'])])])
135-
if test "$pgac_cv_func_wcstombs_l" = 'yes (in xlocale.h)'; then
136-
AC_DEFINE(WCSTOMBS_L_IN_XLOCALE, 1,
137-
[Define to 1 if `wcstombs_l' requires <xlocale.h>.])
138-
fi])# PGAC_FUNC_WCSTOMBS_L

configure

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -13219,7 +13219,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
1321913219
fi
1322013220

1322113221

13222-
for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h mbarrier.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/ucred.h termios.h ucred.h
13222+
for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h mbarrier.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/ucred.h termios.h ucred.h xlocale.h
1322313223
do :
1322413224
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
1322513225
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -14547,55 +14547,6 @@ _ACEOF
1454714547
fi
1454814548

1454914549

14550-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for locale_t" >&5
14551-
$as_echo_n "checking for locale_t... " >&6; }
14552-
if ${pgac_cv_type_locale_t+:} false; then :
14553-
$as_echo_n "(cached) " >&6
14554-
else
14555-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14556-
/* end confdefs.h. */
14557-
#include <locale.h>
14558-
locale_t x;
14559-
int
14560-
main ()
14561-
{
14562-
14563-
;
14564-
return 0;
14565-
}
14566-
_ACEOF
14567-
if ac_fn_c_try_compile "$LINENO"; then :
14568-
pgac_cv_type_locale_t=yes
14569-
else
14570-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14571-
/* end confdefs.h. */
14572-
#include <xlocale.h>
14573-
locale_t x;
14574-
int
14575-
main ()
14576-
{
14577-
14578-
;
14579-
return 0;
14580-
}
14581-
_ACEOF
14582-
if ac_fn_c_try_compile "$LINENO"; then :
14583-
pgac_cv_type_locale_t='yes (in xlocale.h)'
14584-
else
14585-
pgac_cv_type_locale_t=no
14586-
fi
14587-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14588-
fi
14589-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14590-
fi
14591-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_type_locale_t" >&5
14592-
$as_echo "$pgac_cv_type_locale_t" >&6; }
14593-
if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
14594-
14595-
$as_echo "#define LOCALE_T_IN_XLOCALE 1" >>confdefs.h
14596-
14597-
fi
14598-
1459914550
# MSVC doesn't cope well with defining restrict to __restrict, the
1460014551
# spelling it understands, because it conflicts with
1460114552
# __declspec(restrict). Therefore we define pg_restrict to the
@@ -15082,59 +15033,6 @@ if test x"$pgac_cv_var_int_timezone" = xyes ; then
1508215033

1508315034
$as_echo "#define HAVE_INT_TIMEZONE 1" >>confdefs.h
1508415035

15085-
fi
15086-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wcstombs_l declaration" >&5
15087-
$as_echo_n "checking for wcstombs_l declaration... " >&6; }
15088-
if ${pgac_cv_func_wcstombs_l+:} false; then :
15089-
$as_echo_n "(cached) " >&6
15090-
else
15091-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15092-
/* end confdefs.h. */
15093-
#include <stdlib.h>
15094-
#include <locale.h>
15095-
int
15096-
main ()
15097-
{
15098-
#ifndef wcstombs_l
15099-
(void) wcstombs_l;
15100-
#endif
15101-
;
15102-
return 0;
15103-
}
15104-
_ACEOF
15105-
if ac_fn_c_try_compile "$LINENO"; then :
15106-
pgac_cv_func_wcstombs_l='yes'
15107-
else
15108-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15109-
/* end confdefs.h. */
15110-
#include <stdlib.h>
15111-
#include <locale.h>
15112-
#include <xlocale.h>
15113-
int
15114-
main ()
15115-
{
15116-
#ifndef wcstombs_l
15117-
(void) wcstombs_l;
15118-
#endif
15119-
;
15120-
return 0;
15121-
}
15122-
_ACEOF
15123-
if ac_fn_c_try_compile "$LINENO"; then :
15124-
pgac_cv_func_wcstombs_l='yes (in xlocale.h)'
15125-
else
15126-
pgac_cv_func_wcstombs_l='no'
15127-
fi
15128-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15129-
fi
15130-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15131-
fi
15132-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_func_wcstombs_l" >&5
15133-
$as_echo "$pgac_cv_func_wcstombs_l" >&6; }
15134-
if test "$pgac_cv_func_wcstombs_l" = 'yes (in xlocale.h)'; then
15135-
15136-
$as_echo "#define WCSTOMBS_L_IN_XLOCALE 1" >>confdefs.h
15137-
1513815036
fi
1513915037

1514015038
# Some versions of libedit contain strlcpy(), setproctitle(), and other

configure.ac

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@ AC_CHECK_HEADERS(m4_normalize([
14461446
sys/ucred.h
14471447
termios.h
14481448
ucred.h
1449+
xlocale.h
14491450
]))
14501451

14511452
if expr x"$pgac_cv_check_readline" : 'x-lreadline' >/dev/null ; then
@@ -1608,8 +1609,6 @@ PGAC_UNION_SEMUN
16081609
AC_CHECK_TYPES(socklen_t, [], [], [#include <sys/socket.h>])
16091610
PGAC_STRUCT_SOCKADDR_SA_LEN
16101611

1611-
PGAC_TYPE_LOCALE_T
1612-
16131612
# MSVC doesn't cope well with defining restrict to __restrict, the
16141613
# spelling it understands, because it conflicts with
16151614
# __declspec(restrict). Therefore we define pg_restrict to the
@@ -1708,7 +1707,6 @@ fi
17081707
##
17091708

17101709
PGAC_VAR_INT_TIMEZONE
1711-
PGAC_FUNC_WCSTOMBS_L
17121710

17131711
# Some versions of libedit contain strlcpy(), setproctitle(), and other
17141712
# symbols that that library has no business exposing to the world. Pending

meson.build

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,6 +2403,7 @@ header_checks = [
24032403
'sys/ucred.h',
24042404
'termios.h',
24052405
'ucred.h',
2406+
'xlocale.h',
24062407
]
24072408

24082409
foreach header : header_checks
@@ -2546,15 +2547,6 @@ else
25462547
cdata.set('STRERROR_R_INT', false)
25472548
endif
25482549

2549-
# Find the right header file for the locale_t type. macOS needs xlocale.h;
2550-
# standard is locale.h, but glibc <= 2.25 also had an xlocale.h file that
2551-
# we should not use so we check the standard header first. MSVC has a
2552-
# replacement defined in src/include/port/win32_port.h.
2553-
if not cc.has_type('locale_t', prefix: '#include <locale.h>') and \
2554-
cc.has_type('locale_t', prefix: '#include <xlocale.h>')
2555-
cdata.set('LOCALE_T_IN_XLOCALE', 1)
2556-
endif
2557-
25582550
# Check if the C compiler understands typeof or a variant. Define
25592551
# HAVE_TYPEOF if so, and define 'typeof' to the actual key word.
25602552
foreach kw : ['typeof', '__typeof__', 'decltype']
@@ -2580,29 +2572,6 @@ int main(void)
25802572
endforeach
25812573

25822574

2583-
# Try to find a declaration for wcstombs_l(). It might be in stdlib.h
2584-
# (following the POSIX requirement for wcstombs()), or in locale.h, or in
2585-
# xlocale.h. If it's in the latter, define WCSTOMBS_L_IN_XLOCALE.
2586-
wcstombs_l_test = '''
2587-
#include <stdlib.h>
2588-
#include <locale.h>
2589-
@0@
2590-
2591-
void main(void)
2592-
{
2593-
#ifndef wcstombs_l
2594-
(void) wcstombs_l;
2595-
#endif
2596-
}
2597-
'''
2598-
if (not cc.compiles(wcstombs_l_test.format(''),
2599-
name: 'wcstombs_l') and
2600-
cc.compiles(wcstombs_l_test.format('#include <xlocale.h>'),
2601-
name: 'wcstombs_l in xlocale.h'))
2602-
cdata.set('WCSTOMBS_L_IN_XLOCALE', 1)
2603-
endif
2604-
2605-
26062575
# MSVC doesn't cope well with defining restrict to __restrict, the spelling it
26072576
# understands, because it conflicts with __declspec(restrict). Therefore we
26082577
# define pg_restrict to the appropriate definition, which presumably won't

src/include/c.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
#include <fcntl.h> /* ensure O_BINARY is available */
7272
#endif
7373
#include <locale.h>
74+
#ifdef HAVE_XLOCALE_H
75+
#include <xlocale.h>
76+
#endif
7477
#ifdef ENABLE_NLS
7578
#include <libintl.h>
7679
#endif

src/include/pg_config.h.in

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@
499499
/* Define to 1 if the assembler supports X86_64's POPCNTQ instruction. */
500500
#undef HAVE_X86_64_POPCNTQ
501501

502+
/* Define to 1 if you have the <xlocale.h> header file. */
503+
#undef HAVE_XLOCALE_H
504+
502505
/* Define to 1 if you have XSAVE intrinsics. */
503506
#undef HAVE_XSAVE_INTRINSICS
504507

@@ -559,9 +562,6 @@
559562
/* Define to the appropriate printf length modifier for 64-bit ints. */
560563
#undef INT64_MODIFIER
561564

562-
/* Define to 1 if `locale_t' requires <xlocale.h>. */
563-
#undef LOCALE_T_IN_XLOCALE
564-
565565
/* Define as the maximum alignment requirement of any C data type. */
566566
#undef MAXIMUM_ALIGNOF
567567

@@ -748,9 +748,6 @@
748748
/* Define to 1 to build with ZSTD support. (--with-zstd) */
749749
#undef USE_ZSTD
750750

751-
/* Define to 1 if `wcstombs_l' requires <xlocale.h>. */
752-
#undef WCSTOMBS_L_IN_XLOCALE
753-
754751
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
755752
significant byte first (like Motorola and SPARC, unlike Intel). */
756753
#if defined AC_APPLE_UNIVERSAL_BUILD

src/include/utils/pg_locale.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
#ifndef _PG_LOCALE_
1313
#define _PG_LOCALE_
1414

15-
#if defined(LOCALE_T_IN_XLOCALE) || defined(WCSTOMBS_L_IN_XLOCALE)
16-
#include <xlocale.h>
17-
#endif
1815
#ifdef USE_ICU
1916
#include <unicode/ucol.h>
2017
#endif

src/interfaces/ecpg/ecpglib/ecpglib_extern.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#ifndef CHAR_BIT
1414
#include <limits.h>
1515
#endif
16-
#ifdef LOCALE_T_IN_XLOCALE
17-
#include <xlocale.h>
18-
#endif
1916

2017
enum COMPAT_MODE
2118
{

src/port/chklocale.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
#include <langinfo.h>
2424
#endif
2525

26-
#ifdef LOCALE_T_IN_XLOCALE
27-
#include <xlocale.h>
28-
#endif
29-
3026
#include "mb/pg_wchar.h"
3127

3228

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy