Zth (libzth)
Loading...
Searching...
No Matches
io.h
Go to the documentation of this file.
1#ifndef ZTH_IO_H
2#define ZTH_IO_H
3/*
4 * SPDX-FileCopyrightText: 2019-2026 Jochem Rutgers
5 *
6 * SPDX-License-Identifier: MPL-2.0
7 */
8
18#include <libzth/macros.h>
19
20#include <libzth/poller.h>
21
22#include <unistd.h>
23
24#if defined(ZTH_HAVE_POLLER)
25# if !defined(ZTH_OS_WINDOWS)
26# if defined(__cplusplus)
27namespace zth {
28namespace io {
29
30ZTH_EXPORT ssize_t read(int fd, void* buf, size_t count);
31ZTH_EXPORT ssize_t write(int fd, void const* buf, size_t count);
32
33} // namespace io
34} // namespace zth
35
41EXTERN_C ZTH_EXPORT ZTH_INLINE ssize_t zth_read(int fd, void* buf, size_t count)
42{
43 return zth::io::read(fd, buf, count);
44}
45
51EXTERN_C ZTH_EXPORT ZTH_INLINE ssize_t zth_write(int fd, void const* buf, size_t count)
52{
53 return zth::io::write(fd, buf, count);
54}
55
56# else // !__cplusplus
57ZTH_EXPORT ssize_t zth_read(int fd, void* buf, size_t count);
58ZTH_EXPORT ssize_t zth_write(int fd, void const* buf, size_t count);
59# endif // __cplusplus
60# endif // !ZTH_OS_WINDOWS
61#endif // ZTH_HAVE_POLLER
62
63#endif // ZTH_IO_H
ssize_t zth_read(int fd, void *buf, size_t count)
Like normal read(), but forwards the poll() to the zth::Waiter in case it would block.
Definition io.h:41
ssize_t zth_write(int fd, void const *buf, size_t count)
Like normal write(), but forwards the poll() to the zth::Waiter in case it would block.
Definition io.h:51
ssize_t read(int fd, void *buf, size_t count)
Like normal read(), but forwards the poll() to the zth::Waiter in case it would block.
Definition io.cpp:24
ssize_t write(int fd, void const *buf, size_t count)
Like normal write(), but forwards the poll() to the zth::Waiter in case it would block.
Definition io.cpp:52
#define ZTH_INLINE
Definition macros.h:129