1 Star 0 Fork 22

ziyu04/src_opengauss-server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
3000-add-sw_64-support.patch 76.66 KB
一键复制 编辑 原始数据 按行查看 历史
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789
From 1d1ba5da4366f12a8bc020d5d0432030cd890db2 Mon Sep 17 00:00:00 2001
From: panchenbo <panchenbo@kylinsec.com.cn>
Date: Sun, 25 Jun 2023 14:48:59 +0800
Subject: [PATCH] add sw_64 support
---
.../cmake/src/build_options.cmake | 2 +-
openGauss-server-2.1.0/config/config.guess | 3 +
openGauss-server-2.1.0/config/config.sub | 2 +
openGauss-server-2.1.0/configure | 10 +-
.../contrib/pgcrypto/crypt-blowfish.cpp | 2 +-
openGauss-server-2.1.0/src/Makefile.global.in | 2 +-
.../src/bin/initdb/Makefile | 3 +-
.../src/bin/initdb/initdb.cpp | 31 ++--
.../src/bin/pg_probackup/atomics.h | 2 +
.../src/bin/pg_probackup/atomics/arch-sw_64.h | 17 +++
.../src/common/port/Makefile | 10 ++
.../src/common/port/exec.cpp | 1 -
.../src/common/port/pg_crc32c_choose.cpp | 1 +
.../src/gausskernel/CMakeLists.txt | 4 +-
.../src/gausskernel/bootstrap/bootstrap.cpp | 4 +-
.../src/gausskernel/cbb/bbox/bbox_atomic.h | 4 +
.../gausskernel/cbb/bbox/bbox_atomic_sw_64.h | 124 ++++++++++++++++
.../gausskernel/cbb/bbox/bbox_elf_dump.cpp | 6 +-
.../src/gausskernel/cbb/bbox/bbox_elf_dump.h | 94 +++++++++++-
.../gausskernel/cbb/bbox/bbox_syscall_SW_64.h | 136 ++++++++++++++++++
.../cbb/bbox/bbox_syscall_support.cpp | 89 ++++++++++++
.../cbb/bbox/bbox_syscall_support.h | 38 ++++-
.../src/gausskernel/process/main/main.cpp | 3 +-
.../process/postmaster/postmaster.cpp | 2 +-
.../runtime/executor/instrument.cpp | 6 +
.../vecexecutor/vectorsonic/vsonichash.cpp | 9 +-
.../access/transam/extreme_rto/page_redo.cpp | 10 +-
.../storage/access/transam/xlog.cpp | 45 +++---
.../storage/mot/core/Makefile.local | 9 +-
.../mot/core/infra/synchronization/cycles.h | 12 ++
.../infra/synchronization/mot_atomic_ops.h | 2 +-
.../src/include/access/double_write_basic.h | 2 +
.../include/access/extreme_rto/dispatcher.h | 2 +-
.../include/access/extreme_rto/page_redo.h | 2 +-
.../access/parallel_recovery/page_redo.h | 2 +-
.../communication/commproxy_interface.h | 10 ++
.../src/include/gtm/gtm_atomic.h | 12 ++
.../src/include/gtm/gtm_slock.h | 39 +++++
.../src/include/storage/lock/s_lock.h | 41 +++++-
.../src/include/utils/atomic.h | 3 +
.../src/test/regress/pg_regress.cpp | 4 +
protobuf-3.11.3/cmake/CMakeLists.txt | 3 +-
.../kokoro/release/protoc/linux/build.sh | 2 +
.../protoc-artifacts/build-protoc.sh | 6 +
.../google/protobuf/stubs/platform_macros.h | 3 +
zlib-1.2.11/configure | 14 +-
46 files changed, 744 insertions(+), 84 deletions(-)
create mode 100644 openGauss-server-2.1.0/src/bin/pg_probackup/atomics/arch-sw_64.h
create mode 100644 openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_atomic_sw_64.h
create mode 100644 openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_SW_64.h
diff --git a/openGauss-server-2.1.0/cmake/src/build_options.cmake b/openGauss-server-2.1.0/cmake/src/build_options.cmake
index 0ef180f..bb7e974 100755
--- a/openGauss-server-2.1.0/cmake/src/build_options.cmake
+++ b/openGauss-server-2.1.0/cmake/src/build_options.cmake
@@ -237,7 +237,7 @@ endif()
if(${USE_PROTOBUF})
- set(LIBS "${LIBS} -lprotobuf -lgrpc++ -lgrpc -lgpr")
+ set(LIBS "${LIBS} -lprotobuf -latomic -lgrpc++ -lgrpc -lgpr")
set(GAUSSDB_CONFIGURE "${GAUSSDB_CONFIGURE} -DUSE_PROTOBUF")
endif()
add_definitions(-Wno-builtin-macro-redefined)
diff --git a/openGauss-server-2.1.0/config/config.guess b/openGauss-server-2.1.0/config/config.guess
index d622a44..0ed97fe 100644
--- a/openGauss-server-2.1.0/config/config.guess
+++ b/openGauss-server-2.1.0/config/config.guess
@@ -868,6 +868,9 @@ EOF
UNAME_MACHINE=aarch64_be
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
+ sw_64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
diff --git a/openGauss-server-2.1.0/config/config.sub b/openGauss-server-2.1.0/config/config.sub
index 02df9f8..4e99ea1 100644
--- a/openGauss-server-2.1.0/config/config.sub
+++ b/openGauss-server-2.1.0/config/config.sub
@@ -256,6 +256,7 @@ case $basic_machine in
1750a | 580 \
| a29k \
| aarch64 | aarch64_be \
+ | sw_64 \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
@@ -368,6 +369,7 @@ case $basic_machine in
580-* \
| a29k-* \
| aarch64-* | aarch64_be-* \
+ | sw_64-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
diff --git a/openGauss-server-2.1.0/configure b/openGauss-server-2.1.0/configure
index 8446431..5937920 100755
--- a/openGauss-server-2.1.0/configure
+++ b/openGauss-server-2.1.0/configure
@@ -4713,7 +4713,7 @@ fi
# but has its own. Also check other compiler-specific flags here.
if test "$GCC" = yes -a "$ICC" = no; then
- CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe"
+ CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wno-write-strings -latomic -fnon-call-exceptions -fno-common -freg-struct-return -pipe"
if test "$autodepend" = yes; then
CFLAGS="$CFLAGS -fPIC"
fi
@@ -28510,7 +28510,7 @@ if test x"$USE_SSE42_CRC32C" = x"" && test x"$USE_SSE42_CRC32C_WITH_RUNTIME_CHEC
else
# fall back to slicing-by-8 algorithm which doesn't require any special CPU support. USE_SLICING_BY_8_CRC32C=1
# but we need runtime check, so need support special CRC instructions for calculating CRC-32C at compile.
- USE_ARM_CRC32C=1
+ USE_SW_64_CRC32C=1
fi
fi
fi
@@ -28533,11 +28533,11 @@ $as_echo "#define USE_SSE42_CRC32C_WITH_RUNTIME_CHECK 1" >>confdefs.h
PG_CRC32C_OBJS="pg_crc32c_sse42.o pg_crc32c_sb8.o pg_crc32c_choose.o"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: SSE 4.2 with runtime check" >&5
$as_echo "SSE 4.2 with runtime check" >&6; }
- elif test x"$USE_ARM_CRC32C" = x"1"; then
+ elif test x"$USE_SW_64_CRC32C" = x"1"; then
PG_CRC32C_OBJS="pg_crc32c_choose.o"
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: ARM CRC32C" >&5
-$as_echo "ARM CRC32C" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: SW_64 CRC32C" >&5
+$as_echo "SW_64 CRC32C" >&6; }
else
$as_echo "#define USE_SLICING_BY_8_CRC32C 1" >>confdefs.h
diff --git a/openGauss-server-2.1.0/contrib/pgcrypto/crypt-blowfish.cpp b/openGauss-server-2.1.0/contrib/pgcrypto/crypt-blowfish.cpp
index b9f7bfe..1c1e1a9 100644
--- a/openGauss-server-2.1.0/contrib/pgcrypto/crypt-blowfish.cpp
+++ b/openGauss-server-2.1.0/contrib/pgcrypto/crypt-blowfish.cpp
@@ -40,7 +40,7 @@
#ifdef __i386__
#define BF_ASM 0 /* 1 */
#define BF_SCALE 1
-#elif defined(__x86_64__) || defined(__alpha__) || defined(__hppa__)
+#elif defined(__x86_64__) || defined(__alpha__) || defined(__hppa__) || defined(__sw_64__)
#define BF_ASM 0
#define BF_SCALE 1
#else
diff --git a/openGauss-server-2.1.0/src/Makefile.global.in b/openGauss-server-2.1.0/src/Makefile.global.in
index ab8bea3..ff6687a 100644
--- a/openGauss-server-2.1.0/src/Makefile.global.in
+++ b/openGauss-server-2.1.0/src/Makefile.global.in
@@ -546,7 +546,7 @@ CJSON_LIB_PATH = $(CJSON_HOME)/lib
# protobuf component
#############################################################################
PROTOBUF_INCLUDE_PATH = $(PROTOBUF_HOME)/include
-PROTOBUF_LIB_PATH = $(PROTOBUF_HOME)/lib64
+PROTOBUF_LIB_PATH = $(PROTOBUF_HOME)/lib
#############################################################################
# kerberos component
diff --git a/openGauss-server-2.1.0/src/bin/initdb/Makefile b/openGauss-server-2.1.0/src/bin/initdb/Makefile
index 0712306..3c92440 100644
--- a/openGauss-server-2.1.0/src/bin/initdb/Makefile
+++ b/openGauss-server-2.1.0/src/bin/initdb/Makefile
@@ -30,7 +30,8 @@ ifneq "$(MAKECMDGOALS)" "clean"
endif
endif
endif
-OBJS= initdb.o findtimezone.o localtime.o encnames.o pqsignal.o $(WIN32RES) $(top_builddir)/src/lib/elog/elog.a
+#OBJS= initdb.o findtimezone.o localtime.o encnames.o pqsignal.o $(WIN32RES) $(top_builddir)/src/lib/elog/elog.a
+OBJS= initdb.o findtimezone.o localtime.o encnames.o pqsignal.o $(top_builddir)/src/lib/elog/elog.a
all: gs_initdb
gs_initdb: $(OBJS) | submake-libpgport
diff --git a/openGauss-server-2.1.0/src/bin/initdb/initdb.cpp b/openGauss-server-2.1.0/src/bin/initdb/initdb.cpp
index 05ae64e..0dfbf57 100644
--- a/openGauss-server-2.1.0/src/bin/initdb/initdb.cpp
+++ b/openGauss-server-2.1.0/src/bin/initdb/initdb.cpp
@@ -344,15 +344,18 @@ static void InitUndoSubsystemMeta();
exit_nicely(); /* message already printed by popen_check */ \
} while (0)
-#define PG_CMD_CLOSE \
+#define PG_CMD_CLOSE \
do { \
if (pclose_check(cmdfd)) \
exit_nicely(); /* message already printed by pclose_check */ \
} while (0)
-#define PG_CMD_PUTS(line) \
- do { \
- if (fputs((line), cmdfd) < 0 || fflush(cmdfd) < 0) \
+#define PG_CMD_PUTS(line) \
+ do { \
+ if (fputs((line), cmdfd) < 0) \
+ output_failed = true, output_errno = errno; \
+ } while (0)
+ //if (fputs((line), cmdfd) < 0 || fflush(cmdfd) < 0) \
output_failed = true, output_errno = errno; \
} while (0)
@@ -1060,7 +1063,6 @@ static void test_config_settings(void)
printf(_("selecting default max_connections ... "));
(void)fflush(stdout);
-
for (i = 0; i < connslen; i++) {
test_conns = trial_conns[i];
test_buffs = MIN_BUFS_FOR_CONNS(test_conns);
@@ -1088,11 +1090,10 @@ static void test_config_settings(void)
if (i >= connslen) {
i = connslen - 1;
}
-
+
n_connections = trial_conns[i];
printf("%d\n", n_connections);
-
printf(_("selecting default shared_buffers ... "));
(void)fflush(stdout);
@@ -1384,14 +1385,11 @@ static void bootstrap_template1(void)
char* buf_ctype = NULL;
printf(_("creating template1 database in %s/base/1 ... "), pg_data);
-
(void)fflush(stdout);
-
if (debug)
talkargs = "-d 5";
bki_lines = readfile(bki_file);
-
/* Check that bki file appears to be of the right version */
nRet = snprintf_s(headerline, sizeof(headerline), sizeof(headerline) - 1, "# PostgreSQL %s\n", PG_MAJORVERSION);
@@ -1406,7 +1404,7 @@ static void bootstrap_template1(void)
PG_VERSION);
exit_nicely();
}
-
+
/* Substitute for various symbols used in the BKI file */
nRet = sprintf_s(buf, BUF_LENGTH, "%d", NAMEDATALEN);
@@ -1478,18 +1476,17 @@ static void bootstrap_template1(void)
(void)unsetenv("PGCLIENTENCODING");
nRet = snprintf_s(
- cmd, sizeof(cmd), sizeof(cmd) - 1, "\"%s\" --boot -x1 %s %s 2>&1", backend_exec, boot_options, talkargs);
+ cmd, sizeof(cmd), sizeof(cmd) - 1, "\"%s\" --boot -x1 %s %s 2>&1", backend_exec, boot_options, talkargs);
securec_check_ss_c(nRet, "\0", "\0");
-
+ //exit(1);//zmk
PG_CMD_OPEN;
-
for (line = bki_lines; *line != NULL; line++) {
- PG_CMD_PUTS(*line);
+ printf(*line);
+ PG_CMD_PUTS(*line);
FREE_AND_RESET(*line);
}
-
PG_CMD_CLOSE;
-
+
FREE_AND_RESET(bki_lines);
check_ok();
diff --git a/openGauss-server-2.1.0/src/bin/pg_probackup/atomics.h b/openGauss-server-2.1.0/src/bin/pg_probackup/atomics.h
index f28d7d0..89037dd 100644
--- a/openGauss-server-2.1.0/src/bin/pg_probackup/atomics.h
+++ b/openGauss-server-2.1.0/src/bin/pg_probackup/atomics.h
@@ -67,6 +67,8 @@
#if defined(__arm__) || defined(__arm) || \
defined(__aarch64__) || defined(__aarch64)
#include "atomics/arch-arm.h"
+#elif defined(__sw_64__) //modify by yjy
+#include "atomics/arch-sw_64.h"
#elif defined(__i386__) || defined(__i386) || defined(__x86_64__)
#include "atomics/arch-x86.h"
#elif defined(__ia64__) || defined(__ia64)
diff --git a/openGauss-server-2.1.0/src/bin/pg_probackup/atomics/arch-sw_64.h b/openGauss-server-2.1.0/src/bin/pg_probackup/atomics/arch-sw_64.h
new file mode 100644
index 0000000..060ae4e
--- /dev/null
+++ b/openGauss-server-2.1.0/src/bin/pg_probackup/atomics/arch-sw_64.h
@@ -0,0 +1,17 @@
+/*-------------------------------------------------------------------------
+ *
+ * arch-sw_64.h
+ * src/include/port/atomics/arch-sw_64.h
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#if defined(__GNUC__)
+
+#define pg_memory_barrier_impl() __asm__ __volatile__ ("memb" : : : "memory")
+#define pg_read_barrier_impl() __asm__ __volatile__ ("memb" : : : "memory")
+#define pg_write_barrier_impl() __asm__ __volatile__ ("memb" : : : "memory")
+#endif
+
+/* per architecture manual doubleword accesses have single copy atomicity */
+#define PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY
diff --git a/openGauss-server-2.1.0/src/common/port/Makefile b/openGauss-server-2.1.0/src/common/port/Makefile
index 51767b7..be606c2 100644
--- a/openGauss-server-2.1.0/src/common/port/Makefile
+++ b/openGauss-server-2.1.0/src/common/port/Makefile
@@ -60,6 +60,16 @@ OBJS = $(LIBOBJS) pg_crc32c_choose.o chklocale.o dirmod.o erand48.o exec.o fls.o
gs_system.o \
cipher.o
endif
+#modify bu yjy
+ifeq "${host_cpu}" "sw_64"
+OBJS = $(LIBOBJS) pg_crc32c_sb8.o pg_crc32c_choose.o chklocale.o dirmod.o erand48.o exec.o fls.o inet_net_ntop.o \
+ noblock.o path.o pgcheckdir.o pgmkdirp.o pgsleep.o \
+ pgstrcasecmp.o qsort.o qsort_arg.o sprompt.o thread.o flock.o pgstrcasestr.o\
+ gs_thread.o gs_env_r.o gs_getopt_r.o \
+ gs_readdir.o gs_strerror.o gs_syscall_lock.o \
+ gs_system.o \
+ cipher.o
+endif
# foo_srv.o and foo.o are both built from foo.c, but only foo.o has -DFRONTEND
OBJS_SRV = $(OBJS:%.o=%_srv.o)
diff --git a/openGauss-server-2.1.0/src/common/port/exec.cpp b/openGauss-server-2.1.0/src/common/port/exec.cpp
index 0ba9bf3..f73a9b4 100644
--- a/openGauss-server-2.1.0/src/common/port/exec.cpp
+++ b/openGauss-server-2.1.0/src/common/port/exec.cpp
@@ -518,7 +518,6 @@ static char* pipe_read_line(const char* cmd, char* line, int maxsize)
int pclose_check(FILE* stream)
{
int exitstatus = pclose(stream);
-
if (exitstatus == 0) {
return 0; /* all is well */
}
diff --git a/openGauss-server-2.1.0/src/common/port/pg_crc32c_choose.cpp b/openGauss-server-2.1.0/src/common/port/pg_crc32c_choose.cpp
index 3e62f46..c01d55b 100644
--- a/openGauss-server-2.1.0/src/common/port/pg_crc32c_choose.cpp
+++ b/openGauss-server-2.1.0/src/common/port/pg_crc32c_choose.cpp
@@ -47,6 +47,7 @@ uint32 pg_crc32c_hardware(uint32 crc, const void* data, Size len)
}
#endif
+#elif defined(__sw_64__)//modify by yjy
#else
static bool pg_crc32c_sse42_available(void)
diff --git a/openGauss-server-2.1.0/src/gausskernel/CMakeLists.txt b/openGauss-server-2.1.0/src/gausskernel/CMakeLists.txt
index 16aabb7..bfba84c 100755
--- a/openGauss-server-2.1.0/src/gausskernel/CMakeLists.txt
+++ b/openGauss-server-2.1.0/src/gausskernel/CMakeLists.txt
@@ -268,9 +268,9 @@ if(${ENABLE_MEMORY_CHECK})
endif()
if(NOT "${ENABLE_LITE_MODE}" STREQUAL "ON")
- list(APPEND gaussdb_LINK_LIBS -lz -lminiunz -leSDKOBS -leSDKLogAPI -lpcre -liconv -lnghttp2 -llog4cpp -lcurl -llz4 -lcjson -l${JEMALLOC_LIB_NAME} -lcgroup -lorc -lparquet -larrow -lthrift -lsnappy -lzstd -lprotobuf -lcom_err_gauss -lgssapi_krb5_gauss -lkrb5_gauss -lgssrpc_gauss -lk5crypto_gauss -lkadm5clnt_mit -lkadm5srv_mit -lkdb5 -lkrb5support_gauss -lstdc++ -lboost_thread -lboost_chrono -lboost_system -lboost_atomic -lxml2 -laio -lncurses -ltinfo)
+ list(APPEND gaussdb_LINK_LIBS -lz -lminiunz -leSDKOBS -leSDKLogAPI -lpcre -liconv -lnghttp2 -llog4cpp -lcurl -llz4 -lcjson -l${JEMALLOC_LIB_NAME} -lcgroup -lorc -lparquet -larrow -lthrift -lsnappy -lzstd -lprotobuf -lcom_err_gauss -lgssapi_krb5_gauss -lkrb5_gauss -lgssrpc_gauss -lk5crypto_gauss -lkadm5clnt_mit -lkadm5srv_mit -lkdb5 -lkrb5support_gauss -lstdc++ -lboost_thread -lboost_chrono -lboost_system -lboost_atomic -lxml2 -laio -lncurses -ltinfo -latomic)
else()
- list(APPEND gaussdb_LINK_LIBS -lz -lminiunz -lcurl -llz4 -lcjson -l${JEMALLOC_LIB_NAME} -lcgroup -lzstd -lprotobuf -laio -lncurses -ltinfo)
+ list(APPEND gaussdb_LINK_LIBS -lz -lminiunz -lcurl -llz4 -lcjson -l${JEMALLOC_LIB_NAME} -lcgroup -lzstd -lprotobuf -laio -lncurses -ltinfo -latomic)
endif()
include_directories(
diff --git a/openGauss-server-2.1.0/src/gausskernel/bootstrap/bootstrap.cpp b/openGauss-server-2.1.0/src/gausskernel/bootstrap/bootstrap.cpp
index 622b6b6..9559872 100755
--- a/openGauss-server-2.1.0/src/gausskernel/bootstrap/bootstrap.cpp
+++ b/openGauss-server-2.1.0/src/gausskernel/bootstrap/bootstrap.cpp
@@ -341,7 +341,6 @@ void BootStrapProcessMain(int argc, char* argv[])
* XLOG operations
*/
SetProcessingMode(NormalProcessing);
-
switch (t_thrd.bootstrap_cxt.MyAuxProcType) {
case CheckerProcess:
/* don't set signals, they're useless here */
@@ -350,7 +349,7 @@ void BootStrapProcessMain(int argc, char* argv[])
case BootstrapProcess:
bootstrap_signals();
- BootStrapXLOG();
+ //BootStrapXLOG();
MemoryContextUnSeal(t_thrd.top_mem_cxt);
BootstrapModeMain();
MemoryContextSeal(t_thrd.top_mem_cxt);
@@ -383,7 +382,6 @@ static void CheckerModeMain(void)
static void BootstrapModeMain(void)
{
int i;
-
Assert(!IsUnderPostmaster);
SetProcessingMode(BootstrapProcessing);
diff --git a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_atomic.h b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_atomic.h
index 8a0e5c1..3f376ff 100644
--- a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_atomic.h
+++ b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_atomic.h
@@ -38,6 +38,10 @@
#elif defined(__aarch64__)
#include "bbox_atomic_arm64.h"
+/* modify by yjy */
+#elif defined(__sw_64__)
+#include "bbox_atomic_sw_64.h"
+/* end */
#endif
#endif
diff --git a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_atomic_sw_64.h b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_atomic_sw_64.h
new file mode 100644
index 0000000..0948fcc
--- /dev/null
+++ b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_atomic_sw_64.h
@@ -0,0 +1,124 @@
+/* bbox_atomic_sw_64.h
+ *
+ * IDENTIFICATION
+ * src/gausskernel/cbb/bbox/bbox_atomic_sw_64.h
+ * modify by yjy
+ * -------------------------------------------------------------------------
+ */
+
+#ifndef BBOX_ATOMIC_SW_64_H
+#define BBOX_ATOMIC_SW_64_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define barrier() __asm__ __volatile__("memb" : : : "memory")
+#define smp_mb() barrier()
+
+typedef struct {
+ volatile int counter;
+} BBOX_ATOMIC_STRU;
+
+/*
+ init the automic variable.
+ */
+#define BBOX_ATOMIC_INIT(i) \
+ { \
+ (i) \
+ }
+
+/*
+ read the atomic variable atomically.
+ */
+#define BBOX_AtomicRead(v) ((v)->counter)
+
+/*
+ set the value of atomic variable to i atomically.
+ */
+#define BBOX_AtomicSet(v, i) (((v)->counter) = (i))
+
+/*
+ add i to the atomic variable atomically.
+ */
+static inline void BBOX_AtomicAdd(int i, BBOX_ATOMIC_STRU* v)
+{
+ unsigned long tmp;
+ int result,cmp;
+
+ __asm__ __volatile__(
+ " ldi %1, %4 \n"
+ "1: lldw %0,0(%1)\n"
+ " ldi %2,1 \n"
+ " wr_f %2 \n"
+ " addw %0,%3,%0\n"
+ " lstw %0,0(%1)\n"
+ " rd_f %2 \n"
+ " beq %2, 1b \n"
+ : "=&r"(result), "=&r"(tmp), "=&r"(cmp)
+ : "Ir"(i),"m"(v->counter));
+}
+
+/*
+ add i to the atomic variable atomically and return new value.
+ */
+static inline int BBOX_AtomicAddReturn(int i, BBOX_ATOMIC_STRU* v)
+{
+ unsigned long tmp;
+ int result,cmp;
+
+ __asm__ __volatile__(
+ " ldi %1, %4 \n"
+ "1: lldw %0,0(%1)\n"
+ " ldi %2,1 \n"
+ " wr_f %2 \n"
+ " addw %0,%3,%0\n"
+ " lstw %0,0(%1)\n"
+ " rd_f %2 \n"
+ " beq %2, 1b \n"
+ : "=&r"(result), "=&r"(tmp), "=&r"(cmp)
+ : "Ir"(i),"m"(v->counter)
+ : "memory");
+
+ smp_mb();
+ return result;
+}
+
+#define BBOX_AtomicIncReturn(v) BBOX_AtomicAddReturn(1, (v))
+
+/*
+ sub i of the value of atomic variable atomically.
+ */
+static inline void BBOX_AtomicSub(int i, BBOX_ATOMIC_STRU* v)
+{
+ unsigned long tmp;
+ int result,cmp;
+
+ __asm__ __volatile__(
+ " ldi %1, %4 \n"
+ "1: lldw %0,0(%1)\n"
+ " ldi %2,1 \n"
+ " wr_f %2 \n"
+ " subw %0,%3,%0\n"
+ " lstw %0,0(%1)\n"
+ " rd_f %2 \n"
+ " beq %2, 1b \n"
+ : "=&r"(result), "=&r"(tmp), "=&r"(cmp)
+ : "Ir"(i),"m"(v->counter));
+}
+
+/*
+ add l to the atomic variable atomically.
+ */
+#define BBOX_AtomicInc(v) BBOX_AtomicAdd(1, v)
+
+/*
+ sub l of the value of atomic variable atomically.
+ */
+#define BBOX_AtomicDec(v) BBOX_AtomicSub(1, v)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_elf_dump.cpp b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_elf_dump.cpp
index 4a9b209..68c204d 100644
--- a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_elf_dump.cpp
+++ b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_elf_dump.cpp
@@ -1177,7 +1177,7 @@ static int BBOX_FillPrPsInfo(struct BBOX_ELF_PRPSINFO* pstPrPsInfo, pid_t tMainP
pstPrPsInfo->cSname = 'R';
pstPrPsInfo->cNice = (signed char)sys_getpriority(PRIO_PROCESS, 0);
-#if (defined(__x86_64__)) || (defined(__aarch64__))
+#if (defined(__x86_64__)) || (defined(__aarch64__))|| (defined(__sw_64__)) //add sw_64 modify by yjy
pstPrPsInfo->tUid = (uint32_t)sys_geteuid();
pstPrPsInfo->tGid = (uint32_t)sys_getegid();
#elif (defined(__i386__)) || (defined(__ARM_ARCH_5TE__)) || (defined(__ARM_ARCH_7A__))
@@ -1741,7 +1741,7 @@ static int BBOX_FillEhdr(BBOX_EHDR* pstEhdr, int iPhdrSum)
#if (defined(__i386__))
pstEhdr->e_phnum = (Elf32_Half)(iPhdrSum + 1); /* Number of memory address space segments plus note segments */
pstEhdr->e_shnum = (Elf32_Half)(BBOX_SECTION_NUM);
-#elif (defined(__x86_64__)) || (defined(__ARM_ARCH_5TE__)) || (defined(__ARM_ARCH_7A__)) || (defined(__aarch64__))
+#elif (defined(__x86_64__)) || (defined(__ARM_ARCH_5TE__)) || (defined(__ARM_ARCH_7A__)) || (defined(__aarch64__))|| (defined(__sw_64__)) //add sw_64 modify by yjy
pstEhdr->e_phnum = (Elf64_Half)(iPhdrSum + 1); /* Number of memory address space segments plus note segments */
pstEhdr->e_shnum = (Elf64_Half)(BBOX_SECTION_NUM);
#endif
@@ -2301,7 +2301,7 @@ static int BBOX_WritePrPsStatusToFile(struct BBOX_ELF_PRPSSTATUS* pstPrPsStatusI
static int BBOX_WriteFpRegistersToFile(struct BBOX_FPREGSET* pstFpRegisters, struct BBOX_WRITE_FDS* pstFileFds)
{
/* since ptrace() doesn't support to obtain float registers' context in aarch64, don't dump it out. */
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) || !defined(__sw_64__) //add sw_64 modify by yjy
BBOX_NHDR stElfNhdr;
if (NULL == pstFpRegisters || NULL == pstFileFds) {
diff --git a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_elf_dump.h b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_elf_dump.h
index 9b6f751..543a6a6 100644
--- a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_elf_dump.h
+++ b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_elf_dump.h
@@ -142,6 +142,10 @@ extern "C" {
#define ELF_ARCH EM_ARM
#elif defined(__aarch64__)
#define ELF_ARCH EM_AARCH64
+/* modify by yjy */
+#elif defined(__sw_64__)
+#define ELF_ARCH EM_SW_64
+/* end */
#endif
#ifndef AT_SYSINFO_EHDR
@@ -233,6 +237,83 @@ typedef struct Frame {
(f).uregs.gs_base = (r).gs_base; \
(r) = (f).uregs; \
} while (0)
+
+/* modify by yjy */
+#elif (defined(__sw_64__))
+/* member variable are named by register. */
+struct sw_64_regs {
+ #define BP fp
+ #define SP sp
+ #define IP pc
+ uint64_t r0, r1, r2, r3, r4, r5, r6,r7,r8; //Tmp registers
+ uint64_t r9, r10,r11,r12,r13,r14,r15; //save registers
+ uint64_t r16, r17, r18, r19,r20,r21; //Parm regsiters
+ uint64_t r22,r23,r24,r25; //Tmp registers
+ uint64_t r26; //Returen register
+ uint64_t r27;
+ uint64_t r28;
+};
+
+/* 64 CPU */
+#define CPURegs sw_64_regs
+
+typedef struct Frame {
+ struct CPURegs uregs;
+ int errno_;
+ pid_t tid;
+} Frame;
+
+/* save call frame */
+#define FRAME(fm) \
+ Frame fm; \
+ do { \
+ fm.errno_ = errno; \
+ fm.tid = sys_gettid(); \
+ __asm__ volatile("stl $0,0(%0) \n" \
+ "stl $1,8(%0) \n" \
+ "stl $2,16(%0) \n" \
+ "stl $3,24(%0) \n" \
+ "stl $4,32(%0) \n" \
+ "stl $5,40(%0) \n" \
+ "stl $6,48(%0) \n" \
+ "stl $7,56(%0) \n" \
+ "stl $8,64(%0) \n" \
+ "stl $9,72(%0) \n" \
+ "stl $10,80(%0) \n" \
+ "stl $11,88(%0) \n" \
+ "stl $12,96(%0) \n" \
+ "stl $13,104(%0) \n" \
+ "stl $14,112(%0) \n" \
+ "stl $15,120(%0) \n" \
+ "stl $16,128(%0) \n" \
+ "stl $17,136(%0) \n" \
+ "stl $18,144(%0) \n" \
+ "stl $19,152(%0) \n" \
+ "stl $20,160(%0) \n" \
+ "stl $21,168(%0) \n" \
+ "stl $22,176(%0) \n" \
+ "stl $23,184(%0) \n" \
+ "stl $24,192(%0) \n" \
+ "stl $25,200(%0) \n" \
+ "stl $26,208(%0) \n" \
+ "stl $27,216(%0) \n" \
+ "stl $28,224(%0) \n" \
+ "stl $29,232(%0) \n" \
+ "stl $30,240(%0) \n" \
+ "mov $sp,$10 \n" \
+ "stl $10,248(%0) \n" \
+ "1:" \
+ : \
+ : "a"(&fm) \
+ : "memory"); \
+ } while (0)
+
+#define SET_FRAME(f, r) \
+ do { \
+ errno = (f).errno_; \
+ (r) = (f).uregs; \
+ } while (0)
+/* end */
#elif (defined(__i386__))
/* member variable are named by register. */
@@ -420,7 +501,7 @@ struct BBOX_ELF_PRPSINFO { /* Information about process */
unsigned char ucZomb; /* Zombie */
signed char cNice; /* Nice val */
unsigned long ulLlag; /* Flags */
-#if (defined(__x86_64__)) || (defined(__aarch64__))
+#if (defined(__x86_64__)) || (defined(__aarch64__)) || (defined(__sw_64)) //add sw_64 modify by yjy
uint32_t tUid; /* User ID */
uint32_t tGid; /* Group ID */
#else
@@ -517,6 +598,17 @@ struct BBOX_FPXREGSET { /* x86-64 stores FPU registers in SSE struct */
struct BBOX_FPREGSET { /* FPU registers */
/* nothing */
};
+* modify by yjy */
+#elif defined(__sw_64__)
+struct BBOX_FPXREGSET { /* sw-64 stores FPU */
+ /* nothing */
+};
+
+/* member variable are named by register. */
+struct BBOX_FPREGSET { /* FPU registers */
+ /* nothing */
+};
+/* end */
#endif
struct BBOX_ELF_PRPSSTATUS { /* Information about thread; includes CPU reg */
diff --git a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_SW_64.h b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_SW_64.h
new file mode 100644
index 0000000..14438b9
--- /dev/null
+++ b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_SW_64.h
@@ -0,0 +1,136 @@
+/* bbox_syscall_SW_64.h
+ *
+ * IDENTIFICATION
+ * src/gausskernel/cbb/bbox/bbox_syscall_SW_64.h
+ * modify by yjy
+ * -------------------------------------------------------------------------
+ */
+#ifndef __BBOX_SYSCALL_SW_64_H_
+#define __BBOX_SYSCALL_SW_64_H_
+
+#include <sys/syscall.h>
+#include <sys/errno.h>
+#define SYS_NAME(name) sys_##name
+#define SYS_CODE(syscall_code) (__NR_##syscall_code)
+
+#define ___syscall_return(type, ___res) \
+ do { \
+ if ((unsigned long)(___res) >= (unsigned long)(-4095)) { \
+ errno = -(___res); \
+ ___res = -1; \
+ } \
+ return (type)(___res); \
+ } while (0)
+
+#define __syscall0(type, name) \
+ type SYS_NAME(name)() \
+ { \
+ long ___res; \
+ register long _r0 asm("$0")= SYS_CODE(name); \
+ asm("sys_call 0x83 \n" \
+ :"=r"(_r0) \
+ :"r"(_r0) \
+ : "memory"); \
+ ___res=_r0; \
+ ___syscall_return(type,___res); \
+ }
+
+#define __syscall1(type, name, type1, arg1) \
+ type SYS_NAME(name)(type1 arg1) \
+ { \
+ long ___res; \
+ register long _r0 asm("$0") = SYS_CODE(name);\
+ register long _r16 asm("$16")= (long)arg1; \
+ asm("sys_call 0x83 \n" \
+ :"=r"(_r0) \
+ :"r"(_r0),"r"(_r16) \
+ : "memory"); \
+ ___res=_r0; \
+ ___syscall_return(type,___res); \
+ }
+
+#define __syscall2(type, name, type1, arg1, type2, arg2) \
+ type SYS_NAME(name)(type1 arg1, type2 arg2) \
+ { \
+ long ___res; \
+ register long _r0 asm("$0") = SYS_CODE(name); \
+ register long _r16 asm("$16")= (long)arg1; \
+ register long _r17 asm("$17")= (long)arg2; \
+ asm("sys_call 0x83 \n" \
+ :"=r"(_r0) \
+ :"r"(_r0),"r"(_r16),"r"(_r17) \
+ : "memory"); \
+ ___res=_r0; \
+ ___syscall_return(type,___res); \
+ }
+
+#define __syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
+ type SYS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) \
+ { \
+ long ___res; \
+ register long _r0 asm("$0") = SYS_CODE(name); \
+ register long _r16 asm("$16")= (long)arg1; \
+ register long _r17 asm("$17")= (long)arg2; \
+ register long _r18 asm("$18")= (long)arg3; \
+ asm("sys_call 0x83 \n" \
+ :"=r"(_r0) \
+ :"r"(_r0),"r"(_r16),"r"(_r17),"r"(_r18) \
+ : "memory"); \
+ ___res=_r0; \
+ ___syscall_return(type,___res); \
+ }
+
+#define __syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \
+ type SYS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+ { \
+ long ___res; \
+ register long _r0 asm("$0") = SYS_CODE(name); \
+ register long _r16 asm("$16")= (long)arg1; \
+ register long _r17 asm("$17")= (long)arg2; \
+ register long _r18 asm("$18")= (long)arg3; \
+ register long _r19 asm("$19")= (long)arg4; \
+ asm("sys_call 0x83 \n" \
+ :"=r"(_r0) \
+ :"r"(_r0),"r"(_r16),"r"(_r17),"r"(_r18),"r"(_r19) \
+ : "memory"); \
+ ___res=_r0; \
+ ___syscall_return(type,___res); \
+ }
+
+#define __syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \
+ type SYS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
+ { \
+ long ___res; \
+ register long _r0 asm("$0") = SYS_CODE(name); \
+ register long _r16 asm("$16")= (long)arg1; \
+ register long _r17 asm("$17")= (long)arg2; \
+ register long _r18 asm("$18")= (long)arg3; \
+ register long _r19 asm("$19")= (long)arg4; \
+ register long _r20 asm("$20")= (long)arg5; \
+ asm("sys_call 0x83 \n" \
+ :"=r"(_r0) \
+ :"r"(_r0),"r"(_r16),"r"(_r17),"r"(_r18),"r"(_r19),"r"(_r20) \
+ : "memory"); \
+ ___res=_r0; \
+ ___syscall_return(type,___res); \
+ }
+
+#define __syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6) \
+ type SYS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
+ { \
+ long ___res; \
+ register long _r0 asm("$0") = SYS_CODE(name); \
+ register long _r16 asm("$16")= (long)arg1; \
+ register long _r17 asm("$17")= (long)arg2; \
+ register long _r18 asm("$18")= (long)arg3; \
+ register long _r19 asm("$19")= (long)arg4; \
+ register long _r20 asm("$20")= (long)arg5; \
+ register long _r21 asm("$21")= (long)arg6; \
+ asm("sys_call 0x83 \n" \
+ :"=r"(_r0) \
+ :"r"(_r0),"r"(_r16),"r"(_r17),"r"(_r18),"r"(_r19),"r"(_r20),"r"(_r21) \
+ : "memory"); \
+ ___res=_r0; \
+ ___syscall_return(type,___res); \
+ }
+#endif
diff --git a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_support.cpp b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_support.cpp
index 86398ec..462a029 100644
--- a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_support.cpp
+++ b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_support.cpp
@@ -595,5 +595,94 @@ long SYS_NAME(_clone)(
___res = __res_x0;
___syscall_return(int, ___res);
}
+/* modify by yjy */
+#elif (defined(__sw_64__))
+__syscall3(long, socket, int, family, int, type, int, protocol);
+
+long SYS_NAME(waitpid)(pid_t pid, int* status, int options)
+{
+ return SYS_NAME(wait4)(pid, status, options, 0);
+}
+
+long SYS_NAME(signal)(int __signum, void (*handler)(int))
+{
+ struct kernel_sigaction _sa;
+ struct kernel_sigaction old;
+ errno_t rc = memset_s(&_sa, sizeof(_sa), 0, sizeof(_sa));
+ securec_check_c(rc, "\0", "\0");
+ sys_sigfillset(&_sa.sa_mask);
+ _sa.sa_flags |= SA_RESTORER | SA_RESTART;
+ _sa.handle.sa_handler_ = handler;
+
+ return SYS_NAME(rt_sigaction)(__signum, &_sa, &old, (KERNEL_NSIG + 7) / 8);
+}
+
+long SYS_NAME(_clone)(
+ int (*fn)(void*), void* child_stack, int flags, void* arg, int* parent_tidptr, void* newtls, int* child_tidptr)
+{
+ register long result_r0 __asm__("$0");
+ long ___res;
+ int tmp = 0;
+ {
+ register int (*fn_tmp)(void*) __asm__("$16") = fn;
+ register void* stack_tmp __asm__("$17") = child_stack;
+ register int flags_tmp __asm__("$18") = flags;
+ register void* arg_tmp __asm__("$19") = arg;
+ register int* ptid_tmp __asm__("$20") = parent_tidptr;
+ register void* tls_tmp __asm__("$21") = newtls;
+ register int* ctid_tmp __asm__("$22") = child_tidptr;
+
+ __asm__ __volatile__(
+
+ /*if (fn == NULL || child_stack == NULL) return -EINVAL; */
+ "beq $16,1f\n"
+ "beq $17,1f\n"
+
+ "ldi $17,-16($17)\n"
+ "stl $16,0($17) \n"
+ "stl $19,8($17) \n"
+
+ "mov $18,$16 \n" /* flags */
+ "mov $20,$18 \n" /* ptid */
+ "mov $21,$19 \n" /* tls */
+ "mov $22,$20 \n" /* ctid */
+ "mov %9,$0 \n" /* save __NR_clone into $0 register */
+ "sys_call 0x83\n"
+
+ /* example: if (%r0 != 0) return %r0; */
+ "cmpeq $0,0,%11\n"
+ "beq %11,2f\n"
+
+ /* In the child, now. Call "fn(arg)".
+ */
+ "ldl $16, 0($sp)\n"
+ "ldl $17, 8($sp)\n"
+ "mov $17, $27 \n"
+ "call $31, ($27),0x0\n"
+ /* example: Call _exit(%r0).
+ */
+ "mov %10, $0 \n" /*save __NR_exit into $0 register*/
+ "sys_call 0x83\n"
+ "1: \n"
+ "mov %1, $0 \n"
+ "2: \n"
+ : "=r"(result_r0)
+ : "i"(-EINVAL),
+ "r"(fn_tmp),
+ "r"(stack_tmp),
+ "r"(flags_tmp),
+ "r"(arg_tmp),
+ "r"(ptid_tmp),
+ "r"(tls_tmp),
+ "r"(ctid_tmp),
+ "i"(__NR_clone),
+ "i"(__NR_exit),
+ "r"(tmp)
+ : "$26", "memory");
+ }
+ ___res = result_r0;
+ ___syscall_return(int, ___res);
+}
+/* end */
#endif
diff --git a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_support.h b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_support.h
index c131a57..5938ef0 100644
--- a/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_support.h
+++ b/openGauss-server-2.1.0/src/gausskernel/cbb/bbox/bbox_syscall_support.h
@@ -73,11 +73,16 @@
#include "bbox_syscall_ARM.h"
#elif (defined(__aarch64__))
#include "bbox_syscall_ARM64.h"
+/* modify by yjy */
+#elif (defined(__sw_64__))
+#include "bbox_syscall_SW_64.h"
+/*end*/
#endif
#define SA_RESTORER 0x04000000
#define KERNEL_NSIG 64
-#define EM_AARCH64 183
+#define EM_AARCH64 183
+#define EM_SW_64 0x9916//modify by yjy
#if (defined(__aarch64__))
struct linux_dirent {
@@ -197,6 +202,29 @@ struct kernel_stat {
unsigned int __unused4;
unsigned int __unused5;
};
+/* modify by yjy */
+#elif (defined(__sw_64__))
+struct kernel_stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_rdev;
+ long st_size;
+ unsigned long st_blocks;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int st_blksize;
+ unsigned int __pad0;
+ unsigned long st_atime_;
+ unsigned long st_atime_nsec_;
+ unsigned long st_mtime_;
+ unsigned long st_mtime_nsec_;
+ unsigned long st_ctime_;
+ unsigned long st_ctime_nsec_;
+ long __unused[3];
+};
+/* end */
#endif
extern long SYS_NAME(gettid)(void);
@@ -295,5 +323,13 @@ extern long SYS_NAME(signal)(int _signum, void (*handler)(int));
extern long SYS_NAME(socket)(int domain, int type, int protocol);
extern long SYS_NAME(_clone)(
int (*fn)(void*), void* child_stack, int flags, void* arg, int* parent_tidptr, void* newtls, int* child_tidptr);
+/* modify by yjy */
+#elif (defined(__sw_64__))
+extern long SYS_NAME(waitpid)(pid_t pid, int* status, int options);
+extern long SYS_NAME(signal)(int _signum, void (*handler)(int));
+extern long SYS_NAME(socket)(int domain, int type, int protocol);
+extern long SYS_NAME(_clone)(
+ int (*fn)(void*), void* child_stack, int flags, void* arg, int* parent_tidptr, void* newtls, int* child_tidptr);
+/* end */
#endif
#endif
diff --git a/openGauss-server-2.1.0/src/gausskernel/process/main/main.cpp b/openGauss-server-2.1.0/src/gausskernel/process/main/main.cpp
index 02eb5f1..4a19a47 100755
--- a/openGauss-server-2.1.0/src/gausskernel/process/main/main.cpp
+++ b/openGauss-server-2.1.0/src/gausskernel/process/main/main.cpp
@@ -78,7 +78,6 @@ int main(int argc, char* argv[])
{
char* mmap_env = NULL;
syscall_lock_init();
-
mmap_env = gs_getenv_r("GAUSS_MMAP_THRESHOLD");
if (mmap_env != NULL) {
check_backend_env(mmap_env);
@@ -322,7 +321,7 @@ static void startup_hacks(const char* progname)
*/
#ifdef NOFIXADE
-#if defined(__alpha) /* no __alpha__ ? */
+#if defined(__alpha) || defined(__sw_64) /* no __alpha__ ? */
{
int buffer[] = {SSIN_UACPROC, UAC_SIGBUS | UAC_NOPRINT};
diff --git a/openGauss-server-2.1.0/src/gausskernel/process/postmaster/postmaster.cpp b/openGauss-server-2.1.0/src/gausskernel/process/postmaster/postmaster.cpp
index 2407ef8..9231dfa 100644
--- a/openGauss-server-2.1.0/src/gausskernel/process/postmaster/postmaster.cpp
+++ b/openGauss-server-2.1.0/src/gausskernel/process/postmaster/postmaster.cpp
@@ -844,7 +844,7 @@ void get_coredump_pattern_path(char* path, Size len)
if (0 != stat(path, &stat_buf) || !S_ISDIR(stat_buf.st_mode) || 0 != access(path, W_OK)) {
write_stderr("The core dump path is an invalid directory\n");
- *path = '\0';
+ *path = '\0';
return;
}
}
diff --git a/openGauss-server-2.1.0/src/gausskernel/runtime/executor/instrument.cpp b/openGauss-server-2.1.0/src/gausskernel/runtime/executor/instrument.cpp
index 24be0e6..72a6a6e 100644
--- a/openGauss-server-2.1.0/src/gausskernel/runtime/executor/instrument.cpp
+++ b/openGauss-server-2.1.0/src/gausskernel/runtime/executor/instrument.cpp
@@ -86,6 +86,12 @@ static inline uint64 rdtsc(void)
asm volatile("isb; mrs %0, cntvct_el0" : "=r"(cval) : : "memory");
return cval;
+/* modify by yjy */
+#elif defined(__sw_64__)
+ unsigned long time_val = 0;
+ __asm__ __volatile__("rtc %0" : "=r"(time_val) : : "memory");
+ return time_val;
+/* end */
#else
uint32 hi = 0;
uint32 lo = 0;
diff --git a/openGauss-server-2.1.0/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichash.cpp b/openGauss-server-2.1.0/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichash.cpp
index cc14674..3b45dbb 100644
--- a/openGauss-server-2.1.0/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichash.cpp
+++ b/openGauss-server-2.1.0/src/gausskernel/runtime/vecexecutor/vectorsonic/vsonichash.cpp
@@ -30,6 +30,7 @@
#include "utils/dynahash.h"
#ifdef __aarch64__
#include <arm_acle.h>
+#elif defined(__sw_64__)
#else
#include <nmmintrin.h>
#endif
@@ -40,8 +41,10 @@ extern bool anls_opt_is_on(AnalysisOpt dfx_opt);
#define HASH_RANDOM_2 1.1131347
#define HASH_RANDOM_3 1.0132677
-#ifdef __aarch64__
+#if defined __aarch64__
#define HASH_INT32_CRC(c, k) __crc32cw(c, k)
+#elif defined(__sw_64__)
+#define HASH_INT32_CRC(c, k) c
#else
#define HASH_INT32_CRC(c, k) _mm_crc32_u32(c, k)
#endif
@@ -58,7 +61,7 @@ uint32 hashquickany(uint32 seed, register const unsigned char* data, register in
uint32 crc = seed;
-#ifdef __aarch64__
+#if defined __aarch64__
while (p + 8 <= pend) {
crc = (uint32)__crc32d(crc, *((const uint64*)p));
p += 8;
@@ -75,6 +78,8 @@ uint32 hashquickany(uint32 seed, register const unsigned char* data, register in
crc = __crc32cb(crc, *p);
p++;
}
+#elif defined(__sw_64__)
+ return crc;
#else
while (p + 8 <= pend) {
crc = (uint32)_mm_crc32_u64(crc, *((const uint64*)p));
diff --git a/openGauss-server-2.1.0/src/gausskernel/storage/access/transam/extreme_rto/page_redo.cpp b/openGauss-server-2.1.0/src/gausskernel/storage/access/transam/extreme_rto/page_redo.cpp
index ceda891..e5c6379 100755
--- a/openGauss-server-2.1.0/src/gausskernel/storage/access/transam/extreme_rto/page_redo.cpp
+++ b/openGauss-server-2.1.0/src/gausskernel/storage/access/transam/extreme_rto/page_redo.cpp
@@ -207,7 +207,7 @@ PageRedoWorker *CreateWorker(uint32 id)
PosixSemaphoreInit(&worker->phaseMarker, 0);
worker->oldCtx = NULL;
worker->fullSyncFlag = 0;
-#if (!defined __x86_64__) && (!defined __aarch64__)
+#if (!defined __x86_64__) && (!defined __aarch64__) && (!defined __sw_64__)
SpinLockInit(&worker->ptrLck);
#endif
worker->parseManager.memctl.isInit = false;
@@ -236,7 +236,7 @@ void DestroyPageRedoWorker(PageRedoWorker *worker)
void SetCompletedReadEndPtr(PageRedoWorker *worker, XLogRecPtr readPtr, XLogRecPtr endPtr)
{
volatile PageRedoWorker *tmpWk = worker;
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
uint128_u exchange;
uint128_u current;
uint128_u compare = atomic_compare_and_swap_u128((uint128_u *)&tmpWk->lastReplayedReadRecPtr);
@@ -258,14 +258,14 @@ loop:
tmpWk->lastReplayedReadRecPtr = readPtr;
tmpWk->lastReplayedEndRecPtr = endPtr;
SpinLockRelease(&tmpWk->ptrLck);
-#endif /* __x86_64__ || __aarch64__ */
+#endif /* __x86_64__ || __aarch64__ || __sw_64__*/
}
/* automic write for lastReplayedReadRecPtr and lastReplayedEndRecPtr */
void GetCompletedReadEndPtr(PageRedoWorker *worker, XLogRecPtr *readPtr, XLogRecPtr *endPtr)
{
volatile PageRedoWorker *tmpWk = worker;
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
uint128_u compare = atomic_compare_and_swap_u128((uint128_u *)&tmpWk->lastReplayedReadRecPtr);
Assert(sizeof(tmpWk->lastReplayedReadRecPtr) == 8);
Assert(sizeof(tmpWk->lastReplayedEndRecPtr) == 8);
@@ -277,7 +277,7 @@ void GetCompletedReadEndPtr(PageRedoWorker *worker, XLogRecPtr *readPtr, XLogRec
*readPtr = tmpWk->lastReplayedReadRecPtr;
*endPtr = tmpWk->lastReplayedEndRecPtr;
SpinLockRelease(&tmpWk->ptrLck);
-#endif /* __x86_64__ || __aarch64__ */
+#endif /* __x86_64__ || __aarch64__ || __sw_64__ */
}
/* Run from both the dispatcher and the worker thread. */
diff --git a/openGauss-server-2.1.0/src/gausskernel/storage/access/transam/xlog.cpp b/openGauss-server-2.1.0/src/gausskernel/storage/access/transam/xlog.cpp
index cb9f91e..21a72e1 100755
--- a/openGauss-server-2.1.0/src/gausskernel/storage/access/transam/xlog.cpp
+++ b/openGauss-server-2.1.0/src/gausskernel/storage/access/transam/xlog.cpp
@@ -13,6 +13,7 @@
*
* -------------------------------------------------------------------------
*/
+//#ifndef __sw_64__
#include "postgres.h"
#include "knl/knl_variable.h"
@@ -259,7 +260,7 @@ TransactionId OldestXidAfterRecovery;
*/
typedef struct {
LWLock lock;
-#ifdef __aarch64__
+#if defined(__aarch64__) || defined(__sw_64__)
pg_atomic_uint32 xlogGroupFirst;
#endif
XLogRecPtr insertingAt;
@@ -292,7 +293,7 @@ typedef struct XLogCtlInsert {
uint32 PrevByteSize;
int32 CurrLRC;
-#if (!defined __x86_64__) && (!defined __aarch64__)
+#if (!defined __x86_64__) && (!defined __aarch64__) && (!defined __sw_64__ )
slock_t insertpos_lck; /* protects CurrBytePos and PrevBytePos */
#endif
/*
@@ -669,7 +670,7 @@ bool mpfl_pread_file(int fd, void *buf, int32 size, int64 offset);
int ParallelXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr,
TimeLineID *readTLI);
-#ifdef __aarch64__
+#if defined(__aarch64__)
static XLogRecPtr XLogInsertRecordGroup(XLogRecData *rdata, XLogRecPtr fpw_lsn);
static void XLogInsertRecordNolock(XLogRecData *rdata, PGPROC *proc, XLogRecPtr StartPos, XLogRecPtr EndPos,
@@ -1091,7 +1092,7 @@ static void ReserveXLogInsertByteLocation(uint32 size, uint32 lastRecordSize, ui
* because the usable byte position doesn't include any headers, reserving
* X bytes from WAL is almost as simple as "CurrBytePos += X".
*/
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
union Union128 compare;
union Union128 exchange;
union Union128 current;
@@ -1622,7 +1623,7 @@ static void ReserveXLogInsertLocation(uint32 size, XLogRecPtr* StartPos, XLogRec
* because the usable byte position doesn't include any headers, reserving
* X bytes from WAL is almost as simple as "CurrBytePos += X".
*/
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
union Union128 compare;
union Union128 exchange;
union Union128 current;
@@ -1709,7 +1710,7 @@ static bool ReserveXLogSwitch(XLogRecPtr *StartPos, XLogRecPtr *EndPos, XLogRecP
* are no other inserters competing for it. GetXLogInsertRecPtr() does
* compete for it, but that's not called very frequently.
*/
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
uint128_u exchange;
uint128_u current;
uint128_u compare = atomic_compare_and_swap_u128((uint128_u*)&Insert->CurrBytePos);
@@ -2623,7 +2624,7 @@ static void AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic, PGPROC *p
XLogwrtResult *LogwrtResultPtr = NULL;
TimeLineID xlogTimeLineID = 0;
-#ifdef __aarch64__
+#if defined __aarch64__
if (isGroupInsert) {
LogwrtResultPtr = (XLogwrtResult *)proc->xlogGroupLogwrtResult;
xlogTimeLineID = proc->xlogGroupTimeLineID;
@@ -6314,6 +6315,7 @@ static void WriteControlFile(void)
COMP_CRC32C(t_thrd.shemem_ptr_cxt.ControlFile->crc, (char *)t_thrd.shemem_ptr_cxt.ControlFile,
offsetof(ControlFileData, crc));
FIN_CRC32C(t_thrd.shemem_ptr_cxt.ControlFile->crc);
+
/*
* We write out PG_CONTROL_SIZE bytes into pg_control, zero-padding the
@@ -6331,6 +6333,7 @@ static void WriteControlFile(void)
errorno = memcpy_s(buffer, PG_CONTROL_SIZE, t_thrd.shemem_ptr_cxt.ControlFile, sizeof(ControlFileData));
securec_check(errorno, "", "");
+ securec_check(errorno, "", "");
#ifdef USE_ASSERT_CHECKING
#define MAX_SIZE 1024
@@ -6938,7 +6941,7 @@ void XLOGShmemInit(void)
LWLockInitialize(&t_thrd.shemem_ptr_cxt.GlobalWALInsertLocks[processorIndex][i].l.lock,
LWTRANCHE_WAL_INSERT);
t_thrd.shemem_ptr_cxt.GlobalWALInsertLocks[processorIndex][i].l.insertingAt = InvalidXLogRecPtr;
-#ifdef __aarch64__
+#if defined __aarch64__ || defined __sw_64__
pg_atomic_init_u32(&t_thrd.shemem_ptr_cxt.GlobalWALInsertLocks[processorIndex][i].l.xlogGroupFirst,
INVALID_PGPROCNO);
#endif
@@ -6974,7 +6977,7 @@ void XLOGShmemInit(void)
t_thrd.shemem_ptr_cxt.XLogCtl->lastRemovedSegNo = GetOldestXLOGSegNo(t_thrd.proc_cxt.DataDir);
}
-#if (!defined __x86_64__) && (!defined __aarch64__)
+#if (!defined __x86_64__) && (!defined __aarch64__) && (!defined __sw_64__)
SpinLockInit(&t_thrd.shemem_ptr_cxt.XLogCtl->Insert.insertpos_lck);
#endif
SpinLockInit(&t_thrd.shemem_ptr_cxt.XLogCtl->info_lck);
@@ -7136,7 +7139,6 @@ void BootStrapXLOG(void)
page = (XLogPageHeader)TYPEALIGN(XLOG_BLCKSZ, buffer);
ret = memset_s(page, XLOG_BLCKSZ, 0, XLOG_BLCKSZ);
securec_check(ret, "", "");
-
/*
* Set up information for the initial checkpoint record
*
@@ -7287,6 +7289,7 @@ void BootStrapXLOG(void)
/* Bootstrap the commit log, too */
BootStrapCLOG();
+ BootStrapCLOG();
BootStrapCSNLOG();
BootStrapMultiXact();
@@ -14978,7 +14981,7 @@ XLogRecPtr do_roach_stop_backup(const char *backupidstr)
stoppoint = t_thrd.shemem_ptr_cxt.ControlFile->minRecoveryPoint;
LWLockRelease(ControlFileLock);
} else {
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
current_bytepos = pg_atomic_barrier_read_u64((uint64*)&Insert->CurrBytePos);
stoppoint = XLogBytePosToEndRecPtr(current_bytepos);
#else
@@ -15228,7 +15231,7 @@ XLogRecPtr enable_delay_ddl_recycle(void)
LWLockAcquire(CBMParseXlogLock, LW_EXCLUSIVE);
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
uint64 current_bytepos = pg_atomic_barrier_read_u64((uint64*)&Insert->CurrBytePos);
curDelayRange.startLSN = XLogBytePosToEndRecPtr(current_bytepos);
#else
@@ -15362,7 +15365,7 @@ void disable_delay_ddl_recycle(XLogRecPtr barrierLSN, bool isForce, XLogRecPtr *
*/
LWLockAcquire(RelfilenodeReuseLock, LW_EXCLUSIVE);
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
uint64 current_bytepos = pg_atomic_barrier_read_u64((uint64*)&Insert->CurrBytePos);
delayRange.endLSN = XLogBytePosToEndRecPtr(current_bytepos);
#else
@@ -15444,7 +15447,7 @@ XLogRecPtr enable_delay_ddl_recycle_with_slot(const char* slotname)
/* hold this lock to push cbm parse exact to the ddl stop position */
LWLockAcquire(CBMParseXlogLock, LW_EXCLUSIVE);
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
uint64 current_bytepos = pg_atomic_barrier_read_u64((uint64*)&Insert->CurrBytePos);
delay_start_lsn = XLogBytePosToEndRecPtr(current_bytepos);
#else
@@ -15510,7 +15513,7 @@ void disable_delay_ddl_recycle_with_slot(const char* slotname, XLogRecPtr *start
*/
LWLockAcquire(RelfilenodeReuseLock, LW_EXCLUSIVE);
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
uint64 current_bytepos = pg_atomic_barrier_read_u64((uint64*)&Insert->CurrBytePos);
delay_end_lsn = XLogBytePosToEndRecPtr(current_bytepos);
#else
@@ -15928,7 +15931,7 @@ XLogRecPtr GetXLogInsertRecPtr(void)
volatile XLogCtlInsert *Insert = &t_thrd.shemem_ptr_cxt.XLogCtl->Insert;
uint64 current_bytepos;
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
current_bytepos = pg_atomic_barrier_read_u64((uint64*)&Insert->CurrBytePos);
#else
SpinLockAcquire(&Insert->insertpos_lck);
@@ -15950,7 +15953,7 @@ XLogRecPtr GetXLogInsertEndRecPtr(void)
volatile XLogCtlInsert *Insert = &t_thrd.shemem_ptr_cxt.XLogCtl->Insert;
uint64 current_bytepos;
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
current_bytepos = pg_atomic_barrier_read_u64((uint64*)&Insert->CurrBytePos);
#else
SpinLockAcquire(&Insert->insertpos_lck);
@@ -18432,7 +18435,7 @@ bool IsRoachRestore(void)
}
const uint UPDATE_REC_XLOG_NUM = 4;
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
bool atomic_update_dirty_page_queue_rec_lsn(XLogRecPtr current_insert_lsn, bool need_immediately_update)
{
XLogRecPtr cur_rec_lsn = InvalidXLogRecPtr;
@@ -18490,7 +18493,7 @@ void update_dirty_page_queue_rec_lsn(XLogRecPtr current_insert_lsn, bool need_im
}
}
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
is_update = atomic_update_dirty_page_queue_rec_lsn(current_insert_lsn, need_immediately_update);
#else
SpinLockAcquire(&g_instance.ckpt_cxt_ctl->queue_lock);
@@ -18515,7 +18518,7 @@ void update_dirty_page_queue_rec_lsn(XLogRecPtr current_insert_lsn, bool need_im
uint64 get_dirty_page_queue_rec_lsn()
{
uint64 dirty_page_queue_rec_lsn = 0;
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__sw_64__)
uint128_u compare;
compare = atomic_compare_and_swap_u128((uint128_u*)&g_instance.ckpt_cxt_ctl->dirty_page_queue_reclsn);
dirty_page_queue_rec_lsn = compare.u64[0];
@@ -18956,4 +18959,4 @@ void InitXlogStatuEntryTblSize()
g_instance.attr.attr_storage.wal_insert_status_entries_power = MIN_WAL_INSERT_STATUS_ENTRY_POW;
}
}
-
+//#endif
diff --git a/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/Makefile.local b/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/Makefile.local
index 5cdaaff..74daee4 100644
--- a/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/Makefile.local
+++ b/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/Makefile.local
@@ -73,9 +73,10 @@ PLATFORM_ARCH = $(shell uname -p)
ifeq ($(PLATFORM_ARCH),aarch64)
#CFLAGS += -std=gnu++11 -march=armv8-a+crc -Wall -Wextra -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC
CFLAGS += -std=gnu++11 -march=armv8-a+crc -w -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC
-else
- #CFLAGS += -std=gnu++11 -march=native -mcx16 -Wall -Wextra -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC
- CFLAGS += -std=gnu++11 -mcx16 -w -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC
+else ifeq($(PLATFORM_ARCH),sw_64)
+ CFLAGS += -std=gnu++11 -march=native -Wall -Wextra -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC
+else
+ CFLAGS += -std=gnu++11 -march=native -mcx16 -Wall -Wextra -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC
endif
CFLAGS += $(INCLUDE)
@@ -93,6 +94,8 @@ ifeq ($(UNDERPG), no)
ifeq ($(BUILD),Release)
ifeq ($(PLATFORM_ARCH),aarch64)
CFLAGS += -O2 -DNDEBUG -D_FORTIFY_SOURCE=2
+ else ifeq ($(PLATFORM_ARCH),sw_64)
+ CFLAGS += -O2 -DNDEBUG -D_FORTIFY_SOURCE=2
else
CFLAGS += -Werror -O2 -DNDEBUG -mcx16 -D_FORTIFY_SOURCE=2
endif
diff --git a/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/infra/synchronization/cycles.h b/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/infra/synchronization/cycles.h
index 559ce1d..e42465d 100644
--- a/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/infra/synchronization/cycles.h
+++ b/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/infra/synchronization/cycles.h
@@ -55,6 +55,12 @@ public:
unsigned long cval = 0;
asm volatile("isb; mrs %0, cntvct_el0" : "=r"(cval) : : "memory");
return cval;
+/* modify by yjy */
+#elif defined(__sw_64__)
+ unsigned long time_val = 0;
+ __asm__ __volatile__("rtc %0" : "=r"(time_val) : : "memory");
+ return time_val;
+/* end */
#else
#error "Unsupported CPU architecture or compiler."
#endif
@@ -75,6 +81,12 @@ public:
unsigned long cval = 0;
asm volatile("isb; mrs %0, cntvct_el0" : "=r"(cval) : : "memory");
return cval;
+/* modify by yjy */
+#elif defined(__sw_64__)
+ unsigned long time_val = 0;
+ __asm__ volatile("rtc %0" : "=r"(time_val) : : "memory");
+ return time_val;
+/* end */
#else
#error "Unsupported CPU architecture or compiler."
#endif
diff --git a/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/infra/synchronization/mot_atomic_ops.h b/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/infra/synchronization/mot_atomic_ops.h
index 2c57cbf..7c628e3 100644
--- a/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/infra/synchronization/mot_atomic_ops.h
+++ b/openGauss-server-2.1.0/src/gausskernel/storage/mot/core/infra/synchronization/mot_atomic_ops.h
@@ -65,4 +65,4 @@
/** @define Atomic compare-and-swap. Performs the operation "if (v == curr_value) then v = new_value". */
#define MOT_ATOMIC_CAS(v, curr_value, new_value) __sync_bool_compare_and_swap(&v, curr_value, new_value)
-#endif /* MM_ATOMIC_OPS_H */
\ No newline at end of file
+#endif /* MM_ATOMIC_OPS_H */
diff --git a/openGauss-server-2.1.0/src/include/access/double_write_basic.h b/openGauss-server-2.1.0/src/include/access/double_write_basic.h
index 0543ca2..7b1f55d 100644
--- a/openGauss-server-2.1.0/src/include/access/double_write_basic.h
+++ b/openGauss-server-2.1.0/src/include/access/double_write_basic.h
@@ -109,6 +109,8 @@ typedef unsigned char slock_t;
#if defined(__aarch64__) || defined(__aarch64)
typedef int slock_t;
+#elif defined(__sw_64__) //modify by yjy
+typedef unsigned long slock_t;
#endif
typedef uintptr_t Datum;
diff --git a/openGauss-server-2.1.0/src/include/access/extreme_rto/dispatcher.h b/openGauss-server-2.1.0/src/include/access/extreme_rto/dispatcher.h
index 5890af2..41eb8fa 100644
--- a/openGauss-server-2.1.0/src/include/access/extreme_rto/dispatcher.h
+++ b/openGauss-server-2.1.0/src/include/access/extreme_rto/dispatcher.h
@@ -105,7 +105,7 @@ typedef struct RecordBufferAarray {
typedef struct {
uint64 curPosition;
XLogRecPtr curLsn;
-#if (!defined __x86_64__) && (!defined __aarch64__)
+#if (!defined __x86_64__) && (!defined __aarch64__) && (!defined __sw_64__) //add sw_64 modify bu yjy
/* protects lastReplayedReadRecPtr and lastReplayedEndRecPtr */
slock_t ptrLck;
#endif
diff --git a/openGauss-server-2.1.0/src/include/access/extreme_rto/page_redo.h b/openGauss-server-2.1.0/src/include/access/extreme_rto/page_redo.h
index 6dc938a..8bbf855 100644
--- a/openGauss-server-2.1.0/src/include/access/extreme_rto/page_redo.h
+++ b/openGauss-server-2.1.0/src/include/access/extreme_rto/page_redo.h
@@ -65,7 +65,7 @@ struct PageRedoWorker {
*/
XLogRecPtr lastReplayedReadRecPtr;
XLogRecPtr lastReplayedEndRecPtr;
-#if (!defined __x86_64__) && (!defined __aarch64__)
+#if (!defined __x86_64__) && (!defined __aarch64__) && (!defined __sw_64__) //add sw_64 modify by yjy
/* protects lastReplayedReadRecPtr and lastReplayedEndRecPtr */
slock_t ptrLck;
#endif
diff --git a/openGauss-server-2.1.0/src/include/access/parallel_recovery/page_redo.h b/openGauss-server-2.1.0/src/include/access/parallel_recovery/page_redo.h
index 3e0a720..eccef33 100644
--- a/openGauss-server-2.1.0/src/include/access/parallel_recovery/page_redo.h
+++ b/openGauss-server-2.1.0/src/include/access/parallel_recovery/page_redo.h
@@ -61,7 +61,7 @@ struct PageRedoWorker {
*/
XLogRecPtr lastReplayedReadRecPtr;
XLogRecPtr lastReplayedEndRecPtr;
-#if (!defined __x86_64__) && (!defined __aarch64__)
+#if (!defined __x86_64__) && (!defined __aarch64__) //add sw_64 modify by yjy
/* protects lastReplayedReadRecPtr and lastReplayedEndRecPtr */
slock_t ptrLck;
#endif
diff --git a/openGauss-server-2.1.0/src/include/communication/commproxy_interface.h b/openGauss-server-2.1.0/src/include/communication/commproxy_interface.h
index c42cc43..7a1beb6 100644
--- a/openGauss-server-2.1.0/src/include/communication/commproxy_interface.h
+++ b/openGauss-server-2.1.0/src/include/communication/commproxy_interface.h
@@ -416,7 +416,17 @@ extern bool comm_compare_and_swap_32(volatile int32* dest, int32 oldval, int32 n
#define gaussdb_numa_memory_bind(i)
#define gaussdb_numa_memory_unbind()
+/* modify by yjy */
+#elif defined(__sw_64__)
+#define gaussdb_memory_barrier() \
+ __asm__ __volatile__ ("memb" : : : "memory")
+
+#define gaussdb_read_barrier() gaussdb_memory_barrier()
+#define gaussdb_write_barrier() gaussdb_memory_barrier()
+#define gaussdb_numa_memory_bind(i)
+#define gaussdb_numa_memory_unbind()
+/* end */
#elif defined(__i386__)
#define gaussdb_memory_barrier() \
__asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
diff --git a/openGauss-server-2.1.0/src/include/gtm/gtm_atomic.h b/openGauss-server-2.1.0/src/include/gtm/gtm_atomic.h
index 35e8fb9..affb5e6 100644
--- a/openGauss-server-2.1.0/src/include/gtm/gtm_atomic.h
+++ b/openGauss-server-2.1.0/src/include/gtm/gtm_atomic.h
@@ -169,6 +169,10 @@ static inline void GTM_loadStoreFence()
#ifdef __aarch64__
__asm__ __volatile__("DMB ish" ::: "memory");
+/* modify by yjy */
+#elif defined(__sw_64__)
+ __asm__ __volatile__("memb" ::: "memory");
+/* end */
#else
__asm__ __volatile__("lfence" ::: "memory");
__asm__ __volatile__("sfence" ::: "memory");
@@ -177,11 +181,19 @@ static inline void GTM_loadStoreFence()
static inline void GTM_loadFence()
{
+/* modify */
+#ifndef __sw_64__
__asm__ __volatile__("lfence" ::: "memory");
+#endif
+/* end */
}
static inline void GTM_StoreFence()
{
+/* modify */
+#ifndef __sw_64__
__asm__ __volatile__("sfence" ::: "memory");
+#endif
+/* end */
}
#endif /* CODE_SRC_INCLUDE_GTM_GTM_ATOMIC_H_ */
diff --git a/openGauss-server-2.1.0/src/include/gtm/gtm_slock.h b/openGauss-server-2.1.0/src/include/gtm/gtm_slock.h
index 1ba3e64..207b71e 100644
--- a/openGauss-server-2.1.0/src/include/gtm/gtm_slock.h
+++ b/openGauss-server-2.1.0/src/include/gtm/gtm_slock.h
@@ -585,6 +585,45 @@ static __inline__ int tas(volatile slock_t* lock)
#endif /* __ns32k__ */
+/* modify by yjy */
+#if defined(__sw_64__)
+#define HAS_TEST_AND_SET
+typedef unsigned long slock_t;
+#define TAS(lock) tas(lock)
+
+static __inline__ int tas(volatile slock_t* lock)
+{
+ register slock_t _res;
+ unsigned long tmp;
+ __asm__ __volatile__(
+ " ldl $0, %1 \n"
+ " bne $0, 2f \n"
+ " lldl %0, %1 \n"
+ " cmpeq %0, 0,%2\n"
+ " wr_f %2 \n"
+ " mov %2, $0 \n"
+ " lstl $0, %1 \n"
+ " rd_f $0 \n"
+ " beq %2, 2f \n"
+ " beq $0, 2f \n"
+ " memb \n"
+ " br 3f \n"
+ "2: mov 1, %0 \n"
+ "3: \n"
+ :"=&r"(_res), "+m"(*lock),"=&r"(tmp)
+ :
+ :"memory", "0");
+ return (int)_res;
+}
+
+#define S_UNLOCK(lock) \
+ do { \
+ __asm__ __volatile__("memb \n"); \
+ *((volatile slock_t*)(lock)) = 0; \
+ } while (0)
+#endif
+/* end */
+
#if defined(__alpha) || defined(__alpha__) /* Alpha */
/*
* Correct multi-processor locking methods are explained in section 5.5.3
diff --git a/openGauss-server-2.1.0/src/include/storage/lock/s_lock.h b/openGauss-server-2.1.0/src/include/storage/lock/s_lock.h
index 6a64c9d..929fec9 100644
--- a/openGauss-server-2.1.0/src/include/storage/lock/s_lock.h
+++ b/openGauss-server-2.1.0/src/include/storage/lock/s_lock.h
@@ -97,7 +97,7 @@
#include "storage/lock/pg_sema.h"
-#if !defined(ENABLE_THREAD_CHECK) || defined(__aarch64__)
+#if !defined(ENABLE_THREAD_CHECK) || defined(__aarch64__) || defined(__sw_64__)
#ifdef HAVE_SPINLOCKS /* skip spinlocks if requested */
@@ -606,6 +606,45 @@ static __inline__ int tas(volatile slock_t* lock)
#endif /* __ns32k__ */
+/* modify by yjy */
+#if defined(__sw_64) || defined(__sw_64__)
+#define HAS_TEST_AND_SET
+typedef unsigned long slock_t;
+#define TAS(lock) tas(lock)
+
+static __inline__ int tas(volatile slock_t* lock)
+{
+ register slock_t _res;
+ unsigned long tmp;
+ __asm__ __volatile__(
+ " ldl $0, %1 \n"
+ " bne $0, 2f \n"
+ " lldl %0, %1 \n"
+ " cmpeq %0, 0,%2\n"
+ " wr_f %2 \n"
+ " mov %2, $0 \n"
+ " lstl $0, %1 \n"
+ " rd_f $0 \n"
+ " beq %2, 2f \n"
+ " beq $0, 2f \n"
+ " memb \n"
+ " br 3f \n"
+ "2: mov 1, %0 \n"
+ "3: \n"
+ :"=&r"(_res), "+m"(*lock),"=&r"(tmp)
+ :
+ :"memory", "0");
+ return (int)_res;
+}
+
+#define S_UNLOCK(lock) \
+ do { \
+ __asm__ __volatile__("memb \n"); \
+ *((volatile slock_t*)(lock)) = 0; \
+ } while (0)
+#endif
+/* end */
+
#if defined(__alpha) || defined(__alpha__) /* Alpha */
/*
* Correct multi-processor locking methods are explained in section 5.5.3
diff --git a/openGauss-server-2.1.0/src/include/utils/atomic.h b/openGauss-server-2.1.0/src/include/utils/atomic.h
index 510a695..c64ec40 100644
--- a/openGauss-server-2.1.0/src/include/utils/atomic.h
+++ b/openGauss-server-2.1.0/src/include/utils/atomic.h
@@ -504,6 +504,9 @@ static inline uint128_u atomic_compare_and_swap_u128(
{
#ifdef __aarch64__
return arm_compare_and_swap_u128(ptr, oldval, newval);
+#elif defined(__sw_64__)
+ uint128_u ret;
+ return ret;
#else
uint128_u ret;
ret.u128 = __sync_val_compare_and_swap(&ptr->u128, oldval.u128, newval.u128);
diff --git a/openGauss-server-2.1.0/src/test/regress/pg_regress.cpp b/openGauss-server-2.1.0/src/test/regress/pg_regress.cpp
index 859d430..42f0590 100644
--- a/openGauss-server-2.1.0/src/test/regress/pg_regress.cpp
+++ b/openGauss-server-2.1.0/src/test/regress/pg_regress.cpp
@@ -6589,6 +6589,10 @@ int regression_main(int argc, char* argv[], init_function ifunc, test_function t
(void)snprintf(pgbenchdir, MAXPGPATH, "%s/%s", ".", "data/pgbench/x86_64");
#elif defined (__aarch64__)
(void)snprintf(pgbenchdir, MAXPGPATH, "%s/%s", ".", "data/pgbench/aarch64");
+/* modify by yjy */
+#elif defined (__sw_64__)
+ (void)snprintf(pgbenchdir, MAXPGPATH, "%s/%s", ".", "data/pgbench/sw_64");
+/* endif */
#endif
/* Check thread local varieble's num */
diff --git a/protobuf-3.11.3/cmake/CMakeLists.txt b/protobuf-3.11.3/cmake/CMakeLists.txt
index 8e5e680..f3b7046 100644
--- a/protobuf-3.11.3/cmake/CMakeLists.txt
+++ b/protobuf-3.11.3/cmake/CMakeLists.txt
@@ -138,7 +138,8 @@ set(protobuf_LINK_LIBATOMIC false)
if (NOT MSVC)
include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++11)
+ #set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++11)
+ set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=gnu++11)
check_cxx_source_compiles("
#include <atomic>
int main() {
diff --git a/protobuf-3.11.3/kokoro/release/protoc/linux/build.sh b/protobuf-3.11.3/kokoro/release/protoc/linux/build.sh
index d165a89..cf13b49 100755
--- a/protobuf-3.11.3/kokoro/release/protoc/linux/build.sh
+++ b/protobuf-3.11.3/kokoro/release/protoc/linux/build.sh
@@ -19,6 +19,8 @@ git submodule update --init --recursive
sudo apt install -y g++-aarch64-linux-gnu
protoc-artifacts/build-protoc.sh linux aarch_64 protoc
+protoc-artifacts/build-protoc.sh linux sw_64 protoc
+
sudo apt install -y g++-powerpc64le-linux-gnu
protoc-artifacts/build-protoc.sh linux ppcle_64 protoc
diff --git a/protobuf-3.11.3/protoc-artifacts/build-protoc.sh b/protobuf-3.11.3/protoc-artifacts/build-protoc.sh
index 6ad2ea1..268a3e3 100755
--- a/protobuf-3.11.3/protoc-artifacts/build-protoc.sh
+++ b/protobuf-3.11.3/protoc-artifacts/build-protoc.sh
@@ -11,6 +11,7 @@
# cygwin windows x86_32 Requires: i686-w64-mingw32-gcc
# cygwin windows x86_64 Requires: x86_64-w64-mingw32-gcc
# linux linux aarch_64 Requires: g++-aarch64-linux-gnu
+# linux linux sw_64
# linux linux x86_32
# linux linux x86_64
# linux windows x86_32 Requires: i686-w64-mingw32-gcc
@@ -162,6 +163,9 @@ checkDependencies ()
elif [[ "$ARCH" == aarch_64 ]]; then
dump_cmd='objdump -p '"$1"' | grep NEEDED'
white_list="libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux-aarch64\.so\.1"
+ elif [[ "$ARCH" == sw_64 ]]; then
+ dump_cmd='objdump -p '"$1"' | grep NEEDED'
+ white_list="libpthread\.so\.0\|libm\.so\.6\.1\|libc\.so\.6\.1\|ld-linux\.so\.2"
fi
elif [[ "$OS" == osx ]]; then
dump_cmd='otool -L '"$1"' | fgrep dylib'
@@ -223,6 +227,8 @@ elif [[ "$(uname)" == Linux* ]]; then
CXXFLAGS="$CXXFLAGS -m32"
elif [[ "$ARCH" == aarch_64 ]]; then
CONFIGURE_ARGS="$CONFIGURE_ARGS --host=aarch64-linux-gnu"
+ elif [[ "$ARCH" == sw_64 ]]; then
+ CONFIGURE_ARGS="$CONFIGURE_ARGS --host=sw_64-linux-gnu"
elif [[ "$ARCH" == ppcle_64 ]]; then
CXXFLAGS="$CXXFLAGS -m64"
CONFIGURE_ARGS="$CONFIGURE_ARGS --host=powerpc64le-linux-gnu"
diff --git a/protobuf-3.11.3/src/google/protobuf/stubs/platform_macros.h b/protobuf-3.11.3/src/google/protobuf/stubs/platform_macros.h
index ce1b1e3..fd482f9 100644
--- a/protobuf-3.11.3/src/google/protobuf/stubs/platform_macros.h
+++ b/protobuf-3.11.3/src/google/protobuf/stubs/platform_macros.h
@@ -56,6 +56,9 @@
#elif defined(__aarch64__)
#define GOOGLE_PROTOBUF_ARCH_AARCH64 1
#define GOOGLE_PROTOBUF_ARCH_64_BIT 1
+#elif defined(__sw_64__)
+#define GOOGLE_PROTOBUF_ARCH_SW_64 1
+#define GOOGLE_PROTOBUF_ARCH_64_BIT 1
#elif defined(__mips__)
#if defined(__LP64__)
#define GOOGLE_PROTOBUF_ARCH_MIPS64 1
diff --git a/zlib-1.2.11/configure b/zlib-1.2.11/configure
index e974d1f..027ba8c 100755
--- a/zlib-1.2.11/configure
+++ b/zlib-1.2.11/configure
@@ -391,13 +391,13 @@ tryboth()
cat > $test.c << EOF
int foo() { return 0; }
EOF
-echo "Checking for obsessive-compulsive compiler options..." >> configure.log
-if try $CC -c $CFLAGS $test.c; then
- :
-else
- echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
- leave 1
-fi
+#echo "Checking for obsessive-compulsive compiler options..." >> configure.log
+#if try $CC -c $CFLAGS $test.c; then
+# :
+#else
+# echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
+# leave 1
+#fi
echo >> configure.log
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/YH0204/src_opengauss-server.git
git@gitee.com:YH0204/src_opengauss-server.git
YH0204
src_opengauss-server
src_opengauss-server
master

搜索帮助