free-sw/xcb/libxcb
5 years agogenerator: support parametrized structs ParametrizedStruct-V7
Christian Linhart [Mon, 3 Nov 2014 08:57:59 +0000 (09:57 +0100)]
generator: support parametrized structs

Parametrized structs contain paramref expressions which
refer to the value of a field defined in the context
where the struct is used.

Implementing the parametrized structs turned out
to be somewhat easier than previously thought
because the generator already had some support for type-parametrization
because this is needed when case or bitcase refers to fields outside
of the switch.

So I decided to go with the flow and to implement the solution
which best fits the current implementation.

I did the following:
* I provided a way to specify fieldref with an explicitely given type:
  This resulted in <paramref type="CARD8>fieldname</paramref>
  A paramref is just a fieldref with an explicit type.
  The type is necessary because there is no local field of that
  name where the type can be derived from.

* then I tested it and made several changes in the generator
  such that it really works.

Basically the generated code is as follows:
* The parameter appears on the parameter list of the
  sizeof-function of the parametrized struct.
  When that function gets called, an appropriate argument is supplied.

* The parameter also appears as an additional member of the iterator-struct
  for the iterator of lists of that parametrized struct.
  This way, the next-function can get the value of that parameter from the iterator.
  When the iterator is created, this iterator-member is set accordingly.

* When the paramref appears in the length-expression of a list, then
  the parameter appears on the parameterlist of the "length" and "end" functions.
  When these functions get called, an appropriate argument is supplied.

Some comments:
* I did not implement inline structs.
  This would probably have been more complicated, and at least some additional effort.
  But that can be implemented later if needed.
  (Inline structs could probably use some code from switch-case/bitcase which is already kind of
  an inlined struct but one has to be careful not to break the functionality
  of switch-case/bitcase. Support for inline structs inside lists must probably
  be implemented from scratch...)

* The paramref expression refers to a field of the same name in the struct/request/...
  where it is used.
  So it is not possible to pass the value of arbitrary fields or even expressions
  to the parametrized struct.
  This would have been possible with the previously discussed <typearg>.
  That can be added later, if needed.
  ( Wont be too complicated )

* So this is pretty much like the proposal from Ran Benita.

changes for V2 of this patch, according to suggestions from Ran Benita:
* replace map with list comprehension
  because map returns an iterator instead of a list from Python 3 on,
  so it cannot be added to a list anymore.

* removed "self" parameter of function additional_params_to_str
  and accessed the variable additional_params from the outer
  function directly.

changes for V2 of this patch:
* adapt to revision 2 of patchset ListInputDevices
* style fixes for similar things that Ran Benita has found in my previous patches

Message-ID: <54574397.4060000@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] parametrized structs implemented
Patch-Set: ParametrizedStruct
Patch-Number: libxcb 1/1
Patch-Version: V3
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
5 years agogenerator: support listelement-ref PopcountList-V7
Christian Linhart [Mon, 3 Nov 2014 08:58:08 +0000 (09:58 +0100)]
generator: support listelement-ref

Support for listelement-ref needs the following three changes
(in the order as they appear in the patch):

* making the current list-element accessible with the variable
  xcb_listelement which is a pointer to the list-element

* supporting lists of simple-type for sumof with a nested expression

* using the variable for resolving a listelement-ref expression

Changes for V2 of this patch:
- adapt to removal of patch "libxcb 2/6" from patchset "ListInputDevices".

Changes for V3 of this patch:
- adapt to V2 of patch "libxcb 5/6" from patchset "ListInputDevices"

Changes for V4 of this patch:
- adapt to revision 2 of the patchset "ListInputDevices"

Message-ID: <545743A0.50907@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] support popcount of a list and associated xml changes
Patch-Set: PopcountList
Patch-Number: libxcb 4/4
Patch-Version: V4
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
5 years agogenerator: _c_accessor_get_length: remove buggy special case
Christian Linhart [Thu, 4 Sep 2014 15:50:50 +0000 (17:50 +0200)]
generator: _c_accessor_get_length: remove buggy special case

The function _c_accessor_get_length had a special case handling
for intermixed var and fixed size fields.

However:
* The implementation of that special case was buggy:
  It tried to call a python-dict as a function which causes
  Python to abort the program with a stacktrace and error message.
  So this code was never used.

* The case it tried to handle is handeled elsewhere in the
  meantime: in _c_helper_absolute_name by previous patches
  made by me.

Message-ID: <1409845851-38950-3-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: [Xcb] support popcount of a list and associated xml changes
Patch-Set: PopcountList
Patch-Number: libxcb 3/4
Patch-Version: V1
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
5 years agogenerator: generate accessors for events, too
Christian Linhart [Thu, 4 Sep 2014 15:50:49 +0000 (17:50 +0200)]
generator: generate accessors for events, too

Accessors are generally needed for var-sized fields
and fields after var-sized fields.

Generic events can have ver-sized fields.
Therefore they need accessors.

Message-ID: <1409845851-38950-2-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: [Xcb] support popcount of a list and associated xml changes
Patch-Set: PopcountList
Patch-Number: libxcb 2/4
Patch-Version: V1
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
5 years agogenerator: no type-setup for eventcopies anymore
Christian Linhart [Thu, 4 Sep 2014 15:50:48 +0000 (17:50 +0200)]
generator: no type-setup for eventcopies anymore

_c_type_setup is not called for eventcopies anymore:
Reasons:
* the type-setup of an eventcopy would overwrite members of the original
  event object such as c_type, ...
* it is needed for the next patch, i.e., generating accessors:
  type_setup would create sizeof-etc funtions which called
  undefined accessor functions.

Sizeof-functions are generated for compatibility:
Reason:
* Type-setup of eventcopies has previously generated
  sizeof-functions for eventcopies.
  So, we still need to generate these functions.
  These new sizeof-functions simply call the sizeof-function
  of the defining event of the eventcopy.

Message-ID: <1409845851-38950-1-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: [Xcb] support popcount of a list and associated xml changes
Patch-Set: PopcountList
Patch-Number: libxcb 1/4
Patch-Version: V1
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
5 years ago_c_helper_fieldaccess_expr: remove handling for empty sep ListInputDevices-V7
Christian Linhart [Sun, 2 Nov 2014 12:46:58 +0000 (13:46 +0100)]
_c_helper_fieldaccess_expr: remove handling for empty sep

The loop-variable "sep" is never empty in function
"_c_helper_fieldaccess_expr", after a fix elsewhere.
Therefore I removed the handling of the case of "sep" being empty.

Thanks to Ran Benita for the hint that this can be removed.

Signed-off-by: Christian Linhart <chris@demorecorder.com>
Reviewed-by: Ran Benita <ran234@gmail.com>
Message-ID: <545627C2.3050608@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] [PATCHSET] ListInputDevices revision 2
Patch-Set: ListInputDevices
Patch-Number: libxcb 9/9
Patch-Version: V1

5 years agofunction _c_helper_fieldaccess_expr: improve description
Christian Linhart [Sun, 2 Nov 2014 12:46:50 +0000 (13:46 +0100)]
function _c_helper_fieldaccess_expr: improve description

Signed-off-by: Christian Linhart <chris@demorecorder.com>
Reviewed-by: Ran Benita <ran234@gmail.com>
Message-ID: <545627BA.1000909@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] [PATCHSET] ListInputDevices revision 2
Patch-Set: ListInputDevices
Patch-Number: libxcb 8/9
Patch-Version: V1

