Skip to content

Commit 227dd9b

Browse files
committed
Rename thread compile flag. Move thread test program to tools/thread,
and improve tests.
1 parent fae2ade commit 227dd9b

File tree

21 files changed

+112
-42
lines changed

21 files changed

+112
-42
lines changed

configure

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13292,7 +13292,7 @@ See the comment at the top of src/port/thread.c for more information.
1329213292
fi
1329313293
else
1329413294
# do not use values from template file
13295-
THREAD_CFLAGS=
13295+
THREAD_CPPFLAGS=
1329613296
THREAD_LIBS=
1329713297
fi
1329813298

@@ -13312,7 +13312,7 @@ fi
1331213312
if test "$enable_thread_safety" = yes -a "$NEED_REENTRANT_FUNCS" = yes ; then
1331313313
_CFLAGS="$CFLAGS"
1331413314
_LIBS="$LIBS"
13315-
CFLAGS="$CFLAGS $THREAD_CFLAGS"
13315+
CFLAGS="$CFLAGS $THREAD_CPPFLAGS"
1331613316
LIBS="$LIBS $THREAD_LIBS"
1331713317

1331813318

@@ -18211,7 +18211,7 @@ s,@python_includespec@,$python_includespec,;t t
1821118211
s,@python_libspec@,$python_libspec,;t t
1821218212
s,@LIBOBJS@,$LIBOBJS,;t t
1821318213
s,@HAVE_IPV6@,$HAVE_IPV6,;t t
18214-
s,@THREAD_CFLAGS@,$THREAD_CFLAGS,;t t
18214+
s,@THREAD_CPPFLAGS@,$THREAD_CPPFLAGS,;t t
1821518215
s,@THREAD_LIBS@,$THREAD_LIBS,;t t
1821618216
s,@HAVE_POSIX_SIGNALS@,$HAVE_POSIX_SIGNALS,;t t
1821718217
s,@MSGFMT@,$MSGFMT,;t t

configure.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
\dnl Process this file with autoconf to produce a configure script.
2-
dnl $Header: /cvsroot/pgsql/configure.in,v 1.290 2003/09/15 14:32:35 pgsql Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.291 2003/09/27 15:32:47 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1013,10 +1013,10 @@ See the comment at the top of src/port/thread.c for more information.
10131013
fi
10141014
else
10151015
# do not use values from template file
1016-
THREAD_CFLAGS=
1016+
THREAD_CPPFLAGS=
10171017
THREAD_LIBS=
10181018
fi
1019-
AC_SUBST(THREAD_CFLAGS)
1019+
AC_SUBST(THREAD_CPPFLAGS)
10201020
AC_SUBST(THREAD_LIBS)
10211021

10221022

@@ -1033,7 +1033,7 @@ AC_SUBST(THREAD_LIBS)
10331033
if test "$enable_thread_safety" = yes -a "$NEED_REENTRANT_FUNCS" = yes ; then
10341034
_CFLAGS="$CFLAGS"
10351035
_LIBS="$LIBS"
1036-
CFLAGS="$CFLAGS $THREAD_CFLAGS"
1036+
CFLAGS="$CFLAGS $THREAD_CPPFLAGS"
10371037
LIBS="$LIBS $THREAD_LIBS"
10381038
AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
10391039
CFLAGS="$_CFLAGS"

src/Makefile.global.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.168 2003/09/07 03:36:02 tgl Exp $
2+
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.169 2003/09/27 15:32:47 momjian Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -150,7 +150,7 @@ TK_LIBS = @TK_LIBS@
150150
TK_LIB_SPEC = @TK_LIB_SPEC@
151151
TK_XINCLUDES = @TK_XINCLUDES@
152152

153-
THREAD_CFLAGS = @THREAD_CFLAGS@
153+
THREAD_CPPFLAGS = @THREAD_CPPFLAGS@
154154
THREAD_LIBS = @THREAD_LIBS@
155155

156156
have_docbook = @have_docbook@

src/interfaces/ecpg/compatlib/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.8 2003/08/06 02:19:48 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.9 2003/09/27 15:32:47 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -16,7 +16,7 @@ NAME= ecpg_compat
1616
SO_MAJOR_VERSION= 1
1717
SO_MINOR_VERSION= 0
1818

19-
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CFLAGS)
19+
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CPPFLAGS)
2020
SHLIB_LINK = -L../pgtypeslib -lpgtypes -L../ecpglib -lecpg $(THREAD_LIBS)
2121

2222
OBJS= informix.o

src/interfaces/ecpg/ecpglib/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.7 2003/08/01 16:18:04 petere Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.8 2003/09/27 15:32:47 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -16,7 +16,7 @@ NAME= ecpg
1616
SO_MAJOR_VERSION= 4
1717
SO_MINOR_VERSION= 0
1818

