Yes, it does make sense to use that pattern, for the case of REENT_SMALL.

@jfb do we lose anything by implementing these shims here, and then later 
pushing them into newlib?

http://reviews.llvm.org/D5420

Files:
  include/cmath
  include/cstdio
  include/support/newlib/math.h
Index: include/cmath
===================================================================
--- include/cmath
+++ include/cmath
@@ -305,6 +305,10 @@
 #include "support/win32/math_win32.h"
 #endif
 
+#if defined(_NEWLIB_VERSION)
+#include "support/newlib/math.h"
+#endif
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
Index: include/cstdio
===================================================================
--- include/cstdio
+++ include/cstdio
@@ -120,6 +120,24 @@
 inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);}
 #endif  // putc
 
+#ifdef clearerr
+inline _LIBCPP_INLINE_VISIBILITY void __libcpp_clearerr(FILE* __stream) { return clearerr(__stream); }
+#undef clearerr
+inline _LIBCPP_INLINE_VISIBILITY void clearerr(FILE* __stream) { return __libcpp_clearerr(__stream); }
+#endif  // clearerr
+
+#ifdef feof
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_feof(FILE* __stream) { return feof(__stream); }
+#undef feof
+inline _LIBCPP_INLINE_VISIBILITY int feof(FILE* __stream) { return __libcpp_feof(__stream); }
+#endif  // feof
+
+#ifdef ferror
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ferror(FILE* __stream) { return ferror(__stream); }
+#undef ferror
+inline _LIBCPP_INLINE_VISIBILITY int ferror(FILE* __stream) { return __libcpp_ferror(__stream); }
+#endif  // ferror
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::FILE;
Index: include/support/newlib/math.h
===================================================================
--- include/support/newlib/math.h
+++ include/support/newlib/math.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_NEWLIB_MATH_H
+#define _LIBCPP_SUPPORT_NEWLIB_MATH_H
+
+#if !defined(_NEWLIB_VERSION)
+#error This should only be used when Newlib is the underlying libc
+#endif
+
+#if __cplusplus
+extern "C" {
+#endif
+
+inline _LIBCPP_INLINE_VISIBILITY long double log2l(long double __x) _NOEXCEPT {
+    return __builtin_log2(__x);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY long double logbl(long double __x) _NOEXCEPT {
+    return __builtin_logb(__x);
+}
+
+#if __cplusplus
+}
+#endif
+
+#endif
+
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to