Skip to content
Snippets Groups Projects
Commit 3f18f3e3 authored by Colin Watson's avatar Colin Watson
Browse files

Simplify 64-bit platform detection

It should be much more robust across all architectures now.
parent 1307100e
No related branches found
No related tags found
No related merge requests found
python-ppmd (0.5.0-4) UNRELEASED; urgency=medium
* Simplify 64-bit platform detection; it should be much more robust across
all architectures now.
-- Colin Watson <cjwatson@debian.org> Tue, 25 Mar 2025 10:03:37 +0000
python-ppmd (0.5.0-3) unstable; urgency=medium python-ppmd (0.5.0-3) unstable; urgency=medium
* Team upload. * Team upload.
......
From: Zixing Liu <liushuyu011@gmail.com> From: Colin Watson <cjwatson@debian.org>
Date: Mon, 24 Mar 2025 12:36:06 +0000 Date: Tue, 25 Mar 2025 09:57:01 +0000
Subject: Fix 64-bit platform detection Subject: Fix 64-bit platform detection
MIPS and PowerPC 64-bit platform detection is not adequate. The typedefs in `src/ffi_build.py` need to be in sync with whether
`PPMD_32BIT` is defined, so it's simpler to just control both using the
same condition.
Forwarded: not-needed
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-ppmd/+bug/2100831 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-ppmd/+bug/2100831
Last-Update: 2025-03-24 Last-Update: 2025-03-25
--- ---
src/ext/PpmdArch.h | 5 ++--- src/ext/PpmdArch.h | 18 ------------------
1 file changed, 2 insertions(+), 3 deletions(-) src/ffi_build.py | 6 +++++-
2 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/src/ext/PpmdArch.h b/src/ext/PpmdArch.h diff --git a/src/ext/PpmdArch.h b/src/ext/PpmdArch.h
index 678fc68..ae79c39 100644 index 678fc68..8e991ec 100644
--- a/src/ext/PpmdArch.h --- a/src/ext/PpmdArch.h
+++ b/src/ext/PpmdArch.h +++ b/src/ext/PpmdArch.h
@@ -83,9 +83,8 @@ struct ISzAlloc @@ -72,24 +72,6 @@ struct ISzAlloc
|| defined(__ARMEB__) \ #define ISzAlloc_Alloc(p, size) (p)->Alloc(size)
|| defined(__THUMBEL__) \ #define ISzAlloc_Free(p, a) (p)->Free(a)
|| defined(__THUMBEB__) \
-#if defined(_M_IX86) \
- || defined(__i386__) \
- || defined(_M_ARM) \
- || defined(_M_ARM_NT) \
- || defined(_M_ARMT) \
- || defined(__arm__) \
- || defined(__thumb__) \
- || defined(__ARMEL__) \
- || defined(__ARMEB__) \
- || defined(__THUMBEL__) \
- || defined(__THUMBEB__) \
- || defined(__mips__) \ - || defined(__mips__) \
- || defined(__ppc__) \ - || defined(__ppc__) \
- || defined(__powerpc__) \ - || defined(__powerpc__) \
+ || (defined(__mips__) && !defined(__mips64__)) \ - || defined(__sparc__)
+ || ((defined(__ppc__) || defined(__powerpc__)) && !defined(__powerpc64__)) \ - #define PPMD_32BIT
|| defined(__sparc__) -#endif
#define PPMD_32BIT -
#endif EXTERN_C_END
#endif //PPMD_CFFI_PPMDARCH_H
diff --git a/src/ffi_build.py b/src/ffi_build.py
index 35cd198..ad5fd48 100644
--- a/src/ffi_build.py
+++ b/src/ffi_build.py
@@ -221,6 +221,10 @@ int Ppmd8_DecodeSymbol(CPpmd8 *p);
''')
# ---------------------------------------------------------------------------
+define_macros = []
+if not is_64bit():
+ define_macros.append(('PPMD_32BIT', None))
+
ffibuilder.set_source('_ppmd', r'''
#include "PpmdPy.h"
@@ -315,7 +319,7 @@ int ppmd_decompress(CPpmd7 *p, CPpmd7z_RangeDec *rc, char *buf, int size) {
}
return size;
}
-''', sources=sources, include_dirs=[src_root])
+''', sources=sources, include_dirs=[src_root], define_macros=define_macros)
if __name__ == "__main__": # not when running with setuptools
ffibuilder.compile(verbose=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment