-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SystemZ][z/OS] Fix build errors on z/OS in the Unix .inc files #74758
Conversation
@llvm/pr-subscribers-llvm-support Author: Abhina Sree (abhina-sree) ChangesThis patch resolves the following errors on z/OS: error: no member named 'wait4' in the global namespace Full diff: https://github.com/llvm/llvm-project/pull/74758.diff 2 Files Affected:
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index 2babf07944bf7..bf781eabf5c60 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -62,7 +62,9 @@ getRUsageTimes() {
::getrusage(RUSAGE_SELF, &RU);
return {toDuration(RU.ru_utime), toDuration(RU.ru_stime)};
#else
+#ifndef __MVS__ // Exclude for MVS in case -pedantic is used
#warning Cannot get usage times on this platform
+#endif
return {std::chrono::microseconds::zero(), std::chrono::microseconds::zero()};
#endif
}
@@ -117,7 +119,9 @@ size_t Process::GetMallocUsage() {
return EndOfMemory - StartOfMemory;
return 0;
#else
+#ifndef __MVS__ // Exclude for MVS in case -pedantic is used
#warning Cannot get malloc info on this platform
+#endif
return 0;
#endif
}
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 9466d0f0ba859..f5881003a43bc 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -342,7 +342,7 @@ namespace sys {
#if defined(_AIX)
static pid_t(wait4)(pid_t pid, int *status, int options, struct rusage *usage);
-#elif !defined(__Fuchsia__)
+#elif !defined(__Fuchsia__) && !defined(__MVS__)
using ::wait4;
#endif
@@ -420,7 +420,14 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI,
ProcStat->reset();
do {
+#ifdef __MVS__
+ WaitResult.Pid = waitpid(ChildPid, &status, WaitPidOptions);
+ int GetrusageRC = getrusage(RUSAGE_CHILDREN, &Info);
+ assert(!GetrusageRC &&
+ "Must have valid measure of the resources!");
+#else
WaitResult.Pid = sys::wait4(ChildPid, &status, WaitPidOptions, &Info);
+#endif
} while (WaitUntilTerminates && WaitResult.Pid == -1 && errno == EINTR);
#endif
@@ -466,7 +473,7 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI,
std::chrono::microseconds UserT = toDuration(Info.ru_utime);
std::chrono::microseconds KernelT = toDuration(Info.ru_stime);
uint64_t PeakMemory = 0;
-#ifndef __HAIKU__
+#if !defined(__HAIKU__) && !defined(__MVS__)
PeakMemory = static_cast<uint64_t>(Info.ru_maxrss);
#endif
*ProcStat = ProcessStatistics{UserT + KernelT, UserT, PeakMemory};
@@ -494,7 +501,11 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI,
}
} else if (WIFSIGNALED(status)) {
if (ErrMsg) {
+#ifdef __MVS__
+ *ErrMsg = "Signal " + std::to_string(WTERMSIG(status));
+#else
*ErrMsg = strsignal(WTERMSIG(status));
+#endif
#ifdef WCOREDUMP
if (WCOREDUMP(status))
*ErrMsg += " (core dumped)";
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
f9fdfa4
to
e09bc72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This patch resolves the following errors on z/OS:
error: no member named 'wait4' in the global namespace
error: no member named 'ru_maxrss' in 'rusage'
error: use of undeclared identifier 'strsignal'
error: Cannot get usage times on this platform
error: Cannot get malloc info on this platform