]> granicus.if.org Git - libevent/commitdiff
Add ev_[u]intptr_t to include/event2/util.h
authorNick Mathewson <nickm@torproject.org>
Tue, 26 Jan 2010 17:06:41 +0000 (12:06 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 26 Jan 2010 17:06:41 +0000 (12:06 -0500)
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.

configure.in
include/event2/util.h

index bcca1b90fca697ccd5d0e08bd7a8750efba301f9..26ef40ae55f141af8ab2e3bd92a4fcafe485a2bb 100644 (file)
@@ -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 <stdint.h>
 #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
index 0e7320e4e8e149ccd1bbc1362b563c1205881ed2..d1355db166d1c569b8b8a320a443a938cd63bcb6 100644 (file)
@@ -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