/*
   This header includes the Amiga typedefs and macro's for portability.

   Based on the C9X JTC1/SC22/WG14 N788 draft (November 17, 1997)
   for inttypes.h
   
   Amiga SAS/C V6.5 version for 32Bit integers. (c) 1997 Wolf Faust

 */

#ifndef INTTYPES_H
#define INTTYPES_H


/*
   Each of the following typedef names designates an integer
   type that has exactly the specified width.  These typedef
   names have the general form of intn_t or uintn_t where n is
   the required width.  For example, uint8_t denotes an
   unsigned integer type that has a width of exactly 8 bits.
   (These types must exist.)

*/

typedef char   int8_t;
typedef unsigned char   uint8_t;

typedef signed short  int16_t;
typedef unsigned short  uint16_t;

typedef signed int  int32_t;
typedef unsigned int  uint32_t;

/*
   Each of the following names designates an integer type that
   has at least the specified width.  These names have the
   general form of int_leastn_t or uint_leastn_t where n is the
   minimum required width.  For example, int_least32_t denotes
   a signed integer type that is at least 32 bits wide.

   The following designate minimum-width integer types:
   (These types must exist.)

*/

typedef char   int_least8_t;
typedef unsigned char  uint_least8_t;

typedef signed short  int_least16_t;
typedef unsigned short  uint_least16_t;

typedef signed int  int_least32_t;
typedef unsigned int  uint_least32_t;


/*
   Each of the following names designates an integer type that
   is usually fastest to operate with among all integer types
   that have at least the specified width.  These names have
   the general form of int_fastn_t or uint_fastn_t where n is
   the minimum required width.  For example, int_fast16_t
   denotes the fastest signed integer type that is at least 16
   bits wide. 

   The following designate fastest minimum-width integer
   types (These types must exist.):
*/

typedef signed short  int_fast8_t;
typedef unsigned short  uint_fast8_t;

typedef signed short  int_fast16_t;
typedef unsigned short  uint_fast16_t;

typedef signed int  int_fast32_t;
typedef unsigned int  uint_fast32_t;


/*
   The following name designates a signed integer type that is
   usually fastest among all signed integer types having widths
   of at least 16 bits. 
   It denotes the same type as int_fast16_t.
   (These types must exist.)
*/

typedef int_fast16_t  intfast_t;
typedef uint_fast16_t  uintfast_t;


/*
   The following name designates a (un)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:

   (Support for such conversions is a common extension;
   however, either or both of these types might not exist.)
*/

typedef signed long int  intptr_t;
typedef unsigned long int  uintptr_t;


/*
   The following name designates a (un)signed integer type capable
   of holding any value that can be represented by any (un)signed
   integer type (These types must exist.):
*/

typedef signed long int  intmax_t;
typedef unsigned long int  uintmax_t;


/*
   The following object-like macros specify the minimum and
   maximum limits of integer types corresponding to the typedef
   names defined in &lt;inttypes.h>.  Each macro name corresponds
   to a similar typedef name above.

   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.


   Limits of exact-width integer types
*/

/* Minimum values of exact-width signed integer types: */

#define     INT8_MIN          (                  -127)
#define     INT16_MIN         (                -32767)
#define     INT32_MIN         (           -2147483647)
//#define     INT64_MIN         (  -9223372036854775807)

/* minimum values of exact-width signed integer types  */

#define     INT8_MIN           (                 -127)
#define     INT16_MIN          (               -32767)
#define     INT32_MIN          (          -2147483647)
//#define     INT64_MIN          ( -9223372036854775807)

/* maximum values of exact-width signed integer types  */

#define     INT8_MAX           (                 +127)
#define     INT16_MAX          (               +32767)
#define     INT32_MAX          (          +2147483647)
//#define     INT64_MAX          ( +9223372036854775807)

/* maximum values of exact-width unsigned integer types */
#define     UINT8_MAX          (                  255)
#define     UINT16_MAX         (                65535)
#define     UINT32_MAX         (           4294967295)
//#define     UINT64_MAX         ( 18446744073709551615)



/* minimum values of minimum-width signed integer types */
#define     INT_LEAST8_MIN     (                 -127)
#define     INT_LEAST16_MIN    (               -32767)
#define     INT_LEAST32_MIN    (          -2147483647)
//#define     INT_LEAST64_MIN    ( -9223372036854775807)

/* maximum values of minimum-width signed integer types */
#define     INT_LEAST8_MAX     (                 +127)
#define     INT_LEAST16_MAX    (               +32767)
#define     INT_LEAST32_MAX    (          +2147483647)
//#define     INT_LEAST64_MAX    ( +9223372036854775807)

