free-sw/xcb/libxcb
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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

10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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).

10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 years agoBuild xcb-xkb by default
Michael Stapelberg [Mon, 5 Aug 2013 20:14:18 +0000 (22:14 +0200)]
Build xcb-xkb by default

There have not been any big issues with xcb-xkb recently.

Also, Wayland is using xcb-xkb actively, making distributions compile
libxcb with xkb support anyway, so let’s reflect reality :).

Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
10 years agoc_client.py: Inject full_sequence into GE events
Daniel Martin [Sat, 8 Jun 2013 09:20:39 +0000 (11:20 +0200)]
c_client.py: Inject full_sequence into GE events

The generic event structure xcb_ge_event_t has the full_sequence field
at the 32byte boundary. That's why we've to inject this field into GE
events while generating the structure for them. Otherwise we would read
garbage (the internal full_sequence) when accessing normal event fields
there.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
10 years agoFix "indention" typos in xcb-examples.3 man page
Alan Coopersmith [Tue, 9 Jul 2013 00:54:35 +0000 (17:54 -0700)]
Fix "indention" typos in xcb-examples.3 man page

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
10 years agoUpdate Makefile.am for newer automake
Marc Deslauriers [Wed, 5 Jun 2013 20:38:00 +0000 (16:38 -0400)]
Update Makefile.am for newer automake

Debian Bug #710344

Reviewed-by: Daniel Martin <consume.noise@gmail.com>
10 years agofix deadlock with xcb_take_socket/return_socket v3
Christian König [Wed, 15 May 2013 09:21:36 +0000 (11:21 +0200)]
fix deadlock with xcb_take_socket/return_socket v3

To prevent different threads from stealing the socket from each other the
caller of "xcb_take_socket" must hold a lock that is also acquired in
"return_socket". Unfortunately xcb tries to prevent calling return_socket
from multiple threads and this can lead to a deadlock situation.

A simple example:
- X11 has taken the socket
- Thread A has locked the display.
- Thread B does xcb_no_operation() and thus ends up in libX11's return_socket(),
  waiting for the display lock.
- Thread A calls e.g. xcb_no_operation(), too, ends up in return_socket() and
  because socket_moving == 1, ends up waiting for thread B
=> Deadlock

This patch allows calling return_socket from different threads at the same time
an so resolves the deadlock situation.

Partially fixes: https://bugs.freedesktop.org/show_bug.cgi?id=20708

v2: fixes additional pthread_cond_wait dependencies,
    rework comments and patch description

v3: separate pthread_cond_wait dependencies and unrelated whitespace
    change into their own patch, use unsigned for socket_seq

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
10 years agointeger overflow in read_packet() [CVE-2013-2064]
Alan Coopersmith [Thu, 2 May 2013 00:59:31 +0000 (17:59 -0700)]
integer overflow in read_packet() [CVE-2013-2064]

Ensure that when calculating the size of the incoming response from the
Xserver, we don't overflow the integer used in the calculations when we
multiply the int32_t length by 4 and add it to the default response size.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
10 years agoc_client.py: Handle multiple expr. in a bitcase
Daniel Martin [Mon, 13 May 2013 21:33:04 +0000 (23:33 +0200)]
c_client.py: Handle multiple expr. in a bitcase

Adopt a change from xcbgen. With that modification the expression in a
bitcase became a list of expressions to support multiple <enumref> in a
<bitcase>.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
10 years agowhitespace fix in xcb_take_socket
Christian König [Wed, 15 May 2013 09:21:35 +0000 (11:21 +0200)]
whitespace fix in xcb_take_socket

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
11 years agoautogen.sh: Implement GNOME Build API
Colin Walters [Wed, 4 Jan 2012 22:37:06 +0000 (17:37 -0500)]
autogen.sh: Implement GNOME Build API

http://people.gnome.org/~walters/docs/build-api.txt

