crt: Provide __p__pgmptr() function for all CRT import libraries

Function __p__pgmptr() returns pointer to global variable _pgmptr and is
available since VC20, it is available also in UCRT, and also in x86 version
of OS system version msvcrt.dll.

For all other CRT import libraries (crtdll.dll, msvcrt10.dll and
x64/arm32/arm64 msvcrt.dll) provide mingw-w64 version of __p__pgmptr()
function defined via global variable _pgmptr.

Global variable _pgmptr is available in all CRT libraries except UCRT.

Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 56156e5..1b2d993 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -465,6 +465,7 @@
   misc/__p__fmode.c \
   misc/__p__mbcasemap.c \
   misc/__p__mbctype.c \
+  misc/__p__pgmptr.c \
   misc/__p__wcmdln.c \
   misc/__p__wenviron.c \
   misc/_create_locale.c \
@@ -483,6 +484,7 @@
   misc/__p__fmode.c \
   misc/__p__mbcasemap.c \
   misc/__p__mbctype.c \
+  misc/__p__pgmptr.c \
   misc/__p__wcmdln.c \
   misc/_getpid.c \
   misc/initenv.c \
@@ -585,6 +587,7 @@
   misc/__p__fmode.c \
   misc/__p__mbcasemap.c \
   misc/__p__mbctype.c \
+  misc/__p__pgmptr.c \
   misc/__p__wcmdln.c \
   misc/_getpid.c \
   misc/initenv.c \
@@ -605,6 +608,7 @@
   misc/__p__environ.c \
   misc/__p__fmode.c \
   misc/__p__mbctype.c \
+  misc/__p__pgmptr.c \
   misc/__p__pctype.c \
   misc/__p__pwctype.c \
   misc/__pctype_func.c \
@@ -640,6 +644,7 @@
   misc/__p__environ.c \
   misc/__p__fmode.c \
   misc/__p__pctype.c \
+  misc/__p__pgmptr.c \
   misc/__p__pwctype.c \
   misc/__pctype_func.c \
   misc/__pwctype_func.c \
diff --git a/mingw-w64-crt/misc/__p__pgmptr.c b/mingw-w64-crt/misc/__p__pgmptr.c
new file mode 100644
index 0000000..2c0b7ba
--- /dev/null
+++ b/mingw-w64-crt/misc/__p__pgmptr.c
@@ -0,0 +1,16 @@
+/**
+ * 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 <_mingw.h>
+
+extern char** __MINGW_IMP_SYMBOL(_pgmptr);
+
+char** __cdecl __p__pgmptr(void);
+char** __cdecl __p__pgmptr(void)
+{
+    return __MINGW_IMP_SYMBOL(_pgmptr);
+}
+char** (__cdecl *__MINGW_IMP_SYMBOL(__p__pgmptr))(void) = __p__pgmptr;