Skip to content

Commit 0c4b879

Browse files
committed
Avoid use of bool in thread_test.c
It's not necessary for such a small program, and it causes unnecessary extra work to get the correct definition of bool, more so if we are going to introduce stdbool.h later. Reviewed-by: Thomas Munro <thomas.munro@enterprisedb.com>
1 parent 77b6b5e commit 0c4b879

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

src/test/thread/thread_test.c

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,6 @@
2222

2323
#if !defined(IN_CONFIGURE) && !defined(WIN32)
2424
#include "postgres.h"
25-
#else
26-
/* From src/include/c.h" */
27-
#ifndef bool
28-
typedef char bool;
29-
#endif
30-
31-
#ifndef true
32-
#define true ((bool) 1)
33-
#endif
34-
35-
#ifndef false
36-
#define false ((bool) 0)
37-
#endif
3825
#endif
3926

4027
#include <stdio.h>
@@ -93,23 +80,23 @@ static volatile int errno2_set = 0;
9380
#ifndef HAVE_STRERROR_R
9481
static char *strerror_p1;
9582
static char *strerror_p2;
96-
static bool strerror_threadsafe = false;
83+
static int strerror_threadsafe = 0;
9784
#endif
9885

9986
#if !defined(WIN32) && !defined(HAVE_GETPWUID_R)
10087
static struct passwd *passwd_p1;
10188
static struct passwd *passwd_p2;
102-
static bool getpwuid_threadsafe = false;
89+
static int getpwuid_threadsafe = 0;
10390
#endif
10491

10592
#if !defined(HAVE_GETADDRINFO) && !defined(HAVE_GETHOSTBYNAME_R)
10693
static struct hostent *hostent_p1;
10794
static struct hostent *hostent_p2;
10895
static char myhostname[MAXHOSTNAMELEN];
109-
static bool gethostbyname_threadsafe = false;
96+
static int gethostbyname_threadsafe = 0;
11097
#endif
11198

112-
static bool platform_is_threadsafe = true;
99+
static int platform_is_threadsafe = 1;
113100

114101
int
115102
main(int argc, char *argv[])
@@ -187,17 +174,17 @@ main(int argc, char *argv[])
187174

188175
#ifndef HAVE_STRERROR_R
189176
if (strerror_p1 != strerror_p2)
190-
strerror_threadsafe = true;
177+
strerror_threadsafe = 1;
191178
#endif
192179

193180
#if !defined(WIN32) && !defined(HAVE_GETPWUID_R)
194181
if (passwd_p1 != passwd_p2)
195-
getpwuid_threadsafe = true;
182+
getpwuid_threadsafe = 1;
196183
#endif
197184

198185
#if !defined(HAVE_GETADDRINFO) && !defined(HAVE_GETHOSTBYNAME_R)
199186
if (hostent_p1 != hostent_p2)
200-
gethostbyname_threadsafe = true;
187+
gethostbyname_threadsafe = 1;
201188
#endif
202189

203190
/* close down threads */
@@ -218,7 +205,7 @@ main(int argc, char *argv[])
218205
else
219206
{
220207
printf("not thread-safe. **\n");
221-
platform_is_threadsafe = false;
208+
platform_is_threadsafe = 0;
222209
}
223210
#endif
224211

@@ -233,7 +220,7 @@ main(int argc, char *argv[])
233220
else
234221
{
235222
printf("not thread-safe. **\n");
236-
platform_is_threadsafe = false;
223+
platform_is_threadsafe = 0;
237224
}
238225
#endif
239226

@@ -249,7 +236,7 @@ main(int argc, char *argv[])
249236
else
250237
{
251238
printf("not thread-safe. **\n");
252-
platform_is_threadsafe = false;
239+
platform_is_threadsafe = 0;
253240
}
254241
#endif
255242

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