Signed-off-by: Adam Jackson <ajax@redhat.com>
11 years agoc_client.py: Fix python-3 invalid except statement
Chí-Thanh Christopher Nguyễn [Wed, 10 Oct 2012 23:14:12 +0000 (01:14 +0200)]
c_client.py: Fix python-3 invalid except statement

Replace except statement with a PEP-3110 compliant one. This fixes a regression
introduced by c3deeaf714630531d693a6a902b8dabf791858b1
https://bugs.freedesktop.org/show_bug.cgi?id=55690

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
11 years agoc-client.py: Fix python-3 AttributeError: 'dict' object has no attribute 'iteritems'
Chí-Thanh Christopher Nguyễn [Wed, 10 Oct 2012 23:14:11 +0000 (01:14 +0200)]
c-client.py: Fix python-3 AttributeError: 'dict' object has no attribute 'iteritems'

This fixes a regression introduced by ea71d7d7e3f5d8189b80747678e9ca9a417b1d37
https://bugs.freedesktop.org/show_bug.cgi?id=55690

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
11 years agoRelease libxcb 1.9
Uli Schlachter [Fri, 5 Oct 2012 12:53:37 +0000 (14:53 +0200)]
Release libxcb 1.9

Signed-off-by: Uli Schlachter <psychon@znc.in>
11 years agoInclude static man pages in "make dist"
Uli Schlachter [Fri, 5 Oct 2012 09:23:26 +0000 (11:23 +0200)]
Include static man pages in "make dist"

This was found by distcheck. It tried to install src/man/xcb-examples.3 and
src/man/xcb-requests.3, but those files weren't in the distribution.

Fix this by explicitly telling automake to distribute those files.

Signed-off-by: Uli Schlachter <psychon@znc.in>
11 years agoFix a multi-thread deadlock
Uli Schlachter [Mon, 24 Sep 2012 20:07:51 +0000 (22:07 +0200)]
Fix a multi-thread deadlock

This fixes a deadlock which was seen in-the-wild with wine.

It could happen that two threads tried to read from the socket at the same time
and one of the thread got stuck inside of poll()/select().

The fix works by making sure that the writing thread doesn't steal the reading
thread's reply.

Debugged-by: Erich Hoover <ehoover@mines.edu>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54671
Signed-off-by: Uli Schlachter <psychon@znc.in>
11 years agoAdd a .gitignore for src/man/
Uli Schlachter [Mon, 24 Sep 2012 20:07:30 +0000 (22:07 +0200)]
Add a .gitignore for src/man/

Signed-off-by: Uli Schlachter <psychon@znc.in>
11 years agoAllow xcb_send_request with >MAX_IOV iovecs
Peter Harris [Thu, 16 Aug 2012 15:59:14 +0000 (11:59 -0400)]
Allow xcb_send_request with >MAX_IOV iovecs

This allows an application to do a scatter/gather operation on a large
image buffer to avoid the extra memcpy.

Use autoconf to use UIO_MAXIOV where IOV_MAX is not available (and the
POSIX minimum of 16 where neither are available).

Reviewed-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Peter Harris <pharris@opentext.com>
11 years agoReturn connection failure if display string specifies non-existent screen
Alan Coopersmith [Sat, 25 Aug 2012 20:53:37 +0000 (13:53 -0700)]
Return connection failure if display string specifies non-existent screen

Matches the behaviour of Xlib - if you set DISPLAY to :0.1 but only have
one screen, closes connection and returns error.

This introduces a new connection error code:
XCB_CONN_CLOSED_INVALID_SCREEN

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
11 years agoAdd AC_USE_SYSTEM_EXTENSIONS to allow use of more system functionality
Alan Coopersmith [Sat, 25 Aug 2012 06:35:41 +0000 (23:35 -0700)]
Add AC_USE_SYSTEM_EXTENSIONS to allow use of more system functionality

Copied from libX11 configure.ac

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
11 years agoAlways include "config.h" at the start of all C source files.
Alan Coopersmith [Sat, 25 Aug 2012 06:32:32 +0000 (23:32 -0700)]
Always include "config.h" at the start of all C source files.

