Skip to content

Commit 8931477

Browse files
committed
fixup! [libc][math][c23] Add fabsf16 C23 math function
Move _Float16 detection header to llvm-libc-macros/float16-macros.h.
1 parent 41220f5 commit 8931477

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

libc/config/linux/api.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def IntTypesAPI : PublicAPI<"inttypes.h"> {
6060
}
6161

6262
def MathAPI : PublicAPI<"math.h"> {
63-
let Types = ["double_t", "float_t", "float16", "float128"];
63+
let Types = ["double_t", "float_t", "float128"];
6464
}
6565

6666
def FenvAPI: PublicAPI<"fenv.h"> {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ add_macro_header(
9191
float-macros.h
9292
)
9393

94+
add_macro_header(
95+
float16_macros
96+
HDR
97+
float16-macros.h
98+
)
99+
94100
add_macro_header(
95101
limits_macros
96102
HDR
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- Detection of _Float16 compiler builtin type -----------------------===//
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_FLOAT16_MACROS_H
10+
#define LLVM_LIBC_MACROS_FLOAT16_MACROS_H
11+
12+
#if defined(__FLT16_MANT_DIG__) && \
13+
(!defined(__GNUC__) || __GNUC__ >= 13 || defined(__clang__))
14+
#define LIBC_TYPES_HAS_FLOAT16
15+
#endif
16+
17+
#endif // LLVM_LIBC_MACROS_FLOAT16_MACROS_H

libc/include/math.h.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLVM_LIBC_MATH_H
1111

1212
#include "__llvm-libc-common.h"
13+
#include "llvm-libc-macros/float16-macros.h"
1314
#include "llvm-libc-macros/math-macros.h"
1415
#include "llvm-libc-types/float128.h"
1516

libc/spec/stdc.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ def StdC : StandardSpec<"stdc"> {
378378
[
379379
NamedType<"float_t">,
380380
NamedType<"double_t">,
381-
NamedType<"float16">,
382381
NamedType<"float128">,
383382
],
384383
[], // Enumerations

libc/src/__support/macros/properties/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ add_header_library(
3434
.cpu_features
3535
.os
3636
libc.hdr.float_macros
37+
libc.include.llvm-libc-macros.float16_macros
3738
libc.include.llvm-libc-types.float128
3839
)

libc/src/__support/macros/properties/types.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H
1212

1313
#include "hdr/float_macros.h" // LDBL_MANT_DIG
14-
#include "include/llvm-libc-types/float128.h" // float128
15-
#include "include/llvm-libc-types/float16.h" // LIBC_TYPES_HAS_FLOAT16
14+
#include "include/llvm-libc-macros/float16-macros.h" // LIBC_TYPES_HAS_FLOAT16
15+
#include "include/llvm-libc-types/float128.h" // float128
1616
#include "src/__support/macros/properties/architectures.h"
1717
#include "src/__support/macros/properties/compiler.h"
1818
#include "src/__support/macros/properties/cpu_features.h"
@@ -40,7 +40,8 @@
4040
#endif // defined(__SIZEOF_INT128__)
4141

4242
// -- float16 support ---------------------------------------------------------
43-
// LIBC_TYPES_HAS_FLOAT16 is provided by "include/llvm-libc-types/float16.h"
43+
// LIBC_TYPES_HAS_FLOAT16 is provided by
44+
// "include/llvm-libc-macros/float16-macros.h"
4445
#ifdef LIBC_TYPES_HAS_FLOAT16
4546
// Type alias for internal use.
4647
using float16 = _Float16;

0 commit comments

Comments
 (0)