Compare commits

...

447 Commits
1.1 ... master

Author SHA1 Message Date
Frederik Hertzum 93e6da2e2e added wrap file 2025-08-12 22:52:42 +02:00
Samuel Thibault 6a7661f60a Get rid of PATH_MAX
There could be no upper limit on the length of a path according
to POSIX, therefore these macros may not be defined at all on
some systems (such as GNU Hurd). There is however a limit on
sizeof(struct sockaddr_un.sun_path), so use it.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/65>
2025-07-08 23:05:34 +02:00
Alan Coopersmith daf2c53976 add pure & const function attributes suggested by gcc -Wsuggest-attribute
This only covers the ones in the pre-written code.  There are many more
suggested in the generated code, which will require changing the generator
and will thus be handled separately.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/64>
2024-12-15 10:17:22 -08:00
Alan Coopersmith 021e887de9 xcb.h: use __has_attribute to check for attribute((__packed__)) support
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/64>
2024-12-15 10:17:22 -08:00
Alan Coopersmith 124690ba63 xcb.h: remove __solaris__ ifdef
Nothing was defining __solaris__ on Solaris in current build setup, and
it's not needed on Solaris 10 (released 2005) and later, which has
stdint.h.  (Solaris 2.6 - 9 had inttypes.h, but no stdint.h.)

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/64>
2024-12-15 10:17:22 -08:00
Xi Ruoyao ebea71700f c_client.py: Always open output files in UTF-8
The UTF-8 quotes can appear in man pages etc as well, not only C code.
For example, in xcb_composite_redirect_subwindows.3:

    xcb_composite_redirect_subwindows - Redirect all current and future
    children of ‘window’

Note that window is quoted by a pair of UTF-8 single quotes.

Closes: #72
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/60>
2024-06-06 03:11:02 +08:00
Matt Turner 622152ee42 libxcb 1.17.0 2024-04-15 14:53:31 +00:00
Matt Turner 4574ab269b configure.ac: Require xcb-proto >= 1.17.0
Signed-off-by: Matt Turner <mattst88@gmail.com>
2024-04-15 14:53:31 +00:00
Uli Schlachter b78d304531 Always write C code in UTF-8
Some people apparently use non-utf8 locales and this caused errors when
xcb-proto started using some "fancy" quote marks. Fix this by always
using utf8 encoding.

Fixes: https://gitlab.freedesktop.org/xorg/lib/libxcb/-/issues/72
Signed-off-by: Uli Schlachter <psychon@znc.in>
2024-04-15 14:40:41 +00:00
Erik Kurzinger 389f22d1cb Add xcb-dri3 dependency to xcb-present.pc.in
Present version 1.4 introduces a dependency on DRI3 for the DRI3Syncobj
protocol type.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
2024-03-20 07:06:12 -07:00
Alan Coopersmith 86a478032b xcb_popcount: Use __builtin_popcount if compiler supports it
If the compiler knows of a better implementation for counting the number
of bits set in a word for the target CPU, let it use that, instead of the
classic algorithm optimized for PDP-6.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-03-08 22:11:43 +00:00
Alan Coopersmith c268499c30 tests: fix -Werror=discarded-qualifiers errors in check_public.c
check_public.c: In function ‘parse_display_pass’:
check_public.c:32:32: error: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   32 |                         putenv("DISPLAY=");
      |                                ^~~~~~~~~~
In file included from check_public.c:4:
/usr/include/stdlib.h:148:19: note: expected ‘char *’ but argument is of type ‘const char *’
  148 | extern int putenv(char *);
      |                   ^~~~~~
check_public.c:57:16: error: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   57 |         putenv("DISPLAY=");
      |                ^~~~~~~~~~
/usr/include/stdlib.h:148:19: note: expected ‘char *’ but argument is of type ‘const char *’
  148 | extern int putenv(char *);
      |                   ^~~~~~
check_public.c: In function ‘parse_display_fail’:
check_public.c:73:32: error: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   73 |                         putenv("DISPLAY=");
      |                                ^~~~~~~~~~
/usr/include/stdlib.h:148:19: note: expected ‘char *’ but argument is of type ‘const char *’
  148 | extern int putenv(char *);
      |                   ^~~~~~
check_public.c:99:16: error: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   99 |         putenv("DISPLAY=");
      |                ^~~~~~~~~~
/usr/include/stdlib.h:148:19: note: expected ‘char *’ but argument is of type ‘const char *’
  148 | extern int putenv(char *);
      |                   ^~~~~~
check_public.c: In function ‘public_suite’:
check_public.c:244:16: error: passing argument 1 of ‘putenv’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
  244 |         putenv("DISPLAY=");
      |                ^~~~~~~~~~
/usr/include/stdlib.h:148:19: note: expected ‘char *’ but argument is of type ‘const char *’
  148 | extern int putenv(char *);
      |                   ^~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-03-02 11:47:47 -08:00
Alan Coopersmith c671b9b30a
libxcb 1.16.1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-03-02 11:13:37 -08:00
Fergus Dall 3c946010c8 Enable large file support
Signed-off-by: Fergus Dall <sidereal@google.com>
2023-11-07 17:42:42 +11:00
Peter Williams 02a7bbed39 Fix compilation on Windows
Merge request !30 broke compilation on Windows by introducing unbalanced
curly braces. This change restores the previous behavior on Windows:
only TCP is supported.
2023-08-28 18:01:39 +00:00
Alan Coopersmith 18c3f055e7 gitlab CI: use latest xcbproto from git to build against
Closes issue #70

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-08-20 11:36:40 -07:00
Thomas Klausner 453115f7ee configure.ac: drop `pthread-stubs` dependency on NetBSD 2023-08-20 17:38:39 +00:00
Alan Coopersmith f11691a098 gitlab CI: regenerate container used for builds
This updates the included xcb-proto to the newly required 1.16.
As explained in issue #70, this is a quick workaround, not the
long-term fix for this problem.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-08-20 10:30:11 -07:00
Matt Turner cc4b93c9cd libxcb 1.16
Signed-off-by: Matt Turner <mattst88@gmail.com>
2023-08-16 16:18:09 -04:00
Matt Turner 1519334652 configure.ac: Require xcb-proto >= 1.16.0
Signed-off-by: Matt Turner <mattst88@gmail.com>
2023-08-16 16:18:09 -04:00
Ilya Pominov 038636786a c_client: Fix crash in xcb_randr_set_monitor
Take into account c_need_sizeof when evaluating
xcb_protocol_request_t.count

Incorrect xcb_protocol_request_t.count causes a segmentation fault when
calling functions:
- xcb_randr_set_monitor{_checked}
- xcb_input_change_feedback_control{_checked}
- xcb_input_change_device_control{_unchecked}

Steps to reproduce:
Call xcb_randr_set_monitor() with valid arguments

OBSERVED RESULT
Segmentation fault
```
Process terminating with default action of signal 11 (SIGSEGV)
  Access not within mapped region at address 0x780
    at 0x4852925: memmove (in /usr/libexec/valgrind/vgpreload_memcheck-
amd64-linux.so)
    by 0x486967C: memcpy (string_fortified.h:29)
    by 0x486967C: send_request (xcb_out.c:59)
    by 0x486967C: send_request (xcb_out.c:46)
    by 0x486967C: xcb_send_request_with_fds64 (xcb_out.c:338)
    by 0x48699FC: xcb_send_request (xcb_out.c:359)
    by 0x4891F11: xcb_randr_set_monitor_checked (randr.c:5350)
```

EXPECTED RESULT
Function returns cookie

Amend: 77b594f958

Signed-off-by: Ilya Pominov <ipominov@astralinux.ru>
2023-04-10 20:06:52 +03:00
Demi Marie Obenour 8935793f1f Add tests for unix socket parsing
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-03-25 15:27:50 -04:00
Demi Marie Obenour 095255531b DISPLAY starting with / or unix: is always a socket path
If DISPLAY starts with / or unix:, do not check for anything but a full
filesystem socket path.  In particular, abstract AF_UNIX sockets and TCP
sockets will not be used in this case.   Also be stricter about parsing
the screen part of /path.screen displays, and bail out after all stat()
errors other than ENOENT.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-03-25 13:15:08 -04:00
Demi Marie Obenour ccdef1a8a5 Allow full paths to sockets on non-macOS
When combined with xorg/lib/libxtrans!7, this allows CVE-2020-25697 to
be mitigated by placing the AF_UNIX socket in a secure directory on the
filesystem.

This enables HAVE_LAUNCHD unconditionally and deletes the configure
switch.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-03-25 13:15:08 -04:00
Matthieu Herrb 18e109d755 Fix xcb_connect() call with a custom xcb_auth_info_t
If the function implementing xcb_connect is called directly with a
custom xcb_auth_info_t then checking that the screen in $DISPLAY
is valid is skipped.

Reported by chohag AT jtan DOT com

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2023-02-28 14:21:07 +01:00
Jan Beich fd04ab24a5 configure.ac: drop `pthread-stubs` dependency on DragonFly and FreeBSD
All `pthread_*` symbols used by libxcb have stubs in libc. So, stop
linking against libpthread.
2023-02-11 18:15:23 +00:00
Alan Coopersmith 4d1a578dd5 Raise minimum required version of Python from 2.6 to 3.0
Trying to build with Python 2.7.14 fails with:
  File "./c_client.py", line 2270
    key = (*self.name[:-1], field.enum)
           ^
SyntaxError: invalid syntax

Fixes: 33f3dbe ("Fix handling of documented enum parameters")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-02-09 14:58:12 -08:00
Alan Coopersmith e2a3e80eb8 configure.ac: Remove obsolete AC_HEADER_STDC
Nothing checks for the STDC_HEADERS flag this set, and all supported
systems have C89 compatible headers now.

