libosmocore
0.12.0
Osmocom core library
|
Files | |
file | select.h |
file | select.c |
Data Structures | |
struct | osmo_fd |
Structure representing a file dsecriptor. More... | |
Macros | |
#define | BSC_FD_READ 0x0001 |
Indicate interest in reading from the file descriptor. More... | |
#define | BSC_FD_WRITE 0x0002 |
Indicate interest in writing to the file descriptor. More... | |
#define | BSC_FD_EXCEPT 0x0004 |
Indicate interest in exceptions from the file descriptor. More... | |
Functions | |
void | osmo_fd_setup (struct osmo_fd *ofd, int fd, unsigned int when, int(*cb)(struct osmo_fd *fd, unsigned int what), void *data, unsigned int priv_nr) |
Set up an osmo-fd. More... | |
bool | osmo_fd_is_registered (struct osmo_fd *fd) |
Check if a file descriptor is already registered. More... | |
int | osmo_fd_register (struct osmo_fd *fd) |
Register a new file descriptor with select loop abstraction. More... | |
void | osmo_fd_unregister (struct osmo_fd *fd) |
Unregister a file descriptor from select loop abstraction. More... | |
void | osmo_fd_close (struct osmo_fd *fd) |
Close a file descriptor, mark it as closed + unregister from select loop abstraction. More... | |
int | osmo_select_main (int polling) |
select main loop integration More... | |
struct osmo_fd * | osmo_fd_get_by_fd (int fd) |
find an osmo_fd based on the integer fd More... | |
int | osmo_fd_fill_fds (void *_rset, void *_wset, void *_eset) |
Populate the fd_sets and return the highest fd number. More... | |
int | osmo_fd_disp_fds (void *readset, void *writeset, void *exceptset) |
int | osmo_timerfd_disable (struct osmo_fd *ofd) |
disable the osmocom-wrapped timerfd More... | |
int | osmo_timerfd_schedule (struct osmo_fd *ofd, const struct timespec *first, const struct timespec *interval) |
schedule the osmcoom-wrapped timerfd to occur first at first, then periodically at interval More... | |
int | osmo_timerfd_setup (struct osmo_fd *ofd, int(*cb)(struct osmo_fd *, unsigned int), void *data) |
setup osmocom-wrapped timerfd More... | |
static | LLIST_HEAD (osmo_fds) |
Variables | |
static int | maxfd = 0 |
static int | unregistered_count |
select() loop abstraction
#define BSC_FD_EXCEPT 0x0004 |
Indicate interest in exceptions from the file descriptor.
#define BSC_FD_READ 0x0001 |
Indicate interest in reading from the file descriptor.
#define BSC_FD_WRITE 0x0002 |
Indicate interest in writing to the file descriptor.
|
static |
void osmo_fd_close | ( | struct osmo_fd * | fd | ) |
Close a file descriptor, mark it as closed + unregister from select loop abstraction.
[in] | fd | osmocom file descriptor to be unregistered + closed |
If fd is registered, we unregister it from the select() loop abstraction. We then close the fd and set it to -1, as well as unsetting any 'when' flags
References osmo_fd::fd, osmo_fd_is_registered(), and osmo_fd_unregister().
|
inline |
References BSC_FD_EXCEPT, BSC_FD_READ, BSC_FD_WRITE, osmo_fd::cb, osmo_fd::fd, osmo_fd::list, llist_for_each_entry_safe, and unregistered_count.
Referenced by osmo_select_main().
|
inline |
Populate the fd_sets and return the highest fd number.
[in] | _rset | The readfds to populate |
[in] | _wset | The wrtiefds to populate |
[in] | _eset | The errorfds to populate |
References BSC_FD_EXCEPT, BSC_FD_READ, BSC_FD_WRITE, osmo_fd::fd, osmo_fd::list, llist_for_each_entry, and osmo_fd::when.
Referenced by osmo_select_main().
struct osmo_fd * osmo_fd_get_by_fd | ( | int | fd | ) |
find an osmo_fd based on the integer fd
[in] | fd | file descriptor to use as search key |
References osmo_fd::fd, osmo_fd::list, and llist_for_each_entry.
bool osmo_fd_is_registered | ( | struct osmo_fd * | fd | ) |
Check if a file descriptor is already registered.
[in] | fd | osmocom file descriptor to be checked |
References osmo_fd::fd, osmo_fd::list, and llist_for_each_entry.
Referenced by osmo_fd_close(), and osmo_fd_register().
int osmo_fd_register | ( | struct osmo_fd * | fd | ) |
Register a new file descriptor with select loop abstraction.
[in] | fd | osmocom file descriptor to be registered |
References osmo_fd::fd, llist_add_tail(), maxfd, and osmo_fd_is_registered().
Referenced by gsmtap_source_add_sink(), gsmtap_source_init(), osmo_fd_init_ofd(), and osmo_timerfd_setup().
void osmo_fd_setup | ( | struct osmo_fd * | ofd, |
int | fd, | ||
unsigned int | when, | ||
int(*)(struct osmo_fd *fd, unsigned int what) | cb, | ||
void * | data, | ||
unsigned int | priv_nr | ||
) |
Set up an osmo-fd.
Will not register it.
[in,out] | ofd | Osmo FD to be set-up |
[in] | fd | OS-level file descriptor number |
[in] | when | bit-mask of BSC_FD_{READ,WRITE,EXECEPT} |
[in] | cb | Call-back function to be called |
[in] | data | Private context pointer |
[in] | priv_nr | Private number |
References osmo_fd::cb, osmo_fd::data, osmo_fd::fd, osmo_fd::priv_nr, and osmo_fd::when.
void osmo_fd_unregister | ( | struct osmo_fd * | fd | ) |
Unregister a file descriptor from select loop abstraction.
[in] | fd | osmocom file descriptor to be unregistered |
References osmo_fd::fd, llist_del(), and unregistered_count.
Referenced by osmo_fd_close().
int osmo_select_main | ( | int | polling | ) |
select main loop integration
[in] | polling | should we pollonly (1) or block on select (0) |
References maxfd, osmo_fd_disp_fds(), osmo_fd_fill_fds(), osmo_timers_nearest(), osmo_timers_prepare(), and osmo_timers_update().
int osmo_timerfd_disable | ( | struct osmo_fd * | ofd | ) |
disable the osmocom-wrapped timerfd
References osmo_fd::fd.
int osmo_timerfd_schedule | ( | struct osmo_fd * | ofd, |
const struct timespec * | first, | ||
const struct timespec * | interval | ||
) |
schedule the osmcoom-wrapped timerfd to occur first at first, then periodically at interval
[in] | ofd | Osmocom wrapped timerfd |
[in] | first | Relative time at which the timer should first execute (NULL = interval) |
[in] | interval | Time interval at which subsequent timer shall fire |
References osmo_fd::fd.
int osmo_timerfd_setup | ( | struct osmo_fd * | ofd, |
int(*)(struct osmo_fd *, unsigned int) | cb, | ||
void * | data | ||
) |
setup osmocom-wrapped timerfd
[in,out] | ofd | Osmocom-wrapped timerfd on which to operate |
[in] | cb | Call-back function called when timerfd becomes readable |
[in] | data | Opaque data to be passed on to call-back |
We simply initialize the data structures here, but do not yet schedule the timer.
References BSC_FD_READ, osmo_fd::cb, osmo_fd::data, osmo_fd::fd, osmo_fd_register(), and osmo_fd::when.
|
static |
Referenced by osmo_fd_register(), and osmo_select_main().
|
static |
Referenced by osmo_fd_disp_fds(), and osmo_fd_unregister().