aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.global.in4
-rw-r--r--src/interfaces/ecpg/compatlib/Makefile4
-rw-r--r--src/interfaces/ecpg/ecpglib/Makefile4
-rw-r--r--src/interfaces/ecpg/pgtypeslib/Makefile4
-rw-r--r--src/interfaces/ecpg/preproc/Makefile4
-rw-r--r--src/interfaces/ecpg/test/Makefile4
-rw-r--r--src/interfaces/libpq/Makefile4
-rw-r--r--src/interfaces/libpq/fe-secure.c10
-rw-r--r--src/port/Makefile4
-rw-r--r--src/port/thread.c8
-rw-r--r--src/template/bsdi2
-rw-r--r--src/template/freebsd3
-rw-r--r--src/template/linux2
-rw-r--r--src/template/osf2
-rw-r--r--src/template/solaris2
-rw-r--r--src/template/unixware6
-rw-r--r--src/tools/thread/Makefile25
-rw-r--r--src/tools/thread/README8
-rw-r--r--src/tools/thread/thread_test.c (renamed from src/tools/test_thread_funcs.c)40
19 files changed, 105 insertions, 35 deletions
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 1be4bc0a831..b4b2abb50eb 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -1,5 +1,5 @@
# -*-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,
@@ -150,7 +150,7 @@ TK_LIBS = @TK_LIBS@
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@
diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile
index 73bf3389a19..cd05452aeae 100644
--- a/src/interfaces/ecpg/compatlib/Makefile
+++ b/src/interfaces/ecpg/compatlib/Makefile
@@ -4,7 +4,7 @@
#
# 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 $
#
#-------------------------------------------------------------------------
@@ -16,7 +16,7 @@ NAME= ecpg_compat
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
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index bda52dc7dc9..75fcfc90236 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -4,7 +4,7 @@
#
# 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 $
#
#-------------------------------------------------------------------------
@@ -16,7 +16,7 @@ NAME= ecpg
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
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index 790d87a660b..71100084b1e 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -4,7 +4,7 @@
#
# 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 $
#
#-------------------------------------------------------------------------
@@ -16,7 +16,7 @@ NAME= pgtypes
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 \
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 9fe25529885..1238f809d13 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -1,4 +1,4 @@
-# $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 = ../../../..
@@ -8,7 +8,7 @@ MAJOR_VERSION=3
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)\"
diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile
index ce875428469..7f6835498da 100644
--- a/src/interfaces/ecpg/test/Makefile
+++ b/src/interfaces/ecpg/test/Makefile
@@ -1,10 +1,10 @@
-# $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
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 1f7fc77fdd3..90a7f8c634d 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -4,7 +4,7 @@
#
# 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 $
#
#-------------------------------------------------------------------------
@@ -18,7 +18,7 @@ NAME= pq
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 \
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
index 9a2ac486989..e9620d03a4c 100644
--- a/src/interfaces/libpq/fe-secure.c
+++ b/src/interfaces/libpq/fe-secure.c
@@ -11,7 +11,7 @@
*
*
* 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
@@ -469,7 +469,13 @@ verify_peer(PGconn *conn)
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);
}
diff --git a/src/port/Makefile b/src/port/Makefile
index 740c58657ed..5d06432e2d2 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -7,7 +7,7 @@
# 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 $
#
#-------------------------------------------------------------------------
@@ -23,7 +23,7 @@ libpgport.a: $(LIBOBJS)
$(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)
diff --git a/src/port/thread.c b/src/port/thread.c
index bfc315cc0e4..19b12fe0ba6 100644
--- a/src/port/thread.c
+++ b/src/port/thread.c
@@ -7,7 +7,7 @@
*
* 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 $
*
*-------------------------------------------------------------------------
*/
@@ -165,7 +165,9 @@ pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
/*
* 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,
@@ -213,7 +215,7 @@ pqGethostbyname(const char *name,
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));
@@ -242,6 +244,7 @@ pqGethostbyname(const char *name,
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;
@@ -269,3 +272,4 @@ pqGethostbyname(const char *name,
return -1;
#endif
}
+#endif
diff --git a/src/template/bsdi b/src/template/bsdi
index d6b16a2417d..a5996a5402d 100644
--- a/src/template/bsdi
+++ b/src/template/bsdi
@@ -11,4 +11,4 @@ case $host_os in
esac
SUPPORTS_THREADS=yes
-NEED_REENTRANT_FUNCS=no # verified 4.3 2003-09-03
+NEED_REENTRANT_FUNCS=no # verified 4.3 2003-09-26
diff --git a/src/template/freebsd b/src/template/freebsd
index 71e50140660..0711a83212c 100644
--- a/src/template/freebsd
+++ b/src/template/freebsd
@@ -7,9 +7,10 @@ esac
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"
diff --git a/src/template/linux b/src/template/linux
index 2c4f393e75a..a690b44968c 100644
--- a/src/template/linux
+++ b/src/template/linux
@@ -4,6 +4,6 @@ CPPFLAGS="-D_GNU_SOURCE"
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"
diff --git a/src/template/osf b/src/template/osf
index 7305395a0b2..0856f5c8981 100644
--- a/src/template/osf
+++ b/src/template/osf
@@ -7,4 +7,4 @@ fi
SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNCS=no # 4.0 2003-09-13
-THREAD_CFLAGS="-pthread"
+THREAD_LIBS="-pthread"
diff --git a/src/template/solaris b/src/template/solaris
index d839f935ccb..b333f006602 100644
--- a/src/template/solaris
+++ b/src/template/solaris
@@ -7,5 +7,5 @@ fi
SUPPORTS_THREADS=yes
NEED_REENTRANT_FUNCS=yes # 5.6 2003-09-13
-THREAD_CFLAGS="-pthread"
+THREAD_LIBS="-pthread"
diff --git a/src/template/unixware b/src/template/unixware
index 21d4314d87d..a228fa56ef8 100644
--- a/src/template/unixware
+++ b/src/template/unixware
@@ -1,14 +1,14 @@
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"
diff --git a/src/tools/thread/Makefile b/src/tools/thread/Makefile
new file mode 100644
index 00000000000..ed5be7f5c77
--- /dev/null
+++ b/src/tools/thread/Makefile
@@ -0,0 +1,25 @@
+#-------------------------------------------------------------------------
+#
+# 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
diff --git a/src/tools/thread/README b/src/tools/thread/README
new file mode 100644
index 00000000000..f17e59248fd
--- /dev/null
+++ b/src/tools/thread/README
@@ -0,0 +1,8 @@
+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.
diff --git a/src/tools/test_thread_funcs.c b/src/tools/thread/thread_test.c
index 6fc781a2b64..7beb63dff4a 100644
--- a/src/tools/test_thread_funcs.c
+++ b/src/tools/thread/thread_test.c
@@ -6,7 +6,7 @@
* 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.
@@ -17,9 +17,6 @@
* 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.
- *
*-------------------------------------------------------------------------
*/
@@ -37,8 +34,10 @@
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;
@@ -57,24 +56,47 @@ int main(int argc, char *argv[])
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;
}
@@ -82,6 +104,7 @@ int main(int argc, char *argv[])
void func_call_1(void) {
void *p;
+#ifndef HAVE_GETADDRINFO
hostent_p1 = gethostbyname("yahoo.com");
p = gethostbyname("slashdot.org");
if (hostent_p1 != p)
@@ -89,6 +112,7 @@ void func_call_1(void) {
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);
@@ -109,6 +133,7 @@ void func_call_1(void) {
void func_call_2(void) {
void *p;
+#ifndef HAVE_GETADDRINFO
hostent_p2 = gethostbyname("google.com");
p = gethostbyname("postgresql.org");
if (hostent_p2 != p)
@@ -116,6 +141,7 @@ void func_call_2(void) {
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);