Compare commits

...

42 Commits

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
18 changed files with 353 additions and 111 deletions

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

View File

@ -12,6 +12,9 @@ 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

View File

@ -1,14 +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 $?
git config --local --get format.subjectPrefix >/dev/null 2>&1 ||
git config --local format.subjectPrefix "PATCH libxcb"
if test -z "$NOCONFIGURE"; then
$srcdir/configure "$@"
exec "$srcdir"/configure "$@"
fi

View File

@ -2,8 +2,8 @@ dnl Process this file with autoconf to produce a configure script.
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([libxcb],[1.15],
[https://gitlab.freedesktop.org/xorg/lib/libxcb/issues],
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])
@ -12,12 +12,13 @@ AC_CONFIG_HEADERS([src/config.h])
# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-xz])
AM_PATH_PYTHON([2.6])
AM_PATH_PYTHON([3.0])
# 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])
@ -50,10 +51,10 @@ fi
AC_SUBST(HTML_CHECK_RESULT)
# Checks for pkg-config packages
PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.14)
PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.17.0)
NEEDED="xau >= 0.99.2"
case $host_os in
linux*) ;;
linux*|darwin*|solaris*|dragonfly*|freebsd*|netbsd*) ;;
*) NEEDED="$NEEDED pthread-stubs" ;;
esac
PKG_CHECK_MODULES(NEEDED, $NEEDED)
@ -90,7 +91,6 @@ XCBPROTO_XCBPYTHONDIR=`$PKG_CONFIG --variable=pythondir xcb-proto`
AC_MSG_RESULT($XCBPROTO_XCBPYTHONDIR)
AC_SUBST(XCBPROTO_XCBPYTHONDIR)
AC_HEADER_STDC
AC_SEARCH_LIBS(getaddrinfo, socket)
AC_SEARCH_LIBS(connect, socket)
@ -221,6 +221,7 @@ 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)
@ -247,16 +248,6 @@ XCB_EXTENSION(XTest, yes)
XCB_EXTENSION(Xv, yes)
XCB_EXTENSION(XvMC, yes)
AC_ARG_WITH(launchd, AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto])
if test "x$LAUNCHD" = xauto; then
unset LAUNCHD
AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no], [$PATH$PATH_SEPARATOR/sbin])
fi
if test "x$LAUNCHD" = xyes ; then
AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available])
fi
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")
@ -273,6 +264,7 @@ AC_CONFIG_FILES([
xcb.pc
xcb-composite.pc
xcb-damage.pc
xcb-dbe.pc
xcb-dpms.pc
xcb-dri2.pc
xcb-dri3.pc
@ -321,6 +313,7 @@ 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}"

View File

@ -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,

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

1
src/.gitignore vendored
View File

@ -1,6 +1,7 @@
bigreq.*
composite.*
damage.*
dbe.*
dpms.*
dri2.*
dri3.*

View File

@ -40,6 +40,14 @@ libxcb_damage_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_damage_la_SOURCES = damage.c damage.h
endif
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

View File

@ -331,7 +331,7 @@ def c_close(self):
_h(' */')
# Write header file
hfile = open('%s.h' % _ns.header, 'w')
hfile = open('%s.h' % _ns.header, 'w', encoding='UTF-8')
for list in _hlines:
for line in list:
hfile.write(line)
@ -339,7 +339,7 @@ def c_close(self):
hfile.close()
# Write source file
cfile = open('%s.c' % _ns.header, 'w')
cfile = open('%s.c' % _ns.header, 'w', encoding='UTF-8')
for list in _clines:
for line in list:
cfile.write(line)
@ -2266,13 +2266,13 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
elif base_func_name == 'xcb_create_window' and field.c_field_name == 'value_mask':
field.enum = 'CW'
if field.enum:
# XXX: why the 'xcb' prefix?
key = ('xcb', field.enum)
assert 2 <= len(self.name) <= 3
key = (*self.name[:-1], field.enum)
tname = _t(key)
if namecount[tname] > 1:
tname = _t(key + ('enum',))
_h(' * @param %s A bitmask of #%s values.' % (field.c_field_name, tname))
_h(' * @param %s A bitmask of #%s values.', field.c_field_name, tname)
if self.doc and field.field_name in self.doc.fields:
desc = self.doc.fields[field.field_name]
@ -2280,7 +2280,8 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
desc = desc.replace('`%s`' % name, '\\a %s' % (name))
desc = desc.split("\n")
desc = [line if line != '' else '\\n' for line in desc]
_h(' * @param %s %s' % (field.c_field_name, "\n * ".join(desc)))
_h(' * @param %s %s', field.c_field_name, "\n * ".join(desc))
# If there is no documentation yet, we simply don't generate an
# @param tag. Doxygen will then warn about missing documentation.
@ -2339,7 +2340,7 @@ def _c_request_helper(self, name, void, regular, aux=False, reply_fds=False):
for field in param_fields:
if not field.type.fixed_size() and field.wire:
count = count + 2
if field.type.c_need_serialize:
if field.type.c_need_serialize or field.type.c_need_sizeof:
# _serialize() keeps track of padding automatically
count -= 1
dimension = count + 2
@ -2659,14 +2660,14 @@ def _man_request(self, name, void, aux):
name = 'man/%s.%s' % (linkname, section)
if manpaths:
sys.stdout.write(name)
f = open(name, 'w')
f = open(name, 'w', encoding='UTF-8')
f.write('.so man%s/%s.%s' % (section, func_name, section))
f.close()
if manpaths:
sys.stdout.write('man/%s.%s ' % (func_name, section))
# Our CWD is src/, so this will end up in src/man/
f = open('man/%s.%s' % (func_name, section), 'w')
f = open('man/%s.%s' % (func_name, section), 'w', encoding='UTF-8')
f.write('.TH %s %s "%s" "%s" "XCB Requests"\n' % (func_name, section, center_footer, left_footer))
# Left-adjust instead of adjusting to both sides
f.write('.ad l\n')
@ -3034,7 +3035,7 @@ def _man_event(self, name):
if manpaths:
sys.stdout.write('man/%s.%s ' % (self.c_type, section))
# Our CWD is src/, so this will end up in src/man/
f = open('man/%s.%s' % (self.c_type, section), 'w')
f = open('man/%s.%s' % (self.c_type, section), 'w', encoding='UTF-8')
f.write('.TH %s %s "%s" "%s" "XCB Events"\n' % (self.c_type, section, center_footer, left_footer))
# Left-adjust instead of adjusting to both sides
f.write('.ad l\n')

View File

@ -29,11 +29,7 @@
#define __XCB_H__
#include <sys/types.h>
#if defined(__solaris__)
#include <inttypes.h>
#else
#include <stdint.h>
#endif
#ifndef _WIN32
#include <sys/uio.h>
@ -51,12 +47,36 @@ extern "C" {
* @file xcb.h
*/
#ifdef __GNUC__
#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.
@ -469,6 +489,7 @@ void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
*
* The result must not be freed.
*/
XCB_PURE_FUNCTION
const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
/**
@ -479,6 +500,7 @@ const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
* 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);
/**
@ -499,6 +521,7 @@ int xcb_get_file_descriptor(xcb_connection_t *c);
* @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);
/**

View File

@ -73,7 +73,7 @@ enum auth_protos {
#define AUTH_PROTO_XDM_AUTHORIZATION "XDM-AUTHORIZATION-1"
#define AUTH_PROTO_MIT_MAGIC_COOKIE "MIT-MAGIC-COOKIE-1"
static char *authnames[N_AUTH_PROTOS] = {
static const char *authnames[N_AUTH_PROTOS] = {
#ifdef HASXDMAUTH
AUTH_PROTO_XDM_AUTHORIZATION,
#endif
@ -165,7 +165,7 @@ static Xauth *get_authptr(struct sockaddr *sockname, int display)
return XauGetBestAuthByAddr (family,
(unsigned short) addrlen, addr,
(unsigned short) dispbuflen, dispbuf,
N_AUTH_PROTOS, authnames, authnameslen);
N_AUTH_PROTOS, (char **)authnames, authnameslen);
}
#ifdef HASXDMAUTH

View File

@ -310,9 +310,11 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
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;
}

View File

@ -60,16 +60,27 @@
# include <sys/stat.h>
#endif
#ifdef HAVE_LAUNCHD
#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)
@ -82,7 +93,6 @@ int xcb_sumof(uint8_t *list, int len)
return s;
}
#ifdef HAVE_LAUNCHD
/* Return true and parse if name matches <path to socket>[.<screen>]
* Upon success:
* host = <path to socket>
@ -94,20 +104,33 @@ static int _xcb_parse_display_path_to_socket(const char *name, char **host, char
int *displayp, int *screenp)
{
struct stat sbuf;
char path[PATH_MAX];
int _screen = 0;
/* 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;
strlcpy(path, name, sizeof(path));
if (0 != stat(path, &sbuf)) {
char *dot = strrchr(path, '.');
if (!dot)
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 = atoi(dot + 1);
_screen = (int)lscreen;
}
if (host) {
@ -133,7 +156,6 @@ static int _xcb_parse_display_path_to_socket(const char *name, char **host, char
return 1;
}
#endif
static int _xcb_parse_display(const char *name, char **host, char **protocol,
int *displayp, int *screenp)
@ -146,11 +168,12 @@ static int _xcb_parse_display(const char *name, char **host, char **protocol,
if(!name)
return 0;
#ifdef HAVE_LAUNCHD
/* First check for <path to socket>[.<screen>] */
if (_xcb_parse_display_path_to_socket(name, host, protocol, displayp, screenp))
return 1;
#endif
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, '/');
@ -236,41 +259,46 @@ static int _xcb_open(const char *host, char *protocol, const int display)
char *file = NULL;
int actual_filelen;
/* 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 (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())
{
struct stat sbuf;
const char *tsol_base = "/var/tsol/doors/.X11-unix/X";
char tsol_socket[PATH_MAX];
/* 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);
snprintf(tsol_socket, sizeof(tsol_socket), "%s%d", tsol_base, display);
if (stat(tsol_socket, &sbuf) == 0)
base = tsol_base;
}
if (stat(tsol_socket, &sbuf) == 0)
base = tsol_base;
else if (errno != ENOENT)
return 0;
}
#endif
#ifdef HAVE_LAUNCHD
struct stat sbuf;
if (0 == stat(host, &sbuf)) {
file = strdup(host);
if(file == NULL)
return -1;
filelen = actual_filelen = strlen(file);
} else
#endif
{
filelen = strlen(base) + 1 + sizeof(display) * 3 + 1;
file = malloc(filelen);
if(file == NULL)
@ -278,24 +306,23 @@ static int _xcb_open(const char *host, char *protocol, const int display)
/* 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);
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;
}
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);
@ -389,7 +416,11 @@ static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short
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);
@ -528,10 +559,8 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
if(auth) {
c = xcb_connect_to_fd(fd, auth);
goto out;
}
if(_xcb_get_auth_info(fd, &ourauth, display))
else if(_xcb_get_auth_info(fd, &ourauth, display))
{
c = xcb_connect_to_fd(fd, &ourauth);
free(ourauth.name);

View File

@ -297,6 +297,7 @@ int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xc
* @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);
@ -306,6 +307,7 @@ int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t replylen);
* @param mask The mask to check
* @return The number of set bits in the mask
*/
XCB_CONST_FUNCTION
int xcb_popcount(uint32_t mask);
/**
@ -313,6 +315,7 @@ int xcb_popcount(uint32_t mask);
* @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

View File

@ -225,6 +225,7 @@ struct xcb_connection_t {
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);

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)
{
@ -50,7 +58,7 @@ static void parse_display_pass(const char *name, const char *host, const int dis
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)
{
@ -92,11 +100,42 @@ static void parse_display_fail(const char *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);
@ -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");

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 Present
Description: XCB Present Extension
Version: @PACKAGE_VERSION@
Requires.private: xcb xcb-randr xcb-xfixes xcb-sync
Requires.private: xcb xcb-randr xcb-xfixes xcb-sync xcb-dri3
Libs: -L${libdir} -lxcb-present
Cflags: -I${includedir}