[flang] [llvm] [flang] Don't redefine pid_t on MinGW-w64. (PR #130288)

مهدي شينون via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 7 06:33:27 PST 2025


https://github.com/MehdiChinoune created https://github.com/llvm/llvm-project/pull/130288

None

>From 2893770381845b4e416b7f49855265a69c5078c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?=
 =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= <mehdi.chinoune at hotmail.com>
Date: Fri, 7 Mar 2025 15:29:25 +0100
Subject: [PATCH] [flang] Don't redefine pid_t on MinGW-w64.

---
 flang-rt/lib/runtime/command.cpp                          | 2 ++
 flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h | 2 +-
 flang/include/flang/Runtime/command.h                     | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/flang-rt/lib/runtime/command.cpp b/flang-rt/lib/runtime/command.cpp
index 8a5a61ac1ad44..9ada5bd59c0b7 100644
--- a/flang-rt/lib/runtime/command.cpp
+++ b/flang-rt/lib/runtime/command.cpp
@@ -21,9 +21,11 @@
 #define getcwd _getcwd
 #define PATH_MAX MAX_PATH
 
+#ifdef _MSC_VER
 // On Windows GetCurrentProcessId returns a DWORD aka uint32_t
 #include <processthreadsapi.h>
 inline pid_t getpid() { return GetCurrentProcessId(); }
+#endif
 #else
 #include <unistd.h> //getpid()
 
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index 5158abaa31ed1..722e9191be728 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -30,7 +30,7 @@
 #include <cstdint>
 #include <functional>
 
-#ifdef _WIN32
+#ifdef _MSC_VER
 // On Windows* OS GetCurrentProcessId returns DWORD aka uint32_t
 typedef std::uint32_t pid_t;
 #endif
diff --git a/flang/include/flang/Runtime/command.h b/flang/include/flang/Runtime/command.h
index 7ab3f6442dcf9..3add66dd50d4a 100644
--- a/flang/include/flang/Runtime/command.h
+++ b/flang/include/flang/Runtime/command.h
@@ -12,7 +12,7 @@
 #include "flang/Runtime/entry-names.h"
 #include <cstdint>
 
-#ifdef _WIN32
+#ifdef _MSC_VER
 // On Windows* OS GetCurrentProcessId returns DWORD aka uint32_t
 typedef std::uint32_t pid_t;
 #else



More information about the llvm-commits mailing list