Project

General

Profile

Feature #16597 » 0001-io-move-poll-defines-to-internal-io.h.patch

michals (Michal Suchánek), 05/29/2020 05:52 PM

View differences:

internal/io.h
#include "ruby/ruby.h" /* for VALUE */
#include "ruby/io.h" /* for rb_io_t */
/* non-Linux poll may not work on all FDs */
#if defined(HAVE_POLL)
# if defined(__linux__)
# define USE_POLL 1
# endif
# if defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
# define USE_POLL 1
# endif
#endif
#ifndef USE_POLL
# define USE_POLL 0
#endif
#if USE_POLL
#define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN)
#define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT)
#define POLLEX_SET (POLLPRI)
#define POLLERR_SET (POLLHUP | POLLERR)
#endif
/* io.c */
void ruby_set_inplace_mode(const char *);
void rb_stdio_set_default_encoding(void);
io.c
#include <errno.h>
#include <stddef.h>
/* non-Linux poll may not work on all FDs */
#if defined(HAVE_POLL)
# if defined(__linux__)
# define USE_POLL 1
# endif
# if defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
# define USE_POLL 1
# endif
#endif
#ifndef USE_POLL
# define USE_POLL 0
#endif
#undef free
#define free(x) xfree(x)
thread.c
return vm->living_thread_num;
}
/*
* poll() is supported by many OSes, but so far Linux is the only
* one we know of that supports using poll() in all places select()
* would work.
*/
#if defined(HAVE_POLL)
# if defined(__linux__)
# define USE_POLL
# endif
# if defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
# define USE_POLL
/* FreeBSD does not set POLLOUT when POLLHUP happens */
# define POLLERR_SET (POLLHUP | POLLERR)
# endif
#endif
static void
timeout_prepare(rb_hrtime_t **to, rb_hrtime_t *rel, rb_hrtime_t *end,
const struct timeval *timeout)
......
return Qnil;
}
#ifdef USE_POLL
/* The same with linux kernel. TODO: make platform independent definition. */
#define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP | POLLERR)
#define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT | POLLERR)
#define POLLEX_SET (POLLPRI)
#ifndef POLLERR_SET /* defined for FreeBSD for now */
# define POLLERR_SET (0)
#endif
#if USE_POLL
/*
* returns a mask of events
*/
(4-4/14)