bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH] gettimeofday: do not use LoadLibrary when built for Windows Store apps
@ 2020-05-19  6:24 Steve Lhomme
  2020-05-28  6:24 ` Steve Lhomme
  2020-05-29  0:04 ` Bruno Haible
  0 siblings, 2 replies; 7+ messages in thread
From: Steve Lhomme @ 2020-05-19  6:24 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Steve Lhomme

LoadLibrary is forbidden in such apps (can only load DLLs from within the app
package).
The API entries are available to all apps linking with the Windows API as found
here:
https://docs.microsoft.com/en-us/uwp/win32-and-com/win32-apis

windowsapp.lib (and mincore.lib for Windows 8) are both available in MinGW as
well.

GetSystemTimePreciseAsFileTime is only allowed in Win10 UWP apps.
---
 lib/gettimeofday.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index 19804793a..087f7eada 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -45,12 +45,17 @@ static BOOL initialized = FALSE;
 static void
 initialize (void)
 {
+#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && _WIN32_WINNT >= 0x0A00 /* _WIN32_WINNT_WIN10 */
+  /* LoadLibrary not allowed but the functions are available with the windows runtime */
+  GetSystemTimePreciseAsFileTimeFunc = GetSystemTimePreciseAsFileTime;
+#else /* WINAPI_PARTITION_DESKTOP */
   HMODULE kernel32 = LoadLibrary ("kernel32.dll");
   if (kernel32 != NULL)
     {
       GetSystemTimePreciseAsFileTimeFunc =
         (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");
     }
+#endif /* WINAPI_PARTITION_DESKTOP */
   initialized = TRUE;
 }
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-29 20:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-19  6:24 [PATCH] gettimeofday: do not use LoadLibrary when built for Windows Store apps Steve Lhomme
2020-05-28  6:24 ` Steve Lhomme
2020-05-29  0:04 ` Bruno Haible
2020-05-29  5:12   ` Daiki Ueno
2020-05-29 10:34     ` Bruno Haible
2020-05-29 10:49   ` Steve Lhomme
2020-05-29 20:29   ` do not use GetModuleHandle " Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).