OSDN Git Service

[SystemZ][ZOS] Porting the time functions within libc++ to z/OS
authorZbigniew Sarbinowski <zibi@ca.ibm.com>
Thu, 12 Nov 2020 16:22:04 +0000 (11:22 -0500)
committerAbhina Sreeskantharajan <Abhina.Sreeskantharajan@ibm.com>
Thu, 12 Nov 2020 16:29:13 +0000 (11:29 -0500)
commit173b51169b838255aff4d4ff4eb6014b101a9687
treeae0d50d9cb14ba542265a08ad2d19d6d800dc155
parent89967427412489e10b3625bf1563a804fe5f2be2
[SystemZ][ZOS] Porting the time functions within libc++ to z/OS

This patch is one part of many steps required to build libc++ and libc++abi libraries on z/OS.  This particular deals with time related functions and consists of the following 3 parts.

1) Initialization of :timeval within libc++ library need to be adjusted to work on z/OS.
The following is z/OS definition from time.h which includes additional aggregate member.
typedef signed int suseconds_t;
struct timeval {
time_t tv_sec;
char tv_usec_pad[4];
suseconds_t tv_usec;
};

In contracts the following is definition from time.h on Linux.

typedef long int __suseconds_t;
struct timeval
{
__time_t tv_sec;
__suseconds_t tv_usec;
};

2) In addition, retrieving ::timespec within libc++ library needs to be adjusted to compensate the difference of some of the members of ::stat depending of the target host.
Here are the 2 members in conflict on z/OS extracted from stat.h.
struct stat {
...
time_t st_atime;
time_t st_mtime;
...
};
In contract here is Linux equivalent from stat.h.
struct stat
{
...
struct timespec st_atim;
struct timespec st_mtim;
...
};

3) On Linux both members are of type timespec whereas on z/OS an object of type timespec need to be constructed first before retrieving it within libc++ library.

The libc++ header file __threading_support calls nanosleep, which is not available on z/OS.
The equivalent functionality will be implemented by using both sleep() and usleep().

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D87940
libcxx/include/CMakeLists.txt
libcxx/include/__threading_support
libcxx/include/support/ibm/nanosleep.h [new file with mode: 0644]
libcxx/src/filesystem/filesystem_common.h