10b57cec5SDimitry Andric /*===-- include/llvm-c/DataTypes.h - Define fixed size types ------*- C -*-===*\
20b57cec5SDimitry Andric |*                                                                            *|
30b57cec5SDimitry Andric |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
40b57cec5SDimitry Andric |* Exceptions.                                                                *|
50b57cec5SDimitry Andric |* See https://llvm.org/LICENSE.txt for license information.                  *|
60b57cec5SDimitry Andric |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
70b57cec5SDimitry Andric |*                                                                            *|
80b57cec5SDimitry Andric |*===----------------------------------------------------------------------===*|
90b57cec5SDimitry Andric |*                                                                            *|
100b57cec5SDimitry Andric |* This file contains definitions to figure out the size of _HOST_ data types.*|
110b57cec5SDimitry Andric |* This file is important because different host OS's define different macros,*|
120b57cec5SDimitry Andric |* which makes portability tough.  This file exports the following            *|
130b57cec5SDimitry Andric |* definitions:                                                               *|
140b57cec5SDimitry Andric |*                                                                            *|
150b57cec5SDimitry Andric |*   [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types*|
160b57cec5SDimitry Andric |*   [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values.     *|
170b57cec5SDimitry Andric |*                                                                            *|
180b57cec5SDimitry Andric |* No library is required when using these functions.                         *|
190b57cec5SDimitry Andric |*                                                                            *|
200b57cec5SDimitry Andric |*===----------------------------------------------------------------------===*/
210b57cec5SDimitry Andric 
220b57cec5SDimitry Andric /* Please leave this file C-compatible. */
230b57cec5SDimitry Andric 
240b57cec5SDimitry Andric #ifndef LLVM_C_DATATYPES_H
250b57cec5SDimitry Andric #define LLVM_C_DATATYPES_H
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric #include <inttypes.h>
280b57cec5SDimitry Andric #include <stdint.h>
290b57cec5SDimitry Andric 
300b57cec5SDimitry Andric #ifndef _MSC_VER
310b57cec5SDimitry Andric 
320b57cec5SDimitry Andric #if !defined(UINT32_MAX)
330b57cec5SDimitry Andric # error "The standard header <cstdint> is not C++11 compliant. Must #define "\
340b57cec5SDimitry Andric         "__STDC_LIMIT_MACROS before #including llvm-c/DataTypes.h"
350b57cec5SDimitry Andric #endif
360b57cec5SDimitry Andric 
370b57cec5SDimitry Andric #if !defined(UINT32_C)
380b57cec5SDimitry Andric # error "The standard header <cstdint> is not C++11 compliant. Must #define "\
390b57cec5SDimitry Andric         "__STDC_CONSTANT_MACROS before #including llvm-c/DataTypes.h"
400b57cec5SDimitry Andric #endif
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric /* Note that <inttypes.h> includes <stdint.h>, if this is a C99 system. */
430b57cec5SDimitry Andric #include <sys/types.h>
440b57cec5SDimitry Andric 
450b57cec5SDimitry Andric #ifdef _AIX
460b57cec5SDimitry Andric // GCC is strict about defining large constants: they must have LL modifier.
470b57cec5SDimitry Andric #undef INT64_MAX
480b57cec5SDimitry Andric #undef INT64_MIN
490b57cec5SDimitry Andric #endif
500b57cec5SDimitry Andric 
510b57cec5SDimitry Andric #else /* _MSC_VER */
520b57cec5SDimitry Andric #ifdef __cplusplus
530b57cec5SDimitry Andric #include <cstddef>
540b57cec5SDimitry Andric #include <cstdlib>
550b57cec5SDimitry Andric #else
560b57cec5SDimitry Andric #include <stddef.h>
570b57cec5SDimitry Andric #include <stdlib.h>
580b57cec5SDimitry Andric #endif
590b57cec5SDimitry Andric #include <sys/types.h>
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric #if defined(_WIN64)
620b57cec5SDimitry Andric typedef signed __int64 ssize_t;
630b57cec5SDimitry Andric #else
640b57cec5SDimitry Andric typedef signed int ssize_t;
650b57cec5SDimitry Andric #endif /* _WIN64 */
660b57cec5SDimitry Andric 
670b57cec5SDimitry Andric #endif /* _MSC_VER */
680b57cec5SDimitry Andric 
690b57cec5SDimitry Andric /* Set defaults for constants which we cannot find. */
700b57cec5SDimitry Andric #if !defined(INT64_MAX)
710b57cec5SDimitry Andric # define INT64_MAX 9223372036854775807LL
720b57cec5SDimitry Andric #endif
730b57cec5SDimitry Andric #if !defined(INT64_MIN)
740b57cec5SDimitry Andric # define INT64_MIN ((-INT64_MAX)-1)
750b57cec5SDimitry Andric #endif
760b57cec5SDimitry Andric #if !defined(UINT64_MAX)
770b57cec5SDimitry Andric # define UINT64_MAX 0xffffffffffffffffULL
780b57cec5SDimitry Andric #endif
790b57cec5SDimitry Andric 
800b57cec5SDimitry Andric #endif /* LLVM_C_DATATYPES_H */
810b57cec5SDimitry Andric