blob: e16a3cfeaf0d5cd732904a9ea7e1e45eff21d5cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/*
* Copyright 2022 Yonggang Luo
* SPDX-License-Identifier: MIT
*/
#include "u_call_once.h"
struct util_call_once_context_t
{
const void *data;
util_call_once_data_func func;
};
static thread_local struct util_call_once_context_t call_once_context;
static void
util_call_once_data_slow_once(void)
{
struct util_call_once_context_t *once_context = &call_once_context;
once_context->func(once_context->data);
}
void
util_call_once_data_slow(once_flag *once, util_call_once_data_func func, const void *data)
{
struct util_call_once_context_t *once_context = &call_once_context;
once_context->data = data;
once_context->func = func;
call_once(once, util_call_once_data_slow_once);
}
|