/* maximum values of minimum-width unsigned integer types */
#define     UINT_LEAST8_MAX    (                  255)
#define     UINT_LEAST16_MAX   (                65535)
#define     UINT_LEAST32_MAX   (           4294967295)
//#define     UINT_LEAST64_MAX   ( 18446744073709551615)


/* minimum values of fastest minimum-width signed integer types */
#define     INT_FAST8_MIN      (                 -127)
#define     INT_FAST16_MIN     (               -32767)
#define     INT_FAST32_MIN     (          -2147483647)
//#define     INT_FAST64_MIN   (   -9223372036854775807)

/* maximum values of fastest minimum-width signed integer types */
#define     INT_FAST8_MAX      (                 +127)
#define     INT_FAST16_MAX     (               +32767)
#define     INT_FAST32_MAX     (          +2147483647)
//#define     INT_FAST64_MAX   (   +9223372036854775807)

/* maximum values of fastest minimum-width unsigned integer types */
#define     UINT_FAST8_MAX     (                  255)
#define     UINT_FAST16_MAX    (                65535)
#define     UINT_FAST32_MAX    (           4294967295)
//#define     UINT_FAST64_MAX  (   18446744073709551615)


/* minimum value of fastest signed integer type */
#define     INTFAST_MIN        (               -32767)
/* maximum value of fastest signed integer type */
#define     INTFAST_MAX        (               +32767)
/* maximum value of fastest unsigned integer type */
#define     UINTFAST_MAX       (                65535)


/* minimum value of pointer-holding signed integer type */
#define     INTPTR_MIN         (          -2147483647)
/* maximum value of pointer-holding signed integer type */
#define     INTPTR_MAX         (          +2147483647)
/* maximum value of pointer-holding unsigned integer type */
#define     UINTPTR_MAX        (           4294967295)

/* minimum value of greatest-width signed integer type */
#define     INTMAX_MIN         (          -2147483647)
/* maximum value of greatest-width signed integer type */
#define     INTMAX_MAX         (          +2147483647)
/* maximum value of greatest-width unsigned integer type */
#define     UINTMAX_MAX        (           4294967295)


/*
   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.  These names have the general
   form of INTn_C or UINTn_C where n is the minimum required
   width.  For example, UINT64_C(0x123) might expand to the
   integer constant 0x123ULL.

   The following expand to integer constants that have (un)signed
   integer types:

*/

#define INT8_C(value)    ((int8_t)(value))
#define INT16_C(value)   ((int16_t)(value))
#define INT32_C(value)   ((int32_t)(value))
//#define INT64_C(value)   ((int64_t)(value))

#define UINT8_C(value)    ((uint8_t)(value))
#define UINT16_C(value)   ((uint16_t)(value))
#define UINT32_C(value)   ((uint32_t)(value))
//#define UINT64_C(value)   ((uint64_t)(value))


/*
   The following macro expands to an integer constant having
   the value specified by its argument and a signed integer
   type having width at least as great as any other (un)signed
   integer type:
*/

#define INTMAX_C(value)   ((intmax_t)(value))
#define UINTMAX_C(value)   ((uintmax_t)(value))


