]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Check for stdbool.h at configuration stage, and include it if available.
authorYang Tse <yangsita@gmail.com>
Thu, 22 Feb 2007 02:51:54 +0000 (02:51 +0000)
committerYang Tse <yangsita@gmail.com>
Thu, 22 Feb 2007 02:51:54 +0000 (02:51 +0000)
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

ares/ares_process.c
ares/configure.ac
ares/setup_once.h
configure.ac
lib/connect.c
lib/setup.h
lib/setup_once.h
src/setup.h
tests/libtest/test.h
tests/server/util.h

index 480948ebefb79e1dabde6e603bbd614dede320d7..6b1b07154ec42999fcd27ca00876ae09bea93c00 100644 (file)
 #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));
index 0165c5e902263c8e9b9edb612932675068c2e65d..e870d63d2c865723ed7600e3a033d341fa90cbc1 100644 (file)
@@ -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
 
index 20ea3819ddf94cec8c02c236932f8864c5987936..6911f1bcfcb09c1aaedcbf61f5016712eecd9c7b 100644 (file)
 #include <fcntl.h>
 #endif
 
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#endif
+
 
 /*
  * Definition of timeval struct for platforms that don't have it.
@@ -176,6 +180,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.
  */
index 814777d2b9d27895efc687570a211d4148a00364..be3c5d7b2083ee2bb22a0adb94a5e68a57e9edaf 100644 (file)
@@ -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
 
index 2b8e11ff82513a757f330ac8f5128808a396f5ab..14e2ff038be371189559455fa14f69511f27a3ce 100644 (file)
 #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));
index d02eec92dfcabae45cff30c7b82b55c94b27b299..bd60db09d73803de7c1ef39771a32c9ead1936d2 100644 (file)
 #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
index 7af68bf3fc53e14e1f4817bf4400da1257239fa1..79324d40f64d889c332ed8d5d8cb2d2f04241b1a 100644 (file)
 #include <fcntl.h>
 #endif
 
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#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.
  */
index 139b7467fc806f28650ab12ffae820956aa6c5ec..641be4748f564dd4c484a329fc52a77f96222c57 100644 (file)
 #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"
index 5e298abbda9e4c9bb57f5bed7a70c34395d1171a..c7064f82eaf8931e1f8891aa44ef6358ba42b23c 100644 (file)
@@ -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>
 #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
 
index 2848560bb30f99fd371e3227c1709a7f9ddfee6c..69f2cfc3d6136c362ed4ea56595e3d19ec1fc845 100644 (file)
 
 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 */