mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Remove the option to build thread_test.c outside configure.
Theoretically one could go into src/test/thread and build/run this
program there. In practice, that hasn't worked since 96bf88d52
,
and probably much longer on some platforms (likely including just
the sort of hoary leftovers where this test might be of interest).
While it wouldn't be too hard to repair the breakage, the fact that
nobody has noticed for two years shows that there is zero usefulness
in maintaining this build pathway. Let's get rid of it and decree
that thread_test.c is *only* meant to be built/used in configure.
Given that decision, it makes sense to put thread_test.c under config/
and get rid of src/test/thread altogether, so that's what I did.
In passing, update src/test/README, which had been ignored by some
not-so-recent additions of subdirectories.
Discussion: https://postgr.es/m/227659.1603041612@sss.pgh.pa.us
This commit is contained in:
parent
555eb1a4f0
commit
8a2121185b
@ -1,12 +1,12 @@
|
|||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* thread_test.c
|
* thread_test.c
|
||||||
* libc thread test program
|
* libc threading test program
|
||||||
*
|
*
|
||||||
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* src/test/thread/thread_test.c
|
* config/thread_test.c
|
||||||
*
|
*
|
||||||
* 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.
|
||||||
@ -20,12 +20,7 @@
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(IN_CONFIGURE) && !defined(WIN32)
|
/* We cannot use c.h, as port.h will not exist yet */
|
||||||
#include "postgres.h"
|
|
||||||
|
|
||||||
/* we want to know what the native strerror does, not pg_strerror */
|
|
||||||
#undef strerror
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -36,6 +31,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
/* CYGWIN requires this for MAXHOSTNAMELEN */
|
/* CYGWIN requires this for MAXHOSTNAMELEN */
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
@ -47,25 +43,11 @@
|
|||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Test for POSIX.1c 2-arg sigwait() and fail on single-arg version */
|
/* Test for POSIX.1c 2-arg sigwait() and fail on single-arg version */
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
int sigwait(const sigset_t *set, int *sig);
|
int sigwait(const sigset_t *set, int *sig);
|
||||||
|
|
||||||
|
|
||||||
#if !defined(ENABLE_THREAD_SAFETY) && !defined(IN_CONFIGURE) && !defined(WIN32)
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
fprintf(stderr, "This PostgreSQL build does not support threads.\n");
|
|
||||||
fprintf(stderr, "Perhaps rerun 'configure' using '--enable-thread-safety'.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* This must be down here because this is the code that uses threads. */
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#define TEMP_FILENAME_1 "thread_test.1"
|
#define TEMP_FILENAME_1 "thread_test.1"
|
||||||
#define TEMP_FILENAME_2 "thread_test.2"
|
#define TEMP_FILENAME_2 "thread_test.2"
|
||||||
|
|
||||||
@ -119,11 +101,9 @@ main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IN_CONFIGURE
|
|
||||||
/* Send stdout to 'config.log' */
|
/* Send stdout to 'config.log' */
|
||||||
close(1);
|
close(1);
|
||||||
dup(5);
|
dup(5);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
err = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
err = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||||
@ -455,5 +435,3 @@ func_call_2(void)
|
|||||||
pthread_mutex_lock(&init_mutex); /* wait for parent to test */
|
pthread_mutex_lock(&init_mutex); /* wait for parent to test */
|
||||||
pthread_mutex_unlock(&init_mutex);
|
pthread_mutex_unlock(&init_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !ENABLE_THREAD_SAFETY && !IN_CONFIGURE */
|
|
11
configure
vendored
11
configure
vendored
@ -18992,23 +18992,21 @@ $as_echo_n "checking thread safety of required library functions... " >&6; }
|
|||||||
|
|
||||||
_CFLAGS="$CFLAGS"
|
_CFLAGS="$CFLAGS"
|
||||||
_LIBS="$LIBS"
|
_LIBS="$LIBS"
|
||||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
|
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
LIBS="$LIBS $PTHREAD_LIBS"
|
LIBS="$LIBS $PTHREAD_LIBS"
|
||||||
if test "$cross_compiling" = yes; then :
|
if test "$cross_compiling" = yes; then :
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: maybe" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: maybe" >&5
|
||||||
$as_echo "maybe" >&6; }
|
$as_echo "maybe" >&6; }
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
|
||||||
*** Skipping thread test program because of cross-compile build.
|
*** Skipping thread test program because of cross-compile build.
|
||||||
*** Run the program in src/test/thread on the target machine.
|
|
||||||
" >&5
|
" >&5
|
||||||
$as_echo "$as_me: WARNING:
|
$as_echo "$as_me: WARNING:
|
||||||
*** Skipping thread test program because of cross-compile build.
|
*** Skipping thread test program because of cross-compile build.
|
||||||
*** Run the program in src/test/thread on the target machine.
|
|
||||||
" >&2;}
|
" >&2;}
|
||||||
else
|
else
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
/* end confdefs.h. */
|
/* end confdefs.h. */
|
||||||
#include "$srcdir/src/test/thread/thread_test.c"
|
#include "$srcdir/config/thread_test.c"
|
||||||
_ACEOF
|
_ACEOF
|
||||||
if ac_fn_c_try_run "$LINENO"; then :
|
if ac_fn_c_try_run "$LINENO"; then :
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||||
@ -19017,9 +19015,8 @@ else
|
|||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||||
$as_echo "no" >&6; }
|
$as_echo "no" >&6; }
|
||||||
as_fn_error $? "thread test program failed
|
as_fn_error $? "thread test program failed
|
||||||
This platform is not thread-safe. Check the file 'config.log' or compile
|
This platform is not thread-safe. Check the file 'config.log' for the
|
||||||
and run src/test/thread/thread_test for the exact reason.
|
exact reason, or use --disable-thread-safety to disable thread safety." "$LINENO" 5
|
||||||
Use --disable-thread-safety to disable thread safety." "$LINENO" 5
|
|
||||||
fi
|
fi
|
||||||
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
||||||
conftest.$ac_objext conftest.beam conftest.$ac_ext
|
conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||||
|
10
configure.ac
10
configure.ac
@ -2295,20 +2295,18 @@ AC_MSG_CHECKING([thread safety of required library functions])
|
|||||||
|
|
||||||
_CFLAGS="$CFLAGS"
|
_CFLAGS="$CFLAGS"
|
||||||
_LIBS="$LIBS"
|
_LIBS="$LIBS"
|
||||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
|
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
LIBS="$LIBS $PTHREAD_LIBS"
|
LIBS="$LIBS $PTHREAD_LIBS"
|
||||||
AC_RUN_IFELSE(
|
AC_RUN_IFELSE(
|
||||||
[AC_LANG_SOURCE([[#include "$srcdir/src/test/thread/thread_test.c"]])],
|
[AC_LANG_SOURCE([[#include "$srcdir/config/thread_test.c"]])],
|
||||||
[AC_MSG_RESULT(yes)],
|
[AC_MSG_RESULT(yes)],
|
||||||
[AC_MSG_RESULT(no)
|
[AC_MSG_RESULT(no)
|
||||||
AC_MSG_ERROR([thread test program failed
|
AC_MSG_ERROR([thread test program failed
|
||||||
This platform is not thread-safe. Check the file 'config.log' or compile
|
This platform is not thread-safe. Check the file 'config.log' for the
|
||||||
and run src/test/thread/thread_test for the exact reason.
|
exact reason, or use --disable-thread-safety to disable thread safety.])],
|
||||||
Use --disable-thread-safety to disable thread safety.])],
|
|
||||||
[AC_MSG_RESULT(maybe)
|
[AC_MSG_RESULT(maybe)
|
||||||
AC_MSG_WARN([
|
AC_MSG_WARN([
|
||||||
*** Skipping thread test program because of cross-compile build.
|
*** Skipping thread test program because of cross-compile build.
|
||||||
*** Run the program in src/test/thread on the target machine.
|
|
||||||
])])
|
])])
|
||||||
CFLAGS="$_CFLAGS"
|
CFLAGS="$_CFLAGS"
|
||||||
LIBS="$_LIBS"
|
LIBS="$_LIBS"
|
||||||
|
@ -66,13 +66,11 @@ clean:
|
|||||||
$(MAKE) -C test $@
|
$(MAKE) -C test $@
|
||||||
$(MAKE) -C tutorial NO_PGXS=1 $@
|
$(MAKE) -C tutorial NO_PGXS=1 $@
|
||||||
$(MAKE) -C test/isolation $@
|
$(MAKE) -C test/isolation $@
|
||||||
$(MAKE) -C test/thread $@
|
|
||||||
|
|
||||||
distclean maintainer-clean:
|
distclean maintainer-clean:
|
||||||
$(MAKE) -C test $@
|
$(MAKE) -C test $@
|
||||||
$(MAKE) -C tutorial NO_PGXS=1 $@
|
$(MAKE) -C tutorial NO_PGXS=1 $@
|
||||||
$(MAKE) -C test/isolation $@
|
$(MAKE) -C test/isolation $@
|
||||||
$(MAKE) -C test/thread $@
|
|
||||||
rm -f Makefile.port Makefile.global
|
rm -f Makefile.port Makefile.global
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,9 +47,6 @@
|
|||||||
* use non-*_r functions if they are thread-safe
|
* use non-*_r functions if they are thread-safe
|
||||||
*
|
*
|
||||||
* One thread-safe solution for gethostbyname() might be to use getaddrinfo().
|
* One thread-safe solution for gethostbyname() might be to use getaddrinfo().
|
||||||
*
|
|
||||||
* Run src/test/thread to test if your operating system has thread-safe
|
|
||||||
* non-*_r functions.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ endif
|
|||||||
# clean" etc to recurse into them. (We must filter out those that we
|
# clean" etc to recurse into them. (We must filter out those that we
|
||||||
# have conditionally included into SUBDIRS above, else there will be
|
# have conditionally included into SUBDIRS above, else there will be
|
||||||
# make confusion.)
|
# make confusion.)
|
||||||
ALWAYS_SUBDIRS = $(filter-out $(SUBDIRS),examples kerberos ldap locale thread ssl)
|
ALWAYS_SUBDIRS = $(filter-out $(SUBDIRS),examples kerberos ldap locale ssl)
|
||||||
|
|
||||||
# We want to recurse to all subdirs for all standard targets, except that
|
# We want to recurse to all subdirs for all standard targets, except that
|
||||||
# installcheck and install should not recurse into the subdirectory "modules".
|
# installcheck and install should not recurse into the subdirectory "modules".
|
||||||
|
@ -9,7 +9,7 @@ Not all these tests get run by "make check". Check src/test/Makefile to see
|
|||||||
which tests get run automatically.
|
which tests get run automatically.
|
||||||
|
|
||||||
authentication/
|
authentication/
|
||||||
Tests for authentication
|
Tests for authentication (but see also below)
|
||||||
|
|
||||||
examples/
|
examples/
|
||||||
Demonstration programs for libpq that double as regression tests via
|
Demonstration programs for libpq that double as regression tests via
|
||||||
@ -18,6 +18,12 @@ examples/
|
|||||||
isolation/
|
isolation/
|
||||||
Tests for concurrent behavior at the SQL level
|
Tests for concurrent behavior at the SQL level
|
||||||
|
|
||||||
|
kerberos/
|
||||||
|
Tests for Kerberos/GSSAPI authentication and encryption
|
||||||
|
|
||||||
|
ldap/
|
||||||
|
Tests for LDAP-based authentication
|
||||||
|
|
||||||
locale/
|
locale/
|
||||||
Sanity checks for locale data, encodings, etc
|
Sanity checks for locale data, encodings, etc
|
||||||
|
|
||||||
@ -42,6 +48,3 @@ ssl/
|
|||||||
|
|
||||||
subscription/
|
subscription/
|
||||||
Tests for logical replication
|
Tests for logical replication
|
||||||
|
|
||||||
thread/
|
|
||||||
A thread-safety-testing utility used by configure
|
|
||||||
|
1
src/test/thread/.gitignore
vendored
1
src/test/thread/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
/thread_test
|
|
@ -1,24 +0,0 @@
|
|||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Makefile for tools/thread
|
|
||||||
#
|
|
||||||
# Copyright (c) 2003-2020, PostgreSQL Global Development Group
|
|
||||||
#
|
|
||||||
# src/test/thread/Makefile
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
subdir = src/tools/thread
|
|
||||||
top_builddir = ../../..
|
|
||||||
include $(top_builddir)/src/Makefile.global
|
|
||||||
|
|
||||||
override CFLAGS += $(PTHREAD_CFLAGS)
|
|
||||||
|
|
||||||
all: thread_test
|
|
||||||
|
|
||||||
thread_test: thread_test.o
|
|
||||||
# no need for $LIBS, might not be compiled yet
|
|
||||||
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(PTHREAD_LIBS) -o $@$(X)
|
|
||||||
|
|
||||||
clean distclean maintainer-clean:
|
|
||||||
rm -f thread_test$(X) thread_test.o
|
|
@ -1,54 +0,0 @@
|
|||||||
src/test/thread/README
|
|
||||||
|
|
||||||
Threading
|
|
||||||
=========
|
|
||||||
|
|
||||||
This program is run by configure to determine if threading is
|
|
||||||
properly supported on the platform.
|
|
||||||
|
|
||||||
You can run the program manually to see details, which shows if your
|
|
||||||
native libc functions are thread-safe, or if we use *_r functions or
|
|
||||||
thread locking.
|
|
||||||
|
|
||||||
To use this program manually, you must:
|
|
||||||
|
|
||||||
o run "configure"
|
|
||||||
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.
|
|
||||||
|
|
||||||
Windows Systems
|
|
||||||
===============
|
|
||||||
|
|
||||||
Windows systems do not vary in their thread-safeness in the same way that
|
|
||||||
other systems might, nor do they generally have pthreads installed, hence
|
|
||||||
on Windows this test is skipped by the configure program (pthreads is
|
|
||||||
required by the test program, but not PostgreSQL itself). If you do wish
|
|
||||||
to test your system however, you can do so as follows:
|
|
||||||
|
|
||||||
1) Install pthreads in you Mingw/Msys environment. You can download pthreads
|
|
||||||
from ftp://sources.redhat.com/pub/pthreads-win32/.
|
|
||||||
|
|
||||||
2) Build the test program:
|
|
||||||
|
|
||||||
gcc -o thread_test.exe \
|
|
||||||
-D_REENTRANT \
|
|
||||||
-D_THREAD_SAFE \
|
|
||||||
-D_POSIX_PTHREAD_SEMANTICS \
|
|
||||||
-I../../../src/include/port/win32 \
|
|
||||||
thread_test.c \
|
|
||||||
-lws2_32 \
|
|
||||||
-lpthreadgc2
|
|
||||||
|
|
||||||
3) Run thread_test.exe. You should see output like:
|
|
||||||
|
|
||||||
dpage@PC30:/cvs/pgsql/src/tools/thread$ ./thread_test
|
|
||||||
Your GetLastError() is thread-safe.
|
|
||||||
Your system uses strerror() which is thread-safe.
|
|
||||||
getpwuid_r()/getpwuid() are not applicable to Win32 platforms.
|
|
||||||
Your system uses gethostbyname which is thread-safe.
|
|
||||||
|
|
||||||
Your platform is thread-safe.
|
|
Loading…
Reference in New Issue
Block a user