Skip to content

Commit 9573384

Browse files
committed
Require stdint.h
stdint.h belongs to the compiler (as opposed to inttypes.h), so by requiring a C99 compiler we can also require stdint.h unconditionally. Remove configure checks and other workarounds for it. This also removes a few steps in the required portability adjustments to the imported time zone code, which can be applied on the next import. When using GCC on a platform that is otherwise pre-C99, this will now require at least GCC 4.5, which is the first release that supplied a standard-conforming stdint.h if the native platform didn't have it. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/5d398bbb-262a-5fed-d839-d0e5cff3c0d7%402ndquadrant.com
1 parent dca3911 commit 9573384

File tree

6 files changed

+5
-119
lines changed

6 files changed

+5
-119
lines changed

configure

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -14154,79 +14154,6 @@ _ACEOF
1415414154
fi
1415514155

1415614156

14157-
ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
14158-
if test "x$ac_cv_type_intptr_t" = xyes; then :
14159-
14160-
$as_echo "#define HAVE_INTPTR_T 1" >>confdefs.h
14161-
14162-
else
14163-
for ac_type in 'int' 'long int' 'long long int'; do
14164-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14165-
/* end confdefs.h. */
14166-
$ac_includes_default
14167-
int
14168-
main ()
14169-
{
14170-
static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
14171-
test_array [0] = 0;
14172-
return test_array [0];
14173-
14174-
;
14175-
return 0;
14176-
}
14177-
_ACEOF
14178-
if ac_fn_c_try_compile "$LINENO"; then :
14179-
14180-
cat >>confdefs.h <<_ACEOF
14181-
#define intptr_t $ac_type
14182-
_ACEOF
14183-
14184-
ac_type=
14185-
fi
14186-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14187-
test -z "$ac_type" && break
14188-
done
14189-
fi
14190-
14191-
14192-
14193-
ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
14194-
if test "x$ac_cv_type_uintptr_t" = xyes; then :
14195-
14196-
$as_echo "#define HAVE_UINTPTR_T 1" >>confdefs.h
14197-
14198-
else
14199-
for ac_type in 'unsigned int' 'unsigned long int' \
14200-
'unsigned long long int'; do
14201-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14202-
/* end confdefs.h. */
14203-
$ac_includes_default
14204-
int
14205-
main ()
14206-
{
14207-
static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
14208-
test_array [0] = 0;
14209-
return test_array [0];
14210-
14211-
;
14212-
return 0;
14213-
}
14214-
_ACEOF
14215-
if ac_fn_c_try_compile "$LINENO"; then :
14216-
14217-
cat >>confdefs.h <<_ACEOF
14218-
#define uintptr_t $ac_type
14219-
_ACEOF
14220-
14221-
ac_type=
14222-
fi
14223-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14224-
test -z "$ac_type" && break
14225-
done
14226-
fi
14227-
14228-
14229-
1423014157
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for locale_t" >&5
1423114158
$as_echo_n "checking for locale_t... " >&6; }
1423214159
if ${pgac_cv_type_locale_t+:} false; then :

configure.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,8 +1477,6 @@ PGAC_STRUCT_SOCKADDR_UN
14771477
PGAC_STRUCT_SOCKADDR_STORAGE
14781478
PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
14791479
PGAC_STRUCT_ADDRINFO
1480-
AC_TYPE_INTPTR_T
1481-
AC_TYPE_UINTPTR_T
14821480

14831481
PGAC_TYPE_LOCALE_T
14841482

src/include/c.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@
6464
#ifdef HAVE_STRINGS_H
6565
#include <strings.h>
6666
#endif
67-
#ifdef HAVE_STDINT_H
6867
#include <stdint.h>
69-
#endif
7068
#include <sys/types.h>
7169
#include <errno.h>
7270
#if defined(WIN32) || defined(__CYGWIN__)
@@ -429,8 +427,8 @@ typedef unsigned PG_INT128_TYPE uint128
429427
#endif
430428

431429
/*
432-
* stdint.h limits aren't guaranteed to be present and aren't guaranteed to
433-
* have compatible types with our fixed width types. So just define our own.
430+
* stdint.h limits aren't guaranteed to have compatible types with our fixed
431+
* width types. So just define our own.
434432
*/
435433
#define PG_INT8_MIN (-0x7F-1)
436434
#define PG_INT8_MAX (0x7F)
@@ -445,15 +443,6 @@ typedef unsigned PG_INT128_TYPE uint128
445443
#define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF)
446444
#define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF)
447445

448-
/* Max value of size_t might also be missing if we don't have stdint.h */
449-
#ifndef SIZE_MAX
450-
#if SIZEOF_SIZE_T == 8
451-
#define SIZE_MAX PG_UINT64_MAX
452-
#else
453-
#define SIZE_MAX PG_UINT32_MAX
454-
#endif
455-
#endif
456-
457446
/*
458447
* We now always use int64 timestamps, but keep this symbol defined for the
459448
* benefit of external code that might test it.

src/include/pg_config.h.in

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,6 @@
310310
/* Define to 1 if the system has the type `int8'. */
311311
#undef HAVE_INT8
312312

