42#elif !LELY_NO_THREADS && _WIN32
43 InterlockedIncrementNoFence(&handle->
ref);
60#elif !LELY_NO_THREADS && _WIN32
61 if (!InterlockedDecrementRelease(&handle->
ref)) {
64 if (handle->
ref-- == 1) {
98 handle->
fd = INVALID_HANDLE_VALUE;
113 assert(handle->
vtab);
This header file is part of the utilities library; it contains the native and platform-independent er...
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
io_handle_t io_handle_acquire(io_handle_t handle)
Increments the reference count of an I/O device handle.
void io_handle_fini(struct io_handle *handle)
Finalizes an I/O device handle by invoking its fini method, if available.
int io_handle_unique(io_handle_t handle)
Returns 1 if there is only a single reference to the specified I/O device handle, and 0 otherwise.
void io_handle_destroy(struct io_handle *handle)
Destroys an I/O device handle.
void io_handle_free(struct io_handle *handle)
Frees an I/O device handle.
struct io_handle * io_handle_alloc(const struct io_handle_vtab *vtab)
Allocates a new I/O device handle from a virtual table.
void io_handle_unlock(struct io_handle *handle)
Unlocks a locked I/O device handle.
void io_handle_release(io_handle_t handle)
Decrements the reference count of an I/O device handle.
void io_handle_lock(struct io_handle *handle)
Locks an unlocked I/O device handle, so the flags (and other device-specific fields) can safely be ac...
This is the internal header file of the I/O handle declarations.
#define IO_HANDLE_ERROR
The value of an invalid I/O device handle.
This is the internal header file of the Windows-specific I/O declarations.
@ memory_order_release
A store operation performs a release operation on the affected memory location.
@ memory_order_relaxed
No operation orders memory.
@ memory_order_acquire
A load operation performs an acquire operation on the affected memory location.
#define atomic_fetch_add_explicit(object, operand, order)
Atomically replaces the value at object with *object + operand.
void atomic_thread_fence(memory_order order)
Inserts a fence with semantics according to order.
#define atomic_load(object)
Equivalent to atomic_load_explicit(object, memory_order_seq_cst).
#define atomic_init(obj, value)
Initializes the atomic object at obj with the value value.
#define atomic_fetch_sub_explicit(object, operand, order)
Atomically replaces the value at object with *object - operand.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib....
The virtual table of an I/O device handle.
void(* fini)(struct io_handle *handle)
A pointer to the fini method.
size_t size
The size (in bytes) of the handle struct.
int fd
The native file descriptor.
atomic_size_t ref
The reference count.
int flags
The I/O device flags (any combination of IO_FLAG_NO_CLOSE and IO_FLAG_NONBLOCK).
mtx_t mtx
The mutex protecting flags (and other device-specific fields).
const struct io_handle_vtab * vtab
A pointer to the virtual table.
int mtx_init(mtx_t *mtx, int type)
Creates a mutex object with properties indicated by type, which must have one of the four values:
int mtx_lock(mtx_t *mtx)
Blocks until it locks the mutex at mtx.
int mtx_unlock(mtx_t *mtx)
Unlocks the mutex at mtx.
void mtx_destroy(mtx_t *mtx)
Releases any resources used by the mutex at mtx.
@ mtx_plain
A mutex type that supports neither timeout nor test and return.