From aeebdcf73377d1682b508828db5de55cffe1870f Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 23 Jul 2017 14:05:48 -0700 Subject: [PATCH 2/3] guile-2.0.14 mingw64 fixups. --- libguile/deprecated.h | 2 ++ libguile/iselect.h | 4 ++-- libguile/load.c | 39 +++++++++++++++++++++++++++++++++++---- libguile/null-threads.h | 3 ++- libguile/posix-w32.h | 1 + libguile/stime.c | 2 +- 6 files changed, 43 insertions(+), 8 deletions(-) diff --git a/libguile/deprecated.h b/libguile/deprecated.h index 4d7819761..2d6f71c7d 100644 --- a/libguile/deprecated.h +++ b/libguile/deprecated.h @@ -742,11 +742,13 @@ SCM_DEPRECATED SCM scm_c_make_keyword (const char *s); SCM_DEPRECATED unsigned int scm_thread_sleep (unsigned int); SCM_DEPRECATED unsigned long scm_thread_usleep (unsigned long); +#if HAVE_PTHREAD_SIGMASK SCM_DEPRECATED int scm_internal_select (int fds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeout); +#endif /* Deprecated because the cuserid call is deprecated. */ diff --git a/libguile/iselect.h b/libguile/iselect.h index 1272b8d27..c99ae8e85 100644 --- a/libguile/iselect.h +++ b/libguile/iselect.h @@ -27,7 +27,7 @@ /* Needed for FD_SET on some systems. */ #include - +#if HAVE_PTHREAD_SIGMASK #include SCM_API int scm_std_select (int fds, @@ -37,7 +37,7 @@ SCM_API int scm_std_select (int fds, struct timeval *timeout); #define SELECT_TYPE fd_set - +#endif #endif /* SCM_ISELECT_H */ /* diff --git a/libguile/load.c b/libguile/load.c index c2ee5093a..de9efeb7f 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -535,6 +535,19 @@ is_absolute_file_name (SCM filename) #endif ) return 1; +#ifdef __MINGW32__ + /* MSys passes paths around with e.g. C: replaced with /c. Guile finds + that indigestible, so check for it and if it's the case rewrite + it. */ + if (filename_len >=3 + && is_file_name_separator (scm_c_string_ref (filename, 0)) + && is_drive_letter (scm_c_string_ref (filename, 1)) + && is_file_name_separator (scm_c_string_ref (filename, 2))) + { + scm_c_string_set_x (filename, 0, scm_c_string_ref(filename, 1)); + scm_c_string_set_x (filename, 1, SCM_MAKE_CHAR (':')); + } +#endif if (filename_len >= 3 && is_drive_letter (scm_c_string_ref (filename, 0)) && scm_is_eq (scm_c_string_ref (filename, 1), SCM_MAKE_CHAR (':')) @@ -723,9 +736,18 @@ load_thunk_from_path (SCM filename, SCM source_file_name, buf.ptr = buf.buf; stringbuf_cat_locale_string (&buf, dir); - +#ifdef __MINGW32__ + /* Fiddle the drive letter if necessary */ + if (is_file_name_separator (SCM_MAKE_CHAR (buf.buf[0])) + && is_drive_letter (SCM_MAKE_CHAR (buf.buf[1])) + && is_file_name_separator (SCM_MAKE_CHAR (buf.buf[2]))) + { + buf.buf[0] = buf.buf[1]; + buf.buf[1] = ':'; + } +#endif /* Concatenate the path name and the filename. */ - + if (buf.ptr > buf.buf && !is_file_name_separator (SCM_MAKE_CHAR (buf.ptr[-1]))) stringbuf_cat (&buf, FILE_NAME_SEPARATOR_STRING); @@ -877,9 +899,18 @@ search_path (SCM path, SCM filename, SCM extensions, SCM require_exts, buf.ptr = buf.buf; stringbuf_cat_locale_string (&buf, dir); - +#ifdef __MINGW32__ + /* Fiddle the drive letter if necessary */ + if (is_file_name_separator (SCM_MAKE_CHAR (buf.buf[0])) + && is_drive_letter (SCM_MAKE_CHAR (buf.buf[1])) + && is_file_name_separator (SCM_MAKE_CHAR (buf.buf[2]))) + { + buf.buf[0] = buf.buf[1]; + buf.buf[1] = ':'; + } +#endif /* Concatenate the path name and the filename. */ - + if (buf.ptr > buf.buf && !is_file_name_separator (SCM_MAKE_CHAR (buf.ptr[-1]))) stringbuf_cat (&buf, FILE_NAME_SEPARATOR_STRING); diff --git a/libguile/null-threads.h b/libguile/null-threads.h index dcb14e6a7..cfe06bbb5 100644 --- a/libguile/null-threads.h +++ b/libguile/null-threads.h @@ -82,12 +82,13 @@ scm_i_sched_yield (void) /* Signals */ +#if HAVE_PTHREAD_SIGMASK static inline int scm_i_pthread_sigmask (int how, const sigset_t *set, sigset_t *oldset) { return sigprocmask (how, set, oldset); } - +#endif /* Mutexes */ typedef enum { diff --git a/libguile/posix-w32.h b/libguile/posix-w32.h index f11a25e49..6040e05c8 100644 --- a/libguile/posix-w32.h +++ b/libguile/posix-w32.h @@ -21,6 +21,7 @@ * 02110-1301 USA */ +#include #include #define _UTSNAME_LENGTH 65 diff --git a/libguile/stime.c b/libguile/stime.c index 7a139747f..7e4b7dfe3 100644 --- a/libguile/stime.c +++ b/libguile/stime.c @@ -122,7 +122,7 @@ get_internal_real_time_posix_timer (void) ts.tv_nsec - posix_real_time_base.tv_nsec); } -#if defined _POSIX_CPUTIME && defined CLOCK_PROCESS_CPUTIME_ID +#if defined _POSIX_CPUTIME && defined CLOCK_PROCESS_CPUTIME_ID && !defined(WINPTHREAD_API) /* You see, FreeBSD defines _POSIX_CPUTIME but not CLOCK_PROCESS_CPUTIME_ID. */ #define HAVE_POSIX_CPUTIME 1 @@ -830,12 +830,7 @@ scm_init_stime() #ifdef HAVE_POSIX_CPUTIME { - clockid_t dummy; - - /* Only use the _POSIX_CPUTIME clock if it's going to work across - CPUs. */ - if (clock_getcpuclockid (0, &dummy) == 0 && - clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &posix_run_time_base) == 0) + if (clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &posix_run_time_base) == 0) get_internal_run_time = get_internal_run_time_posix_timer; else errno = 0; diff --git a/lib/intprops.h~ b/lib/intprops.h index feb02c3..84de8ee 100644 --- a/lib/intprops.h~ +++ b/lib/intprops.h @@ -230,11 +230,11 @@ verify (TYPE_MAXIMUM (long long int) == LLONG_MAX); (e.g., A and B) have the same type as MIN and MAX. Instead, they assume that the result (e.g., A + B) has that type. */ #if _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL -# define _GL_ADD_OVERFLOW(a, b, min, max) +# define _GL_ADD_OVERFLOW(a, b, min, max) \ __builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0) -# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) +# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ __builtin_sub_overflow (a, b, (__typeof__ ((a) - (b)) *) 0) -# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) +# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ __builtin_mul_overflow (a, b, (__typeof__ ((a) * (b)) *) 0) #else # define _GL_ADD_OVERFLOW(a, b, min, max) \