Project

General

Profile

Actions

Backport #8174

closed

AIX header file conflict with rb_hook_list_struct

Added by edelsohn (David Edelsohn) over 11 years ago. Updated over 11 years ago.


Description

=begin
rb_hook_list_struct defines a member "events":

typedef struct rb_hook_list_struct {
struct rb_event_hook_struct *hooks;
rb_event_flag_t events;
int need_clean;
} rb_hook_list_t;

AIX defines a macro "events" in sys/poll.h:

struct pollfd
{
long fd; /* file descriptor or file ptr /
ushort reqevents; /
requested events /
ushort rtnevents; /
returned events /
};
#define events reqevents /
SVR3,4 pollfd member name /
#define revents rtnevents /
SVR3,4 pollfd member name */

Ruby thread.c includes sys/poll.c via ruby/io.h. This renames the structure member when referenced through EXEC_EVENT_HOOK, e.g.,

    if ((state = EXEC_TAG()) == 0) {
        SAVE_ROOT_JMPBUF(th, {
            if (!th->first_func) {
                GetProcPtr(th->first_proc, proc);
                th->errinfo = Qnil;
                th->root_lep = rb_vm_ep_local_ep(proc->block.ep);
                th->root_svar = Qnil;
                EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, Qundef);
                th->value = rb_vm_invoke_proc(th, proc, (int)RARRAY_LEN(args), RARRAY_PTR(args), 0);
                EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_END, th->self, 0, 0, Qundef);
            }

This makes the compiler unhappy:

compiling /usr/gnu/src/ruby-2.0.0-p0/thread.c
/usr/gnu/src/ruby-2.0.0-p0/thread.c: In function 'thread_start_func_2':
/usr/gnu/src/ruby-2.0.0-p0/thread.c:496:6: error: 'rb_hook_list_t' has no member named 'reqevents'
/usr/gnu/src/ruby-2.0.0-p0/thread.c:496:6: error: 'rb_hook_list_t' has no member named 'reqevents'
/usr/gnu/src/ruby-2.0.0-p0/thread.c:496:6: error: 'rb_hook_list_t' has no member named 'reqevents'
/usr/gnu/src/ruby-2.0.0-p0/thread.c:496:6: error: 'rb_hook_list_t' has no member named 'reqevents'
/usr/gnu/src/ruby-2.0.0-p0/thread.c: In function 'rb_threadptr_execute_interrupts':
/usr/gnu/src/ruby-2.0.0-p0/thread.c:1917:6: error: 'rb_hook_list_t' has no member named 'reqevents'
/usr/gnu/src/ruby-2.0.0-p0/thread.c:1917:6: error: 'rb_hook_list_t' has no member named 'reqevents'

Because Ruby only uses fd member revents, one option is to change include/ruby/io.h

diff

#include "ruby/config.h"
#if defined(HAVE_POLL)

include <poll.h>

+# undef events

define RB_WAITFD_IN POLLIN

define RB_WAITFD_PRI POLLPRI

define RB_WAITFD_OUT POLLOUT

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0