Clears autoconf warnings of:
configure.ac:93: warning: The macro `AC_HEADER_STDC' is obsolete.
configure.ac:93: You should run autoupdate.
./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from...
configure.ac:93: the top level

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-02-06 15:55:23 -08:00
Daniel G 3333d5bde8 Fix indentation. 2023-01-09 16:21:35 +00:00
Daniel G 973b510e95 Fix windows build. 2023-01-07 19:35:47 +00:00
Jeremy Huddleston Sequoia cb8c70f5a6
xcb_conn: Add a check for NULL to silence a UBSan runtime error
xcb_conn.c:314:60: runtime error: applying zero offset to null pointer

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2022-11-26 22:48:00 -08:00
Demi Marie Obenour 33f3dbe369 Fix handling of documented enum parameters
Previously this would crash the code generator.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2022-10-16 15:44:42 -04:00
Demi Marie Obenour c9513aac2d Fix a compiler warning
The warning is harmless but annoying.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2022-10-16 01:55:30 -04:00
Alan Coopersmith 06e1ef43bb configure.ac: drop dependency `pthread-stubs` on Solaris
On Solaris 10 and later, the pthread functions are directly in libc,
and libpthread only has metadata to redirect calls from it to the
libc functions.

On Solaris 9 and older (no longer supported), libc contained its own
thread stubs that libpthread then overrode.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-10-04 11:30:09 -07:00
PaperChalice d53ad60d77 configure.ac: drop dependency `pthread-stubs` on macOS
`libpthread.dylib` on macOS is an alias of `libSystem.B.dylib`,
every program should link against `libSystem.B.dylib`.
2022-09-28 22:55:38 +00:00
Uli Schlachter e2ee5aabe9 Improve tutorial example
This tutorial example only handles XCB_EXPOSURE and XCB_KEY_RELEASE
events and ignores everything else. Thus, there is no point in asking
for more kinds of events.

A while ago, I ported this tutorial to x11rb [1]. Recently, I received a
pull request [2] removing these unnecessary event masks. This commit is
thus only partially by me and the 'issue' was originally found by the
author of [2].

[1]: https://github.com/psychon/x11rb/blob/master/x11rb/examples/tutorial.rs
[2]: https://github.com/psychon/x11rb/pull/754

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-09-28 22:39:32 +00:00
Mihail Konev 9dcb081708 autogen: add default patch prefix
Signed-off-by: Mihail Konev <k.mvc@ya.ru>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-07-24 14:26:03 -07:00
Emil Velikov 7d798d3ccb autogen.sh: use quoted string variables
Place quotes around the $srcdir, $ORIGDIR and $0 variables to prevent
fall-outs, when they contain space.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-07-24 14:25:54 -07:00
Peter Hutterer 7071b4a13c autogen.sh: use exec instead of waiting for configure to finish
Syncs the invocation of configure with the one from the server.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-07-24 14:25:53 -07:00
Alan Coopersmith ee60239b73 gitlab CI: add a basic build test
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-07-18 17:55:43 -07:00
Mike Sharov 3123dfe723 Require xcb-proto >= 1.15.1, which has Dbe
Signed-off-by: Mike Sharov <msharov@users.sourceforge.net>
2022-06-22 10:56:37 -04:00
Mike Sharov 816407655f Build DOUBLE-BUFFER extension.
Signed-off-by: Mike Sharov <msharov@users.sourceforge.net>
2022-06-02 13:27:48 -04:00
Matt Turner c2c4a2cd19 libxcb 1.15
Signed-off-by: Matt Turner <mattst88@gmail.com>
2022-05-03 15:09:54 -07:00
Hodong ddafdba11f Fix a memory leak
Signed-off-by: Hodong <hodong@yozmos.com>
2022-01-15 02:32:04 +09:00
Demi Marie Obenour 43fbf03e54 Fix integer overflows in xcb_in.c
This fixes an integer overflow security vulnerability in xcb_in.c, which
may allow for memory corruption.
2021-11-17 12:09:02 -05:00
Thomas Anderson 233d7b7f1f Fix hang in xcb_request_check()
This fixes https://gitlab.freedesktop.org/xorg/lib/libxcb/-/issues/53

The issue was that libxcb expected to get a reply based on the request_expected
variable, but a reply would never arrive because the request was never actually
written.  To resolve this, a separate request_expected_written variable is
added.
2021-09-30 23:32:35 +00:00
Ran Benita dc28118747 Avoid request counter truncation in replies map after 2**32 requests
The c->in request counters are uint64_t, and can realistically go over
2**32 over a lifetime of a client. The c->in->replies map however uses
unsigned int keys and the passed request numbers are silently truncated.

I haven't analyzed in depth what happens what it wraps around but it's
probably nothing good.

The only user of the xcb_list.c map code is c->in->replies, so just
change it to use uint64_t keys.

Reviewed-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-09-30 17:22:06 +00:00
Julien Cristau 26396bf156 Add newline when printing auth/connection failure string to stderr
The reason strings returned by the server don't all include a newline,
so make sure we add one to avoid confusing clients.  Xlib used to do
this before it delegated that work to libxcb.

Fixes #34

Signed-off-by: Julien Cristau <jcristau@debian.org>
2021-09-30 17:18:18 +00:00
Uli Schlachter a503167f75 Improve/fix docs for reply fds functions
Fixes: https://gitlab.freedesktop.org/xorg/lib/libxcb/-/issues/56
Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-09-20 18:40:08 +00:00
Povilas Kanapickas 3c76c0579f c_client.py: Implement handling of <length> element
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-07-30 22:58:47 +03:00
Povilas Kanapickas bdc3f21a52 c_client: Extract _c_get_field_mapping_for_expr() 2021-07-30 22:58:46 +03:00
Povilas Kanapickas 068af21cb3 c_client.py: Use get_expr_field_names directly to resolve list fields
Using get_expr_fields() is only needed in case we are doing things that
can span multiple types easily, e.g. when deciding what data to pass via
function parameters and so on.

In _c_serialize_helper_list_field() we are building function body, so
acquiring field names via get_expr_field_names() is enough.

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-07-30 22:58:45 +03:00
Povilas Kanapickas 4d678b162b c_client.py: Extract get_expr_field_names()
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-07-30 22:58:44 +03:00
Peter Harris 21414e7c44 Fix writev emulation on Windows
There are at least two bugs in the previous implementation:

- If an early iovec is partially written, there can be a gap of missing
  data (as a later iovec will be started before the early iovec is
  completed).
- If a late iovec returns WSAEWOULDBLOCK, *vector and *count are not
  updated, leading to a re-send of the entire request.

Move the *vector update into the send() loop to update piecemeal as
individual iovecs are sent.

Example program that demonstrates the issue (this program should run
forever after these bugs have been fixed):

#include <stdio.h>
#include <stdlib.h>
#include "xcb.h"

// Non-cryptographic random number generator from http://burtleburtle.net/bob/rand/smallprng.html
// because Microsoft's random number generators either have a too small RAND_MAX or are too slow
typedef struct ranctx { uint32_t a; uint32_t b; uint32_t c; uint32_t d; } ranctx;

static uint32_t ranval(ranctx *x);
static void raninit(ranctx *x, uint32_t seed);


#define MAX_PROP_LEN (128 * 1024)

int main(int argc, char *argv[]) {
    uint32_t seed = 0x12345678;
    if (argc > 1) {
        seed = strtoul(argv[1], NULL, 0);
    }
    ranctx ran;
    raninit(&ran, seed);

    xcb_connection_t *c = xcb_connect(NULL, NULL);
    if (!c || xcb_connection_has_error(c)) {
        printf("Cannot connect to $DISPLAY\n");
        return 1;
    }
    const xcb_setup_t *setup = xcb_get_setup(c);
    char *buf = malloc(MAX_PROP_LEN + 8); // plus a bit of slack so we can run random values off the end
    if (!buf) {
        printf("oom\n");
        return 1;
    }
    for (uint32_t i=0; i < (MAX_PROP_LEN + 3) / 4; i++) {
        ((uint32_t *)buf)[i] = ranval(&ran);
    }

    xcb_window_t win = xcb_generate_id(c);
    xcb_create_window(c, 0, win, xcb_setup_roots_iterator(setup).data[0].root, 0, 0, 1, 1, 0,
            XCB_WINDOW_CLASS_INPUT_ONLY, 0, 0, NULL);
    printf("Created window 0x%X\n", win);

    for (;;) {
        xcb_flush(c);
        xcb_generic_event_t *ev = xcb_poll_for_event(c);
        if (ev) {
            if (ev->response_type == 0) {
                xcb_generic_error_t *err = (xcb_generic_error_t *)ev;
                printf("Unexpected X Error %d\n", err->error_code);
                printf("   Sequence %d\n", err->sequence);
                printf("   Resource ID 0x%X\n", err->resource_id);
                printf("   Opcode: %d.%d\n", err->major_code, err->minor_code);
                return 1;
            }
            printf("Unexpected X Event %d\n", ev->response_type);
            return 1;
        }

        uint32_t siz = ranval(&ran) % MAX_PROP_LEN + 1;
        xcb_change_property(c, XCB_PROP_MODE_REPLACE, win, XCB_ATOM_STRING, XCB_ATOM_STRING, 8, siz, buf);
    }

    return 0;
}


#define rot(x,k) (((x)<<(k))|((x)>>(32-(k))))
static uint32_t ranval(ranctx *x) {
    uint32_t e = x->a - rot(x->b, 27);
    x->a = x->b ^ rot(x->c, 17);
    x->b = x->c + x->d;
    x->c = x->d + e;
    x->d = e + x->a;
    return x->d;
}

static void raninit(ranctx *x, uint32_t seed) {
    uint32_t i;
    x->a = 0xf1ea5eed, x->b = x->c = x->d = seed;
    for (i = 0; i<20; ++i) {
        (void)ranval(x);
    }
}

Signed-off-by: Peter Harris <pharris@opentext.com>
2021-06-04 14:31:13 +00:00
Peter Harris 4b0d9d3868 Fix build on Windows
Notable changes: Protect include of unistd.h (and other POSIX headers).
Use SOCKET (which is larger than int) and closesocket (because close is
not compatible) for sockets. Use <stdint.h>'s intptr_t instead of the
non-portable ssize_t.

Signed-off-by: Peter Harris <pharris@opentext.com>
2021-06-04 14:31:13 +00:00
Alan Coopersmith cd0fba98a2 xcb_auth: Quiet -Wimplicit-fallthrough warning in get_authptr()
xcb_auth.c:135:14: warning: this statement may fall through [-Wimplicit-fallthrough=]
         addr += 12;
         ~~~~~^~~~~
xcb_auth.c:138:5: note: here
     case AF_INET:
     ^~~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2021-06-01 18:40:59 -07:00
Julien Cristau 2ef8655987 Increment libtool version info for libxcb-dri3
Somewhat belatedly given the last update was in xcb-proto 1.13 in 2017...

Quoting @smcv from https://bugs.debian.org/921069:
>>>
libxcb-dri3 version 1.13 appears to have added new symbols without increasing
the minor ABI version in its -version-info. This will break anything that
compares libraries by their version info to decide which one is newer.

The Steam Runtime uses libraries' major/minor/micro ABI version info (in this
case 0.0.0) to decide whether to use the system copy of a library or the copy
in the Steam Runtime, depending on which one is newer (#921026). We can
work around this by adding a versioned dependency on libxcb-dri3-0 and
deleting the copy from the Steam Runtime, but this isn't a particularly
scalable solution.
>>>
2021-02-02 10:00:23 +01:00
Ran Benita 4cbcac4eca gitignore: add files generated by make check
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-18 23:06:32 -05:00
Ran Benita f01f3c378e tests: don't use deprecated fail_unless check API
It causes errors like this when running make check:

check_public.c:40:24: error: too many arguments for format [-Werror=format-extra-args]
   40 |   fail_unless(success, "unexpected parse failure %sfor '%s'", test_string[test_type], name);

Closes: https://gitlab.freedesktop.org/xorg/lib/libxcb/-/issues/49
Tested-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-11-18 23:06:05 -05:00
Eduardo Sánchez Muñoz 704e0a91b1 Use the 'present' field to properly check that the XC-MISC
extension is available in xcb_generate_id.

Also document the returned value when xcb_generate_id fails.
2020-03-02 19:01:41 +01:00
Matt Turner 4b40b44cb6 Release libxcb 1.14
Signed-off-by: Matt Turner <mattst88@gmail.com>
2020-02-22 12:20:08 -08:00
Matt Turner 78c492deaa Build xz tarballs instead of bzip2
Signed-off-by: Matt Turner <mattst88@gmail.com>
2020-02-22 12:20:08 -08:00
Matt Turner 8f7e4c4e9f configure.ac: Depend on pthread-stubs only on not-Linux
Signed-off-by: Matt Turner <mattst88@gmail.com>
2020-02-22 11:35:44 -08:00
Sam Varshavchik f9f4b00aad Implement xcb_total_read() and xcb_total_written().
Returns raw byte counts that have been read or written to the
xcb_connection_t.

I found it very useful when developing a high level widget toolkit, to
track down inefficient/sub-optimum code that generates a lot of X
protocol traffic.

Signed-off-by: Sam Varshavchik <mrsam@courier-mta.com>
2020-02-22 19:12:51 +00:00
A. Wilcox 59e271e15b tests: Support Check 0.13.0 API
[mattst88]: Keep compatibility 	with old API via preprocessor

Fixes: #43
2020-02-22 11:02:09 -08:00
Martin Dørum 21324989b7 Handle EINTR from recvmsg in _xcb_in_read
I have a GTK application which occasionally crashes with an "interrupted
system call" g_message from gdk. After a lot of debugging, I've found
that the call to recvmsg in _xcb_in_read occasionally fails with EINTR,
and instead of retrying the system call, xcb would just shut down the
connection.

This change makes _xcb_in_read treat EINTR the same as it would treat
EAGAIN; it returns 1 and libX11 ends up calling xcb_poll_for_event
again (from what I have understood).

I have spoken with a few people who think recvmsg failing with EINTR in
this case shouldn't ever happen, and I don't know enough to agree or
disagree with that. In case anyone wants to dig further and try to
figure out why the recvmsg call sometimes fails with EINTR, here's the
backtrace from inside of _xcb_in_read where that happened:

Thread 1 "beanbar" hit Breakpoint 1, _xcb_in_read (c=c@entry=0x55ecbe4aba80) at xcb_in.c:1059
1059                fprintf(stderr, "Hello World am %s:%i, errno is %s\n", __FILE__, __LINE__, strerror(errno));
(gdb) bt
0  0x00007fa48fa48639 in _xcb_in_read (c=c@entry=0x55ecbe4aba80) at xcb_in.c:1059
1  0x00007fa48fa489d8 in poll_for_next_event (c=0x55ecbe4aba80, queued=queued@entry=0) at xcb_in.c:352
2  0x00007fa48fa48a3d in poll_for_next_event (queued=0, c=<optimized out>) at xcb_in.c:722
3  0x00007fa48fa48a3d in xcb_poll_for_event (c=<optimized out>) at xcb_in.c:722
4  0x00007fa4908d1b7e in poll_for_event (dpy=dpy@entry=0x55ecbe4a9730, queued_only=queued_only@entry=0) at xcb_io.c:245
5  0x00007fa4908d1cf0 in poll_for_response (dpy=dpy@entry=0x55ecbe4a9730) at xcb_io.c:303
6  0x00007fa4908d1fed in _XEventsQueued (mode=2, dpy=0x55ecbe4a9730) at xcb_io.c:363
7  0x00007fa4908d1fed in _XEventsQueued (dpy=dpy@entry=0x55ecbe4a9730, mode=mode@entry=2) at xcb_io.c:344
8  0x00007fa4908c3d47 in XPending (dpy=0x55ecbe4a9730) at Pending.c:55
9  0x00007fa493cadbc7 in  () at /usr/lib/libgdk-3.so.0
10 0x00007fa49234d08a in g_main_context_prepare () at /usr/lib/libglib-2.0.so.0
11 0x00007fa49234d6e6 in  () at /usr/lib/libglib-2.0.so.0
12 0x00007fa49234d8ae in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
13 0x00007fa4938b920e in g_application_run () at /usr/lib/libgio-2.0.so.0
14 0x000055ecbc820af4 in main (argc=1, argv=0x7ffd06238098) at src/main.c:190

Signed-off-by: Martin Dørum <martid0311@gmail.com>
2019-05-19 16:05:08 +02:00
Jon Turney 656c08c542
Include time.h before using time()
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2019-04-25 17:30:16 +01:00
Alan Coopersmith be1745c8eb Add README.md to EXTRA_DIST
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-17 12:23:17 -08:00
Eduardo Sánchez Muñoz 58f37377c8 Add "ge.*" to src/.gitignore 2019-02-17 13:33:12 +01:00
Alan Coopersmith 7bac366953 Update README for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-16 13:41:28 -08:00
Alan Coopersmith 02ff3eadf4 Update configure.ac bug URL for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-02-16 13:35:06 -08:00
Alan Coopersmith 542befe40a c_client: fix "adress" typo
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-01-07 14:42:53 -08:00
Uli Schlachter 8287ebd7b7 Release libxcb 1.13.1 2018-09-27 14:04:17 +02:00
Erik Kurzinger bbda345a71 don't flag extra reply in xcb_take_socket
If any flags are specified in a call to xcb_take_socket,
they should only be applied to replies for requests sent
after that function returns (and until the socket is
re-acquired by XCB).

Previously, they would also be incorrectly applied to the
reply for the last request sent before the socket was taken.
For instance, in this example program the reply for the
GetInputFocus request gets discarded, even though it was
sent before the socket was taken. This results in the
call to retrieve the reply hanging indefinitely.

static void return_socket(void *closure) {}

int main(void)
{
    Display *dpy = XOpenDisplay(NULL);
    xcb_connection_t *c = XGetXCBConnection(dpy);

    xcb_get_input_focus_cookie_t cookie = xcb_get_input_focus_unchecked(c);
    xcb_flush(c);

    uint64_t seq;
    xcb_take_socket(c, return_socket, dpy, XCB_REQUEST_DISCARD_REPLY, &seq);

    xcb_generic_error_t *err;
    xcb_get_input_focus_reply(c, cookie, &err);
}

In practice, this has been causing intermittent KWin crashes when
used in combination with the proprietary NVIDIA driver such as
https://bugs.kde.org/show_bug.cgi?id=386370 since when Xlib fails to
retrieve one of these incorrectly discarded replies it triggers
an IO error.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-08-21 18:57:01 +02:00
Daniel Stone 7e0f166579 Release libxcb 1.13
Signed-off-by: Daniel Stone <daniels@collabora.com>
2018-02-28 17:24:53 +00:00
Daniel Stone a3e9821bec c_client: Add support for lists of FDs
Matching xcbgen changes, add support having a ListType which contains
file descriptors. Use this to send a variable number of FDs to the
server, including when the list size is not fixed.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2017-06-05 20:36:50 +01:00
Daniel Stone c7aa4e682f c_client: Don't serialise non-wire fields
For when we have a variable-sized field followed by a fixed field, make
sure we do not serialise non-wire fields.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2017-06-05 20:36:50 +01:00
Christian Linhart d10194a321 enable xinput by default
Support for the xinput extension is complete now,
as far as I can tell.

According to our discussion on the list, we enable it now.

Signed-off-by: Christian Linhart <chris@demorecorder.com>
2017-05-13 10:56:24 +02:00
David McFarland fad81b6342 read from connection when polling special events and replies
Using the mesa vulkan driver, if you acquire an image from a
swapchain using a finite timeout (x11_acquire_next_image_poll_x11),
it will occasionally lock, calling xcb_poll_for_special_event in
a loop until the timeout expires.

Call _xcb_in_read() once from the polling functions for special
events and replies, in the same way as xcb_poll_for_event.

Signed-off-by: David McFarland <corngood@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-05-13 09:34:31 +02:00
Tobias Stoeckmann f830eb93c9 Check strdup for NULL return value.
_xcb_open does not check strdup's return value for NULL if launchd suport
was configured.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-04-01 11:50:09 +02:00
Christian Linhart ee9dfc9a76 add support for eventstruct
eventstruct allows to use events as part of requests.
This is, e.g., needed by xcb_input_send_extension_event.

Signed-off-by: Christian Linhart <chris@demorecorder.com>
2017-03-11 10:51:50 +01:00
Christian Linhart 0c2c5d50f8 optionally build the GE extension
xcb contains an xml-definition for the GenericEvent extension
but this extension was neither generated nor built.

This patch enables optional building of the GenericEvent extension
with configure option --enable-ge

By default, the GenericEvent extension is not built.
Normally this is not needed by application programs
because there is implicit support for the GE-extension
for the specific events built with this extension.

But it may be useful for X-protocol analyzers and stuff like that.

Signed-off-by: Christian Linhart <chris@demorecorder.com>
2017-03-11 10:51:33 +01:00
Christian Linhart 9bce1f72e3 move symbol lookup of sumof expr to the parser
replace the complicated symboltable lookup for sumof expr
by accessing the lenfield of the expr-object.

This requires the corresponding patch for xcb/proto
which sets the lenfield accordingly.

This should be OK because for official releases we define
that dependency in the build system.

For getting versions off the HEAD of the git repo, it should
be obvious that xcb/proto and xcb/libxcb have to be updated together.

I have tested this patch and it generates exactly the same code
as before.

Tested-by: Christian Linhart <chris@demorecorder.com>
Signed-off-by: Christian Linhart <chris@demorecorder.com>
2017-03-11 10:51:11 +01:00
Alan Coopersmith 65b298c7ca Correct @param "e" to "error" in xcb_poll_for_reply*()
Found by clang -Wdocumentation:

./xcbext.h:271:11: warning: parameter 'e' not found in the function
      declaration [-Wdocumentation]
 * @param e Location to store errors in, or NULL. Ignored for un...
          ^
./xcbext.h:271:11: note: did you mean 'error'?
 * @param e Location to store errors in, or NULL. Ignored for un...
          ^
          error

./xcbext.h:283:11: warning: parameter 'e' not found in the function
      declaration [-Wdocumentation]
 * @param e Location to store errors in, or NULL. Ignored for un...
          ^
./xcbext.h:283:11: note: did you mean 'error'?
 * @param e Location to store errors in, or NULL. Ignored for un...
          ^
          error

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-05-29 15:56:25 +02:00
Alan Coopersmith 32a9084546 Remove : from @param names in manually written headers
Makes style match the @param names in autogenerated headers and makes
clang -Wdocumentation stop complaining about all of them:

./xcb.h:523:11: warning: parameter 'display:' not found in the function
      declaration [-Wdocumentation]
 * @param display: A pointer to the display number.
          ^~~~~~~~
./xcb.h:523:11: note: did you mean 'display'?
 * @param display: A pointer to the display number.
          ^~~~~~~~
          display

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-05-29 15:56:07 +02:00
Thomas Klausner 8740a288ca Fix inconsistent use of tabs vs. space.
Needed for at least python-3.5.x.

Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-05-28 12:20:59 +02:00
Uli Schlachter d34785a34f Release libxcb 1.12
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-05-18 18:43:38 +02:00
Uli Schlachter b11fca06f7 Bump xcb-proto requirement to 1.12
This is needed due to various changes that were done to the XML schema.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-05-14 10:33:54 +02:00
Mark Kettenis 095353ff1a Increase unix socket send buffer to at least 64KB
Some systems (e.g. OpenBSD) have a rather small default socket send buffer
size of 4KB.  The result is that sending requests with a largish payload
requires serveral writev(2) system calls.  Make sure the socket send buffer
is at least 64KB such that we're likely to succeed with a single system
call for most requests.  A similar change was made to the xtrans code
some time ago.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
2016-02-01 09:10:04 +01:00
Christian Linhart b3516102b4 do not serialize pads by default anymore
Pads should not be serialized/deserialized to maintain
ABI compatibility when adding explicit align pads.

Therefore this pad switches off serialization of pads
unless it is enforced by serialize=true in the xml-definition
of that pad

Signed-off-by: Christian Linhart <chris@demorecorder.com>
2016-02-01 07:53:28 +01:00
Jaya Tiwari c03388ff9e calculate lengthless list
Some rework done by Christian Linhart

Signed-off-by: Jaya Tiwari <tiwari.jaya18@gmail.com>
Signed-off-by: Christian Linhart <chris@demorecorder.com>
2016-01-06 02:34:28 +01:00
Christian Linhart 7758257567 Fix handling of align-pads in end-iterators
If a list is preceded by an align-pad, then
accessor for the end-iterator returned a wrong
value.

Reason: the length of the align-iterator was added
to a pointer of list-member type. Therefore, the length
was multiplied by the size of the list-member type,
due to C pointer arithmetic rules.

This has looked like the following, e.g., in
xcb_randr_get_crtc_transform_pending_params_end:

i.data = ((xcb_render_fixed_t *) prev.data) + ((-prev.index) & (4 - 1)) + (R->pending_nparams);

This bug was introduced with the following commit:
http://cgit.freedesktop.org/xcb/libxcb/commit/?id=4033d39d4da21842bb1396a419dfc299591c3b1f

The fix handles this by casting to char* before adding the align,
and then casting the result to the member type.

Signed-off-by: Christian Linhart <chris@demorecorder.com>
2016-01-06 02:23:28 +01:00
Christian Linhart 32a2189183 set the align-offset as provided by proto
instead of using the lower bits of the pointer address.
This fixes a bug reported by Peter Hutterer in off-list communication
back in June 2015.

This requires the alignment-checker patches in xcb/proto.

Signed-off-by: Christian Linhart <chris@demorecorder.com>
2016-01-06 02:09:56 +01:00
Adam Jackson 6e0378ebbf Bump version to 1.11.90
We've released 1.11.1 and new libX11 wants that or better.  git master
will suffice, so bump the version number ahead of 1.11 branch.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2015-09-21 15:27:52 -04:00
Christian Linhart 4033d39d4d make lists after align-pads work
Handle align-pads when generating an end-function
in the same way as handling them when generating
an accessor or iterator function.

Signed-off-by: Christian Linhart <chris@demorecorder.com>
2015-08-13 18:06:43 +02:00
Christian Linhart b15c96f950 make support for server side stuff optional
and make it disabled by default with an EXPERIMENTAL warning

reason: this feature is unfinished and we want to have flexibility for
ABI/API changes, while still being able to make a release soon

Signed-off-by: Christian Linhart <chris@demorecorder.com>
2015-07-04 16:25:23 +02:00
Jon TURNEY c5d923d8ff Link with winsock library for socket functions on MinGW
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-07-04 16:14:05 +02:00
Uli Schlachter 5b40681c88 Fix a thread hang with xcb_wait_for_special_event()
Consider the following:

- Two threads are calling xcb_wait_for_special_event() and xcb_wait_for_reply()
  concurrently.
- The thread doing xcb_wait_for_reply() wins the race and poll()s the socket for
  readability.
- The other thread will be put to sleep on the special_event_cond of the special
  event (this is done in _xcb_conn_wait() via the argument
  xcb_wait_for_special_event() gives it).
- The first thread gets its reply, but does not yet receive any special event.

In this case, the first thread will return to its caller. On its way out, it
will call _xcb_in_wake_up_next_reader(), but that function cannot wake up
anything since so far it did not handle xcb_wait_for_special_event().

Thus, the first thread stays blocked on the condition variable and no thread
tries to read from the socket.

A test case demonstrating this problem is available at the bug report.

Fix this similar to how we handle this with xcb_wait_for_reply():

The function wait_for_reply() adds an entry into a linked list of threads that
wait for a reply. Via this list, _xcb_in_wake_up_next_reader() can wake up this
thread so that it can call _xcb_conn_wait() again and then poll()s the socket.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84252
Signed-off-by: Uli Schlachter <psychon@znc.in>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2015-06-25 20:38:48 +02:00
Michel Dänzer f85661c3bc Call _xcb_wake_up_next_reader from xcb_wait_for_special_event
All functions calling _xcb_conn_wait() must make sure that waiting
readers are woken up when we read a reply or event that they are waiting
for. xcb_wait_for_special_event() did not do so. This adds the missing
call to_xcb_in_wake_up_next_reader().

Fixes deadlock when waiting for a special event and concurrently
processing the display connection queue in another thread.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84252
Tested-by: Thomas Daede <bztdlinux@gmail.com>
Tested-by: Clément Guérin <geecko.dev@free.fr>
Reviewed-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-06-12 09:45:16 +02:00
Uli Schlachter 8584c0e095 send_fds(): Handle too many outstanding FDs to send
Before this patch, the following code caused an endless loop in send_fds(),
because the queue of FDs to send was eventually full, but _xcb_out_flush_to()
didn't make any progress, since there was no request to send:

   while (1) { xcb_send_fd(conn, dup(some_fd)); }

Fix this by sending a sync when flushing didn't make any progress. That way we
actually have something to send and can attach the pending FDs.

Because send_fds() can now send requests, the code in
xcb_send_request_with_fds64() has to be changed. It has to call send_fds()
before it establishes a good sequence number for the request it wants to send.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-06-12 09:39:13 +02:00
Uli Schlachter 658fb4a5f0 Code generator: Use xcb_send_request_with_fds()
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-06-12 09:39:13 +02:00
Uli Schlachter b15aa6bd4e Add xcb_send_request_with_fds() and *_with_fds64()
Doing xcb_send_fd(), xcb_send_request() is racy. If two threads do this at the
same time, they could mix up their file descriptors. This commit makes it
possibly to fix this race by providing a single function which does everything
that is needed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-06-12 09:39:12 +02:00
Uli Schlachter cc04cfb41b send_fds(): Make sure no other thread interrupts us
Two threads trying to send fds at the same time could interfere. To guarantee a
correct ordering, we have to use correct locking. The code in send_fds() missed
one case: If there was another thread already writing requests, we slept on the
"done with writing" condition variable (c->out.cond). This would allow other
threads to re-acquire the iolock before us and could cause fds to be sent out of
order.

To fix this, at the beginning of send_fds() we now make sure that no other
thread is already writing requests. This is what prepare_socket_request() does.
Additionally, it gets the socket back in case xcb_take_socket() was called,
which is a good thing, too, since fds are only sent with corresponding requests.
2015-06-12 09:39:12 +02:00
Uli Schlachter 25f9e7e45a xcb_send_fd(): Always close fds
The API docs for xcb_send_fd() says "After this function returns, the file
descriptor given is owned by xcb and will be closed eventually".

Let the implementation live up to its documentation. We now also close fds if fd
passing is unavailable (!HAVE_SENDMSG) and when the connection is in an error
state.

(This also does sneak in some preparatory functions for follow-up commits and
thus does things in a more complicated way than really necessary.)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-06-12 09:39:12 +02:00
Ran Benita bbdf1d133f c_client.py: don't generate useless empty /** < */ comments
(This does not change doxygen's output or warnings).

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-05-30 11:36:13 +02:00
Ran Benita ff6cb3913b c_client.py: use pattern matching with enumerate()
Signed-off-by: Ran Benita <ran234@gmail.com>
2015-05-30 11:16:43 +02:00
Christian Linhart cb621341a6 expose 64-bit sequence numbers for XLib
While XCB uses 64-bit sequence number internally, it only exposes
"unsigned int" so that, on 32-bit architecture, Xlib based applications
may see their sequence number wrap which causes the connection to the X
server to be lost.

Expose 64-bit sequence number from XCB API so that Xlib and others can
use it even on 32-bit environment.

This implies the following API addition:

  xcb_send_request64()
  xcb_discard_reply64()
  xcb_wait_for_reply64()
  xcb_poll_for_reply64()

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

Reviewed-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Christian Linhart <chris@demorecorder.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2015-04-08 11:55:48 +02:00
Alan Coopersmith c49aa98594 Escape \n to display properly in xcb-requests man page
In nroff, \n is a macro that "Interpolates number register x" (where x
is the character following the \n sequence), thus the man page currently
prints 0 instead of \n" in several lines, leading to output such as:

 printf("The _NET_WM_NAME atom has ID %u0, reply-⁠>atom);

It needs to be escaped here, as \\n, as is done in other examples in
this man page already.

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

Reported-by: Stefan Merettig
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2015-04-29 23:23:05 -07:00
Ran Benita a90be9955d c_client.py: make condition easier to follow in _c_complex()
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 12:25:58 +01:00
Ran Benita f9f925107e c_client.py: don't add /* <name> */ before references to 'S'
The name can be understood from the type of S already.

For examples, look for 'S->' in xkb.c or xinput.c.

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
Reviewed-by: Rémi Cardona <remi@gentoo.org>
2015-03-15 12:22:32 +01:00
Ran Benita 17f9bda6c2 c_client.py: remove duplicated `cookie_type` argument for requests
It is implied already inside the function by the `void` argument.

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 12:19:07 +01:00
Ran Benita c65005e9d0 c_client.py: spell out keyword arguments in c_request() for clarity
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 12:11:59 +01:00
Ran Benita 6872e92582 c_client.py: simplify _c_reply_has_fds()
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 12:05:37 +01:00
Ran Benita 8bf8b62316 c_client.py: remove commented debug statements
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 12:03:27 +01:00
Ran Benita ec435aebd6 c_client.py: use C99 initializers instead of comments
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 11:52:38 +01:00
Ran Benita 89498d1d45 c_client.py: remove end-of-function comments
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 11:42:16 +01:00
Ran Benita 2871d4b1b8 c_client.py: no need to compare bools to True/False
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 11:39:00 +01:00
Ran Benita 30976e5255 c_client.py: use "foo".join() instead of reduce
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 11:36:23 +01:00
Ran Benita 0ab52cbcc6 c_client.py: fix indentation
(Also remove unnecessary parens around the condition).

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 11:23:30 +01:00
Ran Benita 80341d5df3 c_client.py: use comprehensions instead of map/filter
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 10:42:32 +01:00
Ran Benita 86ea6645d9 c_client.py: use print as a function for python3 compatibility
This works for all python>=2.6, which is what configure requires.

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 10:27:39 +01:00
Ran Benita 70d32ce7d8 c_client.py: fix pyflakes errors
c_client.py:2: 'from xml.etree.cElementTree import *' used; unable to detect undefined names
c_client.py:3: 'basename' imported but unused
c_client.py:9: 'time' imported but unused
c_client.py:1437: local variable 'list_obj' is assigned to but never used
c_client.py:1745: local variable 'varfield' is assigned to but never used
c_client.py:2050: local variable 'length' is assigned to but never used
c_client.py:2416: local variable 'R_obj' is assigned to but never used
c_client.py:2441: local variable 'S_obj' is assigned to but never used

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 10:22:38 +01:00
Ran Benita 12d23b934f c_client.py: simplify maximum expression
Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 10:09:39 +01:00
Ran Benita 1b37d6ad3a c_client.py: remove unneeded call to get_serialize_params()
The results are not used, and the function doesn't have side effects.

Signed-off-by: Ran Benita <ran234@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>
2015-03-15 10:03:12 +01:00
Jaya Tiwari e3ec1f7463 Adding accessors for requests
Added accessor functions for requests the same way they were added for
structs,events and replies.
Lists for replies have accessor functions now.

Signed-off-by: Jaya Tiwari <tiwari.jaya18@gmail.com>
Reviewed-by: Christian Linhart <chris@demorecorder.com>

Comment from the Reviewer Christian Linhart:
I have tested your patch after fixing the issues with the patch-format.
It looks good:
* only adds new functions, and does not modify existing functions.
  Therefore it is API and ABI compatible.

* adds accessors for varsized-stuff in requests.
  This is needed for server-side XCB and may be useful for implementing X11-protocol proxies.
2015-02-22 11:56:04 +01:00
Christian Linhart 5353c0216e Merge http://git.demorecorder.com/git/free-sw/xcb/libxcb
branch 'ParametrizedStruct-V7'
2015-02-10 10:13:04 +01:00
Christian Linhart c6f3fb2529 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>
2014-11-03 11:23:17 +01:00
Christian Linhart 912cd97a6d 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>
2014-11-03 11:23:17 +01:00
Christian Linhart 422458b663 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>
2014-11-03 11:23:17 +01:00
Christian Linhart b1e4a3bbd8 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>
2014-11-03 11:23:16 +01:00
Christian Linhart 6234225b4b 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>
2014-11-03 11:23:16 +01:00
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
Gaetan Nadon c056adcd92 autoconf: replace all tabs with spaces
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2014-01-30 12:10:00 +09:00
Gaetan Nadon 412928f113 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>
2014-01-30 12:09:35 +09:00
Gaetan Nadon 9ba6aa759e autoconf: fix warning by replacing deprecated AC_HELP_STRING
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2014-01-30 12:09:35 +09:00
Gaetan Nadon 942eabaae3 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>
2014-01-30 12:09:35 +09:00
Gaetan Nadon 517cb0e888 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>
2014-01-30 12:09:35 +09:00
Gaetan Nadon 0a17b61a89 autoconf: AC_INIT: add bug url
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
2014-01-30 12:09:35 +09:00
Gaetan Nadon 414b1037c5 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>
2014-01-30 12:09:34 +09:00
Gaetan Nadon c4f2c70bc3 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>
2014-01-30 12:09:34 +09:00
Peter Harris e7263931af Support <pad align="n" />
Reviewed-By: Ran Benita <ran234@gmail.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2014-01-21 15:25:10 -05:00
Kenneth Graunke 3b72a2c9d1 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>
2014-01-03 15:31:19 -08:00
Uli Schlachter 010872f611 Release libxcb 1.10
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-12-22 15:59:24 +01:00
Julien Cristau f653464554 Add NEWS for 1.10
Signed-off-by: Julien Cristau <jcristau@debian.org>
2013-12-14 06:16:37 +01:00
Uli Schlachter 9c2a6dc20c 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>
2013-12-14 05:55:11 +01:00
Julien Cristau ea4406a8e0 Bump xcb-proto requirement to 1.10
Makes sure we generate the new generic event struct.

Signed-off-by: Julien Cristau <jcristau@debian.org>
2013-12-14 05:54:51 +01:00
PHO a1299eb2a2 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>
2013-12-14 05:46:57 +01:00
Uli Schlachter b30b11ac49 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>
2013-12-14 05:46:29 +01:00
Uli Schlachter ce5395eb46 Revert "Remove xcb_ge_event_t from xcb.h"
This reverts commit f4d5b84800.

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>
2013-12-14 05:40:51 +01:00
Daniel Martin 18f0afab3f 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>
2013-12-12 20:37:47 +01:00
Uli Schlachter 5d1dbb468b Revert "fix deadlock with xcb_take_socket/return_socket v3"
This reverts commit 9ae84ad187.

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
2013-11-18 19:49:41 +01:00
Mark Kettenis c7c5b710f2 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>
2013-11-18 16:52:33 +01:00
Alan Coopersmith e8663a9358 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>
2013-11-07 20:25:04 -08:00
Keith Packard af8067cbf4 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>
2013-11-07 20:25:04 -08:00
Keith Packard 83f28ef865 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>
2013-11-07 20:24:59 -08:00
Keith Packard cca6074090 Add Present extension
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-By: Uli Schlachter <psychon@znc.in>
2013-11-07 14:02:37 -08:00
Keith Packard 7a9373078e Add DRI3 library
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-By: Uli Schlachter <psychon@znc.in>
2013-11-07 14:02:37 -08:00
Keith Packard 93d733e85d Require xcb proto version 1.9
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-11-07 14:02:37 -08:00
Keith Packard 79019541e7 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>
2013-11-07 14:02:37 -08:00
Keith Packard 7983bf0fbd 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>
2013-11-07 14:02:37 -08:00
Keith Packard 7b53fb0f9b 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>
2013-11-07 14:02:35 -08:00
Keith Packard 98c227a222 -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>
2013-11-07 14:02:00 -08:00
Keith Packard d04a4a03a9 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>
2013-11-07 14:01:31 -08:00
Keith Packard f4d5b84800 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>
2013-11-07 14:01:31 -08:00
Daphne Pfister e4e0c6eec8 Use /usr/spool/sockets/X11/ on HP-UX for UNIX sockets (#69118). 2013-10-11 18:34:56 +09:00
Daphne Pfister f1405d9fe4 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>
2013-09-08 23:01:11 +02:00
Uli Schlachter ac47e0ecdb Fix documentation of xcb_poll_for_event()
In commit 8eba8690ad, 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>
2013-09-08 22:23:18 +02:00
Daniel Martin c52f2891b4 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>
2013-08-15 00:35:08 +02:00
Daniel Martin a8d11c36ed 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>
2013-08-15 00:35:08 +02:00
Daniel Martin cbe54c97b3 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>
2013-08-15 00:35:08 +02:00
Daniel Martin 6746ab1549 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>
2013-08-15 00:35:07 +02:00
Daniel Martin b6d8c8fe61 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>
2013-08-15 00:35:07 +02:00
Daniel Martin e3b34ad346 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>
2013-08-15 00:35:07 +02:00
Daniel Martin 50fb3a6312 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>
2013-08-15 00:35:07 +02:00
Daniel Martin dd01db570c 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>
2013-08-15 00:35:02 +02:00
Daniel Martin 0289348f2c 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>
2013-08-15 00:34:26 +02:00
Daniel Martin b9efd2a09a 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>
2013-08-15 00:34:21 +02:00
Alan Coopersmith 5648ddd2b9 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>
2013-08-06 11:10:01 -07:00
Alan Coopersmith cb51f271b2 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>
2013-08-06 11:09:56 -07:00
Michael Stapelberg bc6a4f557f 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>
2013-08-06 18:46:43 +02:00
Daniel Martin 45619dc71e 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>
2013-07-12 15:56:14 -04:00
Alan Coopersmith a1e67b141a Fix "indention" typos in xcb-examples.3 man page
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-07-08 17:54:35 -07:00
Marc Deslauriers 8b6bb1a719 Update Makefile.am for newer automake
Debian Bug #710344

Reviewed-by: Daniel Martin <consume.noise@gmail.com>
2013-07-03 19:11:08 -04:00
Christian König 9ae84ad187 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>
2013-06-01 22:28:50 +02:00
Alan Coopersmith 1b33867fa9 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>
2013-05-23 08:12:13 -07:00
Daniel Martin e602b653c1 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>
2013-05-23 10:52:05 -04:00
Christian König 6b6044cb8a whitespace fix in xcb_take_socket
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2013-05-15 15:10:22 -07:00
Colin Walters 0dd8f8d26a autogen.sh: Implement GNOME Build API
http://people.gnome.org/~walters/docs/build-api.txt

Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-01-16 13:20:49 -05:00
Chí-Thanh Christopher Nguyễn 76a2166de9 c_client.py: Fix python-3 invalid except statement
Replace except statement with a PEP-3110 compliant one. This fixes a regression
introduced by c3deeaf714
https://bugs.freedesktop.org/show_bug.cgi?id=55690

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-10 19:45:25 +01:00
Chí-Thanh Christopher Nguyễn 9db4517c87 c-client.py: Fix python-3 AttributeError: 'dict' object has no attribute 'iteritems'
This fixes a regression introduced by ea71d7d7e3
https://bugs.freedesktop.org/show_bug.cgi?id=55690

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-11-10 19:45:13 +01:00
Uli Schlachter 4ffe54f690 Release libxcb 1.9
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-05 14:53:37 +02:00
Uli Schlachter 4f52f884f4 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>
2012-10-05 11:23:26 +02:00
Uli Schlachter 23911a707b 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>
2012-09-30 10:10:18 +02:00
Uli Schlachter c16cc5467e Add a .gitignore for src/man/
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-09-25 12:31:53 +02:00
Peter Harris 08cc068ead 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>
2012-09-18 11:42:23 -04:00
Alan Coopersmith ff53285ae3 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>
2012-08-29 22:00:55 -07:00
Alan Coopersmith 90889794ad 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>
2012-08-25 12:34:25 -07:00
Alan Coopersmith b52790e8ed 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>
2012-08-25 12:34:24 -07:00
Alan Coopersmith ed93a6a2a8 Fix "sppported" typo in doxygen comment for XCB_CONN_CLOSED_EXT_NOTSUPPORTED
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-08-25 12:34:24 -07:00
Colin Walters c3deeaf714 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>
2012-08-14 13:33:01 +02:00
Jeremy Huddleston 5f8f2ba1c4 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>
2012-04-21 22:42:51 -07:00
Julien Danjou 71a295082e Move static man to man
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-27 12:10:59 +02:00
Julien Danjou df217bf7c9 Do not list manpages, use a wildcard
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-27 12:10:15 +02:00
Julien Danjou a4417b1611 Split manpage list in two (static/built)
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-27 12:06:54 +02:00
Julien Danjou cc7fab2d5e Allow undocumented code to be built
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-26 18:29:35 +02:00
Michael Stapelberg ea71d7d7e3 c_client.py: generate manpages
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-26 18:23:56 +02:00
Julien Danjou 57a62e99b1 Release libxcb 1.8.1
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-03-09 15:38:56 +01:00
Uli Schlachter 236f914ea7 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 2dcf8b025b.

This commit also reverts commit 9061ee45b8.

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>
2012-03-08 15:40:35 +01:00
Jeremy Huddleston 9061ee45b8 darwin: Use read(2) rather than recv(2)
2dcf8b025b 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>
2012-03-08 00:50:13 -08:00
Julien Cristau 7d235c62f0 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>
2012-02-19 14:41:17 -08:00
Arnaud Fontaine f7bd139616 Add xkb_internals and xkb_issues to EXTRA_DIST. 2012-02-10 17:51:09 +09:00
Jon TURNEY 68d30adde9 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>
2012-02-09 23:05:10 +01:00
Jon TURNEY 87b7bf875e 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>
2012-01-28 12:44:17 -08:00
Jeremy Huddleston 6db1a2686f Revert "Fix include order with Xdmcp on WIN32"
This reverts commit 0e9246def5.

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>
2012-01-28 12:44:06 -08:00
Julien Danjou da1d15082b Bump xcb-proto requirement
We are now unable to build xcb-proto before 1.7.

Signed-off-by: Julien Danjou <julien@danjou.info>
2012-01-12 10:25:07 +01:00
Julien Danjou b95b33e8c0 Release libxcb 1.8
Signed-off-by: Julien Danjou <julien@danjou.info>
2012-01-11 18:27:38 +01:00
Ryan Pavlik 31b57676e8 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>
2012-01-11 18:07:12 +01:00
Ryan Pavlik 0e9246def5 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>
2012-01-11 18:03:31 +01:00
Jon TURNEY 4aa7a2c849 Fix WIN32 compilation after commit 163c47bdc0
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>
2012-01-11 18:03:10 +01:00
Arvind Umrao 769acff0da 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>
2012-01-11 18:01:29 +01:00
Keith Packard 9b4d6f30a3 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>
2012-01-11 17:49:02 +01:00
Uli Schlachter 5ceeaaa429 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>
2011-09-02 13:01:34 -04:00
Jamey Sharp b12038e9ae Keep ALIGNOF definition out of the public namespace.
Uli's patch is an excellent solution; I just want to keep the new
ALIGNOF macro hidden from XCB's users, as they don't need it to call
XCB.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2011-08-24 08:52:02 -07:00
Markus Duft 163c47bdc0 Support pre-IPv6 systems (without getaddrinfo)
Some of these systems (eg. Interix on XP) are still in use.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Peter Harris <pharris@opentext.com>
2011-08-24 10:49:06 -04:00
Uli Schlachter aa02096b8e Compute alignment correctly
The code previously assumed that everything has to be aligned to a 4 byte
boundary. This assumption is wrong as e.g. the STR struct from xproto shows.

Instead, each type has to be aligned to its natural alignment. So a char doesn't
need any alignment, a INT16 gets aligned to a 2-byte-boundary and a INT32 gets
the old 4 byte alignment.

I'm not 100% sure that this commit is correct, but some quick tests with awesome
and cairo-xcb went well.

This commit causes lots of dead assignments to xcb_align_to since only the last
field's alignment is actually used, but this simplified this patch a lot.

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

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Peter Harris <pharris@opentext.com>
2011-08-24 10:28:49 -04:00
Michael Stapelberg 4f25ee1644 Drop AI_ADDRCONFIG when resolving TCP addresses
When a system is completely offline (no interface has an IP address but 'lo'),
xcb could not connect to localhost via TCP, e.g. connections with
DISPLAY=127.0.0.1:0 fail.

AI_ADDRCONFIG will only return IPv4 addresses if the system has an IPv4
address configured (likewise for IPv6). This also takes place when
resolving localhost (or 127.0.0.0/8 or ::1). Also, as per RFC 3493,
loopback addresses are not considered as valid addresses when
determining whether to return IPv4 or IPv6 addresses.

As per mailing-list discussion on the xcb list started with message
20110813215405.5818a0c1@x200, the AI_ADDRCONFIG flag is there for historical
reasons:

    In the old days, the "default on-link" assumption in IPv6 made the flag vey
    much indispensable for dual-stack hosts on IPv4-only networks. Without it,
    there would be long timeouts trying non-existent IPv6 connectivity. Nowadays,
    this assumption has been flagged as historic bad practice by IETF, and hosts
    should have been updated to not make it anymore.

    Then AI_ADDRCONFIG became mostly cosmetic: it avoids phony "Protocol family
    not supported" or "Host unreachable" errors while trying to connect to a dual-
    stack mode from a host with no support for source address selection.

    Nowadays, on up-to-date systems, this flag is completely useless. Then again,
    I understood only the very latest MacOS release is "up-to-date" with this
    definition.
2011-08-18 13:39:56 -07:00
James Jones 662ad589c5 Insert, not append explicit xcbgen dir python path
If a the path to the xcb python generate libs is
explicitly specified to c_client.py, insert it in
the python path list just after the local dir entry,
rather than appending it to the existing paths.
This keeps a global/distro install of xcb from
overriding a local build of the xcb proto files.

Signed-off-by: James Jones <jajones@nvidia.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2011-05-11 23:49:39 -07:00
David Coles 294c9f455c Add support for building with Python 3
Python 3 introduces some language changes that cause issues when running
c_client.py. This also breaks compatibility with Python 2.5 since it does not
support the "as" statement in try/except blocks and does not have reduce() in
the functools package.

The main changes are:
* try/except blocks require `except ... as ...:` to resolve syntactical ambiguity
* map() and filter() return iterators rather than lists in Python 3
* reduce() is now in functools package (and not built-in in Python 3)
* Dictionaries don't have a has_key() method in Python 3
* None and int types can't be directly compared in Python 3
* print() is a statement in Python 3

See http://diveintopython3.org/porting-code-to-python-3-with-2to3.html and
PEP-3110 for details.

Verified on Python 2.6.5 and 3.1.3.

Signed-off-by: David Coles <dcoles@gaikai.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
2011-05-04 15:00:21 +02:00
Jamey Sharp e300ee4920 Revert "Introduce xcb_wait_for_event_until, for consuming responses in wire-order."
This function was intended to allow libX11 to fix a multi-threaded hang,
but the corresponding libX11 patch caused single-threaded apps to spin
sometimes. Since I've retracted that patch, this patch has no users and
shouldn't go into a release unless/until that changes.

This reverts commit 2415c11dec.

Conflicts:

	src/xcb.h
	src/xcb_in.c

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2011-04-12 13:11:48 -07:00
Rami Ylimäki 527df3c84b Introduce a variant of xcb_poll_for_event for examining event queue.
In some circumstances using xcb_poll_for_event is suboptimal because
it checks the connection for new events. This may lead to a lot of
failed nonblocking read system calls.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2011-04-12 13:05:59 -07:00
Alan Coopersmith b64cd0df88 If protocol is "unix", use a Unix domain socket, not TCP
Fixes fallback to local connections from Xlib's XOpenDisplay(), which
will try with protocol "unix" if a hostname is specified and tcp fails
(as it usually will now that most OS'es ship with -nolisten tcp enabled).

Also fixes explicitly specifying DISPLAY as "unix/foo:0", which Xlib
previously accepted for Unix domain sockets.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-04-12 13:01:03 -07:00
Alan Coopersmith b027922ebf Make launchd code in xcb_util.c match surrounding code indent levels
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-04-12 13:01:03 -07:00
Carlos Garnacho 82b1f3919a Handle XGE events with the "send event" flag
This patch is necessary so xcb reads the payload after the message
for GenericEvents with the 0x80 flag turned on.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2011-04-12 12:57:37 -07:00
Alan Coopersmith 42c4adeff4 Add #include <sys/socket.h> to xcb_conn.c
Solves compiler warning on Solaris:
"xcb_conn.c", line 304: warning: implicit function declaration: shutdown

Also provides system definition of SHUT_RDWR on Solaris 11.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2011-04-04 22:06:16 -07:00
Alan Coopersmith 4b502dd696 Remove unused DECnet code
"unifdef -UDNETCONN src/xcb_util.c" plus re-indenting code that was
formerly in the else clause after a DECnet check.

DECnet support has been removed from most of the X.Org code base for
several years, and it appears DNETCONN was never defined in XCB.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2011-04-04 22:06:03 -07:00
Alan Coopersmith 7131d5d070 Use special path to sockets when running under Solaris Trusted Extensions
Solaris Trusted Extensions puts the endpoints for the X server's Unix
domain sockets in a special directory shared from the global zone to
each of the labeled zones, since each labeled zone has a separate /tmp.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Harris <pharris@opentext.com>
2011-04-04 19:56:16 -07:00
Rami Ylimäki 70976d87f1 Prevent theoretical double free and leak on get_peer_sock_name.
Variable new_sockname will leak and sockname will be double freed if
both of the cases shown below are true.

1. realloc succeeds and doesn't return the original pointer
2. calling socket_func fails

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Reviewed-by: Arnaud Fontaine <arnau@debian.org>
Signed-off-by: Peter Harris <pharris@opentext.com>
2011-03-24 11:30:21 -04:00
Jamey Sharp 3678159e4e Delete the old c-client.xsl.
It hasn't been used since libxcb 1.1.90.1, released in 2008.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2011-03-19 20:04:55 -07:00
Jamey Sharp 2415c11dec Introduce xcb_wait_for_event_until, for consuming responses in wire-order.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Josh Triplett <josh@freedesktop.org>
2011-03-18 21:59:47 -07:00
Jamey Sharp 29a974f212 Dequeue readers that can't receive any new responses.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Josh Triplett <josh@freedesktop.org>
2011-03-18 21:59:44 -07:00
Jamey Sharp 131e867fca Factor reader_list management out of wait_for_reply.
Later patches will insert reader_list entries from other entry points.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Josh Triplett <josh@freedesktop.org>
2011-03-18 21:59:38 -07:00
Jamey Sharp 1469e87965 Enable AM_SILENT_RULES on automake 1.11 or newer.
This incantation is supposed to be a no-op on earlier automake versions.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Josh Triplett <josh@freedesktop.org>
2011-03-18 21:58:45 -07:00
Rami Ylimäki 6310475e23 Prevent reply waiters from being blocked.
It's possible to call xcb_wait_for_reply more than once for a single
request. In this case we are nice and let reply waiters continue so
that they can notice that the reply is not available
anymore. Otherwise an event waiter could just signal the reply waiter
that got its reply to continue but leave a waiter for an earlier reply
blocked.

Below is an example sequence for reproducing this problem.

thread #1 (XNextEvent)
  - waits for events
thread #2 (XSync)
  - executes request #2
  - waits for reply #2
thread #1
  - reads reply #2
  - signals waiter of reply #2 to continue
  - waits for events
thread #2
  - handles reply #2
thread #3 (XCloseDisplay)
  - executes request #3
  - waits for reply #2
thread #1
  - reads reply #3
  - nobody is waiting for reply #3 so don't signal
  - wait for events

Of course it may be questionable to wait for a reply twice, but XCB
should be smart enough to let clients continue if they choose to do
so.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2011-03-14 17:19:14 -07:00
Jamey Sharp 29ab5aeb9b Include XKB in ./configure's summary output.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2011-03-13 09:41:10 -07:00
Jamey Sharp 2edfd5c375 Merge branch 'master' of git+ssh://git.freedesktop.org/git/xcb/libxcb
Apparently I forgot to push these months ago.
2011-03-13 09:33:44 -07:00
Jeremy Huddleston 8c3325f8bb darwin: Don't use poll() when expected to run on darwin10 and prior
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-03-04 12:41:55 -08:00
Peter Harris c2e0236462 Don't try to sizeof(void)
sizeof(void) is a gcc extension, and not portable.

Xorg Bugzilla 31959
http://bugs.freedesktop.org/show_bug.cgi?id=31959
http://lists.freedesktop.org/archives/xcb/2010-May/006039.html

Signed-off-by: Peter Harris <pharris@opentext.com>
Tested-by: Cyril Brulebois <kibi@debian.org>
2011-01-27 15:38:36 -05:00
Vincent Torri 9efced72a3 fix Windows build and installation 2011-01-20 20:46:04 -05:00
Peter Harris 3c58136971 Merge branch 'master' of git://anongit.freedesktop.org/~peterh/libxcb 2010-12-23 13:04:40 -05:00
Jeetu Golani 69b78ced1a Don't validate FD_SETSIZE on Win32
Windows' file handles have never been small or consecutive, so Windows'
select has always been implemented the same way as everyone else's poll.

On Windows, FD_SETSIZE is the size of the poll array, not the maximum
SOCKET number.

Signed-off-by: Peter Harris <git@peter.is-a-geek.org>
2010-12-12 16:48:41 -05:00
Uli Schlachter 8ecd754b16 xcb_take_socket: Document sequence wrap requirements
If lots of requests are send without one causing a reply, xcb can get confused
about the current sequence number of a reply. Document the requirements of an
external socket owner to avoid this problem.

The return_socket callback for xcb_take_socket() originally was supposed to
return the last sequence number used, but the version committed to libxcb never
actually had this signature. This fixes the function's documentation not to
mention this non-existent return value.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-11-27 12:48:27 +01:00
Nick Bowler 5755582444 xcb_auth: Fix memory leak in _xcb_get_auth_info.
If the initial get_peer_sock_name(getpeername ...) succeeds, the
pointer to allocated memory is overwritten by the later call to
get_peer_sock_name(getsockname ...).  Fix that up by freeing
the allocated memory before overwriting the pointer.

Signed-off-by: Nick Bowler <nbowler@draconx.ca>
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-11-23 14:58:48 +01:00
Jamey Sharp ed37b08751 xcb_in: Use 64-bit sequence numbers internally everywhere.
Widen sequence numbers on entry to those public APIs that still take
32-bit sequence numbers.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-10-09 17:13:45 -07:00
Jamey Sharp 6c8b539c2a xcb_discard_reply: Simplify by re-using poll_for_reply helper.
If you discard a sequence number that has multiple responses already
read, this will do more allocations than necessary. But nobody cares
about ListFontsWithInfo.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-10-09 13:19:05 -07:00
Jamey Sharp 3a74b5e7a1 xcb_request_check: Hold the I/O lock while deciding to sync.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-10-09 12:37:48 -07:00
Jamey Sharp ee1bc1d28a xcb_send_request: Send all requests using a common internal send_request.
This simplifies the critical section of xcb_send_request and fixes a
couple of subtle bugs:

- It's possible for xcb_send_request to need to issue two sync requests
  before it can issue the real request. Previously, we counted sequence
  numbers as if both were issued, but only one went out on the wire.

- The test for whether to sync at 32-bit sequence number wrap has been
  incorrect since we switched to 64-bit sequence numbers internally.

This change means that if the output queue was already full and the
current request is bigger than the output queue, XCB will do one more
write syscall than it did before. But syncs are rare and small requests
are the norm, so this shouldn't be a measurable difference.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-10-09 12:37:23 -07:00
Peter Harris b672d1514c Fix _unserialize of reply headers
This cleans up a number of warnings, and passes the sequence number
through correctly.

Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-22 23:16:33 -04:00
Peter Harris 29cca33b90 Clean up a couple of warnings in xprint
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-22 22:32:51 -04:00
Peter Harris 8c1d2021ca Make *_unserialize safe to use on buffers in-place
By calling memmove instead of memcpy, and walking the buffer backward
from the end, *_unserialize is safe to use in-place.

Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-22 22:20:04 -04:00
Peter Harris 28a71c6567 Fix memory leak in _sizeof implemented with _unserialize
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-22 22:20:04 -04:00
Peter Harris a22909c0f5 Don't emit out-of-module sizeof definitions
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-22 22:20:04 -04:00
Josh Triplett 1c4717de36 Allow disconnecting connections that are in error state.
In support of this, consolidate the two static error_connection
definitions into one so we don't try to free the static out-of-memory
error_connection.

Commit by Josh Triplett and Jamey Sharp.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-09-19 20:38:06 +02:00
Peter Harris 03bcccb132 Add xkb.* to gitignore
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-10 15:54:56 -04:00
Peter Harris 28d3925800 Merge branch 'gsoc2010' of git://anongit.freedesktop.org/~chr/libxcb 2010-09-08 14:41:52 -04:00
Jamey Sharp f0565e8f06 _xcb_conn_wait: Shut down the connection on unexpected poll() events.
If a client calls close(2) on the connection's file descriptor and then
flushes writes, libxcb causes a hang in the client.

Any flush eventually calls _xcb_out_send() with has the following loop:
   while(ret && *count)
       ret = _xcb_conn_wait(c, &c->out.cond, vector, count);

_xcb_conn_wait(), if built with USE_POLL, gets the POLLNVAL error. It only
checks for POLLIN and POLLOUT though, ignoring the error. Return value is 1,
count is unmodified, leaving us with an endless loop and a client hang.

XTS testcase Xlib3/XConnectionNumber triggers this bug. It creates a display
connection, closes its file descriptor, tries to send a no-op, and then expects
an error.
http://cgit.freedesktop.org/xorg/test/xts/tree/xts5/Xlib3/XConnectionNumber.m

If poll returned POLLHUP or POLLERR, we might see the same result.

If poll returns any event we didn't ask for, this patch causes
_xcb_conn_shutdown() to be invoked and an error returned. This matches the
behaviour if select(2) is used instead of poll(2): select(2) returns -1 and
EBADF for an already closed file descriptor.

I believe this fix both is safe and will handle any similar error. POSIX says
that the only bits poll is permitted to set in revents are those bits that were
set in events, plus POLLHUP, POLLERR, and POLLNVAL. So if we see any flags we
didn't ask for then something has gone wrong.

Patch inspired by earlier proposals from Peter Hutterer and Aaron
Plattner--thanks!

Reported-by: Peter Hutterer <peter.hutterer@who-t.net>
Reported-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Aaron Plattner <aplattner@nvidia.com>
Cc: Peter Hutterer <peter.hutterer@who-t.net>
Cc: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-09-04 13:39:38 -04:00
Peter Harris 20da10490f Merge branch 'master' of git://github.com/topcat/xcb-win32
Conflicts:
	src/xcb_conn.c
	src/xcb_util.c

Signed-off-by: Peter Harris <pharris@opentext.com>
2010-08-31 18:35:20 -04:00
Aaron Plattner 7f5cfcc2fd xcb_disconnect: call shutdown() to force a disconnect
Fixes the X Test Suite's XCloseDisplay-6 test, which has this (admittedly
ridiculous) behavior:

 1. Create a window w.
 2. Open two display connections, dpy1, and dpy2.
 3. Grab the server using dpy1.
 4. Fork.
 5 (child). XSetProperty on w using dpy2.
 5 (parent). Verify that no event was recieved on dpy1.
 6 (parent). XCloseDisplay(dpy1).
 6 (child). Verify that an event was received on dpy2.

It was failing because at step 6 (child), the server had not actually ungrabbed
yet because the file descriptor for dpy1 was still open in the child process.

Shutting down the socket during XCloseDisplay matches the behavior of non-XCB
Xlib, which calls shutdown() from _X11TransSocketDisconnect.

Thanks to Julien Cristau for noticing this.

Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-08-25 21:40:52 -04:00
Jamey Sharp 2040f10a4e xcb_request_check: Sync even if an event was read for this sequence.
This fixes the test case I have so far for Havoc's report that
xcb_request_check hangs.

Rationale: Since we have a void cookie, request_expected can't have been
set equal to this sequence number when the request was sent; it can only
have become equal due to the arrival of an event or error. If it became
equal due to an event then we still need to sync. If it became equal due
to an error, then request_completed will have been updated, which means
we correctly won't sync.

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

However, Havoc reports that he can still reproduce the problem, so we
may be revisiting this later.

Reported-by: Havoc Pennington <hp@pobox.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-08-24 09:29:59 -07:00
Christoph Reimann 5e8a7ade2d small fix to get rid of some compiler warnings
also added very basic documentation for xkb
2010-08-16 20:24:40 +02:00
Christoph Reimann b89f634ff9 small fix in the xkb pkg file 2010-08-16 18:22:42 +02:00
Christoph Reimann 22e1013131 added accessors for special cases
major bugfixes include: rewrite of prefix related functions, merge of serialize/unserialize/... generators, extended field name resolution
2010-08-16 18:19:16 +02:00
Julien Danjou 35f901a0f2 Release libxcb 1.7
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-08-13 13:46:37 +02:00
Christoph Reimann fe0e32b5fa special case 'intermixed variable and fixed size fields': fixed reply side, needs testing 2010-08-08 21:25:13 +02:00
Christoph Reimann 77b594f958 renamed most _unserialize() functions to _sizeof() and fixed _unserialize() for the special case of intermixed variable and fixed size fields 2010-08-05 15:55:28 +02:00
Eamon Walsh dd1a4dbe20 Tutorial uses wrong function.
https://bugs.freedesktop.org/show_bug.cgi?id=29392

Signed-off-by: Eamon Walsh <efw@eamonwalsh.com>
2010-08-05 00:50:22 -04:00
Christoph Reimann b187f029d6 attempt to fix special case: variable fields followed by fixed size fields 2010-08-02 23:30:42 +02:00
Christoph Reimann a700eeb502 bug fixes for all kinds of 'special cases' 2010-08-01 23:40:20 +02:00
Christoph Reimann 1c590d5a86 partial rewrite of serialize helper functions completed;
_serialize() & _unserialize() have been tested for switch derived from valueparam
2010-07-22 16:41:15 +02:00
Christoph Reimann 566ae9baee preliminary handling of further special cases in unserialize
first attempts to unify serialize and unserialize
2010-07-20 22:46:37 +02:00
Christoph Reimann 4e665e1580 added generating code for _serialize() in case of variable sized structs (largely untested) 2010-07-15 18:43:43 +02:00
Christoph Reimann d003145609 xkb: added pkg config file 2010-07-13 20:08:51 +02:00
Christoph Reimann 86704124b1 new and still preliminary functions for switch; feautures include
- API compatibility with valueparam
- request _aux() auxiliary functions
- _serialize() and _unserialize() auxiliary functions
- new data type that allows mixing of fixed and variable size members
2010-07-13 20:06:08 +02:00
Christoph Reimann 80322d1163 xkb: updated configure.ac/Makefile.am 2010-07-13 19:59:23 +02:00
Christoph Reimann 8c2707773b added xcb_sumof() with restriction to uint8_t 2010-07-13 19:56:44 +02:00
Jamey Sharp 496efb7624 _xcb_conn_wait: Fix whitespace.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
2010-07-13 07:10:50 -07:00
Jeremy Huddleston 74057c7eb6 AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no], [$PATH$PATH_SEPARATOR/sbin])
launchd: Explicitly search /sbin

Previously, launchd wasn't found if /sbin wasn't in the user's PATH.
https://bugs.freedesktop.org/show_bug.cgi?id=29028

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-07-12 16:53:53 -07:00
Vincent Torri 75ff427d41 configure.ac: Report which extensions are being built.
I was surprised to see that xinput was not installed. Looking at
configure.ac, it seems that it is disabled by default. Maybe configure
should output the status of the different extensions.
2010-06-20 20:50:06 -07:00
Pauli Nieminen de3cdad87a xcb_connect_to_display_with_auth_info: Fix memory leak
protocol and host are allocated in _xcb_parse_display but ownership of
them is passed to the caller. They have to be freed in
xcb_connect_to_display_with_auth_info.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-06-15 13:16:45 -04:00
Pauli Nieminen 18718d483e _xcb_parse_display: Fix error path
xcb_parse_display claims that there is no side effects when failing.
That requires _xcb_parse_display to free the memory in failure case.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-06-15 13:16:45 -04:00
Jeremy Huddleston 3f79628bec xcb_open: Improve protocol/host parsing
Support scenarios where host is not set and protocol is.  eg:

DISPLAY=tcp/:0

as well as the "inet" and "inet6" alias for "tcp" for compatability
with Xlib

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
2010-05-14 14:28:53 -07:00
Marcin Kościelnicki e4b746ac13 Add ~ operator support in code generator
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-05-14 13:19:28 +02:00
Arnaud Fontaine 5e86cb0566 Fix GCC error on undeclared variable when not using abstract socket
This is a regression found by tinderbox in previous commit:

xcb_util.c: In function '_xcb_open':
xcb_util.c:213: error: 'fd' undeclared (first use in this function)
2010-04-30 18:49:18 +01:00
Arnaud Fontaine a546d00091 Get rid of PATH_MAX and MAXPATHLEN
There could be no upper limit on the length of a path according
to POSIX, therefore these macros may not be defined at all on
some systems (such as GNU Hurd).

Signed-off-by: Arnaud Fontaine <arnau@debian.org>
Reviewed-by: Peter Harris <pharris@opentext.com>
2010-04-30 14:47:16 +02:00
Jeremy Huddleston d068572173 Use limits.h instead of syslimits.h
Regression found by tinderbox in 89b3485dad

xcb_util.c:31:27: error: sys/syslimits.h: No such file or directory
xcb_util.c: In function '_xcb_open':
xcb_util.c:148: error: 'PATH_MAX' undeclared (first use in this function)

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-23 21:57:26 -07:00
Jeremy Huddleston 89b3485dad Reworked launchd support to work better with _xcb_parse_display
Fixes: http://xquartz.macosforge.org/trac/ticket/390

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-23 17:29:25 -07:00
Jeetu Golani 2dcf8b025b Replaced read() in read_block and _xcb_in_read() with recv for all
platforms. MSG_WAITALL is undefined in MinGW so it's been explicitly
defined in xcb_in.c
2010-04-23 00:47:16 +05:30
Jeetu Golani 56962e42a5 Set errno=0 in read_block. On Win32 there is no errno and this makes the
do..while loop execute only once. Also set the return value to -1 in
_xcb_open if control reaches the end - if all goes well it shouldn't
reach there.
2010-04-22 23:23:27 +05:30
Jamey Sharp b0525e2423 Always wake up readers after writing.
Since writers must make sure they read as well, threads may have gone to
sleep waiting for the opportunity to read. The writer must wake up one
of those readers or the application can hang.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Josh Triplett <josh@freedesktop.org>
2010-04-17 18:20:41 -07:00
Jamey Sharp eff3851ba8 Fix strict-aliasing warning when getting generic event length.
xcb_ge_event_t has its length field in the same place that
xcb_generic_reply_t does, so there's no need to cast the generic reply.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Cc: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Danjou <julien@danjou.info>
2010-04-17 18:20:41 -07:00
Jamey Sharp 6dd8228a13 Delete a useless level of indirection from _xcb_out_send's parameters.
_xcb_out_send needs _xcb_conn_wait to store back its progress so it can
be reinvoked to pick up where it left off---but then _xcb_out_send
guarantees that it leaves either an empty output vector or a shut-down
connection, so *its* callers never care how much progress was made.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Josh Triplett <josh@freedesktop.org>
2010-04-17 18:20:40 -07:00
Julien Danjou a63fbc9d6c Release libxcb 1.6 2010-04-09 16:57:51 +02:00
Rémi Denis-Courmont a1d9aa6e07 Fail if fd is too big and poll() is not available
Depending on the process file limit, a file descriptor can be larger
than the capacity of fd_set. There is no portable way to create a
large enough fd_set at run-time. So we just fail if the file descriptor
number is too high and poll() is not available.

Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-04-08 12:05:00 +02:00
Jeetu Golani 0e0c80e749 xcb_in.c #ifndef _WIN32 inside of #if USE_POLL redundant and removed 2010-03-31 22:00:04 +05:30
Jeetu Golani e8009194c9 restablished inclusion of fcntl.h and netinet/tcp.h in xcb_util.c -- without these the code no longer compiled on *ix 2010-03-31 09:50:51 +05:30
Jeetu Golani d302f1e9b1 changes in xcb_windefs.h - the flag _XCB_WINDEFS_H replaces WINDEFS_H 2010-03-29 22:37:33 +05:30
Jeetu Golani 36c9a985aa windefs.h is now called xcb_windefs.h - changed all includes to reflect that.Replaced one instance ofWIN32 with _WIN32 in each xcb_in.c and xcb_conn.c 2010-03-29 22:31:49 +05:30
Jeetu Golani bce72f63d2 Win32 code for xcb-1.5 2010-03-26 09:40:09 +05:30
Samuel Thibault d18d03d6f3 Fix authentication on hpux and Hurd
libxcb's 010e5661 (Fix XDM-AUTHORIZATION-1 (bug #14202)) mistakenly
inverted a few lines of code, making local socket authentication fail on
hpux and Hurd: when getpeername fails, sockname needs to be initialized
by getsockname before its address family can be checked.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-03-13 16:20:12 +01:00
Rémi Denis-Courmont 53a9834e4c Open the X11 socket with close-on-exec flag
This saves the X11 connection from leaking into children processes.
On Linux, this is fully thread-safe using SOCK_CLOEXEC. On other
systems, there is a small race condition.

Signed-off-by: Julien Danjou <julien@danjou.info>
2010-02-17 10:09:43 +01:00
Peter Harris 367882fa32 Support xcb_discard_reply
This function is useful for dynamic language garbage collectors. Frequently
a GC cycle may run before you want to block wainting for a reply.

This function is also marginally useful for libxcb apps that issue
speculative requests (eg. xlsclients).

Reviewed-by: Jamey Sharp <jamey@minilop.net>
Tested-by: Eamon Walsh <efw@eamonwalsh.com>
Signed-off-by: Peter Harris <pharris@opentext.com>
2010-02-11 14:35:37 -05:00
Rémi Denis-Courmont be7e528eae xcb_connect_to_fd: fix descriptor leak on memory error path
Signed-off-by: Julien Danjou <julien@danjou.info>
2010-01-07 18:03:30 +01:00
Jeremy Huddleston c7a57043da configure.ac: Fix a typo on the last commit.
Signed-off-by: Jeremy Huddleston <jeremyhu@freedesktop.org>
2009-12-11 17:24:43 -08:00
Jeremy Huddleston 58c96da928 darwin: xnu doesn't support poll on ttys on the master side.
<rdar://problem/7360546>

Signed-off-by: Jeremy Huddleston <jeremyhu@freedesktop.org>
2009-12-11 17:15:16 -08:00
Jim Ingram 1e746fd89a Tutorial code fix
Accessed elements of names[] after freeing them in the first example.

Signed-off-by: Julien Danjou <julien@danjou.info>
2009-12-08 09:41:26 +01:00
Rémi Cardona a470579ba2 DRI2 extension requires xcb-proto 1.6 or newer
Signed-off-by: Rémi Cardona <remi@gentoo.org>
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-12-05 11:54:39 +01:00
Julien Danjou 6e875a82a8 build: simplify extension building
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-12-03 11:34:18 +01:00
Julien Danjou 48217ac986 Release libxcb 1.5
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-12-03 10:09:06 +01:00
Adam Jackson 1cf2a87def setsockopt(SO_KEEPALIVE) on TCP display connections.
This matches xtrans behaviour in SocketINETConnect, and makes it so apps
don't hang forever if their display dies.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2009-12-02 14:31:56 -05:00
Eric Anholt e82c34c2f7 Add DRI2 support. (v2)
v2: Build fix from jcristau.
2009-10-19 09:47:06 -07:00
Eric Anholt a27c77ccae Fix typo in the tutorial. 2009-10-15 13:49:47 -07:00
Paulo R. Zanoni 17af34b4a4 Don't build docs if 'dot' is not found Signed-off-by: Paulo R. Zanoni <pzanoni@mandriva.com> 2009-09-18 17:14:04 -04:00
Julien Cristau 29207e2943 Fix check dependency
Bugzilla #21992

make -j check fails because the check-local rule gets executed before
the tests actually ran, so CheckLog*.xml doesn't exist.

Signed-off-by: Julien Danjou <julien@danjou.info>
2009-08-31 17:51:36 +02:00
Yaakov Selkowitz ff2e2e35bc Cygwin build fix: Add -no-undefined to libtool flags
-no-undefined is needed to tell libtool a shared library can be built
on platforms which require all references to be statisfied at link time.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-08-31 17:48:32 +02:00
Arnaud Fontaine 96ff5fb635 Release libxcb 1.4 2009-07-15 16:15:02 +01:00
Arnaud Fontaine f4c2794bf5 Add majorCode, minorCode and resourceID fields to X generic error 2009-07-15 16:03:56 +01:00
Jamey Sharp e06955ed66 Fix precedence bug: wrong length for big-requests preceded by sync.
Also replace excessively clever use of bitwise OR with equivalent
addition.

Reported-by: Geoffrey Li <geoffrey@seitopos.com>
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
2009-07-06 13:14:35 -07:00
Julien Cristau 9e191c722a Fix libxcb-randr version info
The SONAME shouldn't have been bumped in 1.3, only new symbols were
added.

Signed-off-by: Julien Danjou <julien@danjou.info>
2009-05-29 17:05:11 +02:00
Julien Danjou f44dc519c5 Release libxcb 1.3 2009-05-29 08:28:53 +02:00
elupus ee89850e68 Disable Nagle on TCP socket
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-05-26 16:14:48 +02:00
Bob Ham 62fe187e2d Store xcbproto version libxcb was compiled with
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-05-25 12:20:23 +02:00
Julien Danjou efbe96ee0a depends on recent xcb-proto and bump version of randr
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-05-09 17:39:34 +02:00
Bart Massey 010e566126 Fix XDM-AUTHORIZATION-1 (bug #14202)
With this patch, we know use correctly the socket address or peer
address for authentication purpose.

Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-21 08:41:34 +02:00
Julien Danjou ca978a9dae util: remove useless strlen calls from decnet opening
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-10 09:59:49 +02:00
Julien Danjou cc19143141 util: merge common code for xcb_connect
Many code was duplicated between xcb_connect_to_display_with_auth_info
and xcb_connect(). We merge both, since the difference is just about the
xcb_auth_info_t pointer being supplied, or not.

Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-10 09:59:49 +02:00
Julien Danjou 8797e053b2 util: open_abstract gets filelen as parameters
That saves us from a couple of strlen() calls.

Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-10 09:59:49 +02:00
Julien Danjou f0b2981974 auth: use snprintf() return value
That save us from a strlen().

Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-10 09:59:49 +02:00
Julien Danjou 9f24c91f91 auth: precompute authnameslen
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-10 09:59:49 +02:00
Jeremy Huddleston 2a4f1cf380 darwin: Don't use poll() on versions of darwin before darwin10 2009-04-09 05:12:02 -07:00
Samuel Thibault 6e2e87d0bb Local socket connections do not work on hurd-i386
Local socket connections currently do not work on hurd-i386 because
xcb_auth calls getpeername() on the client socket, but hurd-i386 does
not implement anything in that case (I actually wonder what reasonable
value could be returned).  In such case the xcb code does not actually
need the peer name anyway.

Signed-off-by: Julien Danjou <julien@danjou.info>
2009-04-06 16:53:11 +02:00
Michael Ost f916062edf use poll() instead of select() when available
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-03-30 11:09:32 +02:00
Bart Massey beccb0be15 kludgily hand-merged xid fixes
Signed-off-by: Bart Massey <bart@cs.pdx.edu>
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-03-28 14:59:01 +01:00
Julien Danjou 1e9c0f1012 Fix do_append() arguments
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-03-16 10:26:37 +01:00
Julien Danjou fcb433db80 Copy full IPv4 mapping (Bug #20665)
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-03-15 19:57:56 +01:00
Peter Harris eaa71eac02 Avoid name collisions between xidtype and enum.
These changes are necessary to build with latest xcb/proto.

Signed-off-by: Peter Harris <pharris@opentext.com>
2009-03-14 12:34:31 -04:00
Peter Harris e986d1ee5a Revert "Don't use enums in generated C code"
This commit broke xcb/util.

This reverts commit 9984b72888.

Signed-off-by: Peter Harris <pharris@opentext.com>
2009-03-13 15:25:30 -04:00
Peter Harris 9984b72888 Don't use enums in generated C code - use integer constants instead.
Signed-off-by: Peter Harris <pharris@opentext.com>
2009-02-25 19:07:23 -05:00
Julien Danjou b08e1535cf Release libxcb 1.2
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-02-17 13:37:29 +01:00
Julien Danjou 2e65188f91 Stop providing autogenerated files in tarball
Signed-off-by: Julien Danjou <julien@danjou.info>
2009-02-16 11:44:20 +01:00
Julien Danjou 37f5ce3ef4 Release libxcb 1.1.93
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-12-11 11:17:13 +01:00
Jeremy Huddleston f896ae8c53 Shutup compiler warning about unused variable... 2008-11-23 17:25:21 -08:00
Jeremy Huddleston d79621b25b Apple: Apple launchd cleanup
Added --with-launchd option instead of just using __APPLE__
Fixed opening launchd fd when displayname=NULL
2008-11-23 17:23:17 -08:00
Jeremy Huddleston 9b79ae49f7 Apple: Enable support for launchd DISPLAY socket 2008-11-23 16:18:25 -08:00
Peter Harris 43b612a5e9 Treat XIDs the same as other cardinal values.
This fixes a bug where c_client.py wasn't generating *_end functions,
but expected them to exist in order to find the subsequent list's start.

Signed-off-by: Peter Harris <peter.harris@hummingbird.com>
2008-11-19 11:06:01 -05:00
Julien Danjou 902cade8ec Release libxcb 1.1.92
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-11-04 10:22:51 +01:00
Josh Triplett fa452cc9b2 Support handing off socket write permission to external code.
Libraries like Xlib, some XCB language bindings, and potentially others
have a common problem: they want to share the X connection with XCB. This
requires coordination of request sequence numbers.  Previously, XCB had an
Xlib-specific lock, and allowed Xlib to block XCB from making requests.
Now we've replaced that lock with a handoff mechanism, xcb_take_socket,
allowing external code to ask XCB for permission to take over the write
side of the socket and send raw data with xcb_writev.  The caller of
xcb_take_socket must supply a callback which XCB can call when it wants
the write side of the socket back to make a request.  This callback
synchronizes with the external socket owner, flushes any output queues if
appropriate, and then returns the sequence number of the last request sent
over the socket.

Commit by Josh Triplett and Jamey Sharp.
Handoff mechanism inspired by Keith Packard.
2008-10-29 15:40:41 -07:00
Jamey Sharp baff35a04b Track 64-bit sequence numbers internally.
External APIs that used 32-bit sequence numbers continue to do so.

Commit by Josh Triplett and Jamey Sharp.
2008-10-29 15:40:41 -07:00
Jamey Sharp 96e55444b9 Use sequence number ranges in pending replies
This allows optimizing adjacent pending replies with the same flags, and
will help support default flags for a range of future requests.

Commit by Josh Triplett and Jamey Sharp.
2008-10-29 15:40:41 -07:00
Jamey Sharp 059ca642c7 Inline _xcb_lock_io, _xcb_unlock_io, and _xcb_wait_io.
These functions are once again a single pthread call, so just make that
call directly.
2008-10-29 15:40:41 -07:00
Jamey Sharp d989656cde Remove libxcb-xlib and xcbxlib.h. 2008-10-29 15:40:04 -07:00
Julien Danjou dcbef23d73 build: fix configure.ac AC_DEFINE
Rather use AC_DEFINE_UNQUOTED and only once.

Signed-off-by: Julien Danjou <julien@danjou.info>
2008-10-14 23:39:07 +02:00
Julien Danjou cebd482a20 allow compile-time setting for XCB queue buffer size
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-10-14 20:38:47 +02:00
Josh Triplett 625ed596ca Remove duplicate XCB_EXTENSION calls for Composite extension 2008-10-08 16:04:25 -07:00
Henning Sten db332dcda9 fix tiny memory leak in read_packet (leak only happens when malloc returns NULL so it's very rare)
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-09-20 14:21:17 +02:00
Carsten Meier 9afadd2aef Added generation of extern "C" for compatibility with C++
The auto-generated header files now include an extern "C"
declaration for compatibility with C++.

Signed-off-by: Julien Danjou <julien@danjou.info>
2008-09-09 15:00:38 +02:00
Julien Cristau 25e59ccc0d Add support for the abstract socket namespace under Linux
Based on same in Xtrans.

Signed-off-by: Julien Danjou <julien@danjou.info>
2008-09-09 14:44:54 +02:00
Julien Cristau f3f8738436 Fix some fd leaks in _xcb_open_*()
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-09-09 14:44:54 +02:00
Bart Massey d6d44e1bf0 fixed overly aggressive warning about fixed field following variable 2008-09-03 13:52:58 -07:00
Bart Massey 7e0674e761 added small fix to support trailing fixed fields; also warning for non-pad fixed fields 2008-09-03 11:58:14 -07:00
Vincent Torri 2d04a1e6ce factorize m4 macros and add one to set X extensions
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-31 10:33:31 +02:00
Julien Danjou bcf662c1b4 Initialize all fields of addrinfo
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-28 14:35:54 +02:00
Julien Danjou baf31b1bf2 Use ifdef instead of if for defined value
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-28 13:51:38 +02:00
Julien Danjou 38d5de3a55 Set namelen unsigned
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-28 13:49:21 +02:00
Julien Danjou 9c9c09b376 Rename index to idx to avoid shadowing
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-28 13:49:21 +02:00
Julien Danjou c5b2e53abf Use a signed size in read_block()
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-28 13:49:21 +02:00
Julien Danjou 1bbdba5211 Use unsigned to compare and rename sync
- i must be unsigned to be compare in the loop
- sync shadow global sync() function

Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-28 13:49:21 +02:00
Julien Danjou 6438584285 Fix htonl() arg & convert sizeof() to signed
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-28 13:49:21 +02:00
Julien Danjou 1ead02e88e initialize global_id to 0
Signed-off-by: Julien Danjou <julien@danjou.info>
2008-08-28 13:49:21 +02:00
Peter Hutterer f209d0ef7a Bump to 1.1.91. 2008-07-17 13:58:19 +09:30
Julien Cristau cdc3479387 Make EXTHEADERS, EXTSOURCES, EXTENSION_XML unconditional of configure flags.
yay, make distcheck works now even when some extensions are disabled.

Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
2008-07-16 23:25:04 +09:30
Petr Salinger a9d15a0845 fix FreeBSD support
The GNU/kFreeBSD (and BSDs in general) have a different
layout of struct sockaddr, sockaddr_in, sockaddr_un ...

The first member do not have to be "sa_family",
they also have "sa_len" field.

Signed-off-by: Julien Danjou <julien@danjou.info>
2008-07-07 17:57:37 +02:00
Peter Hutterer ee78071902 Bump to 1.1.90. 2008-05-29 16:02:18 +09:30
Josh Triplett 424ad131b7 Fix variable declaration formatting 2008-05-28 12:26:13 -07:00
Peter Hutterer 6532c715c3 Add xcb_ge_event_t and handling for long events.
GenericEvent can be more than 32 bytes long. Ensure that the required data is
pulled off the wire and tack it onto the event.

Due to the structure of the xcb_generic_event_t, the data is appended AFTER
the full_sequence field.
2008-05-21 21:22:13 +09:30
Oswald Buddenhagen b08a5909da Fix libxcb/src compile with srcdir != builddir. 2008-05-01 16:17:55 -04:00
Eamon Walsh 4a405feba8 Replace a stray c-client.xsl in the libxcb SOURCES. Fixes make distcheck. 2008-04-23 20:28:13 -04:00
Eamon Walsh 40566c36d5 Use the python install path from xcb-xproto.pc to locate the xcbgen package. 2008-04-23 20:25:57 -04:00
Jeremy Kolb b3832bcc46 Add mention of PYTHONPATH if xcbgen cannot be found. 2008-04-20 16:26:51 -04:00
Eamon Walsh 5ee915e12a Add Python parser C language-dependent part. 2008-04-19 04:44:29 -04:00
Eamon Walsh 947a2e26e4 Add SELinux extension support, disabled by default. 2008-01-24 16:02:34 -05:00
Eamon Walsh 0b5f684eb0 Add XInput extension support, disabled by default. 2008-01-24 15:57:35 -05:00
Eamon Walsh c72581c844 Inputs to AC_CONFIG_FILES are automatically distributed.
Hence, it is not necessary to explicitly add them to EXTRA_DIST.
2008-01-15 17:06:14 -05:00
Eamon Walsh 7a74ba3d02 Generated the configure.ac and Makefile.am's in libxcb with the idea of
making each extension library individually selectable for build.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
2007-12-07 16:22:04 -05:00
Eamon Walsh bcd1dcec9b Merge branch 'master' of git+ssh://git.freedesktop.org/git/xcb/libxcb 2007-12-07 16:18:00 -05:00
Bart Massey 9bf8329b50 make IPv6 optional 2007-11-24 14:53:54 -08:00
Eamon Walsh 0593989103 Remove file that wasn't meant to be committed. 2007-11-16 19:38:40 -05:00
Eamon Walsh baae5826a6 Merge branch 'master' of git+ssh://git.freedesktop.org/git/xcb/libxcb 2007-11-16 19:36:08 -05:00
Eamon Walsh 46413cd85e Add comment noting the requirement to free replies when finished. 2007-11-16 19:34:42 -05:00
Eamon Walsh c3136d1832 Add generated comment noting requirement to free replies after use. 2007-11-16 19:33:20 -05:00
73 changed files with 7637 additions and 2933 deletions

3
.autom4te.cfg Normal file
View File

@ -0,0 +1,3 @@
begin-language: "Autoconf-without-aclocal-m4"
args: --cache=build-aux
end-language: "Autoconf-without-aclocal-m4"

46
.gitignore vendored
View File

@ -1,30 +1,28 @@
aclocal.m4
autom4te.cache
compile
depcomp
install-sh
libtool
ltmain.sh
missing
mkinstalldirs
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
configure.lineno
.deps
.dirstamp
.libs
*.la
*.lo
*.loT
*.la
Makefile
Makefile.in
stamp-h1
*.o
*.pc
*.tar.bz2
*.tar.gz
.deps
.dirstamp
.libs
Makefile
Makefile.in
aclocal.m4
build-aux
config.h*
config.log
config.status
configure
configure.lineno
libtool
m4/l*.m4
mkinstalldirs
stamp-h1
ChangeLog
INSTALL
check-pc-requires.log
check-pc-requires.trs
test-suite.log

123
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,123 @@
# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
#
# This CI uses the freedesktop.org ci-templates.
# Please see the ci-templates documentation for details:
# https://freedesktop.pages.freedesktop.org/ci-templates/
.templates_sha: &template_sha b791bd48996e3ced9ca13f1c5ee82be8540b8adb # see https://docs.gitlab.com/ee/ci/yaml/#includefile
include:
# Arch container builder template
- project: 'freedesktop/ci-templates'
ref: *template_sha
file: '/templates/arch.yml'
- project: 'freedesktop/ci-templates'
ref: *template_sha
file: '/templates/ci-fairy.yml'
- template: Security/SAST.gitlab-ci.yml
stages:
- prep # prep work like rebuilding the container images if there is a change
- install xcbproto
- build # for actually building and testing things in a container
- test
- deploy
variables:
FDO_UPSTREAM_REPO: 'xorg/lib/libxcb'
# The tag should be updated each time the list of packages is updated.
# Changing a tag forces the associated image to be rebuilt.
# Note: the tag has no meaning, we use a date format purely for readability
FDO_DISTRIBUTION_TAG: '2023-08-21.0'
FDO_DISTRIBUTION_PACKAGES: 'git gcc pkgconf autoconf automake libtool make xorg-util-macros python doxygen graphviz check libxslt libxau libxdmcp'
#
# Verify that commit messages are as expected
#
check-commits:
extends:
- .fdo.ci-fairy
stage: prep
script:
- ci-fairy check-commits --junit-xml=results.xml
except:
- master@xorg/lib/libxcb
variables:
GIT_DEPTH: 100
artifacts:
reports:
junit: results.xml
#
# Verify that the merge request has the allow-collaboration checkbox ticked
#
check-merge-request:
extends:
- .fdo.ci-fairy
stage: deploy
script:
- ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
artifacts:
when: on_failure
reports:
junit: results.xml
allow_failure: true
#
# Build a container with the given tag and the packages pre-installed.
# This only happens if/when the tag changes, otherwise the existing image is
# re-used.
#
container-prep:
extends:
- .fdo.container-build@arch
stage: prep
variables:
GIT_STRATEGY: none
#
# Build latest xcbproto from git, instead of relying on the container
# to package a new enough version.
#
xcbproto-build:
extends:
- .fdo.distribution-image@arch
stage: install xcbproto
script:
- export INSTDIR="$PWD/_inst"
- git clone --depth=1 https://gitlab.freedesktop.org/xorg/proto/xcbproto
- pushd xcbproto > /dev/null
- mkdir _builddir
- pushd _builddir > /dev/null
- ../autogen.sh --disable-silent-rules --prefix="$INSTDIR"
- make -j${FDO_CI_CONCURRENT:-4} install
- popd > /dev/null
- popd > /dev/null
variables:
artifacts:
paths:
- _inst
#
# The default build, runs on the image built above.
#
build:
stage: build
extends:
- .fdo.distribution-image@arch
script:
- export INSTDIR="$PWD/_inst"
- export PKG_CONFIG_PATH=$(find $INSTDIR/ -name '*.pc' -printf "%h:")
- autoreconf -ivf
- mkdir _builddir
- pushd _builddir > /dev/null
- ../configure --disable-silent-rules --enable-devel-docs --with-doxygen
- make
- make check
- make distcheck
- popd > /dev/null

229
INSTALL
View File

@ -1,229 +0,0 @@
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
will cause the specified gcc to be used as the C compiler (unless it is
overridden in the site shell script).
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@ -1,55 +1,118 @@
SUBDIRS=src tests doc
ACLOCAL_AMFLAGS=-I m4
SUBDIRS=src tests doc man
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = \
xcb.pc \
xcb-xlib.pc \
xcb-composite.pc \
xcb-damage.pc \
xcb-dpms.pc \
xcb-glx.pc \
xcb-randr.pc \
xcb-record.pc \
xcb-render.pc \
xcb-res.pc \
xcb-screensaver.pc \
xcb-shape.pc \
xcb-shm.pc \
xcb-sync.pc \
xcb-xevie.pc \
xcb-xf86dri.pc \
xcb-xfixes.pc \
xcb-xinerama.pc \
xcb-xprint.pc \
xcb-xtest.pc \
xcb-xv.pc \
xcb-xvmc.pc
pkgconfig_DATA = xcb.pc
if BUILD_COMPOSITE
pkgconfig_DATA += xcb-composite.pc
endif
if BUILD_DAMAGE
pkgconfig_DATA += xcb-damage.pc
endif
if BUILD_DBE
pkgconfig_DATA += xcb-dbe.pc
endif
if BUILD_DPMS
pkgconfig_DATA += xcb-dpms.pc
endif
if BUILD_DRI2
pkgconfig_DATA += xcb-dri2.pc
endif
if BUILD_DRI3
pkgconfig_DATA += xcb-dri3.pc
endif
if BUILD_GLX
pkgconfig_DATA += xcb-glx.pc
endif
if BUILD_PRESENT
pkgconfig_DATA += xcb-present.pc
endif
if BUILD_RANDR
pkgconfig_DATA += xcb-randr.pc
endif
if BUILD_RECORD
pkgconfig_DATA += xcb-record.pc
endif
if BUILD_RENDER
pkgconfig_DATA += xcb-render.pc
endif
if BUILD_RESOURCE
pkgconfig_DATA += xcb-res.pc
endif
if BUILD_SCREENSAVER
pkgconfig_DATA += xcb-screensaver.pc
endif
if BUILD_SHAPE
pkgconfig_DATA += xcb-shape.pc
endif
if BUILD_SHM
pkgconfig_DATA += xcb-shm.pc
endif
if BUILD_SYNC
pkgconfig_DATA += xcb-sync.pc
endif
if BUILD_XEVIE
pkgconfig_DATA += xcb-xevie.pc
endif
if BUILD_XFREE86_DRI
pkgconfig_DATA += xcb-xf86dri.pc
endif
if BUILD_XFIXES
pkgconfig_DATA += xcb-xfixes.pc
endif
if BUILD_XINERAMA
pkgconfig_DATA += xcb-xinerama.pc
endif
if BUILD_XINPUT
pkgconfig_DATA += xcb-xinput.pc
endif
if BUILD_XKB
pkgconfig_DATA += xcb-xkb.pc
endif
if BUILD_XPRINT
pkgconfig_DATA += xcb-xprint.pc
endif
if BUILD_SELINUX
pkgconfig_DATA += xcb-xselinux.pc
endif
if BUILD_XTEST
pkgconfig_DATA += xcb-xtest.pc
endif
if BUILD_XV
pkgconfig_DATA += xcb-xv.pc
endif
if BUILD_XVMC
pkgconfig_DATA += xcb-xvmc.pc
endif
if BUILD_GE
pkgconfig_DATA += xcb-ge.pc
endif
AM_TESTS_ENVIRONMENT = \
AM_SRCDIR=${srcdir}
TESTS=check-pc-requires
EXTRA_DIST = \
xcb.pc.in \
xcb-xlib.pc.in \
xcb-composite.pc.in \
xcb-damage.pc.in \
xcb-dpms.pc.in \
xcb-glx.pc.in \
xcb-randr.pc.in \
xcb-record.pc.in \
xcb-render.pc.in \
xcb-res.pc.in \
xcb-screensaver.pc.in \
xcb-shape.pc.in \
xcb-shm.pc.in \
xcb-sync.pc.in \
xcb-xevie.pc.in \
xcb-xinerama.pc.in \
xcb-xf86dri.pc.in \
xcb-xfixes.pc.in \
xcb-xprint.pc.in \
xcb-xtest.pc.in \
xcb-xv.pc.in \
xcb-xvmc.pc.in \
tools/README \
tools/api_conv.pl \
tools/constants \
autogen.sh
autogen.sh \
README.md \
$(TESTS)
MAINTAINERCLEANFILES = ChangeLog INSTALL
.PHONY: ChangeLog INSTALL
INSTALL:
$(INSTALL_CMD)
ChangeLog:
$(CHANGELOG_CMD)
dist-hook: ChangeLog INSTALL

244
NEWS
View File

@ -1,3 +1,247 @@
Release 1.14 (2020-02-22)
=========================
* Add xcb_total_read() and xcb_total_written() API
* Support check >= 0.13 API (for make check)
* Bug fix to handle EINTR from recvmsg
* Only require pthread-stubs on non-Linux platforms
Release 1.13.1 (2018-09-27)
===========================
* Don't flag extra reply in xcb_take_socket
Release 1.13 (2018-02-28)
=========================
* Add support for variable-sized lists of FDs
* Poll for events when blocking waiting for special events
* xinput: Enable XInput extension by default
* ge: Add explicit support for GenericEvent extension
* Fix documentation warnings from clang
* Cosmetic cleanups
Release 1.12 (2016-05-18)
=========================
* configure: Various fixes for dri3 and FD passing support
* configure: Don't report all the warning CFLAGS
* configure: Disable Xevie and Xprint by default
* Add support for various new constructs in the XML schema
* Make some functions also accept connections in an error state
* Never return NULL from xcb_get_setup()
* Use Requires.private in .pc files to avoid overlinking
* Fix align-pads for switches which start at unaligned positions
* Use anonymous structs for some nested structs
* Also generate accessors for variable-sized events and requests
* Improved python3 compatibility
* Generate C99 initializers instead of comments
* Various simplifications to the python code
* Fix line breaks in xcb-requests manual page
* Always close FDs in xcb_send_fd()
* Fix thread-safety issues with FD passing
* Add xcb_send_request_with_fds() and xcb_send_request_with_fds64()
* Fix endless loop with too many outstanding FDs to send
* Link with winsock library on MinGW
* Disable some unfinished API for some server-side code by default
* Use align-offsets computed by xcb-proto instead of low bits of pointers
* Fix iterator interaction with align padding
* Stop serializing padding by default
* Increase unix socket send buffer to at least 64KiB
Release 1.11.1 (2015-09-06)
===========================
* Expose 64-bit sequence numbers for XLib
* Fix some hangs related to xcb_wait_for_special_event()
Release 1.11 (2014-08-01)
=========================
* Force structures with 64-bit fields to be packed
* Add support for <pad align="n">
* Use X.org's build machinery from xorg-macros
* Fix leak with xcb_disconnect() and connections in an error state
* Make xcb_disconnect(NULL) safe
* Use less #include statements in generated code
* Automatically validate the Requires lines in our .pc.in files
* Fix a race that resulted in a failed assertion
* Improve launchd secure socket support
* Improve API documentation
* Remove trailing whitespaces
* c_client.py: prefix all monkey-patched fields with c_
* c_client.py: make the man page output deterministic
* c_client.py: remove useless generated comments
* xcb.h: add 'struct' before xcb_setup_t, xcb_query_extension_reply_t
Release 1.10 (2013-12-22)
=========================
* Bump libxcb-xkb SONAME due to ABI break introduced in 1.9.2
* Enable libxcb-xkb by default
* Bump libxcb-sync SONAME
* c_client.py: Fix _sizeof() functions
* c_client.py: Do not create pointers in unions
* c_client.py: Always initialize xcb_align_to
* Re-introduce xcb_ge_event_t (deprecated, xcb_ge_generic_event_t should be
used instead)
* Fix alignment issues in FD passing code
* Fix poll() if POLLIN == ROLLRDNORM|POLLRDBAND
* Use /usr/spool/sockets/X11/ on HP-UX for UNIX sockets
* Make xsltproc optional
Release 1.9.3 (2013-11-07)
==========================
* Check if we need to define _XOPEN_SOURCE for struct msghdr.msg_control
* Add configure option to enable or disable fd passing with sendmsg
* Switch to using the CMSG_* macros for FD passing
* Initialize automake earlier (bugfix for #66413)
Release 1.9.2 (2013-11-07)
==========================
* Add Present extension
* Add DRI3 library
* Add event queue splitting
* Add support for receiving fds in replies
* Add xcb_send_fd API
* Remove xcb_ge_event_t from xcb.h
* c_client.py: Inject full_sequence into GE events
* c_client.py: Handle multiple expr. in a bitcase
Release 1.9.1 (2013-05-30)
==========================
* Fix python code to work with python-3
* Security fix for integer overflow in read_packet() [CVE-2013-2064]
Release 1.9 (2012-10-05)
========================
* Always include "config.h" at the start of all C source files.
* Add AC_USE_SYSTEM_EXTENSIONS to allow use of more system functionality
* Return connection failure if display string specifies non-existent screen
* c_client: Fix parallel-make issue creating 'man' directory
* xcb_connect: launchd: Don't fall back on tcp if $DISPLAY is a path to a launchd socket
* c_client.py: generate manpages
* Allow xcb_send_request with >MAX_IOV iovecs
* Add a .gitignore for src/man/
* Fix a multi-thread deadlock
Release 1.8.1 (2012-03-09)
==========================
- Fix a busy loop on BSD and Mac OS
- Bump xcb-proto requirement
- Fallback to TCP if no protocol is specified and the UNIX connection fails
- Update use of error_connection under WIN32 to _xcb_conn_ret_error()
- Fix build of xcb_auth.c with XDMCP on WIN32
- Revert "Fix include order with Xdmcp on WIN32"
- darwin: Use read(2) rather than recv(2)
- Add xkb_internals and xkb_issues to EXTRA_DIST.
Release 1.8 (2012-01-11)
========================
- xcb_disconnect: call shutdown() to force a disconnect
- Use special path to sockets when running under Solaris Trusted Extensions
- Remove unused DECnet code
- Add #include <sys/socket.h> to xcb_conn.c
- Make launchd code in xcb_util.c match surrounding code indent levels
- If protocol is "unix", use a Unix domain socket, not TCP
- Added more error states and removed global error_connection
- Handle XGE events with the "send event" flag
- added xcb_sumof() with restriction to uint8_t
- xkb: updated configure.ac/Makefile.am
- xkb: added pkg config file
- special case 'intermixed variable and fixed size fields': fixed reply side, needs testing
- added accessors for special cases
- Add support for building with Python 3
- Insert, not append explicit xcbgen dir python path
- xcb_request_check: Sync even if an event was read for this sequence.
- _xcb_conn_wait: Shut down the connection on unexpected poll() events.
- xcb_send_request: Send all requests using a common internal send_request.
- xcb_request_check: Hold the I/O lock while deciding to sync.
- xcb_discard_reply: Simplify by re-using poll_for_reply helper.
- xcb_in: Use 64-bit sequence numbers internally everywhere.
- Enable AM_SILENT_RULES on automake 1.11 or newer.
- Factor reader_list management out of wait_for_reply.
- Dequeue readers that can't receive any new responses.
- Delete the old c-client.xsl.
- Keep ALIGNOF definition out of the public namespace.
- darwin: Don't use poll() when expected to run on darwin10 and prior
- Add Win32
- Allow disconnecting connections that are in error state.
- Make xcb_take_socket keep flushing until idle
- Support pre-IPv6 systems (without getaddrinfo)
- Drop AI_ADDRCONFIG when resolving TCP addresses
- xcb_auth: Fix memory leak in _xcb_get_auth_info.
- Don't emit out-of-module sizeof definitions
- Clean up a couple of warnings in xprint
- Prevent reply waiters from being blocked.
- Prevent theoretical double free and leak on get_peer_sock_name.
- Introduce a variant of xcb_poll_for_event for examining event queue.
- xcb_take_socket: Document sequence wrap requirements
- Compute alignment correctly
- Fix a dead-lock due to xcb_poll_for_reply
Release 1.7 (2010-08-13)
========================
- Always wake up readers after writing
- Get rid of PATH_MAX and MAXPATHLEN
- Add ~ operator support in code generator
- xcb_open: Improve protocol/host parsing
- xcb_connect_to_display_with_auth_info: Fix memory leak
- Report which extensions are being built
Release 1.6 (2010-04-09)
========================
- darwin: xnu doesn't support poll on ttys on the master side
- Fix descriptor leak on memory error path
- Support xcb_discard_reply
- Open the X11 socket with close-on-exec flag
- Fix authentication on hpux and Hurd
Release 1.5 (2009-12-03)
========================
- setsockopt(SO_KEEPALIVE) on TCP display connections
- Add DRI2 support
- Fix check dependency
- Cygwin build fix: Add -no-undefined to libtool flags
Release 1.4 (2009-07-15)
========================
* Add majorCode, minorCode and resourceID fields to X generic error
* Fix precedence bug: wrong length for big-requests preceded by sync
* Fix libxcb-randr version info
Release 1.3 (2009-05-29)
========================
* Copy full IPv4 mapping (Bug #20665)
* Fix XID allocation
* Use poll() instead of select() when available
* Fix local socket connection on Hurd
* Fix XDM-AUTHORIZATION-1
* Disable Nagle on TCP socket
Release 1.2 (2009-02-17)
========================
* Stop packaging auto-generated C files into tarball.
Release 1.1.93 (2008-12-11)
===========================
Enhancements:
* Apple: Enable support for launchd DISPLAY socket
* Treat XIDs the same as other cardinal values.
Release 1.1.92 (2008-11-01)
===========================
Enhancements:
* Added small fix to support trailing fixed fields; also warning for non-pad fixed fields
* Fixed overly aggressive warning about fixed field following variable
* Added generation of extern "C" for compatibility with C++
* Remove libxcb-xlib and xcbxlib.h.
* Inline _xcb_lock_io, _xcb_unlock_io, and _xcb_wait_io.
* Track 64-bit sequence numbers internally.
* Use sequence number ranges in pending replies
* Remove duplicate XCB_EXTENSION calls for Composite extension
* Factorize m4 macros and add one to set X extensions
* Allow compile-time setting for XCB queue buffer size
* Support handing off socket write permission to external code.
* Add support for the abstract socket namespace under Linux
Bug fixes:
* Fix tiny memory leak in read_packet
* Fix some fd leaks in _xcb_open_*()
Release 1.1 (2007-11-04)
========================

View File

@ -2,7 +2,7 @@ About libxcb
============
libxcb provides an interface to the X Window System protocol, which
replaces the current Xlib interface. It has several advantages over
replaces the traditional Xlib interface. It has several advantages over
Xlib, including:
- size: small, simple library, and lower memory footprint
- latency hiding: batch several requests and wait for the replies later
@ -10,27 +10,32 @@ Xlib, including:
- proven thread support: transparently access XCB from multiple threads
- easy extension implementation: interfaces auto-generated from XML-XCB
Xlib can also use XCB as a transport layer, allowing software to make
Xlib also uses XCB as a transport layer, allowing software to make
requests and receive responses with both, which eases porting to XCB.
However, client programs, libraries, and toolkits will gain the most
benefit from a native XCB port.
More information about xcb is available from our website:
Please report any issues you find to the freedesktop.org bug tracker,
at:
https://xcb.freedesktop.org/
<https://bugs.freedesktop.org/enter_bug.cgi?product=XCB>
Please report any issues you find to the freedesktop.org bug tracker at:
https://gitlab.freedesktop.org/xorg/lib/libxcb/issues
Discussion about XCB occurs on the XCB mailing list:
<mailto:xcb at lists.freedesktop.org>
<http://lists.freedesktop.org/mailman/listinfo/xcb>
https://lists.freedesktop.org/mailman/listinfo/xcb
You can obtain the latest development versions of XCB using GIT.
For anonymous checkouts, use:
You can obtain the latest development versions of XCB using GIT from
the libxcb code repository at:
git clone git://anongit.freedesktop.org/git/xcb/libxcb
https://gitlab.freedesktop.org/xorg/lib/libxcb
For developers, use:
For anonymous checkouts, use:
git clone git+ssh://git.freedesktop.org/git/xcb/libxcb
git clone https://gitlab.freedesktop.org/xorg/lib/libxcb.git
For developers, use:
git clone git@gitlab.freedesktop.org:xorg/lib/libxcb.git

View File

@ -1,109 +0,0 @@
dnl Detection and configuration of the visibility feature of gcc
dnl Vincent Torri 2006-02-11
dnl
dnl GCC_CHECK_VISIBILITY([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Check the visibility feature of gcc
dnl
AC_DEFUN([GCC_CHECK_VISIBILITY],
[AC_MSG_CHECKING([whether ${CC} supports symbol visibility])
save_CFLAGS=${CFLAGS}
CFLAGS="$CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#pragma GCC visibility push(hidden)
extern void f(int);
#pragma GCC visibility pop
]],
[[]]
)],
[AC_DEFINE(
GCC_HAS_VISIBILITY,
[],
[Defined if GCC supports the visibility feature])
m4_if([$1], [], [:], [$1])
AC_MSG_RESULT(yes)],
[m4_if([$2], [], [:], [$2])
AC_MSG_RESULT(no)])
CFLAGS=${save_CFLAGS}
])
dnl Configure script for doxygen
dnl Vincent Torri 2006-05-11
dnl
dnl AM_CHECK_DOXYGEN([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for the doxygen program, and define BUILD_DOCS and DOXYGEN.
dnl
AC_DEFUN([AM_CHECK_DOXYGEN],
[
DOXYGEN="doxygen"
dnl
dnl Disable the build of the documentation
dnl
AC_ARG_ENABLE(
[build_docs],
AC_HELP_STRING(
[--disable-build-docs],
[Disable the build of the documentation]),
[if test x"$enableval" != x"yes" ; then
enable_build_docs="no"
else
enable_build_docs="yes"
fi],
[enable_build_docs="yes"])
if test "$enable_build_docs" = "no" ; then
BUILD_DOCS=no
else
dnl
dnl Get the prefix where doxygen is installed.
dnl
AC_ARG_WITH(
[doxygen],
AC_HELP_STRING(
[--with-doxygen=FILE],
[doxygen program to use (eg /usr/bin/doxygen)]),
dnl
dnl Check the given doxygen program.
dnl
[DOXYGEN=${withval}
AC_CHECK_PROG(
[BUILD_DOCS],
[${DOXYGEN}],
[yes],
[no])
if test $BUILD_DOCS = no; then
echo "WARNING:"
echo "The doxygen program you specified:"
echo "$DOXYGEN"
echo "was not found. Please check the path and make sure "
echo "the program exists and is executable."
AC_MSG_WARN(
[Warning: no doxygen detected. Documentation will not be built])
fi],
[AC_CHECK_PROG(
[BUILD_DOCS],
[${DOXYGEN}],
[yes],
[no])
if test ${BUILD_DOCS} = no; then
echo "WARNING:"
echo "The doxygen program was not found in your execute"
echo "You may have doxygen installed somewhere not covered by your path."
echo ""
echo "If this is the case make sure you have the packages installed, AND"
echo "that the doxygen program is in your execute path (see your"
echo "shell's manual page on setting the \$PATH environment variable), OR"
echo "alternatively, specify the program to use with --with-doxygen."
AC_MSG_WARN(
[Warning: no doxygen detected. Documentation will not be built])
fi])
fi
AC_MSG_CHECKING([whether documentation is built])
AC_MSG_RESULT([${BUILD_DOCS}])
dnl
dnl Substitution
dnl
AC_SUBST([DOXYGEN])
AM_CONDITIONAL(BUILD_DOCS, test "x$BUILD_DOCS" = "xyes")
])
dnl End of acinclude.m4

View File

@ -1,12 +1,17 @@
#! /bin/sh
srcdir=`dirname $0`
srcdir=`dirname "$0"`
test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd`
cd $srcdir
cd "$srcdir"
autoreconf -v --install || exit 1
cd $ORIGDIR || exit $?
cd "$ORIGDIR" || exit $?
$srcdir/configure --enable-maintainer-mode "$@"
git config --local --get format.subjectPrefix >/dev/null 2>&1 ||
git config --local format.subjectPrefix "PATCH libxcb"
if test -z "$NOCONFIGURE"; then
exec "$srcdir"/configure "$@"
fi

