aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/check/crc64_small.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2022-11-14 16:00:52 +0200
committerLasse Collin <lasse.collin@tukaani.org>2022-11-14 16:00:52 +0200
commiteb0f1450ad9f23dac03050d9c8375980240aee21 (patch)
tree2ccb523dc0277999d3629bad18e0c2e819d33b64 /src/liblzma/check/crc64_small.c
parentTranslations: Update the Romanian translation. (diff)
downloadxz-eb0f1450ad9f23dac03050d9c8375980240aee21.tar.xz
liblzma: Use __attribute__((__constructor__)) if available.
This uses it for CRC table initializations when using --disable-small. It avoids mythread_once() overhead. It also means that then --disable-small --disable-threads is thread-safe if this attribute is supported.
Diffstat (limited to 'src/liblzma/check/crc64_small.c')
-rw-r--r--src/liblzma/check/crc64_small.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/liblzma/check/crc64_small.c b/src/liblzma/check/crc64_small.c
index 55d72316..420f7cfb 100644
--- a/src/liblzma/check/crc64_small.c
+++ b/src/liblzma/check/crc64_small.c
@@ -16,6 +16,9 @@
static uint64_t crc64_table[256];
+#ifdef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR
+__attribute__((__constructor__))
+#endif
static void
crc64_init(void)
{
@@ -40,7 +43,9 @@ crc64_init(void)
extern LZMA_API(uint64_t)
lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
{
+#ifndef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR
mythread_once(crc64_init);
+#endif
crc = ~crc;