From cef41b3286ff12039be5d2f62db368ad9e59ec2b Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Tue, 5 May 2009 08:06:37 +0000 Subject: [PATCH] 1. Solaric/Sparc SunProCC port. 2. Cleanup SOLARIS_MT threading model. --- builds/posix/make.platform.solaris.examples | 2 +- builds/posix/prefix.solaris | 114 ++++++--- builds/posix/prefix.solaris-64SCC | 2 +- builds/posix/prefix.solaris-64gcc | 2 +- builds/posix/prefix.solx86 | 2 +- builds/posix/prefix.solx86gcc_64 | 2 +- configure.in | 66 ++--- extern/icu/source/config/mh-solaris | 35 ++- src/common/classes/alloc.h | 2 +- src/common/classes/condition.h | 5 - src/common/classes/fb_tls.h | 52 ---- src/common/classes/locks.cpp | 4 - src/common/classes/locks.h | 60 ----- src/common/classes/rwlock.h | 81 ------ src/common/thd.cpp | 13 - src/gpre/gpre.h | 2 +- src/jrd/SysFunction.cpp | 2 +- src/jrd/ThreadData.h | 4 - src/jrd/ThreadStart.cpp | 53 ---- src/jrd/ThreadStart.h | 3 - src/jrd/common.h | 6 - src/jrd/exe.cpp | 2 +- src/jrd/isc.h | 17 +- src/jrd/isc_sync.cpp | 265 -------------------- src/jrd/why.cpp | 9 +- src/utilities/guard/util.cpp | 6 +- src/utilities/ibmgr/srvrmgr.cpp | 10 +- 27 files changed, 155 insertions(+), 666 deletions(-) diff --git a/builds/posix/make.platform.solaris.examples b/builds/posix/make.platform.solaris.examples index 6e9246dae6..dcfbf9fad8 100644 --- a/builds/posix/make.platform.solaris.examples +++ b/builds/posix/make.platform.solaris.examples @@ -20,7 +20,7 @@ # 2 Oct 2002, Nickolay Samofatov - Major Cleanup WARNINGS=-Wall -W -Wno-unused -Wno-parentheses -Wno-switch -Wwrite-strings -COMM_SOLX_FLAGS:=-DSOLARIS -DSOLARIS_MT -DSOLX86 -DBSD_COMP -fno-omit-frame-pointer -fmessage-length=0 -MMD -fPIC +COMM_SOLX_FLAGS:=-DSOLARIS -DBSD_COMP -fno-omit-frame-pointer -fmessage-length=0 -MMD -fPIC SFIO=@SFIO_DIR@ SFIO_LDFLAGS=@SFIO_LDFLAGS@ diff --git a/builds/posix/prefix.solaris b/builds/posix/prefix.solaris index d144734d2b..79bf49b04c 100644 --- a/builds/posix/prefix.solaris +++ b/builds/posix/prefix.solaris @@ -1,54 +1,108 @@ # -# Compiler settings for Solaris (Sparc) -# -# This file is processed by configure and the output written to -# gen/make.platform which is included in src directory makefiles -# before other common make files ie: make.[rules|defaults|shared.variables] -# +# Compiler settings for Solaris with Sun Studio 12, CC +# Works for all hosts that SS Pro supports (e.g. sparc, amd64, i386) +# Works for 32/64 bit builds, depends on CFLAGS/CXXFLAGS +# Before attempting the Solaris build, you must export necessary +# CFLAGS and CXXFLAGS to be picked up by the configure process and +# subsequent build. Make sure CC is in the path! +# +# for typical 64-bit build +# export CC=cc +# export CXX=CC +# export CFLAGS="-m64" +# export CXXFLAGS=$CFLAGS + +# History # 30-Dec-2002 nmcc FB2 initial working build on Solaris8 with gcc 3.2.1 -# 18-apr-2005 kkuznetsov FB2 Solaris 32 bits update (only gcc) as Ray Holme story talks -# Firebird defines specific to Solaris (and x86) build -CFLAGS_COMMON= -DSOLARIS -DSOLARIS_MT -DBSD_COMP -Dsparc +# 07-Apr-2005 kkuznetsov starting moving to sparc 64 +# 20-Mar-2009 wbo refresh for Sun Studio C++ 5.9, Solaris 9+ -# compile flags for GCC compiler -COMMON_GCC_FLAGS= -MMD -fPIC -m32 +# Useful predefined macros from Sun Studio +# __SUNPRO_CC, indicates the release number of the compiler, e.g. 0x590 -DEBUG_GCC_FLAGS= -ggdb -g3 -Wall -Wno-switch -Wcast-align -PROD_GCC_FLAGS= -mcpu=ultrasparc -mtune=ultrasparc -O2 -DNDEBUG +# These macros are predefined by both Sun Studio and g++ when appropriate. +# No need to define again. +# __amd64 +# __i386 +# __sparc +# __sun +# __unix +# set Instruction Set Architecture, and add any processor specific flags +ISA=$(shell isainfo -k) +ifeq ($(ISA),sparcv9) +# -xcheck=%all, SPARC only, add run time check for stack overflow + ISA_DEV_FLAGS=-xcheck=%all + ISA_COMMON_FLAGS=-xarch=sparcvis2 +endif -# compile flags for SUNWspro/Forte compiler - untested nmcc dec2002 -COMMON_FORTE_FLAGS= -Xt -xstrconst -mt -K PIC -DEBUG_FORTE_FLAGS= -v -g -PROD_FORTE_FLAGS= -O2 -w +ifeq ($(ISA),amd64) + ISA_COMMON_FLAGS=-xarch=sse2 +endif +# Flags shared by production and debug build +# -m32 | -m64, specify memory model. -m64 means LP64, -m32 means ILP32 +# -m64 is default on Intel/AMD architecture, -m32 default on sparc +# -m64 is sufficient to create 64-bit targets on most(?) platforms +# -KPIC, use to compile source files when building a shared library +# -bBinding, specify library binding for linking. Can be symbolic, dynamic, or static +# -features=extensions, allow non-standard C++ commonly accepted by other compilers +# -D_POSIX_C_SOURCE, we are conformant to this posix version +# -D__EXTENSIONS__, access all interfaces and headers not in conflict with posix version +# -D_POSIX_THREAD_SEMANTICS, enable threading extensions +# -erroff=nothrowneww, suppress warning for redefined new with different +# exception specification +# -D_REENTRANT is added by -mt switch, explicit definition not needed +COMMON_FLAGS= -DSOLARIS -DBSD_COMP -DSUNCC -D__EXTENSIONS__ \ + -D_POSIX_THREAD_SEMANTICS -D_POSIX_THREAD_PRIO_INHERIT -D_POSIX_C_SOURCE=199506L -mt -KPIC \ + -erroff=nothrowneww -DUSE_POSIX_THREADS $(ISA_COMMON_FLAGS) + +# if we keep sfio this needs to be set by configure (or move in to extern directory) +# must use full sfio not stdio emulation to get file handle number fix +#SFIO_DIR=$(SRC_ROOT)/../../../sfio/sfio_2002 +#SFIO_DIR=/data01/fb-dev/sfio/sfio_2002 +#SFIO_FLAGS= -DSFIO -I$(SFIO_DIR)/include +#SFIO_LDFLAGS= -L$(SFIO)/lib #these come from configure --with-sfio=/path/to/sfio SFIO_DIR=@SFIO_DIR@ SFIO_FLAGS=@SFIO_FLAGS@ SFIO_LDFLAGS=@SFIO_LDFLAGS@ -PROD_FLAGS= $(CFLAGS_COMMON) $(SFIO_FLAGS) $(COMMON_GCC_FLAGS) $(PROD_GCC_FLAGS) \ - $(LOCAL_CFLAGS) +# Production flags +# -fast, provides near-maximum performance. **includes** -O5, -libmil, and more! +# -fast must come first, and must be present in compile and link! +# -libmil, use the intrinsic library functions like strlen +# -O, optimize, implies -O3 in Sun Studio 12 +PROD_FLAGS= -fast -O -DNDEBUG \ + $(COMMON_FLAGS) $(SFIO_FLAGS) -DEV_FLAGS= $(CFLAGS_COMMON) $(SFIO_FLAGS) $(COMMON_GCC_FLAGS) $(DEBUG_GCC_FLAGS) \ - $(LOCAL_CFLAGS) +# Debug flags +# -xport64, warn about 32-bit to 64-bit funny stuff, like sign extension +# -w, warn about code that may have "unintended consequences." How nice! +DEV_FLAGS= -g -xs \ + $(COMMON_FLAGS) $(SFIO_FLAGS) $(ISA_DEV_FLAGS) - -LOCKPRINT_Other_Sources= jrd/ThreadData.cpp -Server_main_dummy = os/sun/server_main_dummy.cpp OS_ServerFiles=inet_server.cpp +Server_main_dummy= os/sun/server_main_dummy.cpp LIB_LINK_OPTIONS= -G -LIB_PLATFORM_RPATH=-R $(1) -LIB_LINK_SONAME=-h $(1) -LIB_LINK_MAPFILE= -Xlinker -M + +LIB_PLATFORM_RPATH= -R $(1) +LIB_LINK_SONAME= -h $(1) +LIB_LINK_MAPFILE= -M + +# link options for Solaris linker, /usr/ccs/bin/ld +#LINK_OPTS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) +#LIB_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) -shared + EMBED_UTIL_TARGETS=gstat gsec fbguard nbackup fb_lock_print CLIENT_UTIL_TARGETS=gstat gsec fbguard fbmgr_bin nbackup fb_lock_print Physical_IO_Module=os/posix/unix.cpp -LD=g++ -LDFLAGS=-m32 -LINK_OPTS:=$(LDFLAGS) +#LD=CC +LDFLAGS=-library=no%Cstd -mt + +UNDEF_PLATFORM= diff --git a/builds/posix/prefix.solaris-64SCC b/builds/posix/prefix.solaris-64SCC index 549d933c6a..959f9460ab 100644 --- a/builds/posix/prefix.solaris-64SCC +++ b/builds/posix/prefix.solaris-64SCC @@ -14,7 +14,7 @@ # # Firebird defines specific to Solaris (sparc) build -CFLAGS_COMMON= -DSOLARIS -DSOLARIS_MT -DBSD_COMP -Dsparc -DSUNCC +CFLAGS_COMMON= -DSOLARIS -DBSD_COMP -Dsparc -DSUNCC #-DSUNCC - correcting gnuc C++ extentions # compile flags for SUNWspro/Forte/CC/Sun Studio compiler diff --git a/builds/posix/prefix.solaris-64gcc b/builds/posix/prefix.solaris-64gcc index 8599a87d73..7c16a62159 100644 --- a/builds/posix/prefix.solaris-64gcc +++ b/builds/posix/prefix.solaris-64gcc @@ -13,7 +13,7 @@ # # Firebird defines specific to Solaris (and x86) build -CFLAGS_COMMON= -DSOLARIS -DSOLARIS_MT -DBSD_COMP -Dsparc +CFLAGS_COMMON= -DSOLARIS -DBSD_COMP -Dsparc # compile flags for GCC compiler COMMON_GCC_FLAGS= -MMD -fPIC -m64 -D__sparcv9 -mptr64 -mstack-bias -mno-v8plus -mcpu=v9 diff --git a/builds/posix/prefix.solx86 b/builds/posix/prefix.solx86 index d6e6aaeef5..9952f1bb81 100644 --- a/builds/posix/prefix.solx86 +++ b/builds/posix/prefix.solx86 @@ -26,7 +26,7 @@ #FirebirdInstallPrefix = @prefix@ WARNINGS=+w2 -COMM_SOLX_FLAGS:= -DSOLARIS -DSOLARIS26 -DSOLARIS_MT -DSOLX86 -DBSD_COMP -KPIC -features=no%conststrings #,extensions +COMM_SOLX_FLAGS:= -DSOLARIS -DSOLARIS26 -DSOLX86 -DBSD_COMP -KPIC -features=no%conststrings #,extensions #SFIO= /export/home/interbase/SfIO #SfIO is a pretty portable stdIO diff --git a/builds/posix/prefix.solx86gcc_64 b/builds/posix/prefix.solx86gcc_64 index a0fa33a289..681e63a5bb 100644 --- a/builds/posix/prefix.solx86gcc_64 +++ b/builds/posix/prefix.solx86gcc_64 @@ -30,7 +30,7 @@ # LINK_LIBS and STATICLINK_LIBS e.g. -lncurses -leditline WARNINGS=-Wall -Wno-switch -Wno-parentheses -Wno-unused-variable -COMM_SOLX_FLAGS:=-DSOLARIS -DSOLARIS_MT -DBSD_COMP -DAMD64 -pipe -fmessage-length=0 -MMD -fPIC +COMM_SOLX_FLAGS:=-DSOLARIS -DBSD_COMP -DAMD64 -pipe -fmessage-length=0 -MMD -fPIC SFIO=@SFIO_DIR@ SFIO_FLAGS=@SFIO_FLAGS@ diff --git a/configure.in b/configure.in index 91eee8fd5e..81d321c4f4 100644 --- a/configure.in +++ b/configure.in @@ -77,7 +77,7 @@ dnl CPU_TYPE=ppc64 powerpc-*-aix*) dnl ibm xlC has many invocations, like xlC, xlc++, or xlc_r7 - comp=$(echo "$CXX" | cut -c1-3 | dd conv=lcase 2>/dev/null) + comp=`echo "$CXX" | cut -c1-3 | dd conv=lcase 2>/dev/null` if test "$comp" = "xlc"; then MAKEFILE_PREFIX=aix_powerpc_xlc else @@ -242,44 +242,42 @@ dnl ICU_PLATFORM=AIXPPCXLC ;; i386-pc-solaris*) - MAKEFILE_PREFIX=solx86gcc +dnl detect native compiler, Sun Studio Pro + comp=`echo "$CXX" | cut -c1-2` + case $comp in + CC) MAKEFILE_PREFIX=solaris ; + ICU_PLATFORM=SOLARISX86 ;; + *) MAKEFILE_PREFIX=solx86gcc ; + ICU_PLATFORM=SOLARISX86GCC ; + PTHREAD_CFLAGS=-pthreads ;; + esac +dnl if this is amd64 system, we should install our libraries in /usr/lib/amd64 + isa=`isainfo -k` + if test "$isa" = "amd64"; then + libdir=/usr/lib/amd64 + fi INSTALL_PREFIX=solaris PLATFORM=solx86 AC_DEFINE(solx86, 1, [Define this if OS is Solarix x86]) EDITLINE_FLG=Y SHRLIB_EXT=so - PTHREAD_CFLAGS=-threads - PTHREAD_LIBS=-lthread - ICU_PLATFORM=SOLARISX86GCC RT_LIB_CHECK=true ;; - x86_64-pc-solaris*) - MAKEFILE_PREFIX=solx86gcc_64 - INSTALL_PREFIX=solaris - PLATFORM=solx86 - AC_DEFINE(solx86, 1, [Define this if OS is Solarix x86]) - AC_DEFINE(AMD64, 1, [Define this if CPU is amd64]) - EDITLINE_FLG=Y - SHRLIB_EXT=so - PTHREAD_CFLAGS=-threads - PTHREAD_LIBS=-lthread - ICU_PLATFORM=SOLARISX86GCC - service_thread_CS=true - libdir=/usr/lib/amd64 - CPU_TYPE=amd64 - RT_LIB_CHECK=true - ;; sparc-sun-solaris*) - MAKEFILE_PREFIX=solaris +dnl detect native compiler, Sun Studio Pro + comp=`echo "$CXX" | cut -c1-3` + case $comp in + CC) MAKEFILE_PREFIX=solaris ; + ICU_PLATFORM=SOLARISCC ;; + *) MAKEFILE_PREFIX=solaris-64gcc ; + ICU_PLATFORM=SOLARISGCC ;; + esac INSTALL_PREFIX=solaris PLATFORM=SOLARIS AC_DEFINE(SOLARIS, 1, [Define this if OS is Solaris Sparc]) EDITLINE_FLG=Y SHRLIB_EXT=so - PTHREAD_CFLAGS=-threads - PTHREAD_LIBS=-lthread - ICU_PLATFORM=SOLARISGCC RT_LIB_CHECK=true ;; @@ -485,14 +483,7 @@ AC_CHECK_HEADERS(pwd.h) AC_CHECK_HEADERS(libio.h) AC_CHECK_HEADERS(locale.h) AC_CHECK_HEADERS(math.h) -case "$PLATFORM" in - SOLARIS|solx86) - AC_CHECK_HEADERS(thread.h) - ;; - *) - AC_CHECK_HEADERS(pthread.h) - ;; -esac +AC_CHECK_HEADERS(pthread.h) AC_CHECK_HEADERS(sys/types.h) AC_CHECK_HEADERS(sys/stat.h) AC_CHECK_HEADERS(sys/uio.h) @@ -519,7 +510,8 @@ if test "$ac_cv_header_unistd_h" = "yes"; then dnl http://www.opengroup.org/onlinepubs/007904975/basedefs/unistd.h.html dnl http://people.redhat.com/drepper/posix-option-groups.html AC_MSG_CHECKING(if POSIX threads are available) - AC_TRY_RUN([#include + AC_TRY_RUN([#define _XOPEN_SOURCE 600 +#include main () { #if defined(_POSIX_THREADS) && _POSIX_THREADS >= 200112L exit(0); @@ -796,12 +788,8 @@ case "$PLATFORM" in ;; SOLARIS|solx86) - dnl kkuznetsov: Solaris always check for -lnsl and use Sun thread (!not posix) - AC_CHECK_LIB(nsl, gethostname, XE_APPEND(-lnsl,LIBS)) - AC_CHECK_LIB(thread, thr_create, XE_PREPEND(-lthread,LIBS)) - if test "$EDITLINE_FLG" = "Y"; then - AC_CHECK_LIB(termcap, main, XE_APPEND(-ltermcap,EDITLINE_A)) + AC_CHECK_LIB(termcap, main, XE_APPEND(-ltermcap,EDITLINE_A)) fi AC_CHECK_TYPES([caddr_t]) diff --git a/extern/icu/source/config/mh-solaris b/extern/icu/source/config/mh-solaris index 603f2c4d21..85b9fbad53 100644 --- a/extern/icu/source/config/mh-solaris +++ b/extern/icu/source/config/mh-solaris @@ -13,7 +13,16 @@ GEN_DEPS.c= $(CC) -xM $(DEFS) $(CPPFLAGS) GEN_DEPS.cc= $(CXX) -xM $(DEFS) $(CPPFLAGS) # -libmil means use the intrinsic library functions like strlen -CPPFLAGS += -libmil -xarch=v9 +CPPFLAGS += -libmil + +# add any desired instruction set architecture flags +ISA=$(shell isainfo -k) +ifeq ($(ISA),sparcv9) + CPPFLAGS+= -xarch=sparcvis2 +endif +ifeq ($(ISA),amd64) + CPPFLAGS+= -xarch=sse2 +endif # -mt means 'compiles and links a multithreaded program' THREADSCFLAGS += -mt @@ -29,10 +38,10 @@ SHLIB.c= $(CC) $(CFLAGS) $(LDFLAGS) -G SHLIB.cc= $(CXX) $(CXXFLAGS) $(LDFLAGS) -G ## Compiler switch to embed a runtime search path -LD=CC +LD=cc LD_RPATH= -R LD_RPATH_PRE= -LDFLAGS+= -xarch=v9 +LDFLAGS+= -mt ## Compiler switch to embed a library name LD_SONAME = -h $(notdir $(MIDDLE_SO_TARGET)) @@ -47,31 +56,31 @@ STATIC_O = o ## Compilation rules %.$(STATIC_O): $(srcdir)/%.c - $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -o $@ $< + $(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -o $@ $< %.o: $(srcdir)/%.c - $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -o $@ $< + $(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -o $@ $< %.$(STATIC_O): $(srcdir)/%.cpp - $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -o $@ $< + $(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -o $@ $< %.o: $(srcdir)/%.cpp - $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $< + $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $< ## Dependency rules %.d : $(srcdir)/%.c - @echo "generating dependency information for $<" - @$(GEN_DEPS.c) $< > $@ + @echo "generating dependency information for $<" + @$(GEN_DEPS.c) $< > $@ %.d : $(srcdir)/%.cpp - @echo "generating dependency information for $<" - @$(GEN_DEPS.cc) $< > $@ + @echo "generating dependency information for $<" + @$(GEN_DEPS.cc) $< > $@ ## Versioned libraries rules %.$(SO).$(SO_TARGET_VERSION_MAJOR): %.$(SO).$(SO_TARGET_VERSION) - $(RM) $@ && ln -s ${ 2.1 -#ifdef SOLARIS -#error Mutex/Condition based semaphore is NOT OK for Solaris -#endif - #include #include diff --git a/src/common/classes/fb_tls.h b/src/common/classes/fb_tls.h index e1078494cd..fc377326ca 100644 --- a/src/common/classes/fb_tls.h +++ b/src/common/classes/fb_tls.h @@ -102,15 +102,12 @@ private: //# define TLS_SET(NAME, VALUE) NAME = (VALUE) #else -#ifndef SOLARIS_MT - #include "../common/classes/init.h" #include namespace Firebird { - template class TlsValue : private InstanceControl { @@ -159,55 +156,6 @@ private: bool keySet; // This is used to avoid conflicts when destroying global variables #endif }; -#else //SOLARIS_MT -#include -#include - -namespace Firebird { - - -template -class TlsValue -{ -public: - static void TlsV_on_thread_exit (void * pval) - { - // Usually should delete pval like this - // T* ptempT = (T*) pval; - // delete ptempT; - } - - TlsValue() - { - if (thr_keycreate(&key, TlsV_on_thread_exit)) - system_call_failed::raise("thr_key_create"); - } - const T get() - { - // We use double C-style cast to allow using scalar datatypes - // with sizes up to size of pointer without warnings - T* valuep; - if (thr_getspecific(key, (void**) &valuep) == 0) - return (T)(IPTR) valuep; - - system_call_failed::raise("thr_getspecific"); - return (T) NULL; - } - void set(const T value) - { - if (thr_setspecific(key, (void*)(IPTR) value)) - system_call_failed::raise("thr_setspecific"); - } - ~TlsValue() - { - // Do nothing if no pthread_key_delete - } -private: - thread_key_t key; -}; - - -#endif //SOLARIS_MT } // namespace Firebird diff --git a/src/common/classes/locks.cpp b/src/common/classes/locks.cpp index 1a001a4169..c5dc7758b2 100644 --- a/src/common/classes/locks.cpp +++ b/src/common/classes/locks.cpp @@ -79,10 +79,6 @@ void Spinlock::init() SetCriticalSectionSpinCount(&spinlock, 4000); } -#elif defined(SOLARIS_MT) - -// no support needed for solaris threads - #else //posix mutex pthread_mutexattr_t Mutex::attr; diff --git a/src/common/classes/locks.h b/src/common/classes/locks.h index 80c317c768..efd1441ae6 100644 --- a/src/common/classes/locks.h +++ b/src/common/classes/locks.h @@ -37,12 +37,7 @@ // in thd.h ? This is Windows platform maintainers choice #include #else -#ifndef SOLARIS_MT #include -#else -#include -#include -#endif #include #endif @@ -154,59 +149,6 @@ public: #else //WIN_NT -#ifdef SOLARIS_MT - -class Mutex -{ -private: - mutex_t mlock; - - void init() - { - int rc = mutex_init(&mlock, USYNC_THREAD | LOCK_RECURSIVE, NULL); - if (rc) - system_call_failed::raise("mutex_init", rc); - } - -public: - Mutex() { init(); } - explicit Mutex(MemoryPool&) { init(); } - ~Mutex() - { - int rc = mutex_destroy(&mlock); - if (rc) - system_call_failed::raise("mutex_destroy", rc); - } - void enter() - { - int rc = mutex_lock(&mlock); - if (rc) - system_call_failed::raise("mutex_lock", rc); - } - bool tryEnter() - { - int rc = mutex_trylock(&mlock); - if (rc == EBUSY) - return false; - if (rc) - system_call_failed::raise("mutex_trylock", rc); - return true; - } - void leave() - { - int rc = mutex_unlock(&mlock); - if (rc) - system_call_failed::raise("mutex_unlock", rc); - } - -public: - static void initMutexes() { } -}; - -typedef Mutex Spinlock; - -#else //SOLARIS_MT - // Pthreads version of the class class Mutex { @@ -294,8 +236,6 @@ public: typedef Mutex Spinlock; #endif // have spinlocks -#endif //SOLARIS_MT - #endif //WIN_NT diff --git a/src/common/classes/rwlock.h b/src/common/classes/rwlock.h index 6edd1d9e2d..b6234199e4 100644 --- a/src/common/classes/rwlock.h +++ b/src/common/classes/rwlock.h @@ -172,85 +172,6 @@ public: } // namespace Firebird -#else - -#ifdef SOLARIS_MT - -#include -#include -#include - -namespace Firebird -{ - -class RWLock -{ -private: - rwlock_t lock; - // Forbid copy constructor - RWLock(const RWLock& source); - - void init() - { - if (rwlock_init(&lock, USYNC_PROCESS, NULL)) - { - system_call_failed::raise("rwlock_init"); - } - } - -public: - RWLock() { init(); } - explicit RWLock(Firebird::MemoryPool&) { init(); } - ~RWLock() - { - if (rwlock_destroy(&lock)) - system_call_failed::raise("rwlock_destroy"); - } - void beginRead() - { - if (rw_rdlock(&lock)) - system_call_failed::raise("rw_rdlock"); - } - bool tryBeginRead() - { - const int code = rw_tryrdlock(&lock); - if (code == EBUSY) - return false; - if (code) - system_call_failed::raise("rw_tryrdlock"); - return true; - } - void endRead() - { - if (rw_unlock(&lock)) - system_call_failed::raise("rw_unlock"); - } - bool tryBeginWrite() - { - const int code = rw_trywrlock(&lock); - if (code == EBUSY) - return false; - if (code) - system_call_failed::raise("rw_trywrlock"); - return true; - } - void beginWrite() - { - if (rw_wrlock(&lock)) - system_call_failed::raise("rw_wrlock"); - } - void endWrite() - { - if (rw_unlock(&lock)) - system_call_failed::raise("rw_unlock"); - } -}; - -} // namespace Firebird - - - - #else #include @@ -336,8 +257,6 @@ public: } // namespace Firebird -#endif // solaris threading (not posix) - #endif // !WIN_NT namespace Firebird { diff --git a/src/common/thd.cpp b/src/common/thd.cpp index a351ed1784..ce1231b7eb 100644 --- a/src/common/thd.cpp +++ b/src/common/thd.cpp @@ -55,11 +55,6 @@ # endif #endif -#ifdef SOLARIS_MT -#include -#include -#endif - #ifdef USE_POSIX_THREADS #include #endif @@ -81,10 +76,6 @@ FB_THREAD_ID getThreadId() id = GetCurrentThreadId(); #endif -#ifdef SOLARIS_MT - id = thr_self(); -#endif - #ifdef USE_POSIX_THREADS id = (FB_THREAD_ID) pthread_self(); #endif @@ -157,10 +148,6 @@ void THD_yield() #endif // _POSIX_PRIORITY_SCHEDULING #endif -#ifdef SOLARIS_MT - thr_yield(); -#endif - #ifdef WIN_NT SleepEx(0, FALSE); #endif diff --git a/src/gpre/gpre.h b/src/gpre/gpre.h index a49581e4a8..5891e14117 100644 --- a/src/gpre/gpre.h +++ b/src/gpre/gpre.h @@ -865,7 +865,7 @@ enum dbb_flags_valss { DBB_sqlca = 2, // Created as default for a sqlca DBB_in_trans = 4, // included in this transaction // DBB_drop_log = 8, - DBB_log_serial = 16, + DBB_log_serial = 16 // DBB_log_default = 32, // DBB_cascade = 64, // only set but not used // DBB_drop_cache = 128, // only set but not used diff --git a/src/jrd/SysFunction.cpp b/src/jrd/SysFunction.cpp index 80156a7184..90bd68e062 100644 --- a/src/jrd/SysFunction.cpp +++ b/src/jrd/SysFunction.cpp @@ -3133,7 +3133,7 @@ dsc* evlUuidToChar(Jrd::thread_db* tdbb, const SysFunction* function, Jrd::jrd_n -#ifdef _MSC_VER +#if defined (_MSC_VER) || defined (__SUNPRO_CC) typedef StdMathFunc VoidPtrStdMathFunc; #else typedef void* VoidPtrStdMathFunc; diff --git a/src/jrd/ThreadData.h b/src/jrd/ThreadData.h index f128987a3b..0f79ff5e90 100644 --- a/src/jrd/ThreadData.h +++ b/src/jrd/ThreadData.h @@ -82,10 +82,6 @@ public: #define THREAD_ENTRY_PARAM void* #define THREAD_ENTRY_RETURN void* #define THREAD_ENTRY_CALL -#elif defined(SOLARIS_MT) -#define THREAD_ENTRY_PARAM void* -#define THREAD_ENTRY_RETURN void * -#define THREAD_ENTRY_CALL #else // Define correct types for other platforms #define THREAD_ENTRY_PARAM void* diff --git a/src/jrd/ThreadStart.cpp b/src/jrd/ThreadStart.cpp index 9b470dee1f..1d91463d84 100644 --- a/src/jrd/ThreadStart.cpp +++ b/src/jrd/ThreadStart.cpp @@ -47,11 +47,6 @@ #include #endif -#ifdef SOLARIS_MT -#include -#include -#endif - #include "../common/classes/locks.h" #include "../common/classes/rwlock.h" @@ -239,54 +234,6 @@ void THD_wait_for_completion(ThreadHandle& thread) #endif /* USE_POSIX_THREADS */ -#ifdef SOLARIS_MT -#define START_THREAD -void ThreadStart::start(ThreadEntryPoint* routine, - void* arg, - int priority_arg, - void* thd_id) -{ -/************************************** - * - * t h r e a d _ s t a r t ( S o l a r i s ) - * - ************************************** - * - * Functional description - * Start a new thread. Return 0 if successful, - * status if not. - * - **************************************/ - int rval; - thread_t thread_id; - sigset_t new_mask, orig_mask; - - sigfillset(&new_mask); - sigdelset(&new_mask, SIGALRM); - if (rval = thr_sigsetmask(SIG_SETMASK, &new_mask, &orig_mask)) - Firebird::system_call_failed::raise("thr_sigsetmask", rval); - rval = thr_create(NULL, 0, THREAD_ENTRYPOINT, THREAD_ARG, - (thd_id ? 0 : THR_DETACHED) | THR_NEW_LWP, &thread_id); - thr_sigsetmask(SIG_SETMASK, &orig_mask, NULL); - - if (rval) - Firebird::system_call_failed::raise("thr_create", rval); - - if (thd_id) - { - *static_cast(thd_id) = thread_id; - } -} - -void THD_wait_for_completion(ThreadHandle& thread) -{ - int state = thr_join(thread, NULL, NULL); - if (state) - Firebird::system_call_failed::raise("thread_join", state); -} -#endif // SOLARIS_MT - - #ifdef WIN_NT #define START_THREAD void ThreadStart::start(ThreadEntryPoint* routine, diff --git a/src/jrd/ThreadStart.h b/src/jrd/ThreadStart.h index be0bb7849b..a936222ef8 100644 --- a/src/jrd/ThreadStart.h +++ b/src/jrd/ThreadStart.h @@ -68,9 +68,6 @@ typedef HANDLE ThreadHandle; #ifdef USE_POSIX_THREADS typedef pthread_t ThreadHandle; #endif -#ifdef SOLARIS_MT -typedef thread_t ThreadHandle; -#endif void THD_wait_for_completion(ThreadHandle& handle); diff --git a/src/jrd/common.h b/src/jrd/common.h index 254c167ed7..d33062335f 100644 --- a/src/jrd/common.h +++ b/src/jrd/common.h @@ -269,12 +269,6 @@ #ifdef SOLARIS -/* This is NOT defined when building the special shared-pipe library - * which customers can use to avoid the problems with signals & threads - * in Solaris - */ -#define SOLARIS_MT - /* Define the following only on platforms whose standard I/O * implementation is so weak that we wouldn't be able to fopen * a file whose underlying file descriptor would be > 255. diff --git a/src/jrd/exe.cpp b/src/jrd/exe.cpp index 2aaa8e586b..8284375e15 100644 --- a/src/jrd/exe.cpp +++ b/src/jrd/exe.cpp @@ -227,7 +227,7 @@ static void stuff_stack_trace(const jrd_req*); /* macro definitions */ -#if (defined SUPERSERVER) && (defined WIN_NT || defined SOLARIS_MT) +#if (defined SUPERSERVER) && (defined WIN_NT) const int MAX_CLONES = 750; #else const int MAX_CLONES = 1000; diff --git a/src/jrd/isc.h b/src/jrd/isc.h index 5532d53bbf..766b5303b3 100644 --- a/src/jrd/isc.h +++ b/src/jrd/isc.h @@ -40,22 +40,7 @@ #ifdef UNIX -#if defined(SOLARIS_MT) -#include - -struct mtx -{ - mutex_t mtx_mutex[1]; -}; - -struct event_t -{ - SLONG event_count; - mutex_t event_mutex[1]; - cond_t event_cond[1]; -}; - -#elif defined(USE_POSIX_THREADS) +#if defined(USE_POSIX_THREADS) #if defined(HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP) && defined(HAVE_PTHREAD_MUTEX_CONSISTENT_NP) diff --git a/src/jrd/isc_sync.cpp b/src/jrd/isc_sync.cpp index 81f9cdee46..934d516425 100644 --- a/src/jrd/isc_sync.cpp +++ b/src/jrd/isc_sync.cpp @@ -738,161 +738,6 @@ static bool event_blocked(const event_t* event, const SLONG value) return true; } -#ifdef SOLARIS_MT - -SLONG ISC_event_clear(event_t* event) -{ -/************************************** - * - * I S C _ e v e n t _ c l e a r ( S O L A R I S _ M T ) - * - ************************************** - * - * Functional description - * Clear an event preparatory to waiting on it. The order of - * battle for event synchronization is: - * - * 1. Clear event. - * 2. Test data structure for event already completed - * 3. Wait on event. - * - **************************************/ - mutex_lock(event->event_mutex); - const SLONG ret = event->event_count + 1; - mutex_unlock(event->event_mutex); - return ret; -} - - -void ISC_event_fini(event_t* event) -{ -/************************************** - * - * I S C _ e v e n t _ f i n i ( S O L A R I S _ M T ) - * - ************************************** - * - * Functional description - * Discard an event object. - * - **************************************/ - -/* Inter-Process event's are destroyed only */ - mutex_destroy(event->event_mutex); - cond_destroy(event->event_cond); -} - - -int ISC_event_init(event_t* event) -{ -/************************************** - * - * I S C _ e v e n t _ i n i t ( S O L A R I S _ M T ) - * - ************************************** - * - * Functional description - * Prepare an event object for use. - * - **************************************/ - event->event_count = 0; - - mutex_init(event->event_mutex, USYNC_PROCESS, NULL); - cond_init(event->event_cond, USYNC_PROCESS, NULL); - - return FB_SUCCESS; -} - - -int ISC_event_post(event_t* event) -{ -/************************************** - * - * I S C _ e v e n t _ p o s t ( S O L A R I S _ M T ) - * - ************************************** - * - * Functional description - * Post an event to wake somebody else up. - * - **************************************/ -/* For Solaris, we use cond_broadcast rather than cond_signal so that - all waiters on the event are notified and awakened */ - - mutex_lock(event->event_mutex); - ++event->event_count; - const int ret = cond_broadcast(event->event_cond); - mutex_unlock(event->event_mutex); - if (ret) { - gds__log("ISC_event_post: cond_broadcast failed with errno = %d", ret); - return FB_FAILURE; - } - return FB_SUCCESS; -} - - -int ISC_event_wait(event_t* event, - const SLONG value, - const SLONG micro_seconds) -{ -/************************************** - * - * I S C _ e v e n t _ w a i t ( S O L A R I S _ M T ) - * - ************************************** - * - * Functional description - * Wait on an event. If timeout limit specified, return - * anyway after the timeout even if no event has - * happened. If returning due to timeout, return - * FB_FAILURE else return FB_SUCCESS. - * - **************************************/ - -/* If we're not blocked, the rest is a gross waste of time */ - - if (!event_blocked(event, value)) - return FB_SUCCESS; - -/* Set up timers if a timeout period was specified. */ - - timestruc_t timer; - if (micro_seconds > 0) { - timer.tv_sec = time(NULL); - timer.tv_sec += micro_seconds / 1000000; - timer.tv_nsec = 1000 * (micro_seconds % 1000000); - } - - int ret = FB_SUCCESS; - mutex_lock(event->event_mutex); - for (;;) { - if (!event_blocked(event, value)) { - ret = FB_SUCCESS; - break; - } - - /* The Solaris cond_wait & cond_timedwait calls atomically release - the mutex and start a wait. The mutex is reacquired before the - call returns. */ - - if (micro_seconds > 0) - ret = cond_timedwait(event->event_cond, event->event_mutex, &timer); - else - ret = cond_wait(event->event_cond, event->event_mutex); - if (micro_seconds > 0 && (ret == ETIME)) { - - /* The timer expired - see if the event occured and return - FB_SUCCESS or FB_FAILURE accordingly. */ - - ret = event_blocked(event, value) ? FB_FAILURE : FB_SUCCESS; - break; - } - } - mutex_unlock(event->event_mutex); - return ret; -} -#endif /* SOLARIS_MT */ - #ifdef USE_POSIX_THREADS @@ -2817,116 +2662,6 @@ void ISC_unmap_object(ISC_STATUS* status_vector, #endif -#ifdef SOLARIS_MT -int ISC_mutex_init(struct mtx* mutex) -{ -/************************************** - * - * I S C _ m u t e x _ i n i t ( S O L A R I S _ M T ) - * - ************************************** - * - * Functional description - * Initialize a mutex. - * - **************************************/ - - memset(mutex->mtx_mutex, 0, sizeof(mutex_t)); - return mutex_init(mutex->mtx_mutex, USYNC_PROCESS | LOCK_ROBUST, NULL); -} - - -void ISC_mutex_fini(struct mtx *mutex) -{ -/************************************** - * - * m u t e x _ f i n i ( S O L A R I S _ M T ) - * - ************************************** - * - * Functional description - * Destroy a mutex. - * - **************************************/ - // no-op for Solaris threads semaphores -} - - -int ISC_mutex_lock(struct mtx* mutex) -{ -/************************************** - * - * I S C _ m u t e x _ l o c k ( S O L A R I S _ M T ) - * - ************************************** - * - * Functional description - * Seize a mutex. - * - **************************************/ - for (;;) { - int state = mutex_lock(mutex->mtx_mutex); - if (!state) - break; - if (!SYSCALL_INTERRUPTED(state)) - return state; - } - - return 0; -} - - -int ISC_mutex_lock_cond(struct mtx* mutex) -{ -/************************************** - * - * I S C _ m u t e x _ l o c k _ c o n d ( S O L A R I S _ M T ) - * - ************************************** - * - * Functional description - * Conditionally seize a mutex. - * - **************************************/ - for (;;) { - int state = mutex_trylock(mutex->mtx_mutex); - if (!state) - break; - if (!SYSCALL_INTERRUPTED(state)) - return state; - } - - return 0; -} - - -int ISC_mutex_unlock(struct mtx* mutex) -{ -/************************************** - * - * I S C _ m u t e x _ u n l o c k ( S O L A R I S _ M T ) - * - ************************************** - * - * Functional description - * Release a mutex. - * - **************************************/ - for (;;) { - /* Note use of undocumented lwp_mutex_unlock call - * due to Solaris 2.4 bug */ - int state = _lwp_mutex_unlock(mutex->mtx_mutex); - if (!state) - break; - if (!SYSCALL_INTERRUPTED(state)) - return state; - } - - return 0; -} -#endif /* SOLARIS_MT */ - - #ifdef USE_POSIX_THREADS #ifdef USE_SYS5SEMAPHORE diff --git a/src/jrd/why.cpp b/src/jrd/why.cpp index c5c805b60e..fd22317cd6 100644 --- a/src/jrd/why.cpp +++ b/src/jrd/why.cpp @@ -5291,7 +5291,14 @@ static const PTR get_entrypoint(int proc, int implementation) **************************************/ const PTR* const entry = entrypoints + implementation * PROC_count + proc; - return *entry ? *entry : &no_entrypoint; + + // static qualifier on &noentrypoint disallows use of conditional operator on Solaris + // return *entry ? *entry : &no_entrypoint; + if (*entry) + return *entry; + else + return &no_entrypoint; + } diff --git a/src/utilities/guard/util.cpp b/src/utilities/guard/util.cpp index 4f6c578114..4d02ad6df3 100644 --- a/src/utilities/guard/util.cpp +++ b/src/utilities/guard/util.cpp @@ -22,10 +22,6 @@ */ #include "firebird.h" -#ifdef SOLARIS_MT -#include -#endif - #include #include #include @@ -105,7 +101,7 @@ pid_t UTIL_start_process(const char* process, const char* process2, char** argv, /* add place in argv for visibility to "ps" */ strcpy(argv[0], string); -#if (defined SOLARIS_MT) +#if (defined SOLARIS) pid_t pid = fork1(); if (!pid) { if (execv(string, argv) == -1) { diff --git a/src/utilities/ibmgr/srvrmgr.cpp b/src/utilities/ibmgr/srvrmgr.cpp index 1fbd0dfeea..32236f4ec3 100644 --- a/src/utilities/ibmgr/srvrmgr.cpp +++ b/src/utilities/ibmgr/srvrmgr.cpp @@ -23,10 +23,6 @@ */ #include "firebird.h" -#ifdef SOLARIS_MT -#include -#endif - #include #include #include @@ -515,7 +511,7 @@ static bool start_server( ibmgr_data_t* data) #endif pid_t pid; -#if (defined SOLARIS_MT) +#if (defined SOLARIS) /* Accoding Sun's documentation vfork() is not MT-safe while linking with libthreads, fork1 - fork one thread */ @@ -560,7 +556,7 @@ static bool start_server( ibmgr_data_t* data) 0 if an exit status of a child process is unavailable (that means in our case that the server is running). */ -#if (defined SOLARIS_MT) +#if (defined SOLARIS) // Trying to understand why it died if (ret_value == pid && (WIFEXITED(exit_status) || WCOREDUMP(exit_status) || WIFSIGNALED(exit_status))) @@ -579,7 +575,7 @@ static bool start_server( ibmgr_data_t* data) break; } -#endif /* SOLARIS_MT */ +#endif /* SOLARIS */ #ifdef DEBUG else if (ret_value == -1) {