5 years agorename _c_helper_absolute_name to _c_helper_fieldaccess_expr
Christian Linhart [Sun, 2 Nov 2014 12:46:38 +0000 (13:46 +0100)]
rename _c_helper_absolute_name to _c_helper_fieldaccess_expr

The function _c_helper_absolute_name was named in
a misleading way.
It computes a C-expression for accessing a field of an xcb-type.

Therefore the name _c_helper_fieldaccess_expr is more appropriate.

Note: Patch 6 of this series has been removed during the review process.

Signed-off-by: Christian Linhart <chris@demorecorder.com>
Reviewed-by: Ran Benita <ran234@gmail.com>
Message-ID: <545627AE.2040200@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] [PATCHSET] ListInputDevices revision 2
Patch-Set: ListInputDevices
Patch-Number: libxcb 7/9
Patch-Version: V1

5 years agogenerator: sumof with nested expression
Christian Linhart [Sun, 2 Nov 2014 12:46:16 +0000 (13:46 +0100)]
generator: sumof with nested expression

Support sumof with a nested expression.
The nested expression is computed for every list-element
and the result of the computation is added to the sum.

This way, sumof can be applied to a list of structs,
and, e.g., compute the sum of a specific field of that struct.

example:
<struct name="SumofTest_Element">
   <field type="CARD16" name="foo" />
   <field type="CARD16" name="bar" />
</struct>

<struct name="SumofTest_FieldAccess">
   <field type="CARD32" name="len" />
   <list type="SumofTest_Element" name="mylist1">
   <fieldref>len</fieldref>
   </list>
   <list type="CARD16" name="mylist2">
<sumof ref="mylist1">
<fieldref>bar</fieldref>
</sumof>
   </list>
</struct>

generated tmpvar:
    int xcb_pre_tmp_1; /* sumof length */
    int xcb_pre_tmp_2; /* sumof loop counter */
    int64_t xcb_pre_tmp_3; /* sumof sum */
    const xcb_input_sumof_test_element_t* xcb_pre_tmp_4; /* sumof list ptr */

generated code:
    /* mylist2 */
    /* sumof start */
    xcb_pre_tmp_1 = _aux->len;
    xcb_pre_tmp_3 = 0;
    xcb_pre_tmp_4 = xcb_input_sumof_test_field_access_mylist_1(_aux);
    for ( xcb_pre_tmp_2 = 0; xcb_pre_tmp_2 < xcb_pre_tmp_1; xcb_pre_tmp_2++) {
        xcb_pre_tmp_3 += xcb_pre_tmp_4->bar;
        xcb_pre_tmp_4++;
    }
    /* sumof end. Result is in xcb_pre_tmp_3 */
    xcb_block_len += xcb_pre_tmp_3 * sizeof(uint16_t);

changes for V2 of this patch:
* explicitely set the member access operator in the prefix-tuple
  passed to function _c_helper_field_mapping.
  This enables us to simplify function "_c_helper_absolute_name"
  (which will be renamed "_c_helper_fieldaccess_expr" soon)

V3: Changed style and formatting according to suggestions from Ran Benita

Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
Reviewed-by: Ran Benita <ran234@gmail.com>
Message-ID: <54562798.8040500@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] [PATCHSET] ListInputDevices revision 2
Patch-Set: ListInputDevices
Patch-Number: libxcb 5/9
Patch-Version: V3

5 years agogenerator: sumof: support any type, generate explicit code
Christian Linhart [Sun, 2 Nov 2014 12:45:40 +0000 (13:45 +0100)]
generator: sumof: support any type, generate explicit code

A sumof-expression now generates explicit code ( for-loop etc )
instead of calling xcb_sumof.

This way, it supports any type which can be added.
Previously, only uint_8 was supported.

Here's an example and the generated code:

xml:
<struct name="SumofTest">
   <field type="CARD32" name="len" />
   <list type="CARD16" name="mylist1">
   <fieldref>len</fieldref>
   </list>
   <list type="CARD8" name="mylist2">
   <sumof ref="mylist1"/>
   </list>
</struct>

declaration of tempvars at the start of enclosing function:
    int xcb_pre_tmp_1; /* sumof length */
    int xcb_pre_tmp_2; /* sumof loop counter */
    int64_t xcb_pre_tmp_3; /* sumof sum */
    const uint16_t* xcb_pre_tmp_4; /* sumof list ptr */

code:
    /* mylist2 */
    /* sumof start */
    xcb_pre_tmp_1 = _aux->len;
    xcb_pre_tmp_3 = 0;
    xcb_pre_tmp_4 = xcb_input_sumof_test_mylist_1(_aux);
    for ( xcb_pre_tmp_2 = 0; xcb_pre_tmp_2 < xcb_pre_tmp_1; xcb_pre_tmp_2++) {
        xcb_pre_tmp_3 += *xcb_pre_tmp_4;
        xcb_pre_tmp_4++;
    }
    /* sumof end. Result is in xcb_pre_tmp_3 */
    xcb_block_len += xcb_pre_tmp_3 * sizeof(uint8_t);

This patch is also a preparation for sumof which can access
fields of lists of struct, etc.

V2: Changed style and formatting according to suggestions from Ran Benita

Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
Reviewed-by: Ran Benita <ran234@gmail.com>
Message-ID: <54562774.8030306@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] [PATCHSET] ListInputDevices revision 2
Patch-Set: ListInputDevices
Patch-Number: libxcb 4/9
Patch-Version: V2

5 years agogenerator: expressions can generate pre-code
Christian Linhart [Sun, 2 Nov 2014 12:45:29 +0000 (13:45 +0100)]
generator: expressions can generate pre-code

This patch provides a mechanism for generating
preparatory code for expressions.

This is e.g. necessary when an expression needs computations
which cannot be done in a C-Expression, like for-loops.

This will be used for sumof expressions but may be useful
elsewhere.

Note: Patch 2 of this series has been removed during the review process.

V2: adapt to changes in previous patches

V3: some style and formatting changes according to suggestions from Ran Benita.

Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
Reviewed-by: Ran Benita <ran234@gmail.com>
Message-ID: <54562769.3090405@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] [PATCHSET] ListInputDevices revision 2
Patch-Set: ListInputDevices
Patch-Number: libxcb 3/9
Patch-Version: V3

5 years agogenerator: fix absname for fields with only accessor function
Christian Linhart [Sun, 2 Nov 2014 12:45:12 +0000 (13:45 +0100)]
generator: fix absname for fields with only accessor function

Fix _c_helper_absolute_name for fields which cannot be accessed
as a struct/union member but which can be accessed by an
accessor function.

The fix generates calls to the accessor function in these cases.

Example:
<struct name="AbsnameTest">
<field type="CARD32" name="len" />
<list type="CARD8" name="mylist1">
   <fieldref>len</fieldref>
</list>
<list type="CARD8" name="mylist2">
   <sumof ref="mylist1"/>
</list>
</struct>

The sumof-expression ( <sumof ref="mylist1"/> ) refers to mylist1
which is only acessible by an accessor function.

Previously, sumof was only used inside bitcases,
where such lists are accessible by members of the
deserialized parent struct.
(there is a difference between deserialization of switches
and structs.)

V2 of this patch:
* replaced "!= None" with "is not None" because that's more pythonic.
(according to suggestion from Ran Benita)

V3 of this patch: simplification:
* fixed the recursion in _c_type_setup
  so that _c_helper_absolute_name does not need check
  a gazillion things as a workaround anymore.

