From: Nick Mathewson Date: Tue, 26 Jan 2010 17:06:41 +0000 (-0500) Subject: Add ev_[u]intptr_t to include/event2/util.h X-Git-Tag: release-2.0.4-alpha~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1fa4c81c71517c0b530b71cc6dd4d1812cab5996;p=libevent Add ev_[u]intptr_t to include/event2/util.h We already emulate most of the other useful bits of stdint.h, and we seem to have started to use uintptr_t in a few places throughout the code. Let's make sure we can continue to do so even on backwards platforms that don't do C99. --- diff --git a/configure.in b/configure.in index bcca1b90..26ef40ae 100644 --- a/configure.in +++ b/configure.in @@ -408,7 +408,7 @@ AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T -AC_CHECK_TYPES([uint64_t, uint32_t, uint16_t, uint8_t], , , +AC_CHECK_TYPES([uint64_t, uint32_t, uint16_t, uint8_t, uintptr_t], , , [#ifdef HAVE_STDINT_H #include #elif defined(HAVE_INTTYPES_H) @@ -431,6 +431,7 @@ AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(size_t) +AC_CHECK_SIZEOF(void *) AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t, struct addrinfo], , , [#define _GNU_SOURCE diff --git a/include/event2/util.h b/include/event2/util.h index 0e7320e4..d1355db1 100644 --- a/include/event2/util.h +++ b/include/event2/util.h @@ -66,14 +66,16 @@ extern "C" { /* Integer type definitions for types that are supposed to be defined in the * C99-specified stdint.h. Shamefully, some platforms do not include * stdint.h, so we need to replace it. (If you are on a platform like this, - * your C headers are now 10 years out of date. You should bug them to do - * something about this.) + * your C headers are now over 10 years out of date. You should bug them to + * do something about this.) * * We define: * ev_uint64_t, ev_uint32_t, ev_uint16_t, ev_uint8_t -- unsigned integer * types of exactly 64, 32, 16, and 8 bits respectively. * ev_int64_t, ev_int32_t, ev_int16_t, ev_int8_t -- signed integer * types of exactly 64, 32, 16, and 8 bits respectively. + * ev_uintptr_t, ev_intptr_t -- unsigned/signed integers large enough + * to hold a pointer without loss of bits. */ #ifdef _EVENT_HAVE_UINT64_T #define ev_uint64_t uint64_t @@ -125,6 +127,19 @@ extern "C" { #define ev_uint8_t unsigned char #endif +#ifdef _EVENT_HAVE_UINTPTR_T +#define ev_uintptr_t uintptr_t +#define ev_intptr_t intptr_t +#elif _EVENT_SIZEOF_VOID_P <= 4 +#define ev_uintptr_t ev_uint32_t +#define ev_uintptr_t ev_int32_t +#elif _EVENT_SIZEOF_VOID_P <= 8 +#define ev_uintptr_t ev_uint64_t +#define ev_uintptr_t ev_int64_t +#else +#error "No way to define ev_uintptr_t" +#endif + #ifdef _EVENT_ssize_t #define ev_ssize_t _EVENT_ssize_t #else