Thread: Reorganization of spinlock defines

Reorganization of spinlock defines

From
Bruce Momjian
Date:
Prompted by confusion over Itanium/Opterion, I have written a patch to
improve the way we define spinlocks for platforms and cpu's.  It
basically decouples the OS from the CPU spinlock code.  In almost all
cases, the spinlock code cares only about the compiler and CPU, not the
OS.

The patch:

    o defines HAS_TEST_AND_SET inside each spinlock routine, not in
      platform-specific files
    o moves slock_t defines into the spinlock routines
    o remove NEED_{CPU}_TAS_ASM define because it is no longer needed
    o reports a compile error if spinlocks are not defined
    o adds a configure option --without-spinlocks to allow
      non-spinlock compiles

Looking at the patch, I realize this is how we should have done it all
along.

It would be nice to report the lack of spinlocks in configure, rather
than during the compile, but I can't compile s_lock.h and test for
HAS_TEST_AND_SET until configure completes.

I plan to apply this to 7.4.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: configure
===================================================================
RCS file: /cvsroot/pgsql-server/configure,v
retrieving revision 1.295
diff -c -c -r1.295 configure
*** configure    7 Sep 2003 16:49:41 -0000    1.295
--- configure    12 Sep 2003 01:36:28 -0000
***************
*** 869,874 ****
--- 869,875 ----
    --with-rendezvous       build with Rendezvous support
    --with-openssl[=DIR]    build with OpenSSL support [/usr/local/ssl]
    --without-readline      do not use Readline
+   --without-spinlocks      do not use Spinlocks
    --without-zlib          do not use Zlib
    --with-gnu-ld           assume the C compiler uses GNU ld default=no

***************
*** 3494,3499 ****
--- 3495,3530 ----


  #
+ # Spinlocks
+ #
+
+
+
+ # Check whether --with-spinlocks or --without-spinlocks was given.
+ if test "${with_spinlocks+set}" = set; then
+   withval="$with_spinlocks"
+
+   case $withval in
+     yes)
+       :
+       ;;
+     no)
+       :
+       ;;
+     *)
+       { { echo "$as_me:$LINENO: error: no argument expected for --with-spinlocks option" >&5
+ echo "$as_me: error: no argument expected for --with-spinlocks option" >&2;}
+    { (exit 1); exit 1; }; }
+       ;;
+   esac
+
+ else
+   with_spinlocks=yes
+
+ fi;
+
+
+ #
  # Zlib
  #

***************
*** 3523,3529 ****
  fi;


-
  #
  # Elf
  #
--- 3554,3559 ----
***************
*** 6060,6065 ****
--- 6090,6108 ----
     { (exit 1); exit 1; }; }
  fi

+ fi
+
+ if test "$with_spinlocks" = yes; then
+
+ cat >>confdefs.h <<\_ACEOF
+ #define HAVE_SPINLOCKS 1
+ _ACEOF
+
+ else
+   { echo "$as_me:$LINENO: WARNING:
+ *** Not using spinlocks will cause poor performance." >&5
+ echo "$as_me: WARNING:
+ *** Not using spinlocks will cause poor performance." >&2;}
  fi

  if test "$with_krb4" = yes ; then
Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql-server/configure.in,v
retrieving revision 1.286
diff -c -c -r1.286 configure.in
*** configure.in    7 Sep 2003 16:38:05 -0000    1.286
--- configure.in    12 Sep 2003 01:36:31 -0000
***************
*** 522,533 ****
                [  --without-readline      do not use Readline])

  #
  # Zlib
  #
  PGAC_ARG_BOOL(with, zlib, yes,
                [  --without-zlib          do not use Zlib])

-
  #
  # Elf
  #
--- 522,538 ----
                [  --without-readline      do not use Readline])

  #
+ # Spinlocks
+ #
+ PGAC_ARG_BOOL(with, spinlocks, yes,
+               [  --without-spinlocks      do not use Spinlocks])
+
+ #
  # Zlib
  #
  PGAC_ARG_BOOL(with, zlib, yes,
                [  --without-zlib          do not use Zlib])

  #
  # Elf
  #
***************
*** 676,681 ****
--- 681,693 ----
  If you have zlib already installed, see config.log for details on the
  failure.  It is possible the compiler isn't looking in the proper directory.
  Use --without-zlib to disable zlib support.])])
+ fi
+
+ if test "$with_spinlocks" = yes; then
+   AC_DEFINE(HAVE_SPINLOCKS, 1, [Define to 1 if you have spinlocks.])
+ else
+   AC_MSG_WARN([
+ *** Not using spinlocks will cause poor performance.])
  fi

  if test "$with_krb4" = yes ; then
Index: doc/src/sgml/installation.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/installation.sgml,v
retrieving revision 1.141
diff -c -c -r1.141 installation.sgml
*** doc/src/sgml/installation.sgml    11 Sep 2003 21:42:20 -0000    1.141
--- doc/src/sgml/installation.sgml    12 Sep 2003 01:36:34 -0000
***************
*** 900,905 ****
--- 900,915 ----
        </varlistentry>

        <varlistentry>
+        <term><option>--without-spinlocks</option></term>
+        <listitem>
+         <para>
+          Allows source builds to succeed without CPU spinlock support.
+          Lack of spinlock support will produce poor performance.
+         </para>
+        </listitem>
+       </varlistentry>
+
+       <varlistentry>
         <term><option>--enable-thread-safety</option></term>
         <listitem>
          <para>
Index: src/backend/main/main.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/main/main.c,v
retrieving revision 1.62
diff -c -c -r1.62 main.c
*** src/backend/main/main.c    9 Sep 2003 15:19:31 -0000    1.62
--- src/backend/main/main.c    12 Sep 2003 01:36:34 -0000
***************
*** 23,29 ****
  #include <pwd.h>
  #include <unistd.h>

! #if defined(__alpha) && defined(__osf__)
  #include <sys/sysinfo.h>
  #include "machine/hal_sysinfo.h"
  #define ASSEMBLER
--- 23,29 ----
  #include <pwd.h>
  #include <unistd.h>

! #if defined(__alpha__) && defined(__osf__)
  #include <sys/sysinfo.h>
  #include "machine/hal_sysinfo.h"
  #define ASSEMBLER
***************
*** 63,76 ****
       * without help.  Avoid adding more here, if you can.
       */

! #if defined(__alpha)
  #ifdef NOFIXADE
      int            buffer[] = {SSIN_UACPROC, UAC_SIGBUS};
  #endif   /* NOFIXADE */
  #ifdef NOPRINTADE
      int            buffer[] = {SSIN_UACPROC, UAC_NOPRINT};
  #endif   /* NOPRINTADE */
! #endif   /* __alpha */

  #if defined(NOFIXADE) || defined(NOPRINTADE)

--- 63,76 ----
       * without help.  Avoid adding more here, if you can.
       */

! #if defined(__alpha__)
  #ifdef NOFIXADE
      int            buffer[] = {SSIN_UACPROC, UAC_SIGBUS};
  #endif   /* NOFIXADE */
  #ifdef NOPRINTADE
      int            buffer[] = {SSIN_UACPROC, UAC_NOPRINT};
  #endif   /* NOPRINTADE */
! #endif   /* __alpha__ */

  #if defined(NOFIXADE) || defined(NOPRINTADE)

***************
*** 78,84 ****
      syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL);
  #endif

! #if defined(__alpha)
      if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
                     (unsigned long) NULL) < 0)
          fprintf(stderr, gettext("%s: setsysinfo failed: %s\n"),
--- 78,84 ----
      syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL);
  #endif

! #if defined(__alpha__)
      if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
                     (unsigned long) NULL) < 0)
          fprintf(stderr, gettext("%s: setsysinfo failed: %s\n"),
Index: src/backend/storage/lmgr/s_lock.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/storage/lmgr/s_lock.c,v
retrieving revision 1.16
diff -c -c -r1.16 s_lock.c
*** src/backend/storage/lmgr/s_lock.c    8 Aug 2003 21:42:00 -0000    1.16
--- src/backend/storage/lmgr/s_lock.c    12 Sep 2003 01:36:35 -0000
***************
*** 118,128 ****
   * Various TAS implementations that cannot live in s_lock.h as no inline
   * definition exists (yet).
   * In the future, get rid of tas.[cso] and fold it into this file.
   */


  #if defined(__GNUC__)
! /*************************************************************************
   * All the gcc flavors that are not inlined
   */

--- 118,133 ----
   * Various TAS implementations that cannot live in s_lock.h as no inline
   * definition exists (yet).
   * In the future, get rid of tas.[cso] and fold it into this file.
+  *
+  * If you change something here, you have to modify s_lock.h because
+  * the definitions for these is split between this file and s_lock.h.
   */


  #if defined(__GNUC__)
!
! /*
!  * -----------------------------------------------------------------
   * All the gcc flavors that are not inlined
   */

***************
*** 208,214 ****



! #if defined(NEED_SPARC_TAS_ASM)
  /*
   * sparc machines not using gcc
   */
--- 213,219 ----



! #if defined(__sparc__)
  /*
   * sparc machines not using gcc
   */
***************
*** 227,240 ****
      asm("retl");
      asm("nop");
  }
! #endif   /* NEED_SPARC_TAS_ASM */
!
!
!

- #if defined(NEED_I386_TAS_ASM)
- /* non gcc i386 based things */
- #endif   /* NEED_I386_TAS_ASM */
  #endif   /* not __GNUC__ */


--- 232,239 ----
      asm("retl");
      asm("nop");
  }
! #endif   /* __sparc__ */

  #endif   /* not __GNUC__ */


Index: src/backend/storage/lmgr/spin.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/storage/lmgr/spin.c,v
retrieving revision 1.11
diff -c -c -r1.11 spin.c
*** src/backend/storage/lmgr/spin.c    4 Aug 2003 02:40:03 -0000    1.11
--- src/backend/storage/lmgr/spin.c    12 Sep 2003 01:36:35 -0000
***************
*** 25,31 ****
  #include "storage/lwlock.h"
  #include "storage/pg_sema.h"
  #include "storage/spin.h"
!

  #ifdef HAS_TEST_AND_SET

--- 25,31 ----
  #include "storage/lwlock.h"
  #include "storage/pg_sema.h"
  #include "storage/spin.h"
! #include "storage/s_lock.h"

  #ifdef HAS_TEST_AND_SET

Index: src/include/pg_config.h.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v
retrieving revision 1.62
diff -c -c -r1.62 pg_config.h.in
*** src/include/pg_config.h.in    7 Sep 2003 03:43:56 -0000    1.62
--- src/include/pg_config.h.in    12 Sep 2003 01:36:36 -0000
***************
*** 357,362 ****
--- 357,365 ----
  /* Define to 1 if you have the `snprintf' function. */
  #undef HAVE_SNPRINTF

+ /* Define to 1 if you have spinlocks. */
+ #undef HAVE_SPINLOCKS
+
  /* Define to 1 if you have the `srandom' function. */
  #undef HAVE_SRANDOM

Index: src/include/port/aix.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/aix.h,v
retrieving revision 1.9
diff -c -c -r1.9 aix.h
*** src/include/port/aix.h    12 Nov 2002 00:39:08 -0000    1.9
--- src/include/port/aix.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,8 ****
  #define CLASS_CONFLICT
  #define DISABLE_XOPEN_NLS
- #define HAS_TEST_AND_SET
-
- typedef unsigned int slock_t;

  #include <sys/machine.h>        /* ENDIAN definitions for network
                                   * communication */
--- 1,5 ----
Index: src/include/port/beos.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/beos.h,v
retrieving revision 1.11
diff -c -c -r1.11 beos.h
*** src/include/port/beos.h    25 Oct 2001 05:50:09 -0000    1.11
--- src/include/port/beos.h    12 Sep 2003 01:36:36 -0000
***************
*** 2,11 ****
  #include <kernel/image.h>
  #include <sys/ioctl.h>

- #define HAS_TEST_AND_SET
-
- typedef unsigned char slock_t;
-
  #define AF_UNIX        10            /* no domain sockets on BeOS */

  /* Beos doesn't have all the required getrusage fields */
--- 2,7 ----
Index: src/include/port/bsdi.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/bsdi.h,v
retrieving revision 1.8
diff -c -c -r1.8 bsdi.h
*** src/include/port/bsdi.h    4 Aug 2003 00:43:32 -0000    1.8
--- src/include/port/bsdi.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,10 ****
- #if defined(__i386__)
- #define NEED_I386_TAS_ASM
- #endif
- #if defined(__sparc__)
- #define NEED_SPARC_TAS_ASM
- #endif
-
- #define HAS_TEST_AND_SET
-
- typedef unsigned char slock_t;
--- 0 ----
Index: src/include/port/cygwin.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/cygwin.h,v
retrieving revision 1.4
diff -c -c -r1.4 cygwin.h
*** src/include/port/cygwin.h    4 Aug 2003 00:43:32 -0000    1.4
--- src/include/port/cygwin.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,8 ****
  /* $Header: /cvsroot/pgsql-server/src/include/port/cygwin.h,v 1.4 2003/08/04 00:43:32 momjian Exp $ */

- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
-
  #include <cygwin/version.h>

  /*
--- 1,5 ----
***************
*** 20,24 ****
  #define DLLIMPORT __declspec (dllexport)
  #else
  #define DLLIMPORT __declspec (dllimport)
-
  #endif
--- 17,20 ----
Index: src/include/port/darwin.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/darwin.h,v
retrieving revision 1.5
diff -c -c -r1.5 darwin.h
*** src/include/port/darwin.h    28 Oct 2001 06:26:08 -0000    1.5
--- src/include/port/darwin.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,13 ****
  #define __darwin__    1
-
- #if defined(__ppc__)
- #define HAS_TEST_AND_SET
- #endif
-
- #if defined(__ppc__)
- typedef unsigned int slock_t;
-
- #else
- typedef unsigned char slock_t;
-
- #endif
--- 1 ----
Index: src/include/port/dgux.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/dgux.h,v
retrieving revision 1.9
diff -c -c -r1.9 dgux.h
*** src/include/port/dgux.h    28 Oct 2001 06:26:08 -0000    1.9
--- src/include/port/dgux.h    12 Sep 2003 01:36:36 -0000
***************
*** 9,13 ****
  #endif
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        BIG_ENDIAN
-
  #endif
--- 9,12 ----
Index: src/include/port/freebsd.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/freebsd.h,v
retrieving revision 1.10
diff -c -c -r1.10 freebsd.h
*** src/include/port/freebsd.h    4 Aug 2003 00:43:32 -0000    1.10
--- src/include/port/freebsd.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,48 ****
- #if defined(__i386__)
- #define NEED_I386_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__sparc__)
- #define NEED_SPARC_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__vax__)
- #define NEED_VAX_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__ns32k__)
- #define NEED_NS32K_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__m68k__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__arm__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__mips__)
- /* #    undef HAS_TEST_AND_SET */
- #endif
-
- #if defined(__alpha__)
- #define HAS_TEST_AND_SET
- typedef unsigned long slock_t;
- #endif
-
- #if defined(__powerpc__)
- #define HAS_TEST_AND_SET
- typedef unsigned int slock_t;
-
- #endif
--- 0 ----
Index: src/include/port/hpux.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/hpux.h,v
retrieving revision 1.19
diff -c -c -r1.19 hpux.h
*** src/include/port/hpux.h    4 Aug 2003 00:43:32 -0000    1.19
--- src/include/port/hpux.h    12 Sep 2003 01:36:36 -0000
***************
*** 10,35 ****

  #if defined(__hppa)

- #define HAS_TEST_AND_SET
- typedef struct
- {
-     int            sema[4];
- } slock_t;
-
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        BIG_ENDIAN
  #endif

  #elif defined(__ia64)

- #define HAS_TEST_AND_SET
- typedef unsigned int slock_t;
-
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        LITTLE_ENDIAN
  #endif

  #else
  #error unrecognized CPU type for HP-UX

  #endif
--- 10,27 ----

  #if defined(__hppa)

  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        BIG_ENDIAN
  #endif

  #elif defined(__ia64)

  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        LITTLE_ENDIAN
  #endif

  #else
+
  #error unrecognized CPU type for HP-UX

  #endif
Index: src/include/port/irix5.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/irix5.h,v
retrieving revision 1.8
diff -c -c -r1.8 irix5.h
*** src/include/port/irix5.h    12 Nov 2002 00:39:08 -0000    1.8
--- src/include/port/irix5.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,3 ****
- #define HAS_TEST_AND_SET
-
- typedef unsigned long slock_t;
--- 0 ----
Index: src/include/port/linux.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/linux.h,v
retrieving revision 1.33
diff -c -c -r1.33 linux.h
*** src/include/port/linux.h    10 Nov 2002 00:33:43 -0000    1.33
--- src/include/port/linux.h    12 Sep 2003 01:36:36 -0000
***************
*** 2,52 ****
  #ifndef _GNU_SOURCE
  #define _GNU_SOURCE 1
  #endif
-
-
- #if defined(__i386__)
- typedef unsigned char slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__sparc__)
- typedef unsigned char slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__powerpc64__)
- typedef unsigned long slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__powerpc__)
- typedef unsigned int slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__alpha__)
- typedef long int slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__mips__)
- typedef unsigned int slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__arm__)
- typedef unsigned char slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__ia64__)
- typedef unsigned int slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__s390__) || defined(__s390x__)
- typedef unsigned int slock_t;
-
- #define HAS_TEST_AND_SET
-
- #endif
--- 2,4 ----
Index: src/include/port/netbsd.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/netbsd.h,v
retrieving revision 1.9
diff -c -c -r1.9 netbsd.h
*** src/include/port/netbsd.h    4 Aug 2003 00:43:32 -0000    1.9
--- src/include/port/netbsd.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,48 ****
- #if defined(__i386__)
- #define NEED_I386_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__sparc__)
- #define NEED_SPARC_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__vax__)
- #define NEED_VAX_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__ns32k__)
- #define NEED_NS32K_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__m68k__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__arm__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__mips__)
- /* #    undef HAS_TEST_AND_SET */
- #endif
-
- #if defined(__alpha__)
- #define HAS_TEST_AND_SET
- typedef unsigned long slock_t;
- #endif
-
- #if defined(__powerpc__)
- #define HAS_TEST_AND_SET
- typedef unsigned int slock_t;
-
- #endif
--- 0 ----
Index: src/include/port/nextstep.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/nextstep.h,v
retrieving revision 1.6
diff -c -c -r1.6 nextstep.h
*** src/include/port/nextstep.h    28 Oct 2000 23:53:00 -0000    1.6
--- src/include/port/nextstep.h    12 Sep 2003 01:36:36 -0000
***************
*** 15,18 ****
  #endif

  #define NO_WAITPID
- typedef struct mutex slock_t;
--- 15,17 ----
Index: src/include/port/openbsd.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/openbsd.h,v
retrieving revision 1.8
diff -c -c -r1.8 openbsd.h
*** src/include/port/openbsd.h    4 Aug 2003 00:43:32 -0000    1.8
--- src/include/port/openbsd.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,48 ****
- #if defined(__i386__)
- #define NEED_I386_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__sparc__)
- #define NEED_SPARC_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__vax__)
- #define NEED_VAX_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__ns32k__)
- #define NEED_NS32K_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__m68k__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__arm__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__mips__)
- /* #    undef HAS_TEST_AND_SET */
- #endif
-
- #if defined(__alpha__)
- #define HAS_TEST_AND_SET
- typedef unsigned long slock_t;
- #endif
-
- #if defined(__powerpc__)
- #define HAS_TEST_AND_SET
- typedef unsigned int slock_t;
-
- #endif
--- 0 ----
Index: src/include/port/osf.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/osf.h,v
retrieving revision 1.7
diff -c -c -r1.7 osf.h
*** src/include/port/osf.h    28 Oct 2001 06:26:08 -0000    1.7
--- src/include/port/osf.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,7 ****
  #define NOFIXADE
  #define DISABLE_XOPEN_NLS
! #define HAS_TEST_AND_SET
!  /* #include <sys/mman.h> */    /* for msemaphore */
  /*typedef msemaphore slock_t;*/
  #include <alpha/builtins.h>
- typedef volatile long slock_t;
--- 1,5 ----
  #define NOFIXADE
  #define DISABLE_XOPEN_NLS
! /* #include <sys/mman.h> */    /* for msemaphore */
  /*typedef msemaphore slock_t;*/
  #include <alpha/builtins.h>
Index: src/include/port/qnx4.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/qnx4.h,v
retrieving revision 1.8
diff -c -c -r1.8 qnx4.h
*** src/include/port/qnx4.h    9 May 2003 16:59:43 -0000    1.8
--- src/include/port/qnx4.h    12 Sep 2003 01:36:36 -0000
***************
*** 5,12 ****
  #include <unix.h>
  #include <sys/select.h>            /* for select */

- #define HAS_TEST_AND_SET
-
  #undef HAVE_GETRUSAGE

  #define strncasecmp strnicmp
--- 5,10 ----
***************
*** 21,28 ****
  #endif   /* NAN */

  typedef u_short ushort;
-
- typedef unsigned char slock_t;

  extern int    isnan(double dsrc);

--- 19,24 ----
Index: src/include/port/sco.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/sco.h,v
retrieving revision 1.13
diff -c -c -r1.13 sco.h
*** src/include/port/sco.h    28 Oct 2001 06:26:08 -0000    1.13
--- src/include/port/sco.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,13 ****
  /* see src/backend/libpq/pqcomm.c */
  #define SCO_ACCEPT_BUG

- #define HAS_TEST_AND_SET
- #define NEED_I386_TAS_ASM
-
  #define USE_UNIVEL_CC

- typedef unsigned char slock_t;
-
  #ifndef            BIG_ENDIAN
  #define            BIG_ENDIAN        4321
  #endif
--- 1,8 ----
***************
*** 19,23 ****
  #endif
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        LITTLE_ENDIAN
-
  #endif
--- 14,17 ----
Index: src/include/port/solaris.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/solaris.h,v
retrieving revision 1.8
diff -c -c -r1.8 solaris.h
*** src/include/port/solaris.h    10 Mar 2003 22:28:21 -0000    1.8
--- src/include/port/solaris.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,8 ****
  /* $Header: /cvsroot/pgsql-server/src/include/port/solaris.h,v 1.8 2003/03/10 22:28:21 tgl Exp $ */

- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
-
  /*
   * Sort this out for all operating systems some time.  The __xxx
   * symbols are defined on both GCC and Solaris CC, although GCC
--- 1,5 ----
Index: src/include/port/sunos4.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/sunos4.h,v
retrieving revision 1.7
diff -c -c -r1.7 sunos4.h
*** src/include/port/sunos4.h    28 Oct 2001 06:26:08 -0000    1.7
--- src/include/port/sunos4.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,6 ****
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
-
  /* sprintf() returns char *, not int, on SunOS 4.1.x */
  #define SPRINTF_CHAR

--- 1,3 ----
***************
*** 15,19 ****
  #endif
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        BIG_ENDIAN
-
  #endif
--- 12,15 ----
Index: src/include/port/svr4.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/svr4.h,v
retrieving revision 1.11
diff -c -c -r1.11 svr4.h
*** src/include/port/svr4.h    28 Oct 2001 06:26:08 -0000    1.11
--- src/include/port/svr4.h    12 Sep 2003 01:36:36 -0000
***************
*** 3,13 ****
  #define            BYTE_ORDER        BIG_ENDIAN
  #endif
  #endif
-
- #ifdef sinix
- #define HAS_TEST_AND_SET
-
- #include "abi_mutex.h"
- typedef abilock_t slock_t;
-
- #endif
--- 3,5 ----
Index: src/include/port/univel.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/univel.h,v
retrieving revision 1.17
diff -c -c -r1.17 univel.h
*** src/include/port/univel.h    28 Oct 2001 06:26:08 -0000    1.17
--- src/include/port/univel.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,14 ****
- #define HAS_TEST_AND_SET
- #define NEED_I386_TAS_ASM
-
  /***************************************
   * Define this if you are compiling with
   * the native UNIXWARE C compiler.
   ***************************************/
  #define USE_UNIVEL_CC

- typedef unsigned char slock_t;
-
  #ifndef            BIG_ENDIAN
  #define            BIG_ENDIAN        4321
  #endif
--- 1,9 ----
***************
*** 20,24 ****
  #endif
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        LITTLE_ENDIAN
-
  #endif
--- 15,18 ----
Index: src/include/port/unixware.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/unixware.h,v
retrieving revision 1.11
diff -c -c -r1.11 unixware.h
*** src/include/port/unixware.h    28 Oct 2001 06:26:08 -0000    1.11
--- src/include/port/unixware.h    12 Sep 2003 01:36:36 -0000
***************
*** 1,6 ****
- #define HAS_TEST_AND_SET
- #define NEED_I386_TAS_ASM
-
  /* see src/backend/libpq/pqcomm.c */
  #define SCO_ACCEPT_BUG

--- 1,3 ----
***************
*** 10,17 ****
   ***************************************/
  #define USE_UNIVEL_CC

- typedef unsigned char slock_t;
-
  #ifndef            BIG_ENDIAN
  #define            BIG_ENDIAN        4321
  #endif
--- 7,12 ----
***************
*** 23,27 ****
  #endif
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        LITTLE_ENDIAN
-
  #endif
--- 18,21 ----
Index: src/include/storage/s_lock.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/storage/s_lock.h,v
retrieving revision 1.112
diff -c -c -r1.112 s_lock.h
*** src/include/storage/s_lock.h    4 Aug 2003 02:40:15 -0000    1.112
--- src/include/storage/s_lock.h    12 Sep 2003 01:36:37 -0000
***************
*** 73,84 ****
  #include "storage/pg_sema.h"


- #if defined(HAS_TEST_AND_SET)
-
-
  #if defined(__GNUC__) || defined(__ICC)
! /*************************************************************************
   * All the gcc inlines
   */

  /*
--- 73,84 ----
  #include "storage/pg_sema.h"


  #if defined(__GNUC__) || defined(__ICC)
! /*
!  * ---------------------------------------------------------------------
   * All the gcc inlines
+  *
+  * Gcc consistently defines the CPU as __cpu__.
   */

  /*
***************
*** 95,101 ****
--- 95,104 ----


  #if defined(__i386__) || defined(__x86_64__) /* AMD Opteron */
+
+ #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 114,122 ****


  /* Intel Itanium */