70
check-pc-requires Executable file
View File

@ -0,0 +1,70 @@
#!/bin/sh
case "$AM_SRCDIR" in
"")
AM_SRCDIR="."
;;
*)
;;
esac
fix=n
status=0
case "$1" in
"-fix")
fix=y
;;
esac
for inc in src/*.h; do
package=xcb-`basename $inc .h`
pcin="$AM_SRCDIR"/$package.pc.in
if [ -f $pcin ]; then
included=`grep '# *include' $inc |
sed -e 's/[^<"]*[<"]//' -e 's/[>"]//' |
grep -v 'xcb.h\|xproto.h'`
requires=`grep '^Requires.private:' $pcin`
missing=""
for i in $included; do
ibase=`basename $i .h`
r="xcb-$ibase"
rpcin="$AM_SRCDIR"/$r.pc.in
if [ -f $rpcin ]; then
m="$r"
for has in $requires; do
if [ $has = $r ]; then
m=""
fi
done
case "$m" in
"")
;;
*)
case "$missing" in
"")
missing=$m
;;
*)
missing="$missing $m"
;;
esac
;;
esac
fi
done
case "$missing" in
"")
;;
*)
if [ "$fix" = "y" ]; then
echo $package adding dependency on $missing
sed -i '/^Requires.private:/s/$/ '"$missing"'/' $pcin
else
echo $package missing $missing
status=1
fi
;;
esac
fi
done
exit $status

View File

@ -1,54 +1,77 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT([libxcb],
1.1,
[xcb@lists.freedesktop.org])
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([libxcb],[1.17.0],
[https://gitlab.freedesktop.org/xorg/lib/libxcb/-/issues],
[libxcb])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([xcb.pc.in])
AM_INIT_AUTOMAKE([foreign dist-bzip2])
PKG_CHECK_MODULES(CHECK, [check >= 0.9.4], [HAVE_CHECK=yes], [HAVE_CHECK=no])
AM_CONDITIONAL(HAVE_CHECK, test x$HAVE_CHECK = xyes)
AC_CONFIG_HEADERS([src/config.h])
AC_PROG_LIBTOOL
AC_PROG_CC
# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-xz])
AM_PATH_PYTHON([3.0])
AC_PATH_PROG(XSLTPROC, xsltproc, no)
if test "$XSLTPROC" = "no"; then
AC_MSG_ERROR([XCB requires xsltproc.])
# Set common system defines for POSIX extensions, such as _GNU_SOURCE
# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL)
# to avoid autoconf errors.
AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
# Initialize libtool
LT_PREREQ([2.2])
LT_INIT([win32-dll])
# Require xorg-macros minimum of 1.18 - Initial version
m4_ifndef([XORG_MACROS_VERSION],
[m4_fatal([must install xorg-macros 1.18 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.18)
XORG_DEFAULT_OPTIONS
XORG_ENABLE_DEVEL_DOCS
XORG_WITH_DOXYGEN
# The dot drawing tool is checked by XORG_WITH_DOXYGEN, needed for xcb manual
if test x"$HAVE_DOT" = xno; then
AC_MSG_WARN([dot not found - doxygen targets will be skipped])
fi
HTML_CHECK_RESULT=false
PKG_CHECK_MODULES(CHECK, [check >= 0.9.6], [HAVE_CHECK=yes], [HAVE_CHECK=no])
AM_CONDITIONAL(HAVE_CHECK, test x$HAVE_CHECK = xyes)
XSLTPROC=no
HTML_CHECK_RESULT=no
if test x"$HAVE_CHECK" = xyes; then
if test x"$XSLTPROC" != xno; then
HTML_CHECK_RESULT=true
fi
AC_PATH_PROG(XSLTPROC, xsltproc, no)
if test x"$XSLTPROC" != xno; then
HTML_CHECK_RESULT=yes
fi
fi
AC_SUBST(HTML_CHECK_RESULT)
# Checks for pkg-config packages
PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.1)
NEEDED="pthread-stubs xau >= 0.99.2"
PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.17.0)
NEEDED="xau >= 0.99.2"
case $host_os in
linux*|darwin*|solaris*|dragonfly*|freebsd*|netbsd*) ;;
*) NEEDED="$NEEDED pthread-stubs" ;;
esac
PKG_CHECK_MODULES(NEEDED, $NEEDED)
have_xdmcp="no"
PKG_CHECK_MODULES(XDMCP, xdmcp,
AC_CHECK_LIB(Xdmcp, XdmcpWrap,
[
AC_DEFINE(HASXDMAUTH,1,[Has Wraphelp.c needed for XDM AUTH protocols])
NEEDED="$NEEDED xdmcp"
have_xdmcp="yes"
],
[
XDMCP_CFLAGS=
XDMCP_LIBS=
], [$XDMCP_LIBS]),
[AC_MSG_RESULT(no)])
AC_CHECK_HEADER([execinfo.h], [AC_DEFINE(HAVE_BACKTRACE,1,[Has backtrace*() needed for retrieving stack traces])])
AC_CHECK_LIB(Xdmcp, XdmcpWrap,
[
AC_DEFINE(HASXDMAUTH,1,[Has Wraphelp.c needed for XDM AUTH protocols])
NEEDED="$NEEDED xdmcp"
have_xdmcp="yes"
],
[
XDMCP_CFLAGS=
XDMCP_LIBS=
], [$XDMCP_LIBS]),
[AC_MSG_RESULT(no)])
AC_SUBST(NEEDED)
@ -58,37 +81,220 @@ XCBPROTO_XCBINCLUDEDIR=`$PKG_CONFIG --variable=xcbincludedir xcb-proto`
AC_MSG_RESULT($XCBPROTO_XCBINCLUDEDIR)
AC_SUBST(XCBPROTO_XCBINCLUDEDIR)
AC_HEADER_STDC
# Find the xcb-proto version
XCBPROTO_VERSION=`$PKG_CONFIG --modversion xcb-proto`
AC_SUBST(XCBPROTO_VERSION)
# Find the xcbgen Python package
AC_MSG_CHECKING(XCBPROTO_XCBPYTHONDIR)
XCBPROTO_XCBPYTHONDIR=`$PKG_CONFIG --variable=pythondir xcb-proto`
AC_MSG_RESULT($XCBPROTO_XCBPYTHONDIR)
AC_SUBST(XCBPROTO_XCBPYTHONDIR)
AC_SEARCH_LIBS(getaddrinfo, socket)
AC_SEARCH_LIBS(connect, socket)
# Find support for sending a message from a socket
AC_SEARCH_LIBS(sendmsg, socket, [have_sendmsg="yes"], [have_sendmsg="no"])
# XPG4v2/UNIX95 added msg_control - check to see if we need to define
# _XOPEN_SOURCE to get it (such as on Solaris)
AC_CHECK_MEMBER([struct msghdr.msg_control], [], [],
[
AC_INCLUDES_DEFAULT
#include <sys/socket.h>
])
# First try for Solaris in C99 compliant mode, which requires XPG6/UNIX03
if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
unset ac_cv_member_struct_msghdr_msg_control
AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=600])
AC_CHECK_MEMBER([struct msghdr.msg_control],
[AC_DEFINE([_XOPEN_SOURCE], [600],
[Defined if needed to expose struct msghdr.msg_control])
], [], [
#define _XOPEN_SOURCE 600
AC_INCLUDES_DEFAULT
#include <sys/socket.h>
])
fi
# If that didn't work, fall back to XPG5/UNIX98 with C89
if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
unset ac_cv_member_struct_msghdr_msg_control
AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=500])
AC_CHECK_MEMBER([struct msghdr.msg_control],
[AC_DEFINE([_XOPEN_SOURCE], [500],
[Defined if needed to expose struct msghdr.msg_control])
], [have_sendmsg="no"], [
#define _XOPEN_SOURCE 500
AC_INCLUDES_DEFAULT
#include <sys/socket.h>
])
fi
case x$have_sendmsg in
xyes)
AC_DEFINE([HAVE_SENDMSG],1,[Define if your platform supports sendmsg])
;;
esac
have_win32="no"
lt_enable_auto_import=""
case $host_os in
mingw*)
have_win32="yes"
lt_enable_auto_import="-Wl,--enable-auto-import"
;;
linux*)
AC_DEFINE([HAVE_ABSTRACT_SOCKETS], 1, [Define if your platform supports abstract sockets])
;;
esac
AC_SUBST(lt_enable_auto_import)
AM_CONDITIONAL([XCB_HAVE_WIN32], [test "x${have_win32}" = "xyes"])
dnl define buffer queue size
AC_ARG_WITH([queue-size],
AS_HELP_STRING([--with-queue-size=SIZE],
[Set the XCB buffer queue size (default is 16384)]),
[xcb_queue_buffer_size="$withval"],
[xcb_queue_buffer_size=16384])
AC_DEFINE_UNQUOTED(XCB_QUEUE_BUFFER_SIZE, [$xcb_queue_buffer_size],
[XCB buffer queue size])
dnl check for the sockaddr_un.sun_len member
AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
[AC_DEFINE(HAVE_SOCKADDR_SUN_LEN,1,[Have the sockaddr_un.sun_len member.])],
[],
[ #include <sys/types.h>
#include <sys/un.h>
])
dnl check for support for Solaris Trusted Extensions
AC_CHECK_HEADERS([tsol/label.h])
AC_CHECK_FUNCS([is_system_labeled])
dnl check for IOV_MAX, and fall back to UIO_MAXIOV on BSDish systems
AC_CHECK_DECL([IOV_MAX], [],
[AC_CHECK_DECL([UIO_MAXIOV], [AC_DEFINE([IOV_MAX], [UIO_MAXIOV])],
[AC_DEFINE([IOV_MAX], [16], [Define if not provided by <limits.h>])],
[[#include <sys/uio.h>]])],
[[#include <limits.h>]])
xcbincludedir='${includedir}/xcb'
AC_SUBST(xcbincludedir)
if test "x$GCC" = xyes ; then
CWARNFLAGS="-Wall -pedantic -Wpointer-arith \
-Wstrict-prototypes -Wmissing-declarations -Wnested-externs"
else
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
if test "x$SUNCC" = "xyes"; then
CWARNFLAGS="-v"
fi
fi
AC_SUBST(CWARNFLAGS)
XCB_CHECK_VISIBILITY()
GCC_CHECK_VISIBILITY()
AC_CHECK_FUNC(getaddrinfo, [AC_DEFINE(HAVE_GETADDRINFO, 1, [getaddrinfo() function is available])], )
# htmldir is not defined prior to autoconf 2.59c, so on earlier versions
# set an equivalent value.
AC_PREREQ([2.59c], [], [AC_SUBST([htmldir], [m4_ifset([AC_PACKAGE_TARNAME],
['${datadir}/doc/${PACKAGE_TARNAME}'],
['${datadir}/doc/${PACKAGE}'])
])])
AM_CHECK_DOXYGEN()
case $host_os in
# darwin through Snow Leopard has poll() but can't be used to poll character devices.
darwin@<:@789@:>@*|darwin10*) ;;
darwin*)
_ac_xorg_macosx_version_min=""
if echo $CPPFLAGS $CFLAGS | grep -q mmacosx-version-min ; then
_ac_xorg_macosx_version_min=`echo $CPPFLAGS $CFLAGS | sed 's/^.*-mmacosx-version-min=\(@<:@^ @:>@*\).*$/\1/'`
else
_ac_xorg_macosx_version_min=$MACOSX_DEPLOYMENT_TARGET
fi
case $_ac_xorg_macosx_version_min in
10.@<:@0123456@:>@|10.@<:@0123456@:>@.*) ;;
*)
AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
;;
esac
unset _ac_xorg_macosx_version_min
;;
*)
AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], )
;;
esac
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/Makefile])
AC_CONFIG_FILES([xcb.pc xcb-xlib.pc xcb-composite.pc xcb-damage.pc xcb-dpms.pc xcb-glx.pc xcb-randr.pc xcb-record.pc xcb-render.pc xcb-res.pc xcb-screensaver.pc xcb-shape.pc xcb-shm.pc xcb-sync.pc xcb-xevie.pc xcb-xf86dri.pc xcb-xfixes.pc xcb-xinerama.pc xcb-xprint.pc xcb-xtest.pc xcb-xv.pc xcb-xvmc.pc])
AC_CONFIG_FILES([doc/xcb.doxygen])
dnl Link with winsock for socket functions on MinGW
case $host_os in
*mingw*)
AC_CHECK_LIB([ws2_32],[main])
;;
*)
;;
esac
XCB_EXTENSION(Composite, yes)
XCB_EXTENSION(Damage, yes)
XCB_EXTENSION(Dbe, yes)
XCB_EXTENSION(DPMS, yes)
XCB_EXTENSION(DRI2, yes)
XCB_EXTENSION(DRI3, $have_sendmsg)
XCB_EXTENSION(GE, no)
XCB_EXTENSION(GLX, yes)
XCB_EXTENSION(Present, yes)
XCB_EXTENSION(RandR, yes)
XCB_EXTENSION(Record, yes)
XCB_EXTENSION(Render, yes)
XCB_EXTENSION(Resource, yes)
XCB_EXTENSION(Screensaver, yes)
XCB_EXTENSION(Shape, yes)
XCB_EXTENSION(Shm, yes)
XCB_EXTENSION(Sync, yes)
XCB_EXTENSION(Xevie, no)
XCB_EXTENSION(XFixes, yes)
XCB_EXTENSION(XFree86-DRI, yes)
XCB_EXTENSION(Xinerama, yes)
XCB_EXTENSION(XInput, yes)
XCB_EXTENSION(XKB, yes)
XCB_EXTENSION(Xprint, no)
XCB_EXTENSION(SELinux, no)
XCB_EXTENSION(XTest, yes)
XCB_EXTENSION(Xv, yes)
XCB_EXTENSION(XvMC, yes)
AC_ARG_WITH(serverside-support, AS_HELP_STRING([--with-serverside-support], [Build with support for server-side usage of xcb. This is still EXPERIMENTAL! ABI/API may change! (default: no)]), [XCB_SERVERSIDE_SUPPORT=$withval], [XCB_SERVERSIDE_SUPPORT=no])
AM_CONDITIONAL(XCB_SERVERSIDE_SUPPORT, test "x$XCB_SERVERSIDE_SUPPORT" = "xyes")
AC_CONFIG_FILES([
Makefile
doc/Makefile
man/Makefile
src/Makefile
tests/Makefile
])
AC_CONFIG_FILES([
xcb.pc
xcb-composite.pc
xcb-damage.pc
xcb-dbe.pc
xcb-dpms.pc
xcb-dri2.pc
xcb-dri3.pc
xcb-ge.pc
xcb-glx.pc
xcb-present.pc
xcb-randr.pc
xcb-record.pc
xcb-render.pc
xcb-res.pc
xcb-screensaver.pc
xcb-shape.pc
xcb-shm.pc
xcb-sync.pc
xcb-xevie.pc
xcb-xf86dri.pc
xcb-xfixes.pc
xcb-xinerama.pc
xcb-xinput.pc
xcb-xkb.pc
xcb-xprint.pc
xcb-xselinux.pc
xcb-xtest.pc
xcb-xv.pc
xcb-xvmc.pc
])
AC_CONFIG_FILES([
doc/xcb.doxygen
])
AC_OUTPUT
@ -99,12 +305,43 @@ echo " Package: ${PACKAGE_NAME} ${PACKAGE_VERSION}"
echo ""
echo " Configuration"
echo " XDM support.........: ${have_xdmcp}"
echo " sendmsg fd passing..: ${have_sendmsg}"
echo " Build unit tests....: ${HAVE_CHECK}"
echo " with html results.: ${HTML_CHECK_RESULT}"
echo " XCB buffer size.....: ${xcb_queue_buffer_size}"
echo ""
echo " X11 extensions"
echo " Composite...........: ${BUILD_COMPOSITE}"
echo " Damage..............: ${BUILD_DAMAGE}"
echo " Dbe.................: ${BUILD_DBE}"
echo " Dpms................: ${BUILD_DPMS}"
echo " Dri2................: ${BUILD_DRI2}"
echo " Dri3................: ${BUILD_DRI3}"
echo " GenericEvent........: ${BUILD_GE}"
echo " Glx.................: ${BUILD_GLX}"
echo " Randr...............: ${BUILD_RANDR}"
echo " Record..............: ${BUILD_RECORD}"
echo " Render..............: ${BUILD_RENDER}"
echo " Resource............: ${BUILD_RESOURCE}"
echo " Screensaver.........: ${BUILD_SCREENSAVER}"
echo " selinux.............: ${BUILD_SELINUX}"
echo " Shape...............: ${BUILD_SHAPE}"
echo " Shm.................: ${BUILD_SHM}"
echo " Sync................: ${BUILD_SYNC}"
echo " Xevie...............: ${BUILD_XEVIE}"
echo " Xfixes..............: ${BUILD_XFIXES}"
echo " Xfree86-dri.........: ${BUILD_XFREE86_DRI}"
echo " xinerama............: ${BUILD_XINERAMA}"
echo " xinput..............: ${BUILD_XINPUT}"
echo " xkb.................: ${BUILD_XKB}"
echo " xprint..............: ${BUILD_XPRINT}"
echo " xtest...............: ${BUILD_XTEST}"
echo " xv..................: ${BUILD_XV}"
echo " xvmc................: ${BUILD_XVMC}"
echo ""
echo " Used CFLAGS:"
echo " CPPFLAGS............: ${CPPFLAGS}"
echo " CFLAGS..............: ${CFLAGS}"
echo " Warning CFLAGS......: ${CWARNFLAGS}"
echo ""
echo " Installation:"
echo " Prefix..............: ${prefix}"

View File

@ -2,11 +2,15 @@
EXTRA_DIST = \
tutorial/index.html \
tutorial/xcb.css \
xcb.doxygen.in
xcb.doxygen.in \
xkb_internals \
xkb_issues
docdirs = $(srcdir)/tutorial
if BUILD_DOCS
if ENABLE_DEVEL_DOCS
if HAVE_DOXYGEN
if HAVE_DOT
docdirs += manual
@ -19,6 +23,8 @@ clean-local:
rm -rf manual/
endif
endif
endif
all-local: $(docdirs)

View File

@ -150,7 +150,7 @@
<li><a class="subsection" href="#DoesBackingStore">DoesBackingStore</a>
<li><a class="subsection" href="#EventMaskOfScreen">EventMaskOfScreen</a>
</ol>
<li><a class="subsection" href="#misc">Miscellaneaous macros</a>
<li><a class="subsection" href="#misc">Miscellaneous macros</a>
<ol>
<li><a class="subsection" href="#DisplayOfScreen">DisplayOfScreen</a>
<li><a class="subsection" href="#DisplayCells">DisplayCells / CellsOfScreen</a>
@ -173,7 +173,7 @@
with the <a href="http://xcb.freedesktop.org">XCB</a>
library. keep in mind that XCB, like the
<a href="http://tronche.com/gui/x/xlib/introduction">Xlib</a>
library, isn't what post programmers wanting to write X
library, isn't what most programmers wanting to write X
applications are looking for. They should use a much higher
level GUI toolkit like Motif,
<a href="http://www.lesstif.org">LessTiff</a>,
@ -471,8 +471,6 @@ main ()
diff = end - start;
/* free var */
for (i = 0; i &lt; count; ++i)
free (names[i]);
free (atoms);
free (cs);
@ -494,6 +492,8 @@ main ()
printf ("ratio : %f\n", diff_x / diff);
free (atoms_x);
for (i = 0; i &lt; count; ++i)
free (names[i]);
free (names);
XCloseDisplay (disp);
@ -1331,7 +1331,7 @@ main ()
/* We draw the polygonal line */
xcb_poly_line (c, XCB_COORD_MODE_PREVIOUS, win, foreground, 4, polyline);
/* We draw the segements */
/* We draw the segments */
xcb_poly_segment (c, win, foreground, 2, segments);
/* We draw the rectangles */
@ -1453,7 +1453,7 @@ typedef enum {
</pre>
<p>
If the window has already been created, we can use the
<span class="code">xcb_configure_window()</span> function to set
<span class="code">xcb_change_window_attributes()</span> function to set
the events that the window will receive. The subsection
<a href="#winconf">Configuring a window</a> shows its
prototype. As an example, here is a piece of code that
@ -1466,14 +1466,14 @@ const static uint32_t values[] = { XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTT
/* The connection c and the window win are supposed to be defined */
xcb_configure_window (c, win, XCB_CW_EVENT_MASK, values);
xcb_change_window_attributes (c, win, XCB_CW_EVENT_MASK, values);
</pre>
<div class="emph">
<p>
Note: A common bug programmers do is adding code to handle new
Note: A common bug programmers have is adding code to handle new
event types in their program, while forgetting to add the
masks for these events in the creation of the window. Such a
programmer then should sit down for hours debugging his
programmer would then sit there for hours debugging their
program, wondering "Why doesn't my program notice that I
released the button?", only to find that they registered for
button press events but not for button release events.
@ -1830,7 +1830,7 @@ typedef xcb_enter_notify_event_t xcb_leave_notify_event_t;
keyboard focus using the window manager (often by clicking
on the title bar of the desired window). Once our window
has the keyboard focus, every key press or key release will
cause an event to be sent to our program (if it regsitered
cause an event to be sent to our program (if it registered
for these event types...).
</p>
<li class="subsubtitle"><a name="keypress">Keyboard press and release events</a>
@ -2090,7 +2090,7 @@ xcb_void_cookie_t xcb_open_font (xcb_connection_t *c,
Once a font is opened, you have to create a Graphic Context
that will contain the informations about the color of the
foreground and the background used when you draw a text in a
Drawable. Here is an exemple of a Graphic Context that will
Drawable. Here is an example of a Graphic Context that will
allow us to draw an opened font with a black foreground and a
white background:
</p>
@ -2297,9 +2297,7 @@ int main ()
values[0] = screen->white_pixel;
values[1] =
XCB_EVENT_MASK_KEY_RELEASE |
XCB_EVENT_MASK_BUTTON_PRESS |
XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_POINTER_MOTION;
XCB_EVENT_MASK_EXPOSURE;
cookie_window = xcb_create_window_checked (c,
screen->root_depth,
window, screen->root,
@ -2404,7 +2402,7 @@ xcb_void_cookie_t xcb_change_property (xcb_connection_t *c, /* Connection
const void *data); /* Data */
</pre>
<p>
The <span class="code">mode</span> parameter coud be one of
The <span class="code">mode</span> parameter could be one of
the following values (defined in enumeration xcb_prop_mode_t in
the xproto.h header file):
</p>
@ -2939,7 +2937,7 @@ xcb_get_window_attributes_reply_t *xcb_get_window_attributes_reply (xcb_connecti
latter case, each time the mouse moves onto your window, the
screen color map will be replaced by your window's color map,
and you'll see all the other windows on screen change their
colors into something quite bizzare. In fact, this is the
colors into something quite bizarre. In fact, this is the
effect you get with X applications that use the "-install"
command line option.
</p>
@ -3302,10 +3300,10 @@ xcb_void_cookie_t xcb_free_pixmap (xcb_connection_t *c, /* Pointer to the
<li class="title"><a name="mousecursor">Messing with the mouse cursor</a>
<p>
It it possible to modify the shape of the mouse pointer (also
called the X pointer) when in certain states, as we otfen see in
called the X pointer) when in certain states, as we often see in
programs. For example, a busy application would often display
the sand clock over its main window, to give the user a visual
hint that he should wait. Let's see how we can change the mouse
the hourglass cursor over its main window, to give the user a visual
hint that they should wait. Let's see how we can change the mouse
cursor of our windows.
</p>
<ol>
@ -3341,7 +3339,7 @@ xcb_void_cookie_t xcb_create_glyph_cursor (xcb_connection_t *c,
</p>
<p>
So we first open that font (see <a href="#loadfont">Loading a Font</a>)
and create the new cursor. As for every X ressource, we have to
and create the new cursor. As for every X resource, we have to
ask for an X id with <span class="code">xcb_generate_id</span>
first:
</p>

49
doc/xkb_internals Normal file
View File

@ -0,0 +1,49 @@
XKB introduces several uncommon data structures:
- switch allows conditional inclusion of fields
- several complex objects intermix variable and fixed size fields
- lists with a variable number of variable size objects
To handle these objects, a number of new functions is generated:
- _serialize() turns a structured object into a byte stream,
(re)ordering or including fields according to the protocol
- _unserialize() rewrites data from a buffer into a structured object
- _unpack() expands a buffer representing a switch object into
a special structured type, all flags needed to resolve the switch
expression have to given as parameters
- _sizeof() calculates the size of a serialized object, often by calling
_unserialize()/_unpack() internally
The new structured data type for switch is special as it contains fixed
and variable size fields. Variable size fields can be accessed via pointers.
If switch appears in a request, an additional set of request helpers is
generated with the suffix _aux or _aux_(un)checked. While the 'common'
request functions require that switch has been serialized before, the _aux
variants take the structured data type. They are especially designed to
replace certain functions in xcb-util/aux.
Accessors for switch members need two parameters, where the first is usually
a pointer to the respective request or reply structure, while the second
is a pointer to the unpacked switch data structure.
Functions from the serialize family that take a double pointer can allocate
memory on their own, which is useful if the size of a buffer has to be
calculated depending on the data within. These functions call malloc() when
the double pointer is given as the address of a pointer that has been
initialized to 0. It is the responsibility of the user to free any allocated
memory.
Intermixed variable and fixed size fields are an important special case in XKB.
The current implementation resolves the issue by reordering the fields before
sending them on the wire as well as before returning a reply. That means that
these objects look like 'common' XCB data types and they can be accessed as such
(i.e. fixed size fields directly via the structured type and variable size fields
via accessors/iterators).
In case a list with variable size elements needs to be accessed, it is necessary
to use iterators. The iterator functions take care of determining the actual
object size for each element automatically.
A small and preliminary set of auxiliary functions is available in xkb_util.c
in the check_xkb module.

38
doc/xkb_issues Normal file
View File

@ -0,0 +1,38 @@
There are a number of problematic special cases in XKB. The issues
mentioned here are at most partly resolved.
1. The are several XxxDoodad structures defined in xkb.xml. They are used
in a few lists, but in a rather special way:
The struct "CommonDoodad" is supposed to be a rather generic data type,
combining the most basic Doodad fields that are common in all these structures.
All Doodads are encapsulated in a union type simply called "Doodad".
Now this union is used in subsequent list definitions, aiming at a kind of
'polymorphism': From inspection of the protocol and Xlib, the Doodads are to
be discriminated based on their type field.
However the special meaning of the type field is not encoded in the protocol.
Furthermore the TextDoodad and the LogoDoodad are variable size types due to
some fields of type CountedString16, thereby turning the union into a
possibly variable size type as well.
However, for lists with variable size elements, special sizeof functions are
required. These cannot be autogenerated as it cannot be referred which
Doodad type to use for the union.
Therefore, the Doodad type structures are unsupported at the moment.
2. There are still some bugs in xkb.xml: Either certain fields are missing
that are required by the protocol, or Xlib simply has another understanding
of the protocol.
3. The interface for accessors should be reviewed.
4. Currently some bitcases carry 'name' attributes. These could be avoided if
the data within would consist of a singe struct field only.
5. switch could get a 'fixed_size' attribute, so when rewriting valueparam to switch,
an uint32_t * pointer could be used instead of void *.
6. The automatic inclusion of padding requires some complicated coding in the
generator. This is errorprone and could be avoided if all padding is explicitly
given in the protocol definition. For variable size fields that require padding,
the pad tag could get a 'fieldref' attribute. That way padding could be handled
a lot easier in the autogenerator.

4
libxcb.wrap Normal file
View File

@ -0,0 +1,4 @@
[wrap-git]
url = https://gitea.gigo-games.dk/frederik/libxcb.git
revision = HEAD
depth = 1

70
m4/xcb.m4 Normal file
View File

@ -0,0 +1,70 @@
dnl Detection and configuration of the visibility feature of gcc
dnl Vincent Torri 2006-02-11
dnl
dnl XCB_CHECK_VISIBILITY([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Check the visibility feature of gcc
dnl
AC_DEFUN([XCB_CHECK_VISIBILITY],
[
AC_MSG_CHECKING([whether ${CC} supports symbol visibility])
save_CFLAGS=${CFLAGS}
CFLAGS="$CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#pragma GCC visibility push(hidden)
extern void f(int);
#pragma GCC visibility pop
]],
[[]]
)],
[AC_DEFINE(
GCC_HAS_VISIBILITY,
[],
[Defined if GCC supports the visibility feature])
m4_if([$1], [], [:], [$1])
AC_MSG_RESULT(yes)],
[m4_if([$2], [], [:], [$2])
AC_MSG_RESULT(no)])
CFLAGS=${save_CFLAGS}
])
dnl Detection and configuration of the visibility feature of gcc
dnl Vincent Torri 2006-02-11
dnl
dnl XCB_EXTENSION(name, default)
dnl set the X extension
dnl
AC_DEFUN([XCB_EXTENSION],
[dnl
pushdef([UP], translit([$1], [-a-z], [_A-Z]))dnl
pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
dnl
m4_if([$2], [yes], [m4_define([xcb_defopt], [yes])],
[$2], [no], [m4_define([xcb_defopt], [no])],
m4_define([xcb_defopt], [auto]))dnl
AC_ARG_ENABLE(DOWN,
[AS_HELP_STRING([--enable-[]DOWN],
[Build XCB $1 Extension (default: ]xcb_defopt[)])],
[BUILD_[]UP=$enableval],
[BUILD_[]UP=xcb_defopt])
dnl
m4_if(xcb_defopt, [auto], [
# This extension has a default value of "auto" and depends on the value of $2
if test "x$BUILD_[]UP" = "xauto" ; then
BUILD_[]UP=$2
fi
if test "x$BUILD_[]UP" = "xyes" ; then
if test "x$2" = "xno" ; then
AC_MSG_ERROR([Extension []UP requested, but dependencies are not met])
fi
fi])
m4_undefine([xcb_defopt])dnl
AM_CONDITIONAL(BUILD_[]UP, [test "x$BUILD_[]UP" = "xyes"])
])
dnl End of acinclude.m4

1
man/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.[0-9]

18
man/Makefile.am Normal file
View File

@ -0,0 +1,18 @@
libmandir = $(LIB_MAN_DIR)
libman_PRE = \
xcb-examples.man \
xcb-requests.man
libman_DATA = $(libman_PRE:man=$(LIB_MAN_SUFFIX))
EXTRA_DIST = $(libman_PRE)
CLEANFILES = $(libman_DATA)
# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
SUFFIXES = .$(LIB_MAN_SUFFIX) .man
.man.$(LIB_MAN_SUFFIX):
$(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@

59
man/xcb-examples.man Normal file
View File

@ -0,0 +1,59 @@
.TH xcb-examples __libmansuffix__ __xorgversion__ "XCB examples"
.ad l
.SH NAME
xcb-examples \- manpage examples
.SH DESCRIPTION
Many of the XCB manpages contain example code. These examples intend to explain
how to use one particular part of XCB. They almost never represent a standalone
(or even useful) program - X11 programs are relatively involved and
thus beyond the scope of a manpage example.
.SH ENVIRONMENT
Every example assumes you have an \fIxcb_connection\fP and possibly other
variables at hand. For illustrating how \fIxcb_get_property\fP works, you need
the window of which you want to get the property, for example. To make it clear
that these variables are your responsibility, these examples consist of a
single function which takes the necessary variables as parameters.
.SH FLUSHING
Flushing means calling \fIxcb_flush\fP to clear the XCB-internal write buffer
and send all pending requests to the X11 server. You don't explicitly need to
flush before using a reply function (like \fIxcb_query_pointer_reply\fP), but
you do need to flush before entering the event loop of your program.
There are only two cases when XCB flushes by itself. The first case is when
its write buffer becomes full, the second case is when you are asking for
the reply of a request which wasn't flushed out yet (like
\fIxcb_query_pointer_reply\fP). This last point also includes
xcb_request_check(). Please note that waiting for an event does \fBNOT\fP
flush.
Examples generally include the \fIxcb_flush\fP call where appropriate (for
example after setting a property). Therefore, including these functions and
calling them in your application should just work. However, you might get
better results when flushing outside of the function, depending on the
architecture of your program.
.SH COMPILATION
If an example does not compile (without warnings) when using \fI-std=c99\fP,
that is considered a documentation bug. Similarly, not handling errors or
leaking memory is also considered a documentation bug. Please inform us about
it on xcb@lists.freedesktop.org.
.SH CODING STYLE
Every example uses 4 spaces for indentation.
Comments are in asterisks, like /* this */.
No line is longer than 80 characters (including indentation).
.SH SEE ALSO
.BR xcb_connect (__libmansuffix__),
.BR xcb_get_property (__libmansuffix__),
.BR xcb_flush (__libmansuffix__)
.SH AUTHOR
Michael Stapelberg <michael+xcb at stapelberg dot de>

165
man/xcb-requests.man Normal file
View File

@ -0,0 +1,165 @@
.TH xcb-requests __libmansuffix__ __xorgversion__ "XCB examples"
.ad l
.SH NAME
xcb-requests \- about request manpages
.SH DESCRIPTION
Every request in X11, like \fIMapWindow\fP, corresponds to a number of
functions and data structures in XCB. For \fIMapWindow\fP, XCB provides the
function \fIxcb_map_window\fP, which fills the \fIxcb_map_window_request_t\fP
data structure and writes that to the X11 connection. Since the \fIMapWindow\fP
request does not have a reply, this is the most simple case.
.SH REPLIES
Many requests have replies. For each reply, XCB provides at least a
corresponding data structure and a function to return a pointer to a filled
data structure. Let's take the \fIInternAtom\fP request as an example: XCB
provides the \fIxcb_intern_atom_reply_t\fP data structure and
\fIxcb_intern_atom_reply\fP function. For replies which are more complex (for
example lists, such as in \fIxcb_list_fonts\fP), accessor functions are
provided.
.SH COOKIES
XCB returns a cookie for each request you send. This is an XCB-specific data
structure containing the sequence number with which the request was sent to the
X11 server. To get any reply, you have to provide that cookie (so that XCB
knows which of the waiting replies you want). Here is an example to illustrate
the use of cookies:
.nf
.sp
void my_example(xcb_connection *conn) {
xcb_intern_atom_cookie_t cookie;
xcb_intern_atom_reply_t *reply;
cookie = xcb_intern_atom(conn, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME");
/* ... do other work here if possible ... */
if ((reply = xcb_intern_atom_reply(conn, cookie, NULL))) {
printf("The _NET_WM_NAME atom has ID %u\\n", reply->atom);
}
free(reply);
}
.fi
.SH CHECKED VS. UNCHECKED
The checked and unchecked suffixes for functions determine which kind of error
handling is used for this specific request.
For requests which have no reply (for example \fIxcb_map_window\fP), errors
will be delivered to the event loop (you will receive an X11 event of type 0
when calling \fIxcb_poll_for_event\fP).
If you want to explicitly check for errors in a blocking fashion, call the
_checked version of the function (for example \fIxcb_map_window_checked\fP) and
use \fIxcb_request_check\fP.
For requests which have a reply (for example \fIxcb_intern_atom\fP), errors
will be checked when calling the reply function. To get errors in the event
loop instead, use the _unchecked version of the function (for example
\fIxcb_intern_atom_unchecked\fP).
Here is an example which illustrates the four different ways of handling errors:
.nf
.sp
/*
* Request without a reply, handling errors in the event loop (default)
*
*/
void my_example(xcb_connection *conn, xcb_window_t window) {
/* This is a request without a reply. Errors will be delivered to the event
* loop. Getting an error to xcb_map_window most likely is a bug in our
* program, so we don't need to check for that in a blocking way. */
xcb_map_window(conn, window);
/* ... of course your event loop would not be in the same function ... */
while ((event = xcb_wait_for_event(conn)) != NULL) {
if (event->response_type == 0) {
fprintf("Received X11 error %d\\n", error->error_code);
free(event);
continue;
}
/* ... handle a normal event ... */
}
}
/*
* Request without a reply, handling errors directly
*
*/
void my_example(xcb_connection *conn, xcb_window_t deco, xcb_window_t window) {
/* A reparenting window manager wants to know whether a new window was
* successfully reparented. If not (because the window got destroyed
* already, for example), it does not make sense to map an empty window
* decoration at all, so we need to know this right now. */
xcb_void_cookie_t cookie = xcb_reparent_window_checked(conn, window,
deco, 0, 0);
xcb_generic_error_t *error;
if ((error = xcb_request_check(conn, cookie))) {
fprintf(stderr, "Could not reparent the window\\n");
free(error);
return;
}
/* ... do window manager stuff here ... */
}
/*
* Request with a reply, handling errors directly (default)
*
*/
void my_example(xcb_connection *conn, xcb_window_t window) {
xcb_intern_atom_cookie_t cookie;
xcb_intern_atom_reply_t *reply;
xcb_generic_error_t *error;
cookie = xcb_intern_atom(c, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME");
/* ... do other work here if possible ... */
if ((reply = xcb_intern_atom_reply(c, cookie, &error))) {
printf("The _NET_WM_NAME atom has ID %u\\n", reply->atom);
free(reply);
} else {
fprintf(stderr, "X11 Error %d\\n", error->error_code);
free(error);
}
}
/*
* Request with a reply, handling errors in the event loop
*
*/
void my_example(xcb_connection *conn, xcb_window_t window) {
xcb_intern_atom_cookie_t cookie;
xcb_intern_atom_reply_t *reply;
cookie = xcb_intern_atom_unchecked(c, 0, strlen("_NET_WM_NAME"),
"_NET_WM_NAME");
/* ... do other work here if possible ... */
if ((reply = xcb_intern_atom_reply(c, cookie, NULL))) {
printf("The _NET_WM_NAME atom has ID %u\\n", reply->atom);
free(reply);
}
/* ... of course your event loop would not be in the same function ... */
while ((event = xcb_wait_for_event(conn)) != NULL) {
if (event->response_type == 0) {
fprintf("Received X11 error %d\\n", error->error_code);
free(event);
continue;
}
/* ... handle a normal event ... */
}
}
.fi
.SH SEE ALSO
.BR xcb_map_window (__libmansuffix__),
.BR xcb_intern_atom (__libmansuffix__),
.BR xcb_list_fonts (__libmansuffix__),
.BR xcb_poll_for_event (__libmansuffix__),
.BR xcb_request_check (__libmansuffix__)
.SH AUTHOR
Michael Stapelberg <michael+xcb at stapelberg dot de>

8
src/.gitignore vendored
View File

@ -1,8 +1,13 @@
bigreq.*
composite.*
damage.*
dbe.*
dpms.*
dri2.*
dri3.*
ge.*
glx.*
present.*
randr.*
record.*
render.*
@ -16,7 +21,10 @@ xevie.*
xf86dri.*
xfixes.*
xinerama.*
xinput.*
xkb.*
xprint.*
xselinux.*
xtest.*
xv.*
xvmc.*

View File

@ -1,105 +1,15 @@
lib_LTLIBRARIES = libxcb.la \
libxcb-xlib.la \
libxcb-composite.la \
libxcb-damage.la \
libxcb-dpms.la \
libxcb-glx.la \
libxcb-randr.la \
libxcb-record.la \
libxcb-render.la \
libxcb-res.la \
libxcb-screensaver.la \
libxcb-shape.la \
libxcb-shm.la \
libxcb-sync.la \
libxcb-xevie.la \
libxcb-xf86dri.la \
libxcb-xfixes.la \
libxcb-xinerama.la \
libxcb-xprint.la \
libxcb-xtest.la \
libxcb-xv.la \
libxcb-xvmc.la
lib_LTLIBRARIES = libxcb.la
EXTHEADERS = xproto.h \
bigreq.h \
composite.h \
damage.h \
dpms.h \
glx.h \
randr.h \
record.h \
render.h \
res.h \
screensaver.h \
shape.h \
shm.h \
sync.h \
xc_misc.h \
xevie.h \
xf86dri.h \
xfixes.h \
xinerama.h \
xprint.h \
xtest.h \
xv.h \
xvmc.h
EXTSOURCES = xproto.c \
bigreq.c \
composite.c \
damage.c \
dpms.c \
glx.c \
randr.c \
record.c \
render.c \
res.c \
screensaver.c \
shape.c \
shm.c \
sync.c \
xc_misc.c \
xevie.c \
xf86dri.c \
xfixes.c \
xinerama.c \
xprint.c \
xtest.c \
xv.c \
xvmc.c
EXTENSION_XML = xproto.xml \
bigreq.xml \
composite.xml \
damage.xml \
dpms.xml \
glx.xml \
randr.xml \
record.xml \
render.xml \
res.xml \
screensaver.xml \
shape.xml \
shm.xml \
sync.xml \
xc_misc.xml \
xevie.xml \
xf86dri.xml \
xfixes.xml \
xinerama.xml \
xprint.xml \
xtest.xml \
xvmc.xml \
xv.xml
xc_misc.c
xcbinclude_HEADERS = xcb.h xcbext.h xcbxlib.h $(EXTHEADERS)
noinst_HEADERS = xcbint.h
AM_CFLAGS = $(CWARNFLAGS) $(NEEDED_CFLAGS) $(XDMCP_CFLAGS)
AM_CFLAGS = $(BASE_CFLAGS) $(NEEDED_CFLAGS) $(XDMCP_CFLAGS)
libxcb_la_LIBADD = $(NEEDED_LIBS) $(XDMCP_LIBS)
libxcb_la_SOURCES = \
xcb_conn.c xcb_out.c xcb_in.c xcb_ext.c xcb_xid.c \
xcb_list.c xcb_util.c xcb_auth.c c-client.xsl \
xproto.c bigreq.c xc_misc.c
xcb_list.c xcb_util.c xcb_auth.c c_client.py
nodist_libxcb_la_SOURCES = xproto.c bigreq.c xc_misc.c
# Explanation for -version-info:
# -version-info current:revision:age
@ -108,116 +18,260 @@ libxcb_la_SOURCES = \
# * If you add an interface, increment current and age and set revision to 0.
# * If you change or remove an interface, increment current and set revision
# and age to 0.
libxcb_la_LDFLAGS = -version-info 1:0:0
BUILT_SOURCES = $(EXTSOURCES) $(EXTHEADERS)
CLEANFILES = $(EXTSOURCES) $(EXTHEADERS) $(EXTENSION_XML)
libxcb_la_LDFLAGS = -version-info 2:0:1 -no-undefined @lt_enable_auto_import@
XCB_LIBS = libxcb.la
libxcb_xlib_la_LDFLAGS = -version-info 0:0:0
libxcb_xlib_la_LIBADD = $(XCB_LIBS)
libxcb_xlib_la_SOURCES = xcb_xlib.c
# FIXME: find a way to autogenerate this from the XML files.
libxcb_composite_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += composite.c
if BUILD_COMPOSITE
lib_LTLIBRARIES += libxcb-composite.la
libxcb_composite_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_composite_la_LIBADD = $(XCB_LIBS)
libxcb_composite_la_SOURCES = composite.c composite.h
nodist_libxcb_composite_la_SOURCES = composite.c composite.h
endif
libxcb_damage_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += damage.c
if BUILD_DAMAGE
lib_LTLIBRARIES += libxcb-damage.la
libxcb_damage_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_damage_la_LIBADD = $(XCB_LIBS)
libxcb_damage_la_SOURCES = damage.c damage.h
nodist_libxcb_damage_la_SOURCES = damage.c damage.h
endif
libxcb_dpms_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += dbe.c
if BUILD_DBE
lib_LTLIBRARIES += libxcb-dbe.la
libxcb_dbe_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_dbe_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_dbe_la_SOURCES = dbe.c dbe.h
endif
EXTSOURCES += dpms.c
if BUILD_DPMS
lib_LTLIBRARIES += libxcb-dpms.la
libxcb_dpms_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_dpms_la_LIBADD = $(XCB_LIBS)
libxcb_dpms_la_SOURCES = dpms.c dpms.h
nodist_libxcb_dpms_la_SOURCES = dpms.c dpms.h
endif
libxcb_glx_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += dri2.c
if BUILD_DRI2
lib_LTLIBRARIES += libxcb-dri2.la
libxcb_dri2_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_dri2_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_dri2_la_SOURCES = dri2.c dri2.h
endif
EXTSOURCES += dri3.c
if BUILD_DRI3
lib_LTLIBRARIES += libxcb-dri3.la
libxcb_dri3_la_LDFLAGS = -version-info 1:0:1 -no-undefined @lt_enable_auto_import@
libxcb_dri3_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_dri3_la_SOURCES = dri3.c dri3.h
endif
EXTSOURCES += present.c
if BUILD_PRESENT
lib_LTLIBRARIES += libxcb-present.la
libxcb_present_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_present_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_present_la_SOURCES = present.c present.h
endif
EXTSOURCES += glx.c
if BUILD_GLX
lib_LTLIBRARIES += libxcb-glx.la
libxcb_glx_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_glx_la_LIBADD = $(XCB_LIBS)
libxcb_glx_la_SOURCES = glx.c glx.h
nodist_libxcb_glx_la_SOURCES = glx.c glx.h
endif
libxcb_randr_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += randr.c
if BUILD_RANDR
lib_LTLIBRARIES += libxcb-randr.la
libxcb_randr_la_LDFLAGS = -version-info 1:0:1 -no-undefined @lt_enable_auto_import@
libxcb_randr_la_LIBADD = $(XCB_LIBS)
libxcb_randr_la_SOURCES = randr.c randr.h
nodist_libxcb_randr_la_SOURCES = randr.c randr.h
endif
libxcb_record_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += record.c
if BUILD_RECORD
lib_LTLIBRARIES += libxcb-record.la
libxcb_record_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_record_la_LIBADD = $(XCB_LIBS)
libxcb_record_la_SOURCES = record.c record.h
nodist_libxcb_record_la_SOURCES = record.c record.h
endif
libxcb_render_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += render.c
if BUILD_RENDER
lib_LTLIBRARIES += libxcb-render.la
libxcb_render_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_render_la_LIBADD = $(XCB_LIBS)
libxcb_render_la_SOURCES = render.c render.h
nodist_libxcb_render_la_SOURCES = render.c render.h
endif
libxcb_res_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += res.c
if BUILD_RESOURCE
lib_LTLIBRARIES += libxcb-res.la
libxcb_res_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_res_la_LIBADD = $(XCB_LIBS)
libxcb_res_la_SOURCES = res.c res.h
nodist_libxcb_res_la_SOURCES = res.c res.h
endif
libxcb_screensaver_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += screensaver.c
if BUILD_SCREENSAVER
lib_LTLIBRARIES += libxcb-screensaver.la
libxcb_screensaver_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_screensaver_la_LIBADD = $(XCB_LIBS)
libxcb_screensaver_la_SOURCES = screensaver.c screensaver.h
nodist_libxcb_screensaver_la_SOURCES = screensaver.c screensaver.h
endif
libxcb_shape_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += shape.c
if BUILD_SHAPE
lib_LTLIBRARIES += libxcb-shape.la
libxcb_shape_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_shape_la_LIBADD = $(XCB_LIBS)
libxcb_shape_la_SOURCES = shape.c shape.h
nodist_libxcb_shape_la_SOURCES = shape.c shape.h
endif
libxcb_shm_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += shm.c
if BUILD_SHM
lib_LTLIBRARIES += libxcb-shm.la
libxcb_shm_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_shm_la_LIBADD = $(XCB_LIBS)
libxcb_shm_la_SOURCES = shm.c shm.h
nodist_libxcb_shm_la_SOURCES = shm.c shm.h
endif
libxcb_sync_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += sync.c
if BUILD_SYNC
lib_LTLIBRARIES += libxcb-sync.la
libxcb_sync_la_LDFLAGS = -version-info 1:0:0 -no-undefined @lt_enable_auto_import@
libxcb_sync_la_LIBADD = $(XCB_LIBS)
libxcb_sync_la_SOURCES = sync.c sync.h
nodist_libxcb_sync_la_SOURCES = sync.c sync.h
endif
libxcb_xevie_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += xevie.c
if BUILD_XEVIE
lib_LTLIBRARIES += libxcb-xevie.la
libxcb_xevie_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_xevie_la_LIBADD = $(XCB_LIBS)
libxcb_xevie_la_SOURCES = xevie.c xevie.h
nodist_libxcb_xevie_la_SOURCES = xevie.c xevie.h
endif
libxcb_xf86dri_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += xf86dri.c
if BUILD_XFREE86_DRI
lib_LTLIBRARIES += libxcb-xf86dri.la
libxcb_xf86dri_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_xf86dri_la_LIBADD = $(XCB_LIBS)
libxcb_xf86dri_la_SOURCES = xf86dri.c xf86dri.h
nodist_libxcb_xf86dri_la_SOURCES = xf86dri.c xf86dri.h
endif
libxcb_xfixes_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += xfixes.c
if BUILD_XFIXES
lib_LTLIBRARIES += libxcb-xfixes.la
libxcb_xfixes_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_xfixes_la_LIBADD = $(XCB_LIBS)
libxcb_xfixes_la_SOURCES = xfixes.c xfixes.h
nodist_libxcb_xfixes_la_SOURCES = xfixes.c xfixes.h
endif
libxcb_xprint_la_LDFLAGS = -version-info 0:0:0
libxcb_xprint_la_LIBADD = $(XCB_LIBS)
libxcb_xprint_la_SOURCES = xprint.c xprint.h
libxcb_xtest_la_LDFLAGS = -version-info 0:0:0
libxcb_xtest_la_LIBADD = $(XCB_LIBS)
libxcb_xtest_la_SOURCES = xtest.c xtest.h
libxcb_xv_la_LDFLAGS = -version-info 0:0:0
libxcb_xv_la_LIBADD = $(XCB_LIBS)
libxcb_xv_la_SOURCES = xv.c xv.h
libxcb_xvmc_la_LDFLAGS = -version-info 0:0:0
libxcb_xvmc_la_LIBADD = $(XCB_LIBS)
libxcb_xvmc_la_SOURCES = xvmc.c xvmc.h
libxcb_xinerama_la_LDFLAGS = -version-info 0:0:0
EXTSOURCES += xinerama.c
if BUILD_XINERAMA
lib_LTLIBRARIES += libxcb-xinerama.la
libxcb_xinerama_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_xinerama_la_LIBADD = $(XCB_LIBS)
libxcb_xinerama_la_SOURCES = xinerama.c xinerama.h
nodist_libxcb_xinerama_la_SOURCES = xinerama.c xinerama.h
endif
$(EXTHEADERS) $(EXTSOURCES): c-client.xsl
EXTSOURCES += xinput.c
if BUILD_XINPUT
lib_LTLIBRARIES += libxcb-xinput.la
libxcb_xinput_la_LDFLAGS = -version-info 1:0:1 -no-undefined @lt_enable_auto_import@
libxcb_xinput_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_xinput_la_SOURCES = xinput.c xinput.h
endif
SUFFIXES = .xml
EXTSOURCES += xkb.c
if BUILD_XKB
lib_LTLIBRARIES += libxcb-xkb.la
libxcb_xkb_la_LDFLAGS = -version-info 1:0:0 -no-undefined
libxcb_xkb_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_xkb_la_SOURCES = xkb.c xkb.h
endif
.xml.h:
@n=`dirname $*`; test -d $$n || (echo mkdir $$n; mkdir $$n)
$(XSLTPROC) --stringparam mode header \
--stringparam base-path $(XCBPROTO_XCBINCLUDEDIR)/ \
--stringparam extension-path $(XCBPROTO_XCBINCLUDEDIR)/ \
-o $@ $(srcdir)/c-client.xsl $<
EXTSOURCES += xprint.c
if BUILD_XPRINT
lib_LTLIBRARIES += libxcb-xprint.la
libxcb_xprint_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_xprint_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_xprint_la_SOURCES = xprint.c xprint.h
endif
.xml.c:
@n=`dirname $*`; test -d $$n || (echo mkdir $$n; mkdir $$n)
$(XSLTPROC) --stringparam mode source \
--stringparam base-path $(XCBPROTO_XCBINCLUDEDIR)/ \
--stringparam extension-path $(XCBPROTO_XCBINCLUDEDIR)/ \
-o $@ $(srcdir)/c-client.xsl $<
EXTSOURCES += xselinux.c
if BUILD_SELINUX
lib_LTLIBRARIES += libxcb-xselinux.la
libxcb_xselinux_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_xselinux_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_xselinux_la_SOURCES = xselinux.c xselinux.h
endif
$(EXTENSION_XML):
$(LN_S) -f $(XCBPROTO_XCBINCLUDEDIR)/$@ $@
EXTSOURCES += xtest.c
if BUILD_XTEST
lib_LTLIBRARIES += libxcb-xtest.la
libxcb_xtest_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_xtest_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_xtest_la_SOURCES = xtest.c xtest.h
endif
EXTSOURCES += xv.c
if BUILD_XV
lib_LTLIBRARIES += libxcb-xv.la
libxcb_xv_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_xv_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_xv_la_SOURCES = xv.c xv.h
endif
EXTSOURCES += xvmc.c
if BUILD_XVMC
lib_LTLIBRARIES += libxcb-xvmc.la
libxcb_xvmc_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_xvmc_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_xvmc_la_SOURCES = xvmc.c xvmc.h
endif
EXTSOURCES += ge.c
if BUILD_GE
lib_LTLIBRARIES += libxcb-ge.la
libxcb_ge_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
libxcb_ge_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_ge_la_SOURCES = ge.c ge.h
endif
EXTHEADERS=$(EXTSOURCES:.c=.h)
xcbinclude_HEADERS = xcb.h xcbext.h
if XCB_HAVE_WIN32
xcbinclude_HEADERS += xcb_windefs.h
endif
nodist_xcbinclude_HEADERS = $(EXTHEADERS)
noinst_HEADERS = xcbint.h
BUILT_MAN_PAGES = man/xcb_*
libmandir = $(LIB_MAN_DIR)
libman_DATA = $(BUILT_MAN_PAGES)
BUILT_SOURCES = $(EXTSOURCES) $(BUILT_MAN_PAGES)
CLEANFILES = $(EXTSOURCES) $(EXTHEADERS) $(BUILT_MAN_PAGES)
C_CLIENT_PY_EXTRA_ARGS =
if XCB_SERVERSIDE_SUPPORT
C_CLIENT_PY_EXTRA_ARGS += --server-side
endif
$(EXTSOURCES): c_client.py $(XCBPROTO_XCBINCLUDEDIR)/$(@:.c=.xml)
$(AM_V_GEN)$(PYTHON) $(srcdir)/c_client.py -c "$(PACKAGE_STRING)" -l "$(XORG_MAN_PAGE)" \
-s "$(LIB_MAN_SUFFIX)" -p $(XCBPROTO_XCBPYTHONDIR) \
$(C_CLIENT_PY_EXTRA_ARGS) \
$(XCBPROTO_XCBINCLUDEDIR)/$(@:.c=.xml)
$(BUILT_MAN_PAGES): $(EXTSOURCES)

File diff suppressed because it is too large Load Diff

3395
src/c_client.py Normal file

File diff suppressed because it is too large Load Diff

2
src/man/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.[0-9]
*.[0-9]x

309
src/xcb.h
View File

@ -29,13 +29,13 @@
#define __XCB_H__
#include <sys/types.h>
#if defined(__solaris__)
#include <inttypes.h>
#else
#include <stdint.h>
#endif
#ifndef _WIN32
#include <sys/uio.h>
#else
#include "xcb_windefs.h"
#endif
#include <pthread.h>
@ -47,6 +47,36 @@ extern "C" {
* @file xcb.h
*/
#ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with older compilers. */
#endif
/*
* For the below checks, we currently assume that __GNUC__ indicates
* gcc 3.0 (released 2001) or later, as we require support for C99.
*/
/* Supported in gcc 2.5 and later */
#if defined(__GNUC__) || __has_attribute(__const__)
#define XCB_CONST_FUNCTION __attribute__((__const__))
#else
#define XCB_CONST_FUNCTION XCB_PURE_FUNCTION
#endif
/* Supported in gcc 2.7 and later */
#if defined(__GNUC__) || __has_attribute(__packed__)
#define XCB_PACKED __attribute__((__packed__))
#else
#define XCB_PACKED
#endif
/* Supported in gcc 2.96 and later */
#if defined(__GNUC__) || __has_attribute(__pure__)
#define XCB_PURE_FUNCTION __attribute__((__pure__))
#else
#define XCB_PURE_FUNCTION
#endif
/**
* @defgroup XCB_Core_API XCB Core API
* @brief Core API of the XCB library.
@ -65,6 +95,27 @@ extern "C" {
/** X_TCP_PORT + display number = server port for TCP transport */
#define X_TCP_PORT 6000
/** xcb connection errors because of socket, pipe and other stream errors. */
#define XCB_CONN_ERROR 1
/** xcb connection shutdown because of extension not supported */
#define XCB_CONN_CLOSED_EXT_NOTSUPPORTED 2
/** malloc(), calloc() and realloc() error upon failure, for eg ENOMEM */
#define XCB_CONN_CLOSED_MEM_INSUFFICIENT 3
/** Connection closed, exceeding request length that server accepts. */
#define XCB_CONN_CLOSED_REQ_LEN_EXCEED 4
/** Connection closed, error during parsing display string. */
#define XCB_CONN_CLOSED_PARSE_ERR 5
/** Connection closed because the server does not have a screen matching the display. */
#define XCB_CONN_CLOSED_INVALID_SCREEN 6
/** Connection closed because some FD passing operation failed */
#define XCB_CONN_CLOSED_FDPASSING_FAILED 7
#define XCB_TYPE_PAD(T,I) (-(I) & (sizeof(T) > 4 ? 3 : sizeof(T) - 1))
/* Opaque structures */
@ -115,6 +166,38 @@ typedef struct {
uint32_t full_sequence; /**< full sequence */
} xcb_generic_event_t;
/**
* @brief Raw Generic event.
*
* A generic event structure as used on the wire, i.e., without the full_sequence field
*/
typedef struct {
uint8_t response_type; /**< Type of the response */
uint8_t pad0; /**< Padding */
uint16_t sequence; /**< Sequence number */
uint32_t pad[7]; /**< Padding */
} xcb_raw_generic_event_t;
/**
* @brief GE event
*
* An event as sent by the XGE extension. The length field specifies the
* number of 4-byte blocks trailing the struct.
*
* @deprecated Since some fields in this struct have unfortunate names, it is
* recommended to use xcb_ge_generic_event_t instead.
*/
typedef struct {
uint8_t response_type; /**< Type of the response */
uint8_t pad0; /**< Padding */
uint16_t sequence; /**< Sequence number */
uint32_t length;
uint16_t event_type;
uint16_t pad1;
uint32_t pad[5]; /**< Padding */
uint32_t full_sequence; /**< full sequence */
} xcb_ge_event_t;
/**
* @brief Generic error.
*
@ -124,7 +207,11 @@ typedef struct {
uint8_t response_type; /**< Type of the response */
uint8_t error_code; /**< Error code */
uint16_t sequence; /**< Sequence number */
uint32_t pad[7]; /**< Padding */
uint32_t resource_id; /** < Resource ID for requests with side effects only */
uint16_t minor_code; /** < Minor opcode of the failed request */
uint8_t major_code; /** < Major opcode of the failed request */
uint8_t pad0;
uint32_t pad[5]; /**< Padding */
uint32_t full_sequence; /**< full sequence */
} xcb_generic_error_t;
@ -174,7 +261,7 @@ typedef struct xcb_auth_info_t {
/**
* @brief Forces any buffered output to be written to the server.
* @param c: The connection to the X server.
* @param c The connection to the X server.
* @return > @c 0 on success, <= @c 0 otherwise.
*
* Forces any buffered output to be written to the server. Blocks
@ -184,7 +271,7 @@ int xcb_flush(xcb_connection_t *c);
/**
* @brief Returns the maximum request length that this server accepts.
* @param c: The connection to the X server.
* @param c The connection to the X server.
* @return The maximum request length field.
*
* In the absence of the BIG-REQUESTS extension, returns the
@ -201,7 +288,7 @@ uint32_t xcb_get_maximum_request_length(xcb_connection_t *c);
/**
* @brief Prefetch the maximum request length without blocking.
* @param c: The connection to the X server.
* @param c The connection to the X server.
*
* Without blocking, does as much work as possible toward computing
* the maximum request length accepted by the X server.
@ -223,7 +310,7 @@ void xcb_prefetch_maximum_request_length(xcb_connection_t *c);
/**
* @brief Returns the next event or error from the server.
* @param c: The connection to the X server.
* @param c The connection to the X server.
* @return The next event from the server.
*
* Returns the next event or error from the server, or returns null in
@ -234,8 +321,7 @@ xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c);
/**
* @brief Returns the next event or error from the server.
* @param c: The connection to the X server.
* error status of the operation.
* @param c The connection to the X server.
* @return The next event from the server.
*
* Returns the next event or error from the server, if one is
@ -246,10 +332,58 @@ xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c);
*/
xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c);
/**
* @brief Returns the next event without reading from the connection.
* @param c The connection to the X server.
* @return The next already queued event from the server.
*
* This is a version of xcb_poll_for_event that only examines the
* event queue for new events. The function doesn't try to read new
* events from the connection if no queued events are found.
*
* This function is useful for callers that know in advance that all
* interesting events have already been read from the connection. For
* example, callers might use xcb_wait_for_reply and be interested
* only of events that preceded a specific reply.
*/
xcb_generic_event_t *xcb_poll_for_queued_event(xcb_connection_t *c);
typedef struct xcb_special_event xcb_special_event_t;
/**
* @brief Returns the next event from a special queue
*/
xcb_generic_event_t *xcb_poll_for_special_event(xcb_connection_t *c,
xcb_special_event_t *se);
/**
* @brief Returns the next event from a special queue, blocking until one arrives
*/
xcb_generic_event_t *xcb_wait_for_special_event(xcb_connection_t *c,
xcb_special_event_t *se);
/**
* @typedef typedef struct xcb_extension_t xcb_extension_t
*/
typedef struct xcb_extension_t xcb_extension_t; /**< Opaque structure used as key for xcb_get_extension_data_t. */
/**
* @brief Listen for a special event
*/
xcb_special_event_t *xcb_register_for_special_xge(xcb_connection_t *c,
xcb_extension_t *ext,
uint32_t eid,
uint32_t *stamp);
/**
* @brief Stop listening for a special event
*/
void xcb_unregister_for_special_event(xcb_connection_t *c,
xcb_special_event_t *se);
/**
* @brief Return the error for a request, or NULL if none can ever arrive.
* @param c: The connection to the X server.
* @param cookie: The request cookie.
* @param c The connection to the X server.
* @param cookie The request cookie.
* @return The error for the request, or NULL if none can ever arrive.
*
* The xcb_void_cookie_t cookie supplied to this function must have resulted
@ -264,18 +398,49 @@ xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c);
*/
xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie);
/**
* @brief Discards the reply for a request.
* @param c The connection to the X server.
* @param sequence The request sequence number from a cookie.
*
* Discards the reply for a request. Additionally, any error generated
* by the request is also discarded (unless it was an _unchecked request
* and the error has already arrived).
*
* This function will not block even if the reply is not yet available.
*
* Note that the sequence really does have to come from an xcb cookie;
* this function is not designed to operate on socket-handoff replies.
*/
void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence);
/**
* @brief Discards the reply for a request, given by a 64bit sequence number
* @param c The connection to the X server.
* @param sequence 64-bit sequence number as returned by xcb_send_request64().
*
* Discards the reply for a request. Additionally, any error generated
* by the request is also discarded (unless it was an _unchecked request
* and the error has already arrived).
*
* This function will not block even if the reply is not yet available.
*
* Note that the sequence really does have to come from xcb_send_request64();
* the cookie sequence number is defined as "unsigned" int and therefore
* not 64-bit on all platforms.
* This function is not designed to operate on socket-handoff replies.
*
* Unlike its xcb_discard_reply() counterpart, the given sequence number is not
* automatically "widened" to 64-bit.
*/
void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence);
/* xcb_ext.c */
/**
* @typedef typedef struct xcb_extension_t xcb_extension_t
*/
typedef struct xcb_extension_t xcb_extension_t; /**< Opaque structure used as key for xcb_get_extension_data_t. */
/**
* @brief Caches reply information from QueryExtension requests.
* @param c: The connection.
* @param ext: The extension data.
* @param c The connection.
* @param ext The extension data.
* @return A pointer to the xcb_query_extension_reply_t for the extension.
*
* This function is the primary interface to the "extension cache",
@ -288,12 +453,12 @@ typedef struct xcb_extension_t xcb_extension_t; /**< Opaque structure used as k
* The result must not be freed. This storage is managed by the cache
* itself.
*/
const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
const struct xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
/**
* @brief Prefetch of extension data into the extension cache
* @param c: The connection.
* @param ext: The extension data.
* @param c The connection.
* @param ext The extension data.
*
* This function allows a "prefetch" of extension data into the
* extension cache. Invoking the function may cause a call to
@ -308,7 +473,7 @@ void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
/**
* @brief Access the data returned by the server.
* @param c: The connection.
* @param c The connection.
* @return A pointer to an xcb_setup_t structure.
*
* Accessor for the data returned by the server when the xcb_connection_t
@ -324,37 +489,45 @@ void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
*
* The result must not be freed.
*/
const xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
XCB_PURE_FUNCTION
const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
/**
* @brief Access the file descriptor of the connection.
* @param c: The connection.
* @param c The connection.
* @return The file descriptor.
*
* Accessor for the file descriptor that was passed to the
* xcb_connect_to_fd call that returned @p c.
*/
XCB_PURE_FUNCTION
int xcb_get_file_descriptor(xcb_connection_t *c);
/**
* @brief Test whether the connection has shut down due to a fatal error.
* @param c: The connection.
* @return 1 if the connection is in an error state; 0 otherwise.
* @param c The connection.
* @return > 0 if the connection is in an error state; 0 otherwise.
*
* Some errors that occur in the context of an xcb_connection_t
* are unrecoverable. When such an error occurs, the
* connection is shut down and further operations on the
* xcb_connection_t have no effect.
* xcb_connection_t have no effect, but memory will not be freed until
* xcb_disconnect() is called on the xcb_connection_t.
*
* @todo Other functions should document the conditions in
* which they shut down the connection.
* @return XCB_CONN_ERROR, because of socket errors, pipe errors or other stream errors.
* @return XCB_CONN_CLOSED_EXT_NOTSUPPORTED, when extension not supported.
* @return XCB_CONN_CLOSED_MEM_INSUFFICIENT, when memory not available.
* @return XCB_CONN_CLOSED_REQ_LEN_EXCEED, exceeding request length that server accepts.
* @return XCB_CONN_CLOSED_PARSE_ERR, error during parsing display string.
* @return XCB_CONN_CLOSED_INVALID_SCREEN, because the server does not have a screen matching the display.
*/
XCB_PURE_FUNCTION
int xcb_connection_has_error(xcb_connection_t *c);
/**
* @brief Connects to the X server.
* @param fd: The file descriptor.
* @param auth_info: Authentication data.
* @param fd The file descriptor.
* @param auth_info Authentication data.
* @return A newly allocated xcb_connection_t structure.
*
* Connects to an X server, given the open socket @p fd and the
@ -362,15 +535,20 @@ int xcb_connection_has_error(xcb_connection_t *c);
* bidirectionally connected to an X server. If the connection
* should be unauthenticated, @p auth_info must be @c
* NULL.
*
* Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
* Callers need to use xcb_connection_has_error() to check for failure.
* When finished, use xcb_disconnect() to close the connection and free
* the structure.
*/
xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info);
/**
* @brief Closes the connection.
* @param c: The connection.
* @param c The connection.
*
* Closes the file descriptor and frees all memory associated with the
* connection @c c.
* connection @c c. If @p c is @c NULL, nothing is done.
*/
void xcb_disconnect(xcb_connection_t *c);
@ -379,10 +557,10 @@ void xcb_disconnect(xcb_connection_t *c);
/**
* @brief Parses a display string name in the form documented by X(7x).
* @param name: The name of the display.
* @param host: A pointer to a malloc'd copy of the hostname.
* @param display: A pointer to the display number.
* @param screen: A pointer to the screen number.
* @param name The name of the display.
* @param host A pointer to a malloc'd copy of the hostname.
* @param display A pointer to the display number.
* @param screen A pointer to the screen number.
* @return 0 on failure, non 0 otherwise.
*
* Parses the display string name @p display_name in the form
@ -398,8 +576,8 @@ int xcb_parse_display(const char *name, char **host, int *display, int *screen);
/**
* @brief Connects to the X server.
* @param displayname: The name of the display.
* @param screenp: A pointer to a preferred screen number.
* @param displayname The name of the display.
* @param screenp A pointer to a preferred screen number.
* @return A newly allocated xcb_connection_t structure.
*
* Connects to the X server specified by @p displayname. If @p
@ -407,20 +585,30 @@ int xcb_parse_display(const char *name, char **host, int *display, int *screen);
* variable. If a particular screen on that server is preferred, the
* int pointed to by @p screenp (if not @c NULL) will be set to that
* screen; otherwise the screen will be set to 0.
*
* Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
* Callers need to use xcb_connection_has_error() to check for failure.
* When finished, use xcb_disconnect() to close the connection and free
* the structure.
*/
xcb_connection_t *xcb_connect(const char *displayname, int *screenp);
/**
* @brief Connects to the X server, using an authorization information.
* @param display: The name of the display.
* @param auth: The authorization information.
* @param screen: A pointer to a preferred screen number.
* @param display The name of the display.
* @param auth The authorization information.
* @param screen A pointer to a preferred screen number.
* @return A newly allocated xcb_connection_t structure.
*
* Connects to the X server specified by @p displayname, using the
* authorization @p auth. If a particular screen on that server is
* preferred, the int pointed to by @p screenp (if not @c NULL) will
* be set to that screen; otherwise @p screenp will be set to 0.
*
* Always returns a non-NULL pointer to a xcb_connection_t, even on failure.
* Callers need to use xcb_connection_has_error() to check for failure.
* When finished, use xcb_disconnect() to close the connection and free
* the structure.
*/
xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb_auth_info_t *auth, int *screen);
@ -429,8 +617,8 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb
/**
* @brief Allocates an XID for a new object.
* @param c: The connection.
* @return A newly allocated XID.
* @param c The connection.
* @return A newly allocated XID, or -1 on failure.
*
* Allocates an XID for a new object. Typically used just prior to
* various object creation functions, such as xcb_create_window.
@ -438,6 +626,35 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb
uint32_t xcb_generate_id(xcb_connection_t *c);
/**
* @brief Obtain number of bytes read from the connection.
* @param c The connection
* @return Number of bytes read from the server.
*
* Returns cumulative number of bytes received from the connection.
*
* This retrieves the total number of bytes read from this connection,
* to be used for diagnostic/monitoring/informative purposes.
*/
uint64_t
xcb_total_read(xcb_connection_t *c);
/**
*
* @brief Obtain number of bytes written to the connection.
* @param c The connection
* @return Number of bytes written to the server.
*
* Returns cumulative number of bytes sent to the connection.
*
* This retrieves the total number of bytes written to this connection,
* to be used for diagnostic/monitoring/informative purposes.
*/
uint64_t
xcb_total_written(xcb_connection_t *c);
/**
* @}
*/

View File

@ -25,14 +25,35 @@
/* Authorization systems for the X protocol. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <X11/Xauth.h>
#include <stdlib.h>
#include <time.h>
#ifdef __INTERIX
/* _don't_ ask. interix has INADDR_LOOPBACK in here. */
#include <rpc/types.h>
#endif
#ifdef _WIN32
#ifdef HASXDMAUTH
/* We must include the wrapped windows.h before any system header which includes
it unwrapped, to avoid conflicts with types defined in X headers */
#include <X11/Xwindows.h>
#endif
#include "xcb_windefs.h"
#else
#include <sys/param.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <sys/param.h>
#include <unistd.h>
#include <stdlib.h>
#endif /* _WIN32 */
#include "xcb.h"
#include "xcbint.h"
@ -49,50 +70,59 @@ enum auth_protos {
N_AUTH_PROTOS
};
static char *authnames[N_AUTH_PROTOS] = {
#define AUTH_PROTO_XDM_AUTHORIZATION "XDM-AUTHORIZATION-1"
#define AUTH_PROTO_MIT_MAGIC_COOKIE "MIT-MAGIC-COOKIE-1"
static const char *authnames[N_AUTH_PROTOS] = {
#ifdef HASXDMAUTH
"XDM-AUTHORIZATION-1",
AUTH_PROTO_XDM_AUTHORIZATION,
#endif
"MIT-MAGIC-COOKIE-1",
AUTH_PROTO_MIT_MAGIC_COOKIE,
};
static int authnameslen[N_AUTH_PROTOS] = {
#ifdef HASXDMAUTH
sizeof(AUTH_PROTO_XDM_AUTHORIZATION) - 1,
#endif
sizeof(AUTH_PROTO_MIT_MAGIC_COOKIE) - 1,
};
static size_t memdup(char **dst, void *src, size_t len)
{
if(len)
*dst = malloc(len);
*dst = malloc(len);
else
*dst = 0;
*dst = 0;
if(!*dst)
return 0;
return 0;
memcpy(*dst, src, len);
return len;
}
static int authname_match(enum auth_protos kind, char *name, int namelen)
static int authname_match(enum auth_protos kind, char *name, size_t namelen)
{
if(strlen(authnames[kind]) != namelen)
return 0;
if(authnameslen[kind] != namelen)
return 0;
if(memcmp(authnames[kind], name, namelen))
return 0;
return 0;
return 1;
}
#define SIN6_ADDR(s) (&((struct sockaddr_in6 *)s)->sin6_addr)
static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
int display)
static Xauth *get_authptr(struct sockaddr *sockname, int display)
{
char *addr = 0;
int addrlen = 0;
unsigned short family;
char hostnamebuf[256]; /* big enough for max hostname */
char dispbuf[40]; /* big enough to hold more than 2^64 base 10 */
int authnamelens[N_AUTH_PROTOS];
int i;
int dispbuflen;
family = FamilyLocal; /* 256 */
switch(sockname->sa_family)
{
#ifdef AF_INET6
case AF_INET6:
addr = (char *) SIN6_ADDR(sockname);
addrlen = sizeof(*SIN6_ADDR(sockname));
@ -104,6 +134,8 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
}
addr += 12;
/* if v4-mapped, fall through. */
XCB_ALLOW_FALLTHRU
#endif
case AF_INET:
if(!addr)
addr = (char *) &((struct sockaddr_in *)sockname)->sin_addr;
@ -117,7 +149,11 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
return 0; /* cannot authenticate this family */
}
snprintf(dispbuf, sizeof(dispbuf), "%d", display);
dispbuflen = snprintf(dispbuf, sizeof(dispbuf), "%d", display);
if(dispbuflen < 0)
return 0;
/* snprintf may have truncate our text */
dispbuflen = MIN(dispbuflen, sizeof(dispbuf) - 1);
if (family == FamilyLocal) {
if (gethostname(hostnamebuf, sizeof(hostnamebuf)) == -1)
@ -126,12 +162,10 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen,
addrlen = strlen(addr);
}
for (i = 0; i < N_AUTH_PROTOS; i++)
authnamelens[i] = strlen(authnames[i]);
return XauGetBestAuthByAddr (family,
(unsigned short) addrlen, addr,
(unsigned short) strlen(dispbuf), dispbuf,
N_AUTH_PROTOS, authnames, authnamelens);
(unsigned short) dispbuflen, dispbuf,
N_AUTH_PROTOS, (char **)authnames, authnameslen);
}
#ifdef HASXDMAUTH
@ -151,7 +185,7 @@ static void do_append(char *buf, int *idxp, void *val, size_t valsize) {
*idxp += valsize;
}
#endif
static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *sockname)
{
if (authname_match(AUTH_MC1, authptr->name, authptr->name_length)) {
@ -163,28 +197,29 @@ static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *
#ifdef HASXDMAUTH
#define APPEND(buf,idx,val) do_append((buf),&(idx),&(val),sizeof(val))
if (authname_match(AUTH_XA1, authptr->name, authptr->name_length)) {
int j;
int j;
info->data = malloc(192 / 8);
if(!info->data)
return 0;
info->data = malloc(192 / 8);
if(!info->data)
return 0;
for (j = 0; j < 8; j++)
info->data[j] = authptr->data[j];
switch(sockname->sa_family) {
for (j = 0; j < 8; j++)
info->data[j] = authptr->data[j];
switch(sockname->sa_family) {
case AF_INET:
/*block*/ {
struct sockaddr_in *si = (struct sockaddr_in *) sockname;
APPEND(info->data, j, si->sin_addr.s_addr);
APPEND(info->data, j, si->sin_port);
}
break;
struct sockaddr_in *si = (struct sockaddr_in *) sockname;
APPEND(info->data, j, si->sin_addr.s_addr);
APPEND(info->data, j, si->sin_port);
}
break;
#ifdef AF_INET6
case AF_INET6:
/*block*/ {
struct sockaddr_in6 *si6 = (struct sockaddr_in6 *) sockname;
if(IN6_IS_ADDR_V4MAPPED(SIN6_ADDR(sockname)))
{
APPEND(info->data, j, si6->sin6_addr.s6_addr[12]);
do_append(info->data, &j, &si6->sin6_addr.s6_addr[12], 4);
APPEND(info->data, j, si6->sin6_port);
}
else
@ -199,28 +234,29 @@ static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *
}
}
break;
#endif
case AF_UNIX:
/*block*/ {
uint32_t fakeaddr = htonl(0xffffffff - next_nonce());
uint16_t fakeport = htons(getpid());
APPEND(info->data, j, fakeaddr);
APPEND(info->data, j, fakeport);
}
break;
uint32_t fakeaddr = htonl(0xffffffff - next_nonce());
uint16_t fakeport = htons(getpid());
APPEND(info->data, j, fakeaddr);
APPEND(info->data, j, fakeport);
}
break;
default:
free(info->data);
return 0; /* do not know how to build this */
}
{
uint32_t now = htonl(time(0));
APPEND(info->data, j, now);
}
assert(j <= 192 / 8);
while (j < 192 / 8)
info->data[j++] = 0;
info->datalen = j;
XdmcpWrap ((unsigned char *) info->data, (unsigned char *) authptr->data + 8, (unsigned char *) info->data, info->datalen);
return 1;
}
{
uint32_t now = htonl(time(0));
APPEND(info->data, j, now);
}
assert(j <= 192 / 8);
while (j < 192 / 8)
info->data[j++] = 0;
info->datalen = j;
XdmcpWrap ((unsigned char *) info->data, (unsigned char *) authptr->data + 8, (unsigned char *) info->data, info->datalen);
return 1;
}
#undef APPEND
#endif
@ -228,32 +264,125 @@ static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *
return 0; /* Unknown authorization type */
}
/* `sockaddr_un.sun_path' typical size usually ranges between 92 and 108 */
#define INITIAL_SOCKNAME_SLACK 108
/* Return a dynamically allocated socket address structure according
to the value returned by either getpeername() or getsockname()
(according to POSIX, applications should not assume a particular
length for `sockaddr_un.sun_path') */
#ifdef _WIN32
static struct sockaddr *get_peer_sock_name(int(_stdcall *socket_func)(SOCKET,
struct sockaddr *,
socklen_t *),
int fd)
#else
static struct sockaddr *get_peer_sock_name(int (*socket_func)(int,
struct sockaddr *,
socklen_t *),
int fd)
#endif
{
socklen_t socknamelen = sizeof(struct sockaddr) + INITIAL_SOCKNAME_SLACK;
socklen_t actual_socknamelen = socknamelen;
struct sockaddr *sockname = malloc(socknamelen);
if (sockname == NULL)
return NULL;
/* Both getpeername() and getsockname() truncates sockname if
there is not enough space and set the required length in
actual_socknamelen */
if (socket_func(fd, sockname, &actual_socknamelen) == -1)
goto sock_or_realloc_error;
if (actual_socknamelen > socknamelen)
{
struct sockaddr *new_sockname = NULL;
socknamelen = actual_socknamelen;
if ((new_sockname = realloc(sockname, actual_socknamelen)) == NULL)
goto sock_or_realloc_error;
sockname = new_sockname;
if (socket_func(fd, sockname, &actual_socknamelen) == -1 ||
actual_socknamelen > socknamelen)
goto sock_or_realloc_error;
}
return sockname;
sock_or_realloc_error:
free(sockname);
return NULL;
}
int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display)
{
/* code adapted from Xlib/ConnDis.c, xtrans/Xtranssocket.c,
xtrans/Xtransutils.c */
char sockbuf[sizeof(struct sockaddr) + MAXPATHLEN];
unsigned int socknamelen = sizeof(sockbuf); /* need extra space */
struct sockaddr *sockname = (struct sockaddr *) &sockbuf;
struct sockaddr *sockname = NULL;
int gotsockname = 0;
Xauth *authptr = 0;
int ret = 1;
if (getpeername(fd, sockname, &socknamelen) == -1)
return 0; /* can only authenticate sockets */
/* Some systems like hpux or Hurd do not expose peer names
* for UNIX Domain Sockets, but this is irrelevant,
* since compute_auth() ignores the peer name in this
* case anyway.*/
if ((sockname = get_peer_sock_name(getpeername, fd)) == NULL)
{
if ((sockname = get_peer_sock_name(getsockname, fd)) == NULL)
return 0; /* can only authenticate sockets */
if (sockname->sa_family != AF_UNIX)
{
free(sockname);
return 0; /* except for AF_UNIX, sockets should have peernames */
}
gotsockname = 1;
}
authptr = get_authptr(sockname, socknamelen, display);
authptr = get_authptr(sockname, display);
if (authptr == 0)
{
free(sockname);
return 0; /* cannot find good auth data */
}
info->namelen = memdup(&info->name, authptr->name, authptr->name_length);
if(info->namelen)
ret = compute_auth(info, authptr, sockname);
if (!info->namelen)
goto no_auth; /* out of memory */
if (!gotsockname)
{
free(sockname);
if ((sockname = get_peer_sock_name(getsockname, fd)) == NULL)
{
free(info->name);
goto no_auth; /* can only authenticate sockets */
}
}
ret = compute_auth(info, authptr, sockname);
if(!ret)
{
free(info->name);
info->name = 0;
info->namelen = 0;
free(info->name);
goto no_auth; /* cannot build auth record */
}
free(sockname);
sockname = NULL;
XauDisposeAuth(authptr);
return ret;
no_auth:
free(sockname);
info->name = 0;
info->namelen = 0;
XauDisposeAuth(authptr);
return 0;
}

