diff --git a/libcork/include/libcork/config/config.h b/libcork/include/libcork/config/config.h index 5fa36f7d..3a288572 100644 --- a/libcork/include/libcork/config/config.h +++ b/libcork/include/libcork/config/config.h @@ -52,6 +52,10 @@ /* Do some BSD (4.3 code base or newer)specific autodetection. */ #include +#elif defined(__MINGW32__) +/* Do some mingw32 autodetection. */ +#include + #endif /* platforms */ diff --git a/libcork/include/libcork/config/mingw32.h b/libcork/include/libcork/config/mingw32.h new file mode 100644 index 00000000..c62cbc52 --- /dev/null +++ b/libcork/include/libcork/config/mingw32.h @@ -0,0 +1,52 @@ +/* -*- coding: utf-8 -*- + * ---------------------------------------------------------------------- + * Copyright © 2011, RedJack, LLC. + * All rights reserved. + * + * Please see the COPYING file in this distribution for license + * details. + * ---------------------------------------------------------------------- + */ + +#ifndef LIBCORK_CONFIG_MINGW32_H +#define LIBCORK_CONFIG_MINGW32_H + +#include + +/*----------------------------------------------------------------------- + * Endianness + */ + +/* Assume MinGW32 only works on x86 platform */ + +#define CORK_CONFIG_IS_BIG_ENDIAN 0 +#define CORK_CONFIG_IS_LITTLE_ENDIAN 1 + +#define CORK_HAVE_REALLOCF 0 +#define CORK_HAVE_PTHREADS 1 + +/* + * File io stuff. Odd that this is not defined by MinGW. + * Maybe there is an M$ish way to do it. + */ +#define F_SETFL 4 +#define O_NONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ + +#define F_GETFD 1 +#define F_SETFD 2 +#define FD_CLOEXEC 0x1 + +#define WNOHANG 1 + +/* + * simple adaptors + */ + +static inline int mingw_mkdir(const char *path, int mode) +{ + return mkdir(path); +} +#define mkdir mingw_mkdir + + +#endif /* LIBCORK_CONFIG_MINGW32_H */ diff --git a/libcork/posix/subprocess.c b/libcork/posix/subprocess.c index a97b8043..f2a2442d 100644 --- a/libcork/posix/subprocess.c +++ b/libcork/posix/subprocess.c @@ -12,8 +12,10 @@ #include #include #include +#ifndef __MINGW32__ #include #include +#endif #include #include "libcork/core.h" @@ -506,7 +508,7 @@ cork_subprocess_is_finished(struct cork_subprocess *self) && cork_read_pipe_is_finished(&self->stderr_pipe); } -#if defined(__APPLE__) +#if defined(__APPLE__) || defined(__MINGW32__) #include #define THREAD_YIELD pthread_yield_np #elif defined(__linux__) || defined(BSD)