mcst-linux-kernel/patches-2024.06.26/postgresql13-13.5/0001_spinlocks_and_pg_daemo...

192 lines
4.1 KiB
Diff

diff -ruN postgresql13-13.5/pg_daemon/postgres postgresql13-13.5_patch/pg_daemon/postgres
--- postgresql13-13.5/pg_daemon/postgres 1970-01-01 03:00:00.000000000 +0300
+++ postgresql13-13.5_patch/pg_daemon/postgres 2021-11-21 09:15:58.593332063 +0300
@@ -0,0 +1,104 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: postgres
+# Required-Start: $syslog $network +megaraid_sas
+# Required-Stop: $syslog $network +megaraid_sas
+# Default-Start: 3 5
+# Default-Stop: 0 6
+# Short-Description:
+# Description:
+### END INIT INFO
+#2017
+
+DAEMON=/usr/bin/pg_ctl
+PGDATA=/var/lib/postgresql/13/data
+prog=`basename $DAEMON`
+PGUSER=postgres
+
+export LANG="ru_RU.utf8"
+
+test -e $DAEMON || echo "daemon pg_ctl not found"
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+export PATH
+
+function start() {
+ echo -n "Starting $prog: "
+ if [ -e "/usr/bin/pg_ctl" ]; then
+ if [ -e ${PGDATA}/postmaster.pid ]; then
+ pidserver=`ps -ef | grep 'postgres -D' | head -n 1 | cut -f 3 -d " "`
+ pid_file_postmaster=`head -n 1 $PGDATA/postmaster.pid`
+ if [ $pidserver == $pid_file_postmaster ] ; then
+ echo "DBMS postrgesql running now" ;
+ else
+ rm $PGDATA/postmaster.pid
+ su ${PGUSER} -c "/usr/bin/pg_ctl start -D ${PGDATA} -l ${PGDATA}/server.log";
+ fi 2>/dev/null
+ else
+ su ${PGUSER} -c "/usr/bin/pg_ctl start -D ${PGDATA} -l ${PGDATA}/server.log";
+ fi
+ fi
+ return $?
+}
+
+function stop() {
+ echo -n $"Stopping $prog: "
+ su ${PGUSER} -c "/usr/bin/pg_ctl stop -D ${PGDATA} -m fast 2>/dev/null"
+ echo ""
+ return $?
+}
+
+function status() {
+ su ${PGUSER} -c "/usr/bin/pg_ctl status -D ${PGDATA}"
+ return $?
+}
+
+function initdb() {
+ su ${PGUSER} -c "/usr/bin/pg_ctl init -D ${PGDATA}"
+ return $?
+}
+
+function reload() {
+ su ${PGUSER} -c "/usr/bin/pg_ctl reload -D ${PGDATA}"
+ return $?
+}
+
+function restart() {
+ if [ -e ${PGDATA}/postmaster.pid ]; then
+ stop
+ sleep 5
+ start
+ return $?
+ else
+ start
+ return $?
+ fi
+}
+
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ restart
+ ;;
+ status)
+ status
+ ;;
+ reload|force-reload)
+ reload
+ ;;
+ initdb|init)
+ initdb
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|status|reload|force-reload|initdb}"
+ ;;
+esac
+
+exit $?
+
+
diff -ruN postgresql13-13.5/src/include/storage/s_lock.h postgresql13-13.5_patch/src/include/storage/s_lock.h
--- postgresql13-13.5/src/include/storage/s_lock.h 2021-11-09 01:00:24.000000000 +0300
+++ postgresql13-13.5_patch/src/include/storage/s_lock.h 2021-11-21 09:10:25.338818618 +0300
@@ -201,6 +201,18 @@
#endif /* __i386__ */
+# if defined (__e2k__)
+#define HAS_TEST_AND_SET
+#define TAS(lock) tas(lock)
+typedef int slock_t;
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+ return __sync_lock_test_and_set(lock, 1);
+}
+#define S_UNLOCK(lock) __sync_lock_release(lock)
+#endif
+
#ifdef __x86_64__ /* AMD Opteron, Intel EM64T */
#define HAS_TEST_AND_SET
@@ -571,31 +584,6 @@
#endif /* (__mc68000__ || __m68k__) && __linux__ */
-
-/* Motorola 88k */
-#if defined(__m88k__)
-#define HAS_TEST_AND_SET
-
-typedef unsigned int slock_t;
-
-#define TAS(lock) tas(lock)
-
-static __inline__ int
-tas(volatile slock_t *lock)
-{
- register slock_t _res = 1;
-
- __asm__ __volatile__(
- " xmem %0, %2, %%r0 \n"
-: "+r"(_res), "+m"(*lock)
-: "r"(lock)
-: "memory");
- return (int) _res;
-}
-
-#endif /* __m88k__ */
-
-
/*
* VAXen -- even multiprocessor ones
* (thanks to Tom Ivar Helbekkmo)
@@ -775,6 +763,28 @@
#if !defined(HAS_TEST_AND_SET) /* We didn't trigger above, let's try here */
+#if defined(USE_UNIVEL_CC) /* Unixware compiler */
+#define HAS_TEST_AND_SET
+
+typedef unsigned char slock_t;
+
+#define TAS(lock) tas(lock)
+
+asm int
+tas(volatile slock_t *s_lock)
+{
+/* UNIVEL wants %mem in column 1, so we don't pgindent this file */
+ %mem s_lock
+ pushl %ebx
+ movl s_lock, %ebx
+ movl $255, %eax
+ lock
+ xchgb %al, (%ebx)
+ popl %ebx
+}
+
+#endif /* defined(USE_UNIVEL_CC) */
+
#if defined(__hppa) || defined(__hppa__) /* HP PA-RISC, GCC and HP compilers */
/*