[issue29753] Ctypes Packing Bitfields Incorrectly - Linux

2018-04-01 Thread Marc Le Roy

Marc Le Roy <mleroy...@gmail.com> added the comment:

No solution found to solve this issue ?
The anomaly is not a cross platform inconsistency, it is an inconsistency 
between the behaviours of GCC and ctypes, both under Linux or Cygwin, when 
defining packed structures :

[Marc@I7-860 ~/dev/python/ctypes-bitfields-bug] make test
./bitfield_test1
sizeof(BF32) = 12 ; Memory dump of BF32 = 0x
sizeof(BF64) = 12 ; Memory dump of BF64 = 0x
python3 bitfield_test1.py
sizeof(BF32) = 16 ; Memory dump of BF32 = 0xff00ff00ff00ff00
sizeof(BF64) = 16 ; Memory dump of BF64 = 0x

--
Added file: https://bugs.python.org/file47511/ctypes-bitfields-bug.tar.gz

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue29753>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29753] Ctypes Packing Bitfields Incorrectly - Linux

2017-11-16 Thread Marc Le Roy

Change by Marc Le Roy <mleroy...@gmail.com>:


--
nosy: +mleroy003

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue29753>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31987] Ctypes Packing Bitfields Incorrectly - GCC both Linux and Cygwin

2017-11-08 Thread Marc Le Roy

New submission from Marc Le Roy <mleroy...@gmail.com>:

The structure :
typedef struct __attribute__ ((packed)) {
   unsigned int   F0:24;
   unsigned int   F3:24;
   unsigned int   F6:24;
   unsigned int   F9:24;
} StructF_T;
is mapped as expected by GCC under both Linux and Cygwin.
As expected, the memory layout seen by the C program is :
0x11223344

Using this definition :
class StructF(ctypes.BigEndianStructure):
_pack_ = 1
_fields_ = [
('F0',  ctypes.c_uint, 24),
('F3',  ctypes.c_uint, 24),
('F6',  ctypes.c_uint, 24),
('F9',  ctypes.c_uint, 24),
]
The memory layout seen from Python is not consistent :
0x1100220033004400

It seems that the pack option is ignored by ctypes in such a case.
I found the same problem using both ctypes.BigEndianStructure and 
ctypes.LittleEndianStructure

--
components: ctypes
messages: 305914
nosy: mleroy003
priority: normal
severity: normal
status: open
title: Ctypes Packing Bitfields Incorrectly - GCC both Linux and Cygwin
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31987>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com