* simplified _c_helper_absolute_name
  - remove unneeded check for empty string before
    append of last_sep to prefix_str

  - removed those if-conditions which are not
    needed anymore after fixing the recursion
    in _c_type_setup.

  - extract functionality for checking whether a field
    needs an accessor ( and which type of accessor )
    in functions.
    (also extracted from _c_accessors)

  - rearrange the condition branches and actions for
    more readability.

V3 generates exactly the same *.c and *.h files as V2.

V4 of this patch:
* improve formatting as per suggestions of Ran

Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
Reviewed-by: Ran Benita <ran234@gmail.com>
Message-ID: <54562758.5090107@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] [PATCHSET] ListInputDevices revision 2
Patch-Set: ListInputDevices
Patch-Number: libxcb 1/9
Patch-Version: V4

6 years agono typename for nested structs NestedStructTypenames-V5
Christian Linhart [Wed, 3 Sep 2014 08:10:49 +0000 (10:10 +0200)]
no typename for nested structs

Nested structs which are generated for named case and bitcase
do not get a typename anymore, i.e., they are anonymous structs.

Reasons for this change:
* Prior typenames have caused nameclashes
* Prior typenames introduced names in the global namespace which
  did not start with the xcb prefix.

This change is safe with respect to API compatibility because:
I have searched for instances of named bitcases and there's only one place
where they are used, and that's in xkb.xml: reply GetKbdByName.
( no need to search for <case> because it was introduced after the last release )

The reply GetKbdByName is broken in its current form in the xkb.xml anyways,
so it is most probably not used anywhere.

So, my conclusion is that we can safely omit named types for nested structs.
No need for an attribute.

Message-ID: <1409731849-51897-1-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: Re: [Xcb] names of nested structs of named bitcase/case are prone to nameclashes. Solution?
Patch-Set: NestedStructTypenames
Patch-Number: libxcb 1/1
Patch-Version: V1
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
Reviewed-By: Ran Benita <ran234@gmail.com>
6 years agogenerator: fix align-pads for switches which start at unaligned pos QueryDeviceState-V5
Christian Linhart [Tue, 9 Sep 2014 21:26:40 +0000 (23:26 +0200)]
generator: fix align-pads for switches which start at unaligned pos

Fix the alignment computation inside switches which start at
an unaligned pos.
This affects both explicit and implicit align pads.

The alignment offset is derived from the lowest 3 bits of
the pointer to the protocol-data at the start of the switch.
This is sufficient for correcting all alignments up to 8-byte alignment.
As far as I know there is no bigger alignment than 8-byte for the
X-protocol.

Example:
struct InputState, where the switch starts after two 1-byte fields,
which is a 2 byte offset for 4-byte and 8-byte alignment.

The previous problem can be demonstrated when adding a
<pad align="4"/> at the end of case "key".

(Or when finding a testcase which reports the case "valuator" not
at the last position of the QueryDeviceState-reply.
I didn't find such a testcase, so I have used the pad align
as described above.)

V2: patch modified in order to fix bugs which I found when working on the
next issue:
* xcb_padding_offset has to be set 0 when xcb_block_len is set 0
* xcb_padding_offset cannot be "const" therefore
* for unpack and unserialize, the padding_offset must computed
  from _buffer instead of from the aux_var.

V3: patch revised according to suggestion by Ran Benita:
* only create and use xcb_padding_offset for switch

Message-ID: <1410298000-24734-1-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: [Xcb] xinput:QueryDeviceState: full-support: generator and xml-changes
Patch-Set: QueryDeviceState
Patch-Number: libxcb 4/4
Patch-Version: V3
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
Reviewed-By: Ran Benita <ran234@gmail.com>
6 years agogenerator: support lists of structs which contain a switch
Christian Linhart [Thu, 21 Aug 2014 20:35:55 +0000 (22:35 +0200)]
generator: support lists of structs which contain a switch

This essentially requires to have a correct sizeof-function
for the struct.
This in turn requires a sizeof-function for the switch, too.

Making a sizeof-function for the switch is triggered by
replacing "elif" by "if" in the first change of this patch.
This way, c_need_sizeof is also set to True for switches if appropriate.

The _c_serialize_helper_switch_field function has to support
the context "sizeof":
This is done in the second change of this patch

The third change of this patch fixes an alignment error:
It does not make sense to base the padding on the struct-type
which is generated for switch because this struct does not
represent the protocol. Rather it is the output of deserialization.
( The implicit padding for var-sized fields has other issues, IMHO,
but I am not touching these now...)

The effect on the generated code for the current xml-files
is as follows:
* several additional sizeof-functions are generated
* the fix of the alignment error only changes one place
  in the XKB-extension for the GetKbdByName-reply.
  This is no problem because that reply in its current form
  is broken/unfinished anyways.

Note:
This patch also fixes a problem in the generator when
a fixed-size list is the last field of a case or bitcase.

Message-ID: <1408653356-21191-2-git-send-email-chris@demorecorder.com>
Patch-Thread-Subject: [Xcb] xinput:QueryDeviceState: full-support: generator and xml-changes
Patch-Set: QueryDeviceState
Patch-Number: libxcb 2/3
Patch-Version: V1
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
Reviewed-By: Ran Benita <ran234@gmail.com>
6 years agogenerator: support fixed size lists in var-sized structs
Christian Linhart [Sat, 6 Sep 2014 18:06:15 +0000 (20:06 +0200)]
generator: support fixed size lists in var-sized structs

V2: patch revised according to suggestions from Ran Benita:
* removed blanks before an after parentheses of function-calls or tuples
* replaced if by elif in "if field.type.is_list". ( this fixes old code )

Message-ID: <540B4D17.1080908@DemoRecorder.com>
Patch-Thread-Subject: [Xcb] xinput:QueryDeviceState: full-support: generator and xml-changes
Patch-Set: QueryDeviceState
Patch-Number: libxcb 1/3
Patch-Version: V2
Signed-off-by: Christian Linhart <chris@DemoRecorder.com>
Reviewed-By: Ran Benita <ran234@gmail.com>
6 years agoxcb_get_setup(): Never return NULL
Uli Schlachter [Mon, 18 Aug 2014 08:38:48 +0000 (10:38 +0200)]
xcb_get_setup(): Never return NULL

The documentation doesn't mention it and it's unlikely that a lot of code out
there handles this case correctly. So, instead of returning NULL, let
xcb_get_setup() return a pointer to a static, invalid, all-zero setup
information structure.

Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoMake some functions also work on error connections
Uli Schlachter [Mon, 18 Aug 2014 08:38:41 +0000 (10:38 +0200)]
Make some functions also work on error connections

There is no technical reason why xcb_get_setup() and xcb_get_file_descriptor()
shouldn't work on non-static error connections. They cannot be used for many
useful things, but at least they work.

This works around bugs in lots of programs out there which assume that
xcb_get_setup() does not return NULL and which just happily dereference the
results. Since xcb_connect() never returns NULL, it's a bit weird that
xcb_get_setup() can do so. xcb_get_file_descriptor() is just modified since this
can be done here equally easily and because the fd isn't closed until the final
xcb_disconnect() on the error connection.

Non-static error connections are connections which entered an error state after
xcb_connect() succeeded. If something goes wrong in establishing a connection,
xcb_connect() will return a static error connection which doesn't have the
fields used here.

Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agosupport switch case in the generator
Christian Linhart [Tue, 19 Aug 2014 13:57:34 +0000 (15:57 +0200)]
support switch case in the generator

The implementation is rather simple:
When a <case> is used instead of a <bitcase>
then operator "==" is used instead of "&" in the if-condition.

So it creates a series of "if" statements
(instead of a switch-case statement in C )

