[Issue 13338] New: Wrong declaration of epoll_event in core.sys.linux.epoll.d

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Aug 20 03:17:04 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13338

          Issue ID: 13338
           Summary: Wrong declaration of epoll_event in
                    core.sys.linux.epoll.d
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: netmindms at gmail.com

In core.sys.linux.epoll.d, struct epoll_event is declared as follows.


struct epoll_event 
{ 
     uint events;
     epoll_data_t data;
};

But C declaration is packed in epoll.h as follows.

struct epoll_event
{
  uint32_t events;    /* Epoll events */
  epoll_data_t data;    /* User data variable */
} __attribute__ ((__packed__));

So, I think the declaration must be modified in D as follows.

extern(C) align(1) struct epoll_event
{
align(1):
  uint events;    /* Epoll events */
  epoll_data_t data;    /* User data variable */
}

Because of this mismatch in alignment between C and D, epoll_wait in D reports
abnormal event user data.(especially u64).

I confirmed this malfunction on code test.

--


More information about the Digitalmars-d-bugs mailing list