and improve tests.
fi
else
# do not use values from template file
-THREAD_CFLAGS=
+THREAD_CPPFLAGS=
THREAD_LIBS=
fi
if test "$enable_thread_safety" = yes -a "$NEED_REENTRANT_FUNCS" = yes ; then
_CFLAGS="$CFLAGS"
_LIBS="$LIBS"
-CFLAGS="$CFLAGS $THREAD_CFLAGS"
+CFLAGS="$CFLAGS $THREAD_CPPFLAGS"
LIBS="$LIBS $THREAD_LIBS"
s,@python_libspec@,$python_libspec,;t t
s,@LIBOBJS@,$LIBOBJS,;t t
s,@HAVE_IPV6@,$HAVE_IPV6,;t t
-s,@THREAD_CFLAGS@,$THREAD_CFLAGS,;t t
+s,@THREAD_CPPFLAGS@,$THREAD_CPPFLAGS,;t t
s,@THREAD_LIBS@,$THREAD_LIBS,;t t
s,@HAVE_POSIX_SIGNALS@,$HAVE_POSIX_SIGNALS,;t t
s,@MSGFMT@,$MSGFMT,;t t
\dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.290 2003/09/15 14:32:35 pgsql Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.291 2003/09/27 15:32:47 momjian Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
fi
else
# do not use values from template file
-THREAD_CFLAGS=
+THREAD_CPPFLAGS=
THREAD_LIBS=
fi
-AC_SUBST(THREAD_CFLAGS)
+AC_SUBST(THREAD_CPPFLAGS)
AC_SUBST(THREAD_LIBS)
if test "$enable_thread_safety" = yes -a "$NEED_REENTRANT_FUNCS" = yes ; then
_CFLAGS="$CFLAGS"
_LIBS="$LIBS"
-CFLAGS="$CFLAGS $THREAD_CFLAGS"
+CFLAGS="$CFLAGS $THREAD_CPPFLAGS"
LIBS="$LIBS $THREAD_LIBS"
AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
CFLAGS="$_CFLAGS"
# -*-makefile-*-
-# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.168 2003/09/07 03:36:02 tgl Exp $
+# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.169 2003/09/27 15:32:47 momjian Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
TK_LIB_SPEC = @TK_LIB_SPEC@
TK_XINCLUDES = @TK_XINCLUDES@
-THREAD_CFLAGS = @THREAD_CFLAGS@
+THREAD_CPPFLAGS = @THREAD_CPPFLAGS@
THREAD_LIBS = @THREAD_LIBS@
have_docbook = @have_docbook@
#
# Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.8 2003/08/06 02:19:48 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.9 2003/09/27 15:32:47 momjian Exp $
#
#-------------------------------------------------------------------------
SO_MAJOR_VERSION= 1
SO_MINOR_VERSION= 0
-override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CFLAGS)
+override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CPPFLAGS)
SHLIB_LINK = -L../pgtypeslib -lpgtypes -L../ecpglib -lecpg $(THREAD_LIBS)
OBJS= informix.o
#
# Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.7 2003/08/01 16:18:04 petere Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.8 2003/09/27 15:32:47 momjian Exp $
#
#-------------------------------------------------------------------------
SO_MAJOR_VERSION= 4
SO_MINOR_VERSION= 0
-override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CFLAGS)
+override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS)
OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
connect.o misc.o
#
# Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.11 2003/08/07 04:03:18 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.12 2003/09/27 15:32:47 momjian Exp $
#
#-------------------------------------------------------------------------
SO_MAJOR_VERSION= 1
SO_MINOR_VERSION= 0
-override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CFLAGS) -g
+override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CPPFLAGS) -g
SHLIB_LINK += -lm
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \
-# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.93 2003/08/06 02:19:51 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.94 2003/09/27 15:32:48 momjian Exp $
subdir = src/interfaces/ecpg/preproc
top_builddir = ../../../..
MINOR_VERSION=0
PATCHLEVEL=0
-override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) $(THREAD_CFLAGS) \
+override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS) \
-DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
-DINCLUDE_PATH=\"$(includedir)\"
-# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.40 2003/08/06 02:19:51 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.41 2003/09/27 15:32:48 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_CFLAGS)
+override CPPFLAGS := -I$(srcdir)/../include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS)
ECPG = ../preproc/ecpg -I$(srcdir)/../include
#
# Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.93 2003/09/07 03:43:57 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.94 2003/09/27 15:32:48 momjian Exp $
#
#-------------------------------------------------------------------------
SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 1
-override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) $(THREAD_CFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"'
+override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS) -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 \
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.30 2003/09/05 02:08:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.31 2003/09/27 15:32:48 momjian Exp $
*
* NOTES
* The client *requires* a valid server certificate. Since
struct hostent hpstr;
char buf[BUFSIZ];
int herrno = 0;
-
+
+ /*
+ * Currently, pqGethostbyname() is used only on platforms that
+ * don't have getaddrinfo(). If you enable this function,
+ * you should convert the pqGethostbyname() function call to
+ * use getaddrinfo().
+ */
pqGethostbyname(conn->peer_cn, &hpstr, buf, sizeof(buf),
&h, &herrno);
}
# with broken/missing library files.
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/port/Makefile,v 1.6 2003/08/13 03:12:04 momjian Exp $
+# $Header: /cvsroot/pgsql/src/port/Makefile,v 1.7 2003/09/27 15:32:48 momjian Exp $
#
#-------------------------------------------------------------------------
$(AR) crs $@ $^
thread.o: thread.c
- $(CC) $(CFLAGS) $(CPPFLAGS) $(THREAD_CFLAGS) -c $<
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(THREAD_CPPFLAGS) -c $<
clean distclean maintainer-clean:
rm -f libpgport.a $(LIBOBJS)
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
- * $Id: thread.c,v 1.8 2003/09/15 02:30:29 momjian Exp $
+ * $Id: thread.c,v 1.9 2003/09/27 15:32:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* Wrapper around gethostbyname() or gethostbyname_r() to mimic
* POSIX gethostbyname_r() behaviour, if it is not available or required.
+ * This function is called _only_ by our getaddinfo() portability function.
*/
+#ifndef HAVE_GETADDRINFO
int
pqGethostbyname(const char *name,
struct hostent *resultbuf,
for (i = 0; (*result)->h_aliases[i]; i++, pointers++)
len += (*result)->h_length;
- if (MAXALIGN(len) + pointers * sizeof(char *) + strlen((*result)->h_name) + 1 <= buflen)
+ if (pointers * sizeof(char *) + MAXALIGN(len) + strlen((*result)->h_name) + 1 <= buflen)
{
memcpy(resultbuf, *result, sizeof(struct hostent));
pbuffer++;
/* Place at end for cleaner alignment */
+ buffer = MAXALIGN(buffer);
strcpy(buffer, (*result)->h_name);
resultbuf->h_name = buffer;
buffer += strlen(resultbuf->h_name) + 1;
return -1;
#endif
}
+#endif
esac
SUPPORTS_THREADS=yes
-NEED_REENTRANT_FUNCS=no # verified 4.3 2003-09-03
+NEED_REENTRANT_FUNCS=no # verified 4.3 2003-09-26
SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNCS=yes # 4.8, 5.1 2003-09-12
+THREAD_CPPFLAGS="-D_THREAD_SAFE"
case $host_os in
freebsd2*|freebsd3*|freebsd4*)
- THREAD_CFLAGS="-pthread"
+ THREAD_LIBS="-pthread"
;;
*)
THREAD_LIBS="-lc_r"
SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNCS=yes # verified glibc 2.1 2003-09-03
-THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
+THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread"
SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNCS=no # 4.0 2003-09-13
-THREAD_CFLAGS="-pthread"
+THREAD_LIBS="-pthread"
SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNCS=yes # 5.6 2003-09-13
-THREAD_CFLAGS="-pthread"
+THREAD_LIBS="-pthread"
if test "$GCC" = yes; then
CFLAGS=-O2
- THREAD_CFLAGS="-pthread"
+ THREAD_CPPFLAGS="-pthread"
else
# the -Kno_host is temporary for a bug in the compiler. See -hackers
# discussion on 7-8/Aug/2003.
# when the 7.1.3UP3 or later compiler is out, we can do a version check.
CFLAGS='-O -Kinline,no_host'
- THREAD_CFLAGS="-K pthread"
+ THREAD_CPPFLAGS="-K pthread"
fi
SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNCS=no # verified 7.1.3 2003-09-03
-THREAD_CFLAGS="$THREAD_CFLAGS -D_REENTRANT"
+THREAD_CPPFLAGS="$THREAD_CPPFLAGS -D_REENTRANT"
--- /dev/null
+#-------------------------------------------------------------------------
+#
+# Makefile for tools/thread
+#
+# Copyright (C) 2003 by PostgreSQL Global Development Team
+#
+# $Header: /cvsroot/pgsql/src/tools/thread/Attic/Makefile,v 1.1 2003/09/27 15:32:48 momjian Exp $
+#
+#-------------------------------------------------------------------------
+
+subdir = tools/thread
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
+
+override CFLAGS += $(THREAD_CPPFLAGS)
+
+LDFLAGS += $(THREAD_LIBS)
+
+all: thread_test
+
+thread_test: thread_test.o
+ $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
+
+clean distclean maintainer-clean:
+ rm -f thread_test$(X) thread_test.o
--- /dev/null
+This program should be run by developers wishing to enable threading on
+new platforms.
+
+Run thread_test program to determine if your native libc functions are
+thread-safe, or if we should use *_r functions or thread locking.
+
+Make sure you have added any needed 'THREAD_CPPFLAGS' and 'THREAD_LIBS'
+defines to your template/${port} file before compiling this program.
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/tools/Attic/test_thread_funcs.c,v 1.3 2003/09/03 22:34:08 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/tools/thread/Attic/thread_test.c,v 1.1 2003/09/27 15:32:48 momjian Exp $
*
* This program tests to see if your standard libc functions use
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
* to see if the pointers are different for different threads. If they
* are, the function is thread-safe.
*
- * This program must be compiled with the thread flags required by your
- * operating system. See src/template for the appropriate flags, if any.
- *
*-------------------------------------------------------------------------
*/
void func_call_1(void);
void func_call_2(void);
+#ifndef HAVE_GETADDRINFO
struct hostent *hostent_p1;
struct hostent *hostent_p2;
+#endif
struct passwd *passwd_p1;
struct passwd *passwd_p2;
return 1;
}
+ printf("\
+Make sure you have added any needed 'THREAD_CPPFLAGS' and 'THREAD_LIBS'\n\
+defines to your template/${port} file before compiling this program.\n\n"
+);
pthread_create(&thread1, NULL, (void * (*)(void *)) func_call_1, NULL);
pthread_create(&thread2, NULL, (void * (*)(void *)) func_call_2, NULL);
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
+#ifndef HAVE_GETADDRINFO
if (hostent_p1 == hostent_p2)
printf("Your gethostbyname() is _not_ thread-safe\n");
+#endif
if (passwd_p1 == passwd_p2)
printf("Your getpwuid() is _not_ thread-safe\n");
if (strerror_p1 == strerror_p2)
printf("Your strerror() is _not_ thread-safe\n");
- if (hostent_p1 != hostent_p2 &&
+ if (
+#ifndef HAVE_GETADDRINFO
+ hostent_p1 != hostent_p2 &&
+#endif
passwd_p1 != passwd_p2 &&
strerror_p1 != strerror_p2)
- printf("Your functions are all thread-safe\n");
+ {
+ printf("All your non-*_r functions are thread-safe.\n");
+ printf("Add this to your template/${port} file:\n\n");
+ printf("\
+SUPPORTS_THREADS=yes\n\
+NEED_REENTRANT_FUNCS=no\n"
+ );
+ }
else
- printf("Your functions are _not_ all thread-safe\n");
+ {
+ printf("Not all non-*_r functions are thread-safe.\n");
+ printf("Add this to your template/${port} file:\n\n");
+ printf("\
+SUPPORTS_THREADS=yes\n\
+NEED_REENTRANT_FUNCS=yes\n"
+ );
+ }
return 0;
}
void func_call_1(void) {
void *p;
+#ifndef HAVE_GETADDRINFO
hostent_p1 = gethostbyname("yahoo.com");
p = gethostbyname("slashdot.org");
if (hostent_p1 != p)
printf("Your gethostbyname() changes the static memory area between calls\n");
hostent_p1 = NULL; /* force thread-safe failure report */
}
+#endif
passwd_p1 = getpwuid(0);
p = getpwuid(1);
void func_call_2(void) {
void *p;
+#ifndef HAVE_GETADDRINFO
hostent_p2 = gethostbyname("google.com");
p = gethostbyname("postgresql.org");
if (hostent_p2 != p)
printf("Your gethostbyname() changes the static memory area between calls\n");
hostent_p2 = NULL; /* force thread-safe failure report */
}
+#endif
passwd_p2 = getpwuid(2);
p = getpwuid(3);