Allows configure to set defines such as _POSIX_SOURCE in config.h
that affect functions exposed by system headers and get consistent
results across all the source files.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
11 years agoFix "sppported" typo in doxygen comment for XCB_CONN_CLOSED_EXT_NOTSUPPORTED
Alan Coopersmith [Sat, 25 Aug 2012 19:33:35 +0000 (12:33 -0700)]
Fix "sppported" typo in doxygen comment for XCB_CONN_CLOSED_EXT_NOTSUPPORTED

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
11 years agoc_client: Fix parallel-make issue creating 'man' directory
Colin Walters [Mon, 13 Aug 2012 19:32:31 +0000 (15:32 -0400)]
c_client: Fix parallel-make issue creating 'man' directory

With make -j, it was possible to hit a race condition in the code to
make the 'man' directory.

Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoxcb_connect: launchd: Don't fall back on tcp if $DISPLAY is a path to a launchd socket
Jeremy Huddleston [Sun, 22 Apr 2012 05:42:51 +0000 (22:42 -0700)]
xcb_connect: launchd: Don't fall back on tcp if $DISPLAY is a path to a launchd socket

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
12 years agoMove static man to man
Julien Danjou [Tue, 27 Mar 2012 10:10:59 +0000 (12:10 +0200)]
Move static man to man

Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoDo not list manpages, use a wildcard
Julien Danjou [Tue, 27 Mar 2012 10:10:15 +0000 (12:10 +0200)]
Do not list manpages, use a wildcard

Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoSplit manpage list in two (static/built)
Julien Danjou [Tue, 27 Mar 2012 10:06:54 +0000 (12:06 +0200)]
Split manpage list in two (static/built)

Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoAllow undocumented code to be built
Julien Danjou [Mon, 26 Mar 2012 16:29:35 +0000 (18:29 +0200)]
Allow undocumented code to be built

Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoc_client.py: generate manpages
Michael Stapelberg [Sun, 27 Nov 2011 10:38:26 +0000 (10:38 +0000)]
c_client.py: generate manpages

Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoRelease libxcb 1.8.1
Julien Danjou [Fri, 9 Mar 2012 14:38:56 +0000 (15:38 +0100)]
Release libxcb 1.8.1

Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoFix a busy loop on BSD and Mac OS
Uli Schlachter [Thu, 1 Mar 2012 19:26:39 +0000 (20:26 +0100)]
Fix a busy loop on BSD and Mac OS

On FreeBSD MSG_WAITALL on a non-blocking socket fails immediately if less bytes
than were asked for are available. This is different than the behavior on linux
where as many bytes as are available are returned in this case. Other OS
apparently follow the FreeBSD behavior.

_xcb_in_read() is used to fill xcb's read buffer, thus this function will call
recv() with a big length argument (xcb's read buffer is by default 16 KiB
large). That many bytes are highly unlikely to be available in the kernel
buffer.

This means that _xcb_in_read() always failed on FreeBSD. Since the socket was
still signaled as readable by poll(), this bug even resulted in a busy loop.

The same issue is present in read_block(), but here it is slightly different.
read_block() is called when we read the first few bytes of an event or a reply,
so that we already know its length. This means that we should be able to use
MSG_WAITALL here, because we know how many bytes there have to be.

However, that function could busy loop, too, when only the first few bytes of
the packet were sent while the rest is stuck somewhere on the way to us. Thus,
MSG_WAITALL should be removed here, too.

Thanks to Christoph Egger from Debian for noticing the problem, doing all the
necessary debugging and figuring out what the problem was! This patch is 99%
from debian. Thanks for all the work.

This bug was introduced in commit 2dcf8b025be88a25d4333abdc28d425b88238d96.

This commit also reverts commit 9061ee45b8dbe5431c23e3f628089d703ccad0b1.

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

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
12 years agodarwin: Use read(2) rather than recv(2)
Jeremy Huddleston [Thu, 8 Mar 2012 08:50:13 +0000 (00:50 -0800)]
darwin: Use read(2) rather than recv(2)