313-
/* Define to 1 if the system has the type `intptr_t'. */
314-
#undef HAVE_INTPTR_T
315-
316313
/* Define to 1 if you have the <inttypes.h> header file. */
317314
#undef HAVE_INTTYPES_H
318315

@@ -680,9 +677,6 @@
680677
/* Define to 1 if the system has the type `uint8'. */
681678
#undef HAVE_UINT8
682679

683-
/* Define to 1 if the system has the type `uintptr_t'. */
684-
#undef HAVE_UINTPTR_T
685-
686680
/* Define to 1 if the system has the type `union semun'. */
687681
#undef HAVE_UNION_SEMUN
688682

@@ -1006,10 +1000,6 @@
10061000
#undef inline
10071001
#endif
10081002

1009-
/* Define to the type of a signed integer type wide enough to hold a pointer,
1010-
if such a type exists, and if the system does not define it. */
1011-
#undef intptr_t
1012-
10131003
/* Define to keyword to use for C99 restrict support, or to nothing if not
10141004
supported */
10151005
#undef pg_restrict
@@ -1033,7 +1023,3 @@
10331023

10341024
/* Define to how the compiler spells `typeof'. */
10351025
#undef typeof
1036-
1037-
/* Define to the type of an unsigned integer type wide enough to hold a
1038-
pointer, if such a type exists, and if the system does not define it. */
1039-
#undef uintptr_t

src/timezone/README

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,8 @@ old-style function declarations to C89 style, but thank goodness they
7070
fixed that.)
7171

7272
* We need the code to follow Postgres' portability conventions; this
73-
includes relying on configure's results rather than hand-hacked #defines,
74-
and not relying on <stdint.h> features that may not exist on old systems.
75-
(In particular this means using Postgres' definitions of the int32 and
76-
int64 typedefs, not int_fast32_t/int_fast64_t. Likewise we use
77-
PG_INT32_MIN/MAX not INT32_MIN/MAX.)
73+
includes relying on configure's results rather than hand-hacked
74+
#defines (see private.h).
7875

7976
* Since Postgres is typically built on a system that has its own copy
8077
of the <time.h> functions, we must avoid conflicting with those. This
@@ -112,13 +109,6 @@ to first run the tzcode source files through a sed filter like this:
112109
-e 's|^\*/| */|' \
113110
-e 's/\bregister[ \t]//g' \
114111
-e 's/\bATTRIBUTE_PURE[ \t]//g' \
115-
-e 's/int_fast32_t/int32/g' \
116-
-e 's/int_fast64_t/int64/g' \
117-
-e 's/intmax_t/int64/g' \
118-
-e 's/INT32_MIN/PG_INT32_MIN/g' \
119-
-e 's/INT32_MAX/PG_INT32_MAX/g' \
120-
-e 's/INTMAX_MIN/PG_INT64_MIN/g' \
121-
-e 's/INTMAX_MAX/PG_INT64_MAX/g' \
122112
-e 's/struct[ \t]+tm\b/struct pg_tm/g' \
123113
-e 's/\btime_t\b/pg_time_t/g' \
124114
-e 's/lineno/lineno_t/g' \

src/tools/msvc/Solution.pm

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ sub GenerateFiles
275275
HAVE_INT_TIMEZONE => 1,
276276
HAVE_INT64 => undef,
277277
HAVE_INT8 => undef,
278-
HAVE_INTPTR_T => undef,
279278
HAVE_INTTYPES_H => undef,
280279
HAVE_INT_OPTERR => undef,
281280
HAVE_INT_OPTRESET => undef,
@@ -396,7 +395,6 @@ sub GenerateFiles
396395
HAVE_UCRED_H => undef,
397396
HAVE_UINT64 => undef,
398397
HAVE_UINT8 => undef,
399-
HAVE_UINTPTR_T => undef,
400398
HAVE_UNION_SEMUN => undef,
401399
HAVE_UNISTD_H => 1,
402400
HAVE_UNIX_SOCKETS => undef,
@@ -496,13 +494,11 @@ sub GenerateFiles
496494
_LARGEFILE_SOURCE => undef,
497495
_LARGE_FILES => undef,
498496
inline => '__inline',
499-
intptr_t => undef,
500497
pg_restrict => '__restrict',
501498
# not defined, because it'd conflict with __declspec(restrict)
502499
restrict => undef,
503500
signed => undef,
504-
typeof => undef,
505-
uintptr_t => undef,);
501+
typeof => undef,);
506502

507503
if ($self->{options}->{uuid})
508504
{

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