diff options
-rw-r--r-- | ares/ares_process.c | 6 | ||||
-rw-r--r-- | ares/configure.ac | 12 | ||||
-rw-r--r-- | ares/setup_once.h | 26 | ||||
-rw-r--r-- | configure.ac | 11 | ||||
-rw-r--r-- | lib/connect.c | 7 | ||||
-rw-r--r-- | lib/setup.h | 12 | ||||
-rw-r--r-- | lib/setup_once.h | 26 | ||||
-rw-r--r-- | src/setup.h | 11 | ||||
-rw-r--r-- | tests/libtest/test.h | 9 | ||||
-rw-r--r-- | tests/server/util.h | 7 |
10 files changed, 78 insertions, 49 deletions
diff --git a/ares/ares_process.c b/ares/ares_process.c index 480948ebe..6b1b07154 100644 --- a/ares/ares_process.c +++ b/ares/ares_process.c @@ -54,10 +54,6 @@ #include "ares_dns.h" #include "ares_private.h" -#ifndef TRUE -/* at least Solaris 7 does not have TRUE at this point */ -#define TRUE 1 -#endif static int try_again(int errnum); static void write_tcp_data(ares_channel channel, fd_set *write_fds, @@ -532,7 +528,7 @@ static int nonblock(ares_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/ares/configure.ac b/ares/configure.ac index 0165c5e90..e870d63d2 100644 --- a/ares/configure.ac +++ b/ares/configure.ac @@ -308,6 +308,8 @@ AC_CHECK_HEADERS( netdb.h \ netinet/in.h \ net/if.h \ + errno.h \ + stdbool.h \ arpa/nameser.h \ arpa/nameser_compat.h \ arpa/inet.h, @@ -369,6 +371,16 @@ fi AC_CHECK_TYPE(ssize_t, , AC_DEFINE(ssize_t, int, [the signed version of size_t])) +# check for bool type +AC_CHECK_TYPE([bool],[ + AC_DEFINE(HAVE_BOOL_T, 1, + [Define to 1 if bool is an available type.]) +], ,[ +#ifdef HAVE_STDBOOL_H +#include <stdbool.h> +#endif +]) + # Check for socklen_t or equivalent CURL_CHECK_TYPE_SOCKLEN_T diff --git a/ares/setup_once.h b/ares/setup_once.h index 20ea3819d..6911f1bcf 100644 --- a/ares/setup_once.h +++ b/ares/setup_once.h @@ -62,6 +62,10 @@ #include <fcntl.h> #endif +#ifdef HAVE_STDBOOL_H +#include <stdbool.h> +#endif + /* * Definition of timeval struct for platforms that don't have it. @@ -177,6 +181,28 @@ struct timeval { /* + * 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. */ diff --git a/configure.ac b/configure.ac index 814777d2b..be3c5d7b2 100644 --- a/configure.ac +++ b/configure.ac @@ -1662,6 +1662,7 @@ AC_CHECK_HEADERS( libgen.h \ locale.h \ errno.h \ + stdbool.h \ arpa/tftp.h \ sys/filio.h \ setjmp.h, @@ -1723,6 +1724,16 @@ fi AC_CHECK_TYPE(ssize_t, , AC_DEFINE(ssize_t, int, [the signed version of size_t])) +# check for bool type +AC_CHECK_TYPE([bool],[ + AC_DEFINE(HAVE_BOOL_T, 1, + [Define to 1 if bool is an available type.]) +], ,[ +#ifdef HAVE_STDBOOL_H +#include <stdbool.h> +#endif +]) + # Check for socklen_t or equivalent CURL_CHECK_TYPE_SOCKLEN_T 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 <errno.h> #include <string.h> -#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 <fcntl.h> #endif +#ifdef HAVE_STDBOOL_H +#include <stdbool.h> +#endif + /* * Definition of timeval struct for platforms that don't have it. @@ -184,6 +188,28 @@ struct timeval { /* + * 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. */ diff --git a/src/setup.h b/src/setup.h index 139b7467f..641be4748 100644 --- a/src/setup.h +++ b/src/setup.h @@ -128,17 +128,6 @@ #include <floss.h> #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 #ifndef OS #define OS "unknown" diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 5e298abbd..c7064f82e 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -12,6 +12,7 @@ version, but that might include "config.h" from the build dir so we need both of them in the include path), so that we get good in-depth knowledge about the system we're building this on */ + #include "setup.h" #include <curl.h> @@ -32,14 +33,6 @@ #include <unistd.h> #endif -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - #define TEST_ERR_MAJOR_BAD 100 #define TEST_ERR_RUNS_FOREVER 99 diff --git a/tests/server/util.h b/tests/server/util.h index 2848560bb..69f2cfc3d 100644 --- a/tests/server/util.h +++ b/tests/server/util.h @@ -25,13 +25,6 @@ void logmsg(const char *msg, ...); -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - #define TEST_DATA_PATH "%s/data/test%ld" /* global variable, where to find the 'data' dir */ |