2dcf8b025be88a25d4333abdc28d425b88238d96 was causing some regressions on
darwin, so go back to using read(2) there until I have time to investigate
further.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
12 years agoFallback to TCP if no protocol is specified and the UNIX connection fails
Julien Cristau [Sun, 19 Feb 2012 12:43:54 +0000 (13:43 +0100)]
Fallback to TCP if no protocol is specified and the UNIX connection fails

Signed-off-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
12 years agoAdd xkb_internals and xkb_issues to EXTRA_DIST.
Arnaud Fontaine [Wed, 25 Jan 2012 08:18:20 +0000 (17:18 +0900)]
Add xkb_internals and xkb_issues to EXTRA_DIST.

12 years agoUpdate use of error_connection under WIN32 to _xcb_conn_ret_error()
Jon TURNEY [Tue, 17 Jan 2012 20:59:56 +0000 (20:59 +0000)]
Update use of error_connection under WIN32 to _xcb_conn_ret_error()

Unfortunately, commit 31b57676 adding WSACleanup/WSAShutdown on Win32 adds a new use
of error_connection, which was removed in commit 769acff0, applied 5 minutes earlier.

src/xcb_util.c: In function 'xcb_connect_to_display_with_auth_info':
src/xcb_util.c:433:39: error: 'error_connection' undeclared (first use in this function)

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Arvind Umrao <arvind.umrao@oracle.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
12 years agoFix build of xcb_auth.c with XDMCP on WIN32
Jon TURNEY [Wed, 18 Jan 2012 14:11:07 +0000 (14:11 +0000)]
Fix build of xcb_auth.c with XDMCP on WIN32

Fix a redefinition problem which shows up when building for _WIN32 and
libXdmcp is installed, so HASXDMAUTH is enabled

It seems this is a special place in xcb as it uses other X11 library headers here

If HASXDMAUTH is defined, include the wrapped windows.h before any header which
includes it unwrapped, to avoid conflicts with types defined in X headers

We need to include config.h and check HASXDMAUTH to avoid an unconditional dependency
on x11proto headers

In file included from install/include/X11/Xdmcp.h:19:0,
                 from git/xcb/libxcb/src/xcb_auth.c:52:
install/include/X11/Xmd.h:120:14: error: conflicting types for 'INT32'
/usr/i686-pc-mingw32/sys-root/mingw/include/basetsd.h:54:13: note: previous declaration of 'INT32' was here
install/include/X11/Xmd.h:143:15: error: conflicting types for 'BOOL'
/usr/i686-pc-mingw32/sys-root/mingw/include/windef.h:234:17: note: previous declaration of 'BOOL' was here

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
12 years agoRevert "Fix include order with Xdmcp on WIN32"
Jeremy Huddleston [Wed, 18 Jan 2012 07:55:23 +0000 (23:55 -0800)]
Revert "Fix include order with Xdmcp on WIN32"

This reverts commit 0e9246def562be97cc816f824f702233a826ec56.

This change caused build failures because <X11/Xdmcp.h> was never
included under any circumstance.  This is because the check for
HASXDMAUTH was moved before the inclusion of config.h (via xcbint.h)
which defined it.

Found-by: Tinderbox
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
12 years agoBump xcb-proto requirement
Julien Danjou [Thu, 12 Jan 2012 09:25:07 +0000 (10:25 +0100)]
Bump xcb-proto requirement

We are now unable to build xcb-proto before 1.7.

Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoRelease libxcb 1.8
Julien Danjou [Wed, 11 Jan 2012 17:27:38 +0000 (18:27 +0100)]
Release libxcb 1.8

Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoUse WSAStartup()/WSACleanup() on WIN32
Ryan Pavlik [Wed, 11 Jan 2012 17:06:50 +0000 (18:06 +0100)]
Use WSAStartup()/WSACleanup() on WIN32