View File

@ -25,18 +25,39 @@
/* Connection management: the core of XCB. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <sys/select.h>
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include "xcb.h"
#include "xcbint.h"
#if USE_POLL
#include <poll.h>
#elif !defined _WIN32
#include <sys/select.h>
#endif
#ifdef _WIN32
#include "xcb_windefs.h"
#include <io.h>
#else
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#endif /* _WIN32 */
/* SHUT_RDWR is fairly recent and is not available on all platforms */
#if !defined(SHUT_RDWR)
#define SHUT_RDWR 2
#endif
typedef struct {
uint8_t status;
@ -44,10 +65,53 @@ typedef struct {
uint16_t length;
} xcb_setup_generic_t;
static const int error_connection = 1;
static const xcb_setup_t xcb_error_setup = {
0, /* status: failed (but we wouldn't have a xcb_setup_t in this case) */
0, /* pad0 */
0, 0, /* protocol version, should be 11.0, but isn't */
0, /* length, invalid value */
0, /* release_number */
0, 0, /* resource_id_{base,mask} */
0, /* motion_buffer_size */
0, /* vendor_len */
0, /* maximum_request_length */
0, /* roots_len */
0, /* pixmap_formats_len */
0, /* image_byte_order */
0, /* bitmap_format_bit_order */
0, /* bitmap_format_scanline_unit */
0, /* bitmap_format_scanline_pad */
0, 0, /* {min,max}_keycode */
{ 0, 0, 0, 0 } /* pad1 */
};
/* Keep this list in sync with is_static_error_conn()! */
static const int xcb_con_error = XCB_CONN_ERROR;
static const int xcb_con_closed_mem_er = XCB_CONN_CLOSED_MEM_INSUFFICIENT;
static const int xcb_con_closed_parse_er = XCB_CONN_CLOSED_PARSE_ERR;
static const int xcb_con_closed_screen_er = XCB_CONN_CLOSED_INVALID_SCREEN;
static int is_static_error_conn(xcb_connection_t *c)
{
return c == (xcb_connection_t *) &xcb_con_error ||
c == (xcb_connection_t *) &xcb_con_closed_mem_er ||
c == (xcb_connection_t *) &xcb_con_closed_parse_er ||
c == (xcb_connection_t *) &xcb_con_closed_screen_er;
}
static int set_fd_flags(const int fd)
{
/* Win32 doesn't have file descriptors and the fcntl function. This block sets the socket in non-blocking mode */
#ifdef _WIN32
u_long iMode = 1; /* non-zero puts it in non-blocking mode, 0 in blocking mode */
int ret = 0;
ret = ioctlsocket(fd, FIONBIO, &iMode);
if(ret != 0)
return 0;
return 1;
#else
int flags = fcntl(fd, F_GETFL, 0);
if(flags == -1)
return 0;
@ -57,21 +121,7 @@ static int set_fd_flags(const int fd)
if(fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
return 0;
return 1;
}
static int _xcb_xlib_init(_xcb_xlib *xlib)
{
xlib->lock = 0;
#ifndef NDEBUG
xlib->sloppy_lock = (getenv("LIBXCB_ALLOW_SLOPPY_LOCK") != 0);
#endif
pthread_cond_init(&xlib->cond, 0);
return 1;
}
static void _xcb_xlib_destroy(_xcb_xlib *xlib)
{
pthread_cond_destroy(&xlib->cond);
#endif /* _WIN32 */
}
static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
@ -80,7 +130,7 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
xcb_setup_request_t out;
struct iovec parts[6];
int count = 0;
int endian = 0x01020304;
static const uint32_t endian = 0x01020304;
int ret;
memset(&out, 0, sizeof(out));
@ -110,19 +160,18 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
parts[count].iov_len = XCB_PAD(out.authorization_protocol_data_len);
parts[count++].iov_base = (char *) pad;
}
assert(count <= sizeof(parts) / sizeof(*parts));
assert(count <= (int) (sizeof(parts) / sizeof(*parts)));
_xcb_lock_io(c);
{
struct iovec *parts_ptr = parts;
ret = _xcb_out_send(c, &parts_ptr, &count);
}
_xcb_unlock_io(c);
pthread_mutex_lock(&c->iolock);
ret = _xcb_out_send(c, parts, count);
pthread_mutex_unlock(&c->iolock);
return ret;
}
static int read_setup(xcb_connection_t *c)
{
const char newline = '\n';
/* Read the server response */
c->setup = malloc(sizeof(xcb_setup_generic_t));
if(!c->setup)
@ -148,6 +197,7 @@ static int read_setup(xcb_connection_t *c)
{
xcb_setup_failed_t *setup = (xcb_setup_failed_t *) c->setup;
write(STDERR_FILENO, xcb_setup_failed_reason(setup), xcb_setup_failed_reason_length(setup));
write(STDERR_FILENO, &newline, 1);
return 0;
}
@ -155,6 +205,7 @@ static int read_setup(xcb_connection_t *c)
{
xcb_setup_authenticate_t *setup = (xcb_setup_authenticate_t *) c->setup;
write(STDERR_FILENO, xcb_setup_authenticate_reason(setup), xcb_setup_authenticate_reason_length(setup));
write(STDERR_FILENO, &newline, 1);
return 0;
}
}
@ -165,31 +216,114 @@ static int read_setup(xcb_connection_t *c)
/* precondition: there must be something for us to write. */
static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
{
#ifndef _WIN32
int n;
#endif
assert(!c->out.queue_len);
n = writev(c->fd, *vector, *count);
if(n < 0 && errno == EAGAIN)
return 1;
#ifdef _WIN32
/* Could use the WSASend win32 function for scatter/gather i/o but setting up the WSABUF struct from
an iovec would require more work and I'm not sure of the benefit....works for now */
while (*count)
{
struct iovec *vec = *vector;
if (vec->iov_len)
{
int ret = send(c->fd, vec->iov_base, vec->iov_len, 0);
if (ret == SOCKET_ERROR)
{
int err = WSAGetLastError();
if (err == WSAEWOULDBLOCK)
{
return 1;
}
}
if (ret <= 0)
{
_xcb_conn_shutdown(c, XCB_CONN_ERROR);
return 0;
}
c->out.total_written += ret;
vec->iov_len -= ret;
vec->iov_base = (char *)vec->iov_base + ret;
}
if (vec->iov_len == 0) {
(*vector)++;
(*count)--;
}
}
if (!*count)
*vector = 0;
#else
n = *count;
if (n > IOV_MAX)
n = IOV_MAX;
#if HAVE_SENDMSG
if (c->out.out_fd.nfd) {
union {
struct cmsghdr cmsghdr;
char buf[CMSG_SPACE(XCB_MAX_PASS_FD * sizeof(int))];
} cmsgbuf;
struct msghdr msg = {
.msg_name = NULL,
.msg_namelen = 0,
.msg_iov = *vector,
.msg_iovlen = n,
.msg_control = cmsgbuf.buf,
.msg_controllen = CMSG_LEN(c->out.out_fd.nfd * sizeof (int)),
};
int i;
struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg);
hdr->cmsg_len = msg.msg_controllen;
hdr->cmsg_level = SOL_SOCKET;
hdr->cmsg_type = SCM_RIGHTS;
memcpy(CMSG_DATA(hdr), c->out.out_fd.fd, c->out.out_fd.nfd * sizeof (int));
n = sendmsg(c->fd, &msg, 0);
if(n < 0 && errno == EAGAIN)
return 1;
for (i = 0; i < c->out.out_fd.nfd; i++)
close(c->out.out_fd.fd[i]);
c->out.out_fd.nfd = 0;
} else
#endif
{
n = writev(c->fd, *vector, n);
if(n < 0 && errno == EAGAIN)
return 1;
}
if(n <= 0)
{
_xcb_conn_shutdown(c);
_xcb_conn_shutdown(c, XCB_CONN_ERROR);
return 0;
}
c->out.total_written += n;
for(; *count; --*count, ++*vector)
{
int cur = (*vector)->iov_len;
if(cur > n)
cur = n;
(*vector)->iov_len -= cur;
(*vector)->iov_base = (char *) (*vector)->iov_base + cur;
n -= cur;
if(cur) {
(*vector)->iov_len -= cur;
(*vector)->iov_base = (char *) (*vector)->iov_base + cur;
n -= cur;
}
if((*vector)->iov_len)
break;
}
if(!*count)
*vector = 0;
assert(n == 0);
#endif /* _WIN32 */
return 1;
}
@ -197,15 +331,15 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
const xcb_setup_t *xcb_get_setup(xcb_connection_t *c)
{
if(c->has_error)
return 0;
if(is_static_error_conn(c))
return &xcb_error_setup;
/* doesn't need locking because it's never written to. */
return c->setup;
}
int xcb_get_file_descriptor(xcb_connection_t *c)
{
if(c->has_error)
if(is_static_error_conn(c))
return -1;
/* doesn't need locking because it's never written to. */
return c->fd;
@ -221,16 +355,31 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info)
{
xcb_connection_t* c;
#ifndef _WIN32
#ifndef USE_POLL
if(fd >= FD_SETSIZE) /* would overflow in FD_SET */
{
close(fd);
return _xcb_conn_ret_error(XCB_CONN_ERROR);
}
#endif
#endif /* !_WIN32*/
c = calloc(1, sizeof(xcb_connection_t));
if(!c)
return (xcb_connection_t *) &error_connection;
if(!c) {
#ifdef _WIN32
closesocket(fd);
#else
close(fd);
#endif
return _xcb_conn_ret_error(XCB_CONN_CLOSED_MEM_INSUFFICIENT) ;
}
c->fd = fd;
if(!(
set_fd_flags(fd) &&
pthread_mutex_init(&c->iolock, 0) == 0 &&
_xcb_xlib_init(&c->xlib) &&
_xcb_in_init(&c->in) &&
_xcb_out_init(&c->out) &&
write_setup(c, auth_info) &&
@ -240,7 +389,7 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info)
))
{
xcb_disconnect(c);
return (xcb_connection_t *) &error_connection;
return _xcb_conn_ret_error(XCB_CONN_ERROR);
}
return c;
@ -248,14 +397,20 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info)
void xcb_disconnect(xcb_connection_t *c)
{
if(c->has_error)
if(c == NULL || is_static_error_conn(c))
return;
free(c->setup);
/* disallow further sends and receives */
shutdown(c->fd, SHUT_RDWR);
#ifdef _WIN32
closesocket(c->fd);
#else
close(c->fd);
#endif
pthread_mutex_destroy(&c->iolock);
_xcb_xlib_destroy(&c->xlib);
_xcb_in_destroy(&c->in);
_xcb_out_destroy(&c->out);
@ -263,100 +418,138 @@ void xcb_disconnect(xcb_connection_t *c)
_xcb_xid_destroy(c);
free(c);
#ifdef _WIN32
WSACleanup();
#endif
}
/* Private interface */
void _xcb_conn_shutdown(xcb_connection_t *c)
void _xcb_conn_shutdown(xcb_connection_t *c, int err)
{
c->has_error = 1;
c->has_error = err;
}
void _xcb_lock_io(xcb_connection_t *c)
/* Return connection error state.
* To make thread-safe, I need a seperate static
* variable for every possible error.
* has_error is the first field in xcb_connection_t, so just
* return a casted int here; checking has_error (and only
* has_error) will be safe.
*/
xcb_connection_t *_xcb_conn_ret_error(int err)
{
pthread_mutex_lock(&c->iolock);
while(c->xlib.lock)
{
if(pthread_equal(c->xlib.thread, pthread_self()))
break;
pthread_cond_wait(&c->xlib.cond, &c->iolock);
}
}
void _xcb_unlock_io(xcb_connection_t *c)
{
pthread_mutex_unlock(&c->iolock);
}
void _xcb_wait_io(xcb_connection_t *c, pthread_cond_t *cond)
{
int xlib_locked = c->xlib.lock;
if(xlib_locked)
switch(err)
{
c->xlib.lock = 0;
pthread_cond_broadcast(&c->xlib.cond);
}
pthread_cond_wait(cond, &c->iolock);
if(xlib_locked)
{
while(c->xlib.lock)
pthread_cond_wait(&c->xlib.cond, &c->iolock);
c->xlib.lock = 1;
c->xlib.thread = pthread_self();
case XCB_CONN_CLOSED_MEM_INSUFFICIENT:
{
return (xcb_connection_t *) &xcb_con_closed_mem_er;
}
case XCB_CONN_CLOSED_PARSE_ERR:
{
return (xcb_connection_t *) &xcb_con_closed_parse_er;
}
case XCB_CONN_CLOSED_INVALID_SCREEN:
{
return (xcb_connection_t *) &xcb_con_closed_screen_er;
}
case XCB_CONN_ERROR:
default:
{
return (xcb_connection_t *) &xcb_con_error;
}
}
}
int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count)
{
int ret, xlib_locked;
int ret;
#if USE_POLL
struct pollfd fd;
#else
fd_set rfds, wfds;
#endif
/* If the thing I should be doing is already being done, wait for it. */
if(count ? c->out.writing : c->in.reading)
{
_xcb_wait_io(c, cond);
pthread_cond_wait(cond, &c->iolock);
return 1;
}
#if USE_POLL
memset(&fd, 0, sizeof(fd));
fd.fd = c->fd;
fd.events = POLLIN;
#else
FD_ZERO(&rfds);
FD_SET(c->fd, &rfds);
#endif
++c->in.reading;
#if USE_POLL
if(count)
{
fd.events |= POLLOUT;
++c->out.writing;
}
#else
FD_ZERO(&wfds);
if(count)
{
FD_SET(c->fd, &wfds);
++c->out.writing;
}
#endif
xlib_locked = c->xlib.lock;
if(xlib_locked)
{
c->xlib.lock = 0;
pthread_cond_broadcast(&c->xlib.cond);
}
_xcb_unlock_io(c);
pthread_mutex_unlock(&c->iolock);
do {
ret = select(c->fd + 1, &rfds, &wfds, 0, 0);
#if USE_POLL
ret = poll(&fd, 1, -1);
/* If poll() returns an event we didn't expect, such as POLLNVAL, treat
* it as if it failed. */
if(ret >= 0 && (fd.revents & ~fd.events))
{
ret = -1;
break;
}
#else
ret = select(c->fd + 1, &rfds, &wfds, 0, 0);
#endif
} while (ret == -1 && errno == EINTR);
if (ret < 0)
if(ret < 0)
{
_xcb_conn_shutdown(c);
ret = 0;
}
_xcb_lock_io(c);
if(xlib_locked)
{
c->xlib.lock = 1;
c->xlib.thread = pthread_self();
_xcb_conn_shutdown(c, XCB_CONN_ERROR);
ret = 0;
}
pthread_mutex_lock(&c->iolock);
if(ret)
{
if(FD_ISSET(c->fd, &rfds))
/* The code allows two threads to call select()/poll() at the same time.
* First thread just wants to read, a second thread wants to write, too.
* We have to make sure that we don't steal the reading thread's reply
* and let it get stuck in select()/poll().
* So a thread may read if either:
* - There is no other thread that wants to read (the above situation
* did not occur).
* - It is the reading thread (above situation occurred).
*/
int may_read = c->in.reading == 1 || !count;
#if USE_POLL
if(may_read && (fd.revents & POLLIN) != 0)
#else
if(may_read && FD_ISSET(c->fd, &rfds))
#endif
ret = ret && _xcb_in_read(c);
#if USE_POLL
if((fd.revents & POLLOUT) != 0)
#else
if(FD_ISSET(c->fd, &wfds))
#endif
ret = ret && write_vec(c, vector, count);
}
@ -366,3 +559,30 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
return ret;
}
uint64_t xcb_total_read(xcb_connection_t *c)
{
uint64_t n;
if (xcb_connection_has_error(c))
return 0;
pthread_mutex_lock(&c->iolock);
n = c->in.total_read;
pthread_mutex_unlock(&c->iolock);
return n;
}
uint64_t xcb_total_written(xcb_connection_t *c)
{
uint64_t n;
if (xcb_connection_has_error(c))
return 0;
pthread_mutex_lock(&c->iolock);
n = c->out.total_written;
pthread_mutex_unlock(&c->iolock);
return n;
}