! #if defined(__ia64__) || defined(__ia64)
! #define TAS(lock) tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
  {
--- 117,128 ----


  /* Intel Itanium */
! #if defined(__ia64__)

+ #define HAS_TEST_AND_SET
+ #define TAS(lock) tas(lock)
+ typedef unsigned int slock_t;
+
  static __inline__ int
  tas(volatile slock_t *lock)
  {
***************
*** 131,141 ****
      return (int) ret;
  }

! #endif     /* __ia64__ || __ia64 */


! #if defined(__arm__) || defined(__arm__)
  #define TAS(lock) tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
--- 137,150 ----
      return (int) ret;
  }

! #endif     /* __ia64__ */
!

+ #if defined(__arm__)

! #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 156,162 ****
  /*
   * S/390 Linux
   */
! #define TAS(lock)       tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
--- 165,174 ----
  /*
   * S/390 Linux
   */
!
! #define HAS_TEST_AND_SET
! #define TAS(lock) tas(lock)
! typedef unsigned int slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 182,188 ****
  /*
   * S/390x Linux (64-bit zSeries)
   */
! #define TAS(lock)       tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
--- 194,203 ----
  /*
   * S/390x Linux (64-bit zSeries)
   */
!
! #define HAS_TEST_AND_SET
! #define TAS(lock) tas(lock)
! typedef unsigned int slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 206,212 ****
--- 221,230 ----


  #if defined(__sparc__)
+
+ #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 223,229 ****
--- 241,251 ----
  #endif     /* __sparc__ */

  #if defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
+
+ #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned int slock_t;
+
  /*
   * NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
   * an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
***************
*** 259,265 ****
--- 281,290 ----


  #if defined(__mc68000__) && defined(__linux__)
+
+ #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 281,286 ****
--- 306,315 ----


  #if defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
+
+ #define HAS_TEST_AND_SET
+ typedef unsigned int slock_t;
+
  /*
   * PowerPC S_UNLOCK is almost standard but requires a "sync" instruction.
   */
***************
*** 294,305 ****
  #endif /* powerpc */


! #if defined(NEED_VAX_TAS_ASM)
  /*
   * VAXen -- even multiprocessor ones
   * (thanks to Tom Ivar Helbekkmo)
   */
  #define TAS(lock) tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
--- 323,337 ----
  #endif /* powerpc */


! #if defined(__vax__)
  /*
   * VAXen -- even multiprocessor ones
   * (thanks to Tom Ivar Helbekkmo)
   */
+
+ #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 317,327 ****
      return _res;
  }

! #endif     /* NEED_VAX_TAS_ASM */


! #if defined(NEED_NS32K_TAS_ASM)
  #define TAS(lock) tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
--- 349,362 ----
      return _res;
  }

! #endif     /* __vax__ */


! #if defined (__ns32k__)
!
! #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 335,352 ****
      return _res;
  }

! #endif     /* NEED_NS32K_TAS_ASM */



  #else                            /* !__GNUC__ */

! /***************************************************************************
   * All non-gcc inlines
   */

! #if defined(NEED_I386_TAS_ASM) && defined(USE_UNIVEL_CC)
! #define TAS(lock)    tas(lock)

  asm int
  tas(volatile slock_t *s_lock)
--- 370,404 ----
      return _res;
  }

! #endif     /* __ns32k__ */
!
!
! /* These live in s_lock.c */
!
! #if defined(__m68k__)
! #define HAS_TEST_AND_SET
! typedef unsigned char slock_t;
! #endif
!
! #if defined(__mips__) && !defined(__sgi)
! #define HAS_TEST_AND_SET
! typedef unsigned char slock_t;
! #endif



  #else                            /* !__GNUC__ */

! /*
!  * ---------------------------------------------------------------------
   * All non-gcc inlines
   */

! #if defined(__i386__) && defined(USE_UNIVEL_CC)
!
! #define HAS_TEST_AND_SET
! #define TAS(lock) tas(lock)
! typedef unsigned char slock_t;

  asm int
  tas(volatile slock_t *s_lock)
***************
*** 361,380 ****
      popl %ebx
  }

! #endif     /* defined(NEED_I386_TAS_ASM) && defined(USE_UNIVEL_CC) */

  #endif     /* defined(__GNUC__) */



! /*************************************************************************
   * These are the platforms that have only one compiler, or do not use inline
   * assembler (and hence have common code for gcc and non-gcc compilers,
   * if both are available).
   */


! #if defined(__alpha)

  /*
   * Correct multi-processor locking methods are explained in section 5.5.3
--- 413,451 ----
      popl %ebx
  }

! #endif     /* defined(__i386__) && defined(USE_UNIVEL_CC) */
!
!
! /* These live in s_lock.c */
!
! #if defined(sun3)
! #define HAS_TEST_AND_SET
! typedef unsigned char slock_t;
! #endif
!
! #if defined(__sparc__)
! #define HAS_TEST_AND_SET
! typedef unsigned char slock_t;
! #endif
!
!

  #endif     /* defined(__GNUC__) */



! /*
!  * -------------------------------------------------------------------------
   * These are the platforms that have only one compiler, or do not use inline
   * assembler (and hence have common code for gcc and non-gcc compilers,
   * if both are available).
   */


! #if defined(__alpha__)
!
! #define HAS_TEST_AND_SET
! typedef unsigned long slock_t;

  /*
   * Correct multi-processor locking methods are explained in section 5.5.3
***************
*** 384,390 ****
   */
  #if defined(__GNUC__)

