[Xcb] XSync extension broken in many ways..

Rob Taylor robtaylor at floopily.org
Mon Aug 27 09:58:16 PDT 2007


Hi, I've been attempting to port some XSync extension code to xcb
(libidletime in OHM [1]), and I've found a few pretty large issues.

First is easy to fix- Initialize was incorrectly defined, patch attached.

The second issue is a bit more systemic. The struct
xcb_sync_systemcounter_t is generated correctly, and on the wire the
name starts at a 14 byte offset. However thanks to compiler struct
padding, sizeof (xcb_sync_systemcounter_t) is 16.
This results in iteration of xcb_sync_systemcounter_iterator_t going
wrong (by two bytes every time), and xcb_sync_systemcounter_name
returning a pointer thats two bytes too far on.

In the old Xlib code, they got around this issue by using

#if ((defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus))
&& !defined(UNIXCPP)) || defined(ANSICPP)
#define _SIZEOF(x) sz_##x
#define SIZEOF(x) _SIZEOF(x)
#else
#define SIZEOF(x) sz_/**/x
#endif /* if ANSI C compiler else not */

defining sz_StructName for all structures with the actual wire size, and
using the SIZEOF macro rather than relying on the compilers idea of sizeof.

Do you guys think this would be the right way to go? Another option
might be to play around with gccs __attribute__, but that'd be pretty
problematic for portability.

I've attached a testcase for looking at these issues. Also attached is a
couple of helper functions for helping deal with xcb_sync_int64_t, I
guess this should probably go in xcb/util somewhere.

Thanks,
Rob Taylor

[1] http://ohm.freedesktop.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fix-XSync-Initialize-call.patch
Type: text/x-patch
Size: 0 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/xcb/attachments/20070827/f32a8024/attachment.bin 


More information about the Xcb mailing list