From 2792aa26c335784928c9ad8a6fdc22068d3fb4e8 Mon Sep 17 00:00:00 2001 From: papadave66 Date: Sun, 2 Jun 2019 13:18:24 +0800 Subject: [PATCH 1/2] Move config/linux.h to config/gnu.h as this file contains only GLIBC specific detections --- Makefile.am | 2 +- include/libcork/config/config.h | 6 +++--- include/libcork/config/{linux.h => gnu.h} | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename include/libcork/config/{linux.h => gnu.h} (88%) diff --git a/Makefile.am b/Makefile.am index 4ac80e2..c76f673 100644 --- a/Makefile.am +++ b/Makefile.am @@ -72,7 +72,7 @@ config_include_HEADERS = \ include/libcork/config/gcc.h \ include/libcork/config/macosx.h \ include/libcork/config/bsd.h \ - include/libcork/config/linux.h \ + include/libcork/config/gnu.h \ include/libcork/config/config.h core_include_HEADERS = \ diff --git a/include/libcork/config/config.h b/include/libcork/config/config.h index ca49047..507199a 100644 --- a/include/libcork/config/config.h +++ b/include/libcork/config/config.h @@ -44,9 +44,9 @@ #include #endif -#if defined(__linux) || defined(__FreeBSD_kernel__) || defined(__GNU__) -/* Do some Linux, kFreeBSD or GNU/Hurd specific autodetection. */ -#include +#ifdef __GLIBC__ +/* Do some GNU specific autodetection. */ +#include #elif defined(__APPLE__) && defined(__MACH__) /* Do some Mac OS X-specific autodetection. */ diff --git a/include/libcork/config/linux.h b/include/libcork/config/gnu.h similarity index 88% rename from include/libcork/config/linux.h rename to include/libcork/config/gnu.h index de4a3d9..b8e6f9a 100644 --- a/include/libcork/config/linux.h +++ b/include/libcork/config/gnu.h @@ -7,8 +7,8 @@ * ---------------------------------------------------------------------- */ -#ifndef LIBCORK_CONFIG_LINUX_H -#define LIBCORK_CONFIG_LINUX_H +#ifndef LIBCORK_CONFIG_GNU_H +#define LIBCORK_CONFIG_GNU_H /*----------------------------------------------------------------------- * Endianness @@ -30,4 +30,4 @@ #define CORK_HAVE_PTHREADS 1 -#endif /* LIBCORK_CONFIG_LINUX_H */ +#endif /* LIBCORK_CONFIG_GNU_H */ From f45283ef2a0fd64eb59fbbffb8f43d590ca7b0b3 Mon Sep 17 00:00:00 2001 From: papadave66 Date: Sun, 2 Jun 2019 13:25:46 +0800 Subject: [PATCH 2/2] Add auto-detection macros and THREAD_YIELD support for Cygwin --- Makefile.am | 1 + include/libcork/config/config.h | 4 ++++ include/libcork/config/cygwin.h | 33 +++++++++++++++++++++++++++++++++ src/libcork/posix/subprocess.c | 2 +- 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 include/libcork/config/cygwin.h diff --git a/Makefile.am b/Makefile.am index c76f673..186fa85 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,6 +73,7 @@ config_include_HEADERS = \ include/libcork/config/macosx.h \ include/libcork/config/bsd.h \ include/libcork/config/gnu.h \ + include/libcork/config/cygwin.h \ include/libcork/config/config.h core_include_HEADERS = \ diff --git a/include/libcork/config/config.h b/include/libcork/config/config.h index 507199a..adf9a5b 100644 --- a/include/libcork/config/config.h +++ b/include/libcork/config/config.h @@ -56,6 +56,10 @@ /* Do some BSD (4.3 code base or newer)specific autodetection. */ #include +#elif defined(__CYGWIN__) +/* Do some Cygwin autodectection. */ +#include + #endif /* platforms */ diff --git a/include/libcork/config/cygwin.h b/include/libcork/config/cygwin.h new file mode 100644 index 0000000..b950de5 --- /dev/null +++ b/include/libcork/config/cygwin.h @@ -0,0 +1,33 @@ +/* -*- coding: utf-8 -*- + * ---------------------------------------------------------------------- + * Copyright © 2019, libcork authors + * All rights reserved. + * + * Please see the COPYING file in this distribution for license details. + * ---------------------------------------------------------------------- + */ + +#ifndef LIBCORK_CONFIG_CYGWIN_H +#define LIBCORK_CONFIG_CYGWIN_H + +/*----------------------------------------------------------------------- + * Endianness + */ + +#include + +#if __BYTE_ORDER == __BIG_ENDIAN +#define CORK_CONFIG_IS_BIG_ENDIAN 1 +#define CORK_CONFIG_IS_LITTLE_ENDIAN 0 +#elif __BYTE_ORDER == __LITTLE_ENDIAN +#define CORK_CONFIG_IS_BIG_ENDIAN 0 +#define CORK_CONFIG_IS_LITTLE_ENDIAN 1 +#else +#error "Cannot determine system endianness" +#endif + +#define CORK_HAVE_REALLOCF 1 +#define CORK_HAVE_PTHREADS 1 + + +#endif /* LIBCORK_CONFIG_CYGWIN_H */ diff --git a/src/libcork/posix/subprocess.c b/src/libcork/posix/subprocess.c index b1d23a5..904240e 100644 --- a/src/libcork/posix/subprocess.c +++ b/src/libcork/posix/subprocess.c @@ -497,7 +497,7 @@ cork_subprocess_is_finished(struct cork_subprocess *self) #if defined(__APPLE__) #include #define THREAD_YIELD pthread_yield_np -#elif defined(__linux__) || defined(BSD) || defined(__FreeBSD_kernel__) || defined(__GNU__) +#elif defined(__linux__) || defined(BSD) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__CYGWIN__) #include #define THREAD_YIELD sched_yield #else