View File

@ -25,6 +25,10 @@
/* A cache for QueryExtension results. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
@ -40,11 +44,11 @@ typedef struct lazyreply {
} value;
} lazyreply;
static lazyreply *get_index(xcb_connection_t *c, int index)
static lazyreply *get_index(xcb_connection_t *c, int idx)
{
if(index > c->ext.extensions_size)
if(idx > c->ext.extensions_size)
{
int new_size = index << 1;
int new_size = idx << 1;
lazyreply *new_extensions = realloc(c->ext.extensions, sizeof(lazyreply) * new_size);
if(!new_extensions)
return 0;
@ -52,7 +56,7 @@ static lazyreply *get_index(xcb_connection_t *c, int index)
c->ext.extensions = new_extensions;
c->ext.extensions_size = new_size;
}
return c->ext.extensions + index - 1;
return c->ext.extensions + idx - 1;
}
static lazyreply *get_lazyreply(xcb_connection_t *c, xcb_extension_t *ext)

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,10 @@
/* A generic implementation of a list of void-pointers. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "xcb.h"
@ -32,7 +36,7 @@
typedef struct node {
struct node *next;
unsigned int key;
uint64_t key;
void *data;
} node;
@ -43,7 +47,7 @@ struct _xcb_map {
/* Private interface */
_xcb_map *_xcb_map_new()
_xcb_map *_xcb_map_new(void)
{
_xcb_map *list;
list = malloc(sizeof(_xcb_map));
@ -69,7 +73,7 @@ void _xcb_map_delete(_xcb_map *list, xcb_list_free_func_t do_free)
free(list);
}
int _xcb_map_put(_xcb_map *list, unsigned int key, void *data)
int _xcb_map_put(_xcb_map *list, uint64_t key, void *data)
{
node *cur = malloc(sizeof(node));
if(!cur)
@ -82,7 +86,7 @@ int _xcb_map_put(_xcb_map *list, unsigned int key, void *data)
return 1;
}
void *_xcb_map_remove(_xcb_map *list, unsigned int key)
void *_xcb_map_remove(_xcb_map *list, uint64_t key)
{
node **cur;
for(cur = &list->head; *cur; cur = &(*cur)->next)

View File

@ -25,9 +25,17 @@
/* Stuff that sends stuff to the server. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <stdlib.h>
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include <string.h>
#include "xcb.h"
@ -35,8 +43,17 @@
#include "xcbint.h"
#include "bigreq.h"
static int write_block(xcb_connection_t *c, struct iovec *vector, int count)
static inline void send_request(xcb_connection_t *c, int isvoid, enum workarounds workaround, int flags, struct iovec *vector, int count)
{
if(c->has_error)
return;
++c->out.request;
if(!isvoid)
c->in.request_expected = c->out.request;
if(workaround != WORKAROUND_NONE || flags != 0)
_xcb_in_expect_reply(c, c->out.request, workaround, flags);
while(count && c->out.queue_len + vector[0].iov_len <= sizeof(c->out.queue))
{
memcpy(c->out.queue + c->out.queue_len, vector[0].iov_base, vector[0].iov_len);
@ -46,13 +63,75 @@ static int write_block(xcb_connection_t *c, struct iovec *vector, int count)
++vector, --count;
}
if(!count)
return 1;
return;
--vector, ++count;
vector[0].iov_base = c->out.queue;
vector[0].iov_len = c->out.queue_len;
c->out.queue_len = 0;
return _xcb_out_send(c, &vector, &count);
_xcb_out_send(c, vector, count);
}
static void send_sync(xcb_connection_t *c)
{
static const union {
struct {
uint8_t major;
uint8_t pad;
uint16_t len;
} fields;
uint32_t packet;
} sync_req = { { /* GetInputFocus */ 43, 0, 1 } };
struct iovec vector[2];
vector[1].iov_base = (char *) &sync_req;
vector[1].iov_len = sizeof(sync_req);
send_request(c, 0, WORKAROUND_NONE, XCB_REQUEST_DISCARD_REPLY, vector + 1, 1);
}
static void get_socket_back(xcb_connection_t *c)
{
while(c->out.return_socket && c->out.socket_moving)
pthread_cond_wait(&c->out.socket_cond, &c->iolock);
if(!c->out.return_socket)
return;
c->out.socket_moving = 1;
pthread_mutex_unlock(&c->iolock);
c->out.return_socket(c->out.socket_closure);
pthread_mutex_lock(&c->iolock);
c->out.socket_moving = 0;
pthread_cond_broadcast(&c->out.socket_cond);
c->out.return_socket = 0;
c->out.socket_closure = 0;
_xcb_in_replies_done(c);
}
static void prepare_socket_request(xcb_connection_t *c)
{
/* We're about to append data to out.queue, so we need to
* atomically test for an external socket owner *and* some other
* thread currently writing.
*
* If we have an external socket owner, we have to get the socket back
* before we can use it again.
*
* If some other thread is writing to the socket, we assume it's
* writing from out.queue, and so we can't stick data there.
*
* We satisfy this condition by first calling get_socket_back
* (which may drop the lock, but will return when XCB owns the
* socket again) and then checking for another writing thread and
* escaping the loop if we're ready to go.
*/
for (;;) {
if(c->has_error)
return;
get_socket_back(c);
if (!c->out.writing)
break;
pthread_cond_wait(&c->out.cond, &c->iolock);
}
}
/* Public interface */
@ -102,23 +181,59 @@ uint32_t xcb_get_maximum_request_length(xcb_connection_t *c)
return c->out.maximum_request_length.value;
}
unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
static void close_fds(int *fds, unsigned int num_fds)
{
static const union {
struct {
uint8_t major;
uint8_t pad;
uint16_t len;
} fields;
uint32_t packet;
} sync = { { /* GetInputFocus */ 43, 0, 1 } };
unsigned int request;
uint32_t prefix[3] = { 0 };
for (unsigned int index = 0; index < num_fds; index++)
close(fds[index]);
}
static void send_fds(xcb_connection_t *c, int *fds, unsigned int num_fds)
{
#if HAVE_SENDMSG
/* Calling _xcb_out_flush_to() can drop the iolock and wait on a condition
* variable if another thread is currently writing (c->out.writing > 0).
* This call waits for writers to be done and thus _xcb_out_flush_to() will
* do the work itself (in which case we are a writer and
* prepare_socket_request() will wait for us to be done if another threads
* tries to send fds, too). Thanks to this, we can atomically write out FDs.
*/
prepare_socket_request(c);
while (num_fds > 0) {
while (c->out.out_fd.nfd == XCB_MAX_PASS_FD && !c->has_error) {
/* XXX: if c->out.writing > 0, this releases the iolock and
* potentially allows other threads to interfere with their own fds.
*/
_xcb_out_flush_to(c, c->out.request);
if (c->out.out_fd.nfd == XCB_MAX_PASS_FD) {
/* We need some request to send FDs with */
_xcb_out_send_sync(c);
}
}
if (c->has_error)
break;
c->out.out_fd.fd[c->out.out_fd.nfd++] = fds[0];
fds++;
num_fds--;
}
#endif
close_fds(fds, num_fds);
}
uint64_t xcb_send_request_with_fds64(xcb_connection_t *c, int flags, struct iovec *vector,
const xcb_protocol_request_t *req, unsigned int num_fds, int *fds)
{
uint64_t request;
uint32_t prefix[2];
int veclen = req->count;
enum workarounds workaround = WORKAROUND_NONE;
if(c->has_error)
if(c->has_error) {
close_fds(fds, num_fds);
return 0;
}
assert(c != 0);
assert(vector != 0);
@ -127,7 +242,7 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
if(!(flags & XCB_REQUEST_RAW))
{
static const char pad[3];
int i;
unsigned int i;
uint16_t shortlen = 0;
size_t longlen = 0;
assert(vector[0].iov_len >= 4);
@ -137,7 +252,8 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
const xcb_query_extension_reply_t *extension = xcb_get_extension_data(c, req->ext);
if(!(extension && extension->present))
{
_xcb_conn_shutdown(c);
close_fds(fds, num_fds);
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_EXT_NOTSUPPORTED);
return 0;
}
((uint8_t *) vector[0].iov_base)[0] = extension->major_opcode;
@ -167,14 +283,23 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
}
else if(longlen > xcb_get_maximum_request_length(c))
{
_xcb_conn_shutdown(c);
close_fds(fds, num_fds);
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_REQ_LEN_EXCEED);
return 0; /* server can't take this; maybe need BIGREQUESTS? */
}
/* set the length field. */
((uint16_t *) vector[0].iov_base)[1] = shortlen;
if(!shortlen)
prefix[2] = ++longlen;
{
prefix[0] = ((uint32_t *) vector[0].iov_base)[0];
prefix[1] = ++longlen;
vector[0].iov_base = (uint32_t *) vector[0].iov_base + 1;
vector[0].iov_len -= sizeof(uint32_t);
--vector, ++veclen;
vector[0].iov_base = prefix;
vector[0].iov_len = sizeof(prefix);
}
}
flags &= ~XCB_REQUEST_RAW;
@ -187,62 +312,120 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
workaround = WORKAROUND_GLX_GET_FB_CONFIGS_BUG;
/* get a sequence number and arrange for delivery. */
_xcb_lock_io(c);
/* wait for other writing threads to get out of my way. */
while(c->out.writing)
_xcb_wait_io(c, &c->out.cond);
pthread_mutex_lock(&c->iolock);
request = ++c->out.request;
/* send GetInputFocus (sync) when 64k-2 requests have been sent without
/* send FDs before establishing a good request number, because this might
* call send_sync(), too
*/
send_fds(c, fds, num_fds);
prepare_socket_request(c);
/* send GetInputFocus (sync_req) when 64k-2 requests have been sent without
* a reply.
* Also send sync (could use NoOp) at 32-bit wrap to avoid having
* Also send sync_req (could use NoOp) at 32-bit wrap to avoid having
* applications see sequence 0 as that is used to indicate
* an error in sending the request */
while((req->isvoid &&
c->out.request == c->in.request_expected + (1 << 16) - 1) ||
request == 0)
* an error in sending the request
*/
while ((req->isvoid && c->out.request == c->in.request_expected + (1 << 16) - 2) ||
(unsigned int) (c->out.request + 1) == 0)
{
prefix[0] = sync.packet;
_xcb_in_expect_reply(c, request, WORKAROUND_NONE, XCB_REQUEST_DISCARD_REPLY);
c->in.request_expected = c->out.request;
request = ++c->out.request;
send_sync(c);
prepare_socket_request(c);
}
if(workaround != WORKAROUND_NONE || flags != 0)
_xcb_in_expect_reply(c, request, workaround, flags);
if(!req->isvoid)
c->in.request_expected = c->out.request;
if(prefix[0] || prefix[2])
{
--vector, ++veclen;
if(prefix[2])
{
prefix[1] = ((uint32_t *) vector[1].iov_base)[0];
vector[1].iov_base = (uint32_t *) vector[1].iov_base + 1;
vector[1].iov_len -= sizeof(uint32_t);
}
vector[0].iov_len = sizeof(uint32_t) * (prefix[0] ? 1 : 0 | prefix[2] ? 2 : 0);
vector[0].iov_base = prefix + !prefix[0];
}
if(!write_block(c, vector, veclen))
{
_xcb_conn_shutdown(c);
request = 0;
}
_xcb_unlock_io(c);
send_request(c, req->isvoid, workaround, flags, vector, veclen);
request = c->has_error ? 0 : c->out.request;
pthread_mutex_unlock(&c->iolock);
return request;
}
/* request number are actually uint64_t internally but keep API compat with unsigned int */
unsigned int xcb_send_request_with_fds(xcb_connection_t *c, int flags, struct iovec *vector,
const xcb_protocol_request_t *req, unsigned int num_fds, int *fds)
{
return xcb_send_request_with_fds64(c, flags, vector, req, num_fds, fds);
}
uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
{
return xcb_send_request_with_fds64(c, flags, vector, req, 0, NULL);
}
/* request number are actually uint64_t internally but keep API compat with unsigned int */
unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
{
return xcb_send_request64(c, flags, vector, req);
}
void
xcb_send_fd(xcb_connection_t *c, int fd)
{
int fds[1] = { fd };
if (c->has_error) {
close(fd);
return;
}
pthread_mutex_lock(&c->iolock);
send_fds(c, &fds[0], 1);
pthread_mutex_unlock(&c->iolock);
}
int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent)
{
int ret;
if(c->has_error)
return 0;
pthread_mutex_lock(&c->iolock);
get_socket_back(c);
/* _xcb_out_flush may drop the iolock allowing other threads to
* write requests, so keep flushing until we're done
*/
do
ret = _xcb_out_flush_to(c, c->out.request);
while (ret && c->out.request != c->out.request_written);
if(ret)
{
c->out.return_socket = return_socket;
c->out.socket_closure = closure;
if(flags) {
/* c->out.request + 1 will be the first request sent by the external
* socket owner. If the socket is returned before this request is sent
* it will be detected in _xcb_in_replies_done and this pending_reply
* will be discarded.
*/
_xcb_in_expect_reply(c, c->out.request + 1, WORKAROUND_EXTERNAL_SOCKET_OWNER, flags);
}
assert(c->out.request == c->out.request_written);
*sent = c->out.request;
}
pthread_mutex_unlock(&c->iolock);
return ret;
}
int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t requests)
{
int ret;
if(c->has_error)
return 0;
pthread_mutex_lock(&c->iolock);
c->out.request += requests;
ret = _xcb_out_send(c, vector, count);
pthread_mutex_unlock(&c->iolock);
return ret;
}
int xcb_flush(xcb_connection_t *c)
{
int ret;
if(c->has_error)
return 0;
_xcb_lock_io(c);
pthread_mutex_lock(&c->iolock);
ret = _xcb_out_flush_to(c, c->out.request);
_xcb_unlock_io(c);
pthread_mutex_unlock(&c->iolock);
return ret;
}
@ -250,6 +433,12 @@ int xcb_flush(xcb_connection_t *c)
int _xcb_out_init(_xcb_out *out)
{
if(pthread_cond_init(&out->socket_cond, 0))
return 0;
out->return_socket = 0;
out->socket_closure = 0;
out->socket_moving = 0;
if(pthread_cond_init(&out->cond, 0))
return 0;
out->writing = 0;
@ -258,6 +447,7 @@ int _xcb_out_init(_xcb_out *out)
out->request = 0;
out->request_written = 0;
out->request_expected_written = 0;
if(pthread_mutex_init(&out->reqlenlock, 0))
return 0;
@ -268,36 +458,44 @@ int _xcb_out_init(_xcb_out *out)
void _xcb_out_destroy(_xcb_out *out)
{
pthread_cond_destroy(&out->cond);
pthread_mutex_destroy(&out->reqlenlock);
pthread_cond_destroy(&out->cond);
pthread_cond_destroy(&out->socket_cond);
}
int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count)
int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count)
{
int ret = 1;
while(ret && *count)
ret = _xcb_conn_wait(c, &c->out.cond, vector, count);
while(ret && count)
ret = _xcb_conn_wait(c, &c->out.cond, &vector, &count);
c->out.request_written = c->out.request;
c->out.request_expected_written = c->in.request_expected;
pthread_cond_broadcast(&c->out.cond);
_xcb_in_wake_up_next_reader(c);
return ret;
}
int _xcb_out_flush_to(xcb_connection_t *c, unsigned int request)
void _xcb_out_send_sync(xcb_connection_t *c)
{
prepare_socket_request(c);
send_sync(c);
}
int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request)
{
assert(XCB_SEQUENCE_COMPARE(request, <=, c->out.request));
if(XCB_SEQUENCE_COMPARE(c->out.request_written, >=, request))
return 1;
if(c->out.queue_len)
{
struct iovec vec, *vec_ptr = &vec;
int count = 1;
struct iovec vec;
vec.iov_base = c->out.queue;
vec.iov_len = c->out.queue_len;
c->out.queue_len = 0;
return _xcb_out_send(c, &vec_ptr, &count);
return _xcb_out_send(c, &vec, 1);
}
while(c->out.writing)
_xcb_wait_io(c, &c->out.cond);
pthread_cond_wait(&c->out.cond, &c->iolock);
assert(XCB_SEQUENCE_COMPARE(c->out.request_written, >=, request));
return 1;
}

