crt: Implement a fallback _getpid function for msvcrt.dll for arm/arm64
Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 64d627e..a60b48d 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -247,7 +247,8 @@
misc/__p___argv.c \
misc/__p__acmdln.c \
misc/__p__fmode.c \
- misc/__p__wcmdln.c
+ misc/__p__wcmdln.c \
+ misc/_getpid.c
if !ENABLE_SOFTMATH
src_msvcrtarm32+=\
@@ -289,7 +290,8 @@
misc/__p___argv.c \
misc/__p__acmdln.c \
misc/__p__fmode.c \
- misc/__p__wcmdln.c
+ misc/__p__wcmdln.c \
+ misc/_getpid.c
src_msvcr80_64=\
$(src_msvcrt_common) \
diff --git a/mingw-w64-crt/misc/_getpid.c b/mingw-w64-crt/misc/_getpid.c
new file mode 100644
index 0000000..da13b8e
--- /dev/null
+++ b/mingw-w64-crt/misc/_getpid.c
@@ -0,0 +1,18 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <process.h>
+#include <windows.h>
+
+int __cdecl _getpid(void) {
+ return GetCurrentProcessId();
+}
+
+int __cdecl getpid(void) {
+ return _getpid();
+}
+
+int (__cdecl *__MINGW_IMP_SYMBOL(_getpid))(void) = _getpid;
diff --git a/mingw-w64-headers/crt/process.h b/mingw-w64-headers/crt/process.h
index 7962af1..9077548 100644
--- a/mingw-w64-headers/crt/process.h
+++ b/mingw-w64-headers/crt/process.h
@@ -60,9 +60,7 @@
void __cdecl __MINGW_NOTHROW _cexit(void);
void __cdecl __MINGW_NOTHROW _c_exit(void);
-#if !(defined(__arm__) || defined(__aarch64__)) || __MSVCRT_VERSION__ > 0x700
_CRTIMP int __cdecl _getpid(void);
-#endif
_CRTIMP intptr_t __cdecl _cwait(int *_TermStat,intptr_t _ProcHandle,int _Action);
_CRTIMP intptr_t __cdecl _execl(const char *_Filename,const char *_ArgList,...);
_CRTIMP intptr_t __cdecl _execle(const char *_Filename,const char *_ArgList,...);
@@ -175,10 +173,8 @@
intptr_t __cdecl spawnlpe(int,const char *_Filename,const char *_ArgList,...) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
#ifndef _CRT_GETPID_DEFINED
#define _CRT_GETPID_DEFINED /* Also in unistd.h */
-#if !(defined(__arm__) || defined(__aarch64__)) || __MSVCRT_VERSION__ > 0x700
int __cdecl getpid(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
#endif
-#endif
#ifdef __GNUC__
/* Those methods are predefined by gcc builtins to return int. So to prevent
stupid warnings, define them in POSIX way. This is save, because those