Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/brotli/dec/static_init.c
14730 views
1
/* Copyright 2025 Google Inc. All Rights Reserved.
2
3
Distributed under MIT license.
4
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
*/
6
7
#include "static_init.h"
8
9
#include "../common/platform.h"
10
#include "../common/static_init.h"
11
12
#if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE)
13
#include "../common/dictionary.h"
14
#include "prefix.h"
15
#endif
16
17
#if defined(__cplusplus) || defined(c_plusplus)
18
extern "C" {
19
#endif
20
21
#if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE)
22
static BROTLI_BOOL DoBrotliDecoderStaticInit(void) {
23
BROTLI_BOOL ok = BrotliDecoderInitCmdLut(kCmdLut);
24
if (!ok) return BROTLI_FALSE;
25
return BROTLI_TRUE;
26
}
27
#endif /* BROTLI_STATIC_INIT_NONE */
28
29
#if (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_EARLY)
30
static BROTLI_BOOL kEarlyInitOk;
31
static __attribute__((constructor)) void BrotliDecoderStaticInitEarly(void) {
32
kEarlyInitOk = DoBrotliDecoderStaticInit();
33
}
34
#elif (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_LAZY)
35
static BROTLI_BOOL kLazyInitOk;
36
void BrotliDecoderLazyStaticInitInner(void) {
37
kLazyInitOk = DoBrotliDecoderStaticInit();
38
}
39
#endif /* BROTLI_STATIC_INIT_EARLY */
40
41
BROTLI_BOOL BrotliDecoderEnsureStaticInit(void) {
42
#if (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_NONE)
43
return BROTLI_TRUE;
44
#elif (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_EARLY)
45
return kEarlyInitOk;
46
#else
47
return kLazyInitOk;
48
#endif
49
}
50
51
#if defined(__cplusplus) || defined(c_plusplus)
52
} /* extern "C" */
53
#endif
54
55