Skip to content

Commit c80d68a

Browse files
authored
[libc] Add float.h header. (#78737)
1 parent d0d0727 commit c80d68a

File tree

14 files changed

+68
-0
lines changed

14 files changed

+68
-0
lines changed

libc/config/baremetal/arm/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set(TARGET_PUBLIC_HEADERS
22
libc.include.ctype
33
libc.include.fenv
44
libc.include.errno
5+
libc.include.float
56
libc.include.inttypes
67
libc.include.math
78
libc.include.stdio

libc/config/baremetal/riscv/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set(TARGET_PUBLIC_HEADERS
22
libc.include.ctype
33
libc.include.fenv
44
libc.include.errno
5+
libc.include.float
56
libc.include.inttypes
67
libc.include.math
78
libc.include.stdio

libc/config/darwin/arm/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set(TARGET_PUBLIC_HEADERS
22
libc.include.ctype
33
libc.include.errno
44
libc.include.fenv
5+
libc.include.float
56
libc.include.inttypes
67
libc.include.math
78
libc.include.stdlib

libc/config/darwin/x86_64/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set(TARGET_PUBLIC_HEADERS
33
libc.include.errno
44
# Fenv is currently disabled.
55
#libc.include.fenv
6+
libc.include.float
67
libc.include.inttypes
78
libc.include.math
89
libc.include.stdlib

libc/config/gpu/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set(TARGET_PUBLIC_HEADERS
22
libc.include.assert
33
libc.include.ctype
44
libc.include.string
5+
libc.include.float
56
libc.include.inttypes
67
libc.include.math
78
libc.include.fenv

libc/config/linux/aarch64/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set(TARGET_PUBLIC_HEADERS
44
libc.include.errno
55
libc.include.features
66
libc.include.fenv
7+
libc.include.float
78
libc.include.inttypes
89
libc.include.math
910
libc.include.pthread

libc/config/linux/arm/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set(TARGET_PUBLIC_HEADERS
22
libc.include.ctype
33
libc.include.fenv
44
libc.include.errno
5+
libc.include.float
56
libc.include.inttypes
67
libc.include.math
78
libc.include.stdlib

libc/config/linux/riscv/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(TARGET_PUBLIC_HEADERS
66
libc.include.fcntl
77
libc.include.features
88
libc.include.fenv
9+
libc.include.float
910
libc.include.inttypes
1011
libc.include.math
1112
libc.include.pthread

libc/config/linux/x86_64/headers.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(TARGET_PUBLIC_HEADERS
66
libc.include.fcntl
77
libc.include.features
88
libc.include.fenv
9+
libc.include.float
910
libc.include.inttypes
1011
libc.include.math
1112
libc.include.pthread

libc/include/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ add_gen_header(
7575
.llvm-libc-types.imaxdiv_t
7676
)
7777

78+
add_gen_header(
79+
float
80+
DEF_FILE float.h.def
81+
GEN_HDR float.h
82+
DEPENDS
83+
.llvm-libc-macros.float_macros
84+
)
85+
7886
add_gen_header(
7987
math
8088
DEF_FILE math.h.def

libc/include/float.h.def

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- C standard library header float.h ---------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_FLOAT_H
10+
#define LLVM_LIBC_FLOAT_H
11+
12+
#include <llvm-libc-macros/float-macros.h>
13+
14+
#endif // LLVM_LIBC_FLOAT_H

libc/include/llvm-libc-macros/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ add_macro_header(
6767
file-seek-macros.h
6868
)
6969

70+
add_macro_header(
71+
float_macros
72+
HDR
73+
float-macros.h
74+
)
75+
7076
add_macro_header(
7177
math_macros
7278
HDR
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Definition of macros from float.h ---------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __LLVM_LIBC_MACROS_FLOAT_MACROS_H
10+
#define __LLVM_LIBC_MACROS_FLOAT_MACROS_H
11+
12+
#undef FLT_MANT_DIG
13+
#define FLT_MANT_DIG __FLT_MANT_DIG__
14+
15+
#undef DBL_MANT_DIG
16+
#define DBL_MANT_DIG __DBL_MANT_DIG__
17+
18+
#undef LDBL_MANT_DIG
19+
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
20+
21+
#endif // __LLVM_LIBC_MACROS_FLOAT_MACROS_H

libc/spec/stdc.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,15 @@ def StdC : StandardSpec<"stdc"> {
847847
]
848848
>;
849849

850+
HeaderSpec Float = HeaderSpec<
851+
"float.h",
852+
[
853+
Macro<"FLT_MANT_DIG">,
854+
Macro<"DBL_MANT_DIG">,
855+
Macro<"LDBL_MANT_DIG">,
856+
]
857+
>;
858+
850859
NamedType SigAtomicT = NamedType<"sig_atomic_t">;
851860
HeaderSpec Signal = HeaderSpec<
852861
"signal.h",
@@ -1149,6 +1158,7 @@ def StdC : StandardSpec<"stdc"> {
11491158
CType,
11501159
Errno,
11511160
Fenv,
1161+
Float,
11521162
Math,
11531163
String,
11541164
StdIO,

0 commit comments

Comments
 (0)