[flang-commits] [flang] [flang] add SYSTEM runtime and lowering intrinsics support (PR #74309)
Yi Wu via flang-commits
flang-commits at lists.llvm.org
Wed Dec 20 08:02:00 PST 2023
================
@@ -282,4 +282,24 @@ std::int32_t RTNAME(GetEnvVariable)(const Descriptor &name,
return StatOk;
}
+void RTNAME(System)(const Descriptor &command, const Descriptor *exitstat,
+ const char *sourceFile, int line) {
+ Terminator terminator{sourceFile, line};
+
+ const char *newCmd{EnsureNullTerminated(
+ command.OffsetElement(), command.ElementBytes(), terminator)};
+ int status{std::system(newCmd)};
+
+ if (exitstat) {
+ RUNTIME_CHECK(terminator, IsValidIntDescriptor(exitstat));
+#ifdef _WIN32
+ StoreLengthToDescriptor(exitstat, status, terminator);
+#else
+ int exitstatVal{WEXITSTATUS(status)};
+ StoreLengthToDescriptor(exitstat, exitstatVal, terminator);
+#endif
+ FreeMemory((void *)newCmd);
----------------
yi-wu-arm wrote:
I should move it outside, just before that last `}`
https://github.com/llvm/llvm-project/pull/74309
More information about the flang-commits
mailing list