bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Steve Lhomme <robux4@ycbcr.xyz>
To: bug-gnulib@gnu.org
Subject: Re: [PATCH] gettimeofday: do not use LoadLibrary when built for Windows Store apps
Date: Thu, 28 May 2020 08:24:04 +0200	[thread overview]
Message-ID: <621264d9-a352-83a8-1156-40496d0e10cd@ycbcr.xyz> (raw)
In-Reply-To: <20200519062424.8282-1-robux4@ycbcr.xyz>

Any update on this patch ?

On Dekstop it's better to use kernel32.dll as it's loaded with every 
process, so the LoadLibrary is not loading any new DLL.

On Winstore/UWP apps you cannot use LoadLibrary, only LoadLibraryFromApp 
which cannot be used to load system DLLs. Static linking in necessary in 
this case. Any app targeting UWP is already using the windowsapp.lib 
(replacing the kernel32 lib they used to link with) so no need to fore 
linking with it via pkg-config, libtool, etc.

For example in CLang you either link with windowsapp or kernel32:
https://github.com/llvm-project/clang/blob/master/lib/Driver/ToolChains/MinGW.cpp#L269

On 2020-05-19 8:24, Steve Lhomme wrote:
> 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
> 
> 


  reply	other threads:[~2020-05-28  6:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=621264d9-a352-83a8-1156-40496d0e10cd@ycbcr.xyz \
    --to=robux4@ycbcr.xyz \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).