aports/community/libmarisa/0001-Fix-detection-of-MARISA_WORD_SIZE.patch
Natanael Copa cdfcf37ceb community/libmarisa: fix wordsize detection
Fixes detection of word size on riscv64 and loongarch64.

ref: https://github.com/s-yata/marisa-trie/issues/57
2024-04-24 11:25:58 +02:00

52 lines
1.6 KiB
Diff

From 1e167755c04c4816b7c19a985301df81a5b511ca Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 24 Apr 2024 11:17:09 +0200
Subject: [PATCH] Fix detection of MARISA_WORD_SIZE
Detect the MARISA_WORD_SIZE independent of architecture.
Fixes: https://github.com/s-yata/marisa-trie/issues/40
Fixes: https://github.com/s-yata/marisa-trie/issues/57
Fixes: https://github.com/s-yata/marisa-trie/pull/44
Fixes: https://github.com/s-yata/marisa-trie/pull/46
Fixes: https://github.com/s-yata/marisa-trie/pull/56
---
include/marisa/base.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/marisa/base.h b/include/marisa/base.h
index ffcdc5b..f8c0e1c 100644
--- a/include/marisa/base.h
+++ b/include/marisa/base.h
@@ -1,6 +1,7 @@
#ifndef MARISA_BASE_H_
#define MARISA_BASE_H_
+#include <limits.h>
// Old Visual C++ does not provide stdint.h.
#ifndef _MSC_VER
#include <stdint.h>
@@ -28,14 +29,13 @@ typedef uint32_t marisa_uint32;
typedef uint64_t marisa_uint64;
#endif // _MSC_VER
-#if defined(_WIN64) || defined(__amd64__) || defined(__x86_64__) || \
- defined(__ia64__) || defined(__ppc64__) || defined(__powerpc64__) || \
- defined(__sparc64__) || defined(__mips64__) || defined(__aarch64__) || \
- defined(__s390x__)
+#if (ULONG_MAX == 0xffffffffffffffff)
#define MARISA_WORD_SIZE 64
-#else // defined(_WIN64), etc.
+#elif (ULONG_MAX == 0xffffffff)
#define MARISA_WORD_SIZE 32
-#endif // defined(_WIN64), etc.
+#else
+ #error Failed to detect MARISA_WORD_SIZE
+#endif
//#define MARISA_WORD_SIZE (sizeof(void *) * 8)
--
2.44.0