From 3825e638e1bb390a6cfc20c2a2edf3d86f89247b Mon Sep 17 00:00:00 2001 From: David Turner Date: Sat, 22 May 2021 23:51:40 +0200 Subject: [PATCH 1/4] * src/ftbench.c: Fix get_time() for Mingw64 clock_gettime() cannot be used when cross-compiling for Windows using the Linux Mingw64 toolchain, so ensure the Win32-specific timer code is always used when _WIN32 is defined. --- ChangeLog | 8 ++++++++ src/ftbench.c | 30 +++++++++++++++++------------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8290fb..a7dfa84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2021-05-22 David Turner + + * src/ftbench.c: Fix get_time() for Mingw64 + + clock_gettime() cannot be used when cross-compiling for Windows + using the Linux Mingw64 toolchain, so ensure the Win32-specific + timer code is always used when _WIN32 is defined. + 2021-05-24 David Turner [build] Add Meson build files and documentation. diff --git a/src/ftbench.c b/src/ftbench.c index 37e8e0e..592fcff 100644 --- a/src/ftbench.c +++ b/src/ftbench.c @@ -198,19 +198,11 @@ static double get_time( void ) { -#if defined _POSIX_TIMERS && _POSIX_TIMERS > 0 - struct timespec tv; - - -#ifdef _POSIX_CPUTIME - clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &tv ); -#else - clock_gettime( CLOCK_REALTIME, &tv ); -#endif /* _POSIX_CPUTIME */ - - return 1E6 * (double)tv.tv_sec + 1E-3 * (double)tv.tv_nsec; - -#elif defined _WIN32 +/* NOTE: When building with the Mingw64 toolchain, _POSIX_TIMERS + * will be defined, but clock_gettime() won't, so ensure that the + * _WIN32 specific timer code appears first here. + */ +#if defined _WIN32 #ifdef QPC LARGE_INTEGER ticks; @@ -238,6 +230,18 @@ #endif +#elif defined _POSIX_TIMERS && _POSIX_TIMERS > 0 + struct timespec tv; + + +#ifdef _POSIX_CPUTIME + clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &tv ); +#else + clock_gettime( CLOCK_REALTIME, &tv ); +#endif /* _POSIX_CPUTIME */ + + return 1E6 * (double)tv.tv_sec + 1E-3 * (double)tv.tv_nsec; + #else /* clock() accuracy has improved since glibc 2.18 */ return 1E6 * (double)clock() / (double)CLOCKS_PER_SEC; -- GitLab From 501ac20f725e17cf44b06398b650f57219f3e605 Mon Sep 17 00:00:00 2001 From: David Turner Date: Sun, 23 May 2021 00:08:36 +0200 Subject: [PATCH 2/4] * graph/win32/grwin32.c: Fix compiler warnings - Redefine the LCS_sRGB macro to properly compile with the Mingw64 toolchain and the -Wmultichar warning enabled. - Add missing return code paths in function. --- ChangeLog | 9 +++++++++ graph/win32/grwin32.c | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index a7dfa84..87ebffb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2021-05-23 David Turner + + * graph/win32/grwin32.c: Fix compiler warnings + + - Redefine the LCS_sRGB macro to properly compile with the Mingw64 + toolchain and the -Wmultichar warning enabled. + + - Add missing return code paths in function. + 2021-05-22 David Turner * src/ftbench.c: Fix get_time() for Mingw64 diff --git a/graph/win32/grwin32.c b/graph/win32/grwin32.c index 799e4e3..a078a57 100644 --- a/graph/win32/grwin32.c +++ b/graph/win32/grwin32.c @@ -256,6 +256,15 @@ gr_win32_surface_set_icon( grWin32Surface* surface, ICONINFO ici = { TRUE }; HICON hIcon; +/* NOTE: The Mingw64 wingdi.h defines this macro as 'sRGB' + * which triggers the -Wmultichar warning during compilation, + * so replace it with the corresponding numerical value. + */ +#ifdef __MINGW64__ +#undef LCS_sRGB +#define LCS_sRGB 0x73524742 +#endif + BITMAPV4HEADER hdr = { sizeof( BITMAPV4HEADER ), 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, @@ -297,6 +306,8 @@ gr_win32_surface_set_icon( grWin32Surface* surface, case ICON_BIG: surface->bIcon = hIcon; return s[0]; + default: + return 0; /* should not happen */ } } -- GitLab From 3d1095e630681508c365f25c75e9927ddc52e7ba Mon Sep 17 00:00:00 2001 From: David Turner Date: Sun, 23 May 2021 00:01:26 +0200 Subject: [PATCH 3/4] * src/ftpngout.c: Remove compiler warning for Mingw64 toolchain. The #pragma statement is only valid with Microsoft Visual C++ --- ChangeLog | 6 ++++++ src/ftpngout.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 87ebffb..74da122 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-05-23 David Turner + + * src/ftpngout.c: Remove compiler warning for Mingw64 toolchain. + + The #pragma statement is only valid with Microsoft Visual C++ + 2021-05-23 David Turner * graph/win32/grwin32.c: Fix compiler warnings diff --git a/src/ftpngout.c b/src/ftpngout.c index 137a186..c003425 100644 --- a/src/ftpngout.c +++ b/src/ftpngout.c @@ -147,7 +147,10 @@ #define WIN32_LEAN_AND_MEAN #include +/* Microsoft Visual C++ specific pragma */ +#ifdef _MSC_VER #pragma comment (lib,"Gdiplus.lib") +#endif /* Barebone definitions and opaque types to avoid GDI+ (C++) headers */ -- GitLab From 51c0b8ac4b6d223df9f3a2f53b7d121c3a76a442 Mon Sep 17 00:00:00 2001 From: David Turner Date: Sun, 23 May 2021 00:03:11 +0200 Subject: [PATCH 4/4] * src/ftmemchk.c: Remove minor compiler warning. Casting a pointer to (long) isn't always correct. --- ChangeLog | 6 ++++++ src/ftmemchk.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 74da122..3c624b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-05-23 David Turner + + * src/ftmemchk.c: Remove minor compiler warning. + + Casting a pointer to (long) isn't always correct. + 2021-05-23 David Turner * src/ftpngout.c: Remove compiler warning for Mingw64 toolchain. diff --git a/src/ftmemchk.c b/src/ftmemchk.c index dc3b3bf..3975b56 100644 --- a/src/ftmemchk.c +++ b/src/ftmemchk.c @@ -66,7 +66,7 @@ void record_my_block( void* base, long size ) { if ( block->base == base && block->size != 0 ) { - fprintf( stderr, "duplicate memory block at %08lx\n", (long)block->base ); + fprintf( stderr, "duplicate memory block at %p\n", block->base ); exit(1); } } -- GitLab