/*  Metrowerks Standard Library  */

/*  $Date: 
 *  $Revision: 
 *  $NoKeywords: $ 
 *
 *		Copyright  2000 Metrowerks, Inc.
 *		All rights reserved.
 */

/*
 *	cstdint
 *  Based on the C99 Standard for stdint.h
*/

#ifndef __CSTDINT__
#define __CSTDINT__

#include <limits.h>

#ifndef RC_INVOKED

#ifdef __cplusplus              
	#ifdef _MSL_USING_NAMESPACE
		namespace std {
	#endif
	extern "C" {
#endif

/*
7.18 Integer types <stdint.h>

1 The header <stdint.h> declares sets of integer types having specified widths, and
defines corresponding sets of macros.214) It also defines macros that specify limits of
integer types corresponding to types defined in other standard headers.

2 Types are defined in the following categories:
	 integer types having certain exact widths;
	 integer types having at least certain specified widths;
	 fastest integer types having at least certain specified widths;
	 integer types wide enough to hold pointers to objects;
	 integer types having greatest width.
	(Some of these types may denote the same type.)
	
3 Corresponding macros specify limits of the declared types and construct suitable
constants.

4 For each type described herein that the implementation provides,215) <stdint.h> shall
declare that typedef name and define the associated macros. Conversely, for each type
described herein that the implementation does not provide, <stdint.h> shall not
declare that typedef name nor shall it define the associated macros. An implementation
shall provide those types described as required, but need not provide any of the others
(described as optional).
_____________________
215) Some of these types may denote implementation-defined extended integer types.

7.18.1 Integer types

1 When typedef names differing only in the absence or presence of the initial u are defined,
they shall denote corresponding signed and unsigned types as described in 6.2.5; an
implementation providing one of these corresponding types shall also provide the other.

2 In the following descriptions, the symbol N represents an unsigned decimal integer with
no leading zeros (e.g., 8 or 24, but not 04 or 048).

7.18.1.1 Exact-width integer types

1 The typedef name intN_t designates a signed integer type with width N, no padding
bits, and a twos complement representation. Thus, int8_t denotes a signed integer
type with a width of exactly 8 bits.
 */
typedef signed char int8_t;
typedef short int   int16_t;
typedef long int    int32_t;
#ifdef __MSL_LONGLONG_SUPPORT__					
typedef long long   int64_t;
#endif	/* #ifdef __MSL_LONGLONG_SUPPORT__	*/	
/*

2 The typedef name uintN_t designates an unsigned integer type with width N. Thus,
uint24_t denotes an unsigned integer type with a width of exactly 24 bits.
*/
typedef unsigned char		uint8_t;
typedef unsigned short int  uint16_t;
typedef unsigned long int   uint32_t;
#ifdef __MSL_LONGLONG_SUPPORT__					
typedef unsigned long long  uint64_t;
#endif	/* #ifdef __MSL_LONGLONG_SUPPORT__	*/	
/*

3 These types are optional. However, if an implementation provides integer types with
widths of 8, 16, 32, or 64 bits, it shall define the corresponding typedef names.

7.18.1.2 Minimum-width integer types

1 The typedef name int_leastN_t designates a signed integer type with a width of at
least N, such that no signed integer type with lesser size has at least the specified width.
Thus, int_least32_t denotes a signed integer type with a width of at least 32 bits.

2 The typedef name uint_leastN_t designates an unsigned integer type with a width
of at least N, such that no unsigned integer type with lesser size has at least the specified
width. Thus, uint_least16_t denotes an unsigned integer type with a width of at
least 16 bits.

3 The following types are required:
	int_least8_t
	int_least16_t
	int_least32_t
	int_least64_t
	uint_least8_t
	uint_least16_t
	uint_least32_t
	uint_least64_t
All other types of this form are optional.
*/

typedef signed char 		int_least8_t;
typedef short int   		int_least16_t;
typedef long int    		int_least32_t;
#ifdef __MSL_LONGLONG_SUPPORT__					
typedef long long   		int_least64_t;
#endif	/* #ifdef __MSL_LONGLONG_SUPPORT__	*/	
typedef unsigned char		uint_least8_t;
typedef unsigned short int  uint_least16_t;
typedef unsigned long int   uint_least32_t;
#ifdef __MSL_LONGLONG_SUPPORT__				
typedef unsigned long long  uint_least64_t;
#endif	/* #ifdef __MSL_LONGLONG_SUPPORT__	*/	


/*
7.18.1.3 Fastest minimum-width integer types

1 Each of the following types designates an integer type that is usually fastest 216) to operate
with among all integer types that have at least the specified width.

2 The typedef name int_fastN_t designates the fastest signed integer type with a width
of at least N. The typedef name uint_fastN_t designates the fastest unsigned integer
type with a width of at least N.
_________________
216) The designated type is not guaranteed to be fastest for all purposes; if the implementation has no clear
grounds for choosing one type over another, it will simply pick some integer type satisfying the
signedness and width requirements.

3 The following types are required:
	int_fast8_t
	int_fast16_t
	int_fast32_t
	int_fast64_t
	uint_fast8_t
	uint_fast16_t
	uint_fast32_t
	uint_fast64_t
All other types of this form are optional.
*/

typedef signed char 		int_fast8_t;
typedef short int   		int_fast16_t;
typedef long int    		int_fast32_t;
#ifdef __MSL_LONGLONG_SUPPORT__					
typedef long long   		int_fast64_t;
#endif	/* #ifdef __MSL_LONGLONG_SUPPORT__	*/	
typedef unsigned char		uint_fast8_t;
typedef unsigned short int  uint_fast16_t;
typedef unsigned long int   uint_fast32_t;
#ifdef __MSL_LONGLONG_SUPPORT__					
typedef unsigned long long  uint_fast64_t;
#endif	/* #ifdef __MSL_LONGLONG_SUPPORT__	*/	


/*
7.18.1.4 Integer types capable of holding object pointers

1 The following type designates a signed integer type with the property that any valid
pointer to void can be converted to this type, then converted back to pointer to void,
and the result will compare equal to the original pointer:
	intptr_t
*/
typedef int32_t intptr_t;
/*

The following type designates an unsigned integer type with the property that any valid
pointer to void can be converted to this type, then converted back to pointer to void,
and the result will compare equal to the original pointer:
	uintptr_t
These types are optional.
*/
typedef uint32_t uintptr_t;

/*
7.18.1.5 Greatest-width integer types

1 The following type designates a signed integer type capable of representing any value of
any signed integer type:
	intmax_t
*/
#ifdef __MSL_LONGLONG_SUPPORT__					
typedef int64_t intmax_t;
#else											
typedef int32_t intmax_t;						
#endif	/* #ifdef __MSL_LONGLONG_SUPPORT__	*/	
/*
The following type designates an unsigned integer type capable of representing any value
of any unsigned integer type:
	uintmax_t
*/
#ifdef __MSL_LONGLONG_SUPPORT__					
typedef uint64_t uintmax_t;
#else											
typedef uint32_t uintmax_t;						
#endif	/* #ifdef __MSL_LONGLONG_SUPPORT__	*/	
/*
These types are required.

7.18.2 Limits of specified-width integer types
1 The following object-like macros 217) specify the minimum and maximum limits of the
types declared in <stdint.h>. Each macro name corresponds to a similar type name in
7.18.1.
________________
217) C++ implementations should define these macros only when _ _STDC_LIMIT_MACROS is defined
before <stdint.h> is included.

2 Each instance of any defined macro shall be replaced by a constant expression suitable
for use in #if preprocessing directives, and this expression shall have the same type as
would an expression that is an object of the corresponding type converted according to
the integer promotions. Its implementation-defined value shall be equal to or greater in
magnitude (absolute value) than the corresponding value given below, with the same sign,
except where stated to be exactly the given value.

7.18.2.1 Limits of exact-width integer types
	 minimum values of exact-width signed integer types
		INTN_MIN exactly -(2^(N-1) )
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#define INT8_MIN		SCHAR_MIN
#define INT16_MIN		SHRT_MIN
#define INT32_MIN		LONG_MIN
#define INT64_MIN		LLONG_MIN
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*
	 maximum values of exact-width signed integer types
		INTN_MAX exactly 2^(N-1) - 1
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#define INT8_MAX		SCHAR_MAX
#define INT16_MAX		SHRT_MAX
#define INT32_MAX		LONG_MAX
#define INT64_MAX		LLONG_MAX
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*
	 maximum values of exact-width unsigned integer types
		UINTN_MAX exactly 2^N - 1
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#define UINT8_MAX		UCHAR_MAX
#define UINT16_MAX		USHRT_MAX
#define UINT32_MAX		ULONG_MAX
#define UINT64_MAX		ULLONG_MAX
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*

7.18.2.2 Limits of minimum-width integer types
	 minimum values of minimum-width signed integer types
		INT_LEASTN_MIN -(2^(N-1) - 1)
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#define INT_LEAST8_MIN		SCHAR_MIN
#define INT_LEAST16_MIN		SHRT_MIN
#define INT_LEAST32_MIN		LONG_MIN
#define INT_LEAST64_MIN		LLONG_MIN
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*
	 maximum values of minimum-width signed integer types
		INT_LEASTN_MAX 2^(N-1) - 1
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#define INT_LEAST8_MAX		SCHAR_MAX
#define INT_LEAST16_MAX		SHRT_MAX
#define INT_LEAST32_MAX		LONG_MAX
#define INT_LEAST64_MAX		LLONG_MAX
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*
	 maximum values of minimum-width unsigned integer types
		UINT_LEASTN_MAX 2^N - 1
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#define UINT_LEAST8_MAX		UCHAR_MAX
#define UINT_LEAST16_MAX	USHRT_MAX
#define UINT_LEAST32_MAX	ULONG_MAX
#define UINT_LEAST64_MAX	ULLONG_MAX
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*
	
7.18.2.3 Limits of fastest minimum-width integer types
	 minimum values of fastest minimum-width signed integer types
		INT_FASTN_MIN -(2^(N-1) - 1)
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#define INT_FAST8_MIN		SCHAR_MIN
#define INT_FAST16_MIN		SHRT_MIN
#define INT_FAST32_MIN		LONG_MIN
#define INT_FAST64_MIN		LLONG_MIN
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*
	 maximum values of fastest minimum-width signed integer types
		INT_FASTN_MAX 2^(N-1) - 1
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#define INT_FAST8_MAX		SCHAR_MAX
#define INT_FAST16_MAX		SHRT_MAX
#define INT_FAST32_MAX		LONG_MAX
#define INT_FAST64_MAX		LLONG_MAX
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*
	 maximum values of fastest minimum-width unsigned integer types
		UINT_FASTN_MAX 2^N - 1
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#define UINT_FAST8_MAX		UCHAR_MAX
#define UINT_FAST16_MAX		USHRT_MAX
#define UINT_FAST32_MAX		ULONG_MAX
#define UINT_FAST64_MAX		ULLONG_MAX
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*
		
7.18.2.4 Limits of integer types capable of holding object pointers
	 minimum value of pointer-holding signed integer type
		INTPTR_MIN -(2^15 - 1)
	 maximum value of pointer-holding signed integer type
		INTPTR_MAX 2^15 - 1
	 maximum value of pointer-holding unsigned integer type
		UINTPTR_MAX 2^16 - 1
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#define INTPTR_MIN			LONG_MIN
#define INTPTR_MAX			LONG_MAX
#define UINTPTR_MAX			ULONG_MAX
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*
		
7.18.2.5 Limits of greatest-width integer types
	 minimum value of greatest-width signed integer type
		INTMAX_MIN -(2^63 - 1)
	 maximum value of greatest-width signed integer type
		INTMAX_MAX 2^63 - 1
	 maximum value of greatest-width unsigned integer type
		UINTMAX_MAX 2^64 - 1
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
#ifdef __MSL_LONGLONG_SUPPORT__
#define INTMAX_MIN			LLONG_MIN
#define INTMAX_MAX			LLONG_MAX
#define UINTMAX_MAX			ULLONG_MAX
#endif	/* #ifdef __MSL_LONGLONG_SUPPORT__	*/	
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */
/*					

7.18.3 Limits of other integer types
1 The following object-like macros 218) specify the minimum and maximum limits of
integer types corresponding to types defined in other standard headers.
________________
218) C++ implementations should define these macros only when _ _STDC_LIMIT_MACROS is defined
before <stdint.h> is included.

2 Each instance of these macros shall be replaced by a constant expression suitable for use
in #if preprocessing directives, and this expression shall have the same type as would an
expression that is an object of the corresponding type converted according to the integer
promotions. Its implementation-defined value shall be equal to or greater in magnitude
(absolute value) than the corresponding value given below, with the same sign.
	 limits of ptrdiff_t
		PTRDIFF_MIN 65535
		PTRDIFF_MAX +65535
	 limits of sig_atomic_t
		SIG_ATOMIC_MIN see below
		SIG_ATOMIC_MAX see below
	 limit of size_t
		SIZE_MAX 65535
	 limits of wchar_t
		WCHAR_MIN see below
		WCHAR_MAX see below	 limits of wint_t
	 limits of wint_t
		WINT_MIN see below
		WINT_MAX see below
3 Ifsig_atomic_t (see 7.14) is defined as a signed integer type, the value of
SIG_ATOMIC_MIN shall be no greater than -127 and the value of SIG_ATOMIC_MAX
shall be no less than 127; otherwise, sig_atomic_t is defined as an unsigned integer
type, and the value of SIG_ATOMIC_MIN shall be 0 and the value of
SIG_ATOMIC_MAX shall be no less than 255.
4 Ifwchar_t (see 7.17) is defined as a signed integer type, the value of WCHAR_MIN
shall be no greater than 127 and the value of WCHAR_MAX shall be no less than 127;
otherwise, wchar_t is defined as an unsigned integer type, and the value of
WCHAR_MIN shall be 0 and the value of WCHAR_MAX shall be no less than 255. 219)
________________
219) The values WCHAR_MIN and WCHAR_MAX do not necessarily correspond to members of the extended
character set.

5 Ifwint_t (see 7.24) is defined as a signed integer type, the value of WINT_MIN shall
be no greater than 32767 and the value of WINT_MAX shall be no less than 32767;
otherwise, wint_t is defined as an unsigned integer type, and the value of WINT_MIN
shall be 0 and the value of WINT_MAX shall be no less than 65535.
*/
#if (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)					/* mm 000602  */
#define PTRDIFF_MIN			LONG_MIN
#define PTRDIFF_MAX			LONG_MAX
#define SIG_ATOMIC_MIN		INT_MIN
#define SIG_ATOMIC_MAX		INT_MAX
#if __dest_os == __win32_os || __MOTO__  || __dest_os == __wince_os
#define SIZE_MAX     		UINT_MAX
#else
#define SIZE_MAX     		ULONG_MAX
#endif
#ifndef __NO_WIDE_CHAR
#include <wchar_t.h>   /* do define WCHAR_MIN and WCHAR_MAX */				
#define WINT_MIN			WCHAR_MIN
#define WINT_MAX			WCHAR_MAX
#endif 	 /* __NO_WIDE_CHAR */
#endif /* (!defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS) */		/* mm 000602  */
/*

7.18.4 Macros for integer constants
1 The following function-like macros 220) expand to integer constants suitable for
initializing objects that have integer types corresponding to types defined in
<stdint.h>. Each macro name corresponds to a similar type name in 7.18.1.2 or
7.18.1.5.
________________
220) C++ implementations should define these macros only when _ _STDC_CONSTANT_MACROS is
defined before <stdint.h> is included.

2 The argument in any instance of these macros shall be a decimal, octal, or hexadecimal
constant (as defined in 6.4.4.1) with a value that does not exceed the limits for the
corresponding type.
7.18.4.1 Macros for minimum-width integer constants
1 Each of the following macros expands to an integer constant having the value specified
by its argument and a type with at least the specified width.221)
________________
221) For each name described in 7.18.1.2 that the implementation provides, the corresponding macro in
this subclause is required.

2 The macro INTN_C(value) shall expand to a signed integer constant with the specified
value and type int_leastN_t. The macro UINTN_C(value) shall expand to an
unsigned integer constant with the specified value and type uint_leastN_t.For
example, if uint_least64_t is a name for the type unsigned long long int,
then UINT64_C(0x123) might expand to the integer constant 0x123ULL.
*/
#if (!defined(__cplusplus)) || defined(__STDC_CONSTANT_MACROS)
#define INT8_C(value) 	value
#define INT16_C(value) 	value
#define INT32_C(value) 	value ## L
#define INT64_C(value) 	value ## LL
#define UINT8_C(value) 	value ## U
#define UINT16_C(value) value ## U
#define UINT32_C(value) value ## UL
#define UINT64_C(value) value ## ULL
#endif   /*(!defined(__cplusplus)) || defined(__STDC_CONSTANT_MACROS)*/

/*
7.18.4.2 Macros for greatest-width integer constants
1 The following macro expands to an integer constant having the value specified by its
argument and the type intmax_t:
	INTMAX_C(value)
The following macro expands to an integer constant having the value specified by its
argument and the type uintmax_t:
UINTMAX_C(value)
*/
#if (!defined(__cplusplus)) || defined(__STDC_CONSTANT_MACROS)
#ifdef __MSL_LONGLONG_SUPPORT__
#define INTMAX_C(value)  value ## LL
#define UINTMAX_C(value) value ## ULL
#endif	/* #ifdef __MSL_LONGLONG_SUPPORT__	*/	
#endif   /*(!defined(__cplusplus)) || defined(__STDC_CONSTANT_MACROS)*/

#ifdef __cplusplus
	}           										
	#ifdef _MSL_USING_NAMESPACE
		}
	#endif
#endif

#endif /* RC_INVOKED */

#endif   /* __CSTDINT__ */

/*
 * Change record
 * mm 000511 Created.
 * mm 000602  Corrected a pair of guards
*/