diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2013-01-22 19:55:47 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2013-01-22 19:55:47 +0000 |
commit | df236ed1dea7a18cda0c0ecb93461affd4f817c6 (patch) | |
tree | 0bf823e7e61891baefb50ee6fdd9f80213eca613 /shared | |
parent | d629edf90155d7e2e43b6a1d370746375f050815 (diff) |
convert int typedefs to use C99 stdint.h
svn path=/trunk/externals/miXed/; revision=16966
Diffstat (limited to 'shared')
-rw-r--r-- | shared/shared.h | 154 |
1 files changed, 45 insertions, 109 deletions
diff --git a/shared/shared.h b/shared/shared.h index b8c88b8..cb60164 100644 --- a/shared/shared.h +++ b/shared/shared.h @@ -5,6 +5,28 @@ #ifndef __SHARED_H__ #define __SHARED_H__ + +/* Microsoft Visual Studio is not C99, it does not provide stdint.h */ +#ifdef _MSC_VER +typedef signed __int8 int8_t; +typedef signed __int16 int16_t; +typedef signed __int32 int32_t; +typedef signed __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +#elif defined(IRIX) +typedef long int32_t; +typedef unsigned long uint32_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef unsigned char uchar; +#else +#include <stdint.h> +#endif + + /* LATER find a proper place for #include <limits.h> */ #ifdef INT_MAX #define SHARED_INT_MAX INT_MAX @@ -25,127 +47,41 @@ typedef unsigned long shared_t_bitmask; -/* this is for GNU/Linux and also Debian GNU/Hurd and GNU/kFreeBSD */ -#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__GLIBC__) -#include <sys/types.h> -#ifndef int32 -typedef int32_t int32; -#endif -#ifndef uint32 -typedef u_int32_t uint32; -#endif -#ifndef int16 -typedef int16_t int16; -#endif -#ifndef uint16 -typedef u_int16_t uint16; -#endif -#ifndef uchar -typedef u_int8_t uchar; -#endif + +/* this is for GNU/Linux, GNU/Hurd, GNU/kFreeBSD, Mac OS X, iOS */ +#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__GLIBC__) || defined(__APPLE__) #include <endian.h> -#if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN) -#error No byte order defined -#endif -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define SHARED_HIOFFSET 1 -#define SHARED_LOWOFFSET 0 -#else -#define SHARED_HIOFFSET 0 -#define SHARED_LOWOFFSET 1 -#endif +# if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN) +# error No byte order defined +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define SHARED_HIOFFSET 1 +# define SHARED_LOWOFFSET 0 +# else +# define SHARED_HIOFFSET 0 +# define SHARED_LOWOFFSET 1 +# endif #endif #ifdef _WIN32 -#ifndef int32 -typedef long int32; -#endif -#ifndef uint32 -typedef unsigned long uint32; -#endif -#ifndef int16 -typedef short int16; -#endif -#ifndef uint16 -typedef unsigned short uint16; -#endif -#ifndef uchar -typedef unsigned char uchar; -#endif #define SHARED_HIOFFSET 1 #define SHARED_LOWOFFSET 0 #endif -#ifdef __APPLE__ -#ifndef int32 -typedef int int32; -#endif -#ifndef uint32 -typedef unsigned int uint32; -#endif -#ifndef int16 -typedef short int16; -#endif -#ifndef uint16 -typedef unsigned short uint16; -#endif -#ifndef uchar -typedef unsigned char uchar; -#endif -#ifdef __BIG_ENDIAN__ -#define SHARED_HIOFFSET 0 -#define SHARED_LOWOFFSET 1 -#else -#define SHARED_HIOFFSET 1 -#define SHARED_LOWOFFSET 0 -#endif -#endif - #ifdef IRIX -#ifndef int32 -typedef long int32; -#endif -#ifndef uint32 -typedef unsigned long uint32; -#endif -#ifndef int16 -typedef short int16; -#endif -#ifndef uint16 -typedef unsigned short uint16; -#endif -#ifndef uchar -typedef unsigned char uchar; -#endif #define SHARED_HIOFFSET 0 #define SHARED_LOWOFFSET 1 #endif #ifdef __FreeBSD__ -#include <sys/types.h> -#ifndef int32 -typedef int32_t int32; -#endif -#ifndef uint32 -typedef u_int32_t uint32; -#endif -#ifndef int16 -typedef int16_t int16; -#endif -#ifndef uint16 -typedef u_int16_t uint16; -#endif -#ifndef uchar -typedef u_int8_t uchar; -#endif #include <machine/endian.h> -#if BYTE_ORDER == LITTLE_ENDIAN -#define SHARED_HIOFFSET 1 -#define SHARED_LOWOFFSET 0 -#else -#define SHARED_HIOFFSET 0 -#define SHARED_LOWOFFSET 1 -#endif +# if BYTE_ORDER == LITTLE_ENDIAN +# define SHARED_HIOFFSET 1 +# define SHARED_LOWOFFSET 0 +# else +# define SHARED_HIOFFSET 0 +# define SHARED_LOWOFFSET 1 +# endif #endif #define SHARED_UNITBIT32 1572864. /* 3*(2^19) gives 32 fractional bits */ @@ -155,16 +91,16 @@ typedef u_int8_t uchar; typedef union _shared_wrappy { double w_d; - int32 w_i[2]; + int32_t w_i[2]; } t_shared_wrappy; typedef union _shared_floatint { t_float fi_f; - int32 fi_i; + int32_t fi_i; } t_shared_floatint; -#define SHARED_TRUEBITS 0x3f800000 /* t_float f = 1; *(int32 *)&f */ +#define SHARED_TRUEBITS 0x3f800000 /* t_float f = 1; *(int32_t *)&f */ #define SHARED_PI 3.14159265359 #define SHARED_2PI 6.28318530718 |