In practice this does not matter because a good
optimizing compiler will create the same code
as for a switch-case.

With this simple implementation we get additional
flexibility in the following forms:
* a case value may appear in multiple case branches.
  for example:
case C1 will be selected by values 1, 4, or 5
case C2 will be selected by values 3, 4, or 7

* mixing of bitcase and case is possible
(this will usually make no sense but there may
be protocol specs where this is needed)

details of the impl:
* replaced "is_bitcase" with "is_case_or_bitcase" in all places
  so that cases are treated like bitcases.

* In function "_c_serialize_helper_switch": write operator "=="
  instead of operator "&" if it is a case.

6 years agoDisable Xevie and Xprint by default
Daniel Martin [Tue, 29 Jul 2014 20:48:44 +0000 (22:48 +0200)]
Disable Xevie and Xprint by default

Both extensions have been dropped from the X-Server in 2008:
    http://cgit.freedesktop.org/xorg/xserver/commit/?id=1c8bd31
    http://cgit.freedesktop.org/xorg/xserver/commit/?id=f4036f6

Don't build them by default.

Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agohelp text: do not report the insanly long list of Warning flags.
Gaetan Nadon [Wed, 26 Mar 2014 19:40:57 +0000 (15:40 -0400)]
help text: do not report the insanly long list of Warning flags.

Originally there was just one. Now that XCB has been integrated with X and
uses the same compiler flags, it is a different story.

  Used CFLAGS:
    CPPFLAGS............:
    CFLAGS..............: -g -O2
    Warning CFLAGS......:  -Wall -Wpointer-arith AND SO ON FOR 8 lines...

It completely defaces the otherwise excellent output.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoAdd ChangeLog and INSTALL using xorg macros
Gaetan Nadon [Wed, 26 Mar 2014 19:40:56 +0000 (15:40 -0400)]
Add ChangeLog and INSTALL using xorg macros

Same as all other X modules. The one in libxcb git is removed.

Those files are created during 'make dist'

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agosendmsg: remove --enable-sendfds as it is superceeded by --enable-dri3
Gaetan Nadon [Wed, 26 Mar 2014 19:24:46 +0000 (15:24 -0400)]
sendmsg: remove --enable-sendfds as it is superceeded by --enable-dri3

DRI3 requires sendmsg support which is auto-detected. A builder can enable
or disable dri3 feature. If sendmsg function is not available, dri3 cannot
be enabled.

This reverts af8067cbf4856 which was done at a time where --enable-dri3
had not been added yet.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoconfig: issue an error if DRI3 is requested, but sendfds is not available
Gaetan Nadon [Wed, 26 Mar 2014 19:24:45 +0000 (15:24 -0400)]
config: issue an error if DRI3 is requested, but sendfds is not available

When a user issues the --enable-dri3 option and sendfds is not available
on the system, the configuration will abort with an error message.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoconfig: default option for enable-dri3 is not implemented
Gaetan Nadon [Wed, 26 Mar 2014 19:24:44 +0000 (15:24 -0400)]
config: default option for enable-dri3 is not implemented

The first symptom is the help text:

  --enable-dri3     Build XCB DRI3 Extension (default: "$sendfds")

The implementation variable $sendfds leaked into the user interface.
Testing the various user inputs:
  <nothing>                DRI3 is enabled     PASS
  --enable-dri3    DRI3 is enabled     PASS
  --enable-dri3=yes        DRI3 is enabled     PASS
  --enable-dri3=no         DRI3 is disabled    PASS
  --disable-dri3           DRI3 is disabled    PASS
  --enable-dri3=$sendfds   DRI3 is disabled    FAIL

This patch implements the usual idiom for features that are enabled by
default if the various conditions are met (sendfds is available).
New help text:

  --enable-dri3     Build XCB DRI3 Extension (default: auto)

With the additional user input:

  --enable-dri3=auto

which is equivalent to providing no input at all.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoRelease libxcb 1.11
Uli Schlachter [Fri, 1 Aug 2014 13:56:52 +0000 (15:56 +0200)]
Release libxcb 1.11

6 years agoBump xcb-proto requirement to 1.11
Uli Schlachter [Fri, 1 Aug 2014 14:03:24 +0000 (16:03 +0200)]
Bump xcb-proto requirement to 1.11

This is needed for the new direct_imports field that we need from xcb-proto.

Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoxcb.h: add 'struct' before xcb_setup_t, xcb_query_extension_reply_t
Alexander Mezin [Sun, 29 Jun 2014 10:33:48 +0000 (17:33 +0700)]
xcb.h: add 'struct' before xcb_setup_t, xcb_query_extension_reply_t

These structs are typedef'ed in xproto.h, so in xcb.h these types
(without 'struct') are actually undefined.

GCC reports this as error when building precompiled header.

Signed-off-by: Alexander Mezin <mezin.alexander@gmail.com>
Reviewed-by: Peter Harris <pharris@opentext.com>
6 years agoc_client.py: remove more trailing space from generated files
Ran Benita [Tue, 25 Feb 2014 12:11:35 +0000 (14:11 +0200)]
c_client.py: remove more trailing space from generated files

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
6 years agoc_client.py: remove trailing whitespace from generated files
Ran Benita [Sun, 23 Feb 2014 20:55:21 +0000 (22:55 +0200)]
c_client.py: remove trailing whitespace from generated files

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
6 years agoc_client.py: remove useless generated comments
Ran Benita [Sun, 23 Feb 2014 20:55:20 +0000 (22:55 +0200)]
c_client.py: remove useless generated comments

They are bloated, don't add anything over the signature, in some cases
duplicate the doxygen comments, and are not integrated with the <doc>
tags in any way. Remove them and cut the generated LOC by half.

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
6 years agoc_client.py: make the man page output deterministic
Ran Benita [Sun, 23 Feb 2014 20:55:19 +0000 (22:55 +0200)]
c_client.py: make the man page output deterministic

Some parts of the man pages (SEE ALSO and ERRORS) are generated by
iterating a Python dict. But the iteration order in a dict is random,
so each build the output is ordered differently. Avoid that by iterating
in sorted order.

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
6 years agoc_client.py: prefix all monkey-patched fields with c_
Ran Benita [Sun, 23 Feb 2014 20:55:18 +0000 (22:55 +0200)]
c_client.py: prefix all monkey-patched fields with c_

The script adds many fields to the objects coming from xcbgen. To
distinguish them, a c_ prefix is used, but for some it was missing.

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
6 years agoc_client.py: remove trailing whitespace
Ran Benita [Sun, 23 Feb 2014 20:55:17 +0000 (22:55 +0200)]
c_client.py: remove trailing whitespace

These are extra annoying in python code.

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
6 years agoc_client.py: remove useless 'today' variable
Ran Benita [Sun, 23 Feb 2014 20:55:16 +0000 (22:55 +0200)]
c_client.py: remove useless 'today' variable

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
6 years agoFix typos & awkward wording in tutorial
Alan Coopersmith [Sat, 12 Jul 2014 03:41:15 +0000 (20:41 -0700)]
Fix typos & awkward wording in tutorial

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
6 years agobug#79986: include system headers early
Michael Haubenwallner [Fri, 13 Jun 2014 14:18:34 +0000 (16:18 +0200)]
bug#79986: include system headers early

AIX <sys/poll.h> does redefine 'events' to 'reqevents' eventually.
To not have this cause compilation errors, need to include the local
header files after any system header file.

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
6 years agoDocument failure modes of xcb_connect*() functions
Alan Coopersmith [Sat, 14 Jun 2014 04:26:21 +0000 (21:26 -0700)]
Document failure modes of xcb_connect*() functions

