From 768b56fea1282686eb3fa28ec193985909c35b58 Mon Sep 17 00:00:00 2001 From: hcq Date: Mon, 21 Sep 2026 16:51:09 +0800 Subject: [PATCH] add 64-bit atomic access on loongarch64 --- src/include/port/atomics.h | 2 ++ src/include/port/atomics/arch-loongarch.h | 27 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/include/port/atomics/arch-loongarch.h diff --git a/src/include/port/atomics.h b/src/include/port/atomics.h index a605ea81d07..fdc9341c2c5 100644 --- a/src/include/port/atomics.h +++ b/src/include/port/atomics.h @@ -65,6 +65,8 @@ */ #if defined(__arm__) || defined(__aarch64__) #include "port/atomics/arch-arm.h" +#elif defined(__loongarch_lp64) +#include "port/atomics/arch-loongarch.h" #elif defined(__i386__) || defined(__x86_64__) #include "port/atomics/arch-x86.h" #elif defined(__powerpc__) || defined(__powerpc64__) diff --git a/src/include/port/atomics/arch-loongarch.h b/src/include/port/atomics/arch-loongarch.h new file mode 100644 index 00000000000..ea007bd3550 --- /dev/null +++ b/src/include/port/atomics/arch-loongarch.h @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------- + * + * arch-loongarch.h + * Atomic operations considerations specific to LoongArch + * + * Portions Copyright (c) 2013-2026, PostgreSQL Global Development Group + * + * NOTES: + * + * src/include/port/atomics/arch-loongarch.h + * + *------------------------------------------------------------------------- + */ + +/* intentionally no include guards, should only be included by atomics.h */ +#ifndef INSIDE_ATOMICS_H +#error "should be included via atomics.h" +#endif + +/* + * A naturally aligned 8-byte load or store is single-copy atomic on + * LoongArch64, so the generic 64-bit atomic implementation can use a plain + * load/store instead of a compare/exchange loop. + */ +#if defined(__loongarch_lp64) +#define PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY +#endif /* __loongarch_lp64 */ -- 2.47.3