Commit Graph

659 Commits

Author SHA1 Message Date
Christian Linhart 18ff453edd _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
2014-11-03 11:23:16 +01:00
Christian Linhart d905b88618 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
2014-11-03 11:23:16 +01:00
Christian Linhart 17f6e04493 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
2014-11-03 11:23:16 +01:00
Christian Linhart 51a0d57acc 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
2014-11-03 11:23:16 +01:00
Christian Linhart 4a915c0dba 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
2014-11-03 11:23:16 +01:00
Christian Linhart fda1fb4ed4 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
2014-11-03 11:23:16 +01:00
Christian Linhart 265d38882c 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
2014-11-03 11:23:16 +01:00
Peter Harris bbca7b82f8 Merge branch 'NestedStructTypenames-V5' of http://infra-srv1.demorecorder.com/git/free-sw/xcb/libxcb 2014-10-30 11:51:57 -04:00
Christian Linhart fdb291b414 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>
2014-10-20 12:21:21 +02:00
Christian Linhart a7c75be5b1 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>
2014-10-20 12:21:21 +02:00
Christian Linhart 277ea629de 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>
2014-10-20 12:21:21 +02:00
Emil Velikov 382d306d6c Move internal/private dependencies to Requires.private
Program using the xcb sub-modules has indirect compile and runtime
dependency of core xcb. To ensure this out we currently list xcb in
the Requires field of the pkg-config files. While this provides all
the required dependencies for successful compilation this causes
over-linking and hides potential linking miss-use against the xcb modules.

By moving to Requires.private we retain the compilation and runtime
compatibility and avoids any runtime problems.

Cc: Keith Packard <keithp@keithp.com>
Cc: Alan Coopersmith <alan.coopersmith@oracle.com>
References: http://people.freedesktop.org/~dbn/pkg-config-guide.html#faq
References: https://wiki.mageia.org/en/Overlinking_issues_in_packaging
References: http://err.no/personal/blog/2008/Mar/25
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-10-03 23:53:54 +02:00
Christian Linhart d74d066949 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>
2014-09-09 23:54:41 +02:00
Uli Schlachter b0e6c2de09 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>
2014-08-25 19:15:34 -04:00
Uli Schlachter c4e40f646b 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>
2014-08-25 19:15:34 -04:00
Christian Linhart 355d4d6ab9 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.
2014-08-20 11:59:04 -04:00
Daniel Martin 966fba6ba4 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>
2014-08-06 13:32:50 +02:00
Gaetan Nadon a5e90ae6a1 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>
2014-08-06 13:29:16 +02:00
Gaetan Nadon 529e3bfc20 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>
2014-08-06 13:29:16 +02:00
Gaetan Nadon 74f552c1b3 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 af8067cbf4 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>
2014-08-06 13:26:08 +02:00
Gaetan Nadon 23f57ac8bf 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>
2014-08-06 13:26:08 +02:00
Gaetan Nadon 7f07b57be5 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>
2014-08-06 13:26:08 +02:00
Uli Schlachter d1e8ec96fc Release libxcb 1.11 2014-08-01 16:04:34 +02:00
Uli Schlachter c5c6cfa4d2 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>
2014-08-01 16:04:33 +02:00
Alexander Mezin 70ea5da64b 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>
2014-07-28 20:36:32 +02:00
Ran Benita 7e6af51b4e 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>
2014-07-28 20:32:56 +02:00
Ran Benita 8221d249b7 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>
2014-07-28 20:30:15 +02:00
Ran Benita e3c728ee3d 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>
2014-07-28 20:30:04 +02:00
Ran Benita cae2e39856 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>
2014-07-28 20:29:59 +02:00
Ran Benita bfbf83b1d8 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>
2014-07-28 20:29:56 +02:00
Ran Benita 285d566a5c 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>
2014-07-28 20:29:49 +02:00
Ran Benita 285838cfe4 c_client.py: remove useless 'today' variable
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
2014-07-28 20:29:04 +02:00
Alan Coopersmith 49a61c8b45 Fix typos & awkward wording in tutorial
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-07-11 20:41:15 -07:00
Michael Haubenwallner 125135452a 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>
2014-06-14 08:24:37 -07:00
Alan Coopersmith bc5a104754 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>
2014-06-14 08:24:30 -07:00
Daniel Martin 72e45969ff 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>
2014-06-10 14:01:03 -04:00
Jeremy Huddleston Sequoia d978a4f69b 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>
2014-04-10 09:50:57 -07:00
Jeremy Huddleston Sequoia 29e419c584 xcb_open: Minor code cleanup for better readability
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
2014-04-10 09:50:54 -07:00
Keith Packard be0fe56c3b 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>
2014-03-30 22:15:38 +02:00
Keith Packard e2813e1cde 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>
2014-03-22 14:44:52 +01:00
Keith Packard 32de4c4213 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>
2014-03-22 14:44:52 +01:00
Keith Packard 1f6cd9f1fc 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>
2014-03-22 14:44:52 +01:00
Uli Schlachter cb686b5767 Add doxygen documentation to functions in xcbext.h
Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
2014-03-21 14:44:22 +01:00
Uli Schlachter 2fb14e5883 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>
2014-03-21 14:39:44 +01:00
Uli Schlachter 4dcbfd77b7 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 769acff0da, 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>
2014-03-21 14:38:58 +01:00
Uli Schlachter d84dd752ef Remove tabs and trailing whitespaces
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-03-21 14:35:16 +01:00
Ran Benita 4ffa6f83b9 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>
2014-02-19 22:01:58 +01:00
Gaetan Nadon d7eb0bdf3b 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>
2014-01-30 12:10:06 +09:00
Gaetan Nadon e4061b8f00 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>
2014-01-30 12:10:06 +09:00
Gaetan Nadon 3cdd524cad 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>
2014-01-30 12:10:00 +09:00