Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8a21211

Browse files
committed
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 96bf88d, 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
1 parent 555eb1a commit 8a21211

File tree

10 files changed

+20
-128
lines changed

10 files changed

+20
-128
lines changed

src/test/thread/thread_test.c renamed to config/thread_test.c

+4-26
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*-------------------------------------------------------------------------
22
*
33
* thread_test.c
4-
* libc thread test program
4+
* libc threading test program
55
*
66
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* src/test/thread/thread_test.c
9+
* config/thread_test.c
1010
*
1111
* This program tests to see if your standard libc functions use
1212
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
@@ -20,12 +20,7 @@
2020
*-------------------------------------------------------------------------
2121
*/
2222

23-
#if !defined(IN_CONFIGURE) && !defined(WIN32)
24-
#include "postgres.h"
25-
26-
/* we want to know what the native strerror does, not pg_strerror */
27-
#undef strerror
28-
#endif
23+
/* We cannot use c.h, as port.h will not exist yet */
2924

3025
#include <stdio.h>
3126
#include <stdlib.h>
@@ -36,6 +31,7 @@
3631
#include <string.h>
3732
#include <fcntl.h>
3833
#include <errno.h>
34+
#include <pthread.h>
3935

4036
/* CYGWIN requires this for MAXHOSTNAMELEN */
4137
#ifdef __CYGWIN__
@@ -47,25 +43,11 @@
4743
#include <winsock2.h>
4844
#endif
4945

50-
5146
/* Test for POSIX.1c 2-arg sigwait() and fail on single-arg version */
5247
#include <signal.h>
5348
int sigwait(const sigset_t *set, int *sig);
5449

5550

56-
#if !defined(ENABLE_THREAD_SAFETY) && !defined(IN_CONFIGURE) && !defined(WIN32)
57-
int
58-
main(int argc, char *argv[])
59-
{
60-
fprintf(stderr, "This PostgreSQL build does not support threads.\n");
61-
fprintf(stderr, "Perhaps rerun 'configure' using '--enable-thread-safety'.\n");
62-
return 1;
63-
}
64-
#else
65-
66-
/* This must be down here because this is the code that uses threads. */
67-
#include <pthread.h>
68-
6951
#define TEMP_FILENAME_1 "thread_test.1"
7052
#define TEMP_FILENAME_2 "thread_test.2"
7153

@@ -119,11 +101,9 @@ main(int argc, char *argv[])
119101
return 1;
120102
}
121103

122-
#ifdef IN_CONFIGURE
123104
/* Send stdout to 'config.log' */
124105
close(1);
125106
dup(5);
126-
#endif
127107

128108
#ifdef WIN32
129109
err = WSAStartup(MAKEWORD(2, 2), &wsaData);
@@ -455,5 +435,3 @@ func_call_2(void)
455435
pthread_mutex_lock(&init_mutex); /* wait for parent to test */
456436
pthread_mutex_unlock(&init_mutex);
457437
}
458-
459-
#endif /* !ENABLE_THREAD_SAFETY && !IN_CONFIGURE */

configure

+4-7
Original file line numberDiff line numberDiff line change
@@ -18992,23 +18992,21 @@ $as_echo_n "checking thread safety of required library functions... " >&6; }
1899218992

1899318993
_CFLAGS="$CFLAGS"
1899418994
_LIBS="$LIBS"
18995-
CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
18995+
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1899618996
LIBS="$LIBS $PTHREAD_LIBS"
1899718997
if test "$cross_compiling" = yes; then :
1899818998
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: maybe" >&5
1899918999
$as_echo "maybe" >&6; }
1900019000
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
1900119001
*** Skipping thread test program because of cross-compile build.
19002-
*** Run the program in src/test/thread on the target machine.
1900319002
" >&5
1900419003
$as_echo "$as_me: WARNING:
1900519004
*** Skipping thread test program because of cross-compile build.
19006-
*** Run the program in src/test/thread on the target machine.
1900719005
" >&2;}
1900819006
else
1900919007
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1901019008
/* end confdefs.h. */
19011-
#include "$srcdir/src/test/thread/thread_test.c"
19009+
#include "$srcdir/config/thread_test.c"
1901219010
_ACEOF
1901319011
if ac_fn_c_try_run "$LINENO"; then :
1901419012
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -19017,9 +19015,8 @@ else
1901719015
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1901819016
$as_echo "no" >&6; }
1901919017
as_fn_error $? "thread test program failed
19020-
This platform is not thread-safe. Check the file 'config.log' or compile
19021-
and run src/test/thread/thread_test for the exact reason.
19022-
Use --disable-thread-safety to disable thread safety." "$LINENO" 5
19018+
This platform is not thread-safe. Check the file 'config.log' for the
19019+
exact reason, or use --disable-thread-safety to disable thread safety." "$LINENO" 5
1902319020
fi
1902419021
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
1902519022
conftest.$ac_objext conftest.beam conftest.$ac_ext

