summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/os_win/os_once.c
blob: 5f72bb366ad52372e908bbfa5dc82396f1863dd9 (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
31
32
33
34
35
36
37
38
39
40
41
42
/*-
 * Copyright (c) 2014-2019 MongoDB, Inc.
 * Copyright (c) 2008-2014 WiredTiger, Inc.
 *	All rights reserved.
 *
 * See the file LICENSE for redistribution information.
 */

#include "wt_internal.h"

/*
 * __wt_init_once_callback --
 *	Global initialization, run once.
 */
BOOL CALLBACK _wt_init_once_callback(
    _Inout_      PINIT_ONCE InitOnce,
    _Inout_opt_  PVOID Parameter,
    _Out_opt_    PVOID *Context
    )
{
	void(*init_routine)(void) = Parameter;
	WT_UNUSED(InitOnce);
	WT_UNUSED(Context);

	init_routine();

	return (TRUE);
}

/*
 * __wt_once --
 *	One-time initialization per process.
 */
int
__wt_once(void (*init_routine)(void))
{
	INIT_ONCE once_control = INIT_ONCE_STATIC_INIT;
	PVOID lpContext = NULL;

	return !InitOnceExecuteOnce(&once_control, &_wt_init_once_callback,
	    init_routine, lpContext);
}