Commit Graph

39 Commits

Author SHA1 Message Date
Louis Dionne
9783f28cbb
[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
2023-12-18 14:01:33 -05:00
Christoph Schlosser
cf6b3315f2 libcxx: Bring back unsigned return from wcstoull_l
Got removed here:
21d9282ae2b6e1e7dfbabfd87f6208c3bdff8ea4#diff-e41832b8aa26da45585a57c5111531f2e1d07e91a67c4f8bf1cd6d566ae45a2bR40

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D148056
2023-07-08 13:54:30 +02:00
Nikolas Klauser
f1ea0b11ca [libc++] Merge _LIBCPP_FUNC_VIS, _LIBCPP_TYPE_VIS and _LIBCPP_EXCEPTION_ABI into _LIBCPP_EXPORTED_FROM_ABI
These macros are always defined identically, so we can simplify the code a bit by merging them.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, krytarowski, smeenai

Differential Revision: https://reviews.llvm.org/D152652
2023-06-15 08:56:45 -07:00
Louis Dionne
3b6bc87520 [libc++] Remove Solaris related code
This was contributed ~10 years ago, but we don't officially support it
and I am not aware of any bot testing it, so this has likely rotten to
the point where it is unusable.

Differential Revision: https://reviews.llvm.org/D138680
2023-05-05 08:39:51 -04:00
Arsen Arsenović
21d9282ae2 libcxx: Don't apply ABI tags to extern "C" fns
GCC rejects ABI tags on non mangled functions, as they would otherwise
be a no-op.  This commit replaces such instances with equivalent
_LIBCPP_HIDE_FROM_ABI constants but without ABI tags attached.

  .../include/c++/v1/__support/musl/xlocale.h:28:68: error: 'abi_tag'
  attribute applied to extern "C" declaration 'long long int
  strtoll_l(const char*, char**, int, locale_t)'
     28 | strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) {
        |                                                                    ^

Bug: https://bugs.gentoo.org/869038

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D142415
2023-01-25 07:35:33 +00:00
Sylvestre Ledru
fc87452916 libc++: bring back the unsigned in the return type in wcstoull_l
got remove here:
67b0b02ec9 (diff-e41832b8aa26da45585a57c5111531f2e1d07e91a67c4f8bf1cd6d566ae45a2bR42)

Differential Revision: https://reviews.llvm.org/D141208
2023-01-08 12:28:14 +01:00
Louis Dionne
b938b8702f [libc++][NFC] Rename include guards under /support/
For consistency with the rest of the code base.
2022-11-28 09:04:33 -05:00
Michael Platings
77793ee33a [libc++] newlib/xlocale.h: remove redundant includes
This permits using the <locale> header with newlib or picolibc when
LIBCXX_ENABLE_WIDE_CHARACTERS=FALSE.

Since D136682 the __support/xlocale headers themselves include the
headers they require, respecting the LIBCXX_ENABLE_WIDE_CHARACTERS
option.

Differential Revision: https://reviews.llvm.org/D136947
2022-10-31 07:40:37 +00:00
Louis Dionne
fd5a2bfaad [libc++] Add missing includes to xlocale helpers
Also, make sure those are compatible with _LIBCPP_HAS_NO_WIDE_CHARACTERS.

Differential Revision: https://reviews.llvm.org/D136682
2022-10-25 14:06:17 -04:00
Nikolas Klauser
55158efe10 [libc++] Remove MSVC code
It's been one and a half months now and nobody said anything, so I guess this code can be removed.

Reviewed By: ldionne, #libc

Spies: Mordante, libcxx-commits, mgorny, mstorsjo

Differential Revision: https://reviews.llvm.org/D132943
2022-09-20 10:11:42 +02:00
Nikolas Klauser
84fc2c3cd6 [libc++] Make the naming of private member variables consistent and enforce it through readability-identifier-naming
Reviewed By: ldionne, #libc

Spies: aheejin, sstefan1, libcxx-commits

Differential Revision: https://reviews.llvm.org/D129386
2022-09-02 21:36:36 +02:00
Louis Dionne
89469df8ba [libc++] Remove trailing whitespace from libcxx includes, source, tests and benchmarks
Differential Revision: https://reviews.llvm.org/D132175
2022-08-23 18:25:54 -04:00
Brad Smith
ba1915028e [libcxx] Remove static inline and make use of _LIBCPP_HIDE_FROM_ABI in __support/xlocale/__nop_locale_mgmt.h header
Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D129949
2022-07-23 22:12:37 -04:00
Brad Smith
da11b775b1 [libcxx] Fix copy and pasto that broke the build on Android/Fuchsia
Reviewed by: Mordante, phosek

Differential Revision: https://reviews.llvm.org/D129978
2022-07-18 09:16:49 -04:00
Brad Smith
21ef59a55e [libcxx] Replace remaining _LIBCPP_INLINE_VISIBILITY in __support
Replace remaining _LIBCPP_INLINE_VISIBILITY in __support with _LIBCPP_HIDE_FROM_ABI.

Reviewed by: Mordante

Differential Revision: https://reviews.llvm.org/D129922
2022-07-16 19:08:34 -04:00
David Tenty
a83004f4ff [libcxx][AIX][z/OS] Remove headers included via _IBMCPP__
D127650 removed support for non-clang-based XL compilers, but left some
of the headers used only by this compiler and included under the
__IBMCPP__ macro. This change cleans this up by deleting these headers.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D129491
2022-07-14 15:41:46 -04:00
David Tenty
4a009797ec [libc++][NFC] Add MVS guard for locale_mgmt_zos.h
This header need not be included on non-z/OS IBM platforms (and indeed
will add nothing when it is), so add a guard. This let's us remove the
header without things breaking when shipping libc++ for AIX.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D129493
2022-07-12 14:15:42 -04:00
Brad Smith
8e19a2b435 [libcxx] Uglify __support/musl
Uglify __support/musl

Reviewed By: philnik

Differential Revision: https://reviews.llvm.org/D129429
2022-07-09 18:01:21 -04:00
Brad Smith
865737581a [libcxx] Uglify __support/openbsd
Uglify __support/openbsd

Reviewed By: philnik

Differential Revision: https://reviews.llvm.org/D129412
2022-07-08 21:37:00 -04:00
Nikolas Klauser
b48c5010a4 [libc++] Make parameter names consistent and enforce the naming style using readability-identifier-naming
Ensure that parameter names have the style `__lower_case`

Reviewed By: ldionne, #libc

Spies: aheejin, sstefan1, libcxx-commits, miyuki

Differential Revision: https://reviews.llvm.org/D129051
2022-07-08 18:17:47 +02:00
Michael Platings
9184002d66 Uglify __support/xlocale
This allows including the headers without risk of conflict with
user-defined macros e.g. max

Differential Revision: https://reviews.llvm.org/D128728
2022-06-30 11:45:29 +01:00
Brad Smith
67b0b02ec9 [libcxx] Remove static inline and make use of _LIBCPP_HIDE_FROM_ABI in __support headers
After feedback from D122861, do the same thing with some of the other headers. Try to move the
headers so they have a similar style and way of doing things.

Reviewed By: ldionne, daltenty

Differential Revision: https://reviews.llvm.org/D124227
2022-05-07 01:14:33 -04:00
Brad Smith
a0d40a579a [libcxx] Add some missing xlocale wrapper functions for OpenBSD
Reviewed By: Mordante

Differential Revision: https://reviews.llvm.org/D122861
2022-04-21 20:00:59 -04:00
zijunzhao
2d0475e371 [libcxx] locale_bionic.h: skip ndk-version.h on Android platform
The Android platform does not have ndk-version.h, but it will always
have up-to-date libc headers, so it does not need any compatibility
code intended for past versions of NDK_MAJOR. If ndk-version.h is missing,
assume NDK_MAJOR is (conceptually) infinite

Bug: https://buganizer.corp.google.com/issues/222341313
Test: None
2022-04-11 17:51:12 +00:00
Louis Dionne
157bbe6aea [libc++] Remove the ability to use the std::nullptr_t emulation in C++03 mode
Back in https://reviews.llvm.org/D109459, we stopped using the C++03
emulation for std::nullptr_t by default, which was an ABI break. We
still left a knob for users to turn it back on if they were broken by
the change, with a note that we would remove that knob after one release.

The time has now come to remove the knob and clean up the std::nullptr_t
emulation.

Differential Revision: https://reviews.llvm.org/D114786
2022-02-07 17:51:05 -05:00
Casey Carter
4e00a1921f [libcxx][test] compiler options are non-portable
... it's easier to suppress warnings internally, where we can detect the compiler.

* Rename `TEST_COMPILER_C1XX` to `TEST_COMPILER_MSVC`
* Rename all `TEST_WORKAROUND_C1XX_<meow>` to `TEST_WORKAROUND_MSVC_<meow>`

Differential Revision: https://reviews.llvm.org/D117422
2022-01-18 11:34:57 -08:00
Zbigniew Sarbinowski
422cf2b506 [SystemZ][z/OS] Fix warnings from unsigned int to long in 32-bit mode
This patch fixes the warnings which shows up when libcxx library started to be compiled in 32-bit mode on z/OS.
More specifically, the assignment from unsigned int to time_t aka long was flags as follows:
 ```
libcxx/include/c++/v1/__support/ibm/nanosleep.h:31:11: warning: implicit conversion changes signedness: 'unsigned int' to 'time_t' (aka 'long') [-Wsign-conversion]
  __sec = sleep(static_cast<unsigned int>(__sec));
        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libcxx/include/c++/v1/__support/ibm/nanosleep.h:36:36: warning: implicit conversion changes signedness: 'unsigned int' to 'long' [-Wsign-conversion]
      __rem->tv_nsec = __micro_sec * 1000;
                     ~ ~~~~~~~~~~~~^~~~~~
libcxx/include/c++/v1/__support/ibm/nanosleep.h:47:36: warning: implicit conversion changes signedness: 'unsigned int' to 'long' [-Wsign-conversion]
      __rem->tv_nsec = __micro_sec * 1000;
                     ~ ~~~~~~~~~~~~^~~~~~
3 warnings generated.
```

Here is a small test case illustrating the issue:

```
typedef long    time_t ;
unsigned int sleep(unsigned int );
int main() {
  time_t sec = 0;
#ifdef FIX
  sec = static_cast<time_t>(sleep(static_cast<unsigned int>(sec)));
#else
  sec = sleep(static_cast<unsigned int>(sec));
#endif
}
```
clang++ -c -Wsign-conversion -m32 t.C
```
t.C:8:9: warning: implicit conversion changes signedness: 'unsigned int' to 'time_t' (aka 'long') [-Wsign-conversion]
  sec = sleep(static_cast<unsigned int>(sec));
      ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reviewed By: ldionne, #libc, Quuxplusone, Mordante

Differential Revision: https://reviews.llvm.org/D112837
2021-11-16 13:51:35 +00:00
David Tenty
7a320b279d [libcxx][AIX] Remove locale fallbacks for old OS levels
These routines were add years ago during initial porting attempts to AIX and are mostly build hacks for routines which we're missing at the time, but are available now on recent AIX OS levels.

Thus builds on modern AIX OS levels no longer need these and they cause problems if you try to build the library with a generic triple (i.e. powerpc-ibm-aix) as we'll pull them in and encounter duplicate definitions from the OS.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D110183
2021-09-21 21:14:50 -04:00
Xiang Xiao
3285c7a436 [libcxx] Remove the locale fallback for NuttX
Since these functions can handled by NuttX's libc now

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D108895
2021-08-31 09:46:55 -04:00
jasonliu
a319eafd16 [libc++] Provide c++03 alternative for va_copy if available in xlocale.h
Summary:
If we are on c++03 mode for some reason, and __builtin_va_copy is
available, then use it instead of error out on not having va_copy
in 03 mode.

Reviewed by: ldionne

Differential Revision: https://reviews.llvm.org/D100336
2021-07-01 18:02:38 +00:00
zoecarver
8110a73164 [libcxx][gardening] Re-order includes across libcxx.
This commit alphabetizes all includes in libcxx. This is a NFC.

This can also serve as a pseudo "announcement" for how we should order these headers going forward (note: double underscores go before other headers).

Differential Revision: https://reviews.llvm.org/D102941
2021-05-21 13:22:10 -07:00
Zbigniew Sarbinowski
916093f49f [SystemZ][z/OS] correct rc and errno within nanosleep()
This patch fixes rc and errno within nanosleep(). It also updates __rem parameter as well it introduces cast to handle conversions from long into unsigned int to avoid warnings.

Reviewed By: Mordante

Differential Revision: https://reviews.llvm.org/D99373
2021-04-06 15:36:58 +00:00
jasonliu
158026301b [libc++][AIX] Initial patch to unblock the libc++ build on AIX
This path would unblock the build of libc++ library on AIX:
1. Add _AIX guard for _LIBCPP_HAS_THREAD_API_PTHREAD
2. Use uselocale to actually take the locale setting
   into account.
3. extract_mtime and extract_atime mod needed for AIX. As stat
   structure on AIX uses internal structure st_timespec to store
   time for binary compatibility reason. So we need to convert it
   back to timespec here.
4. Do not build cxa_thread_atexit.cpp for libcxxabi on AIX.

Differential Revision: https://reviews.llvm.org/D97558
2021-03-24 22:13:20 +00:00
Martin Storsjö
675401e04c [libcxx] Avoid pulling in xlocinfo.h in public headers
Including xlocinfo.h is a bit of a layering violation; locale.h is
the C library header we should use, while xlocinfo.h is essentially
part of the MS C++ library. Including xlocinfo.h brings in yvals.h,
which brings in yvals_core.h, which defines the MS STL's version
support macros, overriding what libc++'s <version> had defined.

Instead just include locale.h, and provide the few defines we need
for locale categories manually.

Differential Revision: https://reviews.llvm.org/D99213
2021-03-24 23:29:59 +02:00
Muiez Ahmed
f6af5efcec [SystemZ][z/OS] vasprintf fix libc++
The aim is to use the correct vasprintf implementation for z/OS libc++, where a copy of va_list ap is needed. In particular, it avoids the potential that the initial internal call to vsnprintf will modify ap and the subsequent call to vsnprintf will use that modified ap.

Differential Revision: https://reviews.llvm.org/D97473
2021-03-18 15:00:57 -04:00
Muiez Ahmed
ebe6161c54 [SystemZ][z/OS] Missing locale functions libc++
The aim is to add the missing z/OS specific locale functions for libc++ (newlocale, freelocale and uselocale).

Reviewed By: ldionne, #libc, curdeius

Differential Revision: https://reviews.llvm.org/D98044
2021-03-08 19:32:33 +00:00
Muiez Ahmed
53c8587dcd [SystemZ][z/OS] Missing non-posix functions libc++
The aim is to add missing non-posix functions for z/OS libc++ (strtod_l and strtof_l).

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D97051
2021-03-04 15:23:21 +00:00
Zbigniew Sarbinowski
cb2d2ae56a [SystemZ][ZOS] Provide CLOCK_MONOTONIC alternative
We need CLOCK_MONOTONIC equivalent implementation for z/OS within libc++. The default implementation is asserting.

On z/OS the lack of  'clock_gettime()' and 'time_point()' force us to look for alternatives.
The current proposal is to use `gettimeofday()` for CLOCK_MONOTONIC  which is also used in CLOCK_REALTIME.  This will allow us to skip the assertion with compromised CLOCK_MONOTONIC implementation which will not guarantee to never go back in time because it will use `gettimeofday()` but only when it's set.

Is this a good compromise for platforms which does not support monotonic clock?
Hopefully this will spark the discussion and agreement how to proceed in this situation.

Reviewed By: #libc, ldionne, hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D93542
2021-02-12 18:39:48 +00:00
Louis Dionne
b51756819a [libc++] Rename include/support to include/__support
We do ship those headers, so the directory name should not be something
that can potentially conflict with user-defined directories.

Differential Revision: https://reviews.llvm.org/D95956
2021-02-04 10:16:33 -05:00