[libcxx] r249800 - Split <stdlib.h> out of <cstdlib>.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 8 18:41:45 PDT 2015


Author: rsmith
Date: Thu Oct  8 20:41:45 2015
New Revision: 249800

URL: http://llvm.org/viewvc/llvm-project?rev=249800&view=rev
Log:
Split <stdlib.h> out of <cstdlib>.

Added:
    libcxx/trunk/include/stdlib.h
      - copied, changed from r249736, libcxx/trunk/include/cstdlib
Modified:
    libcxx/trunk/include/cstdlib
    libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp

Modified: libcxx/trunk/include/cstdlib
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdlib?rev=249800&r1=249799&r2=249800&view=diff
==============================================================================
--- libcxx/trunk/include/cstdlib (original)
+++ libcxx/trunk/include/cstdlib Thu Oct  8 20:41:45 2015
@@ -84,9 +84,6 @@ void *aligned_alloc(size_t alignment, si
 
 #include <__config>
 #include <stdlib.h>
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/locale_win32.h"
-#endif // _LIBCPP_MSVCRT
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -131,20 +128,14 @@ using ::getenv;
 using ::system;
 using ::bsearch;
 using ::qsort;
-#undef abs
 using ::abs;
-#undef labs
 using ::labs;
 #ifndef _LIBCPP_HAS_NO_LONG_LONG
-#undef llabs
 using ::llabs;
 #endif // _LIBCPP_HAS_NO_LONG_LONG
-#undef div
 using ::div;
-#undef ldiv
 using ::ldiv;
 #ifndef _LIBCPP_HAS_NO_LONG_LONG
-#undef lldiv
 using ::lldiv;
 #endif // _LIBCPP_HAS_NO_LONG_LONG
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
@@ -162,19 +153,6 @@ using ::quick_exit;
 using ::aligned_alloc;
 #endif
 
-// MSVCRT already has the correct prototype in <stdlib.h> #ifdef __cplusplus
-#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
-inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-
-inline _LIBCPP_INLINE_VISIBILITY  ldiv_t div(     long __x,      long __y) _NOEXCEPT {return  ldiv(__x, __y);}
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-#endif // _LIBCPP_MSVCRT
-
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_CSTDLIB

Copied: libcxx/trunk/include/stdlib.h (from r249736, libcxx/trunk/include/cstdlib)
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stdlib.h?p2=libcxx/trunk/include/stdlib.h&p1=libcxx/trunk/include/cstdlib&r1=249736&r2=249800&rev=249800&view=diff
==============================================================================
--- libcxx/trunk/include/cstdlib (original)
+++ libcxx/trunk/include/stdlib.h Thu Oct  8 20:41:45 2015
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===--------------------------- cstdlib ----------------------------------===//
+//===--------------------------- stdlib.h ---------------------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,11 +8,19 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef _LIBCPP_CSTDLIB
-#define _LIBCPP_CSTDLIB
+#if defined(__need_malloc_and_calloc)
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <stdlib.h>
+
+#elif !defined(_LIBCPP_STDLIB_H)
+#define _LIBCPP_STDLIB_H
 
 /*
-    cstdlib synopsis
+    stdlib.h synopsis
 
 Macros:
 
@@ -22,9 +30,6 @@ Macros:
     NULL
     RAND_MAX
 
-namespace std
-{
-
 Types:
 
     size_t
@@ -78,91 +83,33 @@ int at_quick_exit(void (*func)(void))
 void quick_exit(int status);                                              // C++11
 void *aligned_alloc(size_t alignment, size_t size);                       // C11
 
-}  // std
-
 */
 
 #include <__config>
-#include <stdlib.h>
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/locale_win32.h"
-#endif // _LIBCPP_MSVCRT
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-_LIBCPP_BEGIN_NAMESPACE_STD
+#include_next <stdlib.h>
+
+#ifdef __cplusplus
+extern "C++" {
+
+#ifdef _LIBCPP_MSVCRT
+#include "support/win32/locale_win32.h"
+#endif // _LIBCPP_MSVCRT
 
-using ::size_t;
-using ::div_t;
-using ::ldiv_t;
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::lldiv_t;
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::atof;
-using ::atoi;
-using ::atol;
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::atoll;
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::strtod;
-using ::strtof;
-using ::strtold;
-using ::strtol;
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::strtoll;
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::strtoul;
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::strtoull;
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::rand;
-using ::srand;
-using ::calloc;
-using ::free;
-using ::malloc;
-using ::realloc;
-using ::abort;
-using ::atexit;
-using ::exit;
-using ::_Exit;
-using ::getenv;
-using ::system;
-using ::bsearch;
-using ::qsort;
 #undef abs
-using ::abs;
-#undef labs
-using ::labs;
-#ifndef _LIBCPP_HAS_NO_LONG_LONG
-#undef llabs
-using ::llabs;
-#endif // _LIBCPP_HAS_NO_LONG_LONG
 #undef div
-using ::div;
+#undef labs
 #undef ldiv
-using ::ldiv;
 #ifndef _LIBCPP_HAS_NO_LONG_LONG
+#undef llabs
 #undef lldiv
-using ::lldiv;
-#endif // _LIBCPP_HAS_NO_LONG_LONG
-#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
-using ::mblen;
-using ::mbtowc;
-using ::wctomb;
-#endif
-using ::mbstowcs;
-using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
-using ::at_quick_exit;
-using ::quick_exit;
-#endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
-using ::aligned_alloc;
 #endif
 
-// MSVCRT already has the correct prototype in <stdlib.h> #ifdef __cplusplus
+// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
 #if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
 inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
 #ifndef _LIBCPP_HAS_NO_LONG_LONG
@@ -173,8 +120,9 @@ inline _LIBCPP_INLINE_VISIBILITY  ldiv_t
 #ifndef _LIBCPP_HAS_NO_LONG_LONG
 inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);}
 #endif // _LIBCPP_HAS_NO_LONG_LONG
-#endif // _LIBCPP_MSVCRT
+#endif // _LIBCPP_MSVCRT / __sun__ / _AIX
 
-_LIBCPP_END_NAMESPACE_STD
+}  // extern "C++"
+#endif  // __cplusplus
 
-#endif  // _LIBCPP_CSTDLIB
+#endif  // _LIBCPP_STDLIB_H

Modified: libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp?rev=249800&r1=249799&r2=249800&view=diff
==============================================================================
--- libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp Thu Oct  8 20:41:45 2015
@@ -18,6 +18,30 @@
 #pragma clang diagnostic ignored "-Wnonnull"
 #endif
 
+#ifdef abs
+#error abs is defined
+#endif
+
+#ifdef labs
+#error labs is defined
+#endif
+
+#ifdef llabs
+#error llabs is defined
+#endif
+
+#ifdef div
+#error div is defined
+#endif
+
+#ifdef ldiv
+#error ldiv is defined
+#endif
+
+#ifdef lldiv
+#error lldiv is defined
+#endif
+
 #ifndef EXIT_FAILURE
 #error EXIT_FAILURE not defined
 #endif




More information about the cfe-commits mailing list