7
7
*
8
8
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
9
9
*
10
- * $Id: thread.c,v 1.12 2003/10/26 04:29:15 momjian Exp $
10
+ * $Id: thread.c,v 1.13 2003/11/24 13:16:22 petere Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
21
21
#else
22
22
#include <pwd.h>
23
23
#endif
24
- #if defined(USE_THREADS )
24
+ #if defined(ENABLE_THREAD_SAFETY )
25
25
#include <pthread.h>
26
26
#endif
27
27
73
73
char *
74
74
pqStrerror (int errnum , char * strerrbuf , size_t buflen )
75
75
{
76
- #if defined(FRONTEND ) && defined(USE_THREADS ) && defined(NEED_REENTRANT_FUNCS ) && defined(HAVE_STRERROR_R )
76
+ #if defined(FRONTEND ) && defined(ENABLE_THREAD_SAFETY ) && defined(NEED_REENTRANT_FUNCS ) && defined(HAVE_STRERROR_R )
77
77
/* reentrant strerror_r is available */
78
78
/* some early standards had strerror_r returning char * */
79
79
strerror_r (errnum , strerrbuf , buflen );
80
80
return strerrbuf ;
81
81
82
82
#else
83
83
84
- #if defined(FRONTEND ) && defined(USE_THREADS ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_STRERROR_R )
84
+ #if defined(FRONTEND ) && defined(ENABLE_THREAD_SAFETY ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_STRERROR_R )
85
85
static pthread_mutex_t strerror_lock = PTHREAD_MUTEX_INITIALIZER ;
86
86
pthread_mutex_lock (& strerror_lock );
87
87
#endif
88
88
89
89
/* no strerror_r() available, just use strerror */
90
90
StrNCpy (strerrbuf , strerror (errnum ), buflen );
91
91
92
- #if defined(FRONTEND ) && defined(USE_THREADS ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_STRERROR_R )
92
+ #if defined(FRONTEND ) && defined(ENABLE_THREAD_SAFETY ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_STRERROR_R )
93
93
pthread_mutex_unlock (& strerror_lock );
94
94
#endif
95
95
106
106
pqGetpwuid (uid_t uid , struct passwd * resultbuf , char * buffer ,
107
107
size_t buflen , struct passwd * * result )
108
108
{
109
- #if defined(FRONTEND ) && defined(USE_THREADS ) && defined(NEED_REENTRANT_FUNCS ) && defined(HAVE_GETPWUID_R )
109
+ #if defined(FRONTEND ) && defined(ENABLE_THREAD_SAFETY ) && defined(NEED_REENTRANT_FUNCS ) && defined(HAVE_GETPWUID_R )
110
110
/*
111
111
* Early POSIX draft of getpwuid_r() returns 'struct passwd *'.
112
112
* getpwuid_r(uid, resultbuf, buffer, buflen)
@@ -117,15 +117,15 @@ pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
117
117
118
118
#else
119
119
120
- #if defined(FRONTEND ) && defined(USE_THREADS ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_GETPWUID_R )
120
+ #if defined(FRONTEND ) && defined(ENABLE_THREAD_SAFETY ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_GETPWUID_R )
121
121
static pthread_mutex_t getpwuid_lock = PTHREAD_MUTEX_INITIALIZER ;
122
122
pthread_mutex_lock (& getpwuid_lock );
123
123
#endif
124
124
125
125
/* no getpwuid_r() available, just use getpwuid() */
126
126
* result = getpwuid (uid );
127
127
128
- #if defined(FRONTEND ) && defined(USE_THREADS ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_GETPWUID_R )
128
+ #if defined(FRONTEND ) && defined(ENABLE_THREAD_SAFETY ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_GETPWUID_R )
129
129
130
130
/* Use 'buffer' memory for storage of strings used by struct passwd */
131
131
if (* result &&
@@ -181,7 +181,7 @@ pqGethostbyname(const char *name,
181
181
struct hostent * * result ,
182
182
int * herrno )
183
183
{
184
- #if defined(FRONTEND ) && defined(USE_THREADS ) && defined(NEED_REENTRANT_FUNCS ) && defined(HAVE_GETHOSTBYNAME_R )
184
+ #if defined(FRONTEND ) && defined(ENABLE_THREAD_SAFETY ) && defined(NEED_REENTRANT_FUNCS ) && defined(HAVE_GETHOSTBYNAME_R )
185
185
/*
186
186
* broken (well early POSIX draft) gethostbyname_r() which returns
187
187
* 'struct hostent *'
@@ -191,15 +191,15 @@ pqGethostbyname(const char *name,
191
191
192
192
#else
193
193
194
- #if defined(FRONTEND ) && defined(USE_THREADS ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_GETHOSTBYNAME_R )
194
+ #if defined(FRONTEND ) && defined(ENABLE_THREAD_SAFETY ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_GETHOSTBYNAME_R )
195
195
static pthread_mutex_t gethostbyname_lock = PTHREAD_MUTEX_INITIALIZER ;
196
196
pthread_mutex_lock (& gethostbyname_lock );
197
197
#endif
198
198
199
199
/* no gethostbyname_r(), just use gethostbyname() */
200
200
* result = gethostbyname (name );
201
201
202
- #if defined(FRONTEND ) && defined(USE_THREADS ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_GETHOSTBYNAME_R )
202
+ #if defined(FRONTEND ) && defined(ENABLE_THREAD_SAFETY ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_GETHOSTBYNAME_R )
203
203
204
204
/*
205
205
* Use 'buffer' memory for storage of structures used by struct hostent.
@@ -268,7 +268,7 @@ pqGethostbyname(const char *name,
268
268
if (* result != NULL )
269
269
* herrno = h_errno ;
270
270
271
- #if defined(FRONTEND ) && defined(USE_THREADS ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_GETHOSTBYNAME_R )
271
+ #if defined(FRONTEND ) && defined(ENABLE_THREAD_SAFETY ) && defined(NEED_REENTRANT_FUNCS ) && !defined(HAVE_GETHOSTBYNAME_R )
272
272
pthread_mutex_unlock (& gethostbyname_lock );
273
273
#endif
274
274
0 commit comments