1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Add new auto-detection of thread flags.

Allow additional thread flags to be added via port templates.

Change thread flag names to PTHREAD_CFLAGS and PTHREAD_LIBS to match new
configure script.
This commit is contained in:
Bruce Momjian
2004-04-23 18:15:55 +00:00
parent 77528c9bd7
commit 7a66015e98
25 changed files with 751 additions and 195 deletions

View File

@ -1,5 +1,5 @@
# -*-makefile-*-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.177 2004/04/20 00:33:46 pgsql Exp $
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.178 2004/04/23 18:15:53 momjian Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
@ -147,9 +147,8 @@ TK_LIBS = @TK_LIBS@
TK_LIB_SPEC = @TK_LIB_SPEC@
TK_XINCLUDES = @TK_XINCLUDES@
THREAD_SUPPORT = @THREAD_SUPPORT@
THREAD_CPPFLAGS = @THREAD_CPPFLAGS@
THREAD_LIBS = @THREAD_LIBS@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
have_docbook = @have_docbook@
DOCBOOKSTYLE = @DOCBOOKSTYLE@

View File

@ -43,15 +43,9 @@
(--enable-thread-safety) */
#undef ENABLE_THREAD_SAFETY
/* Define if gethostbyname is not thread safe */
#undef GETHOSTBYNAME_THREADSAFE
/* Define to 1 if getpwuid_r() takes a 5th argument. */
#undef GETPWUID_R_5ARG
/* Define if getpwuid is not thread safe */
#undef GETPWUID_THREADSAFE
/* Define to 1 if gettimeofday() takes only 1 argument. */
#undef GETTIMEOFDAY_1ARG
@ -324,6 +318,9 @@
/* Define to 1 if the PS_STRINGS thing exists. */
#undef HAVE_PS_STRINGS
/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD
/* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H
@ -588,15 +585,16 @@
/* A string containing the version number, platform, and C compiler */
#undef PG_VERSION_STR
/* Define to the necessary symbol if this constant uses a non-standard name on
your system. */
#undef PTHREAD_CREATE_JOINABLE
/* The size of a `unsigned long', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define if strerror is not thread safe */
#undef STRERROR_THREADSAFE
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME

View File

@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.14 2004/02/10 07:26:25 tgl Exp $
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.15 2004/04/23 18:15:54 momjian Exp $
#
#-------------------------------------------------------------------------
@ -16,9 +16,9 @@ NAME= ecpg_compat
SO_MAJOR_VERSION= 1
SO_MINOR_VERSION= 1
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CPPFLAGS)
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(PTHREAD_CFLAGS)
SHLIB_LINK = -L../ecpglib -lecpg -L../pgtypeslib -lpgtypes $(libpq) \
$(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt -lm, $(LIBS)) $(THREAD_LIBS)
$(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt -lm, $(LIBS)) $(PTHREAD_LIBS)
OBJS= informix.o

View File

@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.14 2004/03/14 12:16:29 meskes Exp $
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.15 2004/04/23 18:15:54 momjian Exp $
#
#-------------------------------------------------------------------------
@ -16,13 +16,13 @@ NAME= ecpg
SO_MAJOR_VERSION= 4
SO_MINOR_VERSION= 2
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS)
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) $(CPPFLAGS) $(PTHREAD_CFLAGS)
OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
connect.o misc.o
SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) \
$(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt -lm, $(LIBS)) $(THREAD_LIBS)
$(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt -lm, $(LIBS)) $(PTHREAD_LIBS)
all: all-lib

View File

@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.16 2004/02/24 16:07:49 meskes Exp $
# $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.17 2004/04/23 18:15:54 momjian Exp $
#
#-------------------------------------------------------------------------
@ -16,7 +16,7 @@ NAME= pgtypes
SO_MAJOR_VERSION= 1
SO_MINOR_VERSION= 2
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS)
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils -I$(libpq_srcdir) $(CPPFLAGS) $(PTHREAD_CFLAGS)
SHLIB_LINK += -lm
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \

View File

@ -1,4 +1,4 @@
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.99 2004/03/02 06:45:05 meskes Exp $
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.100 2004/04/23 18:15:55 momjian Exp $
subdir = src/interfaces/ecpg/preproc
top_builddir = ../../../..
@ -8,7 +8,7 @@ MAJOR_VERSION=3
MINOR_VERSION=2
PATCHLEVEL=0
override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS) \
override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) $(PTHREAD_CFLAGS) \
-DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
-DINCLUDEDIR=\"$(includedir)\" \
@ -25,7 +25,7 @@ OBJS=preproc.o type.o ecpg.o ecpg_keywords.o output.o\
all: submake-libpgport ecpg
ecpg: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(THREAD_LIBS) -o $@
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(PTHREAD_LIBS) -o $@
# pgc is compiled as part of preproc
preproc.o: $(srcdir)/pgc.c

View File