19-
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CFLAGS)
19+
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS)
2020

2121
OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
2222
connect.o misc.o

src/interfaces/ecpg/pgtypeslib/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.11 2003/08/07 04:03:18 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/Makefile,v 1.12 2003/09/27 15:32:47 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -16,7 +16,7 @@ NAME= pgtypes
1616
SO_MAJOR_VERSION= 1
1717
SO_MINOR_VERSION= 0
1818

19-
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CFLAGS) -g
19+
override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CPPFLAGS) -g
2020
SHLIB_LINK += -lm
2121

2222
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \

src/interfaces/ecpg/preproc/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.93 2003/08/06 02:19:51 momjian Exp $
1+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.94 2003/09/27 15:32:48 momjian Exp $
22

33
subdir = src/interfaces/ecpg/preproc
44
top_builddir = ../../../..
@@ -8,7 +8,7 @@ MAJOR_VERSION=3
88
MINOR_VERSION=0
99
PATCHLEVEL=0
1010

11-
override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) $(THREAD_CFLAGS) \
11+
override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS) \
1212
-DMAJOR_VERSION=$(MAJOR_VERSION) \
1313
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
1414
-DINCLUDE_PATH=\"$(includedir)\"

src/interfaces/ecpg/test/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.40 2003/08/06 02:19:51 momjian Exp $
1+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.41 2003/09/27 15:32:48 momjian Exp $
22

33
subdir = src/interfaces/ecpg/test
44
top_builddir = ../../../..
55
include $(top_builddir)/src/Makefile.global
66

7-
override CPPFLAGS := -I$(srcdir)/../include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CFLAGS)
7+
override CPPFLAGS := -I$(srcdir)/../include -I$(libpq_srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS)
88

99
ECPG = ../preproc/ecpg -I$(srcdir)/../include
1010

src/interfaces/libpq/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.93 2003/09/07 03:43:57 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.94 2003/09/27 15:32:48 momjian Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -18,7 +18,7 @@ NAME= pq
1818
SO_MAJOR_VERSION= 3
1919
SO_MINOR_VERSION= 1
2020

21-
override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) $(THREAD_CFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"'
21+
override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"'
2222

2323
OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
2424
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \

src/interfaces/libpq/fe-secure.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.30 2003/09/05 02:08:36 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.31 2003/09/27 15:32:48 momjian Exp $
1515
*
1616
* NOTES
1717
* The client *requires* a valid server certificate. Since
@@ -469,7 +469,13 @@ verify_peer(PGconn *conn)
469469
struct hostent hpstr;
470470
char buf[BUFSIZ];
471471
int herrno = 0;
472-
472+
473+
/*
474+
* Currently, pqGethostbyname() is used only on platforms that
475+
* don't have getaddrinfo(). If you enable this function,
476+
* you should convert the pqGethostbyname() function call to
477+
* use getaddrinfo().
478+
*/
473479
pqGethostbyname(conn->peer_cn, &hpstr, buf, sizeof(buf),
474480
&h, &herrno);
475481
}

src/port/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# with broken/missing library files.
88

99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/port/Makefile,v 1.6 2003/08/13 03:12:04 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/port/Makefile,v 1.7 2003/09/27 15:32:48 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -23,7 +23,7 @@ libpgport.a: $(LIBOBJS)
2323
$(AR) crs $@ $^
2424

2525
thread.o: thread.c
26-
$(CC) $(CFLAGS) $(CPPFLAGS) $(THREAD_CFLAGS) -c $<
26+
$(CC) $(CFLAGS) $(CPPFLAGS) $(THREAD_CPPFLAGS) -c $<
2727

2828
clean distclean maintainer-clean:
2929
rm -f libpgport.a $(LIBOBJS)