Documentation was previously unclear that these always return a non-NULL
pointer, and that callers need to check it for error values, instead of
checking for a NULL return value.

Triggered by having to dig through code to answer a user's question on
the #xcb irc channel, since neither of us found it covered in the docs.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
6 years agoHandle <pad align="n" /> between lists
Daniel Martin [Mon, 9 Jun 2014 15:55:04 +0000 (17:55 +0200)]
Handle <pad align="n" /> between lists

Without this patch we end up with invalid C code if we've a
<pad align="n" /> between two variadic lists. Check for such a condition
and take the alignment pad into account.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79808

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
6 years agoxcb_open: Improve abstraction for launchd secure sockets
Jeremy Huddleston Sequoia [Sun, 6 Apr 2014 03:54:59 +0000 (20:54 -0700)]
xcb_open: Improve abstraction for launchd secure sockets

This changes away from hard-coding the /tmp/launch-* path to now
supporting a generic <path to unix socket>[.<screen>] format for
$DISPLAY.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
6 years agoxcb_open: Minor code cleanup for better readability
Jeremy Huddleston Sequoia [Sun, 6 Apr 2014 04:09:42 +0000 (21:09 -0700)]
xcb_open: Minor code cleanup for better readability

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
6 years agoEnsure xcb owns socket and no other threads are writing before send_request
Keith Packard [Tue, 24 Dec 2013 05:15:20 +0000 (21:15 -0800)]
Ensure xcb owns socket and no other threads are writing before send_request

send_request may only write to out.queue if no other thread is busy
writing to the network (as that thread may be writing from out.queue).

send_request may only allocate request sequence numbers if XCB owns
the socket.

Therefore, send_request must make sure that both conditions are true
when it holds iolock, which can only be done by looping until both
conditions are true without having dropped the lock waiting for the
second condition.

We choose to get the socket back from Xlib first as get_socket_back
has a complicated test and checking for other threads writing is a
simple in-lined check.

This also changes the sequence number checks (64k requests with no
reply, 4M request wrapping) to ensure that both conditions are true
before queueing the request.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
6 years agoUpdate .pc file Requires lines to express full dependencies
Keith Packard [Wed, 12 Feb 2014 22:15:46 +0000 (14:15 -0800)]
Update .pc file Requires lines to express full dependencies

Some xcb libraries depend on others; make these dependencies explicit
in the .pc files that are installed.

This change was generated automatically by running 'check-pc-requires -fix'

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoValidate .pc file Requires lines
Keith Packard [Wed, 12 Feb 2014 22:15:45 +0000 (14:15 -0800)]
Validate .pc file Requires lines

This walks through the .pc.in files and makes sure all of the Requires
lines express sufficient dependency information.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoOnly #include directly referenced module header files
Keith Packard [Wed, 12 Feb 2014 22:15:44 +0000 (14:15 -0800)]
Only #include directly referenced module header files

This avoids having the nested header files also included at the top
level, which is more efficient.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoAdd doxygen documentation to functions in xcbext.h
Uli Schlachter [Tue, 25 Feb 2014 14:50:50 +0000 (15:50 +0100)]
Add doxygen documentation to functions in xcbext.h

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
6 years agoMake xcb_disconnect(NULL) safe
Uli Schlachter [Tue, 31 Dec 2013 14:18:01 +0000 (15:18 +0100)]
Make xcb_disconnect(NULL) safe

Code can be simplified if the deallocation functions can always be called in
cleanup code. So if you have some code that does several things that can go
wrong, one of which is xcb_connect(), after this change, the xcb_connection_t*
variable can be initialized to NULL and xcb_disconnect() can always be called on
the connection object.

References: http://lists.freedesktop.org/archives/xcb/2013-September/008659.html

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Julien Cristau <jcristau@debian.org>
6 years agoxcb_disconnect(): Fix leak with error connections
Uli Schlachter [Tue, 31 Dec 2013 14:05:36 +0000 (15:05 +0100)]
xcb_disconnect(): Fix leak with error connections

There are two kind of error connections in XCB. First, if something goes wrong
while the connection is being set up, _xcb_conn_ret_error() is used to return a
static connection in an error state. If something goes wrong later,
_xcb_conn_shutdown() is used to set c->has_error.

This is important, because the static object that _xcb_conn_ret_error() returns
must not be freed, while the dynamically allocated objects that go through
_xcb_conn_shutdown() must obviously be properly deallocated.

This used to work correctly, but in 769acff0da8, xcb_disconnect() was made to
ignore all connections in an error state completely. Fix this by only ignoring
the few static error connections that we have.

This was tested with the following hack:

    xcb_connection_t *c = xcb_connect(NULL, NULL);
    close(xcb_get_file_descriptor(c));
    xcb_discard_reply(c, xcb_get_input_focus(c).sequence);
    xcb_flush(c);
    xcb_disconnect(c);

Valgrind confirms that xcb has a memory leak before this patch that this patch
indeed fixes.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Julien Cristau <jcristau@debian.org>
6 years agoRemove tabs and trailing whitespaces
Uli Schlachter [Mon, 9 Sep 2013 11:04:11 +0000 (13:04 +0200)]
Remove tabs and trailing whitespaces

Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoAdd comments about how _xcb_conn_ret_error() works
Ran Benita [Sat, 18 Jan 2014 15:10:53 +0000 (17:10 +0200)]
Add comments about how _xcb_conn_ret_error() works

If xcb_connect() fails, it doesn't return NULL. Instead, it always
returns an xcb_connection_t*, and the user should check for errors with
the xcb_connection_has_error() function. What this function does is
check if conn->has_error contains a non-zero error code, and returns it.

If an error did occur, xcb doesn't actually return a full
xcb_connection_t though, it just returns (xcb_connection_t *)
error_code. Since the 'has_error' field is the first, it is still
possible to check conn->has_error.

That last trick was not immediately obvious to me, so add some guiding
comments. This also ensures no one obliviously rearranges the struct.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agogenerated man pages: use xorg footer and no hard coded extension
Gaetan Nadon [Tue, 7 Jan 2014 19:02:21 +0000 (14:02 -0500)]
generated man pages: use xorg footer and no hard coded extension

The section number is no longer hard-coded
The left footer is now "X Version 11".
The center footer is the package name with the version, "libxcb 1.9"
The three values above are provided through xorg-macros. They are passed-in
to the python c_client code.

Example of footer (last line, above dotted line)

[...]
AUTHOR
       Generated from xproto.xml. Contact xcb@lists.freedesktop.org for cor‐
       rections and improvements.

X Version 11                      libxcb 1.9                 xcb_send_event(3)

------------------------------------------------------------------------------

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agogenerated man pages: build without hard coded extension
Gaetan Nadon [Tue, 7 Jan 2014 19:02:16 +0000 (14:02 -0500)]
generated man pages: build without hard coded extension

The automake MAN primary requires a hard coded extension to build
man pages. Let's avoid that as the extension number may vary by platform.
Take advantage of the fact that the man directory only contains man pages.
Wildcards are not supported by Automake but it happens to work
sufficiently well here.

Normally xorg build man pages by converting a source .man file to a
target file with the extension number. That would be too many files
in this case.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agoman: build static man pages using xorg patterns
Gaetan Nadon [Tue, 7 Jan 2014 19:02:05 +0000 (14:02 -0500)]
man: build static man pages using xorg patterns

