WinStoreCompat: Add a getpid replacement using GetCurrentProcessId

git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@5698 4407c894-4637-0410-b4f5-ada5f102cad1
diff --git a/mingw-w64-libraries/winstorecompat/Makefile.am b/mingw-w64-libraries/winstorecompat/Makefile.am
index 8a038b2..a1bc082 100644
--- a/mingw-w64-libraries/winstorecompat/Makefile.am
+++ b/mingw-w64-libraries/winstorecompat/Makefile.am
@@ -21,4 +21,6 @@
   src/SetErrorMode.c \
   src/GetACP.c \
   src/VirtualProtect.c \
-  src/getenv.c
+  src/getenv.c \
+  src/getpid.c \
+  $(NULL)
diff --git a/mingw-w64-libraries/winstorecompat/Makefile.in b/mingw-w64-libraries/winstorecompat/Makefile.in
index fc372c4..b452cf8 100644
--- a/mingw-w64-libraries/winstorecompat/Makefile.in
+++ b/mingw-w64-libraries/winstorecompat/Makefile.in
@@ -106,7 +106,8 @@
 	src/UnhandledExceptionFilter.$(OBJEXT) \
 	src/TerminateProcess.$(OBJEXT) src/IsDBCSLeadByteEx.$(OBJEXT) \
 	src/SetErrorMode.$(OBJEXT) src/GetACP.$(OBJEXT) \
-	src/VirtualProtect.$(OBJEXT) src/getenv.$(OBJEXT)
+	src/VirtualProtect.$(OBJEXT) src/getenv.$(OBJEXT) \
+	src/getpid.$(OBJEXT)
 libwinstorecompat_a_OBJECTS = $(am_libwinstorecompat_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
@@ -247,7 +248,9 @@
   src/SetErrorMode.c \
   src/GetACP.c \
   src/VirtualProtect.c \
-  src/getenv.c
+  src/getenv.c \
+  src/getpid.c \
+  $(NULL)
 
 all: all-am
 
@@ -358,6 +361,8 @@
 	src/$(DEPDIR)/$(am__dirstamp)
 src/getenv.$(OBJEXT): src/$(am__dirstamp) \
 	src/$(DEPDIR)/$(am__dirstamp)
+src/getpid.$(OBJEXT): src/$(am__dirstamp) \
+	src/$(DEPDIR)/$(am__dirstamp)
 libwinstorecompat.a: $(libwinstorecompat_a_OBJECTS) $(libwinstorecompat_a_DEPENDENCIES) $(EXTRA_libwinstorecompat_a_DEPENDENCIES) 
 	-rm -f libwinstorecompat.a
 	$(libwinstorecompat_a_AR) libwinstorecompat.a $(libwinstorecompat_a_OBJECTS) $(libwinstorecompat_a_LIBADD)
@@ -382,6 +387,7 @@
 	-rm -f src/VirtualProtect.$(OBJEXT)
 	-rm -f src/WaitForSingleObject.$(OBJEXT)
 	-rm -f src/getenv.$(OBJEXT)
+	-rm -f src/getpid.$(OBJEXT)
 
 distclean-compile:
 	-rm -f *.tab.c
@@ -403,6 +409,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/VirtualProtect.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/WaitForSingleObject.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/getenv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/getpid.Po@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
diff --git a/mingw-w64-libraries/winstorecompat/src/getpid.c b/mingw-w64-libraries/winstorecompat/src/getpid.c
new file mode 100644
index 0000000..f6a24a4
--- /dev/null
+++ b/mingw-w64-libraries/winstorecompat/src/getpid.c
@@ -0,0 +1,36 @@
+/*
+    Copyright (c) 2013 mingw-w64 project
+
+    Contributing authors: Jean-Baptiste Kempf
+
+    Permission is hereby granted, free of charge, to any person obtaining a
+    copy of this software and associated documentation files (the "Software"),
+    to deal in the Software without restriction, including without limitation
+    the rights to use, copy, modify, merge, publish, distribute, sublicense,
+    and/or sell copies of the Software, and to permit persons to whom the
+    Software is furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+    DEALINGS IN THE SOFTWARE.
+*/
+
+#define getpid __getpid
+#define _getpid __getpid
+#include <windows.h>
+#undef getpid
+#undef _getpid
+
+int getpid(void)
+{
+    return GetCurrentProcessId();
+}
+
+int (*__MINGW_IMP_SYMBOL(getpid))(void) asm("__imp__getpid") = getpid;