View File

@ -25,34 +25,136 @@
/* Utility functions implementable using only public APIs. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#ifdef DNETCONN
#include <netdnet/dnetdb.h>
#include <netdnet/dn.h>
#endif
#include <netdb.h>
#include <limits.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stddef.h>
#include <string.h>
#ifdef _WIN32
#include "xcb_windefs.h"
#else
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <fcntl.h>
#include <netdb.h>
#endif /* _WIN32 */
#include "xcb.h"
#include "xcbext.h"
#include "xcbint.h"
static const int error_connection = 1;
#if defined(HAVE_TSOL_LABEL_H) && defined(HAVE_IS_SYSTEM_LABELED)
# include <tsol/label.h>
# include <sys/stat.h>
#endif
#include <sys/stat.h>
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif
int xcb_popcount(uint32_t mask)
{
#if __has_builtin(__builtin_popcount)
return __builtin_popcount(mask);
#else
/*
* Count the number of bits set to 1 in a 32-bit word.
* Algorithm from MIT AI Lab Memo 239: "HAKMEM", ITEM 169.
* https://dspace.mit.edu/handle/1721.1/6086
*/
uint32_t y;
y = (mask >> 1) & 033333333333;
y = mask - y - ((y >> 1) & 033333333333);
return ((y + (y >> 3)) & 030707070707) % 077;
#endif
}
int xcb_sumof(uint8_t *list, int len)
{
int i, s = 0;
for(i=0; i<len; i++) {
s += *list;
list++;
}
return s;
}
/* Return true and parse if name matches <path to socket>[.<screen>]
* Upon success:
* host = <path to socket>
* protocol = "unix"
* display = 0
* screen = <screen>
*/
static int _xcb_parse_display_path_to_socket(const char *name, char **host, char **protocol,
int *displayp, int *screenp)
{
struct stat sbuf;
/* In addition to the AF_UNIX path, there may be a screen number.
* The trailing \0 is already accounted in the size of sun_path. */
char path[sizeof(((struct sockaddr_un*)0)->sun_path) + 1 + 10];
size_t len;
int _screen = 0, res;
len = strlen(name);
if (len >= sizeof(path))
return 0;
memcpy(path, name, len + 1);
res = stat(path, &sbuf);
if (0 != res) {
unsigned long lscreen;
char *dot, *endptr;
if (res != -1 || (errno != ENOENT && errno != ENOTDIR))
return 0;
dot = strrchr(path, '.');
if (!dot || dot[1] < '1' || dot[1] > '9')
return 0;
*dot = '\0';
errno = 0;
lscreen = strtoul(dot + 1, &endptr, 10);
if (lscreen > INT_MAX || !endptr || *endptr || errno)
return 0;
if (0 != stat(path, &sbuf))
return 0;
_screen = (int)lscreen;
}
if (host) {
*host = strdup(path);
if (!*host)
return 0;
}
if (protocol) {
*protocol = strdup("unix");
if (!*protocol) {
if (host)
free(*host);
return 0;
}
}
if (displayp)
*displayp = 0;
if (screenp)
*screenp = _screen;
return 1;
}
static int _xcb_parse_display(const char *name, char **host, char **protocol,
@ -60,11 +162,21 @@ static int _xcb_parse_display(const char *name, char **host, char **protocol,
{
int len, display, screen;
char *slash, *colon, *dot, *end;
if(!name || !*name)
name = getenv("DISPLAY");
if(!name)
return 0;
/* First check for <path to socket>[.<screen>] */
if (name[0] == '/')
return _xcb_parse_display_path_to_socket(name, host, protocol, displayp, screenp);
if (strncmp(name, "unix:", 5) == 0)
return _xcb_parse_display_path_to_socket(name + 5, host, protocol, displayp, screenp);
slash = strrchr(name, '/');
if (slash) {
len = slash - name;
if (protocol) {
@ -81,35 +193,43 @@ static int _xcb_parse_display(const char *name, char **host, char **protocol,
colon = strrchr(name, ':');
if(!colon)
return 0;
goto error_out;
len = colon - name;
++colon;
display = strtoul(colon, &dot, 10);
if(dot == colon)
return 0;
goto error_out;
if(*dot == '\0')
screen = 0;
else
{
if(*dot != '.')
return 0;
goto error_out;
++dot;
screen = strtoul(dot, &end, 10);
if(end == dot || *end != '\0')
return 0;
goto error_out;
}
/* At this point, the display string is fully parsed and valid, but
* the caller's memory is untouched. */
*host = malloc(len + 1);
if(!*host)
return 0;
goto error_out;
memcpy(*host, name, len);
(*host)[len] = '\0';
*displayp = display;
if(screenp)
*screenp = screen;
return 1;
error_out:
if (protocol) {
free(*protocol);
*protocol = NULL;
}
return 0;
}
int xcb_parse_display(const char *name, char **host, int *displayp,
@ -118,104 +238,164 @@ int xcb_parse_display(const char *name, char **host, int *displayp,
return _xcb_parse_display(name, host, NULL, displayp, screenp);
}
static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port);
static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short port);
#ifndef _WIN32
static int _xcb_open_unix(char *protocol, const char *file);
#ifdef DNETCONN
static int _xcb_open_decnet(const char *host, char *protocol, const unsigned short port);
#endif /* !WIN32 */
#ifdef HAVE_ABSTRACT_SOCKETS
static int _xcb_open_abstract(char *protocol, const char *file, size_t filelen);
#endif
static int _xcb_open(char *host, char *protocol, const int display)
static int _xcb_open(const char *host, char *protocol, const int display)
{
int fd;
static const char base[] = "/tmp/.X11-unix/X";
char file[sizeof(base) + 20];
if(*host)
{
#ifdef DNETCONN
/* DECnet displays have two colons, so _xcb_parse_display will have
left one at the end. However, an IPv6 address can end with *two*
colons, so only treat this as a DECnet display if host ends with
exactly one colon. */
char *colon = strchr(host, ':');
if(colon && *(colon+1) == '\0')
{
*colon = '\0';
return _xcb_open_decnet(host, protocol, display);
}
else
#ifdef __hpux
static const char unix_base[] = "/usr/spool/sockets/X11/";
#else
static const char unix_base[] = "/tmp/.X11-unix/X";
#endif
if (protocol
|| strcmp("unix",host)) { /* follow the old unix: rule */
const char *base = unix_base;
size_t filelen;
char *file = NULL;
int actual_filelen;
/* display specifies TCP */
unsigned short port = X_TCP_PORT + display;
return _xcb_open_tcp(host, protocol, port);
}
#ifndef _WIN32
if (protocol && strcmp("unix", protocol) == 0 && host && host[0] == '/') {
/* Full path to socket provided, ignore everything else */
filelen = strlen(host) + 1;
if (filelen > INT_MAX)
return -1;
file = malloc(filelen);
if (file == NULL)
return -1;
memcpy(file, host, filelen);
actual_filelen = (int)(filelen - 1);
} else {
#endif
/* If protocol or host is "unix", fall through to Unix socket code below */
if ((!protocol || (strcmp("unix",protocol) != 0)) &&
(*host != '\0') && (strcmp("unix",host) != 0))
{
/* display specifies TCP */
unsigned short port = X_TCP_PORT + display;
return _xcb_open_tcp(host, protocol, port);
}
#ifndef _WIN32
#if defined(HAVE_TSOL_LABEL_H) && defined(HAVE_IS_SYSTEM_LABELED)
/* Check special path for Unix sockets under Solaris Trusted Extensions */
if (is_system_labeled())
{
const char *tsol_base = "/var/tsol/doors/.X11-unix/X";
char tsol_socket[PATH_MAX];
struct stat sbuf;
snprintf(tsol_socket, sizeof(tsol_socket), "%s%d", tsol_base, display);
if (stat(tsol_socket, &sbuf) == 0)
base = tsol_base;
else if (errno != ENOENT)
return 0;
}
#endif
filelen = strlen(base) + 1 + sizeof(display) * 3 + 1;
file = malloc(filelen);
if(file == NULL)
return -1;
/* display specifies Unix socket */
actual_filelen = snprintf(file, filelen, "%s%d", base, display);
if(actual_filelen < 0)
{
free(file);
return -1;
}
/* snprintf may truncate the file */
filelen = MIN(actual_filelen, filelen - 1);
#ifdef HAVE_ABSTRACT_SOCKETS
fd = _xcb_open_abstract(protocol, file, filelen);
if (fd >= 0 || (errno != ENOENT && errno != ECONNREFUSED))
{
free(file);
return fd;
}
#endif
}
fd = _xcb_open_unix(protocol, file);
free(file);
if (fd < 0 && !protocol && *host == '\0') {
unsigned short port = X_TCP_PORT + display;
fd = _xcb_open_tcp(host, protocol, port);
}
/* display specifies Unix socket */
snprintf(file, sizeof(file), "%s%d", base, display);
return _xcb_open_unix(protocol, file);
return fd;
#endif /* !_WIN32 */
return -1; /* if control reaches here then something has gone wrong */
}
#ifdef DNETCONN
static int _xcb_open_decnet(const char *host, const char *protocol, const unsigned short port)
static int _xcb_socket(int family, int type, int proto)
{
int fd;
struct sockaddr_dn addr;
struct accessdata_dn accessdata;
struct nodeent *nodeaddr = getnodebyname(host);
if(!nodeaddr)
return -1;
if (protocol && strcmp("dnet",protocol))
return -1;
addr.sdn_family = AF_DECnet;
addr.sdn_add.a_len = nodeaddr->n_length;
memcpy(addr.sdn_add.a_addr, nodeaddr->n_addr, addr.sdn_add.a_len);
sprintf((char *)addr.sdn_objname, "X$X%d", port);
addr.sdn_objnamel = strlen((char *)addr.sdn_objname);
addr.sdn_objnum = 0;
fd = socket(PF_DECnet, SOCK_STREAM, 0);
if(fd == -1)
return -1;
memset(&accessdata, 0, sizeof(accessdata));
sprintf((char*)accessdata.acc_acc, "%d", getuid());
accessdata.acc_accl = strlen((char *)accessdata.acc_acc);
setsockopt(fd, DNPROTO_NSP, SO_CONACCESS, &accessdata, sizeof(accessdata));
if(connect(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1)
return -1;
#ifdef SOCK_CLOEXEC
fd = socket(family, type | SOCK_CLOEXEC, proto);
if (fd == -1 && errno == EINVAL)
#endif
{
fd = socket(family, type, proto);
#ifndef _WIN32
if (fd >= 0)
fcntl(fd, F_SETFD, FD_CLOEXEC);
#endif
}
return fd;
}
#endif
static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port)
static int _xcb_do_connect(int fd, const struct sockaddr* addr, int addrlen) {
int on = 1;
if(fd < 0)
return -1;
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on));
return connect(fd, addr, addrlen);
}
static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short port)
{
int fd = -1;
struct addrinfo hints = { 0
#ifdef AI_ADDRCONFIG
| AI_ADDRCONFIG
#endif
#ifdef AI_NUMERICSERV
| AI_NUMERICSERV
#endif
, AF_UNSPEC, SOCK_STREAM };
#if HAVE_GETADDRINFO
struct addrinfo hints;
char service[6]; /* "65535" with the trailing '\0' */
struct addrinfo *results, *addr;
char *bracket;
#endif
if (protocol && strcmp("tcp",protocol))
if (protocol && strcmp("tcp",protocol) && strcmp("inet",protocol)
#ifdef AF_INET6
&& strcmp("inet6",protocol)
#endif
)
return -1;
if (*host == '\0')
host = "localhost";
#if HAVE_GETADDRINFO
memset(&hints, 0, sizeof(hints));
#ifdef AI_NUMERICSERV
hints.ai_flags |= AI_NUMERICSERV;
#endif
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
#ifdef AF_INET6
/* Allow IPv6 addresses enclosed in brackets. */
if(host[0] == '[' && (bracket = strrchr(host, ']')) && bracket[1] == '\0')
{
@ -224,6 +404,7 @@ static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port)
hints.ai_flags |= AI_NUMERICHOST;
hints.ai_family = AF_INET6;
}
#endif
snprintf(service, sizeof(service), "%hu", port);
if(getaddrinfo(host, service, &hints, &results))
@ -232,71 +413,174 @@ static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port)
for(addr = results; addr; addr = addr->ai_next)
{
fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if(fd >= 0 && connect(fd, addr->ai_addr, addr->ai_addrlen) >= 0)
fd = _xcb_socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if (_xcb_do_connect(fd, addr->ai_addr, addr->ai_addrlen) >= 0)
break;
#ifdef _WIN32
closesocket(fd);
#else
close(fd);
#endif
fd = -1;
}
freeaddrinfo(results);
return fd;
#else
{
struct hostent* _h;
struct sockaddr_in _s;
struct in_addr ** _c;
if((_h = gethostbyname(host)) == NULL)
return -1;
_c = (struct in_addr**)_h->h_addr_list;
fd = -1;
while(*_c) {
_s.sin_family = AF_INET;
_s.sin_port = htons(port);
_s.sin_addr = *(*_c);
fd = _xcb_socket(_s.sin_family, SOCK_STREAM, 0);
if(_xcb_do_connect(fd, (struct sockaddr*)&_s, sizeof(_s)) >= 0)
break;
#ifdef _WIN32
closesocket(fd);
#else
close(fd);
#endif
fd = -1;
++_c;
}
return fd;
}
#endif
}
#ifndef _WIN32
static int _xcb_open_unix(char *protocol, const char *file)
{
int fd;
struct sockaddr_un addr = { AF_UNIX };
struct sockaddr_un addr;
socklen_t len = sizeof(int);
int val;
if (protocol && strcmp("unix",protocol))
return -1;
strcpy(addr.sun_path, file);
fd = socket(AF_UNIX, SOCK_STREAM, 0);
addr.sun_family = AF_UNIX;
#ifdef HAVE_SOCKADDR_SUN_LEN
addr.sun_len = SUN_LEN(&addr);
#endif
fd = _xcb_socket(AF_UNIX, SOCK_STREAM, 0);
if(fd == -1)
return -1;
if(connect(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1)
if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) == 0 && val < 64 * 1024)
{
val = 64 * 1024;
setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, sizeof(int));
}
if(connect(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
close(fd);
return -1;
}
return fd;
}
#endif /* !_WIN32 */
#ifdef HAVE_ABSTRACT_SOCKETS
static int _xcb_open_abstract(char *protocol, const char *file, size_t filelen)
{
int fd;
struct sockaddr_un addr = {0};
socklen_t namelen;
if (protocol && strcmp("unix",protocol))
return -1;
strcpy(addr.sun_path + 1, file);
addr.sun_family = AF_UNIX;
namelen = offsetof(struct sockaddr_un, sun_path) + 1 + filelen;
#ifdef HAVE_SOCKADDR_SUN_LEN
addr.sun_len = 1 + filelen;
#endif
fd = _xcb_socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1)
return -1;
if (connect(fd, (struct sockaddr *) &addr, namelen) == -1) {
close(fd);
return -1;
}
return fd;
}
#endif
xcb_connection_t *xcb_connect(const char *displayname, int *screenp)
{
int fd, display = 0;
char *host;
char *protocol;
xcb_connection_t *c;
xcb_auth_info_t auth;
if(!_xcb_parse_display(displayname, &host, &protocol, &display, screenp))
return (xcb_connection_t *) &error_connection;
fd = _xcb_open(host, protocol, display);
free(host);
if(fd == -1)
return (xcb_connection_t *) &error_connection;
if(_xcb_get_auth_info(fd, &auth, display))
{
c = xcb_connect_to_fd(fd, &auth);
free(auth.name);
free(auth.data);
}
else
c = xcb_connect_to_fd(fd, 0);
return c;
return xcb_connect_to_display_with_auth_info(displayname, NULL, screenp);
}
xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname, xcb_auth_info_t *auth, int *screenp)
{
int fd, display = 0;
char *host;
char *protocol;
char *host = NULL;
char *protocol = NULL;
xcb_auth_info_t ourauth;
xcb_connection_t *c;
int parsed = _xcb_parse_display(displayname, &host, &protocol, &display, screenp);
if(!parsed) {
c = _xcb_conn_ret_error(XCB_CONN_CLOSED_PARSE_ERR);
goto out;
}
#ifdef _WIN32
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
c = _xcb_conn_ret_error(XCB_CONN_ERROR);
goto out;
}
#endif
if(!_xcb_parse_display(displayname, &host, &protocol, &display, screenp))
return (xcb_connection_t *) &error_connection;
fd = _xcb_open(host, protocol, display);
free(host);
if(fd == -1)
return (xcb_connection_t *) &error_connection;
return xcb_connect_to_fd(fd, auth);
if(fd == -1) {
c = _xcb_conn_ret_error(XCB_CONN_ERROR);
#ifdef _WIN32
WSACleanup();
#endif
goto out;
}
if(auth) {
c = xcb_connect_to_fd(fd, auth);
}
else if(_xcb_get_auth_info(fd, &ourauth, display))
{
c = xcb_connect_to_fd(fd, &ourauth);
free(ourauth.name);
free(ourauth.data);
}
else
c = xcb_connect_to_fd(fd, 0);
if(c->has_error)
goto out;
/* Make sure requested screen number is in bounds for this server */
if((screenp != NULL) && (*screenp >= (int) c->setup->roots_len)) {
xcb_disconnect(c);
c = _xcb_conn_ret_error(XCB_CONN_CLOSED_INVALID_SCREEN);
goto out;
}
out:
free(host);
free(protocol);
return c;
}

