diff options
author | Bruno Haible <bruno@clisp.org> | 2020-05-29 02:03:12 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-05-29 02:03:12 +0200 |
commit | 3a1fdff1eebe09d6c4bb87b39d34a1d6f4179eaf (patch) | |
tree | af46b2c731d935ee0e9073e1f919c366afdf9068 /lib/gettimeofday.c | |
parent | 4634d6ffecadd6e355ab15845b0c3a5c31af0825 (diff) | |
download | gnulib-3a1fdff1eebe09d6c4bb87b39d34a1d6f4179eaf.tar.gz |
Avoid dynamic loading of Windows API functions when possible.
Reported by Steve Lhomme <robux4@ycbcr.xyz> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00182.html>.
* lib/gettimeofday.c (GetProcAddress,
GetSystemTimePreciseAsFileTimeFuncType,
GetSystemTimePreciseAsFileTimeFunc, initialized, initialize): Don't
define in a build for Windows 8 or higher.
* lib/isatty.c (GetProcAddress, GetNamedPipeClientProcessIdFuncType,
GetNamedPipeClientProcessIdFunc, QueryFullProcessImageNameFuncType,
QueryFullProcessImageNameFunc, initialized, initialize): Don't define
in a build for Windows Vista or higher.
* lib/stat-w32.c (GetProcAddress, GetFileInformationByHandleExFuncType,
GetFileInformationByHandleExFunc, GetFinalPathNameByHandleFuncType,
GetFinalPathNameByHandleFunc, initialized, initialize): Likewise.
Diffstat (limited to 'lib/gettimeofday.c')
-rw-r--r-- | lib/gettimeofday.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c index 19804793a9..3d53115d9f 100644 --- a/lib/gettimeofday.c +++ b/lib/gettimeofday.c @@ -33,9 +33,11 @@ #ifdef WINDOWS_NATIVE +# if !(_WIN32_WINNT >= _WIN32_WINNT_WIN8) + /* Avoid warnings from gcc -Wcast-function-type. */ -# define GetProcAddress \ - (void *) GetProcAddress +# define GetProcAddress \ + (void *) GetProcAddress /* GetSystemTimePreciseAsFileTime was introduced only in Windows 8. */ typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime); @@ -54,6 +56,8 @@ initialize (void) initialized = TRUE; } +# endif + #endif /* This is a wrapper for gettimeofday. It is used only on systems @@ -84,8 +88,10 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz) <http://www.windowstimestamp.com/description>. */ FILETIME current_time; +# if !(_WIN32_WINNT >= _WIN32_WINNT_WIN8) if (!initialized) initialize (); +# endif if (GetSystemTimePreciseAsFileTimeFunc != NULL) GetSystemTimePreciseAsFileTimeFunc (¤t_time); else |