Include <sys/select.h> for select() if available.

According to the man page, <sys/select.h> is the header to include
on POSIX systems for select() and associated APIs.
Fixes compilation with some versions of Cygwin (Github issue #49).

configure.ac:
runtime/mercury_conf.h.in
    Define MR_HAVE_SYS_SELECT_H if <sys/select.h> is available.

runtime/mercury_reg_workarounds.c
runtime/mercury_reg_workarounds.h
    Include <sys/select.h> if MR_HAVE_SYS_SELECT_H is defined.
This commit is contained in:
Peter Wang
2018-09-11 10:37:28 +10:00
parent 6a915eef05
commit e40d54f89c
4 changed files with 20 additions and 8 deletions

View File

@@ -1420,7 +1420,7 @@ MERCURY_CHECK_FOR_HEADERS( \
sys/types.h sys/stat.h fcntl.h termios.h sys/ioctl.h \
sys/resource.h sys/stropts.h windows.h dirent.h getopt.h malloc.h \
semaphore.h pthread.h time.h spawn.h fenv.h sys/mman.h sys/sem.h \
sched.h utmpx.h dispatch/dispatch.h stdint.h)
sched.h utmpx.h dispatch/dispatch.h stdint.h sys/select.h )
if test "$MR_HAVE_GETOPT_H" = 1; then
GETOPT_H_AVAILABLE=yes
@@ -2426,6 +2426,9 @@ AC_MSG_CHECKING(to see if we can handle contexts blocking on IO)
AC_CACHE_VAL(mercury_cv_can_do_pending_io,
AC_TRY_RUN(
[
#ifdef MR_HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include <sys/types.h>
#include <sys/time.h>
int main() {

View File

@@ -140,7 +140,8 @@
// MR_HAVE_UTMPX_H we have <utmpx.h>
// MR_HAVE_SYS_RESOURCE_H we have <sys/resource.h>
// MR_HAVE_DISPATCH_DISPATCH_H we have <dispatch/dispatch.h>
// MR_HAVE_STDINT we have <stdint.h>
// MR_HAVE_STDINT_H we have <stdint.h>
// MR_HAVE_SYS_SELECT_H we have <sys/select.h>
#undef MR_HAVE_SYS_SIGINFO_H
#undef MR_HAVE_SYS_SIGNAL_H
@@ -175,6 +176,7 @@
#undef MR_HAVE_SYS_RESOURCE_H
#undef MR_HAVE_DISPATCH_DISPATCH_H
#undef MR_HAVE_STDINT_H
#undef MR_HAVE_SYS_SELECT_H
// MR_HAVE_POSIX_TIMES is defined if we have the POSIX
// `struct tms' struct and times() function.

View File

@@ -14,15 +14,19 @@
#ifdef MR_CAN_DO_PENDING_IO
#ifdef MR_BZERO_NEEDS_STRINGS_HEADER
#include <strings.h>
#endif
#ifdef MR_BZERO_NEEDS_STRINGS_HEADER
#include <strings.h>
#endif
#include <sys/types.h> // for fd_set and FD_ZERO()
#include <sys/time.h> // for FD_ZERO()
#ifdef MR_HAVE_SYS_SELECT_H
#include <sys/select.h> // for select() -- POSIX
#endif
#include <sys/types.h> // for fd_set and FD_ZERO()
#include <sys/time.h> // for FD_ZERO()
#ifdef MR_HAVE_UNISTD_H
#include <unistd.h> // for FD_ZERO()
#include <unistd.h> // for FD_ZERO()
#endif
void

View File

@@ -12,6 +12,9 @@
#include "mercury_conf.h"
#ifdef MR_CAN_DO_PENDING_IO
#ifdef MR_HAVE_SYS_SELECT_H
#include <sys/select.h> // for select() -- POSIX
#endif
#include <sys/types.h> // for fd_set
#include <sys/time.h> // for FD_ZERO()
#endif