View File

@ -1,6 +1,4 @@
/*
* Copyright (C) 2005 Bart Massey and Jamey Sharp.
* All Rights Reserved.
/* Copyright (C) 2009 Jatin Golani.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -25,20 +23,23 @@
* authorization from the authors.
*/
/* This include file declares functions used by Xlib/XCB, but nothing else
* should ever use these functions or link to libxcb-xlib. */
#ifndef __XCBXLIB_H
#define __XCBXLIB_H
#include <pthread.h>
#include "xcb.h"
/* The caller of this function must hold the xlib lock, using the lock
* functions below. */
unsigned int xcb_get_request_sent(xcb_connection_t *c);
void xcb_xlib_lock(xcb_connection_t *c);
void xcb_xlib_unlock(xcb_connection_t *c);
#ifndef _XCB_WINDEFS_H
#define _XCB_WINDEFS_H
#ifndef WINVER
#define WINVER 0x0501 /* required for getaddrinfo/freeaddrinfo defined only for WinXP and above */
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windef.h>
struct iovec {
void *iov_base; /* Pointer to data. */
int iov_len; /* Length of data. */
};
typedef unsigned int in_addr_t;
#endif /* xcb_windefs.h */

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
/* Copyright (C) 2001-2008 Bart Massey and Jamey Sharp.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -25,6 +25,11 @@
/* XID allocators. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <stdlib.h>
#include "xcb.h"
#include "xcbext.h"
@ -39,21 +44,40 @@ uint32_t xcb_generate_id(xcb_connection_t *c)
if(c->has_error)
return -1;
pthread_mutex_lock(&c->xid.lock);
if(c->xid.last == c->xid.max)
if(c->xid.last >= c->xid.max - c->xid.inc + 1)
{
xcb_xc_misc_get_xid_range_reply_t *range;
range = xcb_xc_misc_get_xid_range_reply(c, xcb_xc_misc_get_xid_range(c), 0);
if(!range)
{
pthread_mutex_unlock(&c->xid.lock);
return -1;
assert(c->xid.last == c->xid.max);
if (c->xid.last == 0) {
/* finish setting up initial range */
c->xid.max = c->setup->resource_id_mask;
} else {
/* check for extension */
const xcb_query_extension_reply_t *xc_misc_reply =
xcb_get_extension_data(c, &xcb_xc_misc_id);
if (!xc_misc_reply || !xc_misc_reply->present) {
pthread_mutex_unlock(&c->xid.lock);
return -1;
}
/* get new range */
range = xcb_xc_misc_get_xid_range_reply(c,
xcb_xc_misc_get_xid_range(c), 0);
/* XXX The latter disjunct is what the server returns
when it is out of XIDs. Sweet. */
if(!range || (range->start_id == 0 && range->count == 1))
{
pthread_mutex_unlock(&c->xid.lock);
return -1;
}
assert(range->count > 0 && range->start_id > 0);
c->xid.last = range->start_id;
c->xid.max = range->start_id + (range->count - 1) * c->xid.inc;
free(range);
}
c->xid.last = range->start_id;
c->xid.max = range->start_id + (range->count - 1) * c->xid.inc;
free(range);
} else {
c->xid.last += c->xid.inc;
}
ret = c->xid.last | c->xid.base;
c->xid.last += c->xid.inc;
pthread_mutex_unlock(&c->xid.lock);
return ret;
}
@ -65,8 +89,8 @@ int _xcb_xid_init(xcb_connection_t *c)
if(pthread_mutex_init(&c->xid.lock, 0))
return 0;
c->xid.last = 0;
c->xid.max = 0;
c->xid.base = c->setup->resource_id_base;
c->xid.max = c->setup->resource_id_mask;
c->xid.inc = c->setup->resource_id_mask & -(c->setup->resource_id_mask);
return 1;
}