! #define TAS(lock)  tas(lock)
  #define S_UNLOCK(lock)    \
  do \
  {\
--- 455,461 ----
   */
  #if defined(__GNUC__)

! #define TAS(lock) tas(lock)
  #define S_UNLOCK(lock)    \
  do \
  {\
***************
*** 435,441 ****

  #endif     /* defined(__GNUC__) */

! #endif     /* __alpha */


  #if defined(__hppa)
--- 506,512 ----

  #endif     /* defined(__GNUC__) */

! #endif     /* __alpha__ */


  #if defined(__hppa)
***************
*** 449,454 ****
--- 520,530 ----
   * all words set to non-zero. tas() is in tas.s
   */

+ #define HAS_TEST_AND_SET
+ typedef struct
+ {
+     int            sema[4];
+ } slock_t;
  #define S_UNLOCK(lock) \
      do { \
          volatile slock_t *lock_ = (volatile slock_t *) (lock); \
***************
*** 466,471 ****
--- 542,550 ----
  /*
   * QNX 4 using WATCOM C
   */
+
+ #define HAS_TEST_AND_SET
+ typedef unsigned char slock_t;
  #define TAS(lock) wc_tas(lock)
  extern slock_t wc_tas(volatile slock_t *lock);
  #pragma aux wc_tas =\
***************
*** 490,495 ****
--- 569,578 ----
   * assembly from his NECEWS SVR4 port, but we probably ought to retain this
   * for the R3000 chips out there.
   */
+
+ #define HAS_TEST_AND_SET
+ typedef unsigned long slock_t;
+
  #include "mutex.h"
  #define TAS(lock)    (test_and_set(lock,1))
  #define S_UNLOCK(lock)    (test_then_and(lock,0))
***************
*** 504,509 ****
--- 587,597 ----
   * member. (Basically same as SGI)
   *
   */
+
+ #define HAS_TEST_AND_SET
+ #include "abi_mutex.h"
+ typedef abilock_t slock_t;
+
  #define TAS(lock)    (!acquire_lock(lock))
  #define S_UNLOCK(lock)    release_lock(lock)
  #define S_INIT_LOCK(lock)    init_lock(lock)
***************
*** 517,522 ****
--- 605,614 ----
   *
   * Note that slock_t on POWER/POWER2/PowerPC is int instead of char
   */
+
+ #define HAS_TEST_AND_SET
+ typedef unsigned int slock_t;
+
  #define TAS(lock)            _check_lock(lock, 0, 1)
  #define S_UNLOCK(lock)        _clear_lock(lock, 0)
  #endif     /* _AIX */
***************
*** 528,533 ****
--- 620,628 ----
   * slock_t is defined as a struct mutex.
   */

+ #define HAS_TEST_AND_SET
+ typedef struct mutex slock_t;
+
  #define S_LOCK(lock)    mutex_lock(lock)
  #define S_UNLOCK(lock)    mutex_unlock(lock)
  #define S_INIT_LOCK(lock)    mutex_init(lock)
***************
*** 537,543 ****



! #else                            /* !HAS_TEST_AND_SET */

  /*
   * Fake spinlock implementation using semaphores --- slow and prone
--- 632,645 ----



! #ifndef HAS_TEST_AND_SET
!
! #ifdef HAVE_SPINLOCKS
! #error This platform does not support native spinlocks.
! #error To continue the compile, rerun configure using --without-spinlocks.
! #error However, performance will be poor.
! #error Please report this to pgsql-bugs@postgresql.org.
! #endif

  /*
   * Fake spinlock implementation using semaphores --- slow and prone
***************
*** 556,562 ****
  #define S_INIT_LOCK(lock)    s_init_lock_sema(lock)
  #define TAS(lock)    tas_sema(lock)

! #endif     /* HAS_TEST_AND_SET */



--- 658,664 ----
  #define S_INIT_LOCK(lock)    s_init_lock_sema(lock)
  #define TAS(lock)    tas_sema(lock)

! #endif




Re: Reorganization of spinlock defines

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Prompted by confusion over Itanium/Opterion, I have written a patch to
> improve the way we define spinlocks for platforms and cpu's.

The main.c part of the patch strikes me as irrelevant to the claimed
purpose and unlikely to accomplish anything except breaking things.
Do you have a system the main.c "__alpha" code is relevant to, on which
to test that you did not break it?

Other than that, it looks like basically a good idea.  But...

> I plan to apply this to 7.4.

This seems like living dangerously.  You do realize that this patch will
invalidate our trust that the code works on every single supported
platform?  I think beta3 may be a bit late in the game for this sort of
thing, because we've already gotten a good bit of the testing we can
expect to get for lesser-used platforms during this beta cycle.

At the very least I'd like to see the decision discussed on -hackers
and not buried in -patches.

            regards, tom lane

Re: Reorganization of spinlock defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Prompted by confusion over Itanium/Opterion, I have written a patch to
> > improve the way we define spinlocks for platforms and cpu's.
>
> The main.c part of the patch strikes me as irrelevant to the claimed
> purpose and unlikely to accomplish anything except breaking things.
> Do you have a system the main.c "__alpha" code is relevant to, on which
> to test that you did not break it?
>
> Other than that, it looks like basically a good idea.  But...

I was going to have an alpha guy test it --- that was the one change I
wasn't sure about.  We did test for __alpha__ all over the port/*.h
files, so it wasn't clear which alpha's were being hit.  I can throw in
a comment and skip that part --- not sure.

> > I plan to apply this to 7.4.
>
> This seems like living dangerously.  You do realize that this patch will
> invalidate our trust that the code works on every single supported
> platform?  I think beta3 may be a bit late in the game for this sort of
> thing, because we've already gotten a good bit of the testing we can
> expect to get for lesser-used platforms during this beta cycle.
>
> At the very least I'd like to see the decision discussed on -hackers
> and not buried in -patches.

The problem with waiting for 7.5 is that we will have no error reporting
when our non-spinlock code is being executed, and with Opteron/Itanium,
it seems like a good time to get it working.  We had the FreeBSD report
with not finding Opteron/Itanium, and that's what got me going.  Also,
if it doesn't find the spinlock code, it will report an error, so we
should flesh this all out as we collect supported platforms, which we
haven't started yet.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Reorganization of spinlock defines

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> The problem with waiting for 7.5 is that we will have no error reporting
> when our non-spinlock code is being executed, and with Opteron/Itanium,
> it seems like a good time to get it working.

Well, as long as you're prepared to reduce the list of known supported
platforms to zero as of 7.4beta3, and issue a fresh call for port reports.

But it seems to me that this is mostly a cosmetic cleanup and therefore
not the kind of thing to be doing late in beta.  Couldn't we do
something that affects only Opteron/Itanium and doesn't take a chance
on breaking everything else?

            regards, tom lane

Re: Reorganization of spinlock defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > The problem with waiting for 7.5 is that we will have no error reporting
> > when our non-spinlock code is being executed, and with Opteron/Itanium,
> > it seems like a good time to get it working.
>
> Well, as long as you're prepared to reduce the list of known supported
> platforms to zero as of 7.4beta3, and issue a fresh call for port reports.

I haven't collected any known reports yet.  That happens later, I
thought, nearer to RC1.

> But it seems to me that this is mostly a cosmetic cleanup and therefore
> not the kind of thing to be doing late in beta.  Couldn't we do
> something that affects only Opteron/Itanium and doesn't take a chance
> on breaking everything else?

Yes, but to throw an error if spinlocks aren't found, we need this
patch.  We would have to test for Opteron in all the platforms that test
for specific CPU's but don't test for opteron, and might support
opterion/itanium, but even then, we don't have any way of getting a
report of a failure.

Yea, I should have thought of this before beta1, but now that I see the
bug reports, seems we have to go this way.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Reorganization of spinlock defines

From
"Marc G. Fournier"
Date:

On Thu, 11 Sep 2003, Tom Lane wrote:

> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > The problem with waiting for 7.5 is that we will have no error reporting
> > when our non-spinlock code is being executed, and with Opteron/Itanium,
> > it seems like a good time to get it working.
>
> Well, as long as you're prepared to reduce the list of known supported
> platforms to zero as of 7.4beta3, and issue a fresh call for port reports.

I didn't think we had done that yet ... had we?  called for port reports,
that is ... ?

> But it seems to me that this is mostly a cosmetic cleanup and therefore
> not the kind of thing to be doing late in beta.  Couldn't we do
> something that affects only Opteron/Itanium and doesn't take a chance
> on breaking everything else?

I just went through the whole patch myself, and as much as I like the
overall simplification, I tend to agree with Tom here on questioning the
requirement to do suck a massive change so late in the end cycle ... is
there no smaller bandaid that can be applied to handle the Opteron/Itanium
issue for v7.4, with the "cleanup patch" being applied right away after
v7.4?


Re: Reorganization of spinlock defines

From
Bruce Momjian
Date:
Marc G. Fournier wrote:
> > But it seems to me that this is mostly a cosmetic cleanup and therefore
> > not the kind of thing to be doing late in beta.  Couldn't we do
> > something that affects only Opteron/Itanium and doesn't take a chance
> > on breaking everything else?
>
> I just went through the whole patch myself, and as much as I like the
> overall simplification, I tend to agree with Tom here on questioning the
> requirement to do suck a massive change so late in the end cycle ... is
> there no smaller bandaid that can be applied to handle the Opteron/Itanium
> issue for v7.4, with the "cleanup patch" being applied right away after
> v7.4?

Well, the problem was that we defined HAS_TEST_AND_SET inside the ports.
I guess we could splatter a test for Itanium and Opterion in every port
that could possibly use it, but then again, if we fall back to not
finding it for some reason, we don't get a report because we silently
fall back to semaphores.  That's what has me worried, that if we don't
do it, we will not know what platforms really aren't working properly.

Take FreeBSD for example, that couldn't find Opteron. It lists every
cpu like this:

    #if defined(__i386__)
    #define NEED_I386_TAS_ASM
    #define HAS_TEST_AND_SET
    typedef unsigned char slock_t;
    #endif

    #if defined(__sparc__)
    #define NEED_SPARC_TAS_ASM
    #define HAS_TEST_AND_SET
    typedef unsigned char slock_t;
    #endif

We would have to add an opteron/itanium to port that does this, but if
we miss some opteron/itanium define, we might never know because of the
silent fallback.

I don't care if we save it for 7.5 --- I just don't know how we will be
sure we have things working properly without it.

We could apply it tomorrow and see how things look on Monday.


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Reorganization of spinlock defines

From
Larry Rosenman
Date:

--On Thursday, September 11, 2003 23:46:56 -0300 "Marc G. Fournier"
<scrappy@postgresql.org> wrote:

>
>
> On Thu, 11 Sep 2003, Tom Lane wrote:
>
>> Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> > The problem with waiting for 7.5 is that we will have no error
>> > reporting when our non-spinlock code is being executed, and with
>> > Opteron/Itanium, it seems like a good time to get it working.
>>
>> Well, as long as you're prepared to reduce the list of known supported
>> platforms to zero as of 7.4beta3, and issue a fresh call for port
>> reports.
>
> I didn't think we had done that yet ... had we?  called for port reports,
> that is ... ?
>
>> But it seems to me that this is mostly a cosmetic cleanup and therefore
>> not the kind of thing to be doing late in beta.  Couldn't we do
>> something that affects only Opteron/Itanium and doesn't take a chance
>> on breaking everything else?
>
> I just went through the whole patch myself, and as much as I like the
> overall simplification, I tend to agree with Tom here on questioning the
> requirement to do suck a massive change so late in the end cycle ... is
> there no smaller bandaid that can be applied to handle the Opteron/Itanium
> issue for v7.4, with the "cleanup patch" being applied right away after
> v7.4?
>
Bruce sent me a copy of the patch, and it ****BREAKS**** UnixWare (If y'all
care).

LER

--
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

Attachment

Re: Reorganization of spinlock defines

From
"Marc G. Fournier"
Date:
On Thu, 11 Sep 2003, Bruce Momjian wrote:

> Yes, but to throw an error if spinlocks aren't found, we need this
> patch.  We would have to test for Opteron in all the platforms that test
> for specific CPU's but don't test for opteron, and might support
> opterion/itanium, but even then, we don't have any way of getting a
> report of a failure.

'K, but apparently right now we are broken on Opteron/Itanium without this
patch ... so, to fix, we either:

a. add appropriate tests to the individual port files based on individual
failure reports (albeit not clean, definitely safer), or:

b. we do massive, sweeping changes to the whole HAVE_TEST_AND_SET
detection code (definitely cleaner, but has potential of breaking more
then it fixes) :(

personally, as late in the cycle as we are, I think that a. is the wiser
move for v7.4, with b. being something that should happen as soon as
possible once we've branched and start working on v7.5 ...



Re: Reorganization of spinlock defines

From
Tom Lane
Date:
"Marc G. Fournier" <scrappy@postgresql.org> writes:
> On Thu, 11 Sep 2003, Tom Lane wrote:
>> Well, as long as you're prepared to reduce the list of known supported
>> platforms to zero as of 7.4beta3, and issue a fresh call for port reports.

> I didn't think we had done that yet ... had we?  called for port reports,
> that is ... ?

We hadn't, no.  My point is that in the past we've continued to list
platforms as supported if we've had a successful report in the past
release or two.  Fooling with the spinlock code is delicate enough
that I'd want to insist on moving everything to the "unsupported"
category until we get a success report with the modified code.

Maybe we should just do that.  It's likely that the only platforms
that end up marked unsupported are ones that no one cares about any
more anyway.  But I think we have to realize that this is not a
trivial set of changes, even if it looks like it "should work".
(Which it does, just for the record.  I'm just feeling paranoid
because of where we are in the release cycle.)

            regards, tom lane

Re: Reorganization of spinlock defines

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> I guess we could splatter a test for Itanium and Opterion in every port
> that could possibly use it, but then again, if we fall back to not
> finding it for some reason, we don't get a report because we silently
> fall back to semaphores.  That's what has me worried, that if we don't
> do it, we will not know what platforms really aren't working properly.

Agreed, the silent fallback to semaphores isn't such a hot idea in
hindsight.  But the part of the patch that requires a configure option
to use that code path could be applied without touching anything else.

            regards, tom lane

Re: [HACKERS] Reorganization of spinlock defines

From
Tom Lane
Date:
Larry Rosenman <ler@lerctr.org> writes:
> Bruce sent me a copy of the patch, and it ****BREAKS**** UnixWare (If y'all=
> =20
> care).

Unfixably?  Or just a small oversight?

I'm actually not worried about platforms that are actively being tested.
It's the stuff that hasn't been confirmed recently that is going to be
at risk.

            regards, tom lane

Re: [HACKERS] Reorganization of spinlock defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Larry Rosenman <ler@lerctr.org> writes:
> > Bruce sent me a copy of the patch, and it ****BREAKS**** UnixWare (If y'all=
> > =20
> > care).
>
> Unfixably?  Or just a small oversight?
>
> I'm actually not worried about platforms that are actively being tested.
> It's the stuff that hasn't been confirmed recently that is going to be
> at risk.

I sent him a new patch just now.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: [HACKERS] Reorganization of spinlock defines

From
Larry Rosenman
Date:

--On Thursday, September 11, 2003 23:13:54 -0400 Tom Lane
<tgl@sss.pgh.pa.us> wrote:

> Larry Rosenman <ler@lerctr.org> writes:
>> Bruce sent me a copy of the patch, and it ****BREAKS**** UnixWare (If
>> y'all= =20
>> care).
>
> Unfixably?  Or just a small oversight?
>
> I'm actually not worried about platforms that are actively being tested.
> It's the stuff that hasn't been confirmed recently that is going to be
> at risk.
I'm seeing failures with the 2nd patch as well.  Seems like it's not liking
UnixWare's
cc defines.

the documentation is at:

http://www.lerctr.org:8458/

the cc man page is at:

http://www.lerctr.org:8458/en/man/html.1/cc.1.html

Tom, You still have an account here.

Bruce, if you'd like an account, that is easily arranged.

LER

>
>             regards, tom lane



--
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

Attachment

Re: [HACKERS] Reorganization of spinlock defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > I guess we could splatter a test for Itanium and Opterion in every port
> > that could possibly use it, but then again, if we fall back to not
> > finding it for some reason, we don't get a report because we silently
> > fall back to semaphores.  That's what has me worried, that if we don't
> > do it, we will not know what platforms really aren't working properly.
>
> Agreed, the silent fallback to semaphores isn't such a hot idea in
> hindsight.  But the part of the patch that requires a configure option
> to use that code path could be applied without touching anything else.

Yes, we could do just the configure warning, then plaster tests into the
port files to try to hit all the opteron/itanium cases.  I am a little
concerned that this might throw up a bunch of problem cases that we will
patching for a while.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: [HACKERS] Reorganization of spinlock defines

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Yes, we could do just the configure warning, then plaster tests into the
> port files to try to hit all the opteron/itanium cases.  I am a little
> concerned that this might throw up a bunch of problem cases that we will
> patching for a while.

Probably so --- but we'd only be breaking new platforms that people are
starting to use, not old ones that might not be getting tested
regularly.

Understand that I'm not dead set against applying this patch for 7.4.
(On a code-cleanliness point of view I favor it.)  What I want is some
open discussion about the risks and benefits before we decide.

            regards, tom lane

Re: [HACKERS] Reorganization of spinlock defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Yes, we could do just the configure warning, then plaster tests into the
> > port files to try to hit all the opteron/itanium cases.  I am a little
> > concerned that this might throw up a bunch of problem cases that we will
> > patching for a while.
>
> Probably so --- but we'd only be breaking new platforms that people are
> starting to use, not old ones that might not be getting tested
> regularly.

Looking at the code, I wonder if we already have folks not using
spinlocks, and not even knowing it.  I don't think problem reports will
be limited to new platforms.

> Understand that I'm not dead set against applying this patch for 7.4.
> (On a code-cleanliness point of view I favor it.)  What I want is some
> open discussion about the risks and benefits before we decide.

Sure, and I am not pushing the patch.  I am just saying it would have
been ideal a few weeks ago --- I am not sure if we are worse off with or
without it.

I just learned from Larry that Unixware defines intel as i386, not
__i386 or __i386__, at least of the native SCO compiler that he uses.

What the code used to do is define NEED_I386_TAS_ASM unconditionally on
some platforms (negating the need to test for a compiler symbol) or test
for each platform compiler symbol (and not test all possible ways it
could be specified), like FreeBSD did.  That's why things are so messy.
I am going to test for __cpu, __cpu__, and cpu on non-gcc compiler for
consistency.  It is only done in one place in the patch, so that should
be good.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: [HACKERS] Reorganization of spinlock defines

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Looking at the code, I wonder if we already have folks not using
> spinlocks, and not even knowing it.  I don't think problem reports will
> be limited to new platforms.

Very likely --- I heard from someone recently who was trying to run
HPUX/Itanium.  After we got past the hard-wired assumption that HPUX
== HPPA, it was still giving lousy performance for lack of spinlocks.
I like the part of the patch that is in-your-face about that.

> I just learned from Larry that Unixware defines intel as i386, not
> __i386 or __i386__, at least of the native SCO compiler that he uses.

[blink]  Namespace infringement 'r us, huh?

> I am going to test for __cpu, __cpu__, and cpu on non-gcc compiler for
> consistency.  It is only done in one place in the patch, so that should
> be good.

Please, only the first two.  Make the Unixware template add __i386__.
Don't add assumptions about valid user-namespace symbols.

            regards, tom lane

Re: [HACKERS] Reorganization of spinlock defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Looking at the code, I wonder if we already have folks not using
> > spinlocks, and not even knowing it.  I don't think problem reports will
> > be limited to new platforms.
>
> Very likely --- I heard from someone recently who was trying to run
> HPUX/Itanium.  After we got past the hard-wired assumption that HPUX
> == HPPA, it was still giving lousy performance for lack of spinlocks.
> I like the part of the patch that is in-your-face about that.
>
> > I just learned from Larry that Unixware defines intel as i386, not
> > __i386 or __i386__, at least of the native SCO compiler that he uses.
>
> [blink]  Namespace infringement 'r us, huh?
>
> > I am going to test for __cpu, __cpu__, and cpu on non-gcc compiler for
> > consistency.  It is only done in one place in the patch, so that should
> > be good.
>
> Please, only the first two.  Make the Unixware template add __i386__.
> Don't add assumptions about valid user-namespace symbols.

Roger!

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: [HACKERS] Reorganization of spinlock defines

From
Larry Rosenman
Date:

--On Thursday, September 11, 2003 23:42:53 -0400 Tom Lane
<tgl@sss.pgh.pa.us> wrote:

> Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> Looking at the code, I wonder if we already have folks not using
>> spinlocks, and not even knowing it.  I don't think problem reports will
>> be limited to new platforms.
>
> Very likely --- I heard from someone recently who was trying to run
> HPUX/Itanium.  After we got past the hard-wired assumption that HPUX
> == HPPA, it was still giving lousy performance for lack of spinlocks.
> I like the part of the patch that is in-your-face about that.
>
>> I just learned from Larry that Unixware defines intel as i386, not
>> __i386 or __i386__, at least of the native SCO compiler that he uses.
>
> [blink]  Namespace infringement 'r us, huh?
Yeah.  I **DO** have SCO's ear on it, but I don't know how far I'll get,
plus there are
TONS of pre-whenever-we-get-it-fixed out there.


>
>> I am going to test for __cpu, __cpu__, and cpu on non-gcc compiler for
>> consistency.  It is only done in one place in the patch, so that should
>> be good.
>
> Please, only the first two.  Make the Unixware template add __i386__.
> Don't add assumptions about valid user-namespace symbols.
that's reasonable.  At least until 64-bit UnixWare. :-)

(announced at SCOForum).


>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html
>



--
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

Attachment

Re: [HACKERS] Reorganization of spinlock defines

From
Tom Lane
Date:
Larry Rosenman <ler@lerctr.org> writes:
>> Please, only the first two.  Make the Unixware template add __i386__.
>> Don't add assumptions about valid user-namespace symbols.

> that's reasonable.  At least until 64-bit UnixWare. :-)

Even then, I'd prefer to put the necessary kluge into template/unixware
or Makefile.unixware or port/unixware.h, rather than add a risky
assumption globally.

            regards, tom lane

Re: [HACKERS] Reorganization of spinlock defines

From
Larry Rosenman
Date:

--On Friday, September 12, 2003 00:00:43 -0400 Tom Lane <tgl@sss.pgh.pa.us>
wrote:

> Larry Rosenman <ler@lerctr.org> writes:
>>> Please, only the first two.  Make the Unixware template add __i386__.
>>> Don't add assumptions about valid user-namespace symbols.
>
>> that's reasonable.  At least until 64-bit UnixWare. :-)
>
> Even then, I'd prefer to put the necessary kluge into template/unixware
> or Makefile.unixware or port/unixware.h, rather than add a risky
> assumption globally.
Sure, and 64-bit UnixWare is 2 years out any way.

Hopefully we can get reasonableness by then.

I've already sent a whine-a-gram to the compiler guys at SCO.

LER

>
>             regards, tom lane



--
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

Attachment

Re: [HACKERS] Reorganization of spinlock defines

From
Tom Lane
Date:
Larry Rosenman <ler@lerctr.org> writes:
> I've already sent a whine-a-gram to the compiler guys at SCO.

Prolly you thought of this already, but: getting them to *add*
an implicit #define of __i386__ should be plenty easy compared
to getting them to *remove* the one for i386.  And while I think
they should remove the latter, the immediate problem would be
solved as soon as they add the former.

            regards, tom lane

Re: Reorganization of spinlock defines

From
"Marc G. Fournier"
Date:

On Thu, 11 Sep 2003, Bruce Momjian wrote:

> Well, the problem was that we defined HAS_TEST_AND_SET inside the ports.
> I guess we could splatter a test for Itanium and Opterion in every port
> that could possibly use it, but then again, if we fall back to not
> finding it for some reason, we don't get a report because we silently
> fall back to semaphores.  That's what has me worried, that if we don't
> do it, we will not know what platforms really aren't working properly.

From what I understand, "not working properly" means slow, not broken, no?
Which means ppl could submit a problem report and it could be fixed for
v7.4.1 ... its not so much  'not working properly' as it is 'not optimal
performance' ...

Re: [HACKERS] Reorganization of spinlock defines

From
Larry Rosenman
Date:

--On Friday, September 12, 2003 00:06:49 -0400 Tom Lane <tgl@sss.pgh.pa.us>
wrote:

> Larry Rosenman <ler@lerctr.org> writes:
>> I've already sent a whine-a-gram to the compiler guys at SCO.
>
> Prolly you thought of this already, but: getting them to *add*
> an implicit #define of __i386__ should be plenty easy compared
> to getting them to *remove* the one for i386.  And while I think
> they should remove the latter, the immediate problem would be
> solved as soon as they add the former.
sure, and I expect that's what they may do.  We'll see what they say.

LER

>
>             regards, tom lane



--
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

Attachment

Re: [HACKERS] Reorganization of spinlock defines

From
Bruce Momjian
Date:
Marc G. Fournier wrote:
>
>
> On Thu, 11 Sep 2003, Bruce Momjian wrote:
>
> > Well, the problem was that we defined HAS_TEST_AND_SET inside the ports.
> > I guess we could splatter a test for Itanium and Opterion in every port
> > that could possibly use it, but then again, if we fall back to not
> > finding it for some reason, we don't get a report because we silently
> > fall back to semaphores.  That's what has me worried, that if we don't
> > do it, we will not know what platforms really aren't working properly.
>
> >From what I understand, "not working properly" means slow, not broken, no?
> Which means ppl could submit a problem report and it could be fixed for
> v7.4.1 ... its not so much  'not working properly' as it is 'not optimal
> performance' ...

Right, though I am not sure people will know _slow_ configuration vs.
PostgreSQL is slow.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: [HACKERS] Reorganization of spinlock defines

From
"Marc G. Fournier"
Date:
On Thu, 11 Sep 2003, Bruce Momjian wrote:

> I just learned from Larry that Unixware defines intel as i386, not
> __i386 or __i386__, at least of the native SCO compiler that he uses.

could we put something in the various port files to standardize this?  ie.
in unixware.h, add somethinglike:

#ifdef i386
#define __i386__
#endif

just so that 'special cases' are centralized in the ports file, and the
mainstream code doesn't have:

#if defined(i386) || defined(__i386) || defined(__i386__)

?


Re: [HACKERS] Reorganization of spinlock defines

From
Bruce Momjian
Date:
Marc G. Fournier wrote:
>
> On Thu, 11 Sep 2003, Bruce Momjian wrote:
>
> > I just learned from Larry that Unixware defines intel as i386, not
> > __i386 or __i386__, at least of the native SCO compiler that he uses.
>
> could we put something in the various port files to standardize this?  ie.
> in unixware.h, add somethinglike:
>
> #ifdef i386
> #define __i386__
> #endif
>
> just so that 'special cases' are centralized in the ports file, and the
> mainstream code doesn't have:
>
> #if defined(i386) || defined(__i386) || defined(__i386__)

Yep, that's what Tom wants and I am doing that now.  I sent a patch to
Larry for testing.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Reorganization of spinlock defines

From
Bruce Momjian
Date:
New patch attached.

---------------------------------------------------------------------------

Bruce Momjian wrote:
> Prompted by confusion over Itanium/Opterion, I have written a patch to
> improve the way we define spinlocks for platforms and cpu's.  It
> basically decouples the OS from the CPU spinlock code.  In almost all
> cases, the spinlock code cares only about the compiler and CPU, not the
> OS.
>
> The patch:
>
>     o defines HAS_TEST_AND_SET inside each spinlock routine, not in
>       platform-specific files
>     o moves slock_t defines into the spinlock routines
>     o remove NEED_{CPU}_TAS_ASM define because it is no longer needed
>     o reports a compile error if spinlocks are not defined
>     o adds a configure option --without-spinlocks to allow
>       non-spinlock compiles
>
> Looking at the patch, I realize this is how we should have done it all
> along.
>
> It would be nice to report the lack of spinlocks in configure, rather
> than during the compile, but I can't compile s_lock.h and test for
> HAS_TEST_AND_SET until configure completes.
>
> I plan to apply this to 7.4.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: configure
===================================================================
RCS file: /cvsroot/pgsql-server/configure,v
retrieving revision 1.295
diff -c -c -r1.295 configure
*** configure    7 Sep 2003 16:49:41 -0000    1.295
--- configure    12 Sep 2003 04:38:16 -0000
***************
*** 869,874 ****
--- 869,875 ----
    --with-rendezvous       build with Rendezvous support
    --with-openssl[=DIR]    build with OpenSSL support [/usr/local/ssl]
    --without-readline      do not use Readline
+   --without-spinlocks      do not use Spinlocks
    --without-zlib          do not use Zlib
    --with-gnu-ld           assume the C compiler uses GNU ld default=no

***************
*** 3494,3499 ****
--- 3495,3530 ----


  #
+ # Spinlocks
+ #
+
+
+
+ # Check whether --with-spinlocks or --without-spinlocks was given.
+ if test "${with_spinlocks+set}" = set; then
+   withval="$with_spinlocks"
+
+   case $withval in
+     yes)
+       :
+       ;;
+     no)
+       :
+       ;;
+     *)
+       { { echo "$as_me:$LINENO: error: no argument expected for --with-spinlocks option" >&5
+ echo "$as_me: error: no argument expected for --with-spinlocks option" >&2;}
+    { (exit 1); exit 1; }; }
+       ;;
+   esac
+
+ else
+   with_spinlocks=yes
+
+ fi;
+
+
+ #
  # Zlib
  #

***************
*** 3523,3529 ****
  fi;


-
  #
  # Elf
  #
--- 3554,3559 ----
***************
*** 6060,6065 ****
--- 6090,6108 ----
     { (exit 1); exit 1; }; }
  fi

