Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1b4e825

Browse files
committed
Simplify thread test program.
1 parent0fa2afa commit1b4e825

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
structhostent*hostent_p1;
5554
structhostent*hostent_p2;
5655

57-
boolgethostbyname_threadsafe;
58-
boolgetpwuid_threadsafe;
59-
boolstrerror_threadsafe;
56+
boolgethostbyname_threadsafe= false;
57+
boolgetpwuid_threadsafe= false;
58+
boolstrerror_threadsafe= false;
6059
boolplatform_is_threadsafe= true;
6160

6261
pthread_mutex_tinit_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)

[8]ページ先頭

©2009-2025 Movatter.jp