View File

@ -1,87 +0,0 @@
/* Copyright (C) 2005 Bart Massey and Jamey Sharp.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the names of the authors or their
* institutions shall not be used in advertising or otherwise to promote the
* sale, use or other dealings in this Software without prior written
* authorization from the authors.
*/
#include "xcbxlib.h"
#include "xcbint.h"
#include <assert.h>
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#endif
static void xcb_xlib_printbt(void)
{
#ifdef HAVE_BACKTRACE
void *array[20];
int size;
char **strings;
int i;
size = backtrace(array, 20);
strings = backtrace_symbols(array, size);
fprintf(stderr, "Locking assertion failure. Backtrace:\n");
for (i = 0; i < size; ++i)
fprintf(stderr, "#%i %s\n", i, strings[i]);
free(strings);
#endif
}
#ifndef NDEBUG
#define xcb_assert(c,x) do { if (!(x)) { xcb_xlib_printbt(); if (!(c)->xlib.sloppy_lock) assert(x); } } while(0)
#else
#define xcb_assert(c,x)
#endif
unsigned int xcb_get_request_sent(xcb_connection_t *c)
{
if(c->has_error)
return 0;
return c->out.request;
}
void xcb_xlib_lock(xcb_connection_t *c)
{
_xcb_lock_io(c);
xcb_assert(c, !c->xlib.lock);
c->xlib.lock = 1;
c->xlib.thread = pthread_self();
_xcb_unlock_io(c);
}
void xcb_xlib_unlock(xcb_connection_t *c)
{
_xcb_lock_io(c);
xcb_assert(c, c->xlib.lock);
xcb_assert(c, pthread_equal(c->xlib.thread, pthread_self()));
c->xlib.lock = 0;
pthread_cond_broadcast(&c->xlib.cond);
_xcb_unlock_io(c);
}

View File

@ -54,22 +54,270 @@ typedef struct {
enum xcb_send_request_flags_t {
XCB_REQUEST_CHECKED = 1 << 0,
XCB_REQUEST_RAW = 1 << 1,
XCB_REQUEST_DISCARD_REPLY = 1 << 2
XCB_REQUEST_DISCARD_REPLY = 1 << 2,
XCB_REQUEST_REPLY_FDS = 1 << 3
};
/**
* @brief Send a request to the server.
* @param c The connection to the X server.
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
* @param vector Data to send; must have two iovecs before start for internal use.
* @param request Information about the request to be sent.
* @return The request's sequence number on success, 0 otherwise.
*
* This function sends a new request to the X server. The data of the request is
* given as an array of @c iovecs in the @p vector argument. The length of that
* array and the necessary management information are given in the @p request
* argument.
*
* When this function returns, the request might or might not be sent already.
* Use xcb_flush() to make sure that it really was sent.
*
* Please note that this function is not the preferred way for sending requests.
* It's better to use the generated wrapper functions.
*
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
* so they must be valid!
*/
unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
/**
* @brief Send a request to the server.
* @param c The connection to the X server.
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
* @param vector Data to send; must have two iovecs before start for internal use.
* @param request Information about the request to be sent.
* @param num_fds Number of additional file descriptors to send to the server
* @param fds Additional file descriptors that should be send to the server.
* @return The request's sequence number on success, 0 otherwise.
*
* This function sends a new request to the X server. The data of the request is
* given as an array of @c iovecs in the @p vector argument. The length of that
* array and the necessary management information are given in the @p request
* argument.
*
* If @p num_fds is non-zero, @p fds points to an array of file descriptors that
* will be sent to the X server along with this request. After this function
* returns, all file descriptors sent are owned by xcb and will be closed
* eventually.
*
* When this function returns, the request might or might not be sent already.
* Use xcb_flush() to make sure that it really was sent.
*
* Please note that this function is not the preferred way for sending requests.
*
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
* so they must be valid!
*/
unsigned int xcb_send_request_with_fds(xcb_connection_t *c, int flags, struct iovec *vector,
const xcb_protocol_request_t *request, unsigned int num_fds, int *fds);
/**
* @brief Send a request to the server, with 64-bit sequence number returned.
* @param c The connection to the X server.
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
* @param vector Data to send; must have two iovecs before start for internal use.
* @param request Information about the request to be sent.
* @return The request's sequence number on success, 0 otherwise.
*
* This function sends a new request to the X server. The data of the request is
* given as an array of @c iovecs in the @p vector argument. The length of that
* array and the necessary management information are given in the @p request
* argument.
*
* When this function returns, the request might or might not be sent already.
* Use xcb_flush() to make sure that it really was sent.
*
* Please note that this function is not the preferred way for sending requests.
* It's better to use the generated wrapper functions.
*
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
* so they must be valid!
*/
uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
/**
* @brief Send a request to the server, with 64-bit sequence number returned.
* @param c The connection to the X server.
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
* @param vector Data to send; must have two iovecs before start for internal use.
* @param request Information about the request to be sent.
* @param num_fds Number of additional file descriptors to send to the server
* @param fds Additional file descriptors that should be send to the server.
* @return The request's sequence number on success, 0 otherwise.
*
* This function sends a new request to the X server. The data of the request is
* given as an array of @c iovecs in the @p vector argument. The length of that
* array and the necessary management information are given in the @p request
* argument.
*
* If @p num_fds is non-zero, @p fds points to an array of file descriptors that
* will be sent to the X server along with this request. After this function
* returns, all file descriptors sent are owned by xcb and will be closed
* eventually.
*
* When this function returns, the request might or might not be sent already.
* Use xcb_flush() to make sure that it really was sent.
*
* Please note that this function is not the preferred way for sending requests.
* It's better to use the generated wrapper functions.
*
* Please note that xcb might use index -1 and -2 of the @p vector array internally,
* so they must be valid!
*/
uint64_t xcb_send_request_with_fds64(xcb_connection_t *c, int flags, struct iovec *vector,
const xcb_protocol_request_t *request, unsigned int num_fds, int *fds);
/**
* @brief Send a file descriptor to the server in the next call to xcb_send_request.
* @param c The connection to the X server.
* @param fd The file descriptor to send.
*
* After this function returns, the file descriptor given is owned by xcb and
* will be closed eventually.
*
* @deprecated This function cannot be used in a thread-safe way. Two threads
* that run xcb_send_fd(); xcb_send_request(); could mix up their file
* descriptors. Instead, xcb_send_request_with_fds() should be used.
*/
void xcb_send_fd(xcb_connection_t *c, int fd);
/**
* @brief Take over the write side of the socket
* @param c The connection to the X server.
* @param return_socket Callback function that will be called when xcb wants
* to use the socket again.
* @param closure Argument to the callback function.
* @param flags A combination of flags from the xcb_send_request_flags_t enumeration.
* @param sent Location to the sequence number of the last sequence request.
* Must not be NULL.
* @return 1 on success, else 0.
*
* xcb_take_socket allows external code to ask XCB for permission to
* take over the write side of the socket and send raw data with
* xcb_writev. xcb_take_socket provides the sequence number of the last
* request XCB sent. The caller of xcb_take_socket must supply a
* callback which XCB can call when it wants the write side of the
* socket back to make a request. This callback synchronizes with the
* external socket owner and flushes any output queues if appropriate.
* If you are sending requests which won't cause a reply, please note the
* comment for xcb_writev which explains some sequence number wrap issues.
*
* All replies that are generated while the socket is owned externally have
* @p flags applied to them. For example, use XCB_REQUEST_CHECK if you don't
* want errors to go to xcb's normal error handling, but instead having to be
* picked up via xcb_wait_for_reply(), xcb_poll_for_reply() or
* xcb_request_check().
*/
int xcb_take_socket(xcb_connection_t *c, void (*return_socket)(void *closure), void *closure, int flags, uint64_t *sent);
/**
* @brief Send raw data to the X server.
* @param c The connection to the X server.
* @param vector Array of data to be sent.
* @param count Number of entries in @p vector.
* @param requests Number of requests that are being sent.
* @return 1 on success, else 0.
*
* You must own the write-side of the socket (you've called
* xcb_take_socket, and haven't returned from return_socket yet) to call
* xcb_writev. Also, the iovec must have at least 1 byte of data in it.
* You have to make sure that xcb can detect sequence number wraps correctly.
* This means that the first request you send after xcb_take_socket must cause a
* reply (e.g. just insert a GetInputFocus request). After every (1 << 16) - 1
* requests without a reply, you have to insert a request which will cause a
* reply. You can again use GetInputFocus for this. You do not have to wait for
* any of the GetInputFocus replies, but can instead handle them via
* xcb_discard_reply().
*/
int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t requests);
/* xcb_in.c */
/**
* @brief Wait for the reply of a given request.
* @param c The connection to the X server.
* @param request Sequence number of the request as returned by xcb_send_request().
* @param e Location to store errors in, or NULL. Ignored for unchecked requests.
*
* Returns the reply to the given request or returns null in the event of
* errors. Blocks until the reply or error for the request arrives, or an I/O
* error occurs.
*/
void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
/**
* @brief Wait for the reply of a given request, with 64-bit sequence number
* @param c The connection to the X server.
* @param request 64-bit sequence number of the request as returned by xcb_send_request64().
* @param e Location to store errors in, or NULL. Ignored for unchecked requests.
*
* Returns the reply to the given request or returns null in the event of
* errors. Blocks until the reply or error for the request arrives, or an I/O
* error occurs.
*
* Unlike its xcb_wait_for_reply() counterpart, the given sequence number is not
* automatically "widened" to 64-bit.
*/
void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e);
/**
* @brief Poll for the reply of a given request.
* @param c The connection to the X server.
* @param request Sequence number of the request as returned by xcb_send_request().
* @param reply Location to store the reply in, must not be NULL.
* @param error Location to store errors in, or NULL. Ignored for unchecked requests.
* @return 1 when the reply to the request was returned, else 0.
*
* Checks if the reply to the given request already received. Does not block.
*/
int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
/**
* @brief Poll for the reply of a given request, with 64-bit sequence number.
* @param c The connection to the X server.
* @param request 64-bit sequence number of the request as returned by xcb_send_request().
* @param reply Location to store the reply in, must not be NULL.
* @param error Location to store errors in, or NULL. Ignored for unchecked requests.
* @return 1 when the reply to the request was returned, else 0.
*
* Checks if the reply to the given request already received. Does not block.
*
* Unlike its xcb_poll_for_reply() counterpart, the given sequence number is not
* automatically "widened" to 64-bit.
*/
int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error);
/**
* @brief Don't use this, only needed by the generated code.
* @param c The connection to the X server.
* @param reply A reply that was received from the server
* @param replylen The size of the reply.
* @return Pointer to the location where received file descriptors are stored.
*/
XCB_CONST_FUNCTION
int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t replylen);
/* xcb_util.c */
/**
* @param mask The mask to check
* @return The number of set bits in the mask
*/
XCB_CONST_FUNCTION
int xcb_popcount(uint32_t mask);
/**
* @param list The base of an array
* @param len The length of the array
* @return The sum of all entries in the array.
*/
XCB_PURE_FUNCTION
int xcb_sumof(uint8_t *list, int len);
#ifdef __cplusplus
}
#endif

View File

@ -38,9 +38,20 @@
#pragma GCC visibility push(hidden)
#endif
#ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with older compilers. */
#endif
#if __has_attribute(fallthrough)
# define XCB_ALLOW_FALLTHRU __attribute__ ((fallthrough));
#else
# define XCB_ALLOW_FALLTHRU /* FALLTHRU */
#endif
enum workarounds {
WORKAROUND_NONE,
WORKAROUND_GLX_GET_FB_CONFIGS_BUG
WORKAROUND_GLX_GET_FB_CONFIGS_BUG,
WORKAROUND_EXTERNAL_SOCKET_OWNER
};
enum lazy_reply_tag
@ -52,7 +63,17 @@ enum lazy_reply_tag
#define XCB_PAD(i) (-(i) & 3)
#define XCB_SEQUENCE_COMPARE(a,op,b) ((int) ((a) - (b)) op 0)
#define XCB_SEQUENCE_COMPARE(a,op,b) ((int64_t) ((a) - (b)) op 0)
#ifndef offsetof
#define offsetof(type,member) ((size_t) &((type *)0)->member)
#endif
#ifndef MIN
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#endif
#define container_of(pointer,type,member) ((type *)(((char *)(pointer)) - offsetof(type, member)))
/* xcb_list.c */
@ -62,21 +83,38 @@ typedef struct _xcb_map _xcb_map;
_xcb_map *_xcb_map_new(void);
void _xcb_map_delete(_xcb_map *q, xcb_list_free_func_t do_free);
int _xcb_map_put(_xcb_map *q, unsigned int key, void *data);
void *_xcb_map_remove(_xcb_map *q, unsigned int key);
int _xcb_map_put(_xcb_map *q, uint64_t key, void *data);
void *_xcb_map_remove(_xcb_map *q, uint64_t key);
/* xcb_out.c */
#if HAVE_SENDMSG
#define XCB_MAX_PASS_FD 16
typedef struct _xcb_fd {
int fd[XCB_MAX_PASS_FD];
int nfd;
int ifd;
} _xcb_fd;
#endif
typedef struct _xcb_out {
pthread_cond_t cond;
int writing;
char queue[4096];
pthread_cond_t socket_cond;
void (*return_socket)(void *closure);
void *socket_closure;
int socket_moving;
char queue[XCB_QUEUE_BUFFER_SIZE];
int queue_len;
unsigned int request;
unsigned int request_written;
uint64_t request;
uint64_t request_written;
uint64_t request_expected_written;
uint64_t total_written;
pthread_mutex_t reqlenlock;
enum lazy_reply_tag maximum_request_length_tag;
@ -84,13 +122,17 @@ typedef struct _xcb_out {
xcb_big_requests_enable_cookie_t cookie;
uint32_t value;
} maximum_request_length;
#if HAVE_SENDMSG
_xcb_fd out_fd;
#endif
} _xcb_out;
int _xcb_out_init(_xcb_out *out);
void _xcb_out_destroy(_xcb_out *out);
int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count);
int _xcb_out_flush_to(xcb_connection_t *c, unsigned int request);
int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count);
void _xcb_out_send_sync(xcb_connection_t *c);
int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request);
/* xcb_in.c */
@ -102,9 +144,10 @@ typedef struct _xcb_in {
char queue[4096];
int queue_len;
unsigned int request_expected;
unsigned int request_read;
unsigned int request_completed;
uint64_t request_expected;
uint64_t request_read;
uint64_t request_completed;
uint64_t total_read;
struct reply_list *current_reply;
struct reply_list **current_reply_tail;
@ -112,30 +155,28 @@ typedef struct _xcb_in {
struct event_list *events;
struct event_list **events_tail;
struct reader_list *readers;
struct special_list *special_waiters;
struct pending_reply *pending_replies;
struct pending_reply **pending_replies_tail;
#if HAVE_SENDMSG
_xcb_fd in_fd;
#endif
struct xcb_special_event *special_events;
} _xcb_in;
int _xcb_in_init(_xcb_in *in);
void _xcb_in_destroy(_xcb_in *in);
int _xcb_in_expect_reply(xcb_connection_t *c, unsigned int request, enum workarounds workaround, int flags);
void _xcb_in_wake_up_next_reader(xcb_connection_t *c);
int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds workaround, int flags);
void _xcb_in_replies_done(xcb_connection_t *c);
int _xcb_in_read(xcb_connection_t *c);
int _xcb_in_read_block(xcb_connection_t *c, void *buf, int nread);
/* xcb_xlib.c */
typedef struct _xcb_xlib {
int lock;
int sloppy_lock;
pthread_t thread;
pthread_cond_t cond;
} _xcb_xlib;
/* xcb_xid.c */
typedef struct _xcb_xid {
@ -165,6 +206,7 @@ void _xcb_ext_destroy(xcb_connection_t *c);
/* xcb_conn.c */
struct xcb_connection_t {
/* This must be the first field; see _xcb_conn_ret_error(). */
int has_error;
/* constant data */
@ -173,7 +215,6 @@ struct xcb_connection_t {
/* I/O data */
pthread_mutex_t iolock;
_xcb_xlib xlib;
_xcb_in in;
_xcb_out out;
@ -182,8 +223,11 @@ struct xcb_connection_t {
_xcb_xid xid;
};
void _xcb_conn_shutdown(xcb_connection_t *c);
void _xcb_wait_io(xcb_connection_t *c, pthread_cond_t *cond);
void _xcb_conn_shutdown(xcb_connection_t *c, int err);
XCB_CONST_FUNCTION
xcb_connection_t *_xcb_conn_ret_error(int err);
int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count);
@ -195,10 +239,4 @@ int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display);
#pragma GCC visibility pop
#endif
/* xcb_conn.c symbols visible to xcb-xlib */
void _xcb_lock_io(xcb_connection_t *c);
void _xcb_unlock_io(xcb_connection_t *c);
#endif

3
tests/.gitignore vendored
View File

@ -1,3 +1,6 @@
CheckLog.html
CheckLog_xcb.xml
check_all
check_all.log
check_all.trs
test-suite.log

View File

@ -12,12 +12,9 @@ TESTS = check_all
check_PROGRAMS = check_all
check_all_SOURCES = check_all.c check_suites.h check_public.c
all-local::
$(RM) CheckLog*.xml
check-local:
check-local: check-TESTS
$(RM) CheckLog.html
if test x$(HTML_CHECK_RESULT) = xtrue; then \
if test x$(HTML_CHECK_RESULT) = xyes; then \
$(XSLTPROC) $(srcdir)/CheckLog.xsl CheckLog*.xml > CheckLog.html; \
else \
touch CheckLog.html; \

View File

@ -1,10 +1,19 @@
#include <stdlib.h>
#include "check_suites.h"
#if CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13
void suite_add_test(Suite *s, TFun tf, const char *name)
#else
void suite_add_test(Suite *s, const TTest *tt, const char *name)
#endif
{
TCase *tc = tcase_create(name);
#if CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13
tcase_add_test(tc, tf);
#else
tcase_add_test(tc, tt);
#endif
suite_add_tcase(s, tc);
}

View File

@ -1,6 +1,10 @@
#include <check.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef __unix__
#include <unistd.h>
#endif
#include "check_suites.h"
#include "xcb.h"
#include "xcbext.h"
@ -12,6 +16,10 @@ typedef enum test_type_t {
} test_type_t;
static const char *const test_string[] = { "", "via $DISPLAY " };
/* putenv(3) takes a pointer to a writable string that it adds directly
to the environment, so it must be in persistent memory, not on the stack */
static char display_env[] = "DISPLAY=";
static void parse_display_pass(const char *name, const char *host, const int display, const int screen)
{
int success;
@ -25,7 +33,7 @@ static void parse_display_pass(const char *name, const char *host, const int dis
if(test_type == TEST_ARGUMENT)
{
argument = name;
putenv("DISPLAY=");
putenv(display_env);
}
else if(test_type == TEST_ENVIRONMENT)
{
@ -37,20 +45,20 @@ static void parse_display_pass(const char *name, const char *host, const int dis
got_display = got_screen = -42;
mark_point();
success = xcb_parse_display(argument, &got_host, &got_display, &got_screen);
fail_unless(success, "unexpected parse failure %sfor '%s'", test_string[test_type], name);
fail_unless(strcmp(host, got_host) == 0, "parse %sproduced unexpected hostname '%s' for '%s': expected '%s'", test_string[test_type], got_host, name, host);
fail_unless(display == got_display, "parse %sproduced unexpected display '%d' for '%s': expected '%d'", test_string[test_type], got_display, name, display);
fail_unless(screen == got_screen, "parse %sproduced unexpected screen '%d' for '%s': expected '%d'", test_string[test_type], got_screen, name, screen);
ck_assert_msg(success, "unexpected parse failure %sfor '%s'", test_string[test_type], name);
ck_assert_msg(strcmp(host, got_host) == 0, "parse %sproduced unexpected hostname '%s' for '%s': expected '%s'", test_string[test_type], got_host, name, host);
ck_assert_msg(display == got_display, "parse %sproduced unexpected display '%d' for '%s': expected '%d'", test_string[test_type], got_display, name, display);
ck_assert_msg(screen == got_screen, "parse %sproduced unexpected screen '%d' for '%s': expected '%d'", test_string[test_type], got_screen, name, screen);
got_host = (char *) -1;
got_display = got_screen = -42;
mark_point();
success = xcb_parse_display(argument, &got_host, &got_display, 0);
fail_unless(success, "unexpected screenless parse failure %sfor '%s'", test_string[test_type], name);
fail_unless(strcmp(host, got_host) == 0, "screenless parse %sproduced unexpected hostname '%s' for '%s': expected '%s'", test_string[test_type], got_host, name, host);
fail_unless(display == got_display, "screenless parse %sproduced unexpected display '%d' for '%s': expected '%d'", test_string[test_type], got_display, name, display);
ck_assert_msg(success, "unexpected screenless parse failure %sfor '%s'", test_string[test_type], name);
ck_assert_msg(strcmp(host, got_host) == 0, "screenless parse %sproduced unexpected hostname '%s' for '%s': expected '%s'", test_string[test_type], got_host, name, host);
ck_assert_msg(display == got_display, "screenless parse %sproduced unexpected display '%d' for '%s': expected '%d'", test_string[test_type], got_display, name, display);
}
putenv("DISPLAY=");
putenv(display_env);
}
static void parse_display_fail(const char *name)
@ -66,7 +74,7 @@ static void parse_display_fail(const char *name)
if(test_type == TEST_ARGUMENT)
{
argument = name;
putenv("DISPLAY=");
putenv(display_env);
}
else if(test_type == TEST_ENVIRONMENT)
{
@ -79,24 +87,55 @@ static void parse_display_fail(const char *name)
got_display = got_screen = -42;
mark_point();
success = xcb_parse_display(argument, &got_host, &got_display, &got_screen);
fail_unless(!success, "unexpected parse success %sfor '%s'", test_string[test_type], name);
fail_unless(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
fail_unless(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
fail_unless(got_screen == -42, "screen changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_screen);
ck_assert_msg(!success, "unexpected parse success %sfor '%s'", test_string[test_type], name);
ck_assert_msg(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
ck_assert_msg(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
ck_assert_msg(got_screen == -42, "screen changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_screen);
got_host = (char *) -1;
got_display = got_screen = -42;
mark_point();
success = xcb_parse_display(argument, &got_host, &got_display, 0);
fail_unless(!success, "unexpected screenless parse success %sfor '%s'", test_string[test_type], name);
fail_unless(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
fail_unless(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
ck_assert_msg(!success, "unexpected screenless parse success %sfor '%s'", test_string[test_type], name);
ck_assert_msg(got_host == (char *) -1, "host changed on parse failure %sfor '%s': got %p", test_string[test_type], name, got_host);
ck_assert_msg(got_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
}
putenv("DISPLAY=");
putenv(display_env);
}
START_TEST(parse_display_unix)
{
#ifdef __unix__
char buf[sizeof "/tmp/xcb-test.XXXXXXX"];
char buf2[sizeof(buf) + 7];
int r, v;
memcpy(buf, "/tmp/xcb-test.XXXXXXX", sizeof buf);
v = mkstemp(buf);
ck_assert_msg(v >= 0, "cannot create temporary file");
parse_display_pass(buf, buf, 0, 0);
r = snprintf(buf2, sizeof buf2, "unix:%s", buf);
if (r < 5 || r >= (int)sizeof buf2) {
ck_assert_msg(0, "snprintf() failed (return value %d)", r);
unlink(buf);
return;
}
parse_display_pass(buf2, buf, 0, 0);
r = snprintf(buf2, sizeof buf2, "unix:%s.1", buf);
if (r < 7 || r >= (int)sizeof buf2) {
ck_assert_msg(0, "snprintf() failed (return value %d)", r);
unlink(buf);
return;
}
parse_display_pass(buf2, buf, 0, 1);
r = snprintf(buf2, sizeof buf2, "%s.1", buf);
if (r < 2 || r >= (int)sizeof buf2) {
ck_assert_msg(0, "snprintf() failed (return value %d)", r);
unlink(buf);
return;
}
parse_display_pass(buf2, buf, 0, 1);
unlink(buf);
#endif
parse_display_pass(":0", "", 0, 0);
parse_display_pass(":1", "", 1, 0);
parse_display_pass(":0.1", "", 0, 1);
@ -183,7 +222,7 @@ END_TEST
static void popcount_eq(uint32_t bits, int count)
{
fail_unless(xcb_popcount(bits) == count, "unexpected popcount(%08x) != %d", bits, count);
ck_assert_msg(xcb_popcount(bits) == count, "unexpected popcount(%08x) != %d", bits, count);
}
START_TEST(popcount)
@ -206,7 +245,7 @@ END_TEST
Suite *public_suite(void)
{
Suite *s = suite_create("Public API");
putenv("DISPLAY=");
putenv(display_env);
suite_add_test(s, parse_display_unix, "xcb_parse_display unix");
suite_add_test(s, parse_display_ip, "xcb_parse_display ip");
suite_add_test(s, parse_display_ipv4, "xcb_parse_display ipv4");

View File

@ -1,4 +1,8 @@
#include <check.h>
#if CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13
void suite_add_test(Suite *s, TFun tf, const char *name);
#else
void suite_add_test(Suite *s, const TTest *tt, const char *name);
#endif
Suite *public_suite(void);

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Composite
Description: XCB Composite Extension
Version: @PACKAGE_VERSION@
Requires: xcb xcb-xfixes
Requires.private: xcb xcb-xfixes
Libs: -L${libdir} -lxcb-composite
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Damage
Description: XCB Damage Extension
Version: @PACKAGE_VERSION@
Requires: xcb xcb-xfixes
Requires.private: xcb xcb-xfixes
Libs: -L${libdir} -lxcb-damage
Cflags: -I${includedir}

11
xcb-dbe.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: XCB Dbe
Description: XCB Double Buffer Extension
Version: @PACKAGE_VERSION@
Requires.private: xcb
Libs: -L${libdir} -lxcb-dbe
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB DPMS
Description: XCB DPMS Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-dpms
Cflags: -I${includedir}

View File

@ -3,9 +3,9 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: XCB Xlib
Description: XCB Xlib support functions
Name: XCB DRI2
Description: XCB DRI2 Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Libs: -L${libdir} -lxcb-xlib
Requires.private: xcb
Libs: -L${libdir} -lxcb-dri2
Cflags: -I${includedir}

11
xcb-dri3.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: XCB DRI3
Description: XCB DRI3 Extension
Version: @PACKAGE_VERSION@
Requires.private: xcb
Libs: -L${libdir} -lxcb-dri3
Cflags: -I${includedir}

11
xcb-ge.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: XCB GenericEvent
Description: XCB GenericEvent Extension
Version: @PACKAGE_VERSION@
Requires.private: xcb
Libs: -L${libdir} -lxcb-ge
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB GLX
Description: XCB GLX Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-glx
Cflags: -I${includedir}

11
xcb-present.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: XCB Present
Description: XCB Present Extension
Version: @PACKAGE_VERSION@
Requires.private: xcb xcb-randr xcb-xfixes xcb-sync xcb-dri3
Libs: -L${libdir} -lxcb-present
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB RandR
Description: XCB RandR Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb xcb-render
Libs: -L${libdir} -lxcb-randr
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Record
Description: XCB Record Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-record
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Render
Description: XCB Render Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-render
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Res
Description: XCB X-Resource Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-res
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Screensaver
Description: XCB Screensaver Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-screensaver
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Shape
Description: XCB Shape Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-shape
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Shm
Description: XCB Shm Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-shm
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Sync
Description: XCB Sync Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-sync
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Xevie
Description: XCB Xevie Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-xevie
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB XFree86-DRI
Description: XCB XFree86-DRI Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-xf86dri
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB XFixes
Description: XCB XFixes Extension
Version: @PACKAGE_VERSION@
Requires: xcb xcb-render xcb-shape
Requires.private: xcb xcb-render xcb-shape
Libs: -L${libdir} -lxcb-xfixes
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Xinerama
Description: XCB Xinerama Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-xinerama
Cflags: -I${includedir}

11
xcb-xinput.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: XCB XInput
Description: XCB XInput Extension (EXPERIMENTAL)
Version: @PACKAGE_VERSION@
Requires.private: xcb xcb-xfixes
Libs: -L${libdir} -lxcb-xinput
Cflags: -I${includedir}

11
xcb-xkb.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: XCB XKB
Description: XCB Keyboard Extension (EXPERIMENTAL)
Version: @PACKAGE_VERSION@
Requires.private: xcb
Libs: -L${libdir} -lxcb-xkb
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Xprint
Description: XCB Xprint Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-xprint
Cflags: -I${includedir}

11
xcb-xselinux.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: XCB SELinux
Description: XCB SELinux Extension
Version: @PACKAGE_VERSION@
Requires.private: xcb
Libs: -L${libdir} -lxcb-xselinux
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB XTEST
Description: XCB XTEST Extension
Version: @PACKAGE_VERSION@
Requires: xcb
Requires.private: xcb
Libs: -L${libdir} -lxcb-xtest
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB Xv
Description: XCB Xv Extension
Version: @PACKAGE_VERSION@
Requires: xcb xcb-shm
Requires.private: xcb xcb-shm
Libs: -L${libdir} -lxcb-xv
Cflags: -I${includedir}

View File

@ -6,6 +6,6 @@ includedir=@includedir@
Name: XCB XvMC
Description: XCB XvMC Extension
Version: @PACKAGE_VERSION@
Requires: xcb xcb-xv
Requires.private: xcb xcb-xv
Libs: -L${libdir} -lxcb-xvmc
Cflags: -I${includedir}

View File

@ -2,6 +2,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
xcbproto_version=@XCBPROTO_VERSION@
Name: XCB
Description: X-protocol C Binding