matter.c

Cross-platform minimalist libc
git clone git://git.finwo.net/lib/matter.c
Log | Files | Refs | README | LICENSE

commit 3c17f8220ee60c7a16d9dd36a75ff68de823d438
parent 7fb4c97f16dee1787a303b8ab7f98cc5da7f4d27
Author: Yersa Nordman <finwo@pm.me>
Date:   Sat, 12 Oct 2019 01:09:06 +0200

Simplified stdint.h

Diffstat:
Minclude/limits.h | 6+++---
Minclude/stdint.h | 80+++++++++++++++++++++++++++++++++++++++++--------------------------------------
2 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/include/limits.h b/include/limits.h @@ -42,11 +42,11 @@ #define INT_MIN (-1 - INT_MAX) #define INT_MAX (__INT_MAX__) -#define UINT_MAX (INT_MAX * 2u + 1) +#define UINT_MAX (INT_MAX * 2U + 1) -#define LONG_MIN (-1l - LONG_MAX) +#define LONG_MIN (-1L - LONG_MAX) #define LONG_MAX (__LONG_MAX__) -#define ULONG_MAX (LONG_MAX * 2ul + 1) +#define ULONG_MAX (LONG_MAX * 2UL + 1) #define LLONG_MAX 0x7fffffffffffffffLL #define LLONG_MIN (-1LL - LLONG_MAX) diff --git a/include/stdint.h b/include/stdint.h @@ -3,48 +3,52 @@ #include <limits.h> -/* (u)int32_t */ -#ifndef uint32_t - #if (ULONG_MAX == 0xffffffffUL) - typedef unsigned long uint32_t; - #elif (UINT_MAX == 0xffffffffUL) - typedef unsigned int uint32_t; - #elif (USHRT_MAX == 0xffffffffUL) - typedef unsigned short uint32_t; - #endif +/* (u)int8_t */ +#if (UINT_MAX == 0xffU) + typedef unsigned int uint8_t; + typedef signed int int8_t; +#elif (USHRT_MAX == 0xffU) + typedef unsigned short uint8_t; + typedef signed short int8_t; +#elif (UCHAR_MAX == 0xffU) + typedef unsigned char uint8_t; + typedef signed char int8_t; #endif -#ifndef int32_t - #if (LONG_MAX == 0x7fffffffL) - typedef signed long int32_t; - #elif (INT_MAX == 0x7fffffffL) - typedef signed int int32_t; - #elif (SHRT_MAX == 0x7fffffffL) - typedef signed short int32_t; - #endif + +/* (u)int16_t */ +#if (UINT_MAX == 0xffffU) + typedef unsigned int uint16_t; + typedef signed int int16_t; +#elif (USHRT_MAX == 0xffffU) + typedef unsigned short uint16_t; + typedef signed short int16_t; #endif -/* (u)int64_t */ -#ifndef uint64_t - #if (ULLONG_MAX == 0xffffffffffffffffULL) - typedef unsigned long long uint64_t; - #elif (ULONG_MAX == 0xffffffffffffffffULL) - typedef unsigned long uint64_t; - #elif (UINT_MAX == 0xffffffffffffffffULL) - typedef unsigned int uint64_t; - #elif (USHRT_MAX == 0xffffffffffffffffULL) - typedef unsigned short uint64_t; - #endif +/* (u)int32_t */ +#if (ULONG_MAX == 0xffffffffUL) + typedef unsigned long uint32_t; + typedef signed long int32_t +#elif (UINT_MAX == 0xffffffffUL) + typedef unsigned int uint32_t; + typedef signed int int32_t; +#elif (USHRT_MAX == 0xffffffffUL) + typedef unsigned short uint32_t; + typedef signed short int32_t; #endif -#ifndef int64_t - #if (ULLONG_MAX == 0x7fffffffffffffffULL) - typedef signed long long int64_t; - #elif (ULONG_MAX == 0x7fffffffffffffffULL) - typedef signed long int64_t; - #elif (UINT_MAX == 0x7fffffffffffffffULL) - typedef signed int int64_t; - #elif (USHRT_MAX == 0x7fffffffffffffffULL) - typedef signed short int64_t; - #endif + +/* (u)int64_t */ +#if (ULLONG_MAX == 0xffffffffffffffffULL) + typedef unsigned long long uint64_t; + typedef signed long long int64_t; +#elif (ULONG_MAX == 0xffffffffffffffffULL) + typedef unsigned long uint64_t; + typedef signed long int64_t; +#elif (UINT_MAX == 0xffffffffffffffffULL) + typedef unsigned int uint64_t; + typedef signed int int64_t; +#elif (USHRT_MAX == 0xffffffffffffffffULL) + typedef unsigned short uint64_t; + typedef signed short int64_t; #endif #endif // _STDINT_H_