diff options
author | Louis Dionne <ldionne.2@gmail.com> | 2023-12-18 14:01:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-18 14:01:33 -0500 |
commit | 9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7 (patch) | |
tree | 4119e3edc01dd51cf2752b2a3341c34d8a3700ac /libcxx/include/stdlib.h | |
parent | e5c523e8610492b3256dde6856811b527b4dcb35 (diff) | |
download | llvm-9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7.zip llvm-9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7.tar.gz llvm-9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7.tar.bz2 |
[libc++] Format the code base (#74334)
This patch runs clang-format on all of libcxx/include and libcxx/src, in
accordance with the RFC discussed at [1]. Follow-up patches will format
the benchmarks, the test suite and remaining parts of the code. I'm
splitting this one into its own patch so the diff is a bit easier to
review.
This patch was generated with:
find libcxx/include libcxx/src -type f \
| grep -v 'module.modulemap.in' \
| grep -v 'CMakeLists.txt' \
| grep -v 'README.txt' \
| grep -v 'libcxx.imp' \
| grep -v '__config_site.in' \
| xargs clang-format -i
A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh
to help resolve merge and rebase issues across these formatting changes.
[1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
Diffstat (limited to 'libcxx/include/stdlib.h')
-rw-r--r-- | libcxx/include/stdlib.h | 86 |
1 files changed, 39 insertions, 47 deletions
diff --git a/libcxx/include/stdlib.h b/libcxx/include/stdlib.h index 712f121..a9ba438 100644 --- a/libcxx/include/stdlib.h +++ b/libcxx/include/stdlib.h @@ -9,14 +9,14 @@ #if defined(__need_malloc_and_calloc) -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif -#include_next <stdlib.h> +# include_next <stdlib.h> #elif !defined(_LIBCPP_STDLIB_H) -#define _LIBCPP_STDLIB_H +# define _LIBCPP_STDLIB_H /* stdlib.h synopsis @@ -84,39 +84,37 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 */ -#include <__config> +# include <__config> -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif # if __has_include_next(<stdlib.h>) # include_next <stdlib.h> # endif -#ifdef __cplusplus +# 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_EXT inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { - return __builtin_labs(__x); -} +# if !defined(_LIBCPP_MSVCRT) +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } -#endif // !defined(_LIBCPP_MSVCRT) +# endif // !defined(_LIBCPP_MSVCRT) _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h @@ -126,36 +124,30 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _ return __builtin_fabs(__lcpp_x); } -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double -abs(long double __lcpp_x) _NOEXCEPT { +_LIBCPP_NODISCARD_EXT 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) -inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { - return ::ldiv(__x, __y); -} -#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 +# 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)) +inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); } +# endif +# endif // _LIBCPP_MSVCRT } // extern "C++" -#endif // __cplusplus +# endif // __cplusplus #endif // _LIBCPP_STDLIB_H |