ldo / dbussy

Python binding for D-Bus using asyncio
91 stars 22 forks source link

ctypes.c_ulong size on arm #16

Closed toshem closed 3 years ago

toshem commented 5 years ago

The size of c_long on arm differs from x86_64.

ctypes.sizeof(ctypes.c_long)  # returns 4 on arm
ctypes.sizeof(ctypes.c_long)  # returns 8 on x86_64
ctypes.sizeof(ctypes.c_longlong)  # returns 8 on arm and x86_64

Using c_long results with wrong primitive type conversion for DBus 'X' and 'T'. It would be safe to use c_longlong (c_ulonglong) instead as they are 8 bytes on both architectures.

--- a/dbussy.py 2019-03-13 13:32:14.099119209 +0100
+++ b/dbussy.py 2019-03-13 13:27:13.787765219 +0100
@@ -76,8 +76,8 @@
             TYPE_UINT16 : ct.c_ushort,
             TYPE_INT32 : ct.c_int,
             TYPE_UINT32 : ct.c_uint,
-            TYPE_INT64 : ct.c_long,
-            TYPE_UINT64 : ct.c_ulong,
+            TYPE_INT64 : ct.c_longlong,
+            TYPE_UINT64 : ct.c_ulonglong,
             TYPE_DOUBLE : ct.c_double,
             TYPE_STRING : ct.c_char_p,
             TYPE_OBJECT_PATH : ct.c_char_p,
ldo commented 5 years ago

OK, I have done a patch. I think this issue arises on all 32-bit architectures. See how it works now.

ldo commented 3 years ago

No further trouble?