KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
once.h File Reference

Dynamic package initialization. More...

#include <sys/cdefs.h>

Go to the source code of this file.

Macros

#define KTHREAD_ONCE_INIT   0
 Initializer for a kthread_once_t object.
 

Typedefs

typedef volatile int kthread_once_t
 Object type backing kthread_once.
 

Functions

int kthread_once (kthread_once_t *once_control, void(*init_routine)(void))
 Run a function once.
 

Detailed Description

Dynamic package initialization.

This file provides definitions for an object that functions the same way as the pthread_once_t function does from the POSIX specification. This object type and functionality is generally used to make sure that a given initialization function is run once, and only once, no matter how many threads attempt to call it.

Author
Lawrence Sebald

Macro Definition Documentation

◆ KTHREAD_ONCE_INIT

#define KTHREAD_ONCE_INIT   0

Initializer for a kthread_once_t object.

Typedef Documentation

◆ kthread_once_t

typedef volatile int kthread_once_t

Object type backing kthread_once.

This object type should always be initialized with the KTHREAD_ONCE_INIT macro.

Function Documentation

◆ kthread_once()

int kthread_once ( kthread_once_t * once_control,
void(* init_routine )(void) )

Run a function once.

This function, when used with a kthread_once_t object (that should be shared amongst all threads) will run the init_routine once, and set the once_control to make sure that the function will not be run again (as long as all threads attempt to call the init_routine through this function.

Parameters
once_controlThe kthread_once_t object to run against.
init_routineThe function to call.
Return values
-1On failure, and sets errno to one of the following: EPERM if called inside an interrupt or EINVAL if *once_control is not valid or was not initialized with KTHREAD_ONCE_INIT.
0On success.