1pthread_once(3C) Standard C Library Functions pthread_once(3C)
2
3
4
6 pthread_once - initialize dynamic package
7
9 cc -mt [ flag... ] file... -lpthread [ library... ]
10
11 #include <pthread.h>
12 pthread_once_t once_control = PTHREAD_ONCE_INIT;
13
14 int pthread_once(pthread_once_t *once_control,
15 void (*init_routine)(void));
16
17
19 If any thread in a process with a once_control parameter makes a call
20 to pthread_once(), the first call will summon the init_routine(), but
21 subsequent calls will not. The once_control parameter determines
22 whether the associated initialization routine has been called. The
23 init_routine() is complete upon return of pthread_once().
24
25
26 pthread_once() is not a cancellation point; however, if the function
27 init_routine() is a cancellation point and is canceled, the effect on
28 once_control is the same as if pthread_once() had never been called.
29
30
31 The constant PTHREAD_ONCE_INIT is defined in the <pthread.h> header.
32
33
34 If once_control has automatic storage duration or is not initialized by
35 PTHREAD_ONCE_INIT, the behavior of pthread_once() is undefined.
36
38 Upon successful completion, pthread_once() returns 0. Otherwise, an
39 error number is returned to indicate the error.
40
42 EINVAL once_control or init_routine is NULL.
43
44
46 See attributes(5) for descriptions of the following attributes:
47
48
49
50
51 ┌─────────────────────────────┬─────────────────────────────┐
52 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
53 ├─────────────────────────────┼─────────────────────────────┤
54 │Interface Stability │Standard │
55 ├─────────────────────────────┼─────────────────────────────┤
56 │MT-Level │MT-Safe │
57 └─────────────────────────────┴─────────────────────────────┘
58
60 attributes(5), standards(5)
61
63 Solaris threads do not offer this functionality.
64
65
66
67SunOS 5.11 23 Mar 2005 pthread_once(3C)