/* 
 * defines integer sizes ... if having a particular size 
 * integer is always important, use this file, and use int8, int16, int32,
 * int64 instead of char, short, int, long, and uint8, uint16 etc
 * or the macros __INT(8), __UINT(8). Integers defined here should be portable
 * across machines/OS
 */
  
#ifndef __WM_LIB_SYSTEM_H__
#define __WM_LIB_SYSTEM_H__

#ifdef __GNUC__

#if defined (linux)
/* these are all defined in <asm/types.h> */
#include <linux/types.h>
#define __UINT(x) __u##x
#define __INT(x) __s##x

#elif defined (__GO32__)

#define __UINT(x) unsigned __i##x
#define __INT(x) __i##x

#define __i8 char
#define __i16 short
#define __i32 int
#define __i64 long long

#else /* __GO32__ */
/* 
 * GCC - generic, these should all work, 
 * as GCC is at least 32 bits
 */

#define __UINT(x) unsigned __i##x
#define __INT(x) __i##x

#define __i8 char       /* always >= 8 bits */
#define __i16 short     /* always >= 16 bits */

#if ((~0U) >= 0xffffffff)
#define __i32 int
#elif ((~0UL == 0xffffffff)
#define __i32 long
#endif

#if ((~0UL) == 0xffffffff)
#define __i64 long long
#else
#define __i64 long
#endif

/*#error "Compiler = GCC, unknown OS/machine"
 */
#endif
/* __GNUC__ */

#else
/* dunno what to do with anything else */
#error "unknown compiler/machine"
#endif

/* common stuff */
#define __INT__(x) typedef __INT(x) int##x;\
                 typedef __UINT(x) uint##x;\
                 typedef __UINT(x) u_int##x
/* define types int{8,16,32,64}, uint{8,16,32,64}, u_int{8,16,32,64} */
__INT__(8);
__INT__(16);
__INT__(32);
__INT__(64);
#if 0 /* these sometimes conflict */
typedef char byte;
typedef unsigned char ubyte;
typedef ubyte u_byte;
#endif
#undef __INT__


/* Now the variable scope aliases */
#define LOCAL static
#define GLOBAL extern
#define INLINE inline
#define __CFUNC__ extern "C"

#ifdef __cplusplus
#define __BEGIN_C_ extern "C" {
#define __END_C_ }
#else
#define __BEGIN_C_
#define __END_C_
#endif

#endif __WM_LIB_SYSTEM_H__
