ctypes: cauclate bitfield size in a single arithmetic expression
Signed-off-by: Filipe Laíns <lains@archlinux.org>
This commit is contained in:
parent
a0de97dd90
commit
06151bcab5
|
@ -74,9 +74,7 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
|
||||||
|
|
||||||
#ifndef MS_WIN32
|
#ifndef MS_WIN32
|
||||||
if (pack && bitsize) { /* packed bitfield */
|
if (pack && bitsize) { /* packed bitfield */
|
||||||
size = 1;
|
size = (bitsize - 1) / 8 + 1;
|
||||||
while(size * 8 < bitsize)
|
|
||||||
size += 1;
|
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
size = dict->size;
|
size = dict->size;
|
||||||
|
@ -182,8 +180,7 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
|
||||||
|
|
||||||
case EXPAND_BITFIELD:
|
case EXPAND_BITFIELD:
|
||||||
if (pack)
|
if (pack)
|
||||||
while(size * 8 < (*pbitofs + bitsize))
|
size = (*pbitofs + bitsize - 1) / 8 + 1;
|
||||||
size += 1;
|
|
||||||
|
|
||||||
*poffset += size - *pfield_size/8;
|
*poffset += size - *pfield_size/8;
|
||||||
*psize += size - *pfield_size/8;
|
*psize += size - *pfield_size/8;
|
||||||
|
|
Loading…
Reference in New Issue