+ fi
+
+ if test "$with_spinlocks" = yes; then
+
+ cat >>confdefs.h <<\_ACEOF
+ #define HAVE_SPINLOCKS 1
+ _ACEOF
+
+ else
+   { echo "$as_me:$LINENO: WARNING:
+ *** Not using spinlocks will cause poor performance." >&5
+ echo "$as_me: WARNING:
+ *** Not using spinlocks will cause poor performance." >&2;}
  fi

  if test "$with_krb4" = yes ; then
Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql-server/configure.in,v
retrieving revision 1.286
diff -c -c -r1.286 configure.in
*** configure.in    7 Sep 2003 16:38:05 -0000    1.286
--- configure.in    12 Sep 2003 04:38:18 -0000
***************
*** 522,533 ****
                [  --without-readline      do not use Readline])

  #
  # Zlib
  #
  PGAC_ARG_BOOL(with, zlib, yes,
                [  --without-zlib          do not use Zlib])

-
  #
  # Elf
  #
--- 522,538 ----
                [  --without-readline      do not use Readline])

  #
+ # Spinlocks
+ #
+ PGAC_ARG_BOOL(with, spinlocks, yes,
+               [  --without-spinlocks      do not use Spinlocks])
+
+ #
  # Zlib
  #
  PGAC_ARG_BOOL(with, zlib, yes,
                [  --without-zlib          do not use Zlib])

  #
  # Elf
  #
***************
*** 676,681 ****
--- 681,693 ----
  If you have zlib already installed, see config.log for details on the
  failure.  It is possible the compiler isn't looking in the proper directory.
  Use --without-zlib to disable zlib support.])])
+ fi
+
+ if test "$with_spinlocks" = yes; then
+   AC_DEFINE(HAVE_SPINLOCKS, 1, [Define to 1 if you have spinlocks.])
+ else
+   AC_MSG_WARN([
+ *** Not using spinlocks will cause poor performance.])
  fi

  if test "$with_krb4" = yes ; then
Index: doc/src/sgml/installation.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/installation.sgml,v
retrieving revision 1.141
diff -c -c -r1.141 installation.sgml
*** doc/src/sgml/installation.sgml    11 Sep 2003 21:42:20 -0000    1.141
--- doc/src/sgml/installation.sgml    12 Sep 2003 04:38:21 -0000
***************
*** 900,905 ****
--- 900,915 ----
        </varlistentry>

        <varlistentry>
+        <term><option>--without-spinlocks</option></term>
+        <listitem>
+         <para>
+          Allows source builds to succeed without CPU spinlock support.
+          Lack of spinlock support will produce poor performance.
+         </para>
+        </listitem>
+       </varlistentry>
+
+       <varlistentry>
         <term><option>--enable-thread-safety</option></term>
         <listitem>
          <para>
Index: src/backend/main/main.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/main/main.c,v
retrieving revision 1.62
diff -c -c -r1.62 main.c
*** src/backend/main/main.c    9 Sep 2003 15:19:31 -0000    1.62
--- src/backend/main/main.c    12 Sep 2003 04:38:22 -0000
***************
*** 23,29 ****
  #include <pwd.h>
  #include <unistd.h>

! #if defined(__alpha) && defined(__osf__)
  #include <sys/sysinfo.h>
  #include "machine/hal_sysinfo.h"
  #define ASSEMBLER
--- 23,29 ----
  #include <pwd.h>
  #include <unistd.h>

! #if (defined(__alpha__) || defined(__alpha)) && defined(__osf__)
  #include <sys/sysinfo.h>
  #include "machine/hal_sysinfo.h"
  #define ASSEMBLER
***************
*** 63,76 ****
       * without help.  Avoid adding more here, if you can.
       */

! #if defined(__alpha)
  #ifdef NOFIXADE
      int            buffer[] = {SSIN_UACPROC, UAC_SIGBUS};
  #endif   /* NOFIXADE */
  #ifdef NOPRINTADE
      int            buffer[] = {SSIN_UACPROC, UAC_NOPRINT};
  #endif   /* NOPRINTADE */
! #endif   /* __alpha */

  #if defined(NOFIXADE) || defined(NOPRINTADE)

--- 63,76 ----
       * without help.  Avoid adding more here, if you can.
       */

! #if defined(__alpha__) || defined(__alpha)
  #ifdef NOFIXADE
      int            buffer[] = {SSIN_UACPROC, UAC_SIGBUS};
  #endif   /* NOFIXADE */
  #ifdef NOPRINTADE
      int            buffer[] = {SSIN_UACPROC, UAC_NOPRINT};
  #endif   /* NOPRINTADE */
! #endif   /* __alpha__ */

  #if defined(NOFIXADE) || defined(NOPRINTADE)

***************
*** 78,84 ****
      syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL);
  #endif

! #if defined(__alpha)
      if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
                     (unsigned long) NULL) < 0)
          fprintf(stderr, gettext("%s: setsysinfo failed: %s\n"),
--- 78,84 ----
      syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL);
  #endif

