Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cygwin support and rename linux.h to gnu.h #154

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ 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/cygwin.h \
include/libcork/config/config.h

core_include_HEADERS = \
Expand Down
10 changes: 7 additions & 3 deletions include/libcork/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
#include <sys/param.h>
#endif

#if defined(__linux) || defined(__FreeBSD_kernel__) || defined(__GNU__)
/* Do some Linux, kFreeBSD or GNU/Hurd specific autodetection. */
#include <libcork/config/linux.h>
#ifdef __GLIBC__
/* Do some GNU specific autodetection. */
#include <libcork/config/gnu.h>

#elif defined(__APPLE__) && defined(__MACH__)
/* Do some Mac OS X-specific autodetection. */
Expand All @@ -56,6 +56,10 @@
/* Do some BSD (4.3 code base or newer)specific autodetection. */
#include <libcork/config/bsd.h>

#elif defined(__CYGWIN__)
/* Do some Cygwin autodectection. */
#include <libcork/config/cygwin.h>

#endif /* platforms */


Expand Down
33 changes: 33 additions & 0 deletions include/libcork/config/cygwin.h
Original file line number Diff line number Diff line change
@@ -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 <endian.h>

#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 */
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,4 +30,4 @@
#define CORK_HAVE_PTHREADS 1


#endif /* LIBCORK_CONFIG_LINUX_H */
#endif /* LIBCORK_CONFIG_GNU_H */
2 changes: 1 addition & 1 deletion src/libcork/posix/subprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ cork_subprocess_is_finished(struct cork_subprocess *self)
#if defined(__APPLE__)
#include <pthread.h>
#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 <sched.h>
#define THREAD_YIELD sched_yield
#else
Expand Down