The section number is no longer hard-coded, supplied by xorg-macros.
The left footer is now "X Version 11".
The center footer is the package name with the version, "libxcb 1.9"
The man directory is a sibbling to the doc directory. One can build
or clean the man pages without disturbing the library code.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agoautoconf: replace all tabs with spaces
Gaetan Nadon [Thu, 9 Jan 2014 19:32:18 +0000 (14:32 -0500)]
autoconf: replace all tabs with spaces

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agoautoconf: use default xorg configuration for doxygen documentation
Gaetan Nadon [Tue, 7 Jan 2014 19:00:44 +0000 (14:00 -0500)]
autoconf: use default xorg configuration for doxygen documentation

No content or form changes for the xcb manual or tutorial.
Only the configuration user visible bits change.

Xcb will now have the same configuration options as the 30 other
xorg modules.

Xorg classifies documentation as "user", "developer" or "specifications".
The xcb manual falls under the "developer" category. Developers docs
are never installed under $prefix.

A builder can selectively turn on/off any or all of the categories. He can
also selectively turn on/off any of the many tools used to generate
documentation such as doxygen, xmlto, etc... Each tool has an environment
variable defined such as DOXYGEN.

Other features are available, the user interface and the functionality
is the same on all modules.

--with-doxygen=FILE is replaced with DOXYGEN env variable
--disable-build-docs is replaced with --disable-devel-docs

The new interface displayed with ./configure --help:

  --enable-devel-docs     Enable building the developer documentation
                          (default: yes)
  --with-doxygen          Use doxygen to regenerate documentation (default:
                          auto)
  DOXYGEN     Path to doxygen command
  DOT         Path to the dot graphics utility

The dot tool checking has been added to util-macros in version 1.18.

Refer to the table of existing docs in xorg.
XCB will be added for the doxygen generated API manual.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agoautoconf: fix warning by replacing deprecated AC_HELP_STRING
Gaetan Nadon [Tue, 7 Jan 2014 19:00:43 +0000 (14:00 -0500)]
autoconf: fix warning by replacing deprecated AC_HELP_STRING

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agoautoconf: require libtool minimum level 2.2
Gaetan Nadon [Tue, 7 Jan 2014 19:00:42 +0000 (14:00 -0500)]
autoconf: require libtool minimum level 2.2

This is the updated minimum level as referenced in:
http://www.x.org/wiki/Building_the_X_Window_System/#index2h3

Libtool version 2 has been used for several years now. There should be
no surprises.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agoautoconf: comment and layout the initialization section
Gaetan Nadon [Tue, 7 Jan 2014 19:00:41 +0000 (14:00 -0500)]
autoconf: comment and layout the initialization section

No functional changes. Trying to make it clearer.

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agoautoconf: AC_INIT: add bug url
Gaetan Nadon [Tue, 7 Jan 2014 19:00:40 +0000 (14:00 -0500)]
autoconf: AC_INIT: add bug url

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agoautoconf: use the warning variables from xorg
Gaetan Nadon [Tue, 7 Jan 2014 19:00:39 +0000 (14:00 -0500)]
autoconf: use the warning variables from xorg

The BASE_CFLAGS variable contains only warnings, just like the XCB
version of CWARNFLAGS. This will result in no changes in the binaries
produced. Xorg was missing -fd for SUNCC so it has been added to util-macros
v 1.18.

Do not get confused with the xorg deprecated CWARNFLAGS variable which
contains an option that is not a warning, -fno-strict-aliasing. This
option, should it be needed, can be added using the XORG_TESTSET_CFLAG
macro.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agoautoconf: use XORG_DEFAULT_OPTIONS
Gaetan Nadon [Tue, 7 Jan 2014 19:00:38 +0000 (14:00 -0500)]
autoconf: use XORG_DEFAULT_OPTIONS

XCB has been part of X.Org for a while now. This patch will harmonize the XCB
configuration, using xorg-macros series of macros. It is already used in the
XCB utils packages and is needed to build xcb-proto.

The XORG_DEFAULT_OPTIONS already includes the statement for the silent
rules.

The AC_PROG_CC statement is removed so as not to override AC_PROG_CC_C99
in XORG_DEFAULT_OPTIONS. The effective change is that xcb now uses c99 as
requested.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
6 years agoSupport <pad align="n" />
Peter Harris [Tue, 14 Jan 2014 19:50:55 +0000 (14:50 -0500)]
Support <pad align="n" />

Reviewed-By: Ran Benita <ran234@gmail.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
6 years agoForce XCB event structures with 64-bit extended fields to be packed.
Kenneth Graunke [Fri, 3 Jan 2014 23:08:33 +0000 (15:08 -0800)]
Force XCB event structures with 64-bit extended fields to be packed.

With the advent of the Present extension, some events (such as
PresentCompleteNotify) now use native 64-bit types on the wire.

For XGE events, we insert an extra "uint32_t full_sequence" field
immediately after the first 32 bytes of data.  Normally, this causes
the subsequent fields to be shifted over by 4 bytes, and the structure
to grow in size by 4 bytes.  Everything works fine.

However, if event contains 64-bit extended fields, this may result in
the compiler adding an extra 4 bytes of padding so that those fields
remain aligned on 64-bit boundaries.  This causes the structure to grow
by 8 bytes, not 4.  Unfortunately, XCB doesn't realize this, and
always believes that the length only increased by 4.  read_packet()
then fails to malloc enough memory to hold the event, and the event
processing code uses the wrong offsets.

To fix this, mark any event structures containing 64-bit extended
fields with __attribute__((__packed__)).

v2: Use any(...) instead of True in (...), as suggested by
    Daniel Martin.

v3 (Alan Coopersmith): Fix build with Solaris Studio 12.3 by moving the
attribute to after the structure definition.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Keith Packard <keithp@keithp.com> [v1]
Reviewed-by: Josh Triplett <josh@joshtriplett.org> [v1]
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
6 years agoRelease libxcb 1.10
Uli Schlachter [Sun, 22 Dec 2013 14:59:24 +0000 (15:59 +0100)]
Release libxcb 1.10

Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoAdd NEWS for 1.10
Julien Cristau [Sat, 14 Dec 2013 05:16:37 +0000 (06:16 +0100)]
Add NEWS for 1.10

Signed-off-by: Julien Cristau <jcristau@debian.org>
6 years agoAdd NEWS entries for releases 1.9.1 to 1.9.3
Uli Schlachter [Fri, 15 Nov 2013 21:33:12 +0000 (22:33 +0100)]
Add NEWS entries for releases 1.9.1 to 1.9.3

libxcb 1.9.1 was released from a branch and thus its NEWS entries never made it
into the master branch. The other releases didn't update NEWS.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Julien Cristau <jcristau@debian.org>
6 years agoBump xcb-proto requirement to 1.10
Julien Cristau [Sat, 14 Dec 2013 04:54:20 +0000 (05:54 +0100)]
Bump xcb-proto requirement to 1.10

Makes sure we generate the new generic event struct.

Signed-off-by: Julien Cristau <jcristau@debian.org>
6 years agoTest the value of msg_controllen for platforms whose CMSG_FIRSTHDR() does not test...
PHO [Tue, 3 Dec 2013 03:43:04 +0000 (12:43 +0900)]
Test the value of msg_controllen for platforms whose CMSG_FIRSTHDR() does not test it for us

As RFC 2292 points out, some platforms (e.g. Darwin 9.8.0) provide
CMSG_FIRSTHDR(msg) which just returns msg.msg_control without first
checking if msg.msg_controllen is non-zero. We need a workaround for
such platforms not to let _xcb_in_read() segfault.