configure.ac

+4-6
Original file line numberDiff line numberDiff line change
@@ -2295,20 +2295,18 @@ AC_MSG_CHECKING([thread safety of required library functions])
22952295

22962296
_CFLAGS="$CFLAGS"
22972297
_LIBS="$LIBS"
2298-
CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
2298+
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
22992299
LIBS="$LIBS $PTHREAD_LIBS"
23002300
AC_RUN_IFELSE(
2301-
[AC_LANG_SOURCE([[#include "$srcdir/src/test/thread/thread_test.c"]])],
2301+
[AC_LANG_SOURCE([[#include "$srcdir/config/thread_test.c"]])],
23022302
[AC_MSG_RESULT(yes)],
23032303
[AC_MSG_RESULT(no)
23042304
AC_MSG_ERROR([thread test program failed
2305-
This platform is not thread-safe. Check the file 'config.log' or compile
2306-
and run src/test/thread/thread_test for the exact reason.
2307-
Use --disable-thread-safety to disable thread safety.])],
2305+
This platform is not thread-safe. Check the file 'config.log' for the
2306+
exact reason, or use --disable-thread-safety to disable thread safety.])],
23082307
[AC_MSG_RESULT(maybe)
23092308
AC_MSG_WARN([
23102309
*** Skipping thread test program because of cross-compile build.
2311-
*** Run the program in src/test/thread on the target machine.
23122310
])])
23132311
CFLAGS="$_CFLAGS"
23142312
LIBS="$_LIBS"

src/Makefile

-2
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,11 @@ clean:
6666
$(MAKE) -C test $@
6767
$(MAKE) -C tutorial NO_PGXS=1 $@
6868
$(MAKE) -C test/isolation $@
69-
$(MAKE) -C test/thread $@
7069

7170
distclean maintainer-clean:
7271
$(MAKE) -C test $@
7372
$(MAKE) -C tutorial NO_PGXS=1 $@
7473
$(MAKE) -C test/isolation $@
75-
$(MAKE) -C test/thread $@
7674
rm -f Makefile.port Makefile.global
7775

7876

src/port/thread.c

-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@
4747
* use non-*_r functions if they are thread-safe
4848
*
4949
* One thread-safe solution for gethostbyname() might be to use getaddrinfo().
50-
*
51-
* Run src/test/thread to test if your operating system has thread-safe
52-
* non-*_r functions.
5350
*/
5451

5552

src/test/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ endif
3737
# clean" etc to recurse into them. (We must filter out those that we
3838
# have conditionally included into SUBDIRS above, else there will be
3939
# make confusion.)
40-
ALWAYS_SUBDIRS = $(filter-out $(SUBDIRS),examples kerberos ldap locale thread ssl)
40+
ALWAYS_SUBDIRS = $(filter-out $(SUBDIRS),examples kerberos ldap locale ssl)
4141

4242
# We want to recurse to all subdirs for all standard targets, except that
4343
# installcheck and install should not recurse into the subdirectory "modules".

src/test/README

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Not all these tests get run by "make check". Check src/test/Makefile to see
99
which tests get run automatically.
1010

1111
authentication/
12-
Tests for authentication
12+
Tests for authentication (but see also below)
1313

1414
examples/
1515
Demonstration programs for libpq that double as regression tests via
@@ -18,6 +18,12 @@ examples/
1818
isolation/
1919
Tests for concurrent behavior at the SQL level
2020

21+
kerberos/
22+
Tests for Kerberos/GSSAPI authentication and encryption
23+
24+
ldap/
25+
Tests for LDAP-based authentication
26+
2127
locale/
2228
Sanity checks for locale data, encodings, etc
2329

@@ -42,6 +48,3 @@ ssl/
4248

4349
subscription/
4450
Tests for logical replication
45-
46-
thread/
47-
A thread-safety-testing utility used by configure

src/test/thread/.gitignore

-1
This file was deleted.

src/test/thread/Makefile

-24
This file was deleted.

src/test/thread/README

-54
This file was deleted.

0 commit comments

Comments
 (0)