Use and require C11 alignof
The current implementation of ALIGNOF invokes undefined behavior, and C11 is over 12 years old already. Just use C11 alignof(). Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
This commit is contained in:
parent
1c900f7635
commit
06be1d845f
|
@ -281,6 +281,7 @@ def c_open(self):
|
||||||
_c('#include "config.h"')
|
_c('#include "config.h"')
|
||||||
_c('#endif')
|
_c('#endif')
|
||||||
_c('#include <stdlib.h>')
|
_c('#include <stdlib.h>')
|
||||||
|
_c('#include <stdalign.h>')
|
||||||
_c('#include <string.h>')
|
_c('#include <string.h>')
|
||||||
_c('#include <assert.h>')
|
_c('#include <assert.h>')
|
||||||
_c('#include <stddef.h> /* for offsetof() */')
|
_c('#include <stddef.h> /* for offsetof() */')
|
||||||
|
@ -288,7 +289,6 @@ def c_open(self):
|
||||||
_c('#include "%s.h"', _ns.header)
|
_c('#include "%s.h"', _ns.header)
|
||||||
|
|
||||||
_c('')
|
_c('')
|
||||||
_c('#define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)')
|
|
||||||
|
|
||||||
if _ns.is_ext:
|
if _ns.is_ext:
|
||||||
for (n, h) in self.direct_imports:
|
for (n, h) in self.direct_imports:
|
||||||
|
@ -1266,7 +1266,7 @@ def _c_serialize_helper_fields(context, self,
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
code_lines.append(
|
code_lines.append(
|
||||||
'%s xcb_align_to = ALIGNOF(%s);'
|
'%s xcb_align_to = alignof(%s);'
|
||||||
% (space,
|
% (space,
|
||||||
'char'
|
'char'
|
||||||
if field.c_field_type == 'void' or field.type.is_switch
|
if field.c_field_type == 'void' or field.type.is_switch
|
||||||
|
|
Loading…
Reference in New Issue