Compare commits
72 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
93e6da2e2e | ||
|
6a7661f60a | ||
|
daf2c53976 | ||
|
021e887de9 | ||
|
124690ba63 | ||
|
ebea71700f | ||
|
622152ee42 | ||
|
4574ab269b | ||
|
b78d304531 | ||
|
389f22d1cb | ||
|
86a478032b | ||
|
c268499c30 | ||
|
c671b9b30a | ||
|
3c946010c8 | ||
|
02a7bbed39 | ||
|
18c3f055e7 | ||
|
453115f7ee | ||
|
f11691a098 | ||
|
cc4b93c9cd | ||
|
1519334652 | ||
|
038636786a | ||
|
8935793f1f | ||
|
095255531b | ||
|
ccdef1a8a5 | ||
|
18e109d755 | ||
|
fd04ab24a5 | ||
|
4d1a578dd5 | ||
|
e2a3e80eb8 | ||
|
3333d5bde8 | ||
|
973b510e95 | ||
|
cb8c70f5a6 | ||
|
33f3dbe369 | ||
|
c9513aac2d | ||
|
06e1ef43bb | ||
|
d53ad60d77 | ||
|
e2ee5aabe9 | ||
|
9dcb081708 | ||
|
7d798d3ccb | ||
|
7071b4a13c | ||
|
ee60239b73 | ||
|
3123dfe723 | ||
|
816407655f | ||
|
c2c4a2cd19 | ||
|
ddafdba11f | ||
|
43fbf03e54 | ||
|
233d7b7f1f | ||
|
dc28118747 | ||
|
26396bf156 | ||
|
a503167f75 | ||
|
3c76c0579f | ||
|
bdc3f21a52 | ||
|
068af21cb3 | ||
|
4d678b162b | ||
|
21414e7c44 | ||
|
4b0d9d3868 | ||
|
cd0fba98a2 | ||
|
2ef8655987 | ||
|
4cbcac4eca | ||
|
f01f3c378e | ||
|
704e0a91b1 | ||
|
4b40b44cb6 | ||
|
78c492deaa | ||
|
8f7e4c4e9f | ||
|
f9f4b00aad | ||
|
59e271e15b | ||
|
21324989b7 | ||
|
656c08c542 | ||
|
be1745c8eb | ||
|
58f37377c8 | ||
|
7bac366953 | ||
|
02ff3eadf4 | ||
|
542befe40a |
|
@ -23,3 +23,6 @@ mkinstalldirs
|
|||
stamp-h1
|
||||
ChangeLog
|
||||
INSTALL
|
||||
check-pc-requires.log
|
||||
check-pc-requires.trs
|
||||
test-suite.log
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
@ -99,6 +102,7 @@ tools/README \
|
|||
tools/api_conv.pl \
|
||||
tools/constants \
|
||||
autogen.sh \
|
||||
README.md \
|
||||
$(TESTS)
|
||||
|
||||
MAINTAINERCLEANFILES = ChangeLog INSTALL
|
||||
|
|
7
NEWS
7
NEWS
|
@ -1,3 +1,10 @@
|
|||
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
|
||||
|
|
|
@ -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 from
|
||||
the libxcb code repository at:
|
||||
|
||||
https://gitlab.freedesktop.org/xorg/lib/libxcb
|
||||
|
||||
You can obtain the latest development versions of XCB using GIT.
|
||||
For anonymous checkouts, use:
|
||||
|
||||
git clone git://anongit.freedesktop.org/git/xcb/libxcb
|
||||
git clone https://gitlab.freedesktop.org/xorg/lib/libxcb.git
|
||||
|
||||
For developers, use:
|
||||
|
||||
git clone git+ssh://git.freedesktop.org/git/xcb/libxcb
|
||||
git clone git@gitlab.freedesktop.org:xorg/lib/libxcb.git
|
11
autogen.sh
11
autogen.sh
|
@ -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
|
||||
|
|
33
configure.ac
33
configure.ac
|
@ -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.13.1],
|
||||
[https://bugs.freedesktop.org/enter_bug.cgi?product=xcb],
|
||||
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])
|
||||
|
@ -11,13 +11,14 @@ AC_CONFIG_SRCDIR([xcb.pc.in])
|
|||
AC_CONFIG_HEADERS([src/config.h])
|
||||
|
||||
# Initialize Automake
|
||||
AM_INIT_AUTOMAKE([foreign dist-bzip2])
|
||||
AM_PATH_PYTHON([2.6])
|
||||
AM_INIT_AUTOMAKE([foreign dist-xz])
|
||||
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])
|
||||
|
@ -36,7 +37,7 @@ if test x"$HAVE_DOT" = xno; then
|
|||
AC_MSG_WARN([dot not found - doxygen targets will be skipped])
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES(CHECK, [check >= 0.9.4], [HAVE_CHECK=yes], [HAVE_CHECK=no])
|
||||
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
|
||||
|
@ -50,8 +51,12 @@ fi
|
|||
AC_SUBST(HTML_CHECK_RESULT)
|
||||
|
||||
# Checks for pkg-config packages
|
||||
PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.13)
|
||||
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"
|
||||
|
@ -86,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)
|
||||
|
||||
|
@ -217,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)
|
||||
|
@ -243,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")
|
||||
|
@ -269,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
|
||||
|
@ -317,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}"
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
[wrap-git]
|
||||
url = https://gitea.gigo-games.dk/frederik/libxcb.git
|
||||
revision = HEAD
|
||||
depth = 1
|
|
@ -1,9 +1,11 @@
|
|||
bigreq.*
|
||||
composite.*
|
||||
damage.*
|
||||
dbe.*
|
||||
dpms.*
|
||||
dri2.*
|
||||
dri3.*
|
||||
ge.*
|
||||
glx.*
|
||||
present.*
|
||||
randr.*
|
||||
|
|
|
@ -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
|
||||
|
@ -59,7 +67,7 @@ endif
|
|||
EXTSOURCES += dri3.c
|
||||
if BUILD_DRI3
|
||||
lib_LTLIBRARIES += libxcb-dri3.la
|
||||
libxcb_dri3_la_LDFLAGS = -version-info 0:0:0 -no-undefined @lt_enable_auto_import@
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
@ -649,23 +649,22 @@ def _c_helper_resolve_field_names (prefix):
|
|||
|
||||
return all_fields
|
||||
|
||||
def get_expr_fields(self):
|
||||
"""
|
||||
get the Fields referenced by switch or list expression
|
||||
"""
|
||||
|
||||
def get_expr_field_names(expr):
|
||||
"""
|
||||
returns a list of field names referenced in an expression
|
||||
"""
|
||||
if expr.op is None or expr.op == 'calculate_len':
|
||||
if expr.lenfield_name is not None:
|
||||
return [expr.lenfield_name]
|
||||
else:
|
||||
# constant value expr
|
||||
return []
|
||||
else:
|
||||
|
||||
if expr.op == '~':
|
||||
return get_expr_field_names(expr.rhs)
|
||||
elif expr.op == 'popcount':
|
||||
if expr.op == 'popcount':
|
||||
return get_expr_field_names(expr.rhs)
|
||||
elif expr.op == 'sumof':
|
||||
if expr.op == 'sumof':
|
||||
# sumof expr references another list,
|
||||
# we need that list's length field here
|
||||
field = None
|
||||
|
@ -677,11 +676,15 @@ def get_expr_fields(self):
|
|||
raise Exception("list field '%s' referenced by sumof not found" % expr.lenfield_name)
|
||||
# referenced list + its length field
|
||||
return [expr.lenfield_name] + get_expr_field_names(field.type.expr)
|
||||
elif expr.op == 'enumref':
|
||||
if expr.op == 'enumref':
|
||||
return []
|
||||
else:
|
||||
return get_expr_field_names(expr.lhs) + get_expr_field_names(expr.rhs)
|
||||
# get_expr_field_names()
|
||||
|
||||
|
||||
def get_expr_fields(self):
|
||||
"""
|
||||
get the Fields referenced by switch or list expression
|
||||
"""
|
||||
|
||||
# resolve the field names with the parent structure(s)
|
||||
unresolved_fields_names = get_expr_field_names(self.expr)
|
||||
|
@ -963,18 +966,15 @@ def _c_get_additional_type_params(type):
|
|||
param_fields, wire_fields, params = get_serialize_params('sizeof', type)
|
||||
return params[1:]
|
||||
|
||||
def _c_serialize_helper_list_field(context, self, field,
|
||||
code_lines, temp_vars,
|
||||
space, prefix):
|
||||
|
||||
def _c_get_field_mapping_for_expr(self, expr, prefix):
|
||||
"""
|
||||
helper function to cope with lists of variable length
|
||||
helper function to get field mapping of a particular expression.
|
||||
"""
|
||||
expr = field.type.expr
|
||||
prefix_str = _c_helper_fieldaccess_expr(prefix)
|
||||
param_fields, wire_fields, params = get_serialize_params('sizeof', self)
|
||||
param_names = [p[2] for p in params]
|
||||
|
||||
expr_fields_names = [f.field_name for f in get_expr_fields(field.type)]
|
||||
expr_fields_names = get_expr_field_names(expr)
|
||||
resolved = [x for x in expr_fields_names if x in param_names]
|
||||
unresolved = [x for x in expr_fields_names if x not in param_names]
|
||||
|
||||
|
@ -993,6 +993,21 @@ def _c_serialize_helper_list_field(context, self, field,
|
|||
unresolved = [x for x in unresolved if x not in field_mapping]
|
||||
if len(unresolved)>0:
|
||||
raise Exception('could not resolve the length fields required for list %s' % field.c_field_name)
|
||||
|
||||
return field_mapping
|
||||
|
||||
|
||||
def _c_serialize_helper_list_field(context, self, field,
|
||||
code_lines, temp_vars,
|
||||
space, prefix):
|
||||
"""
|
||||
helper function to cope with lists of variable length
|
||||
"""
|
||||
expr = field.type.expr
|
||||
prefix_str = _c_helper_fieldaccess_expr(prefix)
|
||||
|
||||
field_mapping = _c_get_field_mapping_for_expr(self, field.type.expr, prefix)
|
||||
|
||||
if expr.op == 'calculate_len':
|
||||
list_length = field.type.expr.lenfield_name
|
||||
else:
|
||||
|
@ -1402,6 +1417,16 @@ def _c_serialize(context, self):
|
|||
|
||||
elif 'sizeof' == context:
|
||||
param_names = [p[2] for p in params]
|
||||
if self.length_expr is not None:
|
||||
_c(' const %s *_aux = (%s *)_buffer;', self.c_type, self.c_type)
|
||||
prefix = [('_aux', '->', self)]
|
||||
|
||||
field_mapping = _c_get_field_mapping_for_expr(self, self.length_expr, prefix)
|
||||
|
||||
_c(' return %s;', _c_accessor_get_expr(self.length_expr, field_mapping))
|
||||
_c('}')
|
||||
_c_pre.redirect_end()
|
||||
return
|
||||
if self.is_switch:
|
||||
# switch: call _unpack()
|
||||
_c(' %s _aux;', self.c_type)
|
||||
|
@ -1933,7 +1958,7 @@ def _c_accessors_list(self, field):
|
|||
else:
|
||||
# use the accessor to get the start of the list, then
|
||||
# compute the length of it by subtracting it from
|
||||
# the adress of the first byte after the end of the
|
||||
# the address of the first byte after the end of the
|
||||
# request
|
||||
after_end_of_request = '(((char*)R) + R->length * 4)'
|
||||
start_of_list = '%s(R)' % (field.c_accessor_name)
|
||||
|
@ -2241,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]
|
||||
|
@ -2255,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.
|
||||
|
||||
|
@ -2314,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
|
||||
|
@ -2586,9 +2612,10 @@ def _c_reply_fds(self, name):
|
|||
_h(' * @param c The connection')
|
||||
_h(' * @param reply The reply')
|
||||
_h(' *')
|
||||
_h(' * Returns the array of reply fds of the request asked by')
|
||||
_h(' * Returns a pointer to the array of reply fds of the reply.')
|
||||
_h(' *')
|
||||
_h(' * The returned value must be freed by the caller using free().')
|
||||
_h(' * The returned value points into the reply and must not be free().')
|
||||
_h(' * The fds are not managed by xcb. You must close() them before freeing the reply.')
|
||||
_h(' */')
|
||||
_c('')
|
||||
_hc('int *')
|
||||
|
@ -2633,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')
|
||||
|
@ -3008,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')
|
||||
|
|
66
src/xcb.h
66
src/xcb.h
|
@ -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,7 +47,35 @@ 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
|
||||
|
@ -465,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);
|
||||
|
||||
/**
|
||||
|
@ -475,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);
|
||||
|
||||
/**
|
||||
|
@ -495,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);
|
||||
|
||||
/**
|
||||
|
@ -591,7 +618,7 @@ 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.
|
||||
* @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.
|
||||
|
@ -599,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);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -31,9 +31,8 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <X11/Xauth.h>
|
||||
#include <sys/param.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __INTERIX
|
||||
/* _don't_ ask. interix has INADDR_LOOPBACK in here. */
|
||||
|
@ -48,6 +47,8 @@
|
|||
#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>
|
||||
|
@ -72,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
|
||||
|
@ -133,6 +134,7 @@ static Xauth *get_authptr(struct sockaddr *sockname, int display)
|
|||
}
|
||||
addr += 12;
|
||||
/* if v4-mapped, fall through. */
|
||||
XCB_ALLOW_FALLTHRU
|
||||
#endif
|
||||
case AF_INET:
|
||||
if(!addr)
|
||||
|
@ -163,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
|
||||
|
@ -269,10 +271,17 @@ static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *
|
|||
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;
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
@ -48,7 +47,9 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
#include "xcb_windefs.h"
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif /* _WIN32 */
|
||||
|
@ -169,6 +170,8 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
|
|||
|
||||
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)
|
||||
|
@ -194,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;
|
||||
}
|
||||
|
||||
|
@ -201,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;
|
||||
}
|
||||
}
|
||||
|
@ -211,33 +216,47 @@ 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);
|
||||
|
||||
#ifdef _WIN32
|
||||
int i = 0;
|
||||
int ret = 0,err = 0;
|
||||
struct iovec *vec;
|
||||
n = 0;
|
||||
|
||||
/* 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 */
|
||||
vec = *vector;
|
||||
while(i < *count)
|
||||
while (*count)
|
||||
{
|
||||
ret = send(c->fd,vec->iov_base,vec->iov_len,0);
|
||||
struct iovec *vec = *vector;
|
||||
if (vec->iov_len)
|
||||
{
|
||||
int ret = send(c->fd, vec->iov_base, vec->iov_len, 0);
|
||||
if (ret == SOCKET_ERROR)
|
||||
{
|
||||
err = WSAGetLastError();
|
||||
int err = WSAGetLastError();
|
||||
if (err == WSAEWOULDBLOCK)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
n += ret;
|
||||
*vec++;
|
||||
i++;
|
||||
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)
|
||||
|
@ -279,28 +298,32 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
if(n <= 0)
|
||||
{
|
||||
_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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -344,7 +367,11 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info)
|
|||
|
||||
c = calloc(1, sizeof(xcb_connection_t));
|
||||
if(!c) {
|
||||
#ifdef _WIN32
|
||||
closesocket(fd);
|
||||
#else
|
||||
close(fd);
|
||||
#endif
|
||||
return _xcb_conn_ret_error(XCB_CONN_CLOSED_MEM_INSUFFICIENT) ;
|
||||
}
|
||||
|
||||
|
@ -377,7 +404,11 @@ void xcb_disconnect(xcb_connection_t *c)
|
|||
|
||||
/* 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_in_destroy(&c->in);
|
||||
|
@ -528,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;
|
||||
}
|
||||
|
|
28
src/xcb_in.c
28
src/xcb_in.c
|
@ -32,7 +32,6 @@
|
|||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -40,6 +39,7 @@
|
|||
#include <poll.h>
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
@ -239,9 +239,15 @@ static int read_packet(xcb_connection_t *c)
|
|||
if(pend && pend->workaround == WORKAROUND_GLX_GET_FB_CONFIGS_BUG)
|
||||
{
|
||||
uint32_t *p = (uint32_t *) c->in.queue;
|
||||
genrep.length = p[2] * p[3] * 2;
|
||||
uint64_t new_length = ((uint64_t)p[2]) * ((uint64_t)p[3]);
|
||||
if(new_length >= (UINT32_MAX / UINT32_C(16)))
|
||||
{
|
||||
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_MEM_INSUFFICIENT);
|
||||
return 0;
|
||||
}
|
||||
length += genrep.length * 4;
|
||||
genrep.length = (uint32_t)(new_length * UINT64_C(2));
|
||||
}
|
||||
length += genrep.length * UINT64_C(4);
|
||||
|
||||
/* XXX a bit of a hack -- we "know" that all FD replys place
|
||||
* the number of fds in the pad0 byte */
|
||||
|
@ -251,7 +257,7 @@ static int read_packet(xcb_connection_t *c)
|
|||
|
||||
/* XGE events may have sizes > 32 */
|
||||
if ((genrep.response_type & 0x7f) == XCB_XGE_EVENT)
|
||||
eventlength = genrep.length * 4;
|
||||
eventlength = genrep.length * UINT64_C(4);
|
||||
|
||||
bufsize = length + eventlength + nfd * sizeof(int) +
|
||||
(genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t));
|
||||
|
@ -365,7 +371,7 @@ static void free_reply_list(struct reply_list *head)
|
|||
}
|
||||
}
|
||||
|
||||
static int read_block(const int fd, void *buf, const ssize_t len)
|
||||
static int read_block(const int fd, void *buf, const intptr_t len)
|
||||
{
|
||||
int done = 0;
|
||||
while(done < len)
|
||||
|
@ -736,12 +742,17 @@ xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t co
|
|||
return 0;
|
||||
pthread_mutex_lock(&c->iolock);
|
||||
request = widen(c, cookie.sequence);
|
||||
if(XCB_SEQUENCE_COMPARE(request, >=, c->in.request_expected)
|
||||
&& XCB_SEQUENCE_COMPARE(request, >, c->in.request_completed))
|
||||
if (XCB_SEQUENCE_COMPARE(request, >, c->in.request_completed))
|
||||
{
|
||||
if(XCB_SEQUENCE_COMPARE(request, >=, c->in.request_expected))
|
||||
{
|
||||
_xcb_out_send_sync(c);
|
||||
}
|
||||
if (XCB_SEQUENCE_COMPARE(request, >=, c->out.request_expected_written))
|
||||
{
|
||||
_xcb_out_flush_to(c, c->out.request);
|
||||
}
|
||||
}
|
||||
reply = wait_for_reply(c, request, &ret);
|
||||
assert(!reply);
|
||||
pthread_mutex_unlock(&c->iolock);
|
||||
|
@ -1025,6 +1036,7 @@ int _xcb_in_read(xcb_connection_t *c)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
c->in.total_read += n;
|
||||
c->in.queue_len += n;
|
||||
}
|
||||
while(read_packet(c))
|
||||
|
@ -1051,7 +1063,7 @@ int _xcb_in_read(xcb_connection_t *c)
|
|||
}
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
if((n > 0) || (n < 0 && errno == EAGAIN))
|
||||
if((n > 0) || (n < 0 && (errno == EAGAIN || errno == EINTR)))
|
||||
#else
|
||||
if((n > 0) || (n < 0 && WSAGetLastError() == WSAEWOULDBLOCK))
|
||||
#endif /* !_WIN32 */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
typedef struct node {
|
||||
struct node *next;
|
||||
unsigned int key;
|
||||
uint64_t key;
|
||||
void *data;
|
||||
} node;
|
||||
|
||||
|
@ -73,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)
|
||||
|
@ -86,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)
|
||||
|
|
|
@ -31,7 +31,11 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "xcb.h"
|
||||
|
@ -443,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;
|
||||
|
@ -453,8 +458,9 @@ 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)
|
||||
|
@ -463,6 +469,7 @@ int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int 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;
|
||||
|
|
|
@ -36,12 +36,12 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.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>
|
||||
|
@ -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,6 +259,19 @@ static int _xcb_open(const char *host, char *protocol, const int display)
|
|||
char *file = NULL;
|
||||
int actual_filelen;
|
||||
|
||||
#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))
|
||||
|
@ -250,27 +286,19 @@ static int _xcb_open(const char *host, char *protocol, const int display)
|
|||
/* 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];
|
||||
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
|
||||
|
||||
#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,7 +306,6 @@ 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)
|
||||
{
|
||||
|
@ -294,8 +321,8 @@ static int _xcb_open(const char *host, char *protocol, const int display)
|
|||
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);
|
||||
|
@ -415,7 +446,11 @@ static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short
|
|||
if(_xcb_do_connect(fd, (struct sockaddr*)&_s, sizeof(_s)) >= 0)
|
||||
break;
|
||||
|
||||
#ifdef _WIN32
|
||||
closesocket(fd);
|
||||
#else
|
||||
close(fd);
|
||||
#endif
|
||||
fd = -1;
|
||||
++_c;
|
||||
}
|
||||
|
@ -524,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);
|
||||
|
|
|
@ -55,7 +55,7 @@ uint32_t xcb_generate_id(xcb_connection_t *c)
|
|||
/* 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) {
|
||||
if (!xc_misc_reply || !xc_misc_reply->present) {
|
||||
pthread_mutex_unlock(&c->xid.lock);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
18
src/xcbint.h
18
src/xcbint.h
|
@ -38,6 +38,16 @@
|
|||
#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,
|
||||
|
@ -73,8 +83,8 @@ 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 */
|
||||
|
@ -103,6 +113,8 @@ typedef struct _xcb_out {
|
|||
|
||||
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;
|
||||
|
@ -135,6 +147,7 @@ typedef struct _xcb_in {
|
|||
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;
|
||||
|
||||
|
@ -212,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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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}
|
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue