summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorMarc G. Fournier1998-04-29 12:41:29 +0000
committerMarc G. Fournier1998-04-29 12:41:29 +0000
commit51a1741cfb9f812e798681d3edf5866e413f155b (patch)
tree034dacbe407d11c81e521b87a9a41f7bcca373f6 /src/include
parentbab9818c4ba9a636ab1d638c3cf096f90cd66351 (diff)
From: Jeroen van Vianen <[email protected]>
Attached patch will add a version() function to Postges, e.g. template1=> select version(); version ------------------------------------------------------------ PostgreSQL 6.3.2 on i586-pc-linux-gnu, compiled by gcc 2.8.1 (1 row)
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/pg_proc.h6
-rw-r--r--src/include/port/linux.h3
-rw-r--r--src/include/storage/s_lock.h70
-rw-r--r--src/include/version.h24
-rw-r--r--src/include/version.h.in25
5 files changed, 88 insertions, 40 deletions
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 335139cdbeb..12d6ff91d15 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.54 1998/04/27 17:08:41 scrappy Exp $
+ * $Id: pg_proc.h,v 1.55 1998/04/29 12:39:32 scrappy Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@@ -1922,6 +1922,10 @@ DESCR("sequence next value");
DATA(insert OID = 1319 ( currval PGUID 11 f t f 1 f 23 "25" 100 0 0 100 foo bar ));
DESCR("sequence current value");
+DATA(insert OID = 1600 ( version PGUID 11 f t t 0 f 25 "" 100 0 0 100 foo bar ));
+DESCR("PostgreSQL version string");
+
+
/*
* prototypes for functions pg_proc.c
*/
diff --git a/src/include/port/linux.h b/src/include/port/linux.h
index b2a9cd1cb0a..437ee723122 100644
--- a/src/include/port/linux.h
+++ b/src/include/port/linux.h
@@ -7,7 +7,6 @@
#define JMP_BUF
#define USE_POSIX_TIME
#define USE_POSIX_SIGNALS
-#define NEED_I386_TAS_ASM
#define HAS_TEST_AND_SET
#if defined(PPC)
@@ -16,7 +15,7 @@ typedef unsigned int slock_t;
#elif defined(__alpha)
typedef long int slock_t;
-#else
+#else /* i386 probably */
typedef unsigned char slock_t;
#endif
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index e7b3104a650..34303903033 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -7,28 +7,49 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.29 1998/04/27 14:45:33 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.30 1998/04/29 12:40:56 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
/*
* DESCRIPTION
- * The following code fragment should be written (in assembly
- * language) on machines that have a native test-and-set instruction:
+ * The public functions that must be provided are:
+ *
+ * void S_INIT_LOCK(slock_t *lock)
+ *
+ * void S_LOCK(slock_t *lock)
+ *
+ * void S_UNLOCK(slock_t *lock)
+ *
+ * int S_LOCK_FREE(slock_t *lock)
+ * Tests if the lock is free. Returns non-zero if free, 0 if locked.
+ *
+ * The S_LOCK() function (in s_lock.c) implements a primitive but
+ * still useful random backoff to avoid hordes of busywaiting lockers
+ * chewing CPU.
*
* void
- * S_LOCK(char_address)
- * char *char_address;
+ * S_LOCK(slock_t *lock)
* {
- * while (test_and_set(char_address))
- * ;
+ * while (TAS(lock))
+ * {
+ * // back off the cpu for a semi-random short time
+ * }
* }
*
- * If this is not done, POSTGRES will default to using System V
- * semaphores (and take a large performance hit -- around 40% of
- * its time on a DS5000/240 is spent in semop(3)...).
+ * This implementation takes advantage of a tas function written
+ * (in assembly language) on machines that have a native test-and-set
+ * instruction. Alternative mutex implementations may also be used.
+ * This function is hidden under the TAS macro to allow substitutions.
*
- * NOTES
+ * #define TAS(lock) tas(lock)
+ * int tas(slock_t *lock) // True if lock already set
+ *
+ * If none of this can be done, POSTGRES will default to using
+ * System V semaphores (and take a large performance hit -- around 40%
+ * of its time on a DS5000/240 is spent in semop(3)...).
+ *
+ * NOTES
* AIX has a test-and-set but the recommended interface is the cs(3)
* system call. This provides an 8-instruction (plus system call
* overhead) uninterruptible compare-and-set operation. True
@@ -36,6 +57,10 @@
* regression test suite by about 25%. I don't have an assembler
* manual for POWER in any case.
*
+ * There are default implementations for all these macros at the bottom
+ * of this file. Check if your platform can use these or needs to
+ * override them.
+ *
*/
#ifndef S_LOCK_H
#define S_LOCK_H
@@ -44,22 +69,41 @@
#if defined(HAS_TEST_AND_SET)
+#if defined(linux)
+/***************************************************************************
+ * All Linux
+ */
+
+#if defined(__alpha__)
+
+#define S_UNLOCK(lock) { __asm__("mb"); *(lock) = 0; }
+
+#endif /* defined(__alpha__) && defined(linux) */
+
+
+
+
+#else /* defined(linux) */
+/***************************************************************************
+ * All non Linux
+ */
+
#if defined (nextstep)
/*
* NEXTSTEP (mach)
* slock_t is defined as a struct mutex.
*/
+
#define S_LOCK(lock) mutex_lock(lock)
#define S_UNLOCK(lock) mutex_unlock(lock)
#define S_INIT_LOCK(lock) mutex_init(lock)
- /* S_LOCK_FREE should return 1 if lock is free; 0 if lock is locked */
/* For Mach, we have to delve inside the entrails of `struct mutex'. Ick! */
#define S_LOCK_FREE(alock) ((alock)->lock == 0)
-#endif /* next */
+#endif /* nextstep */
diff --git a/src/include/version.h b/src/include/version.h
deleted file mode 100644
index 71511056d63..00000000000
--- a/src/include/version.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * version.h--
- * this file contains the interface to version.c.
- * Also some parameters.
- *
- * $Id: version.h,v 1.8 1998/04/26 04:08:29 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-#ifndef VERSION_H
-#define VERSION_H
-
-void
- ValidatePgVersion(const char *path, char **reason_p);
-
-void
- SetPgVersion(const char *path, char **reason_p);
-
-#define PG_RELEASE 6
-#define PG_VERSION 4
-#define PG_VERFILE "PG_VERSION"
-
-#endif
diff --git a/src/include/version.h.in b/src/include/version.h.in
new file mode 100644
index 00000000000..c0b0b00294e
--- /dev/null
+++ b/src/include/version.h.in
@@ -0,0 +1,25 @@
+/*-------------------------------------------------------------------------
+ *
+ * version.h.in--
+ * this file contains the interface to version.c.
+ * Also some parameters.
+ *
+ * $Header: /cvsroot/pgsql/src/include/Attic/version.h.in,v 1.1 1998/04/29 12:39:21 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef VERSION_H
+#define VERSION_H
+
+void ValidatePgVersion(const char *path, char **reason_p);
+void SetPgVersion(const char *path, char **reason_p);
+
+#define PG_RELEASE "6"
+#define PG_VERSION "3"
+#define PG_SUBVERSION "2"
+
+#define PG_VERFILE "PG_VERSION"
+
+#define PG_VERSION_STR "PostgreSQL " ## PG_RELEASE ## "." ## PG_VERSION ## "." ## PG_SUBVERSION ## " on @host@, compiled by @CC@ @CC_VERSION@"
+
+#endif