! #if defined(__alpha__) || defined(__alpha)
      if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
                     (unsigned long) NULL) < 0)
          fprintf(stderr, gettext("%s: setsysinfo failed: %s\n"),
Index: src/backend/storage/lmgr/s_lock.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/storage/lmgr/s_lock.c,v
retrieving revision 1.16
diff -c -c -r1.16 s_lock.c
*** src/backend/storage/lmgr/s_lock.c    8 Aug 2003 21:42:00 -0000    1.16
--- src/backend/storage/lmgr/s_lock.c    12 Sep 2003 04:38:26 -0000
***************
*** 118,128 ****
   * Various TAS implementations that cannot live in s_lock.h as no inline
   * definition exists (yet).
   * In the future, get rid of tas.[cso] and fold it into this file.
   */


  #if defined(__GNUC__)
! /*************************************************************************
   * All the gcc flavors that are not inlined
   */

--- 118,133 ----
   * Various TAS implementations that cannot live in s_lock.h as no inline
   * definition exists (yet).
   * In the future, get rid of tas.[cso] and fold it into this file.
+  *
+  * If you change something here, you have to modify s_lock.h because
+  * the definitions for these is split between this file and s_lock.h.
   */


  #if defined(__GNUC__)
!
! /*
!  * -----------------------------------------------------------------
   * All the gcc flavors that are not inlined
   */

***************
*** 148,154 ****
  }
  #endif   /* __m68k__ */

! #if defined(__mips__) && !defined(__sgi)
  static void
  tas_dummy()
  {
--- 153,159 ----
  }
  #endif   /* __m68k__ */

! #if defined(__mips__) && !defined(__sgi__)
  static void
  tas_dummy()
  {
***************
*** 173,179 ****
              j       $31            \n\
  ");
  }
! #endif   /* __mips__ && !__sgi */

  #else                            /* not __GNUC__ */
  /***************************************************************************
--- 178,184 ----
              j       $31            \n\
  ");
  }
! #endif   /* __mips__ && !__sgi__ */

  #else                            /* not __GNUC__ */
  /***************************************************************************
***************
*** 208,214 ****



! #if defined(NEED_SPARC_TAS_ASM)
  /*
   * sparc machines not using gcc
   */
--- 213,219 ----



! #if defined(__sparc__) || defined(__sparc)
  /*
   * sparc machines not using gcc
   */
***************
*** 227,240 ****
      asm("retl");
      asm("nop");
  }
! #endif   /* NEED_SPARC_TAS_ASM */
!
!
!

- #if defined(NEED_I386_TAS_ASM)
- /* non gcc i386 based things */
- #endif   /* NEED_I386_TAS_ASM */
  #endif   /* not __GNUC__ */


--- 232,239 ----
      asm("retl");
      asm("nop");
  }
! #endif   /* __sparc__ */

  #endif   /* not __GNUC__ */


Index: src/backend/storage/lmgr/spin.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/storage/lmgr/spin.c,v
retrieving revision 1.11
diff -c -c -r1.11 spin.c
*** src/backend/storage/lmgr/spin.c    4 Aug 2003 02:40:03 -0000    1.11
--- src/backend/storage/lmgr/spin.c    12 Sep 2003 04:38:26 -0000
***************
*** 25,31 ****
  #include "storage/lwlock.h"
  #include "storage/pg_sema.h"
  #include "storage/spin.h"
!

  #ifdef HAS_TEST_AND_SET

--- 25,31 ----
  #include "storage/lwlock.h"
  #include "storage/pg_sema.h"
  #include "storage/spin.h"
! #include "storage/s_lock.h"

  #ifdef HAS_TEST_AND_SET

Index: src/include/pg_config.h.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v
retrieving revision 1.62
diff -c -c -r1.62 pg_config.h.in
*** src/include/pg_config.h.in    7 Sep 2003 03:43:56 -0000    1.62
--- src/include/pg_config.h.in    12 Sep 2003 04:38:26 -0000
***************
*** 357,362 ****
--- 357,365 ----
  /* Define to 1 if you have the `snprintf' function. */
  #undef HAVE_SNPRINTF

+ /* Define to 1 if you have spinlocks. */
+ #undef HAVE_SPINLOCKS
+
  /* Define to 1 if you have the `srandom' function. */
  #undef HAVE_SRANDOM

Index: src/include/port/aix.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/aix.h,v
retrieving revision 1.9
diff -c -c -r1.9 aix.h
*** src/include/port/aix.h    12 Nov 2002 00:39:08 -0000    1.9
--- src/include/port/aix.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,8 ****
  #define CLASS_CONFLICT
  #define DISABLE_XOPEN_NLS
- #define HAS_TEST_AND_SET
-
- typedef unsigned int slock_t;

  #include <sys/machine.h>        /* ENDIAN definitions for network
                                   * communication */
--- 1,5 ----
Index: src/include/port/beos.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/beos.h,v
retrieving revision 1.11
diff -c -c -r1.11 beos.h
*** src/include/port/beos.h    25 Oct 2001 05:50:09 -0000    1.11
--- src/include/port/beos.h    12 Sep 2003 04:38:27 -0000
***************
*** 2,11 ****
  #include <kernel/image.h>
  #include <sys/ioctl.h>

- #define HAS_TEST_AND_SET
-
- typedef unsigned char slock_t;
-
  #define AF_UNIX        10            /* no domain sockets on BeOS */

  /* Beos doesn't have all the required getrusage fields */
--- 2,7 ----
Index: src/include/port/bsdi.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/bsdi.h,v
retrieving revision 1.8
diff -c -c -r1.8 bsdi.h
*** src/include/port/bsdi.h    4 Aug 2003 00:43:32 -0000    1.8
--- src/include/port/bsdi.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,10 ****
- #if defined(__i386__)
- #define NEED_I386_TAS_ASM
- #endif
- #if defined(__sparc__)
- #define NEED_SPARC_TAS_ASM
- #endif
-
- #define HAS_TEST_AND_SET
-
- typedef unsigned char slock_t;
--- 0 ----
Index: src/include/port/cygwin.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/cygwin.h,v
retrieving revision 1.4
diff -c -c -r1.4 cygwin.h
*** src/include/port/cygwin.h    4 Aug 2003 00:43:32 -0000    1.4
--- src/include/port/cygwin.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,8 ****
  /* $Header: /cvsroot/pgsql-server/src/include/port/cygwin.h,v 1.4 2003/08/04 00:43:32 momjian Exp $ */

- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
-
  #include <cygwin/version.h>

  /*
--- 1,5 ----
***************
*** 20,24 ****
  #define DLLIMPORT __declspec (dllexport)
  #else
  #define DLLIMPORT __declspec (dllimport)
-
  #endif
--- 17,20 ----
Index: src/include/port/darwin.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/darwin.h,v
retrieving revision 1.5
diff -c -c -r1.5 darwin.h
*** src/include/port/darwin.h    28 Oct 2001 06:26:08 -0000    1.5
--- src/include/port/darwin.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,13 ****
  #define __darwin__    1
-
- #if defined(__ppc__)
- #define HAS_TEST_AND_SET
- #endif
-
- #if defined(__ppc__)
- typedef unsigned int slock_t;
-
- #else
- typedef unsigned char slock_t;
-
- #endif
--- 1 ----
Index: src/include/port/dgux.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/dgux.h,v
retrieving revision 1.9
diff -c -c -r1.9 dgux.h
*** src/include/port/dgux.h    28 Oct 2001 06:26:08 -0000    1.9
--- src/include/port/dgux.h    12 Sep 2003 04:38:27 -0000
***************
*** 9,13 ****
  #endif
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        BIG_ENDIAN
-
  #endif
--- 9,12 ----
Index: src/include/port/freebsd.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/freebsd.h,v
retrieving revision 1.10
diff -c -c -r1.10 freebsd.h
*** src/include/port/freebsd.h    4 Aug 2003 00:43:32 -0000    1.10
--- src/include/port/freebsd.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,48 ****
- #if defined(__i386__)
- #define NEED_I386_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__sparc__)
- #define NEED_SPARC_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__vax__)
- #define NEED_VAX_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__ns32k__)
- #define NEED_NS32K_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__m68k__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__arm__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__mips__)
- /* #    undef HAS_TEST_AND_SET */
- #endif
-
- #if defined(__alpha__)
- #define HAS_TEST_AND_SET
- typedef unsigned long slock_t;
- #endif
-
- #if defined(__powerpc__)
- #define HAS_TEST_AND_SET
- typedef unsigned int slock_t;
-
- #endif
--- 0 ----
Index: src/include/port/hpux.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/hpux.h,v
retrieving revision 1.19
diff -c -c -r1.19 hpux.h
*** src/include/port/hpux.h    4 Aug 2003 00:43:32 -0000    1.19
--- src/include/port/hpux.h    12 Sep 2003 04:38:27 -0000
***************
*** 10,35 ****

  #if defined(__hppa)

- #define HAS_TEST_AND_SET
- typedef struct
- {
-     int            sema[4];
- } slock_t;
-
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        BIG_ENDIAN
  #endif

  #elif defined(__ia64)

- #define HAS_TEST_AND_SET
- typedef unsigned int slock_t;
-
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        LITTLE_ENDIAN
  #endif

  #else
  #error unrecognized CPU type for HP-UX

  #endif
--- 10,27 ----

  #if defined(__hppa)

  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        BIG_ENDIAN
  #endif

  #elif defined(__ia64)

  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        LITTLE_ENDIAN
  #endif

  #else
+
  #error unrecognized CPU type for HP-UX

  #endif
Index: src/include/port/irix5.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/irix5.h,v
retrieving revision 1.8
diff -c -c -r1.8 irix5.h
*** src/include/port/irix5.h    12 Nov 2002 00:39:08 -0000    1.8
--- src/include/port/irix5.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,3 ****
- #define HAS_TEST_AND_SET
-
- typedef unsigned long slock_t;
--- 0 ----
Index: src/include/port/linux.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/linux.h,v
retrieving revision 1.33
diff -c -c -r1.33 linux.h
*** src/include/port/linux.h    10 Nov 2002 00:33:43 -0000    1.33
--- src/include/port/linux.h    12 Sep 2003 04:38:27 -0000
***************
*** 2,52 ****
  #ifndef _GNU_SOURCE
  #define _GNU_SOURCE 1
  #endif
-
-
- #if defined(__i386__)
- typedef unsigned char slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__sparc__)
- typedef unsigned char slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__powerpc64__)
- typedef unsigned long slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__powerpc__)
- typedef unsigned int slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__alpha__)
- typedef long int slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__mips__)
- typedef unsigned int slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__arm__)
- typedef unsigned char slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__ia64__)
- typedef unsigned int slock_t;
-
- #define HAS_TEST_AND_SET
-
- #elif defined(__s390__) || defined(__s390x__)
- typedef unsigned int slock_t;
-
- #define HAS_TEST_AND_SET
-
- #endif
--- 2,4 ----
Index: src/include/port/netbsd.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/netbsd.h,v
retrieving revision 1.9
diff -c -c -r1.9 netbsd.h
*** src/include/port/netbsd.h    4 Aug 2003 00:43:32 -0000    1.9
--- src/include/port/netbsd.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,48 ****
- #if defined(__i386__)
- #define NEED_I386_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__sparc__)
- #define NEED_SPARC_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__vax__)
- #define NEED_VAX_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__ns32k__)
- #define NEED_NS32K_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__m68k__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__arm__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__mips__)
- /* #    undef HAS_TEST_AND_SET */
- #endif
-
- #if defined(__alpha__)
- #define HAS_TEST_AND_SET
- typedef unsigned long slock_t;
- #endif
-
- #if defined(__powerpc__)
- #define HAS_TEST_AND_SET
- typedef unsigned int slock_t;
-
- #endif
--- 0 ----
Index: src/include/port/nextstep.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/nextstep.h,v
retrieving revision 1.6
diff -c -c -r1.6 nextstep.h
*** src/include/port/nextstep.h    28 Oct 2000 23:53:00 -0000    1.6
--- src/include/port/nextstep.h    12 Sep 2003 04:38:27 -0000
***************
*** 15,18 ****
  #endif

  #define NO_WAITPID
- typedef struct mutex slock_t;
--- 15,17 ----
Index: src/include/port/openbsd.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/openbsd.h,v
retrieving revision 1.8
diff -c -c -r1.8 openbsd.h
*** src/include/port/openbsd.h    4 Aug 2003 00:43:32 -0000    1.8
--- src/include/port/openbsd.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,48 ****
- #if defined(__i386__)
- #define NEED_I386_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__sparc__)
- #define NEED_SPARC_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__vax__)
- #define NEED_VAX_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__ns32k__)
- #define NEED_NS32K_TAS_ASM
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__m68k__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__arm__)
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
- #endif
-
- #if defined(__mips__)
- /* #    undef HAS_TEST_AND_SET */
- #endif
-
- #if defined(__alpha__)
- #define HAS_TEST_AND_SET
- typedef unsigned long slock_t;
- #endif
-
- #if defined(__powerpc__)
- #define HAS_TEST_AND_SET
- typedef unsigned int slock_t;
-
- #endif
--- 0 ----
Index: src/include/port/osf.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/osf.h,v
retrieving revision 1.7
diff -c -c -r1.7 osf.h
*** src/include/port/osf.h    28 Oct 2001 06:26:08 -0000    1.7
--- src/include/port/osf.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,7 ****
  #define NOFIXADE
  #define DISABLE_XOPEN_NLS
! #define HAS_TEST_AND_SET
!  /* #include <sys/mman.h> */    /* for msemaphore */
  /*typedef msemaphore slock_t;*/
  #include <alpha/builtins.h>