/*
       Macros for format specifiers

       Each of the following object-like macros153 expands to a
       string literal containing a conversion specifier, possibly
       modified by a prefix such as hh, h, l, or ll, suitable for
       use within the format argument of a formatted input/output
       function when converting the corresponding integer type.
       These macro names have the general form of PRI (character
       string literals for the fprintf family) or SCN (character
       string literals for the fscanf family),154 followed by the
       conversion specifier, followed by a name corresponding to a
       similar typedef name in subclause 7.4.1.  For example,
       PRIdFAST32 can be used in a format string to print the value
       of an integer of type int_fast32_t.


       153. C++ implementations should define these macros only
           when the macro __STDC_INTTYPES_PRINT_SCAN is defined
           before &lt;inttypes.h> is included.

       154. Separate macros are given for use with fprintf and
           fscanf functions because, typically, different format
           specifiers are required for fprintf and fscanf even when
           the type is the same.

       The fprintf macros for signed integers are:
           PRId8          PRId16         PRId32         PRId64
           PRIdLEAST8     PRIdLEAST16    PRIdLEAST32    PRIdLEAST64
           PRIdFAST8      PRIdFAST16     PRIdFAST32     PRIdFAST64
           PRIdMAX        PRIdPTR

           PRIi8          PRIi16         PRIi32         PRIi64
           PRIiLEAST8     PRIiLEAST16    PRIiLEAST32    PRIiLEAST64
           PRIiFAST8      PRIiFAST16     PRIiFAST32     PRIiFAST64
           PRIiMAX        PRIiPTR

       The fprintf macros for unsigned integers are:
           PRIo8          PRIo16         PRIo32         PRIo64
           PRIoLEAST8     PRIoLEAST16    PRIoLEAST32    PRIoLEAST64
           PRIoFAST8      PRIoFAST16     PRIoFAST32     PRIoFAST64
           PRIoMAX        PRIoPTR

           PRIu8          PRIu16         PRIu32         PRIu64
           PRIuLEAST8     PRIuLEAST16    PRIuLEAST32    PRIuLEAST64
           PRIuFAST8      PRIuFAST16     PRIuFAST32     PRIuFAST64
           PRIuMAX        PRIuPTR

           PRIx8          PRIx16         PRIx32         PRIx64
           PRIxLEAST8     PRIxLEAST16    PRIxLEAST32    PRIxLEAST64
           PRIxFAST8      PRIxFAST16     PRIxFAST32     PRIxFAST64
           PRIxMAX        PRIxPTR

           PRIX8          PRIX16         PRIX32         PRIX64
           PRIXLEAST8     PRIXLEAST16    PRIXLEAST32    PRIXLEAST64
           PRIXFAST8      PRIXFAST16     PRIXFAST32     PRIXFAST64
           PRIXMAX        PRIXPTR

       The fscanf macros for signed integers are:
           SCNd8          SCNd16         SCNd32         SCNd64
           SCNdLEAST8     SCNdLEAST16    SCNdLEAST32    SCNdLEAST64
           SCNdFAST8      SCNdFAST16     SCNdFAST32     SCNdFAST64
           SCNdMAX        SCNdPTR

           SCNi8          SCNi16         SCNi32         SCNi64
           SCNiLEAST8     SCNiLEAST16    SCNiLEAST32    SCNiLEAST64
           SCNiFAST8      SCNiFAST16     SCNiFAST32     SCNiFAST64
           SCNiMAX        SCNiPTR

       The fscanf macros for unsigned integers are:
           SCNo8          SCNo16         SCNo32         SCNo64
           SCNoLEAST8     SCNoLEAST16    SCNoLEAST32    SCNoLEAST64
           SCNoFAST8      SCNoFAST16     SCNoFAST32     SCNoFAST64
           SCNoMAX        SCNoPTR

           SCNu8          SCNu16         SCNu32         SCNu64
           SCNuLEAST8     SCNuLEAST16    SCNuLEAST32    SCNuLEAST64
           SCNuFAST8      SCNuFAST16     SCNuFAST32     SCNuFAST64
           SCNuMAX        SCNuPTR

           SCNx8          SCNx16         SCNx32         SCNx64
           SCNxLEAST8     SCNxLEAST16    SCNxLEAST32    SCNxLEAST64
           SCNxFAST8      SCNxFAST16     SCNxFAST32     SCNxFAST64
           SCNxMAX        SCNxPTR

       Because the default argument promotions do not affect
       pointer parameters, there might not exist suitable fscanf
       format specifiers for some of the typedef names defined in
       this header.  Consequently, as a special exception to the
       requirement that the implementation shall define all macros
       associated with each typedef name defined in this header, in
       such a case the problematic fscanf macros may be left
       undefined.

       Example

            #include &lt;inttypes.h>
            #include &lt;wchar.h>
            int main(void) {
                 uintmax_t i = UINTMAX_MAX;    // this type always exists
                 wprintf(L"The largest integer value is %020" PRIxMAX "\n", i);
                 return 0;
            }

*/


/*
   Limits of other integer types

   The following object-like macros specify the minimum and
   maximum limits of integer types corresponding to typedef
   names defined in other standard headers.

   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.

   If sig_atomic_t 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.

   If wchar_t 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.

   If wint_t 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.

*/


/* limits of ptrdiff_t */
#define     PTRDIFF_MIN                       (-4294967295)
#define     PTRDIFF_MAX                       (4294967295)

/* limits of sig_atomic_t */
#define     SIG_ATOMIC_MIN                    (-127)
#define     SIG_ATOMIC_MAX                    ( 127)

/* limit of size_t */
#define     SIZE_MAX                          (4294967295)

/* limit of wchar_t */
#define     WCHAR_MIN                         (-127)
#define     WCHAR_MAX                         (255)

/* PRIVATE */

//typedef int DWORD;
typedef unsigned char TCHAR; /* 8Bit char */
typedef TCHAR *PSTR;         /* 8Bit/char String Pointer */

/* float_fast_t should be either float or double, whichever is done faster
  by your compiler/machine. Precission might not be max...
 */

typedef double float_fast_t;

/* Highest precission possible for floating point on this machine: */

typedef double floatmax_t;


#endif /* INTTYPES_H */
