diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-04-05 01:46:13 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-05 01:46:13 -0400 |
| commit | 0cd31fc7ff157551cfbba5da35cd79f118d2a2e3 (patch) | |
| tree | a308488f5d85184c8ec402fb3f55f1cf2704443e /lib/libcxx/include/stdlib.h | |
| parent | 8acedfd5baabab705946ad097746f9183ef62420 (diff) | |
| parent | cefe65c1b8abe65a22d4b68410db1be264fdeda0 (diff) | |
| download | zig-0cd31fc7ff157551cfbba5da35cd79f118d2a2e3.tar.gz zig-0cd31fc7ff157551cfbba5da35cd79f118d2a2e3.zip | |
Merge pull request #22780 from ziglang/llvm20
LLVM 20
Diffstat (limited to 'lib/libcxx/include/stdlib.h')
| -rw-r--r-- | lib/libcxx/include/stdlib.h | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/lib/libcxx/include/stdlib.h b/lib/libcxx/include/stdlib.h index a74344d491..39550f36bb 100644 --- a/lib/libcxx/include/stdlib.h +++ b/lib/libcxx/include/stdlib.h @@ -7,17 +7,6 @@ // //===----------------------------------------------------------------------===// -#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 - /* stdlib.h synopsis @@ -84,68 +73,78 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 */ +#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) +# include <__cxx03/stdlib.h> +#else # include <__config> # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header # endif +// The inclusion of the system's <stdlib.h> is intentionally done once outside of any include +// guards because some code expects to be able to include the underlying system header multiple +// times to get different definitions based on the macros that are set before inclusion. # if __has_include_next(<stdlib.h>) # include_next <stdlib.h> # endif -# ifdef __cplusplus +# if !defined(_LIBCPP_STDLIB_H) +# define _LIBCPP_STDLIB_H + +# ifdef __cplusplus extern "C++" { // abs -# ifdef abs -# undef abs -# endif -# ifdef labs -# undef labs -# endif -# ifdef llabs -# undef llabs -# endif +# ifdef abs +# undef abs +# endif +# ifdef labs +# undef labs +# endif +# ifdef llabs +# undef llabs +# endif // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined -# if !defined(_LIBCPP_MSVCRT) -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } -# endif // !defined(_LIBCPP_MSVCRT) +# if !defined(_LIBCPP_MSVCRT) +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } +# endif // !defined(_LIBCPP_MSVCRT) -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT { return __builtin_fabs(__lcpp_x); } -_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT { return __builtin_fabsl(__lcpp_x); } // div -# ifdef div -# undef div -# endif -# ifdef ldiv -# undef ldiv -# endif -# ifdef lldiv -# undef lldiv -# endif +# ifdef div +# undef div +# endif +# ifdef ldiv +# undef ldiv +# endif +# ifdef lldiv +# undef lldiv +# endif // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined -# if !defined(_LIBCPP_MSVCRT) +# if !defined(_LIBCPP_MSVCRT) inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); } -# if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED)) +# if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED)) inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); } -# endif -# endif // _LIBCPP_MSVCRT +# endif +# endif // _LIBCPP_MSVCRT } // extern "C++" -# endif // __cplusplus +# endif // __cplusplus +# endif // _LIBCPP_STDLIB_H -#endif // _LIBCPP_STDLIB_H +#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
