Provide __intmax_t and __uintmax_t

Provide __intmax_t and __uintmax_t via <machine/_default_types.h> and
define intmax_t and uintmax_t in <sys/_stdint.h> for FreeBSD
compatibility.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
This commit is contained in:
Sebastian Huber 2016-10-25 07:13:49 +02:00 committed by Corinna Vinschen
parent 4e91600796
commit b1f3215380
4 changed files with 40 additions and 33 deletions

View File

@ -19,6 +19,20 @@
#include <limits.h> #include <limits.h>
#endif #endif
/* Check if "long long" is 64bit wide */
/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */
#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
|| ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
#define __have_longlong64 1
#endif
/* Check if "long" is 64bit or 32bit wide */
#if __EXP(LONG_MAX) > 0x7fffffff
#define __have_long64 1
#elif __EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
#define __have_long32 1
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -196,6 +210,22 @@ typedef __uint64_t __uint_least64_t;
#define ___int_least64_t_defined 1 #define ___int_least64_t_defined 1
#endif #endif
#if defined(__INTMAX_TYPE__)
typedef __INTMAX_TYPE__ __intmax_t;
#elif __have_longlong64
typedef signed long long __intmax_t;
#else
typedef signed long __intmax_t;
#endif
#if defined(__UINTMAX_TYPE__)
typedef __UINTMAX_TYPE__ __uintmax_t;
#elif __have_longlong64
typedef unsigned long long __uintmax_t;
#else
typedef unsigned long __uintmax_t;
#endif
#ifdef __INTPTR_TYPE__ #ifdef __INTPTR_TYPE__
typedef __INTPTR_TYPE__ __intptr_t; typedef __INTPTR_TYPE__ __intptr_t;
#ifdef __UINTPTR_TYPE__ #ifdef __UINTPTR_TYPE__

View File

@ -124,25 +124,6 @@ typedef __uint_least64_t uint_least64_t;
#endif #endif
#endif #endif
/* Greatest-width integer types */
/* Modern GCCs provide __INTMAX_TYPE__ */
#if defined(__INTMAX_TYPE__)
typedef __INTMAX_TYPE__ intmax_t;
#elif __have_longlong64
typedef signed long long intmax_t;
#else
typedef signed long intmax_t;
#endif
/* Modern GCCs provide __UINTMAX_TYPE__ */
#if defined(__UINTMAX_TYPE__)
typedef __UINTMAX_TYPE__ uintmax_t;
#elif __have_longlong64
typedef unsigned long long uintmax_t;
#else
typedef unsigned long uintmax_t;
#endif
#ifdef __INTPTR_TYPE__ #ifdef __INTPTR_TYPE__
#define INTPTR_MIN (-__INTPTR_MAX__ - 1) #define INTPTR_MIN (-__INTPTR_MAX__ - 1)
#define INTPTR_MAX (__INTPTR_MAX__) #define INTPTR_MAX (__INTPTR_MAX__)

View File

@ -19,20 +19,6 @@
#include <limits.h> #include <limits.h>
#endif #endif
/* Check if "long long" is 64bit wide */
/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */
#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
|| ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
#define __have_longlong64 1
#endif
/* Check if "long" is 64bit or 32bit wide */
#if __STDINT_EXP(LONG_MAX) > 0x7fffffff
#define __have_long64 1
#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
#define __have_long32 1
#endif
/* Determine how intptr_t and intN_t fastN_t and leastN_t are defined by gcc /* Determine how intptr_t and intN_t fastN_t and leastN_t are defined by gcc
for this target. This is used to determine the correct printf() constant in for this target. This is used to determine the correct printf() constant in
inttypes.h and other constants in stdint.h. inttypes.h and other constants in stdint.h.

View File

@ -63,6 +63,16 @@ typedef __uint64_t uint64_t ;
#define __int64_t_defined 1 #define __int64_t_defined 1
#endif /* ___int64_t_defined */ #endif /* ___int64_t_defined */
#ifndef _INTMAX_T_DECLARED
typedef __intmax_t intmax_t;
#define _INTMAX_T_DECLARED
#endif
#ifndef _UINTMAX_T_DECLARED
typedef __uintmax_t uintmax_t;
#define _UINTMAX_T_DECLARED
#endif
#ifndef _INTPTR_T_DECLARED #ifndef _INTPTR_T_DECLARED
typedef __intptr_t intptr_t; typedef __intptr_t intptr_t;
#define _INTPTR_T_DECLARED #define _INTPTR_T_DECLARED