Issue #8174 has been updated by nobu (Nobuyoshi Nakada).

% Done changed from 100 to 50
ruby -v set to trunk


----------------------------------------
Bug #8174: AIX header file conflict with rb_hook_list_struct
https://bugs.ruby-lang.org/issues/8174#change-38021

Author: edelsohn (David Edelsohn)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: 
Target version: 
ruby -v: trunk


=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



-- 
http://bugs.ruby-lang.org/