Require stdint.h
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 21 Feb 2020 08:14:03 +0000 (09:14 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 21 Feb 2020 08:20:32 +0000 (09:20 +0100)
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

configure
configure.in
src/include/c.h
src/include/pg_config.h.in
src/timezone/README
src/tools/msvc/Solution.pm

index 37aa82dcd4e23357090f17d6df143efb1afd1991..569cd2fa916086a4f0bc1e4b3c0fba2432b46437 100755 (executable)
--- a/configure
+++ b/configure
@@ -14154,79 +14154,6 @@ _ACEOF
 fi
 
 
-  ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
-if test "x$ac_cv_type_intptr_t" = xyes; then :
-
-$as_echo "#define HAVE_INTPTR_T 1" >>confdefs.h
-
-else
-  for ac_type in 'int' 'long int' 'long long int'; do
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
-test_array [0] = 0;
-return test_array [0];
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-cat >>confdefs.h <<_ACEOF
-#define intptr_t $ac_type
-_ACEOF
-
-         ac_type=
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-       test -z "$ac_type" && break
-     done
-fi
-
-
-
-  ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
-if test "x$ac_cv_type_uintptr_t" = xyes; then :
-
-$as_echo "#define HAVE_UINTPTR_T 1" >>confdefs.h
-
-else
-  for ac_type in 'unsigned int' 'unsigned long int' \
-       'unsigned long long int'; do
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
-test_array [0] = 0;
-return test_array [0];
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-cat >>confdefs.h <<_ACEOF
-#define uintptr_t $ac_type
-_ACEOF
-
-         ac_type=
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-       test -z "$ac_type" && break
-     done
-fi
-
-
-
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for locale_t" >&5
 $as_echo_n "checking for locale_t... " >&6; }
 if ${pgac_cv_type_locale_t+:} false; then :
index 8adb409558f47f21d8742bb12b41a98954a331e2..140909091a161c411a4b3313d617a09940ff7197 100644 (file)
@@ -1477,8 +1477,6 @@ PGAC_STRUCT_SOCKADDR_UN
 PGAC_STRUCT_SOCKADDR_STORAGE
 PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
 PGAC_STRUCT_ADDRINFO
-AC_TYPE_INTPTR_T
-AC_TYPE_UINTPTR_T
 
 PGAC_TYPE_LOCALE_T
 
index d10b9812fbe2e495a131e3ec28c9d3fbc6d2be1d..2e8b2d4e3fe39273fb46f9ca5773b347d99b1332 100644 (file)
@@ -64,9 +64,7 @@
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
 #endif
-#ifdef HAVE_STDINT_H
 #include <stdint.h>
-#endif
 #include <sys/types.h>
 #include <errno.h>
 #if defined(WIN32) || defined(__CYGWIN__)
@@ -429,8 +427,8 @@ typedef unsigned PG_INT128_TYPE uint128
 #endif
 
 /*
- * stdint.h limits aren't guaranteed to be present and aren't guaranteed to
- * have compatible types with our fixed width types. So just define our own.
+ * stdint.h limits aren't guaranteed to have compatible types with our fixed
+ * width types. So just define our own.
  */
 #define PG_INT8_MIN            (-0x7F-1)
 #define PG_INT8_MAX            (0x7F)
@@ -445,15 +443,6 @@ typedef unsigned PG_INT128_TYPE uint128
 #define PG_INT64_MAX   INT64CONST(0x7FFFFFFFFFFFFFFF)
 #define PG_UINT64_MAX  UINT64CONST(0xFFFFFFFFFFFFFFFF)
 
-/* Max value of size_t might also be missing if we don't have stdint.h */
-#ifndef SIZE_MAX
-#if SIZEOF_SIZE_T == 8
-#define SIZE_MAX PG_UINT64_MAX
-#else
-#define SIZE_MAX PG_UINT32_MAX
-#endif
-#endif
-
 /*
  * We now always use int64 timestamps, but keep this symbol defined for the
  * benefit of external code that might test it.
index 60dcf42974f62473ae91202b11fa353640768827..e7de8f3b2b4bdc322aa77768e0a4c1f0ca007036 100644 (file)
 /* Define to 1 if the system has the type `int8'. */
 #undef HAVE_INT8
 