@ -1,10 +1,10 @@
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.44 2004/03/14 12:16:30 meskes Exp $
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.45 2004/04/23 18:15:55 momjian Exp $
subdir = src/interfaces/ecpg/test
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(srcdir)/../include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS)
override CPPFLAGS := -I$(srcdir)/../include -I$(libpq_srcdir) $(CPPFLAGS) $(PTHREAD_CFLAGS)
ECPG = ../preproc/ecpg -I$(srcdir)/../include
@ -16,10 +16,10 @@ endif
all: $(TESTS)
%: %.o
$(CC) $(CFLAGS) $(LDFLAGS) -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lpq $(THREAD_LIBS) -o $@
$(CC) $(CFLAGS) $(LDFLAGS) -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lpq $(PTHREAD_LIBS) -o $@
test_informix: test_informix.o
$(CC) $(CFLAGS) $(LDFLAGS) -L../compatlib -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lecpg_compat -lpq $(THREAD_LIBS) -o $@
$(CC) $(CFLAGS) $(LDFLAGS) -L../compatlib -L../ecpglib -L ../pgtypeslib -L../../libpq $^ $(LIBS) -lpgtypes -lecpg -lecpg_compat -lpq $(PTHREAD_LIBS) -o $@
%.c: %.pgc
$(ECPG) $<

View File

@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.101 2004/04/19 17:42:59 momjian Exp $
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.102 2004/04/23 18:15:55 momjian Exp $
#
#-------------------------------------------------------------------------
@ -18,7 +18,7 @@ NAME= pq
SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 2
override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"'
override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) $(PTHREAD_CFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"'
OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
@ -32,7 +32,7 @@ endif
# Add libraries that libpq depends (or might depend) on into the
# shared library link. (The order in which you list them here doesn't
# matter.)
SHLIB_LINK += $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) $(THREAD_LIBS)
SHLIB_LINK += $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) $(PTHREAD_LIBS)
ifeq ($(PORTNAME), win32)
SHLIB_LINK += -lwsock32 -lws2_32
endif

View File

@ -7,7 +7,7 @@
# with broken/missing library files.
# IDENTIFICATION
# $PostgreSQL: pgsql/src/port/Makefile,v 1.9 2003/11/29 19:52:13 pgsql Exp $
# $PostgreSQL: pgsql/src/port/Makefile,v 1.10 2004/04/23 18:15:55 momjian Exp $
#
#-------------------------------------------------------------------------
@ -23,7 +23,7 @@ libpgport.a: $(LIBOBJS)
$(AR) $(AROPT) $@ $^
thread.o: thread.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(THREAD_CPPFLAGS) -c $<
$(CC) $(CFLAGS) $(CPPFLAGS) $(PTHREAD_CFLAGS) -c $<
clean distclean maintainer-clean:
rm -f libpgport.a $(LIBOBJS)

View File

@ -7,7 +7,7 @@
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/port/thread.c,v 1.19 2004/03/23 02:03:55 momjian Exp $
* $PostgreSQL: pgsql/src/port/thread.c,v 1.20 2004/04/23 18:15:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -76,10 +76,6 @@ pqStrerror(int errnum, char *strerrbuf, size_t buflen)
#else
#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && !defined(STRERROR_THREADSAFE)
#error This platform can not create a thread-safe version because strerror is not thread-safe and there is no reentrant version
#endif
/* no strerror_r() available, just use strerror */
StrNCpy(strerrbuf, strerror(errnum), buflen);
@ -111,10 +107,6 @@ pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
#else
#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && !defined(GETPWUID_THREADSAFE)
#error This platform can not create a thread-safe version because getpwuid is not thread-safe and there is no reentrant version
#endif
/* no getpwuid_r() available, just use getpwuid() */
*result = getpwuid(uid);
#endif
@ -146,10 +138,6 @@ pqGethostbyname(const char *name,
#else
#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && !defined(GETHOSTBYNAME_THREADSAFE)
#error This platform can not create a thread-safe version because getaddrinfo is not thread-safe and there is no reentrant version
#endif
/* no gethostbyname_r(), just use gethostbyname() */
*result = gethostbyname(name);

View File

@ -1,9 +1,3 @@
case $host_os in
bsdi2.0 | bsdi2.1 | bsdi3*) CC=gcc2;;
esac
THREAD_SUPPORT=yes
# verified 4.3.1 2004-02-11
STRERROR_THREADSAFE=yes
GETPWUID_THREADSAFE=yes
GETHOSTBYNAME_THREADSAFE=yes

View File

@ -5,12 +5,5 @@ CC="$CC -no-cpp-precomp"
# Select appropriate semaphore support
USE_NAMED_POSIX_SEMAPHORES=1
THREAD_SUPPORT=yes
# verified Mac OS X 10.3.3, Darwin Kernel Version 7.3.0, 2004-04-07
THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread"
STRERROR_THREADSAFE=yes
GETPWUID_THREADSAFE=yes
GETHOSTBYNAME_THREADSAFE=yes
PTHREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"

View File

