Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:26

0001 //===- zOSSupport.h - Common z/OS Include File ------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines z/OS implementations for common functions.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_SUPPORT_ZOSSUPPORT_H
0014 #define LLVM_SUPPORT_ZOSSUPPORT_H
0015 
0016 #ifdef __MVS__
0017 #include <sys/resource.h>
0018 #include <sys/wait.h>
0019 
0020 // z/OS Unix System Services does not have strsignal() support, so the
0021 // strsignal() function is implemented here.
0022 inline char *strsignal(int sig) {
0023   static char msg[256];
0024   sprintf(msg, "%d", sig);
0025   return msg;
0026 }
0027 
0028 // z/OS Unix System Services does not have wait4() support, so the wait4
0029 // function is implemented here.
0030 inline pid_t wait4(pid_t pid, int *wstatus, int options,
0031                    struct rusage *rusage) {
0032   pid_t Result = waitpid(pid, wstatus, options);
0033   int GetrusageRC = getrusage(RUSAGE_CHILDREN, rusage);
0034   assert(!GetrusageRC && "Must have valid measure of the resources!");
0035   return Result;
0036 }
0037 
0038 // z/OS Unix System Services does not have strnlen() support, so the strnlen()
0039 // function is implemented here.
0040 inline std::size_t strnlen(const char *S, std::size_t MaxLen) {
0041   const char *PtrToNullChar =
0042       static_cast<const char *>(std::memchr(S, '\0', MaxLen));
0043   return PtrToNullChar ? PtrToNullChar - S : MaxLen;
0044 }
0045 
0046 #endif
0047 #endif