From 34b265df20b150e7785d7e8e32df21e19ed88ad8 Mon Sep 17 00:00:00 2001 From: Peter De Wachter Date: Tue, 16 Oct 2018 20:40:41 +0200 Subject: [PATCH] mescc: Add INTn_MIN/MAX defines to stdint.h. * include/stdint.h: Add INTn_MIN/MAX defines. Move integere size defines from limits.h * include/limits.h: Include it. --- include/limits.h | 15 ++++----------- include/stdint.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/include/limits.h b/include/limits.h index 4e79c5b0..6cc6e307 100644 --- a/include/limits.h +++ b/include/limits.h @@ -29,19 +29,12 @@ #else // ! WITH_GLIBC -#define CHAR_BIT 8 -#define UCHAR_MAX 255 -#define CHAR_MAX 255 -#define UINT_MAX 4294967295U -#define ULONG_MAX 4294967295U -#define INT_MIN -2147483648 -#define INT_MAX 2147483647 +#include + #define MB_CUR_MAX 1 -#define LONG_MIN -2147483648 -#define LONG_MAX 2147483647 -#define _POSIX_OPEN_MAX 16 -#define PATH_MAX 512 #define NAME_MAX 255 +#define PATH_MAX 512 +#define _POSIX_OPEN_MAX 16 #endif // ! WITH_GLIBC diff --git a/include/stdint.h b/include/stdint.h index d6fb7d99..a7aec03c 100644 --- a/include/stdint.h +++ b/include/stdint.h @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2018 Peter De Wachter * * This file is part of GNU Mes. * @@ -80,6 +81,40 @@ typedef unsigned* uintptr_t; typedef long ptrdiff_t; #endif +#define CHAR_BIT 8 +#define CHAR_MAX 255 +#define UCHAR_MAX 255 + +#define INT8_MAX 127 +#define INT8_MIN (-INT8_MAX-1) +#define UINT8_MAX 255 + +#define INT16_MAX 32767 +#define INT16_MIN (-INT16_MAX-1) +#define UINT16_MAX 65535 + +#define INT32_MAX 2147483647 +#define INT32_MIN (-INT32_MAX-1) +#define UINT32_MAX 4294967295U + +#define INT64_MAX 9223372036854775807LL +#define INT64_MIN (-INT64_MAX-1) +#define UINT64_MAX 18446744073709551615ULL + +#define INT_MIN -2147483648 +#define INT_MAX 2147483647 +#if __i386__ +#define LONG_MIN INT_MIN +#define LONG_MAX INT_MAX +#define UINT_MAX UINT32_MAX +#define ULONG_MAX UINT32_MAX +#elif __x86_64__ +#define LONG_MIN INT64_MIN +#define LONG_MAX INT64_MAX +#define UINT_MAX UINT32_MAX +#define ULONG_MAX UINT64_MAX +#endif + #endif // ! WITH_GLIBC #endif // __MES_STDINT_H