Skip to content

Commit

Permalink
Revert "Do not use sized constants in public headers"
Browse files Browse the repository at this point in the history
This reverts commit 22c01e9.

This is a Red Hat specific patch that does not belong into upstream
  • Loading branch information
jhrozek committed Jun 15, 2011
1 parent 22c527c commit ce03c81
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
18 changes: 18 additions & 0 deletions acinclude.m4
Expand Up @@ -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
Expand Down Expand Up @@ -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])
])


Expand Down
16 changes: 16 additions & 0 deletions ares_build.h.in
Expand Up @@ -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 */
/* ================================================================ */
Expand Down Expand Up @@ -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;

Expand Down
29 changes: 29 additions & 0 deletions ares_rules.h
Expand Up @@ -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.
*/
Expand All @@ -81,6 +91,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
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -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,
Expand Down

0 comments on commit ce03c81

Please sign in to comment.