https://bugs.freedesktop.org/show_bug.cgi?id=72253

Signed-off-by: Julien Cristau <jcristau@debian.org>
6 years agoIncrement the "current" version info for sync, xinput and xkb
Uli Schlachter [Mon, 18 Nov 2013 19:28:08 +0000 (20:28 +0100)]
Increment the "current" version info for sync, xinput and xkb

Sync: Due to commit e6a246e50e62cbcba3 "sync: Change value list param of
CreateAlarm and ChangeAlarm into switch", various symbols disappeared,
for example xcb_sync_{change,create}_alarm_sizeof.

xinput: This extension was updated from version 1.4 to 2.3. This means
that lots of new things are generated. However, this change is
backwards-compatible and thus age gets set to 1.

xkb: In commit 37d0f55392d6 "xkb: Work around alignment problems in
GetNames and GetMap replies", some padding fields were introduced into
structures for which an _unpack() function is generated. This changed
the size of the struct and caused offsets into this struct to change.

https://bugs.freedesktop.org/show_bug.cgi?id=71507

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Julien Cristau <jcristau@debian.org>
6 years agoRevert "Remove xcb_ge_event_t from xcb.h"
Uli Schlachter [Mon, 18 Nov 2013 19:30:18 +0000 (20:30 +0100)]
Revert "Remove xcb_ge_event_t from xcb.h"

This reverts commit f4d5b84800f960831e4fbb3ad9848bbb701020be.

The version of this struct that the code generator produces breaks the API,
because it gives the fields different (albeit better) names. Thus, we need to
restore the old version of this struct.

Additionally to the revert, this struct is documented as being deprecated. The
replacement was added to xcb-proto.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=71502
Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Julien Cristau <jcristau@debian.org>
6 years agoc_client.py: Fix _sizeof() functions
Daniel Martin [Fri, 22 Nov 2013 22:27:28 +0000 (23:27 +0100)]
c_client.py: Fix _sizeof() functions

Currently, it is not possible to correctly iterate over the replies of
some requests. For example, the list of XIDeviceInfo returned by
the XIQueryDevice request from xinput2 is read as garbage starting from
the second entry.

The culprits are the _sizeof() used by the iterators. In the above case:

    int
    xcb_input_xi_device_info_sizeof (const void  *_buffer  /**< */)
    {
        char *xcb_tmp = (char *)_buffer;
        [...]
        unsigned int xcb_block_len = 0;
        [...]

        xcb_block_len += sizeof(xcb_input_xi_device_info_t);
        xcb_tmp += xcb_block_len;
        /* name */
        xcb_block_len += (((_aux->name_len + 3) / 4) * 4) * sizeof(char);
        xcb_tmp += xcb_block_len;
        [...]
    }

The problem here is that `xcb_block_len` is not zero'd right above the
`/* name */` comment, causing `xcb_tmp` to be incremented by
`sizeof(xcb_input_xi_device_info_t)` twice. The returned size is too
large.

https://bugs.freedesktop.org/show_bug.cgi?id=68387

Tested-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: Julien Cristau <jcristau@debian.org>
6 years agoRevert "fix deadlock with xcb_take_socket/return_socket v3"
Uli Schlachter [Mon, 18 Nov 2013 18:49:41 +0000 (19:49 +0100)]
Revert "fix deadlock with xcb_take_socket/return_socket v3"

This reverts commit 9ae84ad187e2ba440c40f44b8eb21c82c2fdbf12.

After this patch was merged, there were complaints about it not being a good
idea. Revert this for now until we can agree on this.

References: http://lists.freedesktop.org/archives/xcb/2013-June/008340.html
Signed-off-by: Uli Schlachter <psychon@znc.in>
Conflicts:
src/xcbint.h

6 years agoFix alignment issues in FD passing code
Mark Kettenis [Mon, 11 Nov 2013 22:11:56 +0000 (23:11 +0100)]
Fix alignment issues in FD passing code

A char array on the stack is not guaranteed to have more than byte alignment.
This means that casting it to a 'struct cmsghdr' and accessing its members
may result in unaligned access.  This will generate SIGBUS on struct
alignment architectures like OpenBSD/sparc64.  The canonical solution is to
use a union to force proper alignment.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
Signed-off-by: Uli Schlachter <psychon@znc.in>
6 years agoCheck if we need to define _XOPEN_SOURCE for struct msghdr.msg_control
Alan Coopersmith [Fri, 8 Nov 2013 04:23:27 +0000 (20:23 -0800)]
Check if we need to define _XOPEN_SOURCE for struct msghdr.msg_control

Required to expose the structure members in Solaris headers, since it
was an XPG4/UNIX95 addition to the Solaris ABI.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
6 years agoAdd configure option to enable or disable fd passing with sendmsg
Keith Packard [Fri, 8 Nov 2013 01:36:01 +0000 (17:36 -0800)]
Add configure option to enable or disable fd passing with sendmsg

--disable-sendfds or --enable-sendfds

By default, configure auto-detects based on whether your system
supports sendmsg at all.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
6 years agoSwitch to using the CMSG_* macros for FD passing
Keith Packard [Fri, 8 Nov 2013 01:28:45 +0000 (17:28 -0800)]
Switch to using the CMSG_* macros for FD passing

Use these instead of computing the values directly so that it might
work on BSD or other non-Linux systems

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
6 years agoAdd Present extension
Keith Packard [Thu, 11 Jul 2013 23:01:02 +0000 (16:01 -0700)]
Add Present extension

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-By: Uli Schlachter <psychon@znc.in>
6 years agoAdd DRI3 library
Keith Packard [Wed, 10 Apr 2013 04:35:52 +0000 (21:35 -0700)]
Add DRI3 library

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-By: Uli Schlachter <psychon@znc.in>
6 years agoRequire xcb proto version 1.9
Keith Packard [Thu, 7 Nov 2013 13:20:06 +0000 (05:20 -0800)]
Require xcb proto version 1.9

Signed-off-by: Keith Packard <keithp@keithp.com>
6 years agoAdd event queue splitting
Keith Packard [Sat, 13 Apr 2013 03:15:41 +0000 (20:15 -0700)]
Add event queue splitting

This allows apps to peel off certain XGE events into separate queues
for custom handling. Designed to support the Present extension

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-By: Uli Schlachter <psychon@znc.in>
6 years agoAdd support for receiving fds in replies
Keith Packard [Fri, 18 Jan 2013 09:29:40 +0000 (01:29 -0800)]
Add support for receiving fds in replies

Requests signal which replies will have fds, and the replies report
how many fds they expect in byte 1.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-By: Uli Schlachter <psychon@znc.in>
6 years agoAdd xcb_send_fd API
Keith Packard [Mon, 14 Jan 2013 19:23:00 +0000 (11:23 -0800)]
Add xcb_send_fd API

This uses sendmsg to transmit file descriptors from the application to
the X server

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-By: Uli Schlachter <psychon@znc.in>
6 years ago-pendantic is too pendantic
Keith Packard [Fri, 18 Jan 2013 09:28:56 +0000 (01:28 -0800)]
-pendantic is too pendantic

Many system headers have warnings when compiled with this flag.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-By: Uli Schlachter <psychon@znc.in>
6 years agoMake protocol C files depend on protocol XML files
Keith Packard [Fri, 12 Jul 2013 17:32:03 +0000 (10:32 -0700)]
Make protocol C files depend on protocol XML files

