Skip to content

Commit 95178c8

Browse files
committed
Report error if thread-test is run without having threading enabled in
configure.
1 parent 66b42d3 commit 95178c8

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/tools/thread/thread_test.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.21 2004/04/23 20:35:50 momjian Exp $
9+
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.22 2004/04/23 22:21:49 momjian Exp $
1010
*
1111
* This program tests to see if your standard libc functions use
1212
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
@@ -20,10 +20,10 @@
2020
*-------------------------------------------------------------------------
2121
*/
2222

23-
#include <pthread.h>
24-
#include <unistd.h>
2523
#include <stdio.h>
24+
2625
#include <stdlib.h>
26+
#include <unistd.h>
2727
#include <netdb.h>
2828
#include <sys/types.h>
2929
#include <pwd.h>
@@ -33,6 +33,20 @@
3333

3434
#include "postgres.h"
3535

36+
#ifndef ENABLE_THREAD_SAFETY
37+
int
38+
main(int argc, char *argv[])
39+
{
40+
fprintf(stderr, "This PostgreSQL build does not support threads.\n");
41+
fprintf(stderr, "Perhaps rerun 'configure' using '--enable-thread-safety'.\n");
42+
return 1;
43+
}
44+
45+
#else
46+
47+
/* This must be down here because this is the code that uses threads. */
48+
#include "pthread.h"
49+
3650
void func_call_1(void);
3751
void func_call_2(void);
3852

@@ -311,3 +325,5 @@ func_call_2(void)
311325
pthread_mutex_lock(&init_mutex); /* wait for parent to test */
312326
pthread_mutex_unlock(&init_mutex);
313327
}
328+
#endif /* !ENABLE_THREAD_SAFETY */
329+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy