From: Bruce Momjian Date: Fri, 12 Sep 2003 16:10:27 +0000 (+0000) Subject: Implement compiler #error if spinlock code not found, add configure flag X-Git-Tag: REL7_4_BETA3~36 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06e3ec7a542ede97986cbab8066b1293b1cd2751;p=postgresql Implement compiler #error if spinlock code not found, add configure flag to bypass the error, --without-spinlocks. --- diff --git a/configure b/configure index 9d729d91cc..02c38e4c50 100755 --- a/configure +++ b/configure @@ -869,6 +869,7 @@ Optional Packages: --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 @@ -3493,6 +3494,36 @@ else fi; +# +# 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,7 +3554,6 @@ else fi; - # # Elf # @@ -6062,6 +6092,19 @@ 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 echo "$as_me:$LINENO: checking for des_encrypt in -ldes" >&5 diff --git a/configure.in b/configure.in index 58db85abd0..62c14eeb28 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -dnl $Header: /cvsroot/pgsql/configure.in,v 1.286 2003/09/07 16:38:05 momjian Exp $ +dnl $Header: /cvsroot/pgsql/configure.in,v 1.287 2003/09/12 16:10:26 momjian Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -521,13 +521,18 @@ AC_SUBST(with_openssl) PGAC_ARG_BOOL(with, readline, yes, [ --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 # @@ -678,6 +683,13 @@ 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 AC_CHECK_LIB(des, des_encrypt, [], [AC_MSG_ERROR([library 'des' is required for Kerberos 4])]) AC_CHECK_LIB(krb, krb_sendauth, [], [AC_MSG_ERROR([library 'krb' is required for Kerberos 4])]) diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml index 02a77afcb6..4a298251b7 100644 --- a/doc/src/sgml/installation.sgml +++ b/doc/src/sgml/installation.sgml @@ -1,4 +1,4 @@ - + <![%standalone-include[<productname>PostgreSQL</>]]> @@ -899,6 +899,18 @@ JAVACMD=$JAVA_HOME/bin/java </listitem> </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> diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 03874772cd..8c04b8e6b4 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -357,6 +357,9 @@ /* 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 diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 8279518043..4d49c52c71 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -63,7 +63,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: s_lock.h,v 1.112 2003/08/04 02:40:15 momjian Exp $ + * $Id: s_lock.h,v 1.113 2003/09/12 16:10:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -537,7 +537,11 @@ extern slock_t wc_tas(volatile slock_t *lock); -#else /* !HAS_TEST_AND_SET */ +#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