From: Colin Watson <cjwatson@debian.org>
Date: Tue, 25 Mar 2025 09:57:01 +0000
Subject: Fix 64-bit platform detection

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.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-ppmd/+bug/2100831
Last-Update: 2025-03-25
---
 src/ext/PpmdArch.h | 18 ------------------
 src/ffi_build.py   |  6 +++++-
 2 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/src/ext/PpmdArch.h b/src/ext/PpmdArch.h
index 678fc68..8e991ec 100644
--- a/src/ext/PpmdArch.h
+++ b/src/ext/PpmdArch.h
@@ -72,24 +72,6 @@ struct ISzAlloc
 #define ISzAlloc_Alloc(p, size) (p)->Alloc(size)
 #define ISzAlloc_Free(p, a) (p)->Free(a)
 
-#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(__ppc__) \
-  || defined(__powerpc__) \
-  || defined(__sparc__)
-  #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)
