From 5b3d4a196c87818370dfc85093bf1a8830ca762b Mon Sep 17 00:00:00 2001 From: janwas Date: Wed, 9 Mar 2005 12:56:02 +0000 Subject: [PATCH] mucking about with base lib headers: lib/posix_types.h: wrapper for stdint / sysdep/win/wposix_types.h included by types.h; replaces posix.h there. (works around wsock conflicts by not pulling in all posix stuff everywhere) This was SVN commit r1973. --- source/lib/posix_types.h | 10 ++++++++++ source/lib/sysdep/win/wposix_types.h | 15 +++------------ source/lib/types.h | 10 ++++------ 3 files changed, 17 insertions(+), 18 deletions(-) create mode 100644 source/lib/posix_types.h diff --git a/source/lib/posix_types.h b/source/lib/posix_types.h new file mode 100644 index 0000000000..d35ba1d5be --- /dev/null +++ b/source/lib/posix_types.h @@ -0,0 +1,10 @@ +// lightweight header that defines POSIX types (e.g. ssize_t and int8_t, +// which is also provided by C99) without pulling in all POSIX declarations. +// included from lib/types.h in place of posix.h; this helps avoid conflicts +// due to incompatible winsock definitions. + +#ifdef _WIN32 +# include "sysdep/win/wposix_types.h" +#else +# include +#endif // #ifdef _WIN32 diff --git a/source/lib/sysdep/win/wposix_types.h b/source/lib/sysdep/win/wposix_types.h index 9d98bbe9cd..b00065058d 100644 --- a/source/lib/sysdep/win/wposix_types.h +++ b/source/lib/sysdep/win/wposix_types.h @@ -30,18 +30,9 @@ typedef unsigned long long uint64_t; #error "port uint64_t" #endif -#ifdef _MSC_VER -# ifndef _UINTPTR_T_DEFINED -# define _UINTPTR_T_DEFINED -# define uintptr_t unsigned int -# endif // _UINTPTR_T_DEFINED -# ifndef _INTPTR_T_DEFINED -# define _INTPTR_T_DEFINED -# define intptr_t signed int -# endif // _INTPTR_T_DEFINED -#else // _MSC_VER -# include -#endif // _MSC_VER +// note: we used to define [u]intptr_t here (if not already done). +// however, it's not necessary with VC7 and later, and the compiler's +// definition squelches 'pointer-to-int truncation' warnings, so don't. // diff --git a/source/lib/types.h b/source/lib/types.h index 807c9c0fa6..c17ef77d7c 100755 --- a/source/lib/types.h +++ b/source/lib/types.h @@ -1,9 +1,9 @@ -// convenience type (shorter defs than stdint uintN_t) +// convenient type aliases (shorter than uintN_t from stdint.h) #ifndef __TYPES_H__ #define __TYPES_H__ -#include "posix.h" +#include "posix_types.h" // defines instead of typedefs so we can #undef conflicting decls @@ -27,10 +27,8 @@ typedef unsigned int PS_uint; // the standard only guarantees 16 bits. // we use this for memory offsets and ranges, so it better be big enough. -#ifdef SIZE_MAX // nested #if to avoid ICC warning if not defined -# if SIZE_MAX < 32 -# error "check size_t and SIZE_MAX - too small?" -# endif +#if defined(SIZE_MAX) && SIZE_MAX < 32 +# error "check size_t and SIZE_MAX - too small?" #endif