The alternative is to use these in every WIN32 application which uses xcb. Doing
it this way should be safe, as, according to MSDN, "There must be a call to
WSACleanup for each successful call to WSAStartup. Only the final WSACleanup
function call performs the actual cleanup. The preceding calls simply decrement
an internal reference count"

(We should probably also include ws2_32 in Libs.private for libxcb, as anything
which links with libxcb will also need that, but there seems to be some pkg-config
issues to resolve first...)

v2: Check for errors so WSAStartup()/WSACleanup() uses are balanced
v3: Use same indentation style as surrounding code

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoFix include order with Xdmcp on WIN32
Ryan Pavlik [Thu, 5 Jan 2012 20:57:53 +0000 (20:57 +0000)]
Fix include order with Xdmcp on WIN32

Fix a redefinition problem due to include order which shows up when
building for _WIN32 and libXdmcp is installed, so HASXDMAUTH is enabled

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoFix WIN32 compilation after commit 163c47bdc0d32785d831e4c93fea9ab7e023446b
Jon TURNEY [Thu, 5 Jan 2012 20:57:52 +0000 (20:57 +0000)]
Fix WIN32 compilation after commit 163c47bdc0d32785d831e4c93fea9ab7e023446b

WIN32 does not have arpa/inet.h, so do not try to include it unless _WIN32 is
not defined

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoAdded more error states and removed global error_connection
Arvind Umrao [Fri, 4 Nov 2011 10:12:05 +0000 (15:42 +0530)]
Added more error states and removed global error_connection

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=41443
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=42304

I have added more xcb connection error states at xcb.h header.
Also I have removed global error_connection variable, and added
an interface that returns connection error state.

TBD:
I will segregate errors states in a separate header file and try to
provide more precise error states, in future. Also I will give patch
for libX11, in that patch xcb_connection_t::has_error will be passed
to default io handler of libX11. This value can then be used for
displaying error messages.

Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Arvind Umrao <arvind.umrao@oracle.com>
12 years agoMake xcb_take_socket keep flushing until idle
Keith Packard [Thu, 1 Dec 2011 10:28:51 +0000 (10:28 +0000)]
Make xcb_take_socket keep flushing until idle

_xcb_out_flush_to will drop the iolock in pthread_cond_wait allowing
other threads to queue new requests. When this happened,
there would be requests queued for the socket after _xcb_out_flush_to
returned, and xcb_take_socket would throw an assert.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=29875
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
12 years agoFix a dead-lock due to xcb_poll_for_reply
Uli Schlachter [Thu, 25 Aug 2011 12:18:16 +0000 (14:18 +0200)]
Fix a dead-lock due to xcb_poll_for_reply

Imagine two threads:

Thread#1: for(;;) { xcb_get_input_focus_reply(c, xcb_get_input_focus(c), 0); }

Thread#2: for(;;) { xcb_poll_for_event(c); }

Since xcb_poll_for_event() calls _xcb_in_read() directly without synchronizing
with any other readers, this causes two threads to end up calling recv() at the
same time. We now have a race because any of these two threads could get read
the GetInputFocus reply.

If thread#2 reads this reply, it will be put in the appropriate queue and
thread#1 will still be stuck in recv(), although its reply was already received.
If no other reply or event causes this thread to wake up, the process deadlocks.

To fix this, we have to make sure that there is only ever one thread reading
from the connection. The obvious solution is to check in poll_for_next_event()
if another thread is already reading (in which case c->in.reading != 0) and not
to read from the wire in this case.

This solution is actually correct if we assume that the other thread is blocked
in poll() which means there isn't any data which can be read. Since we already
checked that there is no event in the queue this means that
poll_for_next_event() didn't find any event to return.

There might be a small race here where the other thread already determined that
there is data to read, but it still has to wait for c->iolock. However, this
means that the next poll_for_next_event() will be able to read the event, so
this shouldn't cause any problems.

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

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Peter Harris <pharris@opentext.com>