Revert "Do not use sized constants in public headers"
authorJakub Hrozek <jhrozek@redhat.com>
Wed, 15 Jun 2011 08:55:29 +0000 (10:55 +0200)
committerJakub Hrozek <jhrozek@redhat.com>
Wed, 15 Jun 2011 08:55:29 +0000 (10:55 +0200)
This reverts commit 22c01e96f7b2ae9923e1baa50bfe3c0d22297a7d.

This is a Red Hat specific patch that does not belong into upstream

acinclude.m4
ares_build.h.in
ares_rules.h
configure.ac

index fbee3c3..9606131 100644 (file)
@@ -1749,6 +1749,23 @@ _EOF
 ])
 
 
+dnl CARES_CONFIGURE_LONG
+dnl -------------------------------------------------
+dnl Find out the size of long as reported by sizeof() and define
+dnl CARES_SIZEOF_LONG as appropriate to be used in template file
+dnl ares_build.h.in to properly configure the library.
+dnl The size of long is a build time characteristic and as such
+dnl must be recorded in ares_build.h
+
+AC_DEFUN([CARES_CONFIGURE_LONG], [
+  if test -z "$ac_cv_sizeof_long" ||
+    test "$ac_cv_sizeof_long" -eq "0"; then
+    AC_MSG_ERROR([cannot find out size of long.])
+  fi
+  CARES_DEFINE_UNQUOTED([CARES_SIZEOF_LONG], [$ac_cv_sizeof_long])
+])
+
+
 dnl CARES_CONFIGURE_ARES_SOCKLEN_T
 dnl -------------------------------------------------
 dnl Find out suitable ares_socklen_t data type definition and size, making
@@ -1870,6 +1887,7 @@ AC_DEFUN([CARES_CONFIGURE_ARES_SOCKLEN_T], [
       ;;
   esac
   CARES_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SOCKLEN_T], [$cares_typeof_ares_socklen_t])
+  CARES_DEFINE_UNQUOTED([CARES_SIZEOF_ARES_SOCKLEN_T], [$cares_sizeof_ares_socklen_t])
 ])
 
 
index e582523..227782c 100644 (file)
 /*  DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE  */
 /* ================================================================ */
 
+#ifdef CARES_SIZEOF_LONG
+#  error "CARES_SIZEOF_LONG shall not be defined except in ares_build.h"
+   Error Compilation_aborted_CARES_SIZEOF_LONG_already_defined
+#endif
+
 #ifdef CARES_TYPEOF_ARES_SOCKLEN_T
 #  error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
    Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined
 #endif
 
+#ifdef CARES_SIZEOF_ARES_SOCKLEN_T
+#  error "CARES_SIZEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
+   Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_already_defined
+#endif
+
 /* ================================================================ */
 /*  EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY  */
 /* ================================================================ */
 #  include <sys/socket.h>
 #endif
 
+/* The size of `long', as computed by sizeof. */
+#undef CARES_SIZEOF_LONG
+
 /* Integral data type used for ares_socklen_t. */
 #undef CARES_TYPEOF_ARES_SOCKLEN_T
 
+/* The size of `ares_socklen_t', as computed by sizeof. */
+#undef CARES_SIZEOF_ARES_SOCKLEN_T
+
 /* Data type definition of ares_socklen_t. */
 typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
 
index 334af51..f94c5b5 100644 (file)
  * Verify that some macros are actually defined.
  */
 
+#ifndef CARES_SIZEOF_LONG
+#  error "CARES_SIZEOF_LONG definition is missing!"
+   Error Compilation_aborted_CARES_SIZEOF_LONG_is_missing
+#endif
+
 #ifndef CARES_TYPEOF_ARES_SOCKLEN_T
 #  error "CARES_TYPEOF_ARES_SOCKLEN_T definition is missing!"
    Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_is_missing
 #endif
 
+#ifndef CARES_SIZEOF_ARES_SOCKLEN_T
+#  error "CARES_SIZEOF_ARES_SOCKLEN_T definition is missing!"
+   Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_is_missing
+#endif
+
 /*
  * Macros private to this header file.
  */
 #define CareschkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
 
 /*
+ * Verify that the size previously defined and expected for long
+ * is the same as the one reported by sizeof() at compile time.
+ */
+
+typedef char
+  __cares_rule_01__
+    [CareschkszEQ(long, CARES_SIZEOF_LONG)];
+
+/*
+ * Verify that the size previously defined and expected for
+ * ares_socklen_t is actually the the same as the one reported
+ * by sizeof() at compile time.
+ */
+
+typedef char
+  __cares_rule_02__
+    [CareschkszEQ(ares_socklen_t, CARES_SIZEOF_ARES_SOCKLEN_T)];
+
+/*
  * Verify at compile time that the size of ares_socklen_t as reported
  * by sizeof() is greater or equal than the one reported for int for
  * the current compilation.
index f8a02af..730f8ff 100644 (file)
@@ -462,6 +462,7 @@ CURL_CHECK_STRUCT_TIMEVAL
 AC_CHECK_SIZEOF(size_t)
 AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
+CARES_CONFIGURE_LONG
 AC_CHECK_SIZEOF(time_t)
 
 AC_CHECK_TYPE(long long,