Skip to content

Commit d93779d

Browse files
committed
[Headers] Enable #include_next<float.h> on Darwin
Allows darwin targets to provide additional definitions and implementation specifc values for float.h rdar://problem/21961491 llvm-svn: 289018
1 parent fd461fe commit d93779d

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

clang/lib/Headers/float.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@
2727
/* If we're on MinGW, fall back to the system's float.h, which might have
2828
* additional definitions provided for Windows.
2929
* For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
30+
*
31+
* Also fall back on Darwin to allow additional definitions and
32+
* implementation-defined values.
3033
*/
31-
#if (defined(__MINGW32__) || defined(_MSC_VER)) && __STDC_HOSTED__ && \
32-
__has_include_next(<float.h>)
34+
#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
35+
__STDC_HOSTED__ && __has_include_next(<float.h>)
3336
# include_next <float.h>
3437

3538
/* Undefine anything that we'll be redefining below. */
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef SYSFLOAT_H
2+
#define SYSFLOAT_H
3+
4+
#define FLT_HAS_SUBNORM 1
5+
6+
#endif /* SYSFLOAT_H */

clang/test/Headers/float-darwin.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// REQUIRES: system-darwin
2+
// RUN: %clang -target x86_64-apple-darwin10 -fsyntax-only -std=c11 -isysroot %S/Inputs %s
3+
#include <float.h>
4+
5+
// Test the #include_next on float.h works on Darwin.
6+
#ifndef FLT_HAS_SUBNORM
7+
#error "FLT_HAS_SUBNORM not defined"
8+
#endif
9+
10+
// Test that definition from builtin are also present.
11+
#ifndef FLT_MAX
12+
#error "FLT_MAX not defined"
13+
#endif

0 commit comments

Comments
 (0)