Commit 7a66015e authored by Bruce Momjian's avatar Bruce Momjian

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.
parent 77528c9b
dnl $PostgreSQL: pgsql/aclocal.m4,v 1.17 2004/01/19 21:20:04 tgl Exp $ dnl $PostgreSQL: pgsql/aclocal.m4,v 1.18 2004/04/23 18:15:47 momjian Exp $
m4_include([config/ac_func_accept_argtypes.m4]) m4_include([config/ac_func_accept_argtypes.m4])
m4_include([config/acx_pthread.m4])
m4_include([config/c-compiler.m4]) m4_include([config/c-compiler.m4])
m4_include([config/c-library.m4]) m4_include([config/c-library.m4])
m4_include([config/docbook.m4]) m4_include([config/docbook.m4])
......
dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/acx_pthread.html
dnl
AC_DEFUN([ACX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_LANG_SAVE
AC_LANG_C
acx_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
AC_MSG_RESULT($acx_pthread_ok)
if test x"$acx_pthread_ok" = xno; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
# -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case "${host_cpu}-${host_os}" in
*solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthread or
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
;;
esac
if test x"$acx_pthread_ok" = xno; then
for flag in $acx_pthread_flags; do
case $flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$flag"
;;
pthread-config)
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
if test x"$acx_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$flag])
PTHREAD_LIBS="-l$flag"
;;
esac
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_TRY_LINK([#include <pthread.h>],
[pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
[acx_pthread_ok=yes])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($acx_pthread_ok)
if test "x$acx_pthread_ok" = xyes; then
break;
fi
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$acx_pthread_ok" = xyes; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: threads are created detached by default
# and the JOINABLE attribute has a nonstandard name (UNDETACHED).
AC_MSG_CHECKING([for joinable pthread attribute])
AC_TRY_LINK([#include <pthread.h>],
[int attr=PTHREAD_CREATE_JOINABLE;],
ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
if test x"$ok" = xunknown; then
AC_TRY_LINK([#include <pthread.h>],
[int attr=PTHREAD_CREATE_UNDETACHED;],
ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
fi
if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
[Define to the necessary symbol if this constant
uses a non-standard name on your system.])
fi
AC_MSG_RESULT(${ok})
if test x"$ok" = xunknown; then
AC_MSG_WARN([we do not know how to create joinable pthreads])
fi
AC_MSG_CHECKING([if more special flags are required for pthreads])
flag=no
case "${host_cpu}-${host_os}" in
*-aix* | *-freebsd*) flag="-D_THREAD_SAFE";;
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
esac
AC_MSG_RESULT(${flag})
if test "x$flag" != xno; then
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
# More AIX lossage: must compile with cc_r
AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
else
PTHREAD_CC="$CC"
fi
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$acx_pthread_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
:
else
acx_pthread_ok=no
$2
fi
AC_LANG_RESTORE
])dnl ACX_PTHREAD
This diff is collapsed.
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.323 2004/04/20 00:33:45 pgsql Exp $ dnl $PostgreSQL: pgsql/configure.in,v 1.324 2004/04/23 18:15:53 momjian Exp $
dnl dnl
dnl Developers, please strive to achieve this order: dnl Developers, please strive to achieve this order:
dnl dnl
...@@ -957,43 +957,35 @@ AC_FUNC_FSEEKO ...@@ -957,43 +957,35 @@ AC_FUNC_FSEEKO
# See the comment at the top of src/port/thread.c for more information. # See the comment at the top of src/port/thread.c for more information.
# #
if test "$enable_thread_safety" = yes; then if test "$enable_thread_safety" = yes; then
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --enable-thread-safety])]) ACX_PTHREAD # set thread flags
# ACX_PTHREAD sets PTHREAD_CFLAGS that should be used for linking too
PTHREAD_LIBS="$PTHREAD_CFLAGS $PTHREAD_LIBS"
if test "$THREAD_SUPPORT" != yes; then # At this point, we don't want to muck with the compiler name for threading.
# Let's see who fails, perhaps AIX. 2004-04-23
if test "$PTHREAD_CC" != "$CC"; then
AC_MSG_ERROR([ AC_MSG_ERROR([
Cannot enable threads on your platform. PostgreSQL does not support platforms that require a special
Please report your platform threading info to the PostgreSQL mailing lists compiler binary for thread-safety.
so it can be added to the next release. Report all compile flags, link flags,
functions, or libraries required for threading support.
See the comment at the top of src/port/thread.c for more information.
]) ])
fi fi
# if test "$THREAD_SUPPORT" = no; then
# Check for re-entrant versions of certain functions AC_MSG_ERROR([
# Cannot enable threads on your platform.
# Include special flags if threads are enabled _and_ if required for Your platform is known to not support thread-safe programs.
# threading on this platform. Some platforms have *_r functions but For details, compile and run src/bin/pg_thread_test.
# their natively named funcs are thread-safe too. ])
#
# One trick here is that if we don't call AC_CHECK_FUNCS; the
# functions are marked "not found", which is perfect.
#
if test "$enable_thread_safety" = yes -a "$STRERROR_THREADSAFE" = yes ; then
AC_DEFINE(STRERROR_THREADSAFE, 1, [Define if strerror is not thread safe])
fi
if test "$enable_thread_safety" = yes -a "$GETPWUID_THREADSAFE" = yes ; then
AC_DEFINE(GETPWUID_THREADSAFE, 1, [Define if getpwuid is not thread safe])
fi
if test "$enable_thread_safety" = yes -a "$GETHOSTBYNAME_THREADSAFE" = yes ; then
AC_DEFINE(GETHOSTBYNAME_THREADSAFE, 1, [Define if gethostbyname is not thread safe])
fi fi
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([pthread.h not found, required for --enable-thread-safety])])
# Check for *_r functions # Check for *_r functions
_CFLAGS="$CFLAGS" _CFLAGS="$CFLAGS"
_LIBS="$LIBS" _LIBS="$LIBS"
CFLAGS="$CFLAGS $THREAD_CPPFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$LIBS $THREAD_LIBS" LIBS="$LIBS $PTHREAD_LIBS"
AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r]) AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
CFLAGS="$_CFLAGS" CFLAGS="$_CFLAGS"
LIBS="$_LIBS" LIBS="$_LIBS"
...@@ -1002,13 +994,13 @@ PGAC_FUNC_GETPWUID_R_5ARG ...@@ -1002,13 +994,13 @@ PGAC_FUNC_GETPWUID_R_5ARG
else else
# do not use values from template file # do not use values from template file
THREAD_CPPFLAGS= PTHREAD_CFLAGS=
THREAD_LIBS= PTHREAD_LIBS=
fi fi
AC_SUBST(THREAD_SUPPORT) AC_SUBST(THREAD_SUPPORT)
AC_SUBST(THREAD_CPPFLAGS) AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(THREAD_LIBS) AC_SUBST(PTHREAD_LIBS)
# This test makes sure that run tests work at all. Sometimes a shared # This test makes sure that run tests work at all. Sometimes a shared
......
# -*-makefile-*- # -*-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, # All PostgreSQL makefiles include this file and use the variables it sets,
...@@ -147,9 +147,8 @@ TK_LIBS = @TK_LIBS@ ...@@ -147,9 +147,8 @@ TK_LIBS = @TK_LIBS@
TK_LIB_SPEC = @TK_LIB_SPEC@ TK_LIB_SPEC = @TK_LIB_SPEC@
TK_XINCLUDES = @TK_XINCLUDES@ TK_XINCLUDES = @TK_XINCLUDES@
THREAD_SUPPORT = @THREAD_SUPPORT@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
THREAD_CPPFLAGS = @THREAD_CPPFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@
THREAD_LIBS = @THREAD_LIBS@
have_docbook = @have_docbook@ have_docbook = @have_docbook@
DOCBOOKSTYLE = @DOCBOOKSTYLE@ DOCBOOKSTYLE = @DOCBOOKSTYLE@
......
...@@ -43,15 +43,9 @@ ...@@ -43,15 +43,9 @@
(--enable-thread-safety) */ (--enable-thread-safety) */
#undef 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. */ /* Define to 1 if getpwuid_r() takes a 5th argument. */
#undef GETPWUID_R_5ARG #undef GETPWUID_R_5ARG
/* Define if getpwuid is not thread safe */
#undef GETPWUID_THREADSAFE
/* Define to 1 if gettimeofday() takes only 1 argument. */ /* Define to 1 if gettimeofday() takes only 1 argument. */
#undef GETTIMEOFDAY_1ARG #undef GETTIMEOFDAY_1ARG
...@@ -324,6 +318,9 @@ ...@@ -324,6 +318,9 @@
/* Define to 1 if the PS_STRINGS thing exists. */ /* Define to 1 if the PS_STRINGS thing exists. */
#undef HAVE_PS_STRINGS #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. */ /* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H #undef HAVE_PWD_H
...@@ -588,15 +585,16 @@ ...@@ -588,15 +585,16 @@
/* A string containing the version number, platform, and C compiler */ /* A string containing the version number, platform, and C compiler */
#undef PG_VERSION_STR #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. */ /* The size of a `unsigned long', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG #undef SIZEOF_UNSIGNED_LONG
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS #undef STDC_HEADERS
/* Define if strerror is not thread safe */
#undef STRERROR_THREADSAFE
/* Define to 1 if your <sys/time.h> declares `struct tm'. */ /* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME #undef TM_IN_SYS_TIME
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # 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 ...@@ -16,9 +16,9 @@ NAME= ecpg_compat
SO_MAJOR_VERSION= 1 SO_MAJOR_VERSION= 1
SO_MINOR_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) \ 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 OBJS= informix.o
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # 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 ...@@ -16,13 +16,13 @@ NAME= ecpg
SO_MAJOR_VERSION= 4 SO_MAJOR_VERSION= 4
SO_MINOR_VERSION= 2 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 \ OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
connect.o misc.o connect.o misc.o
SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) \ 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 all: all-lib
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # 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 ...@@ -16,7 +16,7 @@ NAME= pgtypes
SO_MAJOR_VERSION= 1 SO_MAJOR_VERSION= 1
SO_MINOR_VERSION= 2 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 SHLIB_LINK += -lm
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \ OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \
......
# $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 subdir = src/interfaces/ecpg/preproc
top_builddir = ../../../.. top_builddir = ../../../..
...@@ -8,7 +8,7 @@ MAJOR_VERSION=3 ...@@ -8,7 +8,7 @@ MAJOR_VERSION=3
MINOR_VERSION=2 MINOR_VERSION=2
PATCHLEVEL=0 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) \ -DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \ -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
-DINCLUDEDIR=\"$(includedir)\" \ -DINCLUDEDIR=\"$(includedir)\" \
...@@ -25,7 +25,7 @@ OBJS=preproc.o type.o ecpg.o ecpg_keywords.o output.o\ ...@@ -25,7 +25,7 @@ OBJS=preproc.o type.o ecpg.o ecpg_keywords.o output.o\
all: submake-libpgport ecpg all: submake-libpgport ecpg
ecpg: $(OBJS) ecpg: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(THREAD_LIBS) -o $@ $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) $(PTHREAD_LIBS) -o $@
# pgc is compiled as part of preproc # pgc is compiled as part of preproc
preproc.o: $(srcdir)/pgc.c preproc.o: $(srcdir)/pgc.c
......
# $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 subdir = src/interfaces/ecpg/test
top_builddir = ../../../.. top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global 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 ECPG = ../preproc/ecpg -I$(srcdir)/../include
...@@ -16,10 +16,10 @@ endif ...@@ -16,10 +16,10 @@ endif
all: $(TESTS) all: $(TESTS)
%: %.o %: %.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 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 %.c: %.pgc
$(ECPG) $< $(ECPG) $<
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # 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 ...@@ -18,7 +18,7 @@ NAME= pq
SO_MAJOR_VERSION= 3 SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 2 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 \ 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 \ fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
...@@ -32,7 +32,7 @@ endif ...@@ -32,7 +32,7 @@ endif
# Add libraries that libpq depends (or might depend) on into the # Add libraries that libpq depends (or might depend) on into the
# shared library link. (The order in which you list them here doesn't # shared library link. (The order in which you list them here doesn't
# matter.) # 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) ifeq ($(PORTNAME), win32)
SHLIB_LINK += -lwsock32 -lws2_32 SHLIB_LINK += -lwsock32 -lws2_32
endif endif
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# with broken/missing library files. # with broken/missing library files.
# IDENTIFICATION # 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) ...@@ -23,7 +23,7 @@ libpgport.a: $(LIBOBJS)
$(AR) $(AROPT) $@ $^ $(AR) $(AROPT) $@ $^
thread.o: thread.c thread.o: thread.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(THREAD_CPPFLAGS) -c $< $(CC) $(CFLAGS) $(CPPFLAGS) $(PTHREAD_CFLAGS) -c $<
clean distclean maintainer-clean: clean distclean maintainer-clean:
rm -f libpgport.a $(LIBOBJS) rm -f libpgport.a $(LIBOBJS)
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * 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) ...@@ -76,10 +76,6 @@ pqStrerror(int errnum, char *strerrbuf, size_t buflen)
#else #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 */ /* no strerror_r() available, just use strerror */
StrNCpy(strerrbuf, strerror(errnum), buflen); StrNCpy(strerrbuf, strerror(errnum), buflen);
...@@ -111,10 +107,6 @@ pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer, ...@@ -111,10 +107,6 @@ pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
#else #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() */ /* no getpwuid_r() available, just use getpwuid() */
*result = getpwuid(uid); *result = getpwuid(uid);
#endif #endif
...@@ -146,10 +138,6 @@ pqGethostbyname(const char *name, ...@@ -146,10 +138,6 @@ pqGethostbyname(const char *name,
#else #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() */ /* no gethostbyname_r(), just use gethostbyname() */
*result = gethostbyname(name); *result = gethostbyname(name);
......
case $host_os in case $host_os in
bsdi2.0 | bsdi2.1 | bsdi3*) CC=gcc2;; bsdi2.0 | bsdi2.1 | bsdi3*) CC=gcc2;;
esac esac
THREAD_SUPPORT=yes
# verified 4.3.1 2004-02-11
STRERROR_THREADSAFE=yes
GETPWUID_THREADSAFE=yes
GETHOSTBYNAME_THREADSAFE=yes
...@@ -5,12 +5,5 @@ CC="$CC -no-cpp-precomp" ...@@ -5,12 +5,5 @@ CC="$CC -no-cpp-precomp"
# Select appropriate semaphore support # Select appropriate semaphore support
USE_NAMED_POSIX_SEMAPHORES=1 USE_NAMED_POSIX_SEMAPHORES=1
THREAD_SUPPORT=yes
# verified Mac OS X 10.3.3, Darwin Kernel Version 7.3.0, 2004-04-07 # 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" PTHREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread"
STRERROR_THREADSAFE=yes
GETPWUID_THREADSAFE=yes
GETHOSTBYNAME_THREADSAFE=yes
...@@ -2,9 +2,7 @@ case $host_cpu in ...@@ -2,9 +2,7 @@ case $host_cpu in
alpha*) CFLAGS="-O";; # alpha has problems with -O2 alpha*) CFLAGS="-O";; # alpha has problems with -O2
esac esac
# tools/thread/thread_test must be run
THREAD_CPPFLAGS="-D_THREAD_SAFE"
case $host_os in case $host_os in
freebsd2*|freebsd3*|freebsd4*) THREAD_LIBS="-pthread";; freebsd2*|freebsd3*|freebsd4*) ;;
*) THREAD_LIBS="-lc_r";; *) THREAD_LIBS="c_r";; # do we need this? 2004-04-23
esac esac
...@@ -2,12 +2,4 @@ ...@@ -2,12 +2,4 @@
CPPFLAGS="-D_GNU_SOURCE" CPPFLAGS="-D_GNU_SOURCE"
# tools/thread/thread_test must be run # tools/thread/thread_test must be run
THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS" PTHREAD_CFLAGS="-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
# tools/thread/thread_test must be run # tools/thread/thread_test must be run
case $build in
*-netbsdelf[2-9]*) THREAD_CPPFLAGS="-pthread"; THREAD_LIBS="-pthread" ;;
esac
...@@ -2,10 +2,3 @@ if test "$GCC" != yes ; then ...@@ -2,10 +2,3 @@ if test "$GCC" != yes ; then
CC="$CC -std" CC="$CC -std"
CFLAGS="-O -ieee" CFLAGS="-O -ieee"
fi fi
# tools/thread/thread_test must be run
if test "$GCC" = yes
then THREAD_LIBS="-pthread"
else THREAD_CPPFLAGS="-pthread"
THREAD_LIBS="-lpthread"
fi
...@@ -9,10 +9,5 @@ case $host in ...@@ -9,10 +9,5 @@ case $host in
i?86-*-solaris*) need_tas=yes; tas_file=solaris_i386.s ;; i?86-*-solaris*) need_tas=yes; tas_file=solaris_i386.s ;;
esac esac
# tools/thread/thread_test must be run
# -D_POSIX_PTHREAD_SEMANTICS enables 5-arg getpwuid_r, among other things # -D_POSIX_PTHREAD_SEMANTICS enables 5-arg getpwuid_r, among other things
THREAD_CPPFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS" PTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
if test "$GCC" != yes
then THREAD_CPPFLAGS="$THREAD_CPPFLAGS -mt"
fi
THREAD_LIBS="-lpthread"
if test "$GCC" = yes; then if test "$GCC" = yes; then
THREAD_CPPFLAGS="-pthread" PTHREAD_CFLAGS="-pthread"
else else
# The -Kno_host is for a bug in the compiler. See -hackers # The -Kno_host is for a bug in the compiler. See -hackers
# discussion on 7-8/Aug/2003. # discussion on 7-8/Aug/2003.
...@@ -21,17 +21,11 @@ __EOF__ ...@@ -21,17 +21,11 @@ __EOF__
fi fi
rm -f conftest.* rm -f conftest.*
THREAD_CPPFLAGS="-K pthread" PTHREAD_CFLAGS="-Kpthread"
fi fi
# tools/thread/thread_test must be run # 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. # Disabled because flags are required for all apps using libpq.
# Waiting to see if other platforms need this too. 2004-03-22 # 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
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (C) 2003 by PostgreSQL Global Development Team # 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), ) ...@@ -19,9 +19,9 @@ ifeq ($(THREAD_SUPPORT), )
$(error You have not configured your template/$$port file. See the README) $(error You have not configured your template/$$port file. See the README)
endif endif
override CFLAGS += $(THREAD_CPPFLAGS) override CFLAGS += $(PTHREAD_CFLAGS)
LDFLAGS += $(THREAD_LIBS) LDFLAGS += $(PTHREAD_LIBS)
all: thread_test all: thread_test
......
...@@ -6,9 +6,11 @@ thread-safe, or if we should use *_r functions or thread locking. ...@@ -6,9 +6,11 @@ thread-safe, or if we should use *_r functions or thread locking.
To use this program, you must: 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 run "configure --enable-thread-safety"
o compile the main source tree o compile the main source tree
o compile and run this program 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.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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 * This program tests to see if your standard libc functions use
* pthread_setspecific()/pthread_getspecific() to be thread-safe. * pthread_setspecific()/pthread_getspecific() to be thread-safe.
...@@ -78,7 +78,7 @@ int main(int argc, char *argv[]) ...@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
} }
printf("\ 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" defines to your template/$port file before compiling this program.\n\n"
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment