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.
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;
5453struct hostent * hostent_p1 ;
5554struct 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 ;
6059bool platform_is_threadsafe = true;
6160
6261pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER ;
@@ -92,42 +91,16 @@ defines to your template/$port file before compiling this program.\n\n"
9291while (thread1_done == 0 || thread2_done == 0 )
9392sched_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-
9996if (strerror_p1 != strerror_p2 )
100- {
101- printf ("STRERROR_THREADSAFE=yes\n" );
10297strerror_threadsafe = true;
103- }
104- else
105- {
106- printf ("STRERROR_THREADSAFE=no\n" );
107- strerror_threadsafe = false;
108- }
10998
11099if (passwd_p1 != passwd_p2 )
111- {
112- printf ("GETPWUID_THREADSAFE=yes\n" );
113100getpwuid_threadsafe = true;
114- }
115- else
116- {
117- printf ("GETPWUID_THREADSAFE=no\n" );
118- getpwuid_threadsafe = false;
119- }
120101
121102if (hostent_p1 != hostent_p2 )
122- {
123- printf ("GETHOSTBYNAME_THREADSAFE=yes\n" );
124103gethostbyname_threadsafe = true;
125- }
126- else
127- {
128- printf ("GETHOSTBYNAME_THREADSAFE=no\n" );
129- gethostbyname_threadsafe = false;
130- }
131104
132105pthread_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
142115printf ("Your system uses strerror() which is " );
143116if (strerror_threadsafe )
144- printf ("thread-safe\n" );
117+ printf ("thread-safe. \n" );
145118else
146119{
147120platform_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
155128printf ("Your system uses getpwuid() which is " );
156129if (getpwuid_threadsafe )
157- printf ("thread-safe\n" );
130+ printf ("thread-safe. \n" );
158131else
159132{
160133platform_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
172145printf ("Your system uses gethostbyname which is " );
173146if (gethostbyname_threadsafe )
174- printf ("thread-safe\n" );
147+ printf ("thread-safe. \n" );
175148else
176149{
177150platform_is_threadsafe = false;
178- printf ("not thread-safe\n" );
151+ printf ("not thread-safe. \n" );
179152}
180153#endif
181154#endif