@ -2,9 +2,7 @@ case $host_cpu in
alpha*) CFLAGS="-O";; # alpha has problems with -O2
esac
# tools/thread/thread_test must be run
THREAD_CPPFLAGS="-D_THREAD_SAFE"
case $host_os in
freebsd2*|freebsd3*|freebsd4*) THREAD_LIBS="-pthread";;
*) THREAD_LIBS="-lc_r";;
freebsd2*|freebsd3*|freebsd4*) ;;
*) THREAD_LIBS="c_r";; # do we need this? 2004-04-23
esac

View File

@ -2,12 +2,4 @@
CPPFLAGS="-D_GNU_SOURCE"
# tools/thread/thread_test must be run
THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread"
THREAD_SUPPORT=yes
# 2004-03-14, Linux 2.4.25-1-686
STRERROR_THREADSAFE=yes
GETPWUID_THREADSAFE=no
GETHOSTBYNAME_THREADSAFE=no
PTHREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"

View File

@ -1,5 +1,2 @@
# tools/thread/thread_test must be run
case $build in
*-netbsdelf[2-9]*) THREAD_CPPFLAGS="-pthread"; THREAD_LIBS="-pthread" ;;
esac

View File

@ -2,10 +2,3 @@ if test "$GCC" != yes ; then
CC="$CC -std"
CFLAGS="-O -ieee"
fi
# tools/thread/thread_test must be run
if test "$GCC" = yes
then THREAD_LIBS="-pthread"
else THREAD_CPPFLAGS="-pthread"
THREAD_LIBS="-lpthread"
fi

View File

@ -9,10 +9,5 @@ case $host in
i?86-*-solaris*) need_tas=yes; tas_file=solaris_i386.s ;;
esac
# tools/thread/thread_test must be run
# -D_POSIX_PTHREAD_SEMANTICS enables 5-arg getpwuid_r, among other things
THREAD_CPPFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
if test "$GCC" != yes
then THREAD_CPPFLAGS="$THREAD_CPPFLAGS -mt"
fi
THREAD_LIBS="-lpthread"
PTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"

View File

@ -1,5 +1,5 @@
if test "$GCC" = yes; then
THREAD_CPPFLAGS="-pthread"
PTHREAD_CFLAGS="-pthread"
else
# The -Kno_host is for a bug in the compiler. See -hackers
# discussion on 7-8/Aug/2003.
@ -21,17 +21,11 @@ __EOF__
fi
rm -f conftest.*
THREAD_CPPFLAGS="-K pthread"
PTHREAD_CFLAGS="-Kpthread"
fi
# tools/thread/thread_test must be run
THREAD_CPPFLAGS="$THREAD_CPPFLAGS -D_REENTRANT"
PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_REENTRANT"
# Disabled because flags are required for all apps using libpq.
# Waiting to see if other platforms need this too. 2004-03-22
#THREAD_SUPPORT=yes
# verified UnixWare 7.1.4 2004-03-18
STRERROR_THREADSAFE=yes
GETPWUID_THREADSAFE=yes
GETHOSTBYNAME_THREADSAFE=yes

View File

@ -4,7 +4,7 @@
#
# Copyright (C) 2003 by PostgreSQL Global Development Team
#
# $PostgreSQL: pgsql/src/tools/thread/Makefile,v 1.3 2003/11/29 19:52:14 pgsql Exp $
# $PostgreSQL: pgsql/src/tools/thread/Makefile,v 1.4 2004/04/23 18:15:55 momjian Exp $
#
#-------------------------------------------------------------------------
@ -19,9 +19,9 @@ ifeq ($(THREAD_SUPPORT), )
$(error You have not configured your template/$$port file. See the README)
endif
override CFLAGS += $(THREAD_CPPFLAGS)
override CFLAGS += $(PTHREAD_CFLAGS)
LDFLAGS += $(THREAD_LIBS)
LDFLAGS += $(PTHREAD_LIBS)
all: thread_test

View File

@ -6,9 +6,11 @@ thread-safe, or if we should use *_r functions or thread locking.
To use this program, you must:
o add "THREAD_SUPPORT=yes" to your template/${port} file
o add any THREAD_CPPFLAGS and THREAD_LIBS defines to your
template/${port} file
o run "configure --enable-thread-safety"
o compile the main source tree
o compile and run this program
If your platform requires special thread flags that are not tested by
/config/acx_pthread.m4, add PTHREAD_CFLAGS and PTHREAD_LIBS defines to
your template/${port} file.

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.19 2004/04/22 23:58:03 momjian Exp $
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.20 2004/04/23 18:15:55 momjian Exp $
*
* This program tests to see if your standard libc functions use
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
@ -78,7 +78,7 @@ int main(int argc, char *argv[])
}
printf("\
Make sure you have added any needed 'THREAD_CPPFLAGS' and 'THREAD_LIBS'\n\
Make sure you have added any needed 'PTHREAD_CFLAGS' and 'PTHREAD_LIBS'\n\
defines to your template/$port file before compiling this program.\n\n"
);