#### 36.1.3 Call Once ¶

In order to guarantee single access to a function, the GNU C Library implements a call once function to ensure a function is only called once in the presence of multiple, potentially calling threads.

Data Type: once_flag ¶

  A complete object type capable of holding a flag used by `call_once`.

  As of C23, `once_flag` is also defined in `stdlib.h`, but only for C, not for C++.

Macro: ONCE_FLAG_INIT ¶

  This value is used to initialize an object of type `once_flag`.

  As of C23, `ONCE_FLAG_INIT` is also defined in `stdlib.h`, but only for C, not for C++.

Function: `void` call_once `(once_flag *flag, void (*func) (void))` ¶

  Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

  `call_once` calls function func exactly once, even if invoked from several threads. The completion of the function func synchronizes-with all previous or subsequent calls to `call_once` with the same `flag` variable.

These definitions are from C11, where they appear in `threads.h`. In C23, they appear in `stdlib.h` as well as in `threads.h`.