- typedef volatile long slock_t;
--- 1,5 ----
  #define NOFIXADE
  #define DISABLE_XOPEN_NLS
! /* #include <sys/mman.h> */    /* for msemaphore */
  /*typedef msemaphore slock_t;*/
  #include <alpha/builtins.h>
Index: src/include/port/qnx4.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/qnx4.h,v
retrieving revision 1.8
diff -c -c -r1.8 qnx4.h
*** src/include/port/qnx4.h    9 May 2003 16:59:43 -0000    1.8
--- src/include/port/qnx4.h    12 Sep 2003 04:38:27 -0000
***************
*** 5,12 ****
  #include <unix.h>
  #include <sys/select.h>            /* for select */

- #define HAS_TEST_AND_SET
-
  #undef HAVE_GETRUSAGE

  #define strncasecmp strnicmp
--- 5,10 ----
***************
*** 21,28 ****
  #endif   /* NAN */

  typedef u_short ushort;
-
- typedef unsigned char slock_t;

  extern int    isnan(double dsrc);

--- 19,24 ----
Index: src/include/port/sco.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/sco.h,v
retrieving revision 1.13
diff -c -c -r1.13 sco.h
*** src/include/port/sco.h    28 Oct 2001 06:26:08 -0000    1.13
--- src/include/port/sco.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,13 ****
  /* see src/backend/libpq/pqcomm.c */
  #define SCO_ACCEPT_BUG

- #define HAS_TEST_AND_SET
- #define NEED_I386_TAS_ASM
-
  #define USE_UNIVEL_CC

- typedef unsigned char slock_t;
-
  #ifndef            BIG_ENDIAN
  #define            BIG_ENDIAN        4321
  #endif
--- 1,8 ----
***************
*** 19,23 ****
  #endif
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        LITTLE_ENDIAN
-
  #endif
--- 14,17 ----
Index: src/include/port/solaris.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/solaris.h,v
retrieving revision 1.8
diff -c -c -r1.8 solaris.h
*** src/include/port/solaris.h    10 Mar 2003 22:28:21 -0000    1.8
--- src/include/port/solaris.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,8 ****
  /* $Header: /cvsroot/pgsql-server/src/include/port/solaris.h,v 1.8 2003/03/10 22:28:21 tgl Exp $ */

- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
-
  /*
   * Sort this out for all operating systems some time.  The __xxx
   * symbols are defined on both GCC and Solaris CC, although GCC
--- 1,5 ----
Index: src/include/port/sunos4.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/sunos4.h,v
retrieving revision 1.7
diff -c -c -r1.7 sunos4.h
*** src/include/port/sunos4.h    28 Oct 2001 06:26:08 -0000    1.7
--- src/include/port/sunos4.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,6 ****
- #define HAS_TEST_AND_SET
- typedef unsigned char slock_t;
-
  /* sprintf() returns char *, not int, on SunOS 4.1.x */
  #define SPRINTF_CHAR

--- 1,3 ----
***************
*** 15,19 ****
  #endif
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        BIG_ENDIAN
-
  #endif
--- 12,15 ----
Index: src/include/port/svr4.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/svr4.h,v
retrieving revision 1.11
diff -c -c -r1.11 svr4.h
*** src/include/port/svr4.h    28 Oct 2001 06:26:08 -0000    1.11
--- src/include/port/svr4.h    12 Sep 2003 04:38:27 -0000
***************
*** 3,13 ****
  #define            BYTE_ORDER        BIG_ENDIAN
  #endif
  #endif
-
- #ifdef sinix
- #define HAS_TEST_AND_SET
-
- #include "abi_mutex.h"
- typedef abilock_t slock_t;
-
- #endif
--- 3,5 ----
Index: src/include/port/univel.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/univel.h,v
retrieving revision 1.17
diff -c -c -r1.17 univel.h
*** src/include/port/univel.h    28 Oct 2001 06:26:08 -0000    1.17
--- src/include/port/univel.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,14 ****
- #define HAS_TEST_AND_SET
- #define NEED_I386_TAS_ASM
-
  /***************************************
   * Define this if you are compiling with
   * the native UNIXWARE C compiler.
   ***************************************/
  #define USE_UNIVEL_CC

- typedef unsigned char slock_t;
-
  #ifndef            BIG_ENDIAN
  #define            BIG_ENDIAN        4321
  #endif
--- 1,9 ----
***************
*** 20,24 ****
  #endif
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        LITTLE_ENDIAN
-
  #endif
--- 15,18 ----
Index: src/include/port/unixware.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/unixware.h,v
retrieving revision 1.11
diff -c -c -r1.11 unixware.h
*** src/include/port/unixware.h    28 Oct 2001 06:26:08 -0000    1.11
--- src/include/port/unixware.h    12 Sep 2003 04:38:27 -0000
***************
*** 1,6 ****
- #define HAS_TEST_AND_SET
- #define NEED_I386_TAS_ASM
-
  /* see src/backend/libpq/pqcomm.c */
  #define SCO_ACCEPT_BUG

--- 1,3 ----
***************
*** 10,17 ****
   ***************************************/
  #define USE_UNIVEL_CC

- typedef unsigned char slock_t;
-
  #ifndef            BIG_ENDIAN
  #define            BIG_ENDIAN        4321
  #endif
--- 7,12 ----
***************
*** 23,27 ****
  #endif
  #ifndef            BYTE_ORDER
  #define            BYTE_ORDER        LITTLE_ENDIAN
-
  #endif
--- 18,21 ----
Index: src/include/storage/s_lock.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/storage/s_lock.h,v
retrieving revision 1.112
diff -c -c -r1.112 s_lock.h
*** src/include/storage/s_lock.h    4 Aug 2003 02:40:15 -0000    1.112
--- src/include/storage/s_lock.h    12 Sep 2003 04:38:28 -0000
***************
*** 73,84 ****
  #include "storage/pg_sema.h"


- #if defined(HAS_TEST_AND_SET)
-
-
  #if defined(__GNUC__) || defined(__ICC)
! /*************************************************************************
   * All the gcc inlines
   */

  /*
--- 73,85 ----
  #include "storage/pg_sema.h"


  #if defined(__GNUC__) || defined(__ICC)
! /*
!  * ---------------------------------------------------------------------
   * All the gcc inlines
+  *
+  * Gcc consistently defines the CPU as __cpu__.
+  * Other compilers use __cpu or __cpu__ so we test for both.
   */

  /*
***************
*** 95,101 ****
--- 96,105 ----


  #if defined(__i386__) || defined(__x86_64__) /* AMD Opteron */
+
+ #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 114,122 ****


  /* Intel Itanium */
! #if defined(__ia64__) || defined(__ia64)
! #define TAS(lock) tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
  {
--- 118,129 ----


  /* Intel Itanium */
! #if defined(__ia64__)

+ #define HAS_TEST_AND_SET
+ #define TAS(lock) tas(lock)
+ typedef unsigned int slock_t;
+
  static __inline__ int
  tas(volatile slock_t *lock)
  {
***************
*** 131,141 ****
      return (int) ret;
  }

! #endif     /* __ia64__ || __ia64 */


! #if defined(__arm__) || defined(__arm__)
  #define TAS(lock) tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
--- 138,151 ----
      return (int) ret;
  }

! #endif     /* __ia64__ */
!

+ #if defined(__arm__)

! #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 156,162 ****
  /*
   * S/390 Linux
   */
! #define TAS(lock)       tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
--- 166,175 ----
  /*
   * S/390 Linux
   */
!
! #define HAS_TEST_AND_SET
! #define TAS(lock) tas(lock)
! typedef unsigned int slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 182,188 ****
  /*
   * S/390x Linux (64-bit zSeries)
   */
! #define TAS(lock)       tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
--- 195,204 ----
  /*
   * S/390x Linux (64-bit zSeries)
   */
!
! #define HAS_TEST_AND_SET
! #define TAS(lock) tas(lock)
! typedef unsigned int slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 206,212 ****
--- 222,231 ----


  #if defined(__sparc__)
+
+ #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 223,229 ****
--- 242,252 ----
  #endif     /* __sparc__ */

  #if defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
+
+ #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned int slock_t;
+
  /*
   * NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
   * an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
***************
*** 259,265 ****
--- 282,291 ----


  #if defined(__mc68000__) && defined(__linux__)
+
+ #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 281,286 ****
--- 307,316 ----


  #if defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
+
+ #define HAS_TEST_AND_SET
+ typedef unsigned int slock_t;
+
  /*
   * PowerPC S_UNLOCK is almost standard but requires a "sync" instruction.
   */
***************
*** 294,305 ****
  #endif /* powerpc */


! #if defined(NEED_VAX_TAS_ASM)
  /*
   * VAXen -- even multiprocessor ones
   * (thanks to Tom Ivar Helbekkmo)
   */
  #define TAS(lock) tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
--- 324,338 ----
  #endif /* powerpc */


! #if defined(__vax__)
  /*
   * VAXen -- even multiprocessor ones
   * (thanks to Tom Ivar Helbekkmo)
   */
+
+ #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 317,327 ****
      return _res;
  }

! #endif     /* NEED_VAX_TAS_ASM */


! #if defined(NEED_NS32K_TAS_ASM)
  #define TAS(lock) tas(lock)

  static __inline__ int
  tas(volatile slock_t *lock)
--- 350,363 ----
      return _res;
  }

! #endif     /* __vax__ */


! #if defined (__ns32k__)
!
! #define HAS_TEST_AND_SET
  #define TAS(lock) tas(lock)
+ typedef unsigned char slock_t;

  static __inline__ int
  tas(volatile slock_t *lock)
***************
*** 335,352 ****
      return _res;
  }

! #endif     /* NEED_NS32K_TAS_ASM */



  #else                            /* !__GNUC__ */

! /***************************************************************************
   * All non-gcc inlines
   */

! #if defined(NEED_I386_TAS_ASM) && defined(USE_UNIVEL_CC)
! #define TAS(lock)    tas(lock)

  asm int
  tas(volatile slock_t *s_lock)
--- 371,405 ----
      return _res;
  }

! #endif     /* __ns32k__ */
!
!
! /* These live in s_lock.c */
!
! #if defined(__m68k__)
! #define HAS_TEST_AND_SET
! typedef unsigned char slock_t;
! #endif
!
! #if defined(__mips__) && (!defined(__sgi__) && !defined(__sgi))
! #define HAS_TEST_AND_SET
! typedef unsigned char slock_t;
! #endif



  #else                            /* !__GNUC__ */

! /*
!  * ---------------------------------------------------------------------
   * All non-gcc inlines
   */

! #if defined(i386) && defined(USE_UNIVEL_CC)  /* SCO cc only defines 'i386' */
!
! #define HAS_TEST_AND_SET
! #define TAS(lock) tas(lock)
! typedef unsigned char slock_t;

  asm int
  tas(volatile slock_t *s_lock)
***************
*** 361,380 ****
      popl %ebx
  }

! #endif     /* defined(NEED_I386_TAS_ASM) && defined(USE_UNIVEL_CC) */

  #endif     /* defined(__GNUC__) */



! /*************************************************************************
   * These are the platforms that have only one compiler, or do not use inline
   * assembler (and hence have common code for gcc and non-gcc compilers,
   * if both are available).
   */


! #if defined(__alpha)

  /*
   * Correct multi-processor locking methods are explained in section 5.5.3
--- 414,452 ----
      popl %ebx
  }

! #endif     /* i386 && defined(USE_UNIVEL_CC) */
!
!
! /* These live in s_lock.c */
!
! #if defined(sun3)
! #define HAS_TEST_AND_SET
! typedef unsigned char slock_t;
! #endif
!
! #if defined(__sparc__) || defined(__sparc)
! #define HAS_TEST_AND_SET
! typedef unsigned char slock_t;
! #endif
!
!

  #endif     /* defined(__GNUC__) */



! /*
!  * -------------------------------------------------------------------------
   * These are the platforms that have only one compiler, or do not use inline
   * assembler (and hence have common code for gcc and non-gcc compilers,
   * if both are available).
   */


! #if defined(__alpha__) || defined(__alpha)
!
! #define HAS_TEST_AND_SET
! typedef unsigned long slock_t;

  /*
   * Correct multi-processor locking methods are explained in section 5.5.3
***************
*** 384,390 ****
   */
  #if defined(__GNUC__)