When new XML files get installed, make sure the C files are regenerated

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-By: Uli Schlachter <psychon@znc.in>
6 years agoRemove xcb_ge_event_t from xcb.h
Keith Packard [Thu, 7 Nov 2013 03:33:53 +0000 (19:33 -0800)]
Remove xcb_ge_event_t from xcb.h

xcb proto now publishes this structure from an XML description

Signed-off-by: Keith Packard <keithp@keithp.com>
7 years agoUse /usr/spool/sockets/X11/ on HP-UX for UNIX sockets (#69118).
Daphne Pfister [Sat, 14 Sep 2013 21:36:22 +0000 (17:36 -0400)]
Use /usr/spool/sockets/X11/ on HP-UX for UNIX sockets (#69118).

7 years agoFix poll() if POLLIN == ROLLRDNORM|POLLRDBAND
Daphne Pfister [Sun, 8 Sep 2013 20:25:11 +0000 (16:25 -0400)]
Fix poll() if POLLIN == ROLLRDNORM|POLLRDBAND

It seems like POLLIN is specified as equivalent to POLLRDNORM | POLLRDBAND. Some
systems (e.g. QNX and HP-UX) take this literaly and have POLLIN defined as the
above bit combination. Other systems (e.g. Linux) have POLLIN as just a single
bit.

This means that if no out-of-band data is available (which should never be the
case), the result of poll() will not fulfil (fd.revents & POLLIN) == POLLIN on
QNX, because the POLLRDBAND bit is not set.

In other words, even though poll() signaled that the fd is readable, xcb would
not read from the file descriptor.

Fix this by checking if any bits from POLLIN are set in the result of poll(),
instead of all of them.

(This change was independently done by seanb@qnx.com as well)

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=38001
Acked-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Uli Schlachter <psychon@znc.in>
7 years agoFix documentation of xcb_poll_for_event()
Uli Schlachter [Sun, 8 Sep 2013 20:16:39 +0000 (22:16 +0200)]
Fix documentation of xcb_poll_for_event()

In commit 8eba8690adac2, the API documentation for xcb_poll_for_event() was
fixed to remove an argument that was previously removed in commit 34168ab549.

However, that commit only removed the first line of the documentation, leaving
behind a spurious half-sentence. That commit happened seven years ago and now
finally someone noticed...

Thanks to Benjamin Herr for reporting this on IRC.

v2: Thanks again to Benjamin Herr for noticing that my commit message blamed the
wrong commit.

Signed-off-by: Uli Schlachter <psychon@znc.in>
7 years agotests: Add files to .gitignore
Daniel Martin [Sun, 11 Aug 2013 11:25:18 +0000 (13:25 +0200)]
tests: Add files to .gitignore

Add check_all.log, check_all.trs and test-suite.log to tests/.gitignore.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
7 years agoSort gitignore, adjust pattern for config.h
Daniel Martin [Thu, 25 Jul 2013 09:09:26 +0000 (11:09 +0200)]
Sort gitignore, adjust pattern for config.h

Don't ignore the files config.h and config.h.in, adjust the pattern to
ignore config.h*. This matches an additional config.h.in~ too.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
Tested-By: Ran Benita <ran234@gmail.com>
7 years agoUse m4 directory
Daniel Martin [Thu, 25 Jul 2013 08:56:30 +0000 (10:56 +0200)]
Use m4 directory

- Follow the suggestion by libtoolize:
   "Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
    rerunning libtoolize, to keep the correct libtool macros in-tree.
    Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am."
  and add the macro and define.

- Create the m4 directory and move acinclude.m4 as xcb.m4 there.

- Ignore the m4 files libtoolize copies into the m4 directory
  (m4/l*.m4).

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
Tested-By: Ran Benita <ran234@gmail.com>
7 years agoUse build-aux as autom4te cache directory
Daniel Martin [Wed, 24 Jul 2013 12:13:41 +0000 (14:13 +0200)]
Use build-aux as autom4te cache directory

Remove the generated directory ./autom4te.cache by reusing ./build-aux
as cache directory.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
Tested-By: Ran Benita <ran234@gmail.com>
7 years agoSet AC_CONFIG_AUX_DIR to build-aux
Daniel Martin [Wed, 24 Jul 2013 12:08:38 +0000 (14:08 +0200)]
Set AC_CONFIG_AUX_DIR to build-aux

Do not clutter the project directory with generated/copied auxiliary
files, save them in ./build-aux.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
Tested-By: Ran Benita <ran234@gmail.com>
7 years agoRemove second AC_PREREQ, require version 2.60
Daniel Martin [Wed, 24 Jul 2013 17:22:44 +0000 (19:22 +0200)]
Remove second AC_PREREQ, require version 2.60

Remove a second AC_PREREQ and bump the required autoconf version to
2.60.

Version 2.59c was a testing release, published in April 2006. Version
2.60 was the stable release afterwards, released in June 2006.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
Tested-By: Ran Benita <ran234@gmail.com>
7 years agoInitialize automake earlier (bugfix for #66413)
Daniel Martin [Wed, 24 Jul 2013 10:51:04 +0000 (12:51 +0200)]
Initialize automake earlier (bugfix for #66413)

This fixes:
    https://bugs.freedesktop.org/show_bug.cgi?id=66413
    Bug 66413 - libxcb 1.9.1: Fails to build on Arch Linux: \
        /home/<user>/install-sh: No such file or directory

Without that patch the search path for `install-sh` will become $HOME
and the `install` target will fail, when DESTDIR doesn't exist in
advance. (occured with automake 1.14 and autoconf 2.69)

Initial patch by: Alain Kalker <a.c.kalker@gmail.com>
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
Tested-By: Ran Benita <ran234@gmail.com>
7 years agoMake xsltproc optional
Daniel Martin [Mon, 31 Dec 2012 10:57:49 +0000 (11:57 +0100)]
Make xsltproc optional

Fix Bug 23863 - xcb still checks for xsltproc:
    https://bugs.freedesktop.org/show_bug.cgi?id=23863

xsltproc is used to generate the optional html page for `check` results,
only. So, it's not a hard build dependency.

Additionally, use yes/no instead of true/false in the HTML_CHECK_RESULT
variable for consistent output after a configure run.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
7 years agoc_client.py: Do not create pointers in unions
Daniel Martin [Fri, 28 Dec 2012 22:25:16 +0000 (23:25 +0100)]
c_client.py: Do not create pointers in unions

Do not create pointers in unions for fields of variadic length.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Ran Benita <ran234@gmail.com>
7 years agoc_client.py: Always initialize xcb_align_to
Daniel Martin [Wed, 9 Jan 2013 11:52:15 +0000 (12:52 +0100)]
c_client.py: Always initialize xcb_align_to

to get rid of:
    warning: 'xcb_align_to' may be used uninitialized in this function

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Peter Harris <pharris@opentext.com>
7 years agoDefine _xcb_map_new with explicit void arg list instead of empty one
Alan Coopersmith [Sun, 4 Aug 2013 03:25:23 +0000 (20:25 -0700)]
Define _xcb_map_new with explicit void arg list instead of empty one

Fixes Solaris Studio compiler warning:
"xcb_list.c", line 50: warning: old style function definition

and gcc warning:
xcb_list.c: In function '_xcb_map_new':
xcb_list.c:50:11: warning: old-style function definition [-Wold-style-definition]

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
7 years agoEnable warnings for pre-C89 style definitions for gcc & Solaris Studio
Alan Coopersmith [Sun, 4 Aug 2013 03:22:25 +0000 (20:22 -0700)]
Enable warnings for pre-C89 style definitions for gcc & Solaris Studio

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>