llvm.org GIT mirror llvm / 6290580
Assume existence of inttypes.h and stdint.h in DataTypes.h. These should exist in all toolchains LLVM supports nowadays. Enables making DataTypes.h a regular header instead of a .h.cmake file and allows deleting a bunch of cmake goop (which should also speed up cmake configure time a bit). All the code this removes is 9+ years old. https://reviews.llvm.org/D45155 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328970 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 2 years ago
5 changed file(s) with 90 addition(s) and 181 deletion(s). Raw diff Collapse all Expand all
743743 configure_file(
744744 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/abi-breaking.h.cmake
745745 ${LLVM_INCLUDE_DIR}/llvm/Config/abi-breaking.h)
746 configure_file(
747 ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/DataTypes.h.cmake
748 ${LLVM_INCLUDE_DIR}/llvm-c/DataTypes.h)
749746
750747 # Add target for generating source rpm package.
751748 set(LLVM_SRPM_USER_BINARY_SPECFILE ${CMAKE_CURRENT_SOURCE_DIR}/llvm.spec.in
2424 list(APPEND CMAKE_REQUIRED_LIBRARIES "cxxrt")
2525 endif()
2626
27 # Helper macros and functions
28 macro(add_cxx_include result files)
29 set(${result} "")
30 foreach (file_name ${files})
31 set(${result} "${${result}}#include<${file_name}>\n")
32 endforeach()
33 endmacro(add_cxx_include files result)
34
35 function(check_type_exists type files variable)
36 add_cxx_include(includes "${files}")
37 CHECK_CXX_SOURCE_COMPILES("
38 ${includes} ${type} typeVar;
39 int main() {
40 return 0;
41 }
42 " ${variable})
43 endfunction()
44
4527 # include checks
4628 check_include_file(dirent.h HAVE_DIRENT_H)
4729 check_include_file(dlfcn.h HAVE_DLFCN_H)
4830 check_include_file(errno.h HAVE_ERRNO_H)
4931 check_include_file(fcntl.h HAVE_FCNTL_H)
50 check_include_file(inttypes.h HAVE_INTTYPES_H)
5132 check_include_file(link.h HAVE_LINK_H)
5233 check_include_file(malloc.h HAVE_MALLOC_H)
5334 check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
5637 check_include_file(pthread.h HAVE_PTHREAD_H)
5738 endif()
5839 check_include_file(signal.h HAVE_SIGNAL_H)
59 check_include_file(stdint.h HAVE_STDINT_H)
6040 check_include_file(sys/dir.h HAVE_SYS_DIR_H)
6141 check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
6242 check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
287267 check_library_exists(c pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP)
288268 check_library_exists(c pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP)
289269 endif()
290
291 set(headers "sys/types.h")
292
293 if (HAVE_INTTYPES_H)
294 set(headers ${headers} "inttypes.h")
295 endif()
296
297 if (HAVE_STDINT_H)
298 set(headers ${headers} "stdint.h")
299 endif()
300
301 check_type_exists(int64_t "${headers}" HAVE_INT64_T)
302 check_type_exists(uint64_t "${headers}" HAVE_UINT64_T)
303 check_type_exists(u_int64_t "${headers}" HAVE_U_INT64_T)
304270
305271 # available programs checks
306272 function(llvm_find_program name)
8888 /* Define to 1 if you have the `getrusage' function. */
8989 #cmakedefine HAVE_GETRUSAGE ${HAVE_GETRUSAGE}
9090
91 /* Define to 1 if the system has the type `int64_t'. */
92 #cmakedefine HAVE_INT64_T ${HAVE_INT64_T}
93
9491 /* Define to 1 if you have the header file. */
9592 #cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
9693
246243 /* Define to 1 if you have the header file. */
247244 #cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H}
248245
249 /* Define to 1 if the system has the type `uint64_t'. */
250 #cmakedefine HAVE_UINT64_T ${HAVE_UINT64_T}
251
252246 /* Define to 1 if you have the header file. */
253247 #cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
254
255 /* Define to 1 if the system has the type `u_int64_t'. */
256 #cmakedefine HAVE_U_INT64_T ${HAVE_U_INT64_T}
257248
258249 /* Define to 1 if you have the header file. */
259250 #cmakedefine HAVE_VALGRIND_VALGRIND_H ${HAVE_VALGRIND_VALGRIND_H}
0 /*===-- include/llvm-c/DataTypes.h - Define fixed size types ------*- C -*-===*\
1 |* *|
2 |* The LLVM Compiler Infrastructure *|
3 |* *|
4 |* This file is distributed under the University of Illinois Open Source *|
5 |* License. See LICENSE.TXT for details. *|
6 |* *|
7 |*===----------------------------------------------------------------------===*|
8 |* *|
9 |* This file contains definitions to figure out the size of _HOST_ data types.*|
10 |* This file is important because different host OS's define different macros,*|
11 |* which makes portability tough. This file exports the following *|
12 |* definitions: *|
13 |* *|
14 |* [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types*|
15 |* [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values. *|
16 |* *|
17 |* No library is required when using these functions. *|
18 |* *|
19 |*===----------------------------------------------------------------------===*/
20
21 /* Please leave this file C-compatible. */
22
23 #ifndef LLVM_C_DATATYPES_H
24 #define LLVM_C_DATATYPES_H
25
26 #ifdef __cplusplus
27 #include
28 #else
29 #include
30 #endif
31
32 #include
33 #include
34
35 #ifndef _MSC_VER
36
37 #if !defined(UINT32_MAX)
38 # error "The standard header is not C++11 compliant. Must #define "\
39 "__STDC_LIMIT_MACROS before #including llvm-c/DataTypes.h"
40 #endif
41
42 #if !defined(UINT32_C)
43 # error "The standard header is not C++11 compliant. Must #define "\
44 "__STDC_CONSTANT_MACROS before #including llvm-c/DataTypes.h"
45 #endif
46
47 /* Note that includes , if this is a C99 system. */
48 #include
49
50 #ifdef _AIX
51 // GCC is strict about defining large constants: they must have LL modifier.
52 #undef INT64_MAX
53 #undef INT64_MIN
54 #endif
55
56 #else /* _MSC_VER */
57 #ifdef __cplusplus
58 #include
59 #include
60 #else
61 #include
62 #include
63 #endif
64 #include
65
66 #if defined(_WIN64)
67 typedef signed __int64 ssize_t;
68 #else
69 typedef signed int ssize_t;
70 #endif /* _WIN64 */
71
72 #endif /* _MSC_VER */
73
74 /* Set defaults for constants which we cannot find. */
75 #if !defined(INT64_MAX)
76 # define INT64_MAX 9223372036854775807LL
77 #endif
78 #if !defined(INT64_MIN)
79 # define INT64_MIN ((-INT64_MAX)-1)
80 #endif
81 #if !defined(UINT64_MAX)
82 # define UINT64_MAX 0xffffffffffffffffULL
83 #endif
84
85 #ifndef HUGE_VALF
86 #define HUGE_VALF (float)HUGE_VAL
87 #endif
88
89 #endif /* LLVM_C_DATATYPES_H */
+0
-135
include/llvm-c/DataTypes.h.cmake less more
None /*===-- include/llvm-c/DataTypes.h - Define fixed size types ------*- C -*-===*\
1 |* *|
2 |* The LLVM Compiler Infrastructure *|
3 |* *|
4 |* This file is distributed under the University of Illinois Open Source *|
5 |* License. See LICENSE.TXT for details. *|
6 |* *|
7 |*===----------------------------------------------------------------------===*|
8 |* *|
9 |* This file contains definitions to figure out the size of _HOST_ data types.*|
10 |* This file is important because different host OS's define different macros,*|
11 |* which makes portability tough. This file exports the following *|
12 |* definitions: *|
13 |* *|
14 |* [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types*|
15 |* [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values. *|
16 |* *|
17 |* No library is required when using these functions. *|
18 |* *|
19 |*===----------------------------------------------------------------------===*/
20
21 /* Please leave this file C-compatible. */
22
23 #ifndef LLVM_C_DATATYPES_H
24 #define LLVM_C_DATATYPES_H
25
26 #cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
27 #cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
28 #cmakedefine HAVE_UINT64_T ${HAVE_UINT64_T}
29 #cmakedefine HAVE_U_INT64_T ${HAVE_U_INT64_T}
30
31 #ifdef __cplusplus
32 #include
33 #else
34 #include
35 #endif
36
37 #ifdef __cplusplus
38 #include
39 #else
40 #ifdef HAVE_INTTYPES_H
41 #include
42 #endif
43 #endif
44
45 #ifdef __cplusplus
46 #include
47 #else
48 #ifdef HAVE_STDINT_H
49 #include
50 #else
51 #error "Compiler must provide an implementation of stdint.h"
52 #endif
53 #endif
54
55 #ifndef _MSC_VER
56
57 #if !defined(UINT32_MAX)
58 # error "The standard header is not C++11 compliant. Must #define "\
59 "__STDC_LIMIT_MACROS before #including llvm-c/DataTypes.h"
60 #endif
61
62 #if !defined(UINT32_C)
63 # error "The standard header is not C++11 compliant. Must #define "\
64 "__STDC_CONSTANT_MACROS before #including llvm-c/DataTypes.h"
65 #endif
66
67 /* Note that includes , if this is a C99 system. */
68 #include
69
70 #ifdef _AIX
71 // GCC is strict about defining large constants: they must have LL modifier.
72 #undef INT64_MAX
73 #undef INT64_MIN
74 #endif
75
76 /* Handle incorrect definition of uint64_t as u_int64_t */
77 #ifndef HAVE_UINT64_T
78 #ifdef HAVE_U_INT64_T
79 typedef u_int64_t uint64_t;
80 #else
81 # error "Don't have a definition for uint64_t on this platform"
82 #endif
83 #endif
84
85 #else /* _MSC_VER */
86 #ifdef __cplusplus
87 #include
88 #include
89 #else
90 #include
91 #include
92 #endif
93 #include
94
95 #if defined(_WIN64)
96 typedef signed __int64 ssize_t;
97 #else
98 typedef signed int ssize_t;
99 #endif /* _WIN64 */
100
101 #ifndef HAVE_INTTYPES_H
102 #define PRId64 "I64d"
103 #define PRIi64 "I64i"
104 #define PRIo64 "I64o"
105 #define PRIu64 "I64u"
106 #define PRIx64 "I64x"
107 #define PRIX64 "I64X"
108
109 #define PRId32 "d"
110 #define PRIi32 "i"
111 #define PRIo32 "o"
112 #define PRIu32 "u"
113 #define PRIx32 "x"
114 #define PRIX32 "X"
115 #endif /* HAVE_INTTYPES_H */
116
117 #endif /* _MSC_VER */
118
119 /* Set defaults for constants which we cannot find. */
120 #if !defined(INT64_MAX)
121 # define INT64_MAX 9223372036854775807LL
122 #endif
123 #if !defined(INT64_MIN)
124 # define INT64_MIN ((-INT64_MAX)-1)
125 #endif
126 #if !defined(UINT64_MAX)
127 # define UINT64_MAX 0xffffffffffffffffULL
128 #endif
129
130 #ifndef HUGE_VALF
131 #define HUGE_VALF (float)HUGE_VAL
132 #endif
133
134 #endif /* LLVM_C_DATATYPES_H */