Skip to content

Commit 1b4e825

Browse files
committed
Simplify thread test program.
1 parent 0fa2afa commit 1b4e825

File tree

1 file changed

+11
-38
lines changed

1 file changed

+11
-38
lines changed

src/tools/thread/thread_test.c

Lines changed: 11 additions & 38 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.18 2004/04/21 20:58:56 momjian Exp $
9+
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.19 2004/04/22 23:58:03 momjian Exp $
1010
*
1111
* This program tests to see if your standard libc functions use
1212
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
@@ -28,7 +28,6 @@
2828
#include <sys/types.h>
2929
#include <pwd.h>
3030
#include <string.h>
31-
#include <errno.h>
3231
#include <fcntl.h>
3332
#include <errno.h>
3433

@@ -54,9 +53,9 @@ struct passwd *passwd_p2;
5453
struct hostent *hostent_p1;
5554
struct hostent *hostent_p2;
5655

57-
bool gethostbyname_threadsafe;
58-
bool getpwuid_threadsafe;
59-
bool strerror_threadsafe;
56+
bool gethostbyname_threadsafe = false;
57+
bool getpwuid_threadsafe = false;
58+
bool strerror_threadsafe = false;
6059
bool platform_is_threadsafe = true;
6160

6261
pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -92,42 +91,16 @@ defines to your template/$port file before compiling this program.\n\n"
9291
while (thread1_done == 0 || thread2_done == 0)
9392
sched_yield(); /* if this is a portability problem, remove it */
9493

95-
fprintf(stderr, "errno is thread-safe\n\n");
94+
fprintf(stderr, "errno is thread-safe\n");
9695

97-
printf("Add this to your template/$port file:\n\n");
98-
9996
if (strerror_p1 != strerror_p2)
100-
{
101-
printf("STRERROR_THREADSAFE=yes\n");
10297
strerror_threadsafe = true;
103-
}
104-
else
105-
{
106-
printf("STRERROR_THREADSAFE=no\n");
107-
strerror_threadsafe = false;
108-
}
10998

11099
if (passwd_p1 != passwd_p2)
111-
{
112-
printf("GETPWUID_THREADSAFE=yes\n");
113100
getpwuid_threadsafe = true;
114-
}
115-
else
116-
{
117-
printf("GETPWUID_THREADSAFE=no\n");
118-
getpwuid_threadsafe = false;
119-
}
120101

121102
if (hostent_p1 != hostent_p2)
122-
{
123-
printf("GETHOSTBYNAME_THREADSAFE=yes\n");
124103
gethostbyname_threadsafe = true;
125-
}
126-
else
127-
{
128-
printf("GETHOSTBYNAME_THREADSAFE=no\n");
129-
gethostbyname_threadsafe = false;
130-
}
131104

132105
pthread_mutex_unlock(&init_mutex); /* let children exit */
133106

@@ -141,11 +114,11 @@ defines to your template/$port file before compiling this program.\n\n"
141114
#else
142115
printf("Your system uses strerror() which is ");
143116
if (strerror_threadsafe)
144-
printf("thread-safe\n");
117+
printf("thread-safe.\n");
145118
else
146119
{
147120
platform_is_threadsafe = false;
148-
printf("not thread-safe\n");
121+
printf("not thread-safe.\n");
149122
}
150123
#endif
151124

@@ -154,11 +127,11 @@ defines to your template/$port file before compiling this program.\n\n"
154127
#else
155128
printf("Your system uses getpwuid() which is ");
156129
if (getpwuid_threadsafe)
157-
printf("thread-safe\n");
130+
printf("thread-safe.\n");
158131
else
159132
{
160133
platform_is_threadsafe = false;
161-
printf("not thread-safe\n");
134+
printf("not thread-safe.\n");
162135
}
163136
#endif
164137

@@ -171,11 +144,11 @@ defines to your template/$port file before compiling this program.\n\n"
171144
#else
172145
printf("Your system uses gethostbyname which is ");
173146
if (gethostbyname_threadsafe)
174-
printf("thread-safe\n");
147+
printf("thread-safe.\n");
175148
else
176149
{
177150
platform_is_threadsafe = false;
178-
printf("not thread-safe\n");
151+
printf("not thread-safe.\n");
179152
}
180153
#endif
181154
#endif

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