include "spec/posix.td"
include "spec/stdc.td"
+// TODO: Eliminate all TypeDecl specializations. Since we define all public
+// types in their own self contained header files, the header generator can
+// produce the boiler plate which pulls in the type definitions.
+
def SizeT : TypeDecl<"size_t"> {
let Decl = [{
- #define __need_size_t
- #include <stddef.h>
+ #include <llvm-libc-types/size_t.h>
}];
}
def SSizeT : TypeDecl<"ssize_t"> {
let Decl = [{
- #define __need_ssize_t
- #include <__posix-types.h>
+ #include <llvm-libc-types/ssize_t.h>
}];
}
def OffT : TypeDecl<"off_t"> {
let Decl = [{
- #define __need_off_t
- #include <__posix-types.h>
+ #include <llvm-libc-types/off_t.h>
}];
}
def FloatT : TypeDecl<"float_t"> {
let Decl = [{
- #define __need_float_t
- #include <__llvm-libc-stdc-types.h>
+ #include <llvm-libc-types/float_t.h>
}];
}
def DoubleT : TypeDecl<"double_t"> {
let Decl = [{
- #define __need_double_t
- #include <__llvm-libc-stdc-types.h>
+ #include <llvm-libc-types/double_t.h>
}];
}
+add_subdirectory(llvm-libc-types)
add_header(
llvm_libc_common_h
__llvm-libc-common.h
)
-add_header(
- libc_posix_types
- HDR
- __posix-types.h
-)
-
-add_header(
- stdc_types
- HDR
- __llvm-libc-stdc-types.h
-)
-
add_gen_header(
ctype
DEF_FILE ctype.h.def
GEN_HDR math.h
DEPENDS
.llvm_libc_common_h
- .stdc_types
+ .llvm-libc-types.double_t
+ .llvm-libc-types.float_t
)
add_gen_header(
DEF_FILE unistd.h.def
GEN_HDR unistd.h
DEPENDS
- .libc_posix_types
.llvm_libc_common_h
+ .llvm-libc-types.size_t
+ .llvm-libc-types.ssize_t
)
# TODO: Not all platforms will have a include/sys directory. Add the sys
DEF_FILE sys/mman.h.def
GEN_HDR sys/mman.h
DEPENDS
- .libc_posix_types
.llvm_libc_common_h
+ .llvm-libc-types.off_t
+ .llvm-libc-types.ssize_t
)
add_gen_header(
+++ /dev/null
-//===-- Definitions of common types from the C standard. ------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// This header file does not have a header guard. It is internal to LLVM libc
-// and intended to be used to pick specific definitions without polluting the
-// public headers with unnecessary definitions.
-
-#undef __LLVM_LIBC_FLOAT_T
-#undef __LLVM_LIBC_DOUBLE_T
-
-#if !defined(__FLT_EVAL_METHOD__) || __FLT_EVAL_METHOD__ == 0
-#define __LLVM_LIBC_FLOAT_T float
-#define __LLVM_LIBC_DOUBLE_T double
-#elif __FLT_EVAL_METHOD__ == 1
-#define __LLVM_LIBC_FLOAT_T double
-#define __LLVM_LIBC_DOUBLE_T double
-#elif __FLT_EVAL_METHOD__ == 2
-#define __LLVM_LIBC_FLOAT_T long double
-#define __LLVM_LIBC_DOUBLE_T long double
-#else
-#error "Unsupported __FLT_EVAL_METHOD__ value."
-#endif
-
-#if defined(__need_float_t) && !defined(__llvm_libc_float_t_defined)
-typedef __LLVM_LIBC_FLOAT_T float_t;
-#define __llvm_libc_float_t_defined
-#endif // __need_float_t
-
-#if defined(__need_double_t) && !defined(__llvm_libc_double_t_defined)
-typedef __LLVM_LIBC_DOUBLE_T double_t;
-#define __llvm_libc_double_t_defined
-#endif // __need_double_t
+++ /dev/null
-//===-- Definitions of common POSIX types ---------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// This header file does not have a header guard. It is internal to LLVM libc
-// and intended to be used to pick specific definitions without polluting the
-// public headers with unnecessary definitions.
-
-#if defined(__need_off_t) && !defined(__llvm_libc_off_t_defined)
-typedef __INT64_TYPE__ off_t;
-#define __llvm_libc_off_t_defined
-#endif // __need_off_t
-
-#if defined(__need_ssize_t) && !defined(__llvm_libc_ssize_t_defined)
-typedef __INT64_TYPE__ ssize_t;
-#define __llvm_libc_ssize_t_defined
-#endif // __need_ssize_t
--- /dev/null
+add_header(double_t HDR double_t.h)
+add_header(float_t HDR float_t.h)
+add_header(off_t HDR off_t.h)
+add_header(size_t HDR size_t.h)
+add_header(ssize_t HDR ssize_t.h)
--- /dev/null
+//===-- Definition of double_t type ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_TYPES_DOUBLE_T_H__
+#define __LLVM_LIBC_TYPES_DOUBLE_T_H__
+
+#if !defined(__FLT_EVAL_METHOD__) || __FLT_EVAL_METHOD__ == 0
+#define __LLVM_LIBC_DOUBLE_T double
+#elif __FLT_EVAL_METHOD__ == 1
+#define __LLVM_LIBC_DOUBLE_T double
+#elif __FLT_EVAL_METHOD__ == 2
+#define __LLVM_LIBC_DOUBLE_T long double
+#else
+#error "Unsupported __FLT_EVAL_METHOD__ value."
+#endif
+
+typedef __LLVM_LIBC_DOUBLE_T double_t;
+
+#endif // __LLVM_LIBC_TYPES_DOUBLE_T_H__
--- /dev/null
+//===-- Definition of float_t type ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_TYPES_FLOAT_T_H__
+#define __LLVM_LIBC_TYPES_FLOAT_T_H__
+
+#if !defined(__FLT_EVAL_METHOD__) || __FLT_EVAL_METHOD__ == 0
+#define __LLVM_LIBC_FLOAT_T float
+#elif __FLT_EVAL_METHOD__ == 1
+#define __LLVM_LIBC_FLOAT_T double
+#elif __FLT_EVAL_METHOD__ == 2
+#define __LLVM_LIBC_FLOAT_T long double
+#else
+#error "Unsupported __FLT_EVAL_METHOD__ value."
+#endif
+
+typedef __LLVM_LIBC_FLOAT_T float_t;
+
+#endif // __LLVM_LIBC_TYPES_FLOAT_T_H__
--- /dev/null
+//===-- Definition of off_t type ------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_TYPES_OFF_T_H__
+#define __LLVM_LIBC_TYPES_OFF_T_H__
+
+typedef __INT64_TYPE__ off_t;
+
+#endif // __LLVM_LIBC_TYPES_OFF_T_H__
--- /dev/null
+//===-- Definition of size_t types ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_TYPES_SIZE_T_H__
+#define __LLVM_LIBC_TYPES_SIZE_T_H__
+
+// Since __need_size_t is defined, we get the definition of size_t from the
+// standalone C header stddef.h. Also, because __need_size_t is defined,
+// including stddef.h will pull only the type size_t and nothing else.a
+#define __need_size_t
+#include <stddef.h>
+
+#endif // __LLVM_LIBC_TYPES_SIZE_T_H__
--- /dev/null
+//===-- Definition of ssize_t type ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_TYPES_SSIZE_T_H__
+#define __LLVM_LIBC_TYPES_SSIZE_T_H__
+
+typedef __INT64_TYPE__ ssize_t;
+
+#endif // __LLVM_LIBC_TYPES_SSIZE_T_H__