On 2017/5/3 15:35, Christer Solskogen wrote:
I'm having a hard time (cross) compiling winpthreads (from 5.x branch)
with gcc 7.1.
Please try the attached patch.
--
Best regards,
LH_Mouse
From 4fa48b2af092a3b8615cef39b6e0036e20481c3f Mon Sep 17 00:00:00 2001
From: Liu Hao <[email protected]>
Date: Wed, 3 May 2017 15:52:32 +0800
Subject: [PATCH] winpthreads/src/clock.c: Fix undefined reference to
`__divmoddi4'.
GCC targeting i686 _may_ generate an external call to the function in
question when divding a 64-bit (DIMode) integer with another one.
Since we are linking against a fake libgcc, this function is not available.
The functionality can be emulated by casting both operands to `double`
then performing trivial floating point division on them.
Signed-off-by: Liu Hao <[email protected]>
---
mingw-w64-libraries/winpthreads/src/clock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-libraries/winpthreads/src/clock.c
b/mingw-w64-libraries/winpthreads/src/clock.c
index 5ad710b2..3cffdd46 100644
--- a/mingw-w64-libraries/winpthreads/src/clock.c
+++ b/mingw-w64-libraries/winpthreads/src/clock.c
@@ -134,8 +134,8 @@ int clock_gettime(clockid_t clock_id, struct
timespec *tp)
if (QueryPerformanceCounter(&pc) == 0)
return lc_set_errno(EINVAL);
- tp->tv_sec = pc.QuadPart / pf.QuadPart;
- tp->tv_nsec = (int) (((pc.QuadPart % pf.QuadPart) * POW10_9
+ (pf.QuadPart >> 1)) / pf.QuadPart);
+ tp->tv_sec = (time_t)(pc.QuadPart / (double)pf.QuadPart);
+ tp->tv_nsec = (int) (((__int64)(pc.QuadPart - tp->tv_sec *
(double)pf.QuadPart) * POW10_9 + (pf.QuadPart >> 1)) / (double)pf.QuadPart);
if (tp->tv_nsec >= POW10_9) {
tp->tv_sec ++;
tp->tv_nsec -= POW10_9;
--
2.12.1
From 4fa48b2af092a3b8615cef39b6e0036e20481c3f Mon Sep 17 00:00:00 2001
From: Liu Hao <[email protected]>
Date: Wed, 3 May 2017 15:52:32 +0800
Subject: [PATCH] winpthreads/src/clock.c: Fix undefined reference to
`__divmoddi4'.
GCC targeting i686 _may_ generate an external call to the function in
question when divding a 64-bit (DIMode) integer with another one.
Since we are linking against a fake libgcc, this function is not available.
The functionality can be emulated by casting both operands to `double`
then performing trivial floating point division on them.
Signed-off-by: Liu Hao <[email protected]>
---
mingw-w64-libraries/winpthreads/src/clock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-libraries/winpthreads/src/clock.c
b/mingw-w64-libraries/winpthreads/src/clock.c
index 5ad710b2..3cffdd46 100644
--- a/mingw-w64-libraries/winpthreads/src/clock.c
+++ b/mingw-w64-libraries/winpthreads/src/clock.c
@@ -134,8 +134,8 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
if (QueryPerformanceCounter(&pc) == 0)
return lc_set_errno(EINVAL);
- tp->tv_sec = pc.QuadPart / pf.QuadPart;
- tp->tv_nsec = (int) (((pc.QuadPart % pf.QuadPart) * POW10_9 +
(pf.QuadPart >> 1)) / pf.QuadPart);
+ tp->tv_sec = (time_t)(pc.QuadPart / (double)pf.QuadPart);
+ tp->tv_nsec = (int) (((__int64)(pc.QuadPart - tp->tv_sec *
(double)pf.QuadPart) * POW10_9 + (pf.QuadPart >> 1)) / (double)pf.QuadPart);
if (tp->tv_nsec >= POW10_9) {
tp->tv_sec ++;
tp->tv_nsec -= POW10_9;
--
2.12.1
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public