1/* 2 * Copyright (c) 2000-2010 Apple Inc. 3 * All rights reserved. 4 */ 5 6#ifndef _STDINT_H_ 7#define _STDINT_H_ 8 9#if __LP64__ 10#define __WORDSIZE 64 11#else 12#define __WORDSIZE 32 13#endif 14 15/* from ISO/IEC 988:1999 spec */ 16 17/* 7.18.1.1 Exact-width integer types */ 18#include <sys/_types/_int8_t.h> 19#include <sys/_types/_int16_t.h> 20#include <sys/_types/_int32_t.h> 21#include <sys/_types/_int64_t.h> 22 23#include <_types/_uint8_t.h> 24#include <_types/_uint16_t.h> 25#include <_types/_uint32_t.h> 26#include <_types/_uint64_t.h> 27 28/* 7.18.1.2 Minimum-width integer types */ 29typedef int8_t int_least8_t; 30typedef int16_t int_least16_t; 31typedef int32_t int_least32_t; 32typedef int64_t int_least64_t; 33typedef uint8_t uint_least8_t; 34typedef uint16_t uint_least16_t; 35typedef uint32_t uint_least32_t; 36typedef uint64_t uint_least64_t; 37 38 39/* 7.18.1.3 Fastest-width integer types */ 40typedef int8_t int_fast8_t; 41typedef int16_t int_fast16_t; 42typedef int32_t int_fast32_t; 43typedef int64_t int_fast64_t; 44typedef uint8_t uint_fast8_t; 45typedef uint16_t uint_fast16_t; 46typedef uint32_t uint_fast32_t; 47typedef uint64_t uint_fast64_t; 48 49 50/* 7.18.1.4 Integer types capable of holding object pointers */ 51 52#include <sys/_types.h> 53#include <sys/_types/_intptr_t.h> 54#include <sys/_types/_uintptr_t.h> 55 56 57/* 7.18.1.5 Greatest-width integer types */ 58#include <_types/_intmax_t.h> 59#include <_types/_uintmax_t.h> 60 61/* 7.18.2 Limits of specified-width integer types: 62 * These #defines specify the minimum and maximum limits 63 * of each of the types declared above. 64 */ 65 66 67/* 7.18.2.1 Limits of exact-width integer types */ 68#define INT8_MAX 127 69#define INT16_MAX 32767 70#define INT32_MAX 2147483647 71#define INT64_MAX 9223372036854775807LL 72 73#define INT8_MIN -128 74#define INT16_MIN -32768 75 /* 76 Note: the literal "most negative int" cannot be written in C -- 77 the rules in the standard (section 6.4.4.1 in C99) will give it 78 an unsigned type, so INT32_MIN (and the most negative member of 79 any larger signed type) must be written via a constant expression. 80 */ 81#define INT32_MIN (-INT32_MAX-1) 82#define INT64_MIN (-INT64_MAX-1) 83 84#define UINT8_MAX 255 85#define UINT16_MAX 65535 86#define UINT32_MAX 4294967295U 87#define UINT64_MAX 18446744073709551615ULL 88 89/* 7.18.2.2 Limits of minimum-width integer types */ 90#define INT_LEAST8_MIN INT8_MIN 91#define INT_LEAST16_MIN INT16_MIN 92#define INT_LEAST32_MIN INT32_MIN 93#define INT_LEAST64_MIN INT64_MIN 94 95#define INT_LEAST8_MAX INT8_MAX 96#define INT_LEAST16_MAX INT16_MAX 97#define INT_LEAST32_MAX INT32_MAX 98#define INT_LEAST64_MAX INT64_MAX 99 100#define UINT_LEAST8_MAX UINT8_MAX 101#define UINT_LEAST16_MAX UINT16_MAX 102#define UINT_LEAST32_MAX UINT32_MAX 103#define UINT_LEAST64_MAX UINT64_MAX 104 105/* 7.18.2.3 Limits of fastest minimum-width integer types */ 106#define INT_FAST8_MIN INT8_MIN 107#define INT_FAST16_MIN INT16_MIN 108#define INT_FAST32_MIN INT32_MIN 109#define INT_FAST64_MIN INT64_MIN 110 111#define INT_FAST8_MAX INT8_MAX 112#define INT_FAST16_MAX INT16_MAX 113#define INT_FAST32_MAX INT32_MAX 114#define INT_FAST64_MAX INT64_MAX 115 116#define UINT_FAST8_MAX UINT8_MAX 117#define UINT_FAST16_MAX UINT16_MAX 118#define UINT_FAST32_MAX UINT32_MAX 119#define UINT_FAST64_MAX UINT64_MAX 120 121/* 7.18.2.4 Limits of integer types capable of holding object pointers */ 122 123#if __WORDSIZE == 64 124#define INTPTR_MIN INT64_MIN 125#define INTPTR_MAX INT64_MAX 126#else 127#define INTPTR_MIN INT32_MIN 128#define INTPTR_MAX INT32_MAX 129#endif 130 131#if __WORDSIZE == 64 132#define UINTPTR_MAX UINT64_MAX 133#else 134#define UINTPTR_MAX UINT32_MAX 135#endif 136 137/* 7.18.2.5 Limits of greatest-width integer types */ 138#define INTMAX_MIN INT64_MIN 139#define INTMAX_MAX INT64_MAX 140 141#define UINTMAX_MAX UINT64_MAX 142 143/* 7.18.3 "Other" */ 144#if __WORDSIZE == 64 145#define PTRDIFF_MIN INT64_MIN 146#define PTRDIFF_MAX INT64_MAX 147#else 148#define PTRDIFF_MIN INT32_MIN 149#define PTRDIFF_MAX INT32_MAX 150#endif 151 152#if __WORDSIZE == 64 153#define SIZE_MAX UINT64_MAX 154#else 155#define SIZE_MAX UINT32_MAX 156#endif 157 158#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 159#define RSIZE_MAX (SIZE_MAX >> 1) 160#endif 161 162#ifndef WCHAR_MAX 163# ifdef __WCHAR_MAX__ 164# define WCHAR_MAX __WCHAR_MAX__ 165# else 166# define WCHAR_MAX 0x7fffffff 167# endif 168#endif 169 170/* WCHAR_MIN should be 0 if wchar_t is an unsigned type and 171 (-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately, 172 it turns out that -fshort-wchar changes the signedness of 173 the type. */ 174#ifndef WCHAR_MIN 175# if WCHAR_MAX == 0xffff 176# define WCHAR_MIN 0 177# else 178# define WCHAR_MIN (-WCHAR_MAX-1) 179# endif 180#endif 181 182#define WINT_MIN INT32_MIN 183#define WINT_MAX INT32_MAX 184 185#define SIG_ATOMIC_MIN INT32_MIN 186#define SIG_ATOMIC_MAX INT32_MAX 187 188/* 7.18.4 Macros for integer constants */ 189#define INT8_C(v) (v) 190#define INT16_C(v) (v) 191#define INT32_C(v) (v) 192#define INT64_C(v) (v ## LL) 193 194#define UINT8_C(v) (v ## U) 195#define UINT16_C(v) (v ## U) 196#define UINT32_C(v) (v ## U) 197#define UINT64_C(v) (v ## ULL) 198 199#ifdef __LP64__ 200#define INTMAX_C(v) (v ## L) 201#define UINTMAX_C(v) (v ## UL) 202#else 203#define INTMAX_C(v) (v ## LL) 204#define UINTMAX_C(v) (v ## ULL) 205#endif 206 207#endif /* _STDINT_H_ */ 208