! #define TAS(lock)  tas(lock)
  #define S_UNLOCK(lock)    \
  do \
  {\
--- 456,462 ----
   */
  #if defined(__GNUC__)

! #define TAS(lock) tas(lock)
  #define S_UNLOCK(lock)    \
  do \
  {\
***************
*** 435,444 ****

  #endif     /* defined(__GNUC__) */

! #endif     /* __alpha */


! #if defined(__hppa)
  /*
   * HP's PA-RISC
   *
--- 507,516 ----

  #endif     /* defined(__GNUC__) */

! #endif     /* __alpha__ */


! #if defined(__hppa__) || defined(__hppa)
  /*
   * HP's PA-RISC
   *
***************
*** 449,454 ****
--- 521,531 ----
   * all words set to non-zero. tas() is in tas.s
   */

+ #define HAS_TEST_AND_SET
+ typedef struct
+ {
+     int            sema[4];
+ } slock_t;
  #define S_UNLOCK(lock) \
      do { \
          volatile slock_t *lock_ = (volatile slock_t *) (lock); \
***************
*** 466,471 ****
--- 543,551 ----
  /*
   * QNX 4 using WATCOM C
   */
+
+ #define HAS_TEST_AND_SET
+ typedef unsigned char slock_t;
  #define TAS(lock) wc_tas(lock)
  extern slock_t wc_tas(volatile slock_t *lock);
  #pragma aux wc_tas =\
***************
*** 477,483 ****
  #endif     /* __QNX__ and __WATCOMC__*/


! #if defined(__sgi)
  /*
   * SGI IRIX 5
   * slock_t is defined as a unsigned long. We use the standard SGI
--- 557,563 ----
  #endif     /* __QNX__ and __WATCOMC__*/


! #if defined(__sgi__) || defined(__sgi)
  /*
   * SGI IRIX 5
   * slock_t is defined as a unsigned long. We use the standard SGI
***************
*** 490,495 ****
--- 570,579 ----
   * assembly from his NECEWS SVR4 port, but we probably ought to retain this
   * for the R3000 chips out there.
   */
+
+ #define HAS_TEST_AND_SET
+ typedef unsigned long slock_t;
+
  #include "mutex.h"
  #define TAS(lock)    (test_and_set(lock,1))
  #define S_UNLOCK(lock)    (test_then_and(lock,0))
***************
*** 504,509 ****
--- 588,598 ----
   * member. (Basically same as SGI)
   *
   */
+
+ #define HAS_TEST_AND_SET
+ #include "abi_mutex.h"
+ typedef abilock_t slock_t;
+
  #define TAS(lock)    (!acquire_lock(lock))
  #define S_UNLOCK(lock)    release_lock(lock)
  #define S_INIT_LOCK(lock)    init_lock(lock)
***************
*** 511,522 ****
  #endif     /* sinix */


! #if defined(_AIX)
  /*
   * AIX (POWER)
   *
   * Note that slock_t on POWER/POWER2/PowerPC is int instead of char
   */
  #define TAS(lock)            _check_lock(lock, 0, 1)
  #define S_UNLOCK(lock)        _clear_lock(lock, 0)
  #endif     /* _AIX */
--- 600,615 ----
  #endif     /* sinix */


! #if defined(_AIX) || defined(__AIX__) || defined(__AIX)
  /*
   * AIX (POWER)
   *
   * Note that slock_t on POWER/POWER2/PowerPC is int instead of char
   */
+
+ #define HAS_TEST_AND_SET
+ typedef unsigned int slock_t;
+
  #define TAS(lock)            _check_lock(lock, 0, 1)
  #define S_UNLOCK(lock)        _clear_lock(lock, 0)
  #endif     /* _AIX */
***************
*** 528,533 ****
--- 621,629 ----
   * slock_t is defined as a struct mutex.
   */

+ #define HAS_TEST_AND_SET
+ typedef struct mutex slock_t;
+
  #define S_LOCK(lock)    mutex_lock(lock)
  #define S_UNLOCK(lock)    mutex_unlock(lock)
  #define S_INIT_LOCK(lock)    mutex_init(lock)
***************
*** 537,543 ****



! #else                            /* !HAS_TEST_AND_SET */

  /*
   * Fake spinlock implementation using semaphores --- slow and prone
--- 633,643 ----



! #ifndef HAS_TEST_AND_SET
!
! #ifdef HAVE_SPINLOCKS
! #error This platform does not support native spinlocks.  To continue the compile, rerun configure using
--without-spinlocks. However, performance will be poor.  Please report this to pgsql-bugs@postgresql.org. 
! #endif

  /*
   * Fake spinlock implementation using semaphores --- slow and prone
***************
*** 556,562 ****
  #define S_INIT_LOCK(lock)    s_init_lock_sema(lock)
  #define TAS(lock)    tas_sema(lock)

! #endif     /* HAS_TEST_AND_SET */



--- 656,662 ----
  #define S_INIT_LOCK(lock)    s_init_lock_sema(lock)
  #define TAS(lock)    tas_sema(lock)

! #endif




Re: [HACKERS] Reorganization of spinlock defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Larry Rosenman <ler@lerctr.org> writes:
> > Bruce sent me a copy of the patch, and it ****BREAKS**** UnixWare (If y'all=
> > =20
> > care).
>
> Unfixably?  Or just a small oversight?

Updated patch now works on Unixware.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Reorganization of spinlock defines

From
Bruce Momjian
Date:
Bruce Momjian wrote:
> Prompted by confusion over Itanium/Opterion, I have written a patch to
> improve the way we define spinlocks for platforms and cpu's.  It
> basically decouples the OS from the CPU spinlock code.  In almost all
> cases, the spinlock code cares only about the compiler and CPU, not the
> OS.
>
> The patch:
>
>     o defines HAS_TEST_AND_SET inside each spinlock routine, not in
>       platform-specific files
>     o moves slock_t defines into the spinlock routines
>     o remove NEED_{CPU}_TAS_ASM define because it is no longer needed
>     o reports a compile error if spinlocks are not defined
>     o adds a configure option --without-spinlocks to allow
>       non-spinlock compiles

OK, this applied patch implements the last two items.  The earlier items
will have to wait for 7.5.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: configure
===================================================================
RCS file: /cvsroot/pgsql-server/configure,v
retrieving revision 1.295
diff -c -c -r1.295 configure
*** configure    7 Sep 2003 16:49:41 -0000    1.295
--- configure    12 Sep 2003 16:05:13 -0000
***************
*** 869,874 ****
--- 869,875 ----
    --with-rendezvous       build with Rendezvous support
    --with-openssl[=DIR]    build with OpenSSL support [/usr/local/ssl]
    --without-readline      do not use Readline
+   --without-spinlocks     do not use Spinlocks
    --without-zlib          do not use Zlib
    --with-gnu-ld           assume the C compiler uses GNU ld default=no

***************
*** 3494,3499 ****
--- 3495,3530 ----


  #
+ # Spinlocks
+ #
+
+
+
+ # Check whether --with-spinlocks or --without-spinlocks was given.
+ if test "${with_spinlocks+set}" = set; then
+   withval="$with_spinlocks"
+
+   case $withval in
+     yes)
+       :
+       ;;
+     no)
+       :
+       ;;
+     *)
+       { { echo "$as_me:$LINENO: error: no argument expected for --with-spinlocks option" >&5
+ echo "$as_me: error: no argument expected for --with-spinlocks option" >&2;}
+    { (exit 1); exit 1; }; }
+       ;;
+   esac
+
+ else
+   with_spinlocks=yes
+
+ fi;
+
+
+ #
  # Zlib
  #

***************
*** 3523,3529 ****
  fi;


-
  #
  # Elf
  #
--- 3554,3559 ----
***************
*** 6060,6065 ****
--- 6090,6108 ----
     { (exit 1); exit 1; }; }
  fi

+ fi
+
+ if test "$with_spinlocks" = yes; then
+
+ cat >>confdefs.h <<\_ACEOF
+ #define HAVE_SPINLOCKS 1
+ _ACEOF
+
+ else
+   { echo "$as_me:$LINENO: WARNING:
+ *** Not using spinlocks will cause poor performance." >&5
+ echo "$as_me: WARNING:
+ *** Not using spinlocks will cause poor performance." >&2;}
  fi

  if test "$with_krb4" = yes ; then
Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql-server/configure.in,v
retrieving revision 1.286
diff -c -c -r1.286 configure.in
*** configure.in    7 Sep 2003 16:38:05 -0000    1.286
--- configure.in    12 Sep 2003 16:05:15 -0000
***************
*** 522,533 ****
                [  --without-readline      do not use Readline])

  #
  # Zlib
  #
  PGAC_ARG_BOOL(with, zlib, yes,
                [  --without-zlib          do not use Zlib])

-
  #
  # Elf
  #
--- 522,538 ----
                [  --without-readline      do not use Readline])

  #
+ # Spinlocks
+ #
+ PGAC_ARG_BOOL(with, spinlocks, yes,
+               [  --without-spinlocks     do not use Spinlocks])
+
+ #
  # Zlib
  #
  PGAC_ARG_BOOL(with, zlib, yes,
                [  --without-zlib          do not use Zlib])

  #
  # Elf
  #
***************
*** 676,681 ****
--- 681,693 ----
  If you have zlib already installed, see config.log for details on the
  failure.  It is possible the compiler isn't looking in the proper directory.
  Use --without-zlib to disable zlib support.])])
+ fi
+
+ if test "$with_spinlocks" = yes; then
+   AC_DEFINE(HAVE_SPINLOCKS, 1, [Define to 1 if you have spinlocks.])
+ else
+   AC_MSG_WARN([
+ *** Not using spinlocks will cause poor performance.])
  fi

  if test "$with_krb4" = yes ; then
Index: doc/src/sgml/installation.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/installation.sgml,v
retrieving revision 1.141
diff -c -c -r1.141 installation.sgml
*** doc/src/sgml/installation.sgml    11 Sep 2003 21:42:20 -0000    1.141
--- doc/src/sgml/installation.sgml    12 Sep 2003 16:05:17 -0000
***************
*** 900,905 ****
--- 900,917 ----
        </varlistentry>

        <varlistentry>
+        <term><option>--without-spinlocks</option></term>
+        <listitem>
+         <para>
+          Allows source builds to succeed without CPU spinlock support.
+          Lack of spinlock support will produce poor performance.
+          This option is to be used only by platforms without
+          spinlock support.
+         </para>
+        </listitem>
+       </varlistentry>
+
+       <varlistentry>
         <term><option>--enable-thread-safety</option></term>
         <listitem>
          <para>
Index: src/include/pg_config.h.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v
retrieving revision 1.62
diff -c -c -r1.62 pg_config.h.in
*** src/include/pg_config.h.in    7 Sep 2003 03:43:56 -0000    1.62
--- src/include/pg_config.h.in    12 Sep 2003 16:05:19 -0000
***************
*** 357,362 ****
--- 357,365 ----
  /* Define to 1 if you have the `snprintf' function. */
  #undef HAVE_SNPRINTF

+ /* Define to 1 if you have spinlocks. */
+ #undef HAVE_SPINLOCKS
+
  /* Define to 1 if you have the `srandom' function. */
  #undef HAVE_SRANDOM

Index: src/include/storage/s_lock.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/storage/s_lock.h,v
retrieving revision 1.112
diff -c -c -r1.112 s_lock.h
*** src/include/storage/s_lock.h    4 Aug 2003 02:40:15 -0000    1.112
--- src/include/storage/s_lock.h    12 Sep 2003 16:05:20 -0000
***************
*** 537,543 ****



! #else                            /* !HAS_TEST_AND_SET */

  /*
   * Fake spinlock implementation using semaphores --- slow and prone
--- 537,547 ----



! #else     /* HAS_TEST_AND_SET */
!
! #ifdef HAVE_SPINLOCKS
! #error This platform does not support native spinlocks.  To continue the compile, rerun configure using
--without-spinlocks. However, performance will be poor.  Please report this to pgsql-bugs@postgresql.org. 
! #endif

  /*
   * Fake spinlock implementation using semaphores --- slow and prone

Re: Reorganization of spinlock defines

From
Peter Eisentraut
Date:
Bruce Momjian writes:

>     o adds a configure option --without-spinlocks to allow
>       non-spinlock compiles

--disable-spinlocks please.

--
Peter Eisentraut   peter_e@gmx.net


Re: Reorganization of spinlock defines

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Bruce Momjian writes:
>
> >     o adds a configure option --without-spinlocks to allow
> >       non-spinlock compiles
>
> --disable-spinlocks please.

I can make the change, but --without seemed to more closely match
because it was like readline where you didn't have it, and had to say so
specifically.  I don't see how we can say --disable because this is case
were we clearly don't have spinlocks to enable, no?

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Reorganization of spinlock defines

From
Peter Eisentraut
Date:
Bruce Momjian writes:

> I can make the change, but --without seemed to more closely match
> because it was like readline where you didn't have it, and had to say so
> specifically.  I don't see how we can say --disable because this is case
> were we clearly don't have spinlocks to enable, no?

./configure --help | grep --relevant-stuff

Optional Features:
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)

Readline is a package, spinlocks are a feature.

--
Peter Eisentraut   peter_e@gmx.net


Re: Reorganization of spinlock defines

From
Bruce Momjian
Date:
OK.  You'da boss.  :-)

---------------------------------------------------------------------------

Peter Eisentraut wrote:
> Bruce Momjian writes:
>
> > I can make the change, but --without seemed to more closely match
> > because it was like readline where you didn't have it, and had to say so
> > specifically.  I don't see how we can say --disable because this is case
> > were we clearly don't have spinlocks to enable, no?
>
> ./configure --help | grep --relevant-stuff
>
> Optional Features:
>   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
>   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
>
> Optional Packages:
>   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
>   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
>
> Readline is a package, spinlocks are a feature.
>
> --
> Peter Eisentraut   peter_e@gmx.net
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Reorganization of spinlock defines

From
Bruce Momjian
Date:
Done.

---------------------------------------------------------------------------

Peter Eisentraut wrote:
> Bruce Momjian writes:
>
> > I can make the change, but --without seemed to more closely match
> > because it was like readline where you didn't have it, and had to say so
> > specifically.  I don't see how we can say --disable because this is case
> > were we clearly don't have spinlocks to enable, no?
>
> ./configure --help | grep --relevant-stuff
>
> Optional Features:
>   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
>   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
>
> Optional Packages:
>   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
>   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
>
> Readline is a package, spinlocks are a feature.
>
> --
> Peter Eisentraut   peter_e@gmx.net
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073