Ruby: include/ruby/internal/intern/select/posix.h File Reference

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

Macros | Typedefs | Functions
posix.h File Reference

Public APIs to provide rb_fd_select(). More...

`#include "ruby/internal/config.h"`
`#include "ruby/internal/attr/const.h"`
`#include "ruby/internal/attr/noalias.h"`
`#include "ruby/internal/attr/nonnull.h"`
`#include "ruby/internal/attr/pure.h"`

Go to the source code of this file.

## Macros
#define | rb_fd_zero FD_ZERO
| Clears the given rb_fdset_t.
#define | rb_fd_set FD_SET
| Sets the given fd to the rb_fdset_t.
#define | rb_fd_clr FD_CLR
| Unsets the given fd from the rb_fdset_t.
#define | rb_fd_isset FD_ISSET
| Queries if the given fd is in the rb_fdset_t.
#define | rb_fd_init FD_ZERO
| Initialises the :given :rb_fdset_t.
#define | rb_fd_select select
| Waits for multiple file descriptors at once.

## Typedefs
typedef fd_set | rb_fdset_t
| The data structure which wraps the fd_set bitmap used by `select(2)`.

## Functions
static void | rb_fd_copy (rb_fdset_t *dst, const fd_set *src, int n)
| Destructively overwrites an fdset with another.
static void | rb_fd_dup (rb_fdset_t *dst, const fd_set *src)
| Destructively overwrites an fdset with another.
static fd_set * | rb_fd_ptr (rb_fdset_t *f)
| Raw pointer to `fd_set`.
static int | rb_fd_max (const rb_fdset_t *f)
| It seems this function has no use.

## Detailed Description

Public APIs to provide rb_fd_select().

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file posix.h.

## Macro Definition Documentation

## ◆ rb_fd_clr

#define rb_fd_clr FD_CLR

Unsets the given fd from the rb_fdset_t.

Definition at line 57 of file posix.h.

## ◆ rb_fd_init

#define rb_fd_init FD_ZERO

Initialises the :given :rb_fdset_t.

Definition at line 63 of file posix.h.

## ◆ rb_fd_isset

#define rb_fd_isset FD_ISSET

Queries if the given fd is in the rb_fdset_t.

Definition at line 60 of file posix.h.

## ◆ rb_fd_select

#define rb_fd_select select

Waits for multiple file descriptors at once.

Definition at line 66 of file posix.h.

## ◆ rb_fd_set

#define rb_fd_set FD_SET

Sets the given fd to the rb_fdset_t.

Definition at line 54 of file posix.h.

Referenced by rb_thread_fd_select().

## ◆ rb_fd_zero

#define rb_fd_zero FD_ZERO

Clears the given rb_fdset_t.

Definition at line 51 of file posix.h.

## Typedef Documentation

## ◆ rb_fdset_t

typedef fd_set rb_fdset_t

The data structure which wraps the fd_set bitmap used by `select(2)`.

This allows Ruby to use FD sets larger than what has been historically allowed on modern platforms.

Definition at line 48 of file posix.h.

## Function Documentation

## ◆ rb_fd_copy()

static void rb_fd_copy | ( | rb_fdset_t * | dst,
|  | const fd_set * | src,
|  | int | n )
| inlinestatic

Destructively overwrites an fdset with another.

Parameters

  [out] | dst | Target fdset.
  [in] | src | Source fdset.
  [in] | n | Unused parameter.

Postcondition
  `dst` is a copy of `src`.

Definition at line 86 of file posix.h.

## ◆ rb_fd_dup()

static void rb_fd_dup | ( | rb_fdset_t * | dst,
|  | const fd_set * | src )
| inlinestatic

Destructively overwrites an fdset with another.

Parameters

  [out] | dst | Target fdset.
  [in] | src | Source fdset.

Postcondition
  `dst` is a copy of `src`.

Definition at line 101 of file posix.h.

## ◆ rb_fd_max()

static int rb_fd_max | ( | const rb_fdset_t * | f | ) |
| inlinestatic

It seems this function has no use.

Maybe just remove?

Parameters

  [in] | f | A set.

Returns
  Number of file descriptors stored.

Definition at line 133 of file posix.h.

## ◆ rb_fd_ptr()

static fd_set * rb_fd_ptr | ( | rb_fdset_t * | f | ) |
| inlinestatic

Raw pointer to `fd_set`.

Parameters

  [in] | f | Target fdset.

Returns
  Underlying fd_set.

Definition at line 120 of file posix.h.