]> granicus.if.org Git - libexpat/commitdiff
Declare rand_s() for MinGW 32 ourselves
authorVadim Zeitlin <vadim@zeitlins.org>
Sat, 5 Oct 2019 22:21:37 +0000 (00:21 +0200)
committerVadim Zeitlin <vadim@zeitlins.org>
Sun, 6 Oct 2019 20:12:25 +0000 (22:12 +0200)
Runtime files for MinGW don't contain rand_s() declaration, even in
their latest version, so declare it ourselves to avoid the warning about
missing function declaration.

expat/lib/xmlparse.c

index 829e2b35abff6ff9d9a86b8759ab8a8dc037893c..bb56e59a164ce54dbb23250913a01fd2f18d4ee5 100644 (file)
@@ -736,6 +736,13 @@ writeRandomBytes_arc4random(void *target, size_t count) {
 
 #ifdef _WIN32
 
+/* Provide declaration of rand_s() for MinGW-32 (not 64, which has it),
+   as it doesn't declare it in its header up to at least 5.2.2 version
+   of its runtime package (mingwrt, containing stdlib.h). */
+#  if defined(__MINGW32__) && ! defined(__MINGW64_VERSION_MAJOR)
+__declspec(dllimport) int rand_s(unsigned int *);
+#  endif
+
 /* Obtain entropy on Windows using the rand_s() function which
  * generates cryptographically secure random numbers.  Internally it
  * uses RtlGenRandom API which is present in Windows XP and later.