MacLO/src/stdint.h

73 lines
1.6 KiB
C
Raw Normal View History

2021-10-11 18:11:48 +00:00
// Copyright (c) Jon Thysell <http://jonthysell.com>
// Licensed under the MIT License.
2021-12-07 19:07:28 +00:00
/**
* @file stdint.h
*
* This file backports the fixed-width integer types from C99 to C89.
*/
2021-10-11 18:11:48 +00:00
#ifndef STDINT_H
#define STDINT_H
#include <limits.h>
#if !defined(UINT8_MAX) && defined(UCHAR_MAX) && (UCHAR_MAX) == 0xFFU
2021-12-07 19:07:28 +00:00
/** Unsigned integer type with width of exactly 8 bits. */
2021-10-11 18:11:48 +00:00
typedef unsigned char uint8_t;
2021-12-07 19:07:28 +00:00
/** Signed integer type with width of exactly 8 bits. */
2021-10-11 18:11:48 +00:00
typedef signed char int8_t;
2021-12-07 19:07:28 +00:00
/** The max value of an uint8_t. */
2021-10-11 18:11:48 +00:00
#define UINT8_MAX UCHAR_MAX
2021-12-07 19:07:28 +00:00
/** The max value of an int8_t. */
2021-10-11 18:11:48 +00:00
#define INT8_MAX CHAR_MAX
2021-12-07 19:07:28 +00:00
/** The min value of an int8_t. */
2021-10-11 18:11:48 +00:00
#define INT8_MIN CHAR_MIN
2021-12-07 19:07:28 +00:00
2021-10-11 18:11:48 +00:00
#endif
#if !defined(UINT16_MAX) && defined(USHRT_MAX) && (USHRT_MAX) == 0xFFFFU
2021-12-07 19:07:28 +00:00
/** Unsigned integer type with width of exactly 16 bits. */
2021-10-11 18:11:48 +00:00
typedef unsigned short uint16_t;
2021-12-07 19:07:28 +00:00
/** Signed integer type with width of exactly 16 bits. */
2021-10-11 18:11:48 +00:00
typedef signed short int16_t;
2021-12-07 19:07:28 +00:00
/** The max value of an uint16_t. */
2021-10-11 18:11:48 +00:00
#define UINT16_MAX USHRT_MAX
2021-12-07 19:07:28 +00:00
/** The max value of an int16_t. */
2021-10-11 18:11:48 +00:00
#define INT16_MAX SHRT_MAX
2021-12-07 19:07:28 +00:00
/** The min value of an int16_t. */
2021-10-11 18:11:48 +00:00
#define INT16_MIN SHRT_MIN
#endif
#if !defined(UINT32_MAX) && defined(ULONG_MAX) && (ULONG_MAX) == 0xFFFFFFFFUL
2021-12-07 19:07:28 +00:00
/** Unsigned integer type with width of exactly 32 bits. */
2021-10-11 18:11:48 +00:00
typedef unsigned long uint32_t;
2021-12-07 19:07:28 +00:00
/** Signed integer type with width of exactly 32 bits. */
2021-10-11 18:11:48 +00:00
typedef signed long int32_t;
2021-12-07 19:07:28 +00:00
/** The max value of an uint32_t. */
2021-10-11 18:11:48 +00:00
#define UINT32_MAX ULONG_MAX
2021-12-07 19:07:28 +00:00
/** The max value of an int32_t. */
2021-10-11 18:11:48 +00:00
#define INT32_MAX LONG_MAX
2021-12-07 19:07:28 +00:00
/** The min value of an int32_t. */
2021-10-11 18:11:48 +00:00
#define INT32_MIN LONG_MIN
2021-12-07 19:07:28 +00:00
2021-10-11 18:11:48 +00:00
#endif
#endif