• R/O
  • HTTP
  • SSH
  • HTTPS

mingw-org-wsl: 提交

The MinGW.org Windows System Libraries


Commit MetaInfo

修訂3edbad03398142e3fe3d3bb55fa506b5b03acecd (tree)
時間2020-01-22 07:03:45
作者Keith Marshall <keith@user...>
CommiterKeith Marshall

Log Message

Address MinGW-Issue #39658; declare rand_s() function.

Change Summary

差異

--- a/mingwrt/ChangeLog
+++ b/mingwrt/ChangeLog
@@ -1,3 +1,14 @@
1+2020-01-21 Keith Marshall <keith@users.osdn.me>
2+
3+ Address MinGW-Issue #39658; declare rand_s() function.
4+
5+ * include/stdlib.h: When the user has defined...
6+ [_CRT_RAND_S]: ...this optional feature test macro, and then...
7+ [__MSVCRT_VERSION__ >= __MSVCR80_DLL]: ...either this non-free, or...
8+ [_WIN32_WINNT >=_ WIN32_WINNT_VISTA]: ...this system-standard runtime
9+ library version constraint is satisfied, then...
10+ (rand_s): ...declare function prototype.
11+
112 2020-01-17 Keith Marshall <keith@users.osdn.me>
213
314 Support GCC-9.x gratuitous dependency on ftruncate64() function.
--- a/mingwrt/include/stdlib.h
+++ b/mingwrt/include/stdlib.h
@@ -508,6 +508,25 @@ _CRTIMP __cdecl __MINGW_NOTHROW int mbtowc (wchar_t *, const char *, size_t);
508508 _CRTIMP __cdecl __MINGW_NOTHROW int rand (void);
509509 _CRTIMP __cdecl __MINGW_NOTHROW void srand (unsigned int);
510510
511+/* rand() is devoid of entropy, and is thus a mediocre pseudo-random number
512+ * generator. Microsoft do offer a better quality (bogusly dubbed as a more
513+ * secure) PRNG, in the guise of rand_s(), but it
514+ *
515+ * 1) must be explicitly enabled, by user defined feature test macro;
516+ */
517+#ifdef _CRT_RAND_S
518+/*
519+ * 2) is not supported on Win9x, nor any WinNT version prior to WinXP;
520+ * 3) on WinXP, requires linking with non-free MSVCR80.DLL, or later;
521+ * 4) is provided by MSVCRT.DLL, only from Vista onward.
522+ */
523+#if __MSVCRT_VERSION__ >= __MSVCR80_DLL || _WIN32_WINNT >= _WIN32_WINNT_VISTA
524+
525+_CRTIMP __cdecl __MINGW_NOTHROW int rand_s (unsigned int *);
526+
527+#endif /* Win-Vista || MSVCR80.DLL || later */
528+#endif /* _CRT_RAND_S enabled */
529+
511530 _CRTIMP __cdecl __MINGW_NOTHROW void abort (void) __MINGW_ATTRIB_NORETURN;
512531 _CRTIMP __cdecl __MINGW_NOTHROW void exit (int) __MINGW_ATTRIB_NORETURN;
513532
Show on old repository browser