Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit962da90

Browse files
committed
Use <stdint.h> and <inttypes.h> for c.h integers.
Redefine our exact width types with standard C99 types and macros,including int64_t, INT64_MAX, INT64_C(), PRId64 etc. We were alreadyusing <stdint.h> types in a few places.One complication is that Windows' <inttypes.h> uses format strings like"%I64d", "%I32", "%I" for PRI*64, PRI*32, PTR*PTR, instead of mapping toother standardized format strings like "%lld" etc as seen on other knownsystems. Teach our snprintf.c to understand them.This removes a lot of configure clutter, and should also allow 64-bitnumbers and other standard types to be used in localized messageswithout casting.Reviewed-by: Peter Eisentraut <peter@eisentraut.org>Discussion:https://postgr.es/m/ME3P282MB3166F9D1F71F787929C0C7E7B6312%40ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM
1 parent3b08d52 commit962da90

25 files changed

+272
-582
lines changed

‎config/c-compiler.m4

Lines changed: 13 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -38,60 +38,6 @@ ac_c_werror_flag=$ac_save_c_werror_flag
3838
])# PGAC_TEST_PRINTF_ARCHETYPE
3939

4040

41-
# PGAC_TYPE_64BIT_INT(TYPE)
42-
# -------------------------
43-
# Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to
44-
# yes or no respectively, and define HAVE_TYPE_64 if yes.
45-
AC_DEFUN([PGAC_TYPE_64BIT_INT],
46-
[define([Ac_define],[translit([have_$1_64],[a-z *],[A-Z_P])])dnl
47-
define([Ac_cachevar],[translit([pgac_cv_type_$1_64],[ *],[_p])])dnl
48-
AC_CACHE_CHECK([whether$1 is 64 bits],[Ac_cachevar],
49-
[AC_RUN_IFELSE([AC_LANG_SOURCE(
50-
[typedef$1 ac_int64;
51-
52-
/*
53-
* These are globals to discourage the compiler from folding all the
54-
* arithmetic tests down to compile-time constants.
55-
*/
56-
ac_int64 a = 20000001;
57-
ac_int64 b = 40000005;
58-
59-
int does_int64_work()
60-
{
61-
ac_int64 c,d;
62-
63-
if (sizeof(ac_int64) != 8)
64-
return 0;/* definitely not the right size */
65-
66-
/* Do perfunctory checks to see if 64-bit arithmetic seems to work */
67-
c = a * b;
68-
d = (c + b) / b;
69-
if (d != a+1)
70-
return 0;
71-
return 1;
72-
}
73-
74-
int
75-
main() {
76-
return (! does_int64_work());
77-
}])],
78-
[Ac_cachevar=yes],
79-
[Ac_cachevar=no],
80-
[# If cross-compiling, check the size reported by the compiler and
81-
# trust that the arithmetic works.
82-
AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([],[sizeof($1) == 8])],
83-
Ac_cachevar=yes,
84-
Ac_cachevar=no)])])
85-
86-
Ac_define=$Ac_cachevar
87-
if test x"$Ac_cachevar" = xyes ; then
88-
AC_DEFINE(Ac_define,1,[Define to 1 if `]$1[' works and is 64 bits.])
89-
fi
90-
undefine([Ac_define])dnl
91-
undefine([Ac_cachevar])dnl
92-
])# PGAC_TYPE_64BIT_INT
93-
94-
9541
# PGAC_TYPE_128BIT_INT
9642
# --------------------
9743
# Check if __int128 is a working 128 bit integer type, and if so
@@ -270,9 +216,10 @@ fi])# PGAC_C_BUILTIN_CONSTANT_P
270216
AC_DEFUN([PGAC_C_BUILTIN_OP_OVERFLOW],
271217
[AC_CACHE_CHECK(for__builtin_mul_overflow,pgac_cv__builtin_op_overflow,
272218
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
273-
PG_INT64_TYPE a = 1;
274-
PG_INT64_TYPE b = 1;
275-
PG_INT64_TYPE result;
219+
#include <stdint.h>
220+
int64_t a = 1;
221+
int64_t b = 1;
222+
int64_t result;
276223
int oflo;
277224
],
278225
[oflo = __builtin_mul_overflow(a, b, &result);])],
@@ -557,13 +504,13 @@ fi])# PGAC_HAVE_GCC__SYNC_INT32_CAS
557504
# types, and define HAVE_GCC__SYNC_INT64_CAS if so.
558505
AC_DEFUN([PGAC_HAVE_GCC__SYNC_INT64_CAS],
559506
[AC_CACHE_CHECK(forbuiltin__syncint64atomicoperations,pgac_cv_gcc_sync_int64_cas,
560-
[AC_LINK_IFELSE([AC_LANG_PROGRAM([],
561-
[PG_INT64_TYPE lock = 0;
562-
__sync_val_compare_and_swap(&lock, 0, (PG_INT64_TYPE) 37);])],
507+
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdint.h>],
508+
[int64_t lock = 0;
509+
__sync_val_compare_and_swap(&lock, 0, (int64_t) 37);])],
563510
[pgac_cv_gcc_sync_int64_cas="yes"],
564511
[pgac_cv_gcc_sync_int64_cas="no"])])
565512
if test x"$pgac_cv_gcc_sync_int64_cas" = x"yes"; then
566-
AC_DEFINE(HAVE_GCC__SYNC_INT64_CAS,1,[Define to 1 if you have __sync_val_compare_and_swap(int64 *,int64, int64).])
513+
AC_DEFINE(HAVE_GCC__SYNC_INT64_CAS,1,[Define to 1 if you have __sync_val_compare_and_swap(int64_t *,int64_t, int64_t).])
567514
fi])# PGAC_HAVE_GCC__SYNC_INT64_CAS
568515

569516
# PGAC_HAVE_GCC__ATOMIC_INT32_CAS
@@ -588,9 +535,9 @@ fi])# PGAC_HAVE_GCC__ATOMIC_INT32_CAS
588535
# types, and define HAVE_GCC__ATOMIC_INT64_CAS if so.
589536
AC_DEFUN([PGAC_HAVE_GCC__ATOMIC_INT64_CAS],
590537
[AC_CACHE_CHECK(forbuiltin__atomicint64atomicoperations,pgac_cv_gcc_atomic_int64_cas,
591-
[AC_LINK_IFELSE([AC_LANG_PROGRAM([],
592-
[PG_INT64_TYPE val = 0;
593-
PG_INT64_TYPE expect = 0;
538+
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdint.h>],
539+
[int64_t val = 0;
540+
int64_t expect = 0;
594541
__atomic_compare_exchange_n(&val, &expect, 37, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);])],
595542
[pgac_cv_gcc_atomic_int64_cas="yes"],
596543
[pgac_cv_gcc_atomic_int64_cas="no"])])
@@ -734,13 +681,14 @@ AC_DEFUN([PGAC_AVX512_POPCNT_INTRINSICS],
734681
[define([Ac_cachevar],[AS_TR_SH([pgac_cv_avx512_popcnt_intrinsics])])dnl
735682
AC_CACHE_CHECK([for _mm512_popcnt_epi64],[Ac_cachevar],
736683
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <immintrin.h>
684+
#include <stdint.h>
737685
#if defined(__has_attribute) && __has_attribute (target)
738686
__attribute__((target("avx512vpopcntdq,avx512bw")))
739687
#endif
740688
static int popcount_test(void)
741689
{
742690
const char buf@<:@sizeof(__m512i)@:>@;
743-
PG_INT64_TYPE popcnt = 0;
691+
int64_t popcnt = 0;
744692
__m512i accum = _mm512_setzero_si512();
745693
const __m512i val = _mm512_maskz_loadu_epi8((__mmask64) 0xf0f0f0f0f0f0f0f0, (const __m512i *) buf);
746694
const __m512i cnt = _mm512_popcnt_epi64(val);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp