From add5b95a4adf7055bb079debd6607c7454d8081d Mon Sep 17 00:00:00 2001 From: NightStrike Date: Wed, 15 Mar 2017 13:46:35 +0000 Subject: [PATCH] Don't use Win32 functions on CYGWIN. This was a workaround for a cygwin bug which was fixed 4 years ago, and cygwin hasn't supported affected versions for a long time. 2017-03-15 NightStrike Janne Blomqvist * intrinsics/random.c (getosrandom): Remove check for __CYGWIN__ preprocessor flag. * intrinsics/system_clock.c: Likewise. (system_clock_4): Likewise. (system_clock_8): Likewise. * intrinsics/time_1.h: Don't include windows.h if __CYGWIN__ is defined. Co-Authored-By: Janne Blomqvist From-SVN: r246162 --- libgfortran/ChangeLog | 11 +++++++++++ libgfortran/intrinsics/random.c | 2 +- libgfortran/intrinsics/system_clock.c | 8 ++++---- libgfortran/intrinsics/time_1.h | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index e6703700c4b..6ec73f6d51a 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,14 @@ +2017-03-15 NightStrike + Janne Blomqvist + + * intrinsics/random.c (getosrandom): Remove check for __CYGWIN__ + preprocessor flag. + * intrinsics/system_clock.c: Likewise. + (system_clock_4): Likewise. + (system_clock_8): Likewise. + * intrinsics/time_1.h: Don't include windows.h if __CYGWIN__ is + defined. + 2017-03-10 Thomas Koenig PR libfortran/79956 diff --git a/libgfortran/intrinsics/random.c b/libgfortran/intrinsics/random.c index 38036879362..2edfa82929c 100644 --- a/libgfortran/intrinsics/random.c +++ b/libgfortran/intrinsics/random.c @@ -304,7 +304,7 @@ static int getosrandom (void *buf, size_t buflen) { /* rand_s is available in MinGW-w64 but not plain MinGW. */ -#if defined(__MINGW64_VERSION_MAJOR) && !defined(__CYGWIN__) +#if defined(__MINGW64_VERSION_MAJOR) unsigned int* b = buf; for (unsigned i = 0; i < buflen / sizeof (unsigned int); i++) rand_s (&b[i]); diff --git a/libgfortran/intrinsics/system_clock.c b/libgfortran/intrinsics/system_clock.c index 606ef2739de..5674d493aff 100644 --- a/libgfortran/intrinsics/system_clock.c +++ b/libgfortran/intrinsics/system_clock.c @@ -29,7 +29,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "time_1.h" -#if !defined(__MINGW32__) && !defined(__CYGWIN__) +#if !defined(__MINGW32__) /* POSIX states that CLOCK_REALTIME must be present if clock_gettime is available, others are optional. */ @@ -99,7 +99,7 @@ gf_gettime_mono (time_t * secs, long * fracsecs, long * tck) #endif } -#endif /* !__MINGW32 && !__CYGWIN__ */ +#endif /* !__MINGW32__ */ extern void system_clock_4 (GFC_INTEGER_4 *count, GFC_INTEGER_4 *count_rate, @@ -121,7 +121,7 @@ void system_clock_4 (GFC_INTEGER_4 *count, GFC_INTEGER_4 *count_rate, GFC_INTEGER_4 *count_max) { -#if defined(__MINGW32__) || defined(__CYGWIN__) +#if defined(__MINGW32__) if (count) { /* Use GetTickCount here as the resolution and range is @@ -174,7 +174,7 @@ void system_clock_8 (GFC_INTEGER_8 *count, GFC_INTEGER_8 *count_rate, GFC_INTEGER_8 *count_max) { -#if defined(__MINGW32__) || defined(__CYGWIN__) +#if defined(__MINGW32__) LARGE_INTEGER cnt; LARGE_INTEGER freq; bool fail = false; diff --git a/libgfortran/intrinsics/time_1.h b/libgfortran/intrinsics/time_1.h index dbce3d4b517..95177dc9308 100644 --- a/libgfortran/intrinsics/time_1.h +++ b/libgfortran/intrinsics/time_1.h @@ -101,7 +101,7 @@ localtime_r (const time_t * timep, struct tm * result) CPU_TIME intrinsics. Returns 0 for success or -1 if no CPU time could be computed. */ -#if defined(__MINGW32__) || defined(__CYGWIN__) +#if defined(__MINGW32__) #define WIN32_LEAN_AND_MEAN #include -- 2.30.2