Compare commits

..

No commits in common. "master" and "libxcb-1.15" have entirely different histories.

18 changed files with 113 additions and 355 deletions

View File

@ -1,123 +0,0 @@
# 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,9 +12,6 @@ endif
if BUILD_DAMAGE if BUILD_DAMAGE
pkgconfig_DATA += xcb-damage.pc pkgconfig_DATA += xcb-damage.pc
endif endif
if BUILD_DBE
pkgconfig_DATA += xcb-dbe.pc
endif
if BUILD_DPMS if BUILD_DPMS
pkgconfig_DATA += xcb-dpms.pc pkgconfig_DATA += xcb-dpms.pc
endif endif

View File

@ -1,17 +1,14 @@
#! /bin/sh #! /bin/sh
srcdir=`dirname "$0"` srcdir=`dirname $0`
test -z "$srcdir" && srcdir=. test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd` ORIGDIR=`pwd`
cd "$srcdir" cd $srcdir
autoreconf -v --install || exit 1 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 if test -z "$NOCONFIGURE"; then
exec "$srcdir"/configure "$@" $srcdir/configure "$@"
fi fi

View File

@ -2,8 +2,8 @@ dnl Process this file with autoconf to produce a configure script.
# Initialize Autoconf # Initialize Autoconf
AC_PREREQ([2.60]) AC_PREREQ([2.60])
AC_INIT([libxcb],[1.17.0], AC_INIT([libxcb],[1.15],
[https://gitlab.freedesktop.org/xorg/lib/libxcb/-/issues], [https://gitlab.freedesktop.org/xorg/lib/libxcb/issues],
[libxcb]) [libxcb])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
@ -12,13 +12,12 @@ AC_CONFIG_HEADERS([src/config.h])
# Initialize Automake # Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-xz]) AM_INIT_AUTOMAKE([foreign dist-xz])
AM_PATH_PYTHON([3.0]) AM_PATH_PYTHON([2.6])
# Set common system defines for POSIX extensions, such as _GNU_SOURCE # 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) # Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL)
# to avoid autoconf errors. # to avoid autoconf errors.
AC_USE_SYSTEM_EXTENSIONS AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
# Initialize libtool # Initialize libtool
LT_PREREQ([2.2]) LT_PREREQ([2.2])
@ -51,10 +50,10 @@ fi
AC_SUBST(HTML_CHECK_RESULT) AC_SUBST(HTML_CHECK_RESULT)
# Checks for pkg-config packages # Checks for pkg-config packages
PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.17.0) PKG_CHECK_MODULES(XCBPROTO, xcb-proto >= 1.14)
NEEDED="xau >= 0.99.2" NEEDED="xau >= 0.99.2"
case $host_os in case $host_os in
linux*|darwin*|solaris*|dragonfly*|freebsd*|netbsd*) ;; linux*) ;;
*) NEEDED="$NEEDED pthread-stubs" ;; *) NEEDED="$NEEDED pthread-stubs" ;;
esac esac
PKG_CHECK_MODULES(NEEDED, $NEEDED) PKG_CHECK_MODULES(NEEDED, $NEEDED)
@ -91,6 +90,7 @@ XCBPROTO_XCBPYTHONDIR=`$PKG_CONFIG --variable=pythondir xcb-proto`
AC_MSG_RESULT($XCBPROTO_XCBPYTHONDIR) AC_MSG_RESULT($XCBPROTO_XCBPYTHONDIR)
AC_SUBST(XCBPROTO_XCBPYTHONDIR) AC_SUBST(XCBPROTO_XCBPYTHONDIR)
AC_HEADER_STDC
AC_SEARCH_LIBS(getaddrinfo, socket) AC_SEARCH_LIBS(getaddrinfo, socket)
AC_SEARCH_LIBS(connect, socket) AC_SEARCH_LIBS(connect, socket)
@ -221,7 +221,6 @@ esac
XCB_EXTENSION(Composite, yes) XCB_EXTENSION(Composite, yes)
XCB_EXTENSION(Damage, yes) XCB_EXTENSION(Damage, yes)
XCB_EXTENSION(Dbe, yes)
XCB_EXTENSION(DPMS, yes) XCB_EXTENSION(DPMS, yes)
XCB_EXTENSION(DRI2, yes) XCB_EXTENSION(DRI2, yes)
XCB_EXTENSION(DRI3, $have_sendmsg) XCB_EXTENSION(DRI3, $have_sendmsg)
@ -248,6 +247,16 @@ XCB_EXTENSION(XTest, yes)
XCB_EXTENSION(Xv, yes) XCB_EXTENSION(Xv, yes)
XCB_EXTENSION(XvMC, 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]) 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") AM_CONDITIONAL(XCB_SERVERSIDE_SUPPORT, test "x$XCB_SERVERSIDE_SUPPORT" = "xyes")
@ -264,7 +273,6 @@ AC_CONFIG_FILES([
xcb.pc xcb.pc
xcb-composite.pc xcb-composite.pc
xcb-damage.pc xcb-damage.pc
xcb-dbe.pc
xcb-dpms.pc xcb-dpms.pc
xcb-dri2.pc xcb-dri2.pc
xcb-dri3.pc xcb-dri3.pc
@ -313,7 +321,6 @@ echo ""
echo " X11 extensions" echo " X11 extensions"
echo " Composite...........: ${BUILD_COMPOSITE}" echo " Composite...........: ${BUILD_COMPOSITE}"
echo " Damage..............: ${BUILD_DAMAGE}" echo " Damage..............: ${BUILD_DAMAGE}"
echo " Dbe.................: ${BUILD_DBE}"
echo " Dpms................: ${BUILD_DPMS}" echo " Dpms................: ${BUILD_DPMS}"
echo " Dri2................: ${BUILD_DRI2}" echo " Dri2................: ${BUILD_DRI2}"
echo " Dri3................: ${BUILD_DRI3}" echo " Dri3................: ${BUILD_DRI3}"

View File

@ -2297,7 +2297,9 @@ int main ()
values[0] = screen->white_pixel; values[0] = screen->white_pixel;
values[1] = values[1] =
XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_KEY_RELEASE |
XCB_EVENT_MASK_EXPOSURE; XCB_EVENT_MASK_BUTTON_PRESS |
XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_POINTER_MOTION;
cookie_window = xcb_create_window_checked (c, cookie_window = xcb_create_window_checked (c,
screen->root_depth, screen->root_depth,
window, screen->root, window, screen->root,

View File

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

1
src/.gitignore vendored
View File

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

View File

@ -40,14 +40,6 @@ libxcb_damage_la_LIBADD = $(XCB_LIBS)
nodist_libxcb_damage_la_SOURCES = damage.c damage.h nodist_libxcb_damage_la_SOURCES = damage.c damage.h
endif 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 EXTSOURCES += dpms.c
if BUILD_DPMS if BUILD_DPMS
lib_LTLIBRARIES += libxcb-dpms.la lib_LTLIBRARIES += libxcb-dpms.la

View File

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

View File

@ -29,7 +29,11 @@
#define __XCB_H__ #define __XCB_H__
#include <sys/types.h> #include <sys/types.h>
#if defined(__solaris__)
#include <inttypes.h>
#else
#include <stdint.h> #include <stdint.h>
#endif
#ifndef _WIN32 #ifndef _WIN32
#include <sys/uio.h> #include <sys/uio.h>
@ -47,36 +51,12 @@ extern "C" {
* @file xcb.h * @file xcb.h
*/ */
#ifndef __has_attribute #ifdef __GNUC__
# 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__)) #define XCB_PACKED __attribute__((__packed__))
#else #else
#define XCB_PACKED #define XCB_PACKED
#endif #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 * @defgroup XCB_Core_API XCB Core API
* @brief Core API of the XCB library. * @brief Core API of the XCB library.
@ -489,7 +469,6 @@ void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
* *
* The result must not be freed. * The result must not be freed.
*/ */
XCB_PURE_FUNCTION
const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c); const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
/** /**
@ -500,7 +479,6 @@ const struct xcb_setup_t *xcb_get_setup(xcb_connection_t *c);
* Accessor for the file descriptor that was passed to the * Accessor for the file descriptor that was passed to the
* xcb_connect_to_fd call that returned @p c. * xcb_connect_to_fd call that returned @p c.
*/ */
XCB_PURE_FUNCTION
int xcb_get_file_descriptor(xcb_connection_t *c); int xcb_get_file_descriptor(xcb_connection_t *c);
/** /**
@ -521,7 +499,6 @@ int xcb_get_file_descriptor(xcb_connection_t *c);
* @return XCB_CONN_CLOSED_PARSE_ERR, error during parsing display string. * @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. * @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); 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_XDM_AUTHORIZATION "XDM-AUTHORIZATION-1"
#define AUTH_PROTO_MIT_MAGIC_COOKIE "MIT-MAGIC-COOKIE-1" #define AUTH_PROTO_MIT_MAGIC_COOKIE "MIT-MAGIC-COOKIE-1"
static const char *authnames[N_AUTH_PROTOS] = { static char *authnames[N_AUTH_PROTOS] = {
#ifdef HASXDMAUTH #ifdef HASXDMAUTH
AUTH_PROTO_XDM_AUTHORIZATION, AUTH_PROTO_XDM_AUTHORIZATION,
#endif #endif
@ -165,7 +165,7 @@ static Xauth *get_authptr(struct sockaddr *sockname, int display)
return XauGetBestAuthByAddr (family, return XauGetBestAuthByAddr (family,
(unsigned short) addrlen, addr, (unsigned short) addrlen, addr,
(unsigned short) dispbuflen, dispbuf, (unsigned short) dispbuflen, dispbuf,
N_AUTH_PROTOS, (char **)authnames, authnameslen); N_AUTH_PROTOS, authnames, authnameslen);
} }
#ifdef HASXDMAUTH #ifdef HASXDMAUTH

View File

@ -310,11 +310,9 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
int cur = (*vector)->iov_len; int cur = (*vector)->iov_len;
if(cur > n) if(cur > n)
cur = n; cur = n;
if(cur) { (*vector)->iov_len -= cur;
(*vector)->iov_len -= cur; (*vector)->iov_base = (char *) (*vector)->iov_base + cur;
(*vector)->iov_base = (char *) (*vector)->iov_base + cur; n -= cur;
n -= cur;
}
if((*vector)->iov_len) if((*vector)->iov_len)
break; break;
} }

View File

@ -60,27 +60,16 @@
# include <sys/stat.h> # include <sys/stat.h>
#endif #endif
#ifdef HAVE_LAUNCHD
#include <sys/stat.h> #include <sys/stat.h>
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif #endif
int xcb_popcount(uint32_t mask) 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; uint32_t y;
y = (mask >> 1) & 033333333333; y = (mask >> 1) & 033333333333;
y = mask - y - ((y >> 1) & 033333333333); y = mask - y - ((y >> 1) & 033333333333);
return ((y + (y >> 3)) & 030707070707) % 077; return ((y + (y >> 3)) & 030707070707) % 077;
#endif
} }
int xcb_sumof(uint8_t *list, int len) int xcb_sumof(uint8_t *list, int len)
@ -93,6 +82,7 @@ int xcb_sumof(uint8_t *list, int len)
return s; return s;
} }
#ifdef HAVE_LAUNCHD
/* Return true and parse if name matches <path to socket>[.<screen>] /* Return true and parse if name matches <path to socket>[.<screen>]
* Upon success: * Upon success:
* host = <path to socket> * host = <path to socket>
@ -104,33 +94,20 @@ static int _xcb_parse_display_path_to_socket(const char *name, char **host, char
int *displayp, int *screenp) int *displayp, int *screenp)
{ {
struct stat sbuf; struct stat sbuf;
/* In addition to the AF_UNIX path, there may be a screen number. char path[PATH_MAX];
* The trailing \0 is already accounted in the size of sun_path. */ int _screen = 0;
char path[sizeof(((struct sockaddr_un*)0)->sun_path) + 1 + 10];
size_t len;
int _screen = 0, res;
len = strlen(name); strlcpy(path, name, sizeof(path));
if (len >= sizeof(path)) if (0 != stat(path, &sbuf)) {
return 0; char *dot = strrchr(path, '.');
memcpy(path, name, len + 1); if (!dot)
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; return 0;
*dot = '\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)) if (0 != stat(path, &sbuf))
return 0; return 0;
_screen = (int)lscreen;
_screen = atoi(dot + 1);
} }
if (host) { if (host) {
@ -156,6 +133,7 @@ static int _xcb_parse_display_path_to_socket(const char *name, char **host, char
return 1; return 1;
} }
#endif
static int _xcb_parse_display(const char *name, char **host, char **protocol, static int _xcb_parse_display(const char *name, char **host, char **protocol,
int *displayp, int *screenp) int *displayp, int *screenp)
@ -168,12 +146,11 @@ static int _xcb_parse_display(const char *name, char **host, char **protocol,
if(!name) if(!name)
return 0; return 0;
#ifdef HAVE_LAUNCHD
/* First check for <path to socket>[.<screen>] */ /* First check for <path to socket>[.<screen>] */
if (name[0] == '/') if (_xcb_parse_display_path_to_socket(name, host, protocol, displayp, screenp))
return _xcb_parse_display_path_to_socket(name, host, protocol, displayp, screenp); return 1;
#endif
if (strncmp(name, "unix:", 5) == 0)
return _xcb_parse_display_path_to_socket(name + 5, host, protocol, displayp, screenp);
slash = strrchr(name, '/'); slash = strrchr(name, '/');
@ -259,46 +236,41 @@ static int _xcb_open(const char *host, char *protocol, const int display)
char *file = NULL; char *file = NULL;
int actual_filelen; int actual_filelen;
#ifndef _WIN32 /* If protocol or host is "unix", fall through to Unix socket code below */
if (protocol && strcmp("unix", protocol) == 0 && host && host[0] == '/') { if ((!protocol || (strcmp("unix",protocol) != 0)) &&
/* Full path to socket provided, ignore everything else */ (*host != '\0') && (strcmp("unix",host) != 0))
filelen = strlen(host) + 1; {
if (filelen > INT_MAX) /* display specifies TCP */
return -1; unsigned short port = X_TCP_PORT + display;
file = malloc(filelen); return _xcb_open_tcp(host, protocol, port);
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 #ifndef _WIN32
#if defined(HAVE_TSOL_LABEL_H) && defined(HAVE_IS_SYSTEM_LABELED) #if defined(HAVE_TSOL_LABEL_H) && defined(HAVE_IS_SYSTEM_LABELED)
/* Check special path for Unix sockets under Solaris Trusted Extensions */ /* Check special path for Unix sockets under Solaris Trusted Extensions */
if (is_system_labeled()) if (is_system_labeled())
{ {
const char *tsol_base = "/var/tsol/doors/.X11-unix/X"; struct stat sbuf;
char tsol_socket[PATH_MAX]; const char *tsol_base = "/var/tsol/doors/.X11-unix/X";
struct stat sbuf; char tsol_socket[PATH_MAX];
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) if (stat(tsol_socket, &sbuf) == 0)
base = tsol_base; base = tsol_base;
else if (errno != ENOENT) }
return 0;
}
#endif #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; filelen = strlen(base) + 1 + sizeof(display) * 3 + 1;
file = malloc(filelen); file = malloc(filelen);
if(file == NULL) if(file == NULL)
@ -306,23 +278,24 @@ static int _xcb_open(const char *host, char *protocol, const int display)
/* display specifies Unix socket */ /* display specifies Unix socket */
actual_filelen = snprintf(file, filelen, "%s%d", base, display); actual_filelen = snprintf(file, filelen, "%s%d", base, display);
if(actual_filelen < 0)
{
free(file);
return -1;
}
/* snprintf may truncate the file */
filelen = MIN(actual_filelen, filelen - 1);
#ifdef HAVE_ABSTRACT_SOCKETS
fd = _xcb_open_abstract(protocol, file, filelen);
if (fd >= 0 || (errno != ENOENT && errno != ECONNREFUSED))
{
free(file);
return fd;
}
#endif
} }
if(actual_filelen < 0)
{
free(file);
return -1;
}
/* snprintf may truncate the file */
filelen = MIN(actual_filelen, filelen - 1);
#ifdef HAVE_ABSTRACT_SOCKETS
fd = _xcb_open_abstract(protocol, file, filelen);
if (fd >= 0 || (errno != ENOENT && errno != ECONNREFUSED))
{
free(file);
return fd;
}
#endif
fd = _xcb_open_unix(protocol, file); fd = _xcb_open_unix(protocol, file);
free(file); free(file);
@ -416,11 +389,7 @@ 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); fd = _xcb_socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if (_xcb_do_connect(fd, addr->ai_addr, addr->ai_addrlen) >= 0) if (_xcb_do_connect(fd, addr->ai_addr, addr->ai_addrlen) >= 0)
break; break;
#ifdef _WIN32
closesocket(fd);
#else
close(fd); close(fd);
#endif
fd = -1; fd = -1;
} }
freeaddrinfo(results); freeaddrinfo(results);
@ -559,8 +528,10 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
if(auth) { if(auth) {
c = xcb_connect_to_fd(fd, auth); c = xcb_connect_to_fd(fd, auth);
goto out;
} }
else if(_xcb_get_auth_info(fd, &ourauth, display))
if(_xcb_get_auth_info(fd, &ourauth, display))
{ {
c = xcb_connect_to_fd(fd, &ourauth); c = xcb_connect_to_fd(fd, &ourauth);
free(ourauth.name); free(ourauth.name);

View File

@ -297,7 +297,6 @@ int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xc
* @param replylen The size of the reply. * @param replylen The size of the reply.
* @return Pointer to the location where received file descriptors are stored. * @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); int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t replylen);
@ -307,7 +306,6 @@ int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t replylen);
* @param mask The mask to check * @param mask The mask to check
* @return The number of set bits in the mask * @return The number of set bits in the mask
*/ */
XCB_CONST_FUNCTION
int xcb_popcount(uint32_t mask); int xcb_popcount(uint32_t mask);
/** /**
@ -315,7 +313,6 @@ int xcb_popcount(uint32_t mask);
* @param len The length of the array * @param len The length of the array
* @return The sum of all entries in the array. * @return The sum of all entries in the array.
*/ */
XCB_PURE_FUNCTION
int xcb_sumof(uint8_t *list, int len); int xcb_sumof(uint8_t *list, int len);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -225,7 +225,6 @@ struct xcb_connection_t {
void _xcb_conn_shutdown(xcb_connection_t *c, int err); void _xcb_conn_shutdown(xcb_connection_t *c, int err);
XCB_CONST_FUNCTION
xcb_connection_t *_xcb_conn_ret_error(int err); 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); int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count);

View File

@ -1,10 +1,6 @@
#include <check.h> #include <check.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef __unix__
#include <unistd.h>
#endif
#include "check_suites.h" #include "check_suites.h"
#include "xcb.h" #include "xcb.h"
#include "xcbext.h" #include "xcbext.h"
@ -16,10 +12,6 @@ typedef enum test_type_t {
} test_type_t; } test_type_t;
static const char *const test_string[] = { "", "via $DISPLAY " }; 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) static void parse_display_pass(const char *name, const char *host, const int display, const int screen)
{ {
int success; int success;
@ -33,7 +25,7 @@ static void parse_display_pass(const char *name, const char *host, const int dis
if(test_type == TEST_ARGUMENT) if(test_type == TEST_ARGUMENT)
{ {
argument = name; argument = name;
putenv(display_env); putenv("DISPLAY=");
} }
else if(test_type == TEST_ENVIRONMENT) else if(test_type == TEST_ENVIRONMENT)
{ {
@ -58,7 +50,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(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); 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_env); putenv("DISPLAY=");
} }
static void parse_display_fail(const char *name) static void parse_display_fail(const char *name)
@ -74,7 +66,7 @@ static void parse_display_fail(const char *name)
if(test_type == TEST_ARGUMENT) if(test_type == TEST_ARGUMENT)
{ {
argument = name; argument = name;
putenv(display_env); putenv("DISPLAY=");
} }
else if(test_type == TEST_ENVIRONMENT) else if(test_type == TEST_ENVIRONMENT)
{ {
@ -100,42 +92,11 @@ 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_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_display == -42, "display changed on parse failure %sfor '%s': got %d", test_string[test_type], name, got_display);
} }
putenv(display_env); putenv("DISPLAY=");
} }
START_TEST(parse_display_unix) 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(":0", "", 0, 0);
parse_display_pass(":1", "", 1, 0); parse_display_pass(":1", "", 1, 0);
parse_display_pass(":0.1", "", 0, 1); parse_display_pass(":0.1", "", 0, 1);
@ -245,7 +206,7 @@ END_TEST
Suite *public_suite(void) Suite *public_suite(void)
{ {
Suite *s = suite_create("Public API"); Suite *s = suite_create("Public API");
putenv(display_env); putenv("DISPLAY=");
suite_add_test(s, parse_display_unix, "xcb_parse_display unix"); 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_ip, "xcb_parse_display ip");
suite_add_test(s, parse_display_ipv4, "xcb_parse_display ipv4"); suite_add_test(s, parse_display_ipv4, "xcb_parse_display ipv4");

View File

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