diff options
author | Yang Tse <yangsita@gmail.com> | 2007-02-22 02:51:54 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2007-02-22 02:51:54 +0000 |
commit | 915e774a42ad19ad9e8afb8c21ccee88ade22a94 (patch) | |
tree | 760640e0797b16889555a0e5c8c52023041e2fe6 | |
parent | 5f5a8ca90580d8fb12f7c3a843ce5a203942dab5 (diff) | |
download | c-ares-915e774a42ad19ad9e8afb8c21ccee88ade22a94.tar.gz c-ares-915e774a42ad19ad9e8afb8c21ccee88ade22a94.tar.bz2 c-ares-915e774a42ad19ad9e8afb8c21ccee88ade22a94.zip |
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
-rw-r--r-- | ares_process.c | 6 | ||||
-rw-r--r-- | configure.ac | 12 | ||||
-rw-r--r-- | setup_once.h | 26 |
3 files changed, 39 insertions, 5 deletions
diff --git a/ares_process.c b/ares_process.c index 480948e..6b1b071 100644 --- a/ares_process.c +++ b/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/configure.ac b/configure.ac index 0165c5e..e870d63 100644 --- a/configure.ac +++ b/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/setup_once.h b/setup_once.h index 20ea381..6911f1b 100644 --- a/setup_once.h +++ b/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. */ |