def _c_serialize_helper_insert_padding(context, code_lines, space, postpone):
code_lines.append('%s /* insert padding */' % space)
- code_lines.append('%s xcb_pad = -xcb_block_len & (xcb_align_to - 1);' % space)
+ code_lines.append(
+ '%s xcb_pad = -( xcb_block_len + xcb_padding_offset ) & (xcb_align_to - 1);'
+ % space)
# code_lines.append('%s printf("automatically inserting padding: %%%%d\\n", xcb_pad);' % space)
code_lines.append('%s xcb_buffer_len += xcb_block_len + xcb_pad;' % space)
code_lines.append('%s }' % space)
code_lines.append('%s xcb_block_len = 0;' % space)
+ code_lines.append('%s xcb_padding_offset = 0;' % space)
# keep tracking of xcb_parts entries for serialize
return 1
code_lines.append('%s xcb_tmp += xcb_block_len;' % space)
code_lines.append('%s xcb_buffer_len += xcb_block_len;' % space)
code_lines.append('%s xcb_block_len = 0;' % space)
+ code_lines.append('%s xcb_padding_offset = 0;' % space)
count += _c_serialize_helper_fields(context, self,
code_lines, temp_vars,
_c(' char *xcb_out = *_buffer;')
_c(' unsigned int xcb_buffer_len = 0;')
_c(' unsigned int xcb_align_to = 0;')
+ if self.is_switch:
+ _c(' unsigned int xcb_padding_offset = ((size_t)xcb_out) & 7;')
+ else:
+ _c(' unsigned int xcb_padding_offset = 0;')
prefix = [('_aux', '->', self)]
aux_ptr = 'xcb_out'
_c(' unsigned int xcb_block_len = 0;')
_c(' unsigned int xcb_pad = 0;')
_c(' unsigned int xcb_align_to = 0;')
+ if self.is_switch:
+ _c(' unsigned int xcb_padding_offset = ((size_t)_buffer) & 7;')
+ else:
+ _c(' unsigned int xcb_padding_offset = 0;')
elif 'sizeof' == context:
param_names = [p[2] for p in params]
else:
_c(' char *xcb_tmp = (char *)_buffer;')
prefix = [('_aux', '->', self)]
+ _c(' unsigned int xcb_padding_offset = 0;')
count = _c_serialize_helper(context, self, code_lines, temp_vars, prefix=prefix)
# update variable size fields (only important for context=='serialize'