-/* Define to 1 if the system has the type `intptr_t'. */
-#undef HAVE_INTPTR_T
-
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
 /* Define to 1 if the system has the type `uint8'. */
 #undef HAVE_UINT8
 
-/* Define to 1 if the system has the type `uintptr_t'. */
-#undef HAVE_UINTPTR_T
-
 /* Define to 1 if the system has the type `union semun'. */
 #undef HAVE_UNION_SEMUN
 
 #undef inline
 #endif
 
-/* Define to the type of a signed integer type wide enough to hold a pointer,
-   if such a type exists, and if the system does not define it. */
-#undef intptr_t
-
 /* Define to keyword to use for C99 restrict support, or to nothing if not
    supported */
 #undef pg_restrict
 
 /* Define to how the compiler spells `typeof'. */
 #undef typeof
-
-/* Define to the type of an unsigned integer type wide enough to hold a
-   pointer, if such a type exists, and if the system does not define it. */
-#undef uintptr_t
index d3dd7b7fa6da6c72478b55e77df9e876d1000923..3c593933c1c84f80835252afa6d609a10b6bbb8c 100644 (file)
@@ -70,11 +70,8 @@ old-style function declarations to C89 style, but thank goodness they
 fixed that.)
 
 * We need the code to follow Postgres' portability conventions; this
-includes relying on configure's results rather than hand-hacked #defines,
-and not relying on <stdint.h> features that may not exist on old systems.
-(In particular this means using Postgres' definitions of the int32 and
-int64 typedefs, not int_fast32_t/int_fast64_t.  Likewise we use
-PG_INT32_MIN/MAX not INT32_MIN/MAX.)
+includes relying on configure's results rather than hand-hacked
+#defines (see private.h).
 
 * Since Postgres is typically built on a system that has its own copy
 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:
         -e 's|^\*/| */|' \
         -e 's/\bregister[ \t]//g' \
         -e 's/\bATTRIBUTE_PURE[ \t]//g' \
-        -e 's/int_fast32_t/int32/g' \
-        -e 's/int_fast64_t/int64/g' \
-        -e 's/intmax_t/int64/g' \
-        -e 's/INT32_MIN/PG_INT32_MIN/g' \
-        -e 's/INT32_MAX/PG_INT32_MAX/g' \
-        -e 's/INTMAX_MIN/PG_INT64_MIN/g' \
-        -e 's/INTMAX_MAX/PG_INT64_MAX/g' \
         -e 's/struct[ \t]+tm\b/struct pg_tm/g' \
         -e 's/\btime_t\b/pg_time_t/g' \
         -e 's/lineno/lineno_t/g' \
index 8412ef298ea03d5d2c66b44be4aa2df49a4f8981..d1a4f183f3e6ab08f4f270baef118c7f49acfad2 100644 (file)
@@ -275,7 +275,6 @@ sub GenerateFiles
                HAVE_INT_TIMEZONE                           => 1,
                HAVE_INT64                                  => undef,
                HAVE_INT8                                   => undef,
-               HAVE_INTPTR_T                               => undef,
                HAVE_INTTYPES_H                             => undef,
                HAVE_INT_OPTERR                             => undef,
                HAVE_INT_OPTRESET                           => undef,
@@ -396,7 +395,6 @@ sub GenerateFiles
                HAVE_UCRED_H                             => undef,
                HAVE_UINT64                              => undef,
                HAVE_UINT8                               => undef,
-               HAVE_UINTPTR_T                           => undef,
                HAVE_UNION_SEMUN                         => undef,
                HAVE_UNISTD_H                            => 1,
                HAVE_UNIX_SOCKETS                        => undef,
@@ -496,13 +494,11 @@ sub GenerateFiles
                _LARGEFILE_SOURCE => undef,
                _LARGE_FILES      => undef,
                inline            => '__inline',
-               intptr_t          => undef,
                pg_restrict       => '__restrict',
                # not defined, because it'd conflict with __declspec(restrict)
                restrict  => undef,
                signed    => undef,
-               typeof    => undef,
-               uintptr_t => undef,);
+               typeof    => undef,);
 
        if ($self->{options}->{uuid})
        {