src/port/thread.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
99
*
10-
* $Id: thread.c,v 1.8 2003/09/15 02:30:29 momjian Exp $
10+
* $Id: thread.c,v 1.9 2003/09/27 15:32:48 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -165,7 +165,9 @@ pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
165165
/*
166166
* Wrapper around gethostbyname() or gethostbyname_r() to mimic
167167
* POSIX gethostbyname_r() behaviour, if it is not available or required.
168+
* This function is called _only_ by our getaddinfo() portability function.
168169
*/
170+
#ifndef HAVE_GETADDRINFO
169171
int
170172
pqGethostbyname(const char *name,
171173
struct hostent *resultbuf,
@@ -213,7 +215,7 @@ pqGethostbyname(const char *name,
213215
for (i = 0; (*result)->h_aliases[i]; i++, pointers++)
214216
len += (*result)->h_length;
215217

216-
if (MAXALIGN(len) + pointers * sizeof(char *) + strlen((*result)->h_name) + 1 <= buflen)
218+
if (pointers * sizeof(char *) + MAXALIGN(len) + strlen((*result)->h_name) + 1 <= buflen)
217219
{
218220
memcpy(resultbuf, *result, sizeof(struct hostent));
219221

@@ -242,6 +244,7 @@ pqGethostbyname(const char *name,
242244
pbuffer++;
243245

244246
/* Place at end for cleaner alignment */
247+
buffer = MAXALIGN(buffer);
245248
strcpy(buffer, (*result)->h_name);
246249
resultbuf->h_name = buffer;
247250
buffer += strlen(resultbuf->h_name) + 1;
@@ -269,3 +272,4 @@ pqGethostbyname(const char *name,
269272
return -1;
270273
#endif
271274
}
275+
#endif

src/template/bsdi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ case $host_os in
1111
esac
1212

1313
SUPPORTS_THREADS=yes
14-
NEED_REENTRANT_FUNCS=no # verified 4.3 2003-09-03
14+
NEED_REENTRANT_FUNCS=no # verified 4.3 2003-09-26

src/template/freebsd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ esac
77
SUPPORTS_THREADS=yes
88
NEED_REENTRANT_FUNCS=yes # 4.8, 5.1 2003-09-12
99

10+
THREAD_CPPFLAGS="-D_THREAD_SAFE"
1011
case $host_os in
1112
freebsd2*|freebsd3*|freebsd4*)
12-
THREAD_CFLAGS="-pthread"
13+
THREAD_LIBS="-pthread"
1314
;;
1415
*)
1516
THREAD_LIBS="-lc_r"

src/template/linux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ CPPFLAGS="-D_GNU_SOURCE"
44

55
SUPPORTS_THREADS=yes
66
NEED_REENTRANT_FUNCS=yes # verified glibc 2.1 2003-09-03
7-
THREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
7+
THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
88
THREAD_LIBS="-lpthread"
99

src/template/osf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ fi
77

88
SUPPORTS_THREADS=yes
99
NEED_REENTRANT_FUNCS=no # 4.0 2003-09-13
10-
THREAD_CFLAGS="-pthread"
10+
THREAD_LIBS="-pthread"

src/template/solaris

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ fi
77

88
SUPPORTS_THREADS=yes
99
NEED_REENTRANT_FUNCS=yes # 5.6 2003-09-13
10-
THREAD_CFLAGS="-pthread"
10+
THREAD_LIBS="-pthread"
1111

src/template/unixware

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
if test "$GCC" = yes; then
22
CFLAGS=-O2
3-
THREAD_CFLAGS="-pthread"
3+
THREAD_CPPFLAGS="-pthread"
44
else
55
# the -Kno_host is temporary for a bug in the compiler. See -hackers
66
# discussion on 7-8/Aug/2003.
77
# when the 7.1.3UP3 or later compiler is out, we can do a version check.
88
CFLAGS='-O -Kinline,no_host'
9-
THREAD_CFLAGS="-K pthread"
9+
THREAD_CPPFLAGS="-K pthread"
1010
fi
1111

1212
SUPPORTS_THREADS=yes
1313
NEED_REENTRANT_FUNCS=no # verified 7.1.3 2003-09-03
14-
THREAD_CFLAGS="$THREAD_CFLAGS -D_REENTRANT"
14+
THREAD_CPPFLAGS="$THREAD_CPPFLAGS -D_REENTRANT"

src/tools/thread/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile for tools/thread
4+
#
5+
# Copyright (C) 2003 by PostgreSQL Global Development Team
6+
#
7+
# $Header: /cvsroot/pgsql/src/tools/thread/Attic/Makefile,v 1.1 2003/09/27 15:32:48 momjian Exp $
8+
#
9+
#-------------------------------------------------------------------------
10+
11+
subdir = tools/thread
12+
top_builddir = ../../..
13+
include $(top_builddir)/src/Makefile.global
14+
15+
override CFLAGS += $(THREAD_CPPFLAGS)
16+
17+
LDFLAGS += $(THREAD_LIBS)
18+
19+
all: thread_test
20+
21+
thread_test: thread_test.o
22+
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
23+
24+
clean distclean maintainer-clean:
25+
rm -f thread_test$(X) thread_test.o

src/tools/thread/README

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This program should be run by developers wishing to enable threading on
2+
new platforms.
3+
4+
Run thread_test program to determine if your native libc functions are
5+
thread-safe, or if we should use *_r functions or thread locking.
6+
7+
Make sure you have added any needed 'THREAD_CPPFLAGS' and 'THREAD_LIBS'
8+
defines to your template/${port} file before compiling this program.

0 commit comments

Comments
 (0)