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.
This commit is contained in:
Nick Mathewson 2010-01-26 12:06:41 -05:00
parent 439aea0d07
commit 1fa4c81c71
2 changed files with 19 additions and 3 deletions

View 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

View 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