Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "Do not use sized constants in public headers"

This reverts commit 22c01e9.

This is a Red Hat specific patch that does not belong into upstream
  • Loading branch information...
commit ce03c818f4f0474237abdd881450ef7e468306a5 1 parent 22c527c
Jakub Hrozek authored
Showing with 64 additions and 0 deletions.
  1. +18 −0 acinclude.m4
  2. +16 −0 ares_build.h.in
  3. +29 −0 ares_rules.h
  4. +1 −0  configure.ac
View
18 acinclude.m4
@@ -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])
])
View
16 ares_build.h.in
@@ -50,11 +50,21 @@
/* 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 */
/* ================================================================ */
@@ -85,9 +95,15 @@
# 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;
View
29 ares_rules.h
@@ -68,11 +68,21 @@
* 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.
*/
@@ -82,6 +92,25 @@
#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.
View
1  configure.ac
@@ -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,
Please sign in to comment.
Something went wrong with that request. Please try again.