| 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 |
/* |
| 8 |
Central point for static initialization. |
| 9 |
|
| 10 |
In case of "lazy" mode `BrotliXxxLazyStaticInit` is not provided by the |
| 11 |
library. Embedder is responsible for providing it. This function should call |
| 12 |
`BrotliXxxLazyStaticInitInner` on the first invocation. This function should |
| 13 |
not return until execution of `BrotliXxxLazyStaticInitInner` is finished. |
| 14 |
In C or before C++11 it is possible to call `BrotliXxxLazyStaticInitInner` |
| 15 |
on start-up path and then `BrotliEncoderLazyStaticInit` is could be no-op; |
| 16 |
another option is to use available thread execution controls to meet the |
| 17 |
requirements. For possible C++11 implementation see static_init_lazy.cc. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef THIRD_PARTY_BROTLI_COMMON_STATIC_INIT_H_ |
| 21 |
#define THIRD_PARTY_BROTLI_COMMON_STATIC_INIT_H_ |
| 22 |
|
| 23 |
#if defined(__cplusplus) || defined(c_plusplus) |
| 24 |
extern "C" { |
| 25 |
#endif |
| 26 |
|
| 27 |
/* Static data is "initialized" in compile time. */ |
| 28 |
#define BROTLI_STATIC_INIT_NONE 0 |
| 29 |
/* Static data is initialized before "main". */ |
| 30 |
#define BROTLI_STATIC_INIT_EARLY 1 |
| 31 |
/* Static data is initialized when first encoder is created. */ |
| 32 |
#define BROTLI_STATIC_INIT_LAZY 2 |
| 33 |
|
| 34 |
#define BROTLI_STATIC_INIT_DEFAULT BROTLI_STATIC_INIT_NONE |
| 35 |
|
| 36 |
#if !defined(BROTLI_STATIC_INIT) |
| 37 |
#define BROTLI_STATIC_INIT BROTLI_STATIC_INIT_DEFAULT |
| 38 |
#endif |
| 39 |
|
| 40 |
#if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE) && \ |
| 41 |
(BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_EARLY) && \ |
| 42 |
(BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_LAZY) |
| 43 |
#error Invalid value for BROTLI_STATIC_INIT |
| 44 |
#endif |
| 45 |
|
| 46 |
#if (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_EARLY) |
| 47 |
#if defined(BROTLI_EXTERNAL_DICTIONARY_DATA) |
| 48 |
#error BROTLI_STATIC_INIT_EARLY will fail with BROTLI_EXTERNAL_DICTIONARY_DATA |
| 49 |
#endif |
| 50 |
#endif /* BROTLI_STATIC_INIT */ |
| 51 |
|
| 52 |
#if defined(__cplusplus) || defined(c_plusplus) |
| 53 |
} /* extern "C" */ |
| 54 |
#endif |
| 55 |
|
| 56 |
#endif // THIRD_PARTY_BROTLI_COMMON_STATIC_INIT_H_ |