Skip to content

epoll event constants should be declared as u32 #3462

Closed
@tremon015

Description

@tremon015

The current implementation declares all EPOLL* event constants as c_int, but this isn't very useful given that the accompanying field in struct epoll_event is declared as u32.

pub const EPOLLIN: c_int = 0x1;

pub struct epoll_event {
    pub events: u32,
    pub u64: u64,
}

This makes using these constants very unergonomic:

error[E0308]: mismatched types
   --> src/bin/hld.rs:256:46
    |
256 |          if event.events & EPOLLIN == EPOLLIN {
    |                            ^^^^^^^ expected `u32`, found `i32`

error[E0277]: no implementation for `u32 & i32`
   --> src/bin/hld.rs:256:44
    |
256 |          if event.events & EPOLLIN == EPOLLIN {
    |                          ^ no implementation for `u32 & i32`
    |

The first thing every user of these constants will do is redefine them as u32. Can this be done in the libc crate itself? This applies to all EPOLL* event descriptors and input flags, but not the EPOLL_CTL_* operation constants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions