[all-commits] [llvm/llvm-project] 173b51: [SystemZ][ZOS] Porting the time functions within l...

zibi2 via All-commits all-commits at lists.llvm.org
Thu Nov 12 08:29:33 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 173b51169b838255aff4d4ff4eb6014b101a9687
      https://github.com/llvm/llvm-project/commit/173b51169b838255aff4d4ff4eb6014b101a9687
  Author: Zbigniew Sarbinowski <zibi at ca.ibm.com>
  Date:   2020-11-12 (Thu, 12 Nov 2020)

  Changed paths:
    M libcxx/include/CMakeLists.txt
    M libcxx/include/__threading_support
    A libcxx/include/support/ibm/nanosleep.h
    M libcxx/src/filesystem/filesystem_common.h

  Log Message:
  -----------
  [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




More information about the All-commits mailing list