Skip to content

getitimer()/setitimer() are missing on Linux #1347

@frol

Description

@frol
#include <sys/time.h>

int getitimer(int which, struct itimerval *value);
int setitimer(int which, const struct itimerval *restrict value, struct itimerval *restrict ovalue);

man

This is a minimal demo:

let tval = nix::libc::itimerval {
    it_interval: nix::libc::timeval {
        tv_sec: 0,
        tv_usec: 0,
    },
    it_value: nix::libc::timeval {
        tv_sec: 1,
        tv_usec: 0,
    },
};
if unsafe { setitimer(nix::libc::ITIMER_REAL, &tval as *const _, std::ptr::null_mut()) } == -1 {
    panic!("setitimer");
}

let tval2 = nix::libc::itimerval {
    it_interval: nix::libc::timeval {
        tv_sec: 0,
        tv_usec: 0,
    },
    it_value: nix::libc::timeval {
        tv_sec: 0,
        tv_usec: 0,
    },
};
if unsafe { getitimer(nix::libc::ITIMER_REAL, &mut tval as *mut _) } == -1 {
    panic!("getitimer");
}

I have found these two commits: e976c37, bc48202 -- getitimer and setitimer we introduced and dropped for netbsd target. Those definitions seem to work fine for me on Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-API-requestCategory: API requestE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.O-linux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions