Path: blob/master/thirdparty/brotli/dec/static_init.c
14730 views
/* Copyright 2025 Google Inc. All Rights Reserved.12Distributed under MIT license.3See file LICENSE for detail or copy at https://opensource.org/licenses/MIT4*/56#include "static_init.h"78#include "../common/platform.h"9#include "../common/static_init.h"1011#if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE)12#include "../common/dictionary.h"13#include "prefix.h"14#endif1516#if defined(__cplusplus) || defined(c_plusplus)17extern "C" {18#endif1920#if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE)21static BROTLI_BOOL DoBrotliDecoderStaticInit(void) {22BROTLI_BOOL ok = BrotliDecoderInitCmdLut(kCmdLut);23if (!ok) return BROTLI_FALSE;24return BROTLI_TRUE;25}26#endif /* BROTLI_STATIC_INIT_NONE */2728#if (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_EARLY)29static BROTLI_BOOL kEarlyInitOk;30static __attribute__((constructor)) void BrotliDecoderStaticInitEarly(void) {31kEarlyInitOk = DoBrotliDecoderStaticInit();32}33#elif (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_LAZY)34static BROTLI_BOOL kLazyInitOk;35void BrotliDecoderLazyStaticInitInner(void) {36kLazyInitOk = DoBrotliDecoderStaticInit();37}38#endif /* BROTLI_STATIC_INIT_EARLY */3940BROTLI_BOOL BrotliDecoderEnsureStaticInit(void) {41#if (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_NONE)42return BROTLI_TRUE;43#elif (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_EARLY)44return kEarlyInitOk;45#else46return kLazyInitOk;47#endif48}4950#if defined(__cplusplus) || defined(c_plusplus)51} /* extern "C" */52#endif535455