2005-06-10 17:12:03 +02:00
|
|
|
/* stdint.h - Standard sized integer types. Author: Kees J. Bot
|
|
|
|
* 4 Oct 2003
|
|
|
|
*
|
|
|
|
* Assumption: Long is the biggest type.
|
|
|
|
* Bug: C99 requires a 64 bit type, and long isn't 64 bits yet, and
|
|
|
|
* will never be 64 bits under 16-bits Minix.
|
|
|
|
* Omission: Limits like PTR_DIFF_MAX not here yet, maybe <limits.h>?
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _STDINT_H
|
|
|
|
#define _STDINT_H
|
|
|
|
|
|
|
|
#ifndef _MINIX__TYPES_H
|
2009-11-06 09:46:22 +01:00
|
|
|
#include <minix/types.h>
|
2005-06-10 17:12:03 +02:00
|
|
|
#endif
|
2005-08-29 15:52:08 +02:00
|
|
|
#include <minix/sys_config.h>
|
2005-06-10 17:12:03 +02:00
|
|
|
|
|
|
|
#if (_WORD_SIZE != 2 && _WORD_SIZE != 4) || \
|
|
|
|
(_PTR_SIZE != _WORD_SIZE && _PTR_SIZE != 2*_WORD_SIZE)
|
|
|
|
#error Odd word or pointer sizes
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Integer types of precisely the given bitsize. */
|
|
|
|
typedef i8_t int8_t;
|
|
|
|
typedef i16_t int16_t;
|
|
|
|
typedef i32_t int32_t;
|
2009-03-30 19:07:39 +02:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED)
|
|
|
|
typedef long long int64_t;
|
|
|
|
#elif _WORD_SIZE > 2 && __L64
|
2005-06-10 17:12:03 +02:00
|
|
|
typedef i64_t int64_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef u8_t uint8_t;
|
|
|
|
typedef u16_t uint16_t;
|
|
|
|
typedef u32_t uint32_t;
|
2009-03-30 19:07:39 +02:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED)
|
|
|
|
typedef unsigned long long uint64_t;
|
|
|
|
#elif _WORD_SIZE > 2 && __L64
|
2005-06-10 17:12:03 +02:00
|
|
|
typedef u64_t uint64_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Integer types of at least the given bitsize. */
|
|
|
|
typedef int8_t int_least8_t;
|
|
|
|
typedef int16_t int_least16_t;
|
|
|
|
typedef int32_t int_least32_t;
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
typedef int64_t int_least64_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef uint8_t uint_least8_t;
|
|
|
|
typedef uint16_t uint_least16_t;
|
|
|
|
typedef uint32_t uint_least32_t;
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
typedef uint64_t uint_least64_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Fast integer types of at least the given bitsize. */
|
|
|
|
#if _WORD_SIZE == 2
|
|
|
|
typedef int16_t int_fast8_t;
|
|
|
|
typedef int16_t int_fast16_t;
|
|
|
|
#else
|
|
|
|
typedef int32_t int_fast8_t;
|
|
|
|
typedef int32_t int_fast16_t;
|
|
|
|
#endif
|
|
|
|
typedef int32_t int_fast32_t;
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
typedef int64_t int_fast64_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if _WORD_SIZE == 2
|
|
|
|
typedef uint16_t uint_fast8_t;
|
|
|
|
typedef uint16_t uint_fast16_t;
|
|
|
|
#else
|
|
|
|
typedef uint32_t uint_fast8_t;
|
|
|
|
typedef uint32_t uint_fast16_t;
|
|
|
|
#endif
|
|
|
|
typedef uint32_t uint_fast32_t;
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
typedef uint64_t uint_fast64_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Integer type capable of holding a pointer and the largest integer type. */
|
|
|
|
#if _PTR_SIZE == _WORD_SIZE
|
|
|
|
typedef int intptr_t;
|
|
|
|
typedef unsigned uintptr_t;
|
|
|
|
#elif _PTR_SIZE == 2*_WORD_SIZE
|
|
|
|
typedef long intptr_t;
|
|
|
|
typedef unsigned long uintptr_t;
|
|
|
|
#endif
|
2010-01-25 19:16:25 +01:00
|
|
|
|
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
|
|
|
typedef int64_t intmax_t;
|
|
|
|
typedef uint64_t uintmax_t;
|
|
|
|
#else
|
2005-06-10 17:12:03 +02:00
|
|
|
typedef long intmax_t;
|
|
|
|
typedef unsigned long uintmax_t;
|
2010-01-25 19:16:25 +01:00
|
|
|
#endif
|
2005-06-10 17:12:03 +02:00
|
|
|
|
|
|
|
#if !__cplusplus || defined(__STDC_LIMIT_MACROS)
|
|
|
|
#ifndef _LIMITS_H
|
|
|
|
#include <limits.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Range definitions for each of the above types conform <limits.h>. */
|
|
|
|
#define INT8_MIN (-INT8_MAX-1)
|
|
|
|
#define INT16_MIN (-INT16_MAX-1)
|
|
|
|
#define INT32_MIN (-INT32_MAX-1)
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
#define INT64_MIN (-INT64_MAX-1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define INT8_MAX 127
|
|
|
|
#define INT16_MAX 32767
|
|
|
|
#define INT32_MAX 2147483647
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2009-12-02 16:35:09 +01:00
|
|
|
#define INT64_MAX 9223372036854775807LL
|
2005-06-10 17:12:03 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define UINT8_MAX 255
|
|
|
|
#define UINT16_MAX 65535
|
2009-12-02 16:35:09 +01:00
|
|
|
#define UINT32_MAX 4294967295U
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2009-12-02 16:35:09 +01:00
|
|
|
#define UINT64_MAX 18446744073709551615ULL
|
2005-06-10 17:12:03 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define INT_LEAST8_MIN INT8_MIN
|
|
|
|
#define INT_LEAST16_MIN INT16_MIN
|
|
|
|
#define INT_LEAST32_MIN INT32_MIN
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
#define INT_LEAST64_MIN INT64_MIN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define INT_LEAST8_MAX INT8_MAX
|
|
|
|
#define INT_LEAST16_MAX INT16_MAX
|
|
|
|
#define INT_LEAST32_MAX INT32_MAX
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
#define INT_LEAST64_MAX INT64_MAX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define UINT_LEAST8_MAX UINT8_MAX
|
|
|
|
#define UINT_LEAST16_MAX UINT16_MAX
|
|
|
|
#define UINT_LEAST32_MAX UINT32_MAX
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
#define UINT_LEAST64_MAX UINT64_MAX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define INT_FAST8_MIN (-INT_FAST8_MAX-1)
|
|
|
|
#define INT_FAST16_MIN (-INT_FAST16_MAX-1)
|
|
|
|
#define INT_FAST32_MIN INT32_MIN
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
#define INT_FAST64_MIN INT64_MIN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if _WORD_SIZE == 2
|
|
|
|
#define INT_FAST8_MAX INT16_MAX
|
|
|
|
#define INT_FAST16_MAX INT16_MAX
|
|
|
|
#else
|
|
|
|
#define INT_FAST8_MAX INT32_MAX
|
|
|
|
#define INT_FAST16_MAX INT32_MAX
|
|
|
|
#endif
|
|
|
|
#define INT_FAST32_MAX INT32_MAX
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
#define INT_FAST64_MAX INT64_MAX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if _WORD_SIZE == 2
|
|
|
|
#define UINT_FAST8_MAX UINT16_MAX
|
|
|
|
#define UINT_FAST16_MAX UINT16_MAX
|
|
|
|
#else
|
|
|
|
#define UINT_FAST8_MAX UINT32_MAX
|
|
|
|
#define UINT_FAST16_MAX UINT32_MAX
|
|
|
|
#endif
|
|
|
|
#define UINT_FAST32_MAX UINT32_MAX
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
#define UINT_FAST64_MAX UINT64_MAX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if _PTR_SIZE == _WORD_SIZE
|
|
|
|
#define INTPTR_MIN INT_MIN
|
|
|
|
#define INTPTR_MAX INT_MAX
|
|
|
|
#define UINTPTR_MAX UINT_MAX
|
|
|
|
#elif _PTR_SIZE > _WORD_SIZE
|
|
|
|
#define INTPTR_MIN LONG_MIN
|
|
|
|
#define INTPTR_MAX LONG_MAX
|
|
|
|
#define UINTPTR_MAX ULONG_MAX
|
|
|
|
#endif
|
2010-01-25 19:16:25 +01:00
|
|
|
|
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
|
|
|
#define INTMAX_MIN INT64_MIN
|
|
|
|
#define INTMAX_MAX INT64_MAX
|
|
|
|
#define UINTMAX_MAX UINT64_MAX
|
|
|
|
#else
|
2005-06-10 17:12:03 +02:00
|
|
|
#define INTMAX_MIN LONG_MIN
|
|
|
|
#define INTMAX_MAX LONG_MAX
|
|
|
|
#define UINTMAX_MAX ULONG_MAX
|
2010-01-25 19:16:25 +01:00
|
|
|
#endif
|
2005-06-10 17:12:03 +02:00
|
|
|
|
|
|
|
#endif /* !__cplusplus || __STDC_LIMIT_MACROS */
|
|
|
|
|
|
|
|
#ifndef __CONCAT
|
|
|
|
#define __CONCAT(x,y) x ## y
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Constants of the proper type. */
|
|
|
|
#define INT8_C(c) c
|
|
|
|
#define INT16_C(c) c
|
|
|
|
#if _WORD_SIZE == 2
|
|
|
|
#define INT32_C(c) __CONCAT(c,l)
|
|
|
|
#else
|
|
|
|
#define INT32_C(c) c
|
|
|
|
#endif
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
#define INT64_C(c) __CONCAT(c,l)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define UINT8_C(c) __CONCAT(c,u)
|
|
|
|
#define UINT16_C(c) __CONCAT(c,u)
|
|
|
|
#if _WORD_SIZE == 2
|
|
|
|
#define UINT32_C(c) __CONCAT(c,lu)
|
|
|
|
#else
|
|
|
|
#define UINT32_C(c) __CONCAT(c,u)
|
|
|
|
#endif
|
2010-01-22 11:45:05 +01:00
|
|
|
#if defined(__LONG_LONG_SUPPORTED) || (_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
#define UINT64_C(c) __CONCAT(c,lu)
|
|
|
|
#endif
|
|
|
|
|
2010-01-22 11:45:05 +01:00
|
|
|
#if !defined(__LONG_LONG_SUPPORTED) && !(_WORD_SIZE > 2 && __L64)
|
2005-06-10 17:12:03 +02:00
|
|
|
#define INTMAX_C(c) INT32_C(c)
|
|
|
|
#define UINTMAX_C(c) UINT32_C(c)
|
|
|
|
#else
|
|
|
|
#define INTMAX_C(c) INT64_C(c)
|
|
|
|
#define UINTMAX_C(c) UINT64_C(c)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _STDINT_H */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* $PchId: stdint.h,v 1.2 2005/01/27 17:32:00 philip Exp $
|
|
|
|
*/
|