DataTypes.h.cmake revision e2aa5d53db175dff634069cacb31487e3ddb9754
1/*===-- include/Support/DataTypes.h - Define fixed size types -----*- C -*-===*\ 2|* *| 3|* The LLVM Compiler Infrastructure *| 4|* *| 5|* This file is distributed under the University of Illinois Open Source *| 6|* License. See LICENSE.TXT for details. *| 7|* *| 8|*===----------------------------------------------------------------------===*| 9|* *| 10|* This file contains definitions to figure out the size of _HOST_ data types.*| 11|* This file is important because different host OS's define different macros,*| 12|* which makes portability tough. This file exports the following *| 13|* definitions: *| 14|* *| 15|* [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types*| 16|* [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values. *| 17|* *| 18|* No library is required when using these functinons. *| 19|* *| 20|*===----------------------------------------------------------------------===*/ 21 22/* Please leave this file C-compatible. */ 23 24#ifndef SUPPORT_DATATYPES_H 25#define SUPPORT_DATATYPES_H 26 27#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H} 28#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H} 29#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H} 30#cmakedefine HAVE_UINT64_T ${HAVE_UINT64_T} 31#cmakedefine HAVE_U_INT64_T ${HAVE_U_INT64_T} 32 33#ifdef __cplusplus 34#include <cmath> 35#else 36#include <math.h> 37#endif 38 39#ifndef _MSC_VER 40 41/* Note that this header's correct operation depends on __STDC_LIMIT_MACROS 42 being defined. We would define it here, but in order to prevent Bad Things 43 happening when system headers or C++ STL headers include stdint.h before we 44 define it here, we define it on the g++ command line (in Makefile.rules). */ 45#if !defined(__STDC_LIMIT_MACROS) 46# error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" 47#endif 48 49#if !defined(__STDC_CONSTANT_MACROS) 50# error "Must #define __STDC_CONSTANT_MACROS before " \ 51 "#including Support/DataTypes.h" 52#endif 53 54/* Note that <inttypes.h> includes <stdint.h>, if this is a C99 system. */ 55#ifdef HAVE_SYS_TYPES_H 56#include <sys/types.h> 57#endif 58 59#ifdef HAVE_INTTYPES_H 60#include <inttypes.h> 61#endif 62 63#ifdef HAVE_STDINT_H 64#include <stdint.h> 65#endif 66 67#ifdef _AIX 68#include "llvm/Support/AIXDataTypesFix.h" 69#endif 70 71/* Handle incorrect definition of uint64_t as u_int64_t */ 72#ifndef HAVE_UINT64_T 73#ifdef HAVE_U_INT64_T 74typedef u_int64_t uint64_t; 75#else 76# error "Don't have a definition for uint64_t on this platform" 77#endif 78#endif 79 80#ifdef _OpenBSD_ 81#define INT8_MAX 127 82#define INT8_MIN -128 83#define UINT8_MAX 255 84#define INT16_MAX 32767 85#define INT16_MIN -32768 86#define UINT16_MAX 65535 87#define INT32_MAX 2147483647 88#define INT32_MIN -2147483648 89#define UINT32_MAX 4294967295U 90#endif 91 92#else /* _MSC_VER */ 93/* Visual C++ doesn't provide standard integer headers, but it does provide 94 built-in data types. */ 95#include <stdlib.h> 96#include <stddef.h> 97#include <sys/types.h> 98#ifdef __cplusplus 99#include <cmath> 100#else 101#include <math.h> 102#endif 103typedef __int64 int64_t; 104typedef unsigned __int64 uint64_t; 105typedef signed int int32_t; 106typedef unsigned int uint32_t; 107typedef short int16_t; 108typedef unsigned short uint16_t; 109typedef signed char int8_t; 110typedef unsigned char uint8_t; 111typedef signed int ssize_t; 112#ifndef INT8_MAX 113# define INT8_MAX 127 114#endif 115#ifndef INT8_MIN 116# define INT8_MIN -128 117#endif 118#ifndef UINT8_MAX 119# define UINT8_MAX 255 120#endif 121#ifndef INT16_MAX 122# define INT16_MAX 32767 123#endif 124#ifndef INT16_MIN 125# define INT16_MIN -32768 126#endif 127#ifndef UINT16_MAX 128# define UINT16_MAX 65535 129#endif 130#ifndef INT32_MAX 131# define INT32_MAX 2147483647 132#endif 133#ifndef INT32_MIN 134/* MSC treats -2147483648 as -(2147483648U). */ 135# define INT32_MIN (-INT32_MAX - 1) 136#endif 137#ifndef UINT32_MAX 138# define UINT32_MAX 4294967295U 139#endif 140/* Certain compatibility updates to VC++ introduce the `cstdint' 141 * header, which defines the INT*_C macros. On default installs they 142 * are absent. */ 143#ifndef INT8_C 144# define INT8_C(C) C##i8 145#endif 146#ifndef UINT8_C 147# define UINT8_C(C) C##ui8 148#endif 149#ifndef INT16_C 150# define INT16_C(C) C##i16 151#endif 152#ifndef UINT16_C 153# define UINT16_C(C) C##ui16 154#endif 155#ifndef INT32_C 156# define INT32_C(C) C##i32 157#endif 158#ifndef UINT32_C 159# define UINT32_C(C) C##ui32 160#endif 161#ifndef INT64_C 162# define INT64_C(C) C##i64 163#endif 164#ifndef UINT64_C 165# define UINT64_C(C) C##ui64 166#endif 167 168#ifndef PRIx64 169# define PRIx64 "I64x" 170#endif 171 172#endif /* _MSC_VER */ 173 174/* Set defaults for constants which we cannot find. */ 175#if !defined(INT64_MAX) 176# define INT64_MAX 9223372036854775807LL 177#endif 178#if !defined(INT64_MIN) 179# define INT64_MIN ((-INT64_MAX)-1) 180#endif 181#if !defined(UINT64_MAX) 182# define UINT64_MAX 0xffffffffffffffffULL 183#endif 184 185#if __GNUC__ > 3 186#define END_WITH_NULL __attribute__((sentinel)) 187#else 188#define END_WITH_NULL 189#endif 190 191#ifndef HUGE_VALF 192#define HUGE_VALF (float)HUGE_VAL 193#endif 194 195#endif /* SUPPORT_DATATYPES_H */ 196