From 69565afab0be081211df57a245a222cbd3e43ed3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 22 Feb 2007 02:51:54 +0000 Subject: Check for stdbool.h at configuration stage, and include it if available. Check for lowercase 'bool' type at configuration stage. If not available provide a suitable replacement with a type definition of 'unsigned char' in setup_once.h Move definitions of TRUE and FALSE to setup_once.h --- lib/connect.c | 7 +------ lib/setup.h | 12 ------------ lib/setup_once.h | 26 ++++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/connect.c b/lib/connect.c index 2b8e11ff8..14e2ff038 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -79,11 +79,6 @@ #include #include -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - #include "urldata.h" #include "sendf.h" #include "if2ip.h" @@ -122,7 +117,7 @@ int Curl_nonblock(curl_socket_t sockfd, /* operate on this */ int flags; flags = fcntl(sockfd, F_GETFL, 0); - if (TRUE == nonblock) + if (FALSE != nonblock) return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); else return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK)); diff --git a/lib/setup.h b/lib/setup.h index d02eec92d..bd60db09d 100644 --- a/lib/setup.h +++ b/lib/setup.h @@ -120,18 +120,6 @@ #endif -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -#if !defined(__cplusplus) && !defined(__BEOS__) && !defined(__ECOS) && !defined(typedef_bool) -typedef unsigned char bool; -#define typedef_bool -#endif - #ifdef HAVE_LONGLONG #define LONG_LONG long long #define ENABLE_64BIT diff --git a/lib/setup_once.h b/lib/setup_once.h index 7af68bf3f..79324d40f 100644 --- a/lib/setup_once.h +++ b/lib/setup_once.h @@ -69,6 +69,10 @@ #include #endif +#ifdef HAVE_STDBOOL_H +#include +#endif + /* * Definition of timeval struct for platforms that don't have it. @@ -183,6 +187,28 @@ struct timeval { (((unsigned char)x) == '\t')) +/* + * Typedef to 'unsigned char' if bool is not an available 'typedefed' type. + */ + +#ifndef HAVE_BOOL_T +typedef unsigned char bool; +#define HAVE_BOOL_T +#endif + + +/* + * Default definition of uppercase TRUE and FALSE. + */ + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + + /* * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type. */ -- cgit v1.2.3