From 068ccc51aece97a4f9181f414a7df30af40ffc40 Mon Sep 17 00:00:00 2001 From: "changying.yue" Date: Sat, 17 Jun 2023 12:16:06 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20SSE=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E4=B8=8E128=E4=BD=8D=E6=95=B4=E5=9E=8B=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=B2=A1=E6=9C=89=E9=85=8D=E5=90=88=E5=A5=BD?= =?UTF-8?q?=E5=AF=BC=E8=87=B4OG=20coredump=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/include/c.h | 51 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/src/include/c.h b/src/include/c.h index d6dd28d5ab..30fd919b34 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -384,20 +384,55 @@ typedef uint16 uint2; typedef uint32 uint4; /* - * Define signed 128 bit int type. - * Define unsigned 128 bit int type. + * 128-bit signed and unsigned integers + * There currently is only limited support for such types. + * E.g. 128bit literals and snprintf are not supported; but math is. + * Also, because we exclude such types when choosing MAXIMUM_ALIGNOF, + * it must be possible to coerce the compiler to allocate them on no + * more than MAXALIGN boundaries. */ + +#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__) +#define pg_attribute_aligned(a) __attribute__((aligned(a))) +#endif + #ifndef ENABLE_DEFAULT_GCC #if !defined(WIN32) -typedef __int128 int128; -typedef unsigned __int128 uint128; + #if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <= MAXIMUM_ALIGNOF + typedef __int128 int128 + #if defined(pg_attribute_aligned) + pg_attribute_aligned(MAXIMUM_ALIGNOF) + #endif + ; + + typedef unsigned __int128 uint128 + #if defined(pg_attribute_aligned) + pg_attribute_aligned(MAXIMUM_ALIGNOF) + #endif + ; + #else + ereport(ERROR, (errmsg("the compiler can't support int128 or uint128 aligned on a 8-byte boundary."))); + #endif #endif #else #ifdef __linux__ -#if __GNUC__ >= 7 -typedef __int128 int128; -typedef unsigned __int128 uint128; -#endif + #if __GNUC__ >= 7 + #if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <= MAXIMUM_ALIGNOF + typedef __int128 int128 + #if defined(pg_attribute_aligned) + pg_attribute_aligned(MAXIMUM_ALIGNOF) + #endif + ; + + typedef unsigned __int128 uint128 + #if defined(pg_attribute_aligned) + pg_attribute_aligned(MAXIMUM_ALIGNOF) + #endif + ; + #else + ereport(ERROR, (errmsg("the compiler can't support int128 or uint128 aligned on a 8-byte boundary."))); + #endif + #endif #endif #endif -- Gitee