From 226d52b36fe648215f367d352ad6e5eb38e116be Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 29 Sep 2008 15:49:29 +0200 Subject: switch to C99 types, part II Do full C99 integer type conversion in all modules which were not touched by Eric's merged patch. --- src/mpd_types.h | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) (limited to 'src/mpd_types.h') diff --git a/src/mpd_types.h b/src/mpd_types.h index ed573c4a4..0cc35b996 100644 --- a/src/mpd_types.h +++ b/src/mpd_types.h @@ -21,24 +21,49 @@ #include "../config.h" -typedef unsigned char mpd_uint8; -typedef signed char mpd_sint8; +#if defined(HAVE_INTTYPES_H) + /* + * inttypes.h pulls in stdint.h on C99 systems, needed for older systems + * that didn't provide stdint.h but still defined equivalent types. + */ +# include +#elif defined(HAVE_STDINT_H) +# include +#elif defined(HAVE_SYS_INTTYPES_H) +# include /* some ancient systems had this, untested */ +#endif /* C99-ish type headers */ + +#include + +#if (!defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H)) + +/* + * this only includes a partial subset of what is expected in a C99 + * stdint.h or inttypes.h; but includes enough of what is needed for mpd + * to function on older platforms + * (especially Linux ones still using gcc 2.95) + */ + +typedef unsigned char uint8_t; +typedef signed char int8_t; #if SIZEOF_SHORT == 2 -typedef unsigned short mpd_uint16; -typedef signed short mpd_sint16; +typedef unsigned short uint16_t; +typedef signed short int16_t; #elif SIZEOF_INT == 2 -typedef unsigned int mpd_uint16; -typedef signed int mpd_sint16; -#endif +typedef unsigned int uint16_t; +typedef signed int int16_t; +#endif /* (u)int_16_t */ #if SIZEOF_INT == 4 -typedef unsigned int mpd_uint32; -typedef signed int mpd_sint32; +typedef unsigned int uint32_t; +typedef signed int int32_t; #elif SIZEOF_LONG == 4 -typedef unsigned long mpd_uint32; -typedef signed long mpd_sint32; -#endif +typedef unsigned long uint32_t; +typedef signed long int32_t; +#endif /* (u)int_32 */ + +#endif /* !HAVE_STDINT_H && !HAVE_INTTYPES_H */ union const_hack { const char *in; -- cgit v1.2.3