libcppwrap
A collection of C++ wrappers for native APIs
Loading...
Searching...
No Matches
linux.hpp
Go to the documentation of this file.
1//
2// libcppwrap - A collection of C++ wrappers for native APIs
3// Copyright (C) 2021-2023 David A. Norris <danorris@gmail.com>
4// Published under the MIT license - https://opensource.org/licenses/MIT
5//
6
7#pragma once
8
9#include <chrono>
10#include <cstdint>
11#include <utility>
12
13#include <w/posix.hpp>
14
15#include <sys/epoll.h>
16
17namespace w
18{
26 w::fd epoll_create(int size = sizeof(nullptr));
27
37 void epoll_ctl(int epfd, int op, int fd, struct epoll_event *event = nullptr);
38
49 void epoll_ctl(int epfd, int op, int fd, std::uint32_t events, void *user_data = nullptr);
50
61 void epoll_ctl(int epfd, int op, int fd, std::uint32_t events, int user_data);
62
73 void epoll_ctl(int epfd, int op, int fd, std::uint32_t events, std::uint32_t user_data);
74
85 void epoll_ctl(int epfd, int op, int fd, std::uint32_t events, std::uint64_t user_data);
86
98 unsigned epoll_wait(int epfd, struct epoll_event *events, int maxevents,
100
107 w::fd eventfd(unsigned initval = 0, int flags = 0);
108
117 std::uint64_t eventfd_read(int evfd);
118
127 void eventfd_write(int evfd, std::uint64_t value);
128
137 w::fd timerfd_create(int clockid, int flags = 0);
138
150 void timerfd_settime(int fd, int flags,
151 const struct itimerspec *new_value,
152 struct itimerspec *old_value);
153
166 timerfd_settime(int fd, int flags,
169}
An RAII handle type which owns an opaque resource of a specified type, and calls a designated functio...
Definition: handle.hpp:40
Definition: assert.hpp:13
w::handle< int, -1, ::close > fd
An RAII util::handle type for POSIX file descriptors.
Definition: posix.hpp:25
void timerfd_settime(int fd, int flags, const struct itimerspec *new_value, struct itimerspec *old_value)
Sets the timeout and repetition interval of a timer file descriptor.
Definition: linux.cpp:102
unsigned epoll_wait(int epfd, struct epoll_event *events, int maxevents, std::chrono::milliseconds timeout=std::chrono::milliseconds(-1))
Waits for events to occur on an epoll instance.
Definition: linux.cpp:61
void eventfd_write(int evfd, std::uint64_t value)
Modifies the counter value of an event file descriptor; see the man page of eventfd() for a descripti...
Definition: linux.cpp:89
w::fd eventfd(unsigned initval=0, int flags=0)
Creates an event file descriptor.
Definition: linux.cpp:74
w::fd epoll_create(int size=sizeof(nullptr))
Creates an epoll instance.
Definition: linux.cpp:21
w::fd timerfd_create(int clockid, int flags=0)
Creates a timer file descriptor.
Definition: linux.cpp:94
std::uint64_t eventfd_read(int evfd)
Reads the current counter value of an event file descriptor; see the man page of eventfd() for a desc...
Definition: linux.cpp:82
void epoll_ctl(int epfd, int op, int fd, struct epoll_event *event=nullptr)
Manipulates an epoll instance.
Definition: linux.cpp:29