LLVM 20.0.0git
zOSSupport.h
Go to the documentation of this file.
1//===- zOSSupport.h - Common z/OS Include File ------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines z/OS implementations for common functions.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_SUPPORT_ZOSSUPPORT_H
14#define LLVM_SUPPORT_ZOSSUPPORT_H
15
16#ifdef __MVS__
17#include <sys/resource.h>
18#include <sys/wait.h>
19
20// z/OS Unix System Services does not have strsignal() support, so the
21// strsignal() function is implemented here.
22inline char *strsignal(int sig) {
23 static char msg[256];
24 sprintf(msg, "%d", sig);
25 return msg;
26}
27
28// z/OS Unix System Services does not have wait4() support, so the wait4
29// function is implemented here.
30inline pid_t wait4(pid_t pid, int *wstatus, int options,
31 struct rusage *rusage) {
32 pid_t Result = waitpid(pid, wstatus, options);
33 int GetrusageRC = getrusage(RUSAGE_CHILDREN, rusage);
34 assert(!GetrusageRC && "Must have valid measure of the resources!");
35 return Result;
36}
37
38// z/OS Unix System Services does not have strnlen() support, so the strnlen()
39// function is implemented here.
40inline std::size_t strnlen(const char *S, std::size_t MaxLen) {
41 const char *PtrToNullChar =
42 static_cast<const char *>(std::memchr(S, '\0', MaxLen));
43 return PtrToNullChar ? PtrToNullChar - S : MaxLen;
44}
45
46#endif
47#endif
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())