llvm-project/libcxx
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
..
benchmarks [libc++] Disallow running the libc++ benchmarks in standalone builds 2021-11-11 14:13:36 -05:00
cmake [CMake] Cache the compiler-rt library search results 2021-10-27 17:53:03 -07:00
docs [libcxx] [Coroutine] Conform Coroutine Implementation 2021-11-16 14:13:13 +08:00
include [SystemZ][z/OS] Fix warnings from unsigned int to long in 32-bit mode 2021-11-16 13:51:35 +00:00
lib Revert "[libc++] Always define a key function for std::bad_function_call in the dylib" 2021-11-08 00:44:47 -08:00
src [libc++] Implement P2186R2 (Remove Garbage Collection) 2021-11-11 19:03:00 +01:00
test [libcxx] [Coroutine] Conform Coroutine Implementation 2021-11-16 14:13:13 +08:00
utils [libcxx] [Coroutine] Conform Coroutine Implementation 2021-11-16 14:13:13 +08:00
.clang-format [libc++] Update clang-format to C++20. 2021-10-30 12:50:57 +02:00
.gitignore [libcxx] Fix .gitignore to not exclude test directories 2020-03-25 17:52:23 -07:00
CMakeLists.txt [libc++][NFC] Resolve Python 2 FIXME 2021-11-12 13:55:22 -05:00
CREDITS.TXT [NFC] Add contributor name to CREDITS.TXT 2021-09-29 14:48:32 -04:00
LICENSE.TXT
TODO.TXT [libc++] Disallow volatile types in std::allocator 2021-09-22 11:47:38 -04:00
appveyor-reqs-install.cmd
appveyor.yml