summaryrefslogtreecommitdiff
path: root/xserver/Xext
diff options
context:
space:
mode:
Diffstat (limited to 'xserver/Xext')
-rw-r--r--xserver/Xext/Makefile.am42
-rw-r--r--xserver/Xext/Makefile.in139
-rw-r--r--xserver/Xext/bigreq.c19
-rw-r--r--xserver/Xext/dpms.c67
-rw-r--r--xserver/Xext/geext.c21
-rw-r--r--xserver/Xext/geext.h2
-rw-r--r--xserver/Xext/hashtable.c295
-rw-r--r--xserver/Xext/hashtable.h137
-rw-r--r--xserver/Xext/panoramiX.c106
-rw-r--r--xserver/Xext/panoramiXprocs.c47
-rw-r--r--xserver/Xext/saver.c68
-rw-r--r--xserver/Xext/security.c44
-rw-r--r--xserver/Xext/shape.c83
-rw-r--r--xserver/Xext/shm.c93
-rw-r--r--xserver/Xext/sync.c368
-rw-r--r--xserver/Xext/syncsrv.h56
-rw-r--r--xserver/Xext/xace.c12
-rw-r--r--xserver/Xext/xcmisc.c46
-rw-r--r--xserver/Xext/xf86bigfont.c52
-rw-r--r--xserver/Xext/xf86bigfontsrv.h1
-rw-r--r--xserver/Xext/xres.c899
-rw-r--r--xserver/Xext/xselinux_ext.c46
-rw-r--r--xserver/Xext/xtest.c51
-rw-r--r--xserver/Xext/xvdisp.c186
-rw-r--r--xserver/Xext/xvdix.h8
-rw-r--r--xserver/Xext/xvmain.c35
-rw-r--r--xserver/Xext/xvmc.c137
-rw-r--r--xserver/Xext/xvmcext.h4
28 files changed, 2184 insertions, 880 deletions
diff --git a/xserver/Xext/Makefile.am b/xserver/Xext/Makefile.am
index cb432e00e..8e31f1367 100644
--- a/xserver/Xext/Makefile.am
+++ b/xserver/Xext/Makefile.am
@@ -1,16 +1,4 @@
-# libXext.la: includes all extensions and should be linked into Xvfb,
-# Xnest, Xdmx and Xprt
-# libXextbuiltin.la: includes those extensions that are built directly into
-# Xorg by default
-# libXextmodule.la: includes those extensions that are built into a module
-# that Xorg loads
-if XORG
-noinst_LTLIBRARIES = libXext.la libXextbuiltin.la libXextmodule.la
-else
noinst_LTLIBRARIES = libXext.la
-endif
-
-INCLUDES = -I$(top_srcdir)/hw/xfree86/dixmods/extmod
AM_CFLAGS = $(DIX_CFLAGS)
@@ -30,10 +18,7 @@ BUILTIN_SRCS = \
syncsrv.h \
xcmisc.c \
xtest.c
-
-# Sources always included in libXextmodule.la & libXext.la. That's right, zero.
-MODULE_SRCS =
-MODULE_LIBS =
+BUILTIN_LIBS =
# Optional sources included if extension enabled by configure.ac rules
@@ -46,19 +31,19 @@ endif
# XVideo extension
XV_SRCS = xvmain.c xvdisp.c xvmc.c xvdix.h xvmcext.h xvdisp.h
if XV
-MODULE_SRCS += $(XV_SRCS)
+BUILTIN_SRCS += $(XV_SRCS)
endif
# XResource extension: lets clients get data about per-client resource usage
-RES_SRCS = xres.c
+RES_SRCS = hashtable.c hashtable.h xres.c
if RES
-MODULE_SRCS += $(RES_SRCS)
+BUILTIN_SRCS += $(RES_SRCS)
endif
# MIT ScreenSaver extension
SCREENSAVER_SRCS = saver.c
if SCREENSAVER
-MODULE_SRCS += $(SCREENSAVER_SRCS)
+BUILTIN_SRCS += $(SCREENSAVER_SRCS)
endif
# Xinerama extension: making multiple video devices act as one virtual screen
@@ -84,8 +69,8 @@ endif
# requires X-ACE extension
XSELINUX_SRCS = xselinux_ext.c xselinux_hooks.c xselinux_label.c xselinux.h xselinuxint.h
if XSELINUX
-MODULE_SRCS += $(XSELINUX_SRCS)
-MODULE_LIBS += $(SELINUX_LIBS)
+BUILTIN_SRCS += $(XSELINUX_SRCS)
+BUILTIN_LIBS += $(SELINUX_LIBS)
endif
# Security extension: multi-level security to protect clients from each other
@@ -103,20 +88,13 @@ endif
# DPMS extension
DPMS_SRCS = dpms.c dpmsproc.h
if DPMSExtension
-MODULE_SRCS += $(DPMS_SRCS)
+BUILTIN_SRCS += $(DPMS_SRCS)
endif
# Now take all of the above, mix well, bake for 10 minutes and get libXext*.la
-libXext_la_SOURCES = $(BUILTIN_SRCS) $(MODULE_SRCS)
-libXext_la_LIBADD = $(MODULE_LIBS)
-
-if XORG
-libXextbuiltin_la_SOURCES = $(BUILTIN_SRCS)
-
-libXextmodule_la_SOURCES = $(MODULE_SRCS)
-libXextmodule_la_LIBADD = $(MODULE_LIBS)
-endif
+libXext_la_SOURCES = $(BUILTIN_SRCS)
+libXext_la_LIBADD = $(BUILTIN_LIBS)
EXTRA_DIST = \
$(MITSHM_SRCS) \
diff --git a/xserver/Xext/Makefile.in b/xserver/Xext/Makefile.in
index 0a36da66a..d1d666af1 100644
--- a/xserver/Xext/Makefile.in
+++ b/xserver/Xext/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.12.3 from Makefile.am.
+# Makefile.in generated by automake 1.12.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2012 Free Software Foundation, Inc.
@@ -93,63 +93,43 @@ am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2)
libXext_la_DEPENDENCIES = $(am__DEPENDENCIES_3)
am__libXext_la_SOURCES_DIST = bigreq.c geext.c shape.c sleepuntil.c \
sleepuntil.h sync.c syncsdk.h syncsrv.h xcmisc.c xtest.c shm.c \
- shmint.h panoramiX.c panoramiX.h panoramiXh.h panoramiXsrv.h \
- panoramiXprocs.c panoramiXSwap.c xace.c xace.h xacestr.h \
- security.c securitysrv.h xf86bigfont.c xf86bigfontsrv.h \
- xvmain.c xvdisp.c xvmc.c xvdix.h xvmcext.h xvdisp.h xres.c \
- saver.c xselinux_ext.c xselinux_hooks.c xselinux_label.c \
- xselinux.h xselinuxint.h dpms.c dpmsproc.h
+ shmint.h xvmain.c xvdisp.c xvmc.c xvdix.h xvmcext.h xvdisp.h \
+ hashtable.c hashtable.h xres.c saver.c panoramiX.c panoramiX.h \
+ panoramiXh.h panoramiXsrv.h panoramiXprocs.c panoramiXSwap.c \
+ xace.c xace.h xacestr.h xselinux_ext.c xselinux_hooks.c \
+ xselinux_label.c xselinux.h xselinuxint.h security.c \
+ securitysrv.h xf86bigfont.c xf86bigfontsrv.h dpms.c dpmsproc.h
am__objects_1 = shm.lo
@MITSHM_TRUE@am__objects_2 = $(am__objects_1)
-am__objects_3 = panoramiX.lo panoramiXprocs.lo panoramiXSwap.lo
-@XINERAMA_TRUE@am__objects_4 = $(am__objects_3)
-am__objects_5 = xace.lo
-@XACE_TRUE@am__objects_6 = $(am__objects_5)
-am__objects_7 = security.lo
-@XCSECURITY_TRUE@am__objects_8 = $(am__objects_7)
-am__objects_9 = xf86bigfont.lo
-@XF86BIGFONT_TRUE@am__objects_10 = $(am__objects_9)
-am__objects_11 = bigreq.lo geext.lo shape.lo sleepuntil.lo sync.lo \
+am__objects_3 = xvmain.lo xvdisp.lo xvmc.lo
+@XV_TRUE@am__objects_4 = $(am__objects_3)
+am__objects_5 = hashtable.lo xres.lo
+@RES_TRUE@am__objects_6 = $(am__objects_5)
+am__objects_7 = saver.lo
+@SCREENSAVER_TRUE@am__objects_8 = $(am__objects_7)
+am__objects_9 = panoramiX.lo panoramiXprocs.lo panoramiXSwap.lo
+@XINERAMA_TRUE@am__objects_10 = $(am__objects_9)
+am__objects_11 = xace.lo
+@XACE_TRUE@am__objects_12 = $(am__objects_11)
+am__objects_13 = xselinux_ext.lo xselinux_hooks.lo xselinux_label.lo
+@XSELINUX_TRUE@am__objects_14 = $(am__objects_13)
+am__objects_15 = security.lo
+@XCSECURITY_TRUE@am__objects_16 = $(am__objects_15)
+am__objects_17 = xf86bigfont.lo
+@XF86BIGFONT_TRUE@am__objects_18 = $(am__objects_17)
+am__objects_19 = dpms.lo
+@DPMSExtension_TRUE@am__objects_20 = $(am__objects_19)
+am__objects_21 = bigreq.lo geext.lo shape.lo sleepuntil.lo sync.lo \
xcmisc.lo xtest.lo $(am__objects_2) $(am__objects_4) \
- $(am__objects_6) $(am__objects_8) $(am__objects_10)
-am__objects_12 = xvmain.lo xvdisp.lo xvmc.lo
-@XV_TRUE@am__objects_13 = $(am__objects_12)
-am__objects_14 = xres.lo
-@RES_TRUE@am__objects_15 = $(am__objects_14)
-am__objects_16 = saver.lo
-@SCREENSAVER_TRUE@am__objects_17 = $(am__objects_16)
-am__objects_18 = xselinux_ext.lo xselinux_hooks.lo xselinux_label.lo
-@XSELINUX_TRUE@am__objects_19 = $(am__objects_18)
-am__objects_20 = dpms.lo
-@DPMSExtension_TRUE@am__objects_21 = $(am__objects_20)
-am__objects_22 = $(am__objects_13) $(am__objects_15) $(am__objects_17) \
- $(am__objects_19) $(am__objects_21)
-am_libXext_la_OBJECTS = $(am__objects_11) $(am__objects_22)
+ $(am__objects_6) $(am__objects_8) $(am__objects_10) \
+ $(am__objects_12) $(am__objects_14) $(am__objects_16) \
+ $(am__objects_18) $(am__objects_20)
+am_libXext_la_OBJECTS = $(am__objects_21)
libXext_la_OBJECTS = $(am_libXext_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
-@XORG_FALSE@am_libXext_la_rpath =
-@XORG_TRUE@am_libXext_la_rpath =
-libXextbuiltin_la_LIBADD =
-am__libXextbuiltin_la_SOURCES_DIST = bigreq.c geext.c shape.c \
- sleepuntil.c sleepuntil.h sync.c syncsdk.h syncsrv.h xcmisc.c \
- xtest.c shm.c shmint.h panoramiX.c panoramiX.h panoramiXh.h \
- panoramiXsrv.h panoramiXprocs.c panoramiXSwap.c xace.c xace.h \
- xacestr.h security.c securitysrv.h xf86bigfont.c \
- xf86bigfontsrv.h
-@XORG_TRUE@am_libXextbuiltin_la_OBJECTS = $(am__objects_11)
-libXextbuiltin_la_OBJECTS = $(am_libXextbuiltin_la_OBJECTS)
-@XORG_TRUE@am_libXextbuiltin_la_rpath =
-@XORG_TRUE@libXextmodule_la_DEPENDENCIES = $(am__DEPENDENCIES_3)
-am__libXextmodule_la_SOURCES_DIST = xvmain.c xvdisp.c xvmc.c xvdix.h \
- xvmcext.h xvdisp.h xres.c saver.c xselinux_ext.c \
- xselinux_hooks.c xselinux_label.c xselinux.h xselinuxint.h \
- dpms.c dpmsproc.h
-@XORG_TRUE@am_libXextmodule_la_OBJECTS = $(am__objects_22)
-libXextmodule_la_OBJECTS = $(am_libXextmodule_la_OBJECTS)
-@XORG_TRUE@am_libXextmodule_la_rpath =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -184,11 +164,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = $(libXext_la_SOURCES) $(libXextbuiltin_la_SOURCES) \
- $(libXextmodule_la_SOURCES)
-DIST_SOURCES = $(am__libXext_la_SOURCES_DIST) \
- $(am__libXextbuiltin_la_SOURCES_DIST) \
- $(am__libXextmodule_la_SOURCES_DIST)
+SOURCES = $(libXext_la_SOURCES)
+DIST_SOURCES = $(am__libXext_la_SOURCES_DIST)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -285,13 +262,9 @@ DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
DOXYGEN = @DOXYGEN@
DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
-DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
-DRIPROTO_LIBS = @DRIPROTO_LIBS@
DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
-DRI_CFLAGS = @DRI_CFLAGS@
DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
-DRI_LIBS = @DRI_LIBS@
DSYMUTIL = @DSYMUTIL@
DTRACE = @DTRACE@
DUMPBIN = @DUMPBIN@
@@ -313,6 +286,7 @@ FONTTYPE1DIR = @FONTTYPE1DIR@
FOP = @FOP@
GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
GLX_DEFINES = @GLX_DEFINES@
+GLX_SYS_LIBS = @GLX_SYS_LIBS@
GLX_TLS = @GLX_TLS@
GL_CFLAGS = @GL_CFLAGS@
GL_LIBS = @GL_LIBS@
@@ -337,6 +311,7 @@ KHRONOS_SPEC_DIR = @KHRONOS_SPEC_DIR@
LD = @LD@
LDFLAGS = @LDFLAGS@
LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LD_NO_UNDEFINED_FLAG = @LD_NO_UNDEFINED_FLAG@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
@@ -352,7 +327,6 @@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
MAIN_LIB = @MAIN_LIB@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
@@ -451,6 +425,7 @@ XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
XNEST_LIBS = @XNEST_LIBS@
XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
XORG_CFLAGS = @XORG_CFLAGS@
+XORG_DRIVER_LIBS = @XORG_DRIVER_LIBS@
XORG_INCS = @XORG_INCS@
XORG_LIBS = @XORG_LIBS@
XORG_MALLOC_DEBUG_ENV = @XORG_MALLOC_DEBUG_ENV@
@@ -550,16 +525,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-@XORG_FALSE@noinst_LTLIBRARIES = libXext.la
-
-# libXext.la: includes all extensions and should be linked into Xvfb,
-# Xnest, Xdmx and Xprt
-# libXextbuiltin.la: includes those extensions that are built directly into
-# Xorg by default
-# libXextmodule.la: includes those extensions that are built into a module
-# that Xorg loads
-@XORG_TRUE@noinst_LTLIBRARIES = libXext.la libXextbuiltin.la libXextmodule.la
-INCLUDES = -I$(top_srcdir)/hw/xfree86/dixmods/extmod
+noinst_LTLIBRARIES = libXext.la
AM_CFLAGS = $(DIX_CFLAGS)
@XORG_TRUE@sdk_HEADERS = xvdix.h xvmcext.h geext.h geint.h shmint.h \
@XORG_TRUE@ syncsdk.h $(am__append_6) $(am__append_8)
@@ -567,13 +533,10 @@ AM_CFLAGS = $(DIX_CFLAGS)
# Sources always included in libXextbuiltin.la & libXext.la
BUILTIN_SRCS = bigreq.c geext.c shape.c sleepuntil.c sleepuntil.h \
sync.c syncsdk.h syncsrv.h xcmisc.c xtest.c $(am__append_1) \
- $(am__append_5) $(am__append_7) $(am__append_11) \
- $(am__append_12)
-
-# Sources always included in libXextmodule.la & libXext.la. That's right, zero.
-MODULE_SRCS = $(am__append_2) $(am__append_3) $(am__append_4) \
- $(am__append_9) $(am__append_13)
-MODULE_LIBS = $(am__append_10)
+ $(am__append_2) $(am__append_3) $(am__append_4) \
+ $(am__append_5) $(am__append_7) $(am__append_9) \
+ $(am__append_11) $(am__append_12) $(am__append_13)
+BUILTIN_LIBS = $(am__append_10)
# Optional sources included if extension enabled by configure.ac rules
@@ -584,7 +547,7 @@ MITSHM_SRCS = shm.c shmint.h
XV_SRCS = xvmain.c xvdisp.c xvmc.c xvdix.h xvmcext.h xvdisp.h
# XResource extension: lets clients get data about per-client resource usage
-RES_SRCS = xres.c
+RES_SRCS = hashtable.c hashtable.h xres.c
# MIT ScreenSaver extension
SCREENSAVER_SRCS = saver.c
@@ -610,11 +573,8 @@ BIGFONT_SRCS = xf86bigfont.c xf86bigfontsrv.h
DPMS_SRCS = dpms.c dpmsproc.h
# Now take all of the above, mix well, bake for 10 minutes and get libXext*.la
-libXext_la_SOURCES = $(BUILTIN_SRCS) $(MODULE_SRCS)
-libXext_la_LIBADD = $(MODULE_LIBS)
-@XORG_TRUE@libXextbuiltin_la_SOURCES = $(BUILTIN_SRCS)
-@XORG_TRUE@libXextmodule_la_SOURCES = $(MODULE_SRCS)
-@XORG_TRUE@libXextmodule_la_LIBADD = $(MODULE_LIBS)
+libXext_la_SOURCES = $(BUILTIN_SRCS)
+libXext_la_LIBADD = $(BUILTIN_LIBS)
EXTRA_DIST = \
$(MITSHM_SRCS) \
$(XV_SRCS) \
@@ -632,7 +592,7 @@ all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@@ -657,9 +617,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
@@ -674,11 +634,7 @@ clean-noinstLTLIBRARIES:
rm -f $${locs}; \
}
libXext.la: $(libXext_la_OBJECTS) $(libXext_la_DEPENDENCIES) $(EXTRA_libXext_la_DEPENDENCIES)
- $(AM_V_CCLD)$(LINK) $(am_libXext_la_rpath) $(libXext_la_OBJECTS) $(libXext_la_LIBADD) $(LIBS)
-libXextbuiltin.la: $(libXextbuiltin_la_OBJECTS) $(libXextbuiltin_la_DEPENDENCIES) $(EXTRA_libXextbuiltin_la_DEPENDENCIES)
- $(AM_V_CCLD)$(LINK) $(am_libXextbuiltin_la_rpath) $(libXextbuiltin_la_OBJECTS) $(libXextbuiltin_la_LIBADD) $(LIBS)
-libXextmodule.la: $(libXextmodule_la_OBJECTS) $(libXextmodule_la_DEPENDENCIES) $(EXTRA_libXextmodule_la_DEPENDENCIES)
- $(AM_V_CCLD)$(LINK) $(am_libXextmodule_la_rpath) $(libXextmodule_la_OBJECTS) $(libXextmodule_la_LIBADD) $(LIBS)
+ $(AM_V_CCLD)$(LINK) $(libXext_la_OBJECTS) $(libXext_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -689,6 +645,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bigreq.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dpms.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geext.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hashtable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/panoramiX.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/panoramiXSwap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/panoramiXprocs.Plo@am__quote@
diff --git a/xserver/Xext/bigreq.c b/xserver/Xext/bigreq.c
index 49355c4a4..c78a1e4b4 100644
--- a/xserver/Xext/bigreq.c
+++ b/xserver/Xext/bigreq.c
@@ -38,9 +38,7 @@ from The Open Group.
#include "extnsionst.h"
#include <X11/extensions/bigreqsproto.h>
#include "opaque.h"
-#include "modinit.h"
-
-void BigReqExtensionInit(INITARGS);
+#include "extinit.h"
static int
ProcBigReqDispatch(ClientPtr client)
@@ -55,21 +53,22 @@ ProcBigReqDispatch(ClientPtr client)
return BadRequest;
REQUEST_SIZE_MATCH(xBigReqEnableReq);
client->big_requests = TRUE;
- memset(&rep, 0, sizeof(xBigReqEnableReply));
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.max_request_size = maxBigRequestSize;
+ rep = (xBigReqEnableReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .max_request_size = maxBigRequestSize
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.max_request_size);
}
- WriteToClient(client, sizeof(xBigReqEnableReply), (char *) &rep);
+ WriteToClient(client, sizeof(xBigReqEnableReply), &rep);
return Success;
}
void
-BigReqExtensionInit(INITARGS)
+BigReqExtensionInit(void)
{
AddExtension(XBigReqExtensionName, 0, 0,
ProcBigReqDispatch, ProcBigReqDispatch,
diff --git a/xserver/Xext/dpms.c b/xserver/Xext/dpms.c
index 348c87289..5f1a35d9c 100644
--- a/xserver/Xext/dpms.c
+++ b/xserver/Xext/dpms.c
@@ -39,27 +39,28 @@ Equipment Corporation.
#include "opaque.h"
#include <X11/extensions/dpmsproto.h>
#include "dpmsproc.h"
-#include "modinit.h"
+#include "extinit.h"
static int
ProcDPMSGetVersion(ClientPtr client)
{
/* REQUEST(xDPMSGetVersionReq); */
- xDPMSGetVersionReply rep;
+ xDPMSGetVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = DPMSMajorVersion,
+ .minorVersion = DPMSMinorVersion
+ };
REQUEST_SIZE_MATCH(xDPMSGetVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = DPMSMajorVersion;
- rep.minorVersion = DPMSMinorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
- WriteToClient(client, sizeof(xDPMSGetVersionReply), (char *) &rep);
+ WriteToClient(client, sizeof(xDPMSGetVersionReply), &rep);
return Success;
}
@@ -67,19 +68,19 @@ static int
ProcDPMSCapable(ClientPtr client)
{
/* REQUEST(xDPMSCapableReq); */
- xDPMSCapableReply rep;
+ xDPMSCapableReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .capable = DPMSCapableFlag
+ };
REQUEST_SIZE_MATCH(xDPMSCapableReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.capable = DPMSCapableFlag;
-
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
- WriteToClient(client, sizeof(xDPMSCapableReply), (char *) &rep);
+ WriteToClient(client, sizeof(xDPMSCapableReply), &rep);
return Success;
}
@@ -87,24 +88,24 @@ static int
ProcDPMSGetTimeouts(ClientPtr client)
{
/* REQUEST(xDPMSGetTimeoutsReq); */
- xDPMSGetTimeoutsReply rep;
+ xDPMSGetTimeoutsReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .standby = DPMSStandbyTime / MILLI_PER_SECOND,
+ .suspend = DPMSSuspendTime / MILLI_PER_SECOND,
+ .off = DPMSOffTime / MILLI_PER_SECOND
+ };
REQUEST_SIZE_MATCH(xDPMSGetTimeoutsReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.standby = DPMSStandbyTime / MILLI_PER_SECOND;
- rep.suspend = DPMSSuspendTime / MILLI_PER_SECOND;
- rep.off = DPMSOffTime / MILLI_PER_SECOND;
-
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.standby);
swaps(&rep.suspend);
swaps(&rep.off);
}
- WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), (char *) &rep);
+ WriteToClient(client, sizeof(xDPMSGetTimeoutsReply), &rep);
return Success;
}
@@ -188,21 +189,21 @@ static int
ProcDPMSInfo(ClientPtr client)
{
/* REQUEST(xDPMSInfoReq); */
- xDPMSInfoReply rep;
+ xDPMSInfoReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .power_level = DPMSPowerLevel,
+ .state = DPMSEnabled
+ };
REQUEST_SIZE_MATCH(xDPMSInfoReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.power_level = DPMSPowerLevel;
- rep.state = DPMSEnabled;
-
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.power_level);
}
- WriteToClient(client, sizeof(xDPMSInfoReply), (char *) &rep);
+ WriteToClient(client, sizeof(xDPMSInfoReply), &rep);
return Success;
}
@@ -354,7 +355,7 @@ SProcDPMSDispatch(ClientPtr client)
}
void
-DPMSExtensionInit(INITARGS)
+DPMSExtensionInit(void)
{
AddExtension(DPMSExtensionName, 0, 0,
ProcDPMSDispatch, SProcDPMSDispatch,
diff --git a/xserver/Xext/geext.c b/xserver/Xext/geext.c
index 07028238e..1e5ae6f82 100644
--- a/xserver/Xext/geext.c
+++ b/xserver/Xext/geext.c
@@ -32,11 +32,10 @@
#include "geint.h"
#include "geext.h"
#include "protocol-versions.h"
+#include "extinit.h"
DevPrivateKeyRec GEClientPrivateKeyRec;
-int RT_GECLIENT = 0;
-
GEExtension GEExtensions[MAXEXTENSIONS];
/* Major available requests */
@@ -65,14 +64,16 @@ ProcGEQueryVersion(ClientPtr client)
REQUEST_SIZE_MATCH(xGEQueryVersionReq);
- rep.repType = X_Reply;
- rep.RepType = X_GEQueryVersion;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
+ rep = (xGEQueryVersionReply) {
+ .repType = X_Reply,
+ .RepType = X_GEQueryVersion,
+ .sequenceNumber = client->sequence,
+ .length = 0,
- /* return the supported version by the server */
- rep.majorVersion = SERVER_GE_MAJOR_VERSION;
- rep.minorVersion = SERVER_GE_MINOR_VERSION;
+ /* return the supported version by the server */
+ .majorVersion = SERVER_GE_MAJOR_VERSION,
+ .minorVersion = SERVER_GE_MINOR_VERSION
+ };
/* Remember version the client requested */
pGEClient->major_version = stuff->majorVersion;
@@ -85,7 +86,7 @@ ProcGEQueryVersion(ClientPtr client)
swaps(&rep.minorVersion);
}
- WriteToClient(client, sizeof(xGEQueryVersionReply), (char *) &rep);
+ WriteToClient(client, sizeof(xGEQueryVersionReply), &rep);
return Success;
}
diff --git a/xserver/Xext/geext.h b/xserver/Xext/geext.h
index d2a15dcb9..f46897966 100644
--- a/xserver/Xext/geext.h
+++ b/xserver/Xext/geext.h
@@ -78,6 +78,4 @@ extern _X_EXPORT void GERegisterExtension(int extension,
extern _X_EXPORT void GEInitEvent(xGenericEvent *ev, int extension);
-extern _X_EXPORT void GEExtensionInit(void);
-
#endif /* _GEEXT_H_ */
diff --git a/xserver/Xext/hashtable.c b/xserver/Xext/hashtable.c
new file mode 100644
index 000000000..9d9ef8949
--- /dev/null
+++ b/xserver/Xext/hashtable.c
@@ -0,0 +1,295 @@
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdlib.h>
+#include "misc.h"
+#include "hashtable.h"
+
+/* HashResourceID */
+#include "resource.h"
+
+#define INITHASHSIZE 6
+#define MAXHASHSIZE 11
+
+struct HashTableRec {
+ int keySize;
+ int dataSize;
+
+ int elements; /* number of elements inserted */
+ int bucketBits; /* number of buckets is 1 << bucketBits */
+ struct xorg_list *buckets; /* array of bucket list heads */
+
+ HashFunc hash;
+ HashCompareFunc compare;
+
+ pointer cdata;
+};
+
+typedef struct {
+ struct xorg_list l;
+ void *key;
+ void *data;
+} BucketRec, *BucketPtr;
+
+HashTable
+ht_create(int keySize,
+ int dataSize,
+ HashFunc hash,
+ HashCompareFunc compare,
+ pointer cdata)
+{
+ int c;
+ int numBuckets;
+ HashTable ht = malloc(sizeof(struct HashTableRec));
+
+ if (!ht) {
+ return NULL;
+ }
+
+ ht->keySize = keySize;
+ ht->dataSize = dataSize;
+ ht->hash = hash;
+ ht->compare = compare;
+ ht->elements = 0;
+ ht->bucketBits = INITHASHSIZE;
+ numBuckets = 1 << ht->bucketBits;
+ ht->buckets = malloc(numBuckets * sizeof(*ht->buckets));
+ ht->cdata = cdata;
+
+ if (ht->buckets) {
+ for (c = 0; c < numBuckets; ++c) {
+ xorg_list_init(&ht->buckets[c]);
+ }
+ return ht;
+ } else {
+ free(ht);
+ return NULL;
+ }
+}
+
+void
+ht_destroy(HashTable ht)
+{
+ int c;
+ BucketPtr it, tmp;
+ int numBuckets = 1 << ht->bucketBits;
+ for (c = 0; c < numBuckets; ++c) {
+ xorg_list_for_each_entry_safe(it, tmp, &ht->buckets[c], l) {
+ xorg_list_del(&it->l);
+ free(it);
+ }
+ }
+ free(ht->buckets);
+}
+
+static Bool
+double_size(HashTable ht)
+{
+ struct xorg_list *newBuckets;
+ int numBuckets = 1 << ht->bucketBits;
+ int newBucketBits = ht->bucketBits + 1;
+ int newNumBuckets = 1 << newBucketBits;
+ int c;
+
+ newBuckets = malloc(newNumBuckets * sizeof(*ht->buckets));
+ if (newBuckets) {
+ for (c = 0; c < newNumBuckets; ++c) {
+ xorg_list_init(&newBuckets[c]);
+ }
+
+ for (c = 0; c < numBuckets; ++c) {
+ BucketPtr it, tmp;
+ xorg_list_for_each_entry_safe(it, tmp, &ht->buckets[c], l) {
+ struct xorg_list *newBucket =
+ &newBuckets[ht->hash(ht->cdata, it->key, newBucketBits)];
+ xorg_list_del(&it->l);
+ xorg_list_add(&it->l, newBucket);
+ }
+ }
+ free(ht->buckets);
+
+ ht->buckets = newBuckets;
+ ht->bucketBits = newBucketBits;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+pointer
+ht_add(HashTable ht, pointer key)
+{
+ unsigned index = ht->hash(ht->cdata, key, ht->bucketBits);
+ struct xorg_list *bucket = &ht->buckets[index];
+ BucketRec *elem = calloc(1, sizeof(BucketRec));
+ if (!elem) {
+ goto outOfMemory;
+ }
+ elem->key = malloc(ht->keySize);
+ if (!elem->key) {
+ goto outOfMemory;
+ }
+ /* we avoid signaling an out-of-memory error if dataSize is 0 */
+ elem->data = calloc(1, ht->dataSize);
+ if (ht->dataSize && !elem->data) {
+ goto outOfMemory;
+ }
+ xorg_list_add(&elem->l, bucket);
+ ++ht->elements;
+
+ memcpy(elem->key, key, ht->keySize);
+
+ if (ht->elements > 4 * (1 << ht->bucketBits) &&
+ ht->bucketBits < MAXHASHSIZE) {
+ if (!double_size(ht)) {
+ --ht->elements;
+ xorg_list_del(&elem->l);
+ goto outOfMemory;
+ }
+ }
+
+ /* if memory allocation has failed due to dataSize being 0, return
+ a "dummy" pointer pointing at the of the key */
+ return elem->data ? elem->data : ((char*) elem->key + ht->keySize);
+
+ outOfMemory:
+ if (elem) {
+ free(elem->key);
+ free(elem->data);
+ free(elem);
+ }
+
+ return NULL;
+}
+
+void
+ht_remove(HashTable ht, pointer key)
+{
+ unsigned index = ht->hash(ht->cdata, key, ht->bucketBits);
+ struct xorg_list *bucket = &ht->buckets[index];
+ BucketPtr it;
+
+ xorg_list_for_each_entry(it, bucket, l) {
+ if (ht->compare(ht->cdata, key, it->key) == 0) {
+ xorg_list_del(&it->l);
+ --ht->elements;
+ free(it->key);
+ free(it->data);
+ free(it);
+ return;
+ }
+ }
+}
+
+pointer
+ht_find(HashTable ht, pointer key)
+{
+ unsigned index = ht->hash(ht->cdata, key, ht->bucketBits);
+ struct xorg_list *bucket = &ht->buckets[index];
+ BucketPtr it;
+
+ xorg_list_for_each_entry(it, bucket, l) {
+ if (ht->compare(ht->cdata, key, it->key) == 0) {
+ return it->data ? it->data : ((char*) it->key + ht->keySize);
+ }
+ }
+
+ return NULL;
+}
+
+void
+ht_dump_distribution(HashTable ht)
+{
+ int c;
+ int numBuckets = 1 << ht->bucketBits;
+ for (c = 0; c < numBuckets; ++c) {
+ BucketPtr it;
+ int n = 0;
+
+ xorg_list_for_each_entry(it, &ht->buckets[c], l) {
+ ++n;
+ }
+ printf("%d: %d\n", c, n);
+ }
+}
+
+/* Picked the function from http://burtleburtle.net/bob/hash/doobs.html by
+ Bob Jenkins, which is released in public domain */
+static CARD32
+one_at_a_time_hash(const void *data, int len)
+{
+ CARD32 hash;
+ int i;
+ const char *key = data;
+ for (hash=0, i=0; i<len; ++i) {
+ hash += key[i];
+ hash += (hash << 10);
+ hash ^= (hash >> 6);
+ }
+ hash += (hash << 3);
+ hash ^= (hash >> 11);
+ hash += (hash << 15);
+ return hash;
+}
+
+unsigned
+ht_generic_hash(void *cdata, const void *ptr, int numBits)
+{
+ HtGenericHashSetupPtr setup = cdata;
+ return one_at_a_time_hash(ptr, setup->keySize) & ~((~0) << numBits);
+}
+
+int
+ht_generic_compare(void *cdata, const void *l, const void *r)
+{
+ HtGenericHashSetupPtr setup = cdata;
+ return memcmp(l, r, setup->keySize);
+}
+
+unsigned
+ht_resourceid_hash(void * cdata, const void * data, int numBits)
+{
+ const XID* idPtr = data;
+ XID id = *idPtr & RESOURCE_ID_MASK;
+ (void) cdata;
+ return HashResourceID(id, numBits);
+}
+
+int
+ht_resourceid_compare(void* cdata, const void* a, const void* b)
+{
+ const XID* xa = a;
+ const XID* xb = b;
+ (void) cdata;
+ return
+ *xa < *xb ? -1 :
+ *xa > *xb ? 1 :
+ 0;
+}
+
+void
+ht_dump_contents(HashTable ht,
+ void (*print_key)(void *opaque, void *key),
+ void (*print_value)(void *opaque, void *value),
+ void* opaque)
+{
+ int c;
+ int numBuckets = 1 << ht->bucketBits;
+ for (c = 0; c < numBuckets; ++c) {
+ BucketPtr it;
+ int n = 0;
+
+ printf("%d: ", c);
+ xorg_list_for_each_entry(it, &ht->buckets[c], l) {
+ if (n > 0) {
+ printf(", ");
+ }
+ print_key(opaque, it->key);
+ printf("->");
+ print_value(opaque, it->data);
+ ++n;
+ }
+ printf("\n");
+ }
+}
diff --git a/xserver/Xext/hashtable.h b/xserver/Xext/hashtable.h
new file mode 100644
index 000000000..5d1598425
--- /dev/null
+++ b/xserver/Xext/hashtable.h
@@ -0,0 +1,137 @@
+#ifndef HASHTABLE_H
+#define HASHTABLE_H 1
+
+#include <dix-config.h>
+#include <X11/Xfuncproto.h>
+#include <X11/Xdefs.h>
+#include "list.h"
+
+/** @brief A hashing function.
+
+ @param[in/out] cdata Opaque data that can be passed to HtInit that will
+ eventually end up here
+ @param[in] ptr The data to be hashed. The size of the data, if
+ needed, can be configured via a record that can be
+ passed via cdata.
+ @param[in] numBits The number of bits this hash needs to have in the
+ resulting hash
+
+ @return A numBits-bit hash of the data
+*/
+typedef unsigned (*HashFunc)(void * cdata, const void * ptr, int numBits);
+
+/** @brief A comparison function for hashed keys.
+
+ @param[in/out] cdata Opaque data that ca be passed to Htinit that will
+ eventually end up here
+ @param[in] l The left side data to be compared
+ @param[in] r The right side data to be compared
+
+ @return -1 if l < r, 0 if l == r, 1 if l > r
+*/
+typedef int (*HashCompareFunc)(void * cdata, const void * l, const void * r);
+
+struct HashTableRec;
+
+typedef struct HashTableRec *HashTable;
+
+/** @brief A configuration for HtGenericHash */
+typedef struct {
+ int keySize;
+} HtGenericHashSetupRec, *HtGenericHashSetupPtr;
+
+/** @brief ht_create initalizes a hash table for a certain hash table
+ configuration
+
+ @param[out] ht The hash table structure to initialize
+ @param[in] keySize The key size in bytes
+ @param[in] dataSize The data size in bytes
+ @param[in] hash The hash function to use for hashing keys
+ @param[in] compare The comparison function for hashing keys
+ @param[in] cdata Opaque data that will be passed to hash and
+ comparison functions
+*/
+extern _X_EXPORT HashTable ht_create(int keySize,
+ int dataSize,
+ HashFunc hash,
+ HashCompareFunc compare,
+ pointer cdata);
+/** @brief HtDestruct deinitializes the structure. It does not free the
+ memory allocated to HashTableRec
+*/
+extern _X_EXPORT void ht_destroy(HashTable ht);
+
+/** @brief Adds a new key to the hash table. The key will be copied
+ and a pointer to the value will be returned. The data will
+ be initialized with zeroes.
+
+ @param[in/out] ht The hash table
+ @param[key] key The key. The contents of the key will be copied.
+
+ @return On error NULL is returned, otherwise a pointer to the data
+ associated with the newly inserted key.
+
+ @note If dataSize is 0, a pointer to the end of the key may be returned
+ to avoid returning NULL. Obviously the data pointed cannot be
+ modified, as implied by dataSize being 0.
+*/
+extern _X_EXPORT pointer ht_add(HashTable ht, pointer key);
+
+/** @brief Removes a key from the hash table along with its
+ associated data, which will be free'd.
+*/
+extern _X_EXPORT void ht_remove(HashTable ht, pointer key);
+
+/** @brief Finds the associated data of a key from the hash table.
+
+ @return If the key cannot be found, the function returns NULL.
+ Otherwise it returns a pointer to the data associated
+ with the key.
+
+ @note If dataSize == 0, this function may return NULL
+ even if the key has been inserted! If dataSize == NULL,
+ use HtMember instead to determine if a key has been
+ inserted.
+*/
+extern _X_EXPORT pointer ht_find(HashTable ht, pointer key);
+
+/** @brief A generic hash function */
+extern _X_EXPORT unsigned ht_generic_hash(void *cdata,
+ const void *ptr,
+ int numBits);
+
+/** @brief A generic comparison function. It compares data byte-wise. */
+extern _X_EXPORT int ht_generic_compare(void *cdata,
+ const void *l,
+ const void *r);
+
+/** @brief A debugging function that dumps the distribution of the
+ hash table: for each bucket, list the number of elements
+ contained within. */
+extern _X_EXPORT void ht_dump_distribution(HashTable ht);
+
+/** @brief A debugging function that dumps the contents of the hash
+ table: for each bucket, list the elements contained
+ within. */
+extern _X_EXPORT void ht_dump_contents(HashTable ht,
+ void (*print_key)(void *opaque, void *key),
+ void (*print_value)(void *opaque, void *value),
+ void* opaque);
+
+/** @brief A hashing function to be used for hashing resource IDs when
+ used with HashTables. It makes no use of cdata, so that can
+ be NULL. It uses HashXID underneath, and should HashXID be
+ unable to hash the value, it switches into using the generic
+ hash function. */
+extern _X_EXPORT unsigned ht_resourceid_hash(void *cdata,
+ const void * data,
+ int numBits);
+
+/** @brief A comparison function to be used for comparing resource
+ IDs when used with HashTables. It makes no use of cdata,
+ so that can be NULL. */
+extern _X_EXPORT int ht_resourceid_compare(void *cdata,
+ const void *a,
+ const void *b);
+
+#endif // HASHTABLE_H
diff --git a/xserver/Xext/panoramiX.c b/xserver/Xext/panoramiX.c
index 98d327f26..be475f7f4 100644
--- a/xserver/Xext/panoramiX.c
+++ b/xserver/Xext/panoramiX.c
@@ -59,7 +59,7 @@ Equipment Corporation.
#ifdef COMPOSITE
#include "compint.h"
#endif
-#include "modinit.h"
+#include "extinit.h"
#include "protocol-versions.h"
#ifdef GLXPROXY
@@ -150,7 +150,7 @@ static GCFuncs XineramaGCFuncs = {
(pGC)->funcs = &XineramaGCFuncs;
static Bool
-XineramaCloseScreen(int i, ScreenPtr pScreen)
+XineramaCloseScreen(ScreenPtr pScreen)
{
PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
@@ -163,7 +163,7 @@ XineramaCloseScreen(int i, ScreenPtr pScreen)
free((pointer) pScreenPriv);
- return (*pScreen->CloseScreen) (i, pScreen);
+ return (*pScreen->CloseScreen) (pScreen);
}
static Bool
@@ -434,7 +434,7 @@ XineramaReinitData(void)
*/
void
-PanoramiXExtensionInit(int argc, char *argv[])
+PanoramiXExtensionInit(void)
{
int i;
Bool success = FALSE;
@@ -592,8 +592,6 @@ PanoramiXExtensionInit(int argc, char *argv[])
}
-extern Bool CreateConnectionBlock(void);
-
Bool
PanoramiXCreateConnectionBlock(void)
{
@@ -895,6 +893,9 @@ PanoramiXResetProc(ExtensionEntry * extEntry)
#ifdef XFIXES
PanoramiXFixesReset();
#endif
+#ifdef COMPOSITE
+ PanoramiXCompositeReset ();
+#endif
screenInfo.numScreens = PanoramiXNumScreens;
for (i = 256; i--;)
ProcVector[i] = SavedProcVector[i];
@@ -904,21 +905,22 @@ int
ProcPanoramiXQueryVersion(ClientPtr client)
{
/* REQUEST(xPanoramiXQueryVersionReq); */
- xPanoramiXQueryVersionReply rep;
+ xPanoramiXQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = SERVER_PANORAMIX_MAJOR_VERSION,
+ .minorVersion = SERVER_PANORAMIX_MINOR_VERSION
+ };
REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_PANORAMIX_MAJOR_VERSION;
- rep.minorVersion = SERVER_PANORAMIX_MINOR_VERSION;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
- WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *) &rep);
+ WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), &rep);
return Success;
}
@@ -935,17 +937,19 @@ ProcPanoramiXGetState(ClientPtr client)
if (rc != Success)
return rc;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.state = !noPanoramiXExtension;
- rep.window = stuff->window;
+ rep = (xPanoramiXGetStateReply) {
+ .type = X_Reply,
+ .state = !noPanoramiXExtension,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .window = stuff->window
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window);
}
- WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *) &rep);
+ WriteToClient(client, sizeof(xPanoramiXGetStateReply), &rep);
return Success;
}
@@ -963,17 +967,19 @@ ProcPanoramiXGetScreenCount(ClientPtr client)
if (rc != Success)
return rc;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.ScreenCount = PanoramiXNumScreens;
- rep.window = stuff->window;
+ rep = (xPanoramiXGetScreenCountReply) {
+ .type = X_Reply,
+ .ScreenCount = PanoramiXNumScreens,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .window = stuff->window
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window);
}
- WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *) &rep);
+ WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), &rep);
return Success;
}
@@ -993,14 +999,16 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
if (rc != Success)
return rc;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
+ rep = (xPanoramiXGetScreenSizeReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
/* screen dimensions */
- rep.width = screenInfo.screens[stuff->screen]->width;
- rep.height = screenInfo.screens[stuff->screen]->height;
- rep.window = stuff->window;
- rep.screen = stuff->screen;
+ .width = screenInfo.screens[stuff->screen]->width,
+ .height = screenInfo.screens[stuff->screen]->height,
+ .window = stuff->window,
+ .screen = stuff->screen
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -1009,7 +1017,7 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
swapl(&rep.window);
swapl(&rep.screen);
}
- WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *) &rep);
+ WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), &rep);
return Success;
}
@@ -1021,24 +1029,24 @@ ProcXineramaIsActive(ClientPtr client)
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
+ rep = (xXineramaIsActiveReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
#if 1
- {
/* The following hack fools clients into thinking that Xinerama
* is disabled even though it is not. */
- rep.state = !noPanoramiXExtension && !PanoramiXExtensionDisabledHack;
- }
+ .state = !noPanoramiXExtension && !PanoramiXExtensionDisabledHack
#else
- rep.state = !noPanoramiXExtension;
+ .state = !noPanoramiXExtension;
#endif
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.state);
}
- WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep);
+ WriteToClient(client, sizeof(xXineramaIsActiveReply), &rep);
return Success;
}
@@ -1046,20 +1054,22 @@ int
ProcXineramaQueryScreens(ClientPtr client)
{
/* REQUEST(xXineramaQueryScreensReq); */
- xXineramaQueryScreensReply rep;
+ CARD32 number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
+ xXineramaQueryScreensReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(number * sz_XineramaScreenInfo),
+ .number = number
+ };
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
- rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.number);
}
- WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *) &rep);
+ WriteToClient(client, sizeof(xXineramaQueryScreensReply), &rep);
if (!noPanoramiXExtension) {
xXineramaScreenInfo scratch;
@@ -1077,7 +1087,7 @@ ProcXineramaQueryScreens(ClientPtr client)
swaps(&scratch.width);
swaps(&scratch.height);
}
- WriteToClient(client, sz_XineramaScreenInfo, (char *) &scratch);
+ WriteToClient(client, sz_XineramaScreenInfo, &scratch);
}
}
diff --git a/xserver/Xext/panoramiXprocs.c b/xserver/Xext/panoramiXprocs.c
index 12d6163bb..576844cbf 100644
--- a/xserver/Xext/panoramiXprocs.c
+++ b/xserver/Xext/panoramiXprocs.c
@@ -566,14 +566,18 @@ PanoramiXGetGeometry(ClientPtr client)
if (rc != Success)
return rc;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.root = screenInfo.screens[0]->root->drawable.id;
- rep.depth = pDraw->depth;
- rep.width = pDraw->width;
- rep.height = pDraw->height;
- rep.x = rep.y = rep.borderWidth = 0;
+ rep = (xGetGeometryReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .root = screenInfo.screens[0]->root->drawable.id,
+ .depth = pDraw->depth,
+ .width = pDraw->width,
+ .height = pDraw->height,
+ .x = 0,
+ .y = 0,
+ .borderWidth = 0
+ };
if (stuff->id == rep.root) {
xWindowRoot *root = (xWindowRoot *)
@@ -617,11 +621,13 @@ PanoramiXTranslateCoords(ClientPtr client)
rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess);
if (rc != Success)
return rc;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.sameScreen = xTrue;
- rep.child = None;
+ rep = (xTranslateCoordsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .sameScreen = xTrue,
+ .child = None
+ };
if ((pWin == screenInfo.screens[0]->root) ||
(pWin->drawable.id == screenInfo.screens[0]->screensaver.wid)) {
@@ -1954,10 +1960,12 @@ PanoramiXGetImage(ClientPtr client)
return rc;
}
- xgi.visual = wVisual(((WindowPtr) pDraw));
- xgi.type = X_Reply;
- xgi.sequenceNumber = client->sequence;
- xgi.depth = pDraw->depth;
+ xgi = (xGetImageReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .visual = wVisual(((WindowPtr) pDraw)),
+ .depth = pDraw->depth
+ };
if (format == ZPixmap) {
widthBytesLine = PixmapBytePad(w, pDraw->depth);
length = widthBytesLine * h;
@@ -2003,7 +2011,7 @@ PanoramiXGetImage(ClientPtr client)
format, planemask, pBuf, widthBytesLine,
isRoot);
- (void) WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
+ WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
linesDone += nlines;
}
}
@@ -2020,8 +2028,7 @@ PanoramiXGetImage(ClientPtr client)
nlines, format, plane, pBuf,
widthBytesLine, isRoot);
- (void) WriteToClient(client,
- (int) (nlines * widthBytesLine), pBuf);
+ WriteToClient(client, (int)(nlines * widthBytesLine), pBuf);
linesDone += nlines;
}
diff --git a/xserver/Xext/saver.c b/xserver/Xext/saver.c
index 159153c23..8de043f8e 100644
--- a/xserver/Xext/saver.c
+++ b/xserver/Xext/saver.c
@@ -46,6 +46,7 @@ in this Software without prior written authorization from the X Consortium.
#include "cursorstr.h"
#include "colormapst.h"
#include "xace.h"
+#include "inputstr.h"
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
@@ -57,7 +58,7 @@ in this Software without prior written authorization from the X Consortium.
#include <stdio.h>
-#include "modinit.h"
+#include "extinit.h"
static int ScreenSaverEventBase = 0;
@@ -388,8 +389,12 @@ ScreenSaverFreeSuspend(pointer value, XID id)
if (screenIsSaved != SCREEN_SAVER_ON)
#endif
{
+ DeviceIntPtr dev;
UpdateCurrentTimeIf();
- lastDeviceEventTime = currentTime;
+ nt_list_for_each_entry(dev, inputInfo.devices, next)
+ lastDeviceEventTime[dev->id] = currentTime;
+ lastDeviceEventTime[XIAllDevices] = currentTime;
+ lastDeviceEventTime[XIAllMasterDevices] = currentTime;
SetScreenSaverTimer();
}
}
@@ -403,7 +408,6 @@ SendScreenSaverNotify(ScreenPtr pScreen, int state, Bool forced)
ScreenSaverScreenPrivatePtr pPriv;
ScreenSaverEventPtr pEv;
unsigned long mask;
- xScreenSaverNotifyEvent ev;
int kind;
UpdateCurrentTimeIf();
@@ -421,16 +425,18 @@ SendScreenSaverNotify(ScreenPtr pScreen, int state, Bool forced)
else
kind = ScreenSaverInternal;
for (pEv = pPriv->events; pEv; pEv = pEv->next) {
- if (!(pEv->mask & mask))
- continue;
- ev.type = ScreenSaverNotify + ScreenSaverEventBase;
- ev.state = state;
- ev.timestamp = currentTime.milliseconds;
- ev.root = pScreen->root->drawable.id;
- ev.window = pScreen->screensaver.wid;
- ev.kind = kind;
- ev.forced = forced;
- WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
+ if (pEv->mask & mask) {
+ xScreenSaverNotifyEvent ev = {
+ .type = ScreenSaverNotify + ScreenSaverEventBase,
+ .state = state,
+ .timestamp = currentTime.milliseconds,
+ .root = pScreen->root->drawable.id,
+ .window = pScreen->screensaver.wid,
+ .kind = kind,
+ .forced = forced
+ };
+ WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
+ }
}
}
@@ -631,19 +637,21 @@ ScreenSaverHandle(ScreenPtr pScreen, int xstate, Bool force)
static int
ProcScreenSaverQueryVersion(ClientPtr client)
{
- xScreenSaverQueryVersionReply rep;
+ xScreenSaverQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = SERVER_SAVER_MAJOR_VERSION,
+ .minorVersion = SERVER_SAVER_MINOR_VERSION
+ };
REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_SAVER_MAJOR_VERSION;
- rep.minorVersion = SERVER_SAVER_MINOR_VERSION;
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
- WriteToClient(client, sizeof(xScreenSaverQueryVersionReply), (char *) &rep);
+ WriteToClient(client, sizeof(xScreenSaverQueryVersionReply), &rep);
return Success;
}
@@ -672,12 +680,14 @@ ProcScreenSaverQueryInfo(ClientPtr client)
pPriv = GetScreenPrivate(pDraw->pScreen);
UpdateCurrentTime();
- lastInput = GetTimeInMillis() - lastDeviceEventTime.milliseconds;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.window = pSaver->wid;
+ lastInput = GetTimeInMillis() - lastDeviceEventTime[XIAllDevices].milliseconds;
+
+ rep = (xScreenSaverQueryInfoReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .window = pSaver->wid
+ };
if (screenIsSaved != SCREEN_SAVER_OFF) {
rep.state = ScreenSaverOn;
if (ScreenSaverTime)
@@ -714,7 +724,7 @@ ProcScreenSaverQueryInfo(ClientPtr client)
swapl(&rep.idle);
swapl(&rep.eventMask);
}
- WriteToClient(client, sizeof(xScreenSaverQueryInfoReply), (char *) &rep);
+ WriteToClient(client, sizeof(xScreenSaverQueryInfoReply), &rep);
return Success;
}
@@ -827,7 +837,7 @@ ScreenSaverSetAttributes(ClientPtr client)
if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) {
fOK = FALSE;
for (idepth = 0; idepth < pScreen->numDepths; idepth++) {
- pDepth = (DepthPtr) & pScreen->allowedDepths[idepth];
+ pDepth = (DepthPtr) &pScreen->allowedDepths[idepth];
if ((depth == pDepth->depth) || (depth == 0)) {
for (ivisual = 0; ivisual < pDepth->numVids; ivisual++) {
if (visual == pDepth->vids[ivisual]) {
@@ -1381,7 +1391,7 @@ SProcScreenSaverDispatch(ClientPtr client)
}
void
-ScreenSaverExtensionInit(INITARGS)
+ScreenSaverExtensionInit(void)
{
ExtensionEntry *extEntry;
int i;
diff --git a/xserver/Xext/security.c b/xserver/Xext/security.c
index 3699510d3..6cc9aa044 100644
--- a/xserver/Xext/security.c
+++ b/xserver/Xext/security.c
@@ -38,7 +38,7 @@ in this Software without prior written authorization from The Open Group.
#include "xacestr.h"
#include "securitysrv.h"
#include <X11/extensions/securproto.h>
-#include "modinit.h"
+#include "extinit.h"
#include "protocol-versions.h"
/* Extension stuff */
@@ -192,10 +192,10 @@ SecurityDeleteAuthorization(pointer value, XID id)
while ((pEventClient = pAuth->eventClients)) {
/* send revocation event event */
- xSecurityAuthorizationRevokedEvent are;
-
- are.type = SecurityEventBase + XSecurityAuthorizationRevoked;
- are.authId = pAuth->id;
+ xSecurityAuthorizationRevokedEvent are = {
+ .type = SecurityEventBase + XSecurityAuthorizationRevoked,
+ .authId = pAuth->id
+ };
WriteEventsToClient(rClient(pEventClient), 1, (xEvent *) &are);
FreeResource(pEventClient->resource, RT_NONE);
}
@@ -338,21 +338,22 @@ static int
ProcSecurityQueryVersion(ClientPtr client)
{
/* REQUEST(xSecurityQueryVersionReq); */
- xSecurityQueryVersionReply rep;
+ xSecurityQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = SERVER_SECURITY_MAJOR_VERSION,
+ .minorVersion = SERVER_SECURITY_MINOR_VERSION
+ };
REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.majorVersion = SERVER_SECURITY_MAJOR_VERSION;
- rep.minorVersion = SERVER_SECURITY_MINOR_VERSION;
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
- (void) WriteToClient(client, SIZEOF(xSecurityQueryVersionReply),
- (char *) &rep);
+ WriteToClient(client, SIZEOF(xSecurityQueryVersionReply), &rep);
return Success;
} /* ProcSecurityQueryVersion */
@@ -528,11 +529,13 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
/* tell client the auth id and data */
- rep.type = X_Reply;
- rep.length = bytes_to_int32(authdata_len);
- rep.sequenceNumber = client->sequence;
- rep.authId = authId;
- rep.dataLength = authdata_len;
+ rep = (xSecurityGenerateAuthorizationReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(authdata_len),
+ .authId = authId,
+ .dataLength = authdata_len
+ };
if (client->swapped) {
swapl(&rep.length);
@@ -541,8 +544,7 @@ ProcSecurityGenerateAuthorization(ClientPtr client)
swaps(&rep.dataLength);
}
- WriteToClient(client, SIZEOF(xSecurityGenerateAuthorizationReply),
- (char *) &rep);
+ WriteToClient(client, SIZEOF(xSecurityGenerateAuthorizationReply), &rep);
WriteToClient(client, authdata_len, pAuthdata);
SecurityAudit
@@ -1025,7 +1027,7 @@ SecurityResetProc(ExtensionEntry * extEntry)
*/
void
-SecurityExtensionInit(INITARGS)
+SecurityExtensionInit(void)
{
ExtensionEntry *extEntry;
int ret = TRUE;
diff --git a/xserver/Xext/shape.c b/xserver/Xext/shape.c
index cc5214a1b..d36867cc8 100644
--- a/xserver/Xext/shape.c
+++ b/xserver/Xext/shape.c
@@ -44,7 +44,7 @@ in this Software without prior written authorization from The Open Group.
#include <X11/extensions/shapeproto.h>
#include "regionstr.h"
#include "gcstruct.h"
-#include "modinit.h"
+#include "extinit.h"
#include "protocol-versions.h"
typedef RegionPtr (*CreateDftPtr) (WindowPtr /* pWin */
@@ -204,22 +204,23 @@ CreateClipShape(WindowPtr pWin)
static int
ProcShapeQueryVersion(ClientPtr client)
{
- xShapeQueryVersionReply rep;
+ xShapeQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = SERVER_SHAPE_MAJOR_VERSION,
+ .minorVersion = SERVER_SHAPE_MINOR_VERSION
+ };
REQUEST_SIZE_MATCH(xShapeQueryVersionReq);
- memset(&rep, 0, sizeof(xShapeQueryVersionReply));
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_SHAPE_MAJOR_VERSION;
- rep.minorVersion = SERVER_SHAPE_MINOR_VERSION;
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
- WriteToClient(client, sizeof(xShapeQueryVersionReply), (char *) &rep);
+ WriteToClient(client, sizeof(xShapeQueryVersionReply), &rep);
return Success;
}
@@ -631,12 +632,13 @@ ProcShapeQueryExtents(ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
- memset(&rep, 0, sizeof(xShapeQueryExtentsReply));
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.boundingShaped = (wBoundingShape(pWin) != 0);
- rep.clipShaped = (wClipShape(pWin) != 0);
+ rep = (xShapeQueryExtentsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .boundingShaped = (wBoundingShape(pWin) != 0),
+ .clipShaped = (wClipShape(pWin) != 0)
+ };
if ((region = wBoundingShape(pWin))) {
/* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
pExtents = RegionExtents(region);
@@ -679,7 +681,7 @@ ProcShapeQueryExtents(ClientPtr client)
swaps(&rep.widthClipShape);
swaps(&rep.heightClipShape);
}
- WriteToClient(client, sizeof(xShapeQueryExtentsReply), (char *) &rep);
+ WriteToClient(client, sizeof(xShapeQueryExtentsReply), &rep);
return Success;
}
@@ -824,7 +826,6 @@ void
SendShapeNotify(WindowPtr pWin, int which)
{
ShapeEventPtr *pHead, pShapeEvent;
- xShapeNotifyEvent se;
BoxRec extents;
RegionPtr region;
BYTE shaped;
@@ -881,15 +882,17 @@ SendShapeNotify(WindowPtr pWin, int which)
return;
}
for (pShapeEvent = *pHead; pShapeEvent; pShapeEvent = pShapeEvent->next) {
- se.type = ShapeNotify + ShapeEventBase;
- se.kind = which;
- se.window = pWin->drawable.id;
- se.x = extents.x1;
- se.y = extents.y1;
- se.width = extents.x2 - extents.x1;
- se.height = extents.y2 - extents.y1;
- se.time = currentTime.milliseconds;
- se.shaped = shaped;
+ xShapeNotifyEvent se = {
+ .type = ShapeNotify + ShapeEventBase,
+ .kind = which,
+ .window = pWin->drawable.id,
+ .x = extents.x1,
+ .y = extents.y1,
+ .width = extents.x2 - extents.x1,
+ .height = extents.y2 - extents.y1,
+ .time = currentTime.milliseconds,
+ .shaped = shaped
+ };
WriteEventsToClient(pShapeEvent->client, 1, (xEvent *) &se);
}
}
@@ -920,15 +923,17 @@ ProcShapeInputSelected(ClientPtr client)
}
}
}
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.enabled = enabled;
+ rep = (xShapeInputSelectedReply) {
+ .type = X_Reply,
+ .enabled = enabled,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
- WriteToClient(client, sizeof(xShapeInputSelectedReply), (char *) &rep);
+ WriteToClient(client, sizeof(xShapeInputSelectedReply), &rep);
return Success;
}
@@ -1001,19 +1006,21 @@ ProcShapeGetRectangles(ClientPtr client)
rects[i].height = box->y2 - box->y1;
}
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = bytes_to_int32(nrects * sizeof(xRectangle));
- rep.ordering = YXBanded;
- rep.nrects = nrects;
+ rep = (xShapeGetRectanglesReply) {
+ .type = X_Reply,
+ .ordering = YXBanded,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(nrects * sizeof(xRectangle)),
+ .nrects = nrects
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.nrects);
SwapShorts((short *) rects, (unsigned long) nrects * 4);
}
- WriteToClient(client, sizeof(rep), (char *) &rep);
- WriteToClient(client, nrects * sizeof(xRectangle), (char *) rects);
+ WriteToClient(client, sizeof(rep), &rep);
+ WriteToClient(client, nrects * sizeof(xRectangle), rects);
free(rects);
return Success;
}
diff --git a/xserver/Xext/shm.c b/xserver/Xext/shm.c
index de480207d..55960907b 100644
--- a/xserver/Xext/shm.c
+++ b/xserver/Xext/shm.c
@@ -87,7 +87,7 @@ in this Software without prior written authorization from The Open Group.
#include "panoramiXsrv.h"
#endif
-#include "modinit.h"
+#include "extinit.h"
typedef struct _ShmDesc {
struct _ShmDesc *next;
@@ -135,11 +135,11 @@ static ShmFuncs fbFuncs = { fbShmCreatePixmap, NULL };
#define VERIFY_SHMSEG(shmseg,shmdesc,client) \
{ \
- int rc; \
- rc = dixLookupResourceByType((pointer *)&(shmdesc), shmseg, ShmSegType, \
- client, DixReadAccess); \
- if (rc != Success) \
- return rc; \
+ int tmprc; \
+ tmprc = dixLookupResourceByType((pointer *)&(shmdesc), shmseg, ShmSegType, \
+ client, DixReadAccess); \
+ if (tmprc != Success) \
+ return tmprc; \
}
#define VERIFY_SHMPTR(shmseg,offset,needwrite,shmdesc,client) \
@@ -202,14 +202,14 @@ CheckForShmSyscall(void)
#endif
static Bool
-ShmCloseScreen(int i, ScreenPtr pScreen)
+ShmCloseScreen(ScreenPtr pScreen)
{
ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen);
pScreen->CloseScreen = screen_priv->CloseScreen;
dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, NULL);
free(screen_priv);
- return (*pScreen->CloseScreen) (i, pScreen);
+ return (*pScreen->CloseScreen) (pScreen);
}
static ShmScrPrivateRec *
@@ -285,19 +285,20 @@ ShmRegisterFbFuncs(ScreenPtr pScreen)
static int
ProcShmQueryVersion(ClientPtr client)
{
- xShmQueryVersionReply rep;
+ xShmQueryVersionReply rep = {
+ .type = X_Reply,
+ .sharedPixmaps = sharedPixmaps,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = SERVER_SHM_MAJOR_VERSION,
+ .minorVersion = SERVER_SHM_MINOR_VERSION,
+ .uid = geteuid(),
+ .gid = getegid(),
+ .pixmapFormat = sharedPixmaps ? ZPixmap : 0
+ };
REQUEST_SIZE_MATCH(xShmQueryVersionReq);
- memset(&rep, 0, sizeof(xShmQueryVersionReply));
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.sharedPixmaps = sharedPixmaps;
- rep.pixmapFormat = sharedPixmaps ? ZPixmap : 0;
- rep.majorVersion = SERVER_SHM_MAJOR_VERSION;
- rep.minorVersion = SERVER_SHM_MINOR_VERSION;
- rep.uid = geteuid();
- rep.gid = getegid();
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@@ -306,7 +307,7 @@ ProcShmQueryVersion(ClientPtr client)
swaps(&rep.uid);
swaps(&rep.gid);
}
- WriteToClient(client, sizeof(xShmQueryVersionReply), (char *) &rep);
+ WriteToClient(client, sizeof(xShmQueryVersionReply), &rep);
return Success;
}
@@ -594,14 +595,14 @@ ProcShmPutImage(ClientPtr client)
stuff->dstX, stuff->dstY, shmdesc->addr + stuff->offset);
if (stuff->sendEvent) {
- xShmCompletionEvent ev;
-
- ev.type = ShmCompletionCode;
- ev.drawable = stuff->drawable;
- ev.minorEvent = X_ShmPutImage;
- ev.majorEvent = ShmReqCode;
- ev.shmseg = stuff->shmseg;
- ev.offset = stuff->offset;
+ xShmCompletionEvent ev = {
+ .type = ShmCompletionCode,
+ .drawable = stuff->drawable,
+ .minorEvent = X_ShmPutImage,
+ .majorEvent = ShmReqCode,
+ .shmseg = stuff->shmseg,
+ .offset = stuff->offset
+ };
WriteEventsToClient(client, 1, (xEvent *) &ev);
}
@@ -616,6 +617,7 @@ ProcShmGetImage(ClientPtr client)
Mask plane = 0;
xShmGetImageReply xgi;
ShmDescPtr shmdesc;
+ VisualID visual = None;
int rc;
REQUEST(xShmGetImageReq);
@@ -630,7 +632,7 @@ ProcShmGetImage(ClientPtr client)
return rc;
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
if (pDraw->type == DRAWABLE_WINDOW) {
- if ( /* check for being viewable */
+ if ( /* check for being viewable */
!((WindowPtr) pDraw)->realized ||
/* check for being on screen */
pDraw->x + stuff->x < 0 ||
@@ -646,19 +648,22 @@ ProcShmGetImage(ClientPtr client)
stuff->y + (int) stuff->height >
wBorderWidth((WindowPtr) pDraw) + (int) pDraw->height)
return BadMatch;
- xgi.visual = wVisual(((WindowPtr) pDraw));
+ visual = wVisual(((WindowPtr) pDraw));
}
else {
if (stuff->x < 0 ||
stuff->x + (int) stuff->width > pDraw->width ||
stuff->y < 0 || stuff->y + (int) stuff->height > pDraw->height)
return BadMatch;
- xgi.visual = None;
+ visual = None;
}
- xgi.type = X_Reply;
- xgi.length = 0;
- xgi.sequenceNumber = client->sequence;
- xgi.depth = pDraw->depth;
+ xgi = (xShmGetImageReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .visual = visual,
+ .depth = pDraw->depth
+ };
if (stuff->format == ZPixmap) {
length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height;
}
@@ -702,7 +707,7 @@ ProcShmGetImage(ClientPtr client)
swapl(&xgi.visual);
swapl(&xgi.size);
}
- WriteToClient(client, sizeof(xShmGetImageReply), (char *) &xgi);
+ WriteToClient(client, sizeof(xShmGetImageReply), &xgi);
return Success;
}
@@ -830,11 +835,13 @@ ProcPanoramiXShmGetImage(ClientPtr client)
}
}
- xgi.visual = wVisual(((WindowPtr) pDraw));
- xgi.type = X_Reply;
- xgi.length = 0;
- xgi.sequenceNumber = client->sequence;
- xgi.depth = pDraw->depth;
+ xgi = (xShmGetImageReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .visual = wVisual(((WindowPtr) pDraw)),
+ .depth = pDraw->depth
+ };
if (format == ZPixmap) {
widthBytesLine = PixmapBytePad(w, pDraw->depth);
@@ -877,7 +884,7 @@ ProcPanoramiXShmGetImage(ClientPtr client)
swapl(&xgi.visual);
swapl(&xgi.size);
}
- WriteToClient(client, sizeof(xShmGetImageReply), (char *) &xgi);
+ WriteToClient(client, sizeof(xShmGetImageReply), &xgi);
return Success;
}
@@ -1241,7 +1248,7 @@ SProcShmDispatch(ClientPtr client)
}
void
-ShmExtensionInit(INITARGS)
+ShmExtensionInit(void)
{
ExtensionEntry *extEntry;
int i;
diff --git a/xserver/Xext/sync.c b/xserver/Xext/sync.c
index 37c59c2be..4d11992bb 100644
--- a/xserver/Xext/sync.c
+++ b/xserver/Xext/sync.c
@@ -69,13 +69,14 @@ PERFORMANCE OF THIS SOFTWARE.
#include "syncsrv.h"
#include "syncsdk.h"
#include "protocol-versions.h"
+#include "inputstr.h"
#include <stdio.h>
#if !defined(WIN32)
#include <sys/time.h>
#endif
-#include "modinit.h"
+#include "extinit.h"
/*
* Local Global Variables
@@ -87,8 +88,7 @@ static RESTYPE RTAwait;
static RESTYPE RTAlarm;
static RESTYPE RTAlarmClient;
static RESTYPE RTFence;
-static int SyncNumSystemCounters = 0;
-static SyncCounter **SysCounterList = NULL;
+static struct xorg_list SysCounterList;
static int SyncNumInvalidCounterWarnings = 0;
#define MAX_INVALID_COUNTER_WARNINGS 5
@@ -114,6 +114,14 @@ static void SyncInitServerTime(void);
static void SyncInitIdleTime(void);
+static inline void*
+SysCounterGetPrivate(SyncCounter *counter)
+{
+ BUG_WARN(!IsSystemCounter(counter));
+
+ return counter->pSysCounterInfo ? counter->pSysCounterInfo->private : NULL;
+}
+
static Bool
SyncCheckWarnIsCounter(const SyncObject * pSync, const char *warning)
{
@@ -429,22 +437,25 @@ SyncSendAlarmNotifyEvents(SyncAlarm * pAlarm)
UpdateCurrentTime();
- ane.type = SyncEventBase + XSyncAlarmNotify;
- ane.kind = XSyncAlarmNotify;
- ane.alarm = pAlarm->alarm_id;
+ ane = (xSyncAlarmNotifyEvent) {
+ .type = SyncEventBase + XSyncAlarmNotify,
+ .kind = XSyncAlarmNotify,
+ .alarm = pAlarm->alarm_id,
+ .alarm_value_hi = XSyncValueHigh32(pTrigger->test_value),
+ .alarm_value_lo = XSyncValueLow32(pTrigger->test_value),
+ .time = currentTime.milliseconds,
+ .state = pAlarm->state
+ };
+
if (pTrigger->pSync && SYNC_COUNTER == pTrigger->pSync->type) {
ane.counter_value_hi = XSyncValueHigh32(pCounter->value);
ane.counter_value_lo = XSyncValueLow32(pCounter->value);
}
- else { /* XXX what else can we do if there's no counter? */
+ else {
+ /* XXX what else can we do if there's no counter? */
ane.counter_value_hi = ane.counter_value_lo = 0;
}
- ane.alarm_value_hi = XSyncValueHigh32(pTrigger->test_value);
- ane.alarm_value_lo = XSyncValueLow32(pTrigger->test_value);
- ane.time = currentTime.milliseconds;
- ane.state = pAlarm->state;
-
/* send to owner */
if (pAlarm->events)
WriteEventsToClient(pAlarm->client, 1, (xEvent *) &ane);
@@ -466,7 +477,7 @@ SyncSendCounterNotifyEvents(ClientPtr client, SyncAwait ** ppAwait,
if (client->clientGone)
return;
- pev = pEvents = malloc(num_events * sizeof(xSyncCounterNotifyEvent));
+ pev = pEvents = calloc(num_events, sizeof(xSyncCounterNotifyEvent));
if (!pEvents)
return;
UpdateCurrentTime();
@@ -921,26 +932,17 @@ static int FreeCounter(void *, XID);
* ***** System Counter utilities
*/
-pointer
+SyncCounter*
SyncCreateSystemCounter(const char *name,
CARD64 initial,
CARD64 resolution,
SyncCounterType counterType,
- void (*QueryValue) (pointer /* pCounter */ ,
- CARD64 * /* pValue_return */ ),
- void (*BracketValues) (pointer /* pCounter */ ,
- CARD64 * /* pbracket_less */ ,
- CARD64 * /* pbracket_greater */ )
+ SyncSystemCounterQueryValue QueryValue,
+ SyncSystemCounterBracketValues BracketValues
)
{
SyncCounter *pCounter;
- SysCounterList = realloc(SysCounterList,
- (SyncNumSystemCounters +
- 1) * sizeof(SyncCounter *));
- if (!SysCounterList)
- return NULL;
-
/* this function may be called before SYNC has been initialized, so we
* have to make sure RTCounter is created.
*/
@@ -949,6 +951,7 @@ SyncCreateSystemCounter(const char *name,
if (RTCounter == 0) {
return NULL;
}
+ xorg_list_init(&SysCounterList);
}
pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial);
@@ -962,14 +965,16 @@ SyncCreateSystemCounter(const char *name,
return pCounter;
}
pCounter->pSysCounterInfo = psci;
- psci->name = name;
+ psci->pCounter = pCounter;
+ psci->name = strdup(name);
psci->resolution = resolution;
psci->counterType = counterType;
psci->QueryValue = QueryValue;
psci->BracketValues = BracketValues;
+ psci->private = NULL;
XSyncMaxValue(&psci->bracket_greater);
XSyncMinValue(&psci->bracket_less);
- SysCounterList[SyncNumSystemCounters++] = pCounter;
+ xorg_list_add(&psci->entry, &SysCounterList);
}
return pCounter;
}
@@ -1033,15 +1038,15 @@ SyncComputeBracketValues(SyncCounter * pCounter)
pnewltval = &psci->bracket_less;
}
else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) &&
- XSyncValueLessThan(pTrigger->test_value,
- psci->bracket_greater)) {
+ XSyncValueGreaterThan(pTrigger->test_value,
+ psci->bracket_less)) {
/*
* The value is exactly equal to our threshold. We want one
- * more event in the positive direction to ensure we pick up
- * when the value *exceeds* this threshold.
+ * more event in the negative direction to ensure we pick up
+ * when the value is less than this threshold.
*/
- psci->bracket_greater = pTrigger->test_value;
- pnewgtval = &psci->bracket_greater;
+ psci->bracket_less = pTrigger->test_value;
+ pnewltval = &psci->bracket_less;
}
}
else if (pTrigger->test_type == XSyncPositiveTransition &&
@@ -1053,15 +1058,15 @@ SyncComputeBracketValues(SyncCounter * pCounter)
pnewgtval = &psci->bracket_greater;
}
else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) &&
- XSyncValueGreaterThan(pTrigger->test_value,
- psci->bracket_less)) {
+ XSyncValueLessThan(pTrigger->test_value,
+ psci->bracket_greater)) {
/*
* The value is exactly equal to our threshold. We want one
- * more event in the negative direction to ensure we pick up
- * when the value is less than this threshold.
+ * more event in the positive direction to ensure we pick up
+ * when the value *exceeds* this threshold.
*/
- psci->bracket_less = pTrigger->test_value;
- pnewltval = &psci->bracket_less;
+ psci->bracket_greater = pTrigger->test_value;
+ pnewgtval = &psci->bracket_greater;
}
}
} /* end for each trigger */
@@ -1114,26 +1119,10 @@ FreeCounter(void *env, XID id)
free(ptl); /* destroy the trigger list as we go */
}
if (IsSystemCounter(pCounter)) {
- int i, found = 0;
-
+ xorg_list_del(&pCounter->pSysCounterInfo->entry);
+ free(pCounter->pSysCounterInfo->name);
+ free(pCounter->pSysCounterInfo->private);
free(pCounter->pSysCounterInfo);
-
- /* find the counter in the list of system counters and remove it */
-
- if (SysCounterList) {
- for (i = 0; i < SyncNumSystemCounters; i++) {
- if (SysCounterList[i] == pCounter) {
- found = i;
- break;
- }
- }
- if (found < (SyncNumSystemCounters - 1)) {
- for (i = found; i < SyncNumSystemCounters - 1; i++) {
- SysCounterList[i] = SysCounterList[i + 1];
- }
- }
- }
- SyncNumSystemCounters--;
}
free(pCounter);
return Success;
@@ -1199,21 +1188,20 @@ FreeAlarmClient(void *value, XID id)
static int
ProcSyncInitialize(ClientPtr client)
{
- xSyncInitializeReply rep;
+ xSyncInitializeReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = SERVER_SYNC_MAJOR_VERSION,
+ .minorVersion = SERVER_SYNC_MINOR_VERSION,
+ };
REQUEST_SIZE_MATCH(xSyncInitializeReq);
- memset(&rep, 0, sizeof(xSyncInitializeReply));
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_SYNC_MAJOR_VERSION;
- rep.minorVersion = SERVER_SYNC_MINOR_VERSION;
- rep.length = 0;
-
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
- WriteToClient(client, sizeof(rep), (char *) &rep);
+ WriteToClient(client, sizeof(rep), &rep);
return Success;
}
@@ -1223,21 +1211,21 @@ ProcSyncInitialize(ClientPtr client)
static int
ProcSyncListSystemCounters(ClientPtr client)
{
- xSyncListSystemCountersReply rep;
- int i, len;
+ xSyncListSystemCountersReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .nCounters = 0,
+ };
+ SysCounterInfo *psci;
+ int len = 0;
xSyncSystemCounter *list = NULL, *walklist = NULL;
REQUEST_SIZE_MATCH(xSyncListSystemCountersReq);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.nCounters = SyncNumSystemCounters;
-
- for (i = len = 0; i < SyncNumSystemCounters; i++) {
- const char *name = SysCounterList[i]->pSysCounterInfo->name;
-
+ xorg_list_for_each_entry(psci, &SysCounterList, entry) {
/* pad to 4 byte boundary */
- len += pad_to_int32(sz_xSyncSystemCounter + strlen(name));
+ len += pad_to_int32(sz_xSyncSystemCounter + strlen(psci->name));
+ ++rep.nCounters;
}
if (len) {
@@ -1254,12 +1242,11 @@ ProcSyncListSystemCounters(ClientPtr client)
swapl(&rep.nCounters);
}
- for (i = 0; i < SyncNumSystemCounters; i++) {
+ xorg_list_for_each_entry(psci, &SysCounterList, entry) {
int namelen;
char *pname_in_reply;
- SysCounterInfo *psci = SysCounterList[i]->pSysCounterInfo;
- walklist->counter = SysCounterList[i]->sync.id;
+ walklist->counter = psci->pCounter->sync.id;
walklist->resolution_hi = XSyncValueHigh32(psci->resolution);
walklist->resolution_lo = XSyncValueLow32(psci->resolution);
namelen = strlen(psci->name);
@@ -1279,9 +1266,9 @@ ProcSyncListSystemCounters(ClientPtr client)
namelen));
}
- WriteToClient(client, sizeof(rep), (char *) &rep);
+ WriteToClient(client, sizeof(rep), &rep);
if (len) {
- WriteToClient(client, len, (char *) list);
+ WriteToClient(client, len, list);
free(list);
}
@@ -1344,17 +1331,19 @@ ProcSyncGetPriority(ClientPtr client)
return rc;
}
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.priority = priorityclient->priority;
+ rep = (xSyncGetPriorityReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .priority = priorityclient->priority
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.priority);
}
- WriteToClient(client, sizeof(xSyncGetPriorityReply), (char *) &rep);
+ WriteToClient(client, sizeof(xSyncGetPriorityReply), &rep);
return Success;
}
@@ -1621,26 +1610,27 @@ ProcSyncQueryCounter(ClientPtr client)
if (rc != Success)
return rc;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
/* if system counter, ask it what the current value is */
-
if (IsSystemCounter(pCounter)) {
(*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter,
&pCounter->value);
}
- rep.value_hi = XSyncValueHigh32(pCounter->value);
- rep.value_lo = XSyncValueLow32(pCounter->value);
+ rep = (xSyncQueryCounterReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .value_hi = XSyncValueHigh32(pCounter->value),
+ .value_lo = XSyncValueLow32(pCounter->value)
+ };
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.value_hi);
swapl(&rep.value_lo);
}
- WriteToClient(client, sizeof(xSyncQueryCounterReply), (char *) &rep);
+ WriteToClient(client, sizeof(xSyncQueryCounterReply), &rep);
return Success;
}
@@ -1787,32 +1777,33 @@ ProcSyncQueryAlarm(ClientPtr client)
if (rc != Success)
return rc;
- rep.type = X_Reply;
- rep.length =
- bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply));
- rep.sequenceNumber = client->sequence;
-
pTrigger = &pAlarm->trigger;
- rep.counter = (pTrigger->pSync) ? pTrigger->pSync->id : None;
-
-#if 0 /* XXX unclear what to do, depends on whether relative value-types
- * are "consumed" immediately and are considered absolute from then
- * on.
- */
- rep.value_type = pTrigger->value_type;
- rep.wait_value_hi = XSyncValueHigh32(pTrigger->wait_value);
- rep.wait_value_lo = XSyncValueLow32(pTrigger->wait_value);
+ rep = (xSyncQueryAlarmReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length =
+ bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)),
+ .counter = (pTrigger->pSync) ? pTrigger->pSync->id : None,
+
+#if 0 /* XXX unclear what to do, depends on whether relative value-types
+ * are "consumed" immediately and are considered absolute from then
+ * on.
+ */
+ .value_type = pTrigger->value_type,
+ .wait_value_hi = XSyncValueHigh32(pTrigger->wait_value),
+ .wait_value_lo = XSyncValueLow32(pTrigger->wait_value),
#else
- rep.value_type = XSyncAbsolute;
- rep.wait_value_hi = XSyncValueHigh32(pTrigger->test_value);
- rep.wait_value_lo = XSyncValueLow32(pTrigger->test_value);
+ .value_type = XSyncAbsolute,
+ .wait_value_hi = XSyncValueHigh32(pTrigger->test_value),
+ .wait_value_lo = XSyncValueLow32(pTrigger->test_value),
#endif
- rep.test_type = pTrigger->test_type;
- rep.delta_hi = XSyncValueHigh32(pAlarm->delta);
- rep.delta_lo = XSyncValueLow32(pAlarm->delta);
- rep.events = pAlarm->events;
- rep.state = pAlarm->state;
+ .test_type = pTrigger->test_type,
+ .delta_hi = XSyncValueHigh32(pAlarm->delta),
+ .delta_lo = XSyncValueLow32(pAlarm->delta),
+ .events = pAlarm->events,
+ .state = pAlarm->state
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
@@ -1825,7 +1816,7 @@ ProcSyncQueryAlarm(ClientPtr client)
swapl(&rep.delta_lo);
}
- WriteToClient(client, sizeof(xSyncQueryAlarmReply), (char *) &rep);
+ WriteToClient(client, sizeof(xSyncQueryAlarmReply), &rep);
return Success;
}
@@ -1971,18 +1962,20 @@ ProcSyncQueryFence(ClientPtr client)
if (rc != Success)
return rc;
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
+ rep = (xSyncQueryFenceReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
- rep.triggered = pFence->funcs.CheckTriggered(pFence);
+ .triggered = pFence->funcs.CheckTriggered(pFence)
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
- WriteToClient(client, sizeof(xSyncQueryFenceReply), (char *) &rep);
+ WriteToClient(client, sizeof(xSyncQueryFenceReply), &rep);
return client->noClientException;
}
@@ -2444,8 +2437,6 @@ SAlarmNotifyEvent(xSyncAlarmNotifyEvent * from, xSyncAlarmNotifyEvent * to)
static void
SyncResetProc(ExtensionEntry * extEntry)
{
- free(SysCounterList);
- SysCounterList = NULL;
RTCounter = 0;
}
@@ -2463,6 +2454,7 @@ SyncExtensionInit(void)
if (RTCounter == 0) {
RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter");
+ xorg_list_init(&SysCounterList);
}
RTAlarm = CreateNewResourceType(FreeAlarm, "SyncAlarm");
RTAwait = CreateNewResourceType(FreeAwait, "SyncAwait");
@@ -2608,33 +2600,48 @@ SyncInitServerTime(void)
* IDLETIME implementation
*/
-static SyncCounter *IdleTimeCounter;
-static XSyncValue *pIdleTimeValueLess;
-static XSyncValue *pIdleTimeValueGreater;
+typedef struct {
+ XSyncValue *value_less;
+ XSyncValue *value_greater;
+ int deviceid;
+} IdleCounterPriv;
static void
IdleTimeQueryValue(pointer pCounter, CARD64 * pValue_return)
{
- CARD32 idle = GetTimeInMillis() - lastDeviceEventTime.milliseconds;
+ int deviceid;
+ CARD32 idle;
+ if (pCounter) {
+ SyncCounter *counter = pCounter;
+ IdleCounterPriv *priv = SysCounterGetPrivate(counter);
+ deviceid = priv->deviceid;
+ }
+ else
+ deviceid = XIAllDevices;
+ idle = GetTimeInMillis() - lastDeviceEventTime[deviceid].milliseconds;
XSyncIntsToValue(pValue_return, idle, 0);
}
static void
-IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
+IdleTimeBlockHandler(pointer pCounter, struct timeval **wt, pointer LastSelectMask)
{
+ SyncCounter *counter = pCounter;
+ IdleCounterPriv *priv = SysCounterGetPrivate(counter);
+ XSyncValue *less = priv->value_less,
+ *greater = priv->value_greater;
XSyncValue idle, old_idle;
- SyncTriggerList *list = IdleTimeCounter->sync.pTriglist;
+ SyncTriggerList *list = counter->sync.pTriglist;
SyncTrigger *trig;
- if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
+ if (!less && !greater)
return;
- old_idle = IdleTimeCounter->value;
+ old_idle = counter->value;
IdleTimeQueryValue(NULL, &idle);
- IdleTimeCounter->value = idle; /* push, so CheckTrigger works */
+ counter->value = idle; /* push, so CheckTrigger works */
- if (pIdleTimeValueLess && XSyncValueLessOrEqual(idle, *pIdleTimeValueLess)) {
+ if (less && XSyncValueLessOrEqual(idle, *less)) {
/*
* We've been idle for less than the threshold value, and someone
* wants to know about that, but now we need to know whether they
@@ -2643,7 +2650,7 @@ IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
* immediately so we can reschedule.
*/
- for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) {
+ for (list = counter->sync.pTriglist; list; list = list->next) {
trig = list->pTrigger;
if (trig->CheckTrigger(trig, old_idle)) {
AdjustWaitForDelay(wt, 0);
@@ -2656,10 +2663,10 @@ IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
* idle time greater than this. Schedule a wakeup for the next
* millisecond so we won't miss a transition.
*/
- if (XSyncValueEqual(idle, *pIdleTimeValueLess))
+ if (XSyncValueEqual(idle, *less))
AdjustWaitForDelay(wt, 1);
}
- else if (pIdleTimeValueGreater) {
+ else if (greater) {
/*
* There's a threshold in the positive direction. If we've been
* idle less than it, schedule a wakeup for sometime in the future.
@@ -2668,15 +2675,15 @@ IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
*/
unsigned long timeout = -1;
- if (XSyncValueLessThan(idle, *pIdleTimeValueGreater)) {
+ if (XSyncValueLessThan(idle, *greater)) {
XSyncValue value;
Bool overflow;
- XSyncValueSubtract(&value, *pIdleTimeValueGreater, idle, &overflow);
+ XSyncValueSubtract(&value, *greater, idle, &overflow);
timeout = min(timeout, XSyncValueLow32(value));
}
else {
- for (list = IdleTimeCounter->sync.pTriglist; list;
+ for (list = counter->sync.pTriglist; list;
list = list->next) {
trig = list->pTrigger;
if (trig->CheckTrigger(trig, old_idle)) {
@@ -2689,24 +2696,26 @@ IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
AdjustWaitForDelay(wt, timeout);
}
- IdleTimeCounter->value = old_idle; /* pop */
+ counter->value = old_idle; /* pop */
}
static void
-IdleTimeWakeupHandler(pointer env, int rc, pointer LastSelectMask)
+IdleTimeWakeupHandler(pointer pCounter, int rc, pointer LastSelectMask)
{
+ SyncCounter *counter = pCounter;
+ IdleCounterPriv *priv = SysCounterGetPrivate(counter);
+ XSyncValue *less = priv->value_less,
+ *greater = priv->value_greater;
XSyncValue idle;
- if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
+ if (!less && !greater)
return;
- IdleTimeQueryValue(NULL, &idle);
+ IdleTimeQueryValue(pCounter, &idle);
- if ((pIdleTimeValueGreater &&
- XSyncValueGreaterOrEqual(idle, *pIdleTimeValueGreater)) ||
- (pIdleTimeValueLess &&
- XSyncValueLessOrEqual(idle, *pIdleTimeValueLess))) {
- SyncChangeCounter(IdleTimeCounter, idle);
+ if ((greater && XSyncValueGreaterOrEqual(idle, *greater)) ||
+ (less && XSyncValueLessOrEqual(idle, *less))) {
+ SyncChangeCounter(counter, idle);
}
}
@@ -2714,34 +2723,69 @@ static void
IdleTimeBracketValues(pointer pCounter, CARD64 * pbracket_less,
CARD64 * pbracket_greater)
{
- Bool registered = (pIdleTimeValueLess || pIdleTimeValueGreater);
+ SyncCounter *counter = pCounter;
+ IdleCounterPriv *priv = SysCounterGetPrivate(counter);
+ XSyncValue *less = priv->value_less,
+ *greater = priv->value_greater;
+ Bool registered = (less || greater);
if (registered && !pbracket_less && !pbracket_greater) {
RemoveBlockAndWakeupHandlers(IdleTimeBlockHandler,
- IdleTimeWakeupHandler, NULL);
+ IdleTimeWakeupHandler, pCounter);
}
else if (!registered && (pbracket_less || pbracket_greater)) {
RegisterBlockAndWakeupHandlers(IdleTimeBlockHandler,
- IdleTimeWakeupHandler, NULL);
+ IdleTimeWakeupHandler, pCounter);
}
- pIdleTimeValueGreater = pbracket_greater;
- pIdleTimeValueLess = pbracket_less;
+ priv->value_greater = pbracket_greater;
+ priv->value_less = pbracket_less;
}
-static void
-SyncInitIdleTime(void)
+static SyncCounter*
+init_system_idle_counter(const char *name, int deviceid)
{
CARD64 resolution;
XSyncValue idle;
+ IdleCounterPriv *priv = malloc(sizeof(IdleCounterPriv));
+ SyncCounter *idle_time_counter;
IdleTimeQueryValue(NULL, &idle);
XSyncIntToValue(&resolution, 4);
- IdleTimeCounter = SyncCreateSystemCounter("IDLETIME", idle, resolution,
- XSyncCounterUnrestricted,
- IdleTimeQueryValue,
- IdleTimeBracketValues);
+ idle_time_counter = SyncCreateSystemCounter(name, idle, resolution,
+ XSyncCounterUnrestricted,
+ IdleTimeQueryValue,
+ IdleTimeBracketValues);
+
+ priv->deviceid = deviceid;
+ priv->value_less = priv->value_greater = NULL;
+
+ idle_time_counter->pSysCounterInfo->private = priv;
- pIdleTimeValueLess = pIdleTimeValueGreater = NULL;
+ return idle_time_counter;
+}
+
+static void
+SyncInitIdleTime(void)
+{
+ init_system_idle_counter("IDLETIME", XIAllDevices);
+}
+
+SyncCounter*
+SyncInitDeviceIdleTime(DeviceIntPtr dev)
+{
+ char timer_name[64];
+ sprintf(timer_name, "DEVICEIDLETIME %d", dev->id);
+
+ return init_system_idle_counter(timer_name, dev->id);
+}
+
+void SyncRemoveDeviceIdleTime(SyncCounter *counter)
+{
+ /* FreeAllResources() frees all system counters before the devices are
+ shut down, check if there are any left before freeing the device's
+ counter */
+ if (!xorg_list_is_empty(&SysCounterList))
+ xorg_list_del(&counter->pSysCounterInfo->entry);
}
diff --git a/xserver/Xext/syncsrv.h b/xserver/Xext/syncsrv.h
index b0464b304..c68229f46 100644
--- a/xserver/Xext/syncsrv.h
+++ b/xserver/Xext/syncsrv.h
@@ -51,6 +51,7 @@ PERFORMANCE OF THIS SOFTWARE.
#ifndef _SYNCSRV_H_
#define _SYNCSRV_H_
+#include "list.h"
#include "misync.h"
#include "misyncstr.h"
@@ -65,19 +66,25 @@ typedef enum {
XSyncCounterUnrestricted
} SyncCounterType;
+typedef void (*SyncSystemCounterQueryValue)(pointer counter,
+ CARD64 *value_return
+ );
+typedef void (*SyncSystemCounterBracketValues)(pointer counter,
+ CARD64 *pbracket_less,
+ CARD64 *pbracket_greater
+ );
+
typedef struct _SysCounterInfo {
- const char *name;
+ SyncCounter *pCounter;
+ char *name;
CARD64 resolution;
CARD64 bracket_greater;
CARD64 bracket_less;
SyncCounterType counterType; /* how can this counter change */
- void (*QueryValue) (pointer /*pCounter */ ,
- CARD64 * /*freshvalue */
- );
- void (*BracketValues) (pointer /*pCounter */ ,
- CARD64 * /*lessthan */ ,
- CARD64 * /*greaterthan */
- );
+ SyncSystemCounterQueryValue QueryValue;
+ SyncSystemCounterBracketValues BracketValues;
+ void *private;
+ struct xorg_list entry;
} SysCounterInfo;
typedef struct _SyncAlarmClientList {
@@ -113,33 +120,20 @@ typedef union {
SyncAwait await;
} SyncAwaitUnion;
-extern pointer SyncCreateSystemCounter(const char * /* name */ ,
- CARD64 /* inital_value */ ,
- CARD64 /* resolution */ ,
- SyncCounterType
- /* change characterization */ ,
- void (* /*QueryValue */ )(
- pointer
- /* pCounter */
- ,
- CARD64 * /* pValue_return */ ), /* XXX prototype */
- void (* /*BracketValues */ )(
- pointer
- /* pCounter */
- ,
- CARD64 *
- /* pbracket_less */
- ,
- CARD64 *
- /* pbracket_greater */
- )
+extern SyncCounter* SyncCreateSystemCounter(const char *name,
+ CARD64 initial_value,
+ CARD64 resolution,
+ SyncCounterType counterType,
+ SyncSystemCounterQueryValue QueryValue,
+ SyncSystemCounterBracketValues BracketValues
);
-extern void SyncChangeCounter(SyncCounter * /* pCounter */ ,
- CARD64 /* new_value */
+extern void SyncChangeCounter(SyncCounter *pCounter,
+ CARD64 new_value
);
extern void SyncDestroySystemCounter(pointer pCounter);
-extern void SyncExtensionInit(void);
+extern SyncCounter *SyncInitDeviceIdleTime(DeviceIntPtr dev);
+extern void SyncRemoveDeviceIdleTime(SyncCounter *counter);
#endif /* _SYNCSRV_H_ */
diff --git a/xserver/Xext/xace.c b/xserver/Xext/xace.c
index b2e7ddaf0..026d3c5cf 100644
--- a/xserver/Xext/xace.c
+++ b/xserver/Xext/xace.c
@@ -47,18 +47,18 @@ XaceHookDispatch(ClientPtr client, int major)
if (major < 128) {
/* Call the core dispatch hook */
- XaceCoreDispatchRec rec = { client, Success /* default allow */ };
- CallCallbacks(&XaceHooks[XACE_CORE_DISPATCH], &rec);
- return rec.status;
+ XaceCoreDispatchRec drec = { client, Success /* default allow */ };
+ CallCallbacks(&XaceHooks[XACE_CORE_DISPATCH], &drec);
+ return drec.status;
}
else {
/* Call the extension dispatch hook */
ExtensionEntry *ext = GetExtensionEntry(major);
- XaceExtAccessRec rec = { client, ext, DixUseAccess, Success };
+ XaceExtAccessRec erec = { client, ext, DixUseAccess, Success };
if (ext)
- CallCallbacks(&XaceHooks[XACE_EXT_DISPATCH], &rec);
+ CallCallbacks(&XaceHooks[XACE_EXT_DISPATCH], &erec);
/* On error, pretend extension doesn't exist */
- return (rec.status == Success) ? Success : BadRequest;
+ return (erec.status == Success) ? Success : BadRequest;
}
}
diff --git a/xserver/Xext/xcmisc.c b/xserver/Xext/xcmisc.c
index 99a6ece43..034bfb63b 100644
--- a/xserver/Xext/xcmisc.c
+++ b/xserver/Xext/xcmisc.c
@@ -38,27 +38,29 @@ from The Open Group.
#include "extnsionst.h"
#include "swaprep.h"
#include <X11/extensions/xcmiscproto.h>
-#include "modinit.h"
+#include "extinit.h"
#include <stdint.h>
static int
ProcXCMiscGetVersion(ClientPtr client)
{
- xXCMiscGetVersionReply rep;
+ xXCMiscGetVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = XCMiscMajorVersion,
+ .minorVersion = XCMiscMinorVersion
+ };
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = XCMiscMajorVersion;
- rep.minorVersion = XCMiscMinorVersion;
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
}
- WriteToClient(client, sizeof(xXCMiscGetVersionReply), (char *) &rep);
+ WriteToClient(client, sizeof(xXCMiscGetVersionReply), &rep);
return Success;
}
@@ -70,17 +72,19 @@ ProcXCMiscGetXIDRange(ClientPtr client)
REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq);
GetXIDRange(client->index, FALSE, &min_id, &max_id);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.start_id = min_id;
- rep.count = max_id - min_id + 1;
+ rep = (xXCMiscGetXIDRangeReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .start_id = min_id,
+ .count = max_id - min_id + 1
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.start_id);
swapl(&rep.count);
}
- WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), (char *) &rep);
+ WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), &rep);
return Success;
}
@@ -102,16 +106,18 @@ ProcXCMiscGetXIDList(ClientPtr client)
return BadAlloc;
}
count = GetXIDList(client, stuff->count, pids);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = count;
- rep.count = count;
+ rep = (xXCMiscGetXIDListReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = count,
+ .count = count
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.count);
}
- WriteToClient(client, sizeof(xXCMiscGetXIDListReply), (char *) &rep);
+ WriteToClient(client, sizeof(xXCMiscGetXIDListReply), &rep);
if (count) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, count * sizeof(XID), pids);
@@ -184,7 +190,7 @@ SProcXCMiscDispatch(ClientPtr client)
}
void
-XCMiscExtensionInit(INITARGS)
+XCMiscExtensionInit(void)
{
AddExtension(XCMiscExtensionName, 0, 0,
ProcXCMiscDispatch, SProcXCMiscDispatch,
diff --git a/xserver/Xext/xf86bigfont.c b/xserver/Xext/xf86bigfont.c
index 9de785678..46b3242d1 100644
--- a/xserver/Xext/xf86bigfont.c
+++ b/xserver/Xext/xf86bigfont.c
@@ -71,6 +71,7 @@
#include "gcstruct.h"
#include "dixfontstr.h"
#include "extnsionst.h"
+#include "extinit.h"
#include "protocol-versions.h"
#include <X11/extensions/xf86bigfproto.h>
@@ -277,28 +278,24 @@ ProcXF86BigfontQueryVersion(ClientPtr client)
xXF86BigfontQueryVersionReply reply;
REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq);
- reply.type = X_Reply;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- reply.majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION;
- reply.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION;
- reply.uid = geteuid();
- reply.gid = getegid();
+ reply = (xXF86BigfontQueryVersionReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION,
+ .minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION,
+ .uid = geteuid(),
+ .gid = getegid(),
#ifdef HAS_SHM
- reply.signature = signature;
+ .signature = signature,
+ .capabilities = (client->local && !client->swapped)
+ ? XF86Bigfont_CAP_LocalShm : 0
#else
- reply.signature = 0; /* This is redundant. Avoids uninitialized memory. */
+ .signature = 0,
+ .capabilities = 0
#endif
- reply.capabilities =
-#ifdef HAS_SHM
- (LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0)
-#else
- 0
-#endif
- ; /* may add more bits here in future versions */
+ };
if (client->swapped) {
- char tmp;
-
swaps(&reply.sequenceNumber);
swapl(&reply.length);
swaps(&reply.majorVersion);
@@ -307,16 +304,13 @@ ProcXF86BigfontQueryVersion(ClientPtr client)
swapl(&reply.gid);
swapl(&reply.signature);
}
- WriteToClient(client,
- sizeof(xXF86BigfontQueryVersionReply), (char *) &reply);
+ WriteToClient(client, sizeof(xXF86BigfontQueryVersionReply), &reply);
return Success;
}
static void
swapCharInfo(xCharInfo * pCI)
{
- char tmp;
-
swaps(&pCI->leftSideBearing);
swaps(&pCI->rightSideBearing);
swaps(&pCI->characterWidth);
@@ -359,7 +353,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
#else
switch (client->req_len) {
case 2: /* client with version 1.0 libX11 */
- stuff_flags = (LocalClient(client) &&
+ stuff_flags = (client->local &&
!client->swapped ? XF86Bigfont_FLAGS_Shm : 0);
break;
case 3: /* client with version 1.1 libX11 */
@@ -555,7 +549,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
? nUniqCharInfos * sizeof(xCharInfo)
+ (nCharInfos + 1) / 2 * 2 * sizeof(CARD16)
: 0);
- xXF86BigfontQueryFontReply *reply = malloc(rlength);
+ xXF86BigfontQueryFontReply *reply = calloc(1, rlength);
char *p;
if (!reply) {
@@ -587,8 +581,6 @@ ProcXF86BigfontQueryFont(ClientPtr client)
reply->shmid = shmid;
reply->shmsegoffset = 0;
if (client->swapped) {
- char tmp;
-
swaps(&reply->sequenceNumber);
swapl(&reply->length);
swapCharInfo(&reply->minBounds);
@@ -615,8 +607,6 @@ ProcXF86BigfontQueryFont(ClientPtr client)
prFP->name = pFP->name;
prFP->value = pFP->value;
if (client->swapped) {
- char tmp;
-
swapl(&prFP->name);
swapl(&prFP->value);
}
@@ -638,13 +628,11 @@ ProcXF86BigfontQueryFont(ClientPtr client)
for (j = 0; j < nCharInfos; j++, ps++) {
*ps = pIndex2UniqIndex[j];
if (client->swapped) {
- char tmp;
-
swaps(ps);
}
}
}
- WriteToClient(client, rlength, (char *) reply);
+ WriteToClient(client, rlength, reply);
free(reply);
if (nCharInfos > 0) {
if (shmid == -1)
@@ -675,7 +663,6 @@ static int
SProcXF86BigfontQueryVersion(ClientPtr client)
{
REQUEST(xXF86BigfontQueryVersionReq);
- char tmp;
swaps(&stuff->length);
return ProcXF86BigfontQueryVersion(client);
@@ -685,7 +672,6 @@ static int
SProcXF86BigfontQueryFont(ClientPtr client)
{
REQUEST(xXF86BigfontQueryFontReq);
- char tmp;
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
diff --git a/xserver/Xext/xf86bigfontsrv.h b/xserver/Xext/xf86bigfontsrv.h
index 2c78dc4c9..eab528775 100644
--- a/xserver/Xext/xf86bigfontsrv.h
+++ b/xserver/Xext/xf86bigfontsrv.h
@@ -27,7 +27,6 @@
#include <X11/fonts/font.h>
-extern void XFree86BigfontExtensionInit(void);
extern void XF86BigfontFreeFontShm(FontPtr);
extern void XF86BigfontCleanup(void);
diff --git a/xserver/Xext/xres.c b/xserver/Xext/xres.c
index 9d89b6550..445abcab8 100644
--- a/xserver/Xext/xres.c
+++ b/xserver/Xext/xres.c
@@ -10,6 +10,7 @@
#include <string.h>
#include <X11/X.h>
#include <X11/Xproto.h>
+#include <assert.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
@@ -20,29 +21,196 @@
#include "pixmapstr.h"
#include "windowstr.h"
#include "gcstruct.h"
-#include "modinit.h"
+#include "extinit.h"
#include "protocol-versions.h"
+#include "client.h"
+#include "list.h"
+#include "misc.h"
+#include <string.h>
+#include "hashtable.h"
+#include "picturestr.h"
+
+#ifdef COMPOSITE
+#include "compint.h"
+#endif
+
+/** @brief Holds fragments of responses for ConstructClientIds.
+ *
+ * note: there is no consideration for data alignment */
+typedef struct {
+ struct xorg_list l;
+ int bytes;
+ /* data follows */
+} FragmentList;
+
+#define FRAGMENT_DATA(ptr) ((void*) ((char*) (ptr) + sizeof(FragmentList)))
+
+/** @brief Holds structure for the generated response to
+ ProcXResQueryClientIds; used by ConstructClientId* -functions */
+typedef struct {
+ int numIds;
+ int resultBytes;
+ struct xorg_list response;
+ int sentClientMasks[MAXCLIENTS];
+} ConstructClientIdCtx;
+
+/** @brief Holds the structure for information required to
+ generate the response to XResQueryResourceBytes. In addition
+ to response it contains information on the query as well,
+ as well as some volatile information required by a few
+ functions that cannot take that information directly
+ via a parameter, as they are called via already-existing
+ higher order functions. */
+typedef struct {
+ ClientPtr sendClient;
+ int numSizes;
+ int resultBytes;
+ struct xorg_list response;
+ int status;
+ long numSpecs;
+ xXResResourceIdSpec *specs;
+ HashTable visitedResources;
+
+ /* Used by AddSubResourceSizeSpec when AddResourceSizeValue is
+ handling crossreferences */
+ HashTable visitedSubResources;
+
+ /* used when ConstructResourceBytesCtx is passed to
+ AddResourceSizeValue2 via FindClientResourcesByType */
+ RESTYPE resType;
+
+ /* used when ConstructResourceBytesCtx is passed to
+ AddResourceSizeValueByResource from ConstructResourceBytesByResource */
+ xXResResourceIdSpec *curSpec;
+
+ /** Used when iterating through a single resource's subresources
+
+ @see AddSubResourceSizeSpec */
+ xXResResourceSizeValue *sizeValue;
+} ConstructResourceBytesCtx;
+
+/** @brief Allocate and add a sequence of bytes at the end of a fragment list.
+ Call DestroyFragments to release the list.
+
+ @param frags A pointer to head of an initialized linked list
+ @param bytes Number of bytes to allocate
+ @return Returns a pointer to the allocated non-zeroed region
+ that is to be filled by the caller. On error (out of memory)
+ returns NULL and makes no changes to the list.
+*/
+static void *
+AddFragment(struct xorg_list *frags, int bytes)
+{
+ FragmentList *f = malloc(sizeof(FragmentList) + bytes);
+ if (!f) {
+ return NULL;
+ } else {
+ f->bytes = bytes;
+ xorg_list_add(&f->l, frags->prev);
+ return (char*) f + sizeof(*f);
+ }
+}
+
+/** @brief Sends all fragments in the list to the client. Does not
+ free anything.
+
+ @param client The client to send the fragments to
+ @param frags The head of the list of fragments
+*/
+static void
+WriteFragmentsToClient(ClientPtr client, struct xorg_list *frags)
+{
+ FragmentList *it;
+ xorg_list_for_each_entry(it, frags, l) {
+ WriteToClient(client, it->bytes, (char*) it + sizeof(*it));
+ }
+}
+
+/** @brief Frees a list of fragments. Does not free() root node.
+
+ @param frags The head of the list of fragments
+*/
+static void
+DestroyFragments(struct xorg_list *frags)
+{
+ FragmentList *it, *tmp;
+ xorg_list_for_each_entry_safe(it, tmp, frags, l) {
+ xorg_list_del(&it->l);
+ free(it);
+ }
+}
+
+/** @brief Constructs a context record for ConstructClientId* functions
+ to use */
+static void
+InitConstructClientIdCtx(ConstructClientIdCtx *ctx)
+{
+ ctx->numIds = 0;
+ ctx->resultBytes = 0;
+ xorg_list_init(&ctx->response);
+ memset(ctx->sentClientMasks, 0, sizeof(ctx->sentClientMasks));
+}
+
+/** @brief Destroys a context record, releases all memory (except the storage
+ for *ctx itself) */
+static void
+DestroyConstructClientIdCtx(ConstructClientIdCtx *ctx)
+{
+ DestroyFragments(&ctx->response);
+}
+
+static Bool
+InitConstructResourceBytesCtx(ConstructResourceBytesCtx *ctx,
+ ClientPtr sendClient,
+ long numSpecs,
+ xXResResourceIdSpec *specs)
+{
+ ctx->sendClient = sendClient;
+ ctx->numSizes = 0;
+ ctx->resultBytes = 0;
+ xorg_list_init(&ctx->response);
+ ctx->status = Success;
+ ctx->numSpecs = numSpecs;
+ ctx->specs = specs;
+ ctx->visitedResources = ht_create(sizeof(XID), 0,
+ ht_resourceid_hash, ht_resourceid_compare,
+ NULL);
+
+ if (!ctx->visitedResources) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+}
+
+static void
+DestroyConstructResourceBytesCtx(ConstructResourceBytesCtx *ctx)
+{
+ DestroyFragments(&ctx->response);
+ ht_destroy(ctx->visitedResources);
+}
static int
ProcXResQueryVersion(ClientPtr client)
{
REQUEST(xXResQueryVersionReq);
- xXResQueryVersionReply rep;
+ xXResQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .server_major = SERVER_XRES_MAJOR_VERSION,
+ .server_minor = SERVER_XRES_MINOR_VERSION
+ };
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.server_major = SERVER_XRES_MAJOR_VERSION;
- rep.server_minor = SERVER_XRES_MINOR_VERSION;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.server_major);
swaps(&rep.server_minor);
}
- WriteToClient(client, sizeof(xXResQueryVersionReply), (char *) &rep);
+ WriteToClient(client, sizeof(xXResQueryVersionReply), &rep);
return Success;
}
@@ -66,16 +234,18 @@ ProcXResQueryClients(ClientPtr client)
}
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.num_clients = num_clients;
- rep.length = bytes_to_int32(rep.num_clients * sz_xXResClient);
+ rep = (xXResQueryClientsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(num_clients * sz_xXResClient),
+ .num_clients = num_clients
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.num_clients);
}
- WriteToClient(client, sizeof(xXResQueryClientsReply), (char *) &rep);
+ WriteToClient(client, sizeof(xXResQueryClientsReply), &rep);
if (num_clients) {
xXResClient scratch;
@@ -88,7 +258,7 @@ ProcXResQueryClients(ClientPtr client)
swapl(&scratch.resource_base);
swapl(&scratch.resource_mask);
}
- WriteToClient(client, sz_xXResClient, (char *) &scratch);
+ WriteToClient(client, sz_xXResClient, &scratch);
}
}
@@ -133,18 +303,19 @@ ProcXResQueryClientResources(ClientPtr client)
num_types++;
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.num_types = num_types;
- rep.length = bytes_to_int32(rep.num_types * sz_xXResType);
+ rep = (xXResQueryClientResourcesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(num_types * sz_xXResType),
+ .num_types = num_types
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.num_types);
}
- WriteToClient(client, sizeof(xXResQueryClientResourcesReply),
- (char *) &rep);
+ WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep);
if (num_types) {
xXResType scratch;
@@ -170,7 +341,7 @@ ProcXResQueryClientResources(ClientPtr client)
swapl(&scratch.resource_type);
swapl(&scratch.count);
}
- WriteToClient(client, sz_xXResType, (char *) &scratch);
+ WriteToClient(client, sz_xXResType, &scratch);
}
}
@@ -195,6 +366,17 @@ ResGetApproxPixmapBytes(PixmapPtr pix)
}
static void
+ResFindResourcePixmaps(pointer value, XID id, RESTYPE type, pointer cdata)
+{
+ SizeType sizeFunc = GetResourceTypeSizeFunc(type);
+ ResourceSizeRec size = { 0, 0, 0 };
+ unsigned long *bytes = cdata;
+
+ sizeFunc(value, id, &size);
+ *bytes += size.pixmapRefSize;
+}
+
+static void
ResFindPixmaps(pointer value, XID id, pointer cdata)
{
unsigned long *bytes = (unsigned long *) cdata;
@@ -229,6 +411,22 @@ ResFindGCPixmaps(pointer value, XID id, pointer cdata)
*bytes += ResGetApproxPixmapBytes(pGC->tile.pixmap);
}
+static void
+ResFindPicturePixmaps(pointer value, XID id, pointer cdata)
+{
+#ifdef RENDER
+ ResFindResourcePixmaps(value, id, PictureType, cdata);
+#endif
+}
+
+static void
+ResFindCompositeClientWindowPixmaps (pointer value, XID id, pointer cdata)
+{
+#ifdef COMPOSITE
+ ResFindResourcePixmaps(value, id, CompositeClientWindowType, cdata);
+#endif
+}
+
static int
ProcXResQueryClientPixmapBytes(ClientPtr client)
{
@@ -263,31 +461,622 @@ ProcXResQueryClientPixmapBytes(ClientPtr client)
FindClientResourcesByType(clients[clientID], RT_GC,
ResFindGCPixmaps, (pointer) (&bytes));
+#ifdef RENDER
+ /* Render extension picture pixmaps. */
+ FindClientResourcesByType(clients[clientID], PictureType,
+ ResFindPicturePixmaps,
+ (pointer)(&bytes));
+#endif
+
#ifdef COMPOSITE
- /* FIXME: include composite pixmaps too */
+ /* Composite extension client window pixmaps. */
+ FindClientResourcesByType(clients[clientID], CompositeClientWindowType,
+ ResFindCompositeClientWindowPixmaps,
+ (pointer)(&bytes));
#endif
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.bytes = bytes;
+ rep = (xXResQueryClientPixmapBytesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .bytes = bytes,
#ifdef _XSERVER64
- rep.bytes_overflow = bytes >> 32;
+ .bytes_overflow = bytes >> 32
#else
- rep.bytes_overflow = 0;
+ .bytes_overflow = 0
#endif
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.bytes);
swapl(&rep.bytes_overflow);
}
- WriteToClient(client, sizeof(xXResQueryClientPixmapBytesReply),
- (char *) &rep);
+ WriteToClient(client, sizeof(xXResQueryClientPixmapBytesReply), &rep);
return Success;
}
+/** @brief Finds out if a client's information need to be put into the
+ response; marks client having been handled, if that is the case.
+
+ @param client The client to send information about
+ @param mask The request mask (0 to send everything, otherwise a
+ bitmask of X_XRes*Mask)
+ @param ctx The context record that tells which clients and id types
+ have been already handled
+ @param sendMask Which id type are we now considering. One of X_XRes*Mask.
+
+ @return Returns TRUE if the client information needs to be on the
+ response, otherwise FALSE.
+*/
+static Bool
+WillConstructMask(ClientPtr client, CARD32 mask,
+ ConstructClientIdCtx *ctx, int sendMask)
+{
+ if ((!mask || (mask & sendMask))
+ && !(ctx->sentClientMasks[client->index] & sendMask)) {
+ ctx->sentClientMasks[client->index] |= sendMask;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/** @brief Constructs a response about a single client, based on a certain
+ client id spec
+
+ @param sendClient Which client wishes to receive this answer. Used for
+ byte endianess.
+ @param client Which client are we considering.
+ @param mask The client id spec mask indicating which information
+ we want about this client.
+ @param ctx The context record containing the constructed response
+ and information on which clients and masks have been
+ already handled.
+
+ @return Return TRUE if everything went OK, otherwise FALSE which indicates
+ a memory allocation problem.
+*/
+static Bool
+ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
+ ConstructClientIdCtx *ctx)
+{
+ xXResClientIdValue rep;
+
+ rep.spec.client = client->clientAsMask;
+ if (client->swapped) {
+ swapl (&rep.spec.client);
+ }
+
+ if (WillConstructMask(client, mask, ctx, X_XResClientXIDMask)) {
+ void *ptr = AddFragment(&ctx->response, sizeof(rep));
+ if (!ptr) {
+ return FALSE;
+ }
+
+ rep.spec.mask = X_XResClientXIDMask;
+ rep.length = 0;
+ if (sendClient->swapped) {
+ swapl (&rep.spec.mask);
+ /* swapl (&rep.length, n); - not required for rep.length = 0 */
+ }
+
+ memcpy(ptr, &rep, sizeof(rep));
+
+ ctx->resultBytes += sizeof(rep);
+ ++ctx->numIds;
+ }
+ if (WillConstructMask(client, mask, ctx, X_XResLocalClientPIDMask)) {
+ pid_t pid = GetClientPid(client);
+
+ if (pid != -1) {
+ void *ptr = AddFragment(&ctx->response,
+ sizeof(rep) + sizeof(CARD32));
+ CARD32 *value = (void*) ((char*) ptr + sizeof(rep));
+
+ if (!ptr) {
+ return FALSE;
+ }
+
+ rep.spec.mask = X_XResLocalClientPIDMask;
+ rep.length = 4;
+
+ if (sendClient->swapped) {
+ swapl (&rep.spec.mask);
+ swapl (&rep.length);
+ }
+
+ if (sendClient->swapped) {
+ swapl (value);
+ }
+ memcpy(ptr, &rep, sizeof(rep));
+ *value = pid;
+
+ ctx->resultBytes += sizeof(rep) + sizeof(CARD32);
+ ++ctx->numIds;
+ }
+ }
+
+ /* memory allocation errors earlier may return with FALSE */
+ return TRUE;
+}
+
+/** @brief Constructs a response about all clients, based on a client id specs
+
+ @param client Which client which we are constructing the response for.
+ @param numSpecs Number of client id specs in specs
+ @param specs Client id specs
+
+ @return Return Success if everything went OK, otherwise a Bad* (currently
+ BadAlloc or BadValue)
+*/
+static int
+ConstructClientIds(ClientPtr client,
+ int numSpecs, xXResClientIdSpec* specs,
+ ConstructClientIdCtx *ctx)
+{
+ int specIdx;
+
+ for (specIdx = 0; specIdx < numSpecs; ++specIdx) {
+ if (specs[specIdx].client == 0) {
+ int c;
+ for (c = 0; c < currentMaxClients; ++c) {
+ if (clients[c]) {
+ if (!ConstructClientIdValue(client, clients[c],
+ specs[specIdx].mask, ctx)) {
+ return BadAlloc;
+ }
+ }
+ }
+ } else {
+ int clientID = CLIENT_ID(specs[specIdx].client);
+
+ if ((clientID < currentMaxClients) && clients[clientID]) {
+ if (!ConstructClientIdValue(client, clients[clientID],
+ specs[specIdx].mask, ctx)) {
+ return BadAlloc;
+ }
+ }
+ }
+ }
+
+ /* memory allocation errors earlier may return with BadAlloc */
+ return Success;
+}
+
+/** @brief Response to XResQueryClientIds request introduced in XResProto v1.2
+
+ @param client Which client which we are constructing the response for.
+
+ @return Returns the value returned from ConstructClientIds with the same
+ semantics
+*/
+static int
+ProcXResQueryClientIds (ClientPtr client)
+{
+ REQUEST(xXResQueryClientIdsReq);
+
+ xXResClientIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
+ int rc;
+ ConstructClientIdCtx ctx;
+
+ InitConstructClientIdCtx(&ctx);
+
+ REQUEST_AT_LEAST_SIZE(xXResQueryClientIdsReq);
+ REQUEST_FIXED_SIZE(xXResQueryClientIdsReq,
+ stuff->numSpecs * sizeof(specs[0]));
+
+ rc = ConstructClientIds(client, stuff->numSpecs, specs, &ctx);
+
+ if (rc == Success) {
+ xXResQueryClientIdsReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(ctx.resultBytes),
+ .numIds = ctx.numIds
+ };
+
+ assert((ctx.resultBytes & 3) == 0);
+
+ if (client->swapped) {
+ swaps (&rep.sequenceNumber);
+ swapl (&rep.length);
+ swapl (&rep.numIds);
+ }
+
+ WriteToClient(client, sizeof(rep), &rep);
+ WriteFragmentsToClient(client, &ctx.response);
+ }
+
+ DestroyConstructClientIdCtx(&ctx);
+
+ return rc;
+}
+
+/** @brief Swaps xXResResourceIdSpec endianess */
+static void
+SwapXResResourceIdSpec(xXResResourceIdSpec *spec)
+{
+ swapl(&spec->resource);
+ swapl(&spec->type);
+}
+
+/** @brief Swaps xXResResourceSizeSpec endianess */
+static void
+SwapXResResourceSizeSpec(xXResResourceSizeSpec *size)
+{
+ SwapXResResourceIdSpec(&size->spec);
+ swapl(&size->bytes);
+ swapl(&size->refCount);
+ swapl(&size->useCount);
+}
+
+/** @brief Swaps xXResResourceSizeValue endianess */
+static void
+SwapXResResourceSizeValue(xXResResourceSizeValue *rep)
+{
+ SwapXResResourceSizeSpec(&rep->size);
+ swapl(&rep->numCrossReferences);
+}
+
+/** @brief Swaps the response bytes */
+static void
+SwapXResQueryResourceBytes(struct xorg_list *response)
+{
+ struct xorg_list *it = response->next;
+ int c;
+
+ while (it != response) {
+ xXResResourceSizeValue *value = FRAGMENT_DATA(it);
+ it = it->next;
+ for (c = 0; c < value->numCrossReferences; ++c) {
+ xXResResourceSizeSpec *spec = FRAGMENT_DATA(it);
+ SwapXResResourceSizeSpec(spec);
+ it = it->next;
+ }
+ SwapXResResourceSizeValue(value);
+ }
+}
+
+/** @brief Adds xXResResourceSizeSpec describing a resource's size into
+ the buffer contained in the context. The resource is considered
+ to be a subresource.
+
+ @see AddResourceSizeValue
+
+ @param[in] value The X resource object on which to add information
+ about to the buffer
+ @param[in] id The ID of the X resource
+ @param[in] type The type of the X resource
+ @param[in/out] cdata The context object of type ConstructResourceBytesCtx.
+ Void pointer type is used here to satisfy the type
+ FindRes
+*/
+static void
+AddSubResourceSizeSpec(pointer value,
+ XID id,
+ RESTYPE type,
+ pointer cdata)
+{
+ ConstructResourceBytesCtx *ctx = cdata;
+
+ if (ctx->status == Success) {
+ xXResResourceSizeSpec **prevCrossRef =
+ ht_find(ctx->visitedSubResources, &value);
+ if (!prevCrossRef) {
+ Bool ok = TRUE;
+ xXResResourceSizeSpec *crossRef =
+ AddFragment(&ctx->response, sizeof(xXResResourceSizeSpec));
+ ok = ok && crossRef != NULL;
+ if (ok) {
+ xXResResourceSizeSpec **p;
+ p = ht_add(ctx->visitedSubResources, &value);
+ if (!p) {
+ ok = FALSE;
+ } else {
+ *p = crossRef;
+ }
+ }
+ if (!ok) {
+ ctx->status = BadAlloc;
+ } else {
+ SizeType sizeFunc = GetResourceTypeSizeFunc(type);
+ ResourceSizeRec size = { 0, 0, 0 };
+ sizeFunc(value, id, &size);
+
+ crossRef->spec.resource = id;
+ crossRef->spec.type = type;
+ crossRef->bytes = size.resourceSize;
+ crossRef->refCount = size.refCnt;
+ crossRef->useCount = 1;
+
+ ++ctx->sizeValue->numCrossReferences;
+
+ ctx->resultBytes += sizeof(*crossRef);
+ }
+ } else {
+ /* if we have visited the subresource earlier (from current parent
+ resource), just increase its use count by one */
+ ++(*prevCrossRef)->useCount;
+ }
+ }
+}
+
+/** @brief Adds xXResResourceSizeValue describing a resource's size into
+ the buffer contained in the context. In addition, the
+ subresources are iterated and added as xXResResourceSizeSpec's
+ by using AddSubResourceSizeSpec
+
+ @see AddSubResourceSizeSpec
+
+ @param[in] value The X resource object on which to add information
+ about to the buffer
+ @param[in] id The ID of the X resource
+ @param[in] type The type of the X resource
+ @param[in/out] cdata The context object of type ConstructResourceBytesCtx.
+ Void pointer type is used here to satisfy the type
+ FindRes
+*/
+static void
+AddResourceSizeValue(pointer ptr, XID id, RESTYPE type, pointer cdata)
+{
+ ConstructResourceBytesCtx *ctx = cdata;
+ if (ctx->status == Success &&
+ !ht_find(ctx->visitedResources, &id)) {
+ Bool ok = TRUE;
+ HashTable ht;
+ HtGenericHashSetupRec htSetup = {
+ .keySize = sizeof(void*)
+ };
+
+ /* it doesn't matter that we don't undo the work done here
+ * immediately. All but ht_init will be undone at the end
+ * of the request and there can happen no failure after
+ * ht_init, so we don't need to clean it up here in any
+ * special way */
+
+ xXResResourceSizeValue *value =
+ AddFragment(&ctx->response, sizeof(xXResResourceSizeValue));
+ if (!value) {
+ ok = FALSE;
+ }
+ ok = ok && ht_add(ctx->visitedResources, &id);
+ if (ok) {
+ ht = ht_create(htSetup.keySize,
+ sizeof(xXResResourceSizeSpec*),
+ ht_generic_hash, ht_generic_compare,
+ &htSetup);
+ ok = ok && ht;
+ }
+
+ if (!ok) {
+ ctx->status = BadAlloc;
+ } else {
+ SizeType sizeFunc = GetResourceTypeSizeFunc(type);
+ ResourceSizeRec size = { 0, 0, 0 };
+
+ sizeFunc(ptr, id, &size);
+
+ value->size.spec.resource = id;
+ value->size.spec.type = type;
+ value->size.bytes = size.resourceSize;
+ value->size.refCount = size.refCnt;
+ value->size.useCount = 1;
+ value->numCrossReferences = 0;
+
+ ctx->sizeValue = value;
+ ctx->visitedSubResources = ht;
+ FindSubResources(ptr, type, AddSubResourceSizeSpec, ctx);
+ ctx->visitedSubResources = NULL;
+ ctx->sizeValue = NULL;
+
+ ctx->resultBytes += sizeof(*value);
+ ++ctx->numSizes;
+
+ ht_destroy(ht);
+ }
+ }
+}
+
+/** @brief A variant of AddResourceSizeValue that passes the resource type
+ through the context object to satisfy the type FindResType
+
+ @see AddResourceSizeValue
+
+ @param[in] ptr The resource
+ @param[in] id The resource ID
+ @param[in/out] cdata The context object that contains the resource type
+*/
+static void
+AddResourceSizeValueWithResType(pointer ptr, XID id, pointer cdata)
+{
+ ConstructResourceBytesCtx *ctx = cdata;
+ AddResourceSizeValue(ptr, id, ctx->resType, cdata);
+}
+
+/** @brief Adds the information of a resource into the buffer if it matches
+ the match condition.
+
+ @see AddResourceSizeValue
+
+ @param[in] ptr The resource
+ @param[in] id The resource ID
+ @param[in] type The resource type
+ @param[in/out] cdata The context object as a void pointer to satisfy the
+ type FindAllRes
+*/
+static void
+AddResourceSizeValueByResource(pointer ptr, XID id, RESTYPE type, pointer cdata)
+{
+ ConstructResourceBytesCtx *ctx = cdata;
+ xXResResourceIdSpec *spec = ctx->curSpec;
+
+ if ((!spec->type || spec->type == type) &&
+ (!spec->resource || spec->resource == id)) {
+ AddResourceSizeValue(ptr, id, type, ctx);
+ }
+}
+
+/** @brief Add all resources of the client into the result buffer
+ disregarding all those specifications that specify the
+ resource by its ID. Those are handled by
+ ConstructResourceBytesByResource
+
+ @see ConstructResourceBytesByResource
+
+ @param[in] aboutClient Which client is being considered
+ @param[in/out] ctx The context that contains the resource id
+ specifications as well as the result buffer
+*/
+static void
+ConstructClientResourceBytes(ClientPtr aboutClient,
+ ConstructResourceBytesCtx *ctx)
+{
+ int specIdx;
+ for (specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) {
+ xXResResourceIdSpec* spec = ctx->specs + specIdx;
+ if (spec->resource) {
+ /* these specs are handled elsewhere */
+ } else if (spec->type) {
+ ctx->resType = spec->type;
+ FindClientResourcesByType(aboutClient, spec->type,
+ AddResourceSizeValueWithResType, ctx);
+ } else {
+ FindAllClientResources(aboutClient, AddResourceSizeValue, ctx);
+ }
+ }
+}
+
+/** @brief Add the sizes of all such resources that can are specified by
+ their ID in the resource id specification. The scan can
+ by limited to a client with the aboutClient parameter
+
+ @see ConstructResourceBytesByResource
+
+ @param[in] aboutClient Which client is being considered. This may be None
+ to mean all clients.
+ @param[in/out] ctx The context that contains the resource id
+ specifications as well as the result buffer. In
+ addition this function uses the curSpec field to
+ keep a pointer to the current resource id
+ specification in it, which can be used by
+ AddResourceSizeValueByResource .
+*/
+static void
+ConstructResourceBytesByResource(XID aboutClient, ConstructResourceBytesCtx *ctx)
+{
+ int specIdx;
+ for (specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) {
+ xXResResourceIdSpec *spec = ctx->specs + specIdx;
+ if (spec->resource) {
+ int cid = CLIENT_ID(spec->resource);
+ if (cid < currentMaxClients &&
+ (aboutClient == None || cid == aboutClient)) {
+ ClientPtr client = clients[cid];
+ if (client) {
+ ctx->curSpec = spec;
+ FindAllClientResources(client,
+ AddResourceSizeValueByResource,
+ ctx);
+ }
+ }
+ }
+ }
+}
+
+/** @brief Build the resource size response for the given client
+ (or all if not specified) per the parameters set up
+ in the context object.
+
+ @param[in] aboutClient Which client to consider or None for all clients
+ @param[in/out] ctx The context object that contains the request as well
+ as the response buffer.
+*/
+static int
+ConstructResourceBytes(XID aboutClient,
+ ConstructResourceBytesCtx *ctx)
+{
+ if (aboutClient) {
+ int clientIdx = CLIENT_ID(aboutClient);
+ ClientPtr client = NullClient;
+
+ if ((clientIdx >= currentMaxClients) || !clients[clientIdx]) {
+ ctx->sendClient->errorValue = aboutClient;
+ return BadValue;
+ }
+
+ client = clients[clientIdx];
+
+ ConstructClientResourceBytes(client, ctx);
+ ConstructResourceBytesByResource(aboutClient, ctx);
+ } else {
+ int clientIdx;
+
+ ConstructClientResourceBytes(NULL, ctx);
+
+ for (clientIdx = 0; clientIdx < currentMaxClients; ++clientIdx) {
+ ClientPtr client = clients[clientIdx];
+
+ if (client) {
+ ConstructClientResourceBytes(client, ctx);
+ }
+ }
+
+ ConstructResourceBytesByResource(None, ctx);
+ }
+
+
+ return ctx->status;
+}
+
+/** @brief Implements the XResQueryResourceBytes of XResProto v1.2 */
+static int
+ProcXResQueryResourceBytes (ClientPtr client)
+{
+ REQUEST(xXResQueryResourceBytesReq);
+
+ int rc;
+ ConstructResourceBytesCtx ctx;
+
+ REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
+ stuff->numSpecs * sizeof(ctx.specs[0]));
+
+ if (!InitConstructResourceBytesCtx(&ctx, client,
+ stuff->numSpecs,
+ (void*) ((char*) stuff +
+ sz_xXResQueryResourceBytesReq))) {
+ return BadAlloc;
+ }
+
+ rc = ConstructResourceBytes(stuff->client, &ctx);
+
+ if (rc == Success) {
+ xXResQueryResourceBytesReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(ctx.resultBytes),
+ .numSizes = ctx.numSizes
+ };
+
+ if (client->swapped) {
+ swaps (&rep.sequenceNumber);
+ swapl (&rep.length);
+ swapl (&rep.numSizes);
+
+ SwapXResQueryResourceBytes(&ctx.response);
+ }
+
+ WriteToClient(client, sizeof(rep), &rep);
+ WriteFragmentsToClient(client, &ctx.response);
+ }
+
+ DestroyConstructResourceBytesCtx(&ctx);
+
+ return rc;
+}
+
static int
ProcResDispatch(ClientPtr client)
{
@@ -301,8 +1090,11 @@ ProcResDispatch(ClientPtr client)
return ProcXResQueryClientResources(client);
case X_XResQueryClientPixmapBytes:
return ProcXResQueryClientPixmapBytes(client);
- default:
- break;
+ case X_XResQueryClientIds:
+ return ProcXResQueryClientIds(client);
+ case X_XResQueryResourceBytes:
+ return ProcXResQueryResourceBytes(client);
+ default: break;
}
return BadRequest;
@@ -335,7 +1127,39 @@ SProcXResQueryClientPixmapBytes(ClientPtr client)
}
static int
-SProcResDispatch(ClientPtr client)
+SProcXResQueryClientIds (ClientPtr client)
+{
+ REQUEST(xXResQueryClientIdsReq);
+
+ REQUEST_AT_LEAST_SIZE (xXResQueryClientIdsReq);
+ swapl(&stuff->numSpecs);
+ return ProcXResQueryClientIds(client);
+}
+
+/** @brief Implements the XResQueryResourceBytes of XResProto v1.2.
+ This variant byteswaps request contents before issuing the
+ rest of the work to ProcXResQueryResourceBytes */
+static int
+SProcXResQueryResourceBytes (ClientPtr client)
+{
+ REQUEST(xXResQueryResourceBytesReq);
+ int c;
+ xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
+
+ swapl(&stuff->numSpecs);
+ REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
+ stuff->numSpecs * sizeof(specs[0]));
+
+ for (c = 0; c < stuff->numSpecs; ++c) {
+ SwapXResResourceIdSpec(specs + c);
+ }
+
+ return ProcXResQueryResourceBytes(client);
+}
+
+static int
+SProcResDispatch (ClientPtr client)
{
REQUEST(xReq);
swaps(&stuff->length);
@@ -349,15 +1173,18 @@ SProcResDispatch(ClientPtr client)
return SProcXResQueryClientResources(client);
case X_XResQueryClientPixmapBytes:
return SProcXResQueryClientPixmapBytes(client);
- default:
- break;
+ case X_XResQueryClientIds:
+ return SProcXResQueryClientIds(client);
+ case X_XResQueryResourceBytes:
+ return SProcXResQueryResourceBytes(client);
+ default: break;
}
return BadRequest;
}
void
-ResExtensionInit(INITARGS)
+ResExtensionInit(void)
{
(void) AddExtension(XRES_NAME, 0, 0,
ProcResDispatch, SProcResDispatch,
diff --git a/xserver/Xext/xselinux_ext.c b/xserver/Xext/xselinux_ext.c
index 342abb1a6..3115f03ea 100644
--- a/xserver/Xext/xselinux_ext.c
+++ b/xserver/Xext/xselinux_ext.c
@@ -26,7 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "windowstr.h"
#include "propertyst.h"
#include "extnsionst.h"
-#include "modinit.h"
+#include "extinit.h"
#include "xselinuxint.h"
#define CTX_DEV offsetof(SELinuxSubjectRec, dev_create_sid)
@@ -63,20 +63,20 @@ SELinuxCopyContext(char *ptr, unsigned len)
static int
ProcSELinuxQueryVersion(ClientPtr client)
{
- SELinuxQueryVersionReply rep;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.server_major = SELINUX_MAJOR_VERSION;
- rep.server_minor = SELINUX_MINOR_VERSION;
+ SELinuxQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .server_major = SELINUX_MAJOR_VERSION,
+ .server_minor = SELINUX_MINOR_VERSION
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.server_major);
swaps(&rep.server_minor);
}
- WriteToClient(client, sizeof(rep), (char *) &rep);
+ WriteToClient(client, sizeof(rep), &rep);
return Success;
}
@@ -93,10 +93,12 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid)
len = strlen(ctx) + 1;
}
- rep.type = X_Reply;
- rep.length = bytes_to_int32(len);
- rep.sequenceNumber = client->sequence;
- rep.context_len = len;
+ rep = (SELinuxGetContextReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(len),
+ .context_len = len
+ };
if (client->swapped) {
swapl(&rep.length);
@@ -104,7 +106,7 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid)
swapl(&rep.context_len);
}
- WriteToClient(client, sizeof(SELinuxGetContextReply), (char *) &rep);
+ WriteToClient(client, sizeof(SELinuxGetContextReply), &rep);
WriteToClient(client, len, ctx);
freecon(ctx);
return Success;
@@ -372,10 +374,12 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
}
/* Send reply to client */
- rep.type = X_Reply;
- rep.length = size;
- rep.sequenceNumber = client->sequence;
- rep.count = count;
+ rep = (SELinuxListItemsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = size,
+ .count = count
+ };
if (client->swapped) {
swapl(&rep.length);
@@ -383,8 +387,8 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
swapl(&rep.count);
}
- WriteToClient(client, sizeof(SELinuxListItemsReply), (char *) &rep);
- WriteToClient(client, size * 4, (char *) buf);
+ WriteToClient(client, sizeof(SELinuxListItemsReply), &rep);
+ WriteToClient(client, size * 4, buf);
/* Free stuff and return */
rc = Success;
@@ -683,7 +687,7 @@ SELinuxResetProc(ExtensionEntry * extEntry)
}
void
-SELinuxExtensionInit(INITARGS)
+SELinuxExtensionInit(void)
{
ExtensionEntry *extEntry;
diff --git a/xserver/Xext/xtest.c b/xserver/Xext/xtest.c
index e659b4154..0a854f39a 100644
--- a/xserver/Xext/xtest.c
+++ b/xserver/Xext/xtest.c
@@ -55,9 +55,7 @@
#include "eventstr.h"
#include "inpututils.h"
-#include "modinit.h"
-
-extern int DeviceValuator;
+#include "extinit.h"
/* XTest events are sent during request processing and may be interruped by
* a SIGIO. We need a separate event list to avoid events overwriting each
@@ -88,19 +86,21 @@ static int XTestSwapFakeInput(ClientPtr /* client */ ,
static int
ProcXTestGetVersion(ClientPtr client)
{
- xXTestGetVersionReply rep;
+ xXTestGetVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .majorVersion = XTestMajorVersion,
+ .minorVersion = XTestMinorVersion
+ };
REQUEST_SIZE_MATCH(xXTestGetVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = XTestMajorVersion;
- rep.minorVersion = XTestMinorVersion;
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swaps(&rep.minorVersion);
}
- WriteToClient(client, sizeof(xXTestGetVersionReply), (char *) &rep);
+ WriteToClient(client, sizeof(xXTestGetVersionReply), &rep);
return Success;
}
@@ -134,14 +134,16 @@ ProcXTestCompareCursor(ClientPtr client)
return rc;
}
}
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.same = (wCursor(pWin) == pCursor);
+ rep = (xXTestCompareCursorReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .same = (wCursor(pWin) == pCursor)
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
- WriteToClient(client, sizeof(xXTestCompareCursorReply), (char *) &rep);
+ WriteToClient(client, sizeof(xXTestCompareCursorReply), &rep);
return Success;
}
@@ -154,7 +156,6 @@ ProcXTestFakeInput(ClientPtr client)
DeviceIntPtr dev = NULL;
WindowPtr root;
Bool extension = FALSE;
- deviceValuator *dv = NULL;
ValuatorMask mask;
int valuators[MAX_VALUATORS] = { 0 };
int numValuators = 0;
@@ -239,14 +240,14 @@ ProcXTestFakeInput(ClientPtr client)
}
if (nev > 1 && !dev->valuator) {
- client->errorValue = dv->first_valuator;
+ client->errorValue = firstValuator;
return BadValue;
}
/* check validity of valuator events */
base = firstValuator;
for (n = 1; n < nev; n++) {
- dv = (deviceValuator *) (ev + n);
+ deviceValuator *dv = (deviceValuator *) (ev + n);
if (dv->type != DeviceValuator) {
client->errorValue = dv->type;
return BadValue;
@@ -304,7 +305,7 @@ ProcXTestFakeInput(ClientPtr client)
numValuators = 2;
firstValuator = 0;
if (ev->u.u.detail == xFalse)
- flags = POINTER_ABSOLUTE | POINTER_SCREEN;
+ flags = POINTER_ABSOLUTE | POINTER_DESKTOP;
break;
default:
client->errorValue = ev->u.u.type;
@@ -375,6 +376,14 @@ ProcXTestFakeInput(ClientPtr client)
client->errorValue = ev->u.keyButtonPointer.root;
return BadValue;
}
+
+ /* Add the root window's offset to the valuators */
+ if ((flags & POINTER_ABSOLUTE) && firstValuator <= 1 && numValuators > 0) {
+ if (firstValuator == 0)
+ valuators[0] += root->drawable.pScreen->x;
+ if (firstValuator < 2 && firstValuator + numValuators > 1)
+ valuators[1 - firstValuator] += root->drawable.pScreen->y;
+ }
}
if (ev->u.u.detail != xTrue && ev->u.u.detail != xFalse) {
client->errorValue = ev->u.u.detail;
@@ -417,7 +426,7 @@ ProcXTestFakeInput(ClientPtr client)
}
for (i = 0; i < nevents; i++)
- mieqProcessDeviceEvent(dev, &xtest_evlist[i], NULL);
+ mieqProcessDeviceEvent(dev, &xtest_evlist[i], miPointerGetScreen(inputInfo.pointer));
if (need_ptr_update)
miPointerUpdateSprite(dev);
@@ -675,7 +684,7 @@ XTestExtensionTearDown(ExtensionEntry * e)
}
void
-XTestExtensionInit(INITARGS)
+XTestExtensionInit(void)
{
AddExtension(XTestExtensionName, 0, 0,
ProcXTestDispatch, SProcXTestDispatch,
diff --git a/xserver/Xext/xvdisp.c b/xserver/Xext/xvdisp.c
index 8abd51c11..31b77839f 100644
--- a/xserver/Xext/xvdisp.c
+++ b/xserver/Xext/xvdisp.c
@@ -62,7 +62,7 @@ SWriteQueryExtensionReply(ClientPtr client, xvQueryExtensionReply * rep)
swaps(&rep->version);
swaps(&rep->revision);
- (void) WriteToClient(client, sz_xvQueryExtensionReply, (char *) rep);
+ WriteToClient(client, sz_xvQueryExtensionReply, rep);
return Success;
}
@@ -74,7 +74,7 @@ SWriteQueryAdaptorsReply(ClientPtr client, xvQueryAdaptorsReply * rep)
swapl(&rep->length);
swaps(&rep->num_adaptors);
- (void) WriteToClient(client, sz_xvQueryAdaptorsReply, (char *) rep);
+ WriteToClient(client, sz_xvQueryAdaptorsReply, rep);
return Success;
}
@@ -86,7 +86,7 @@ SWriteQueryEncodingsReply(ClientPtr client, xvQueryEncodingsReply * rep)
swapl(&rep->length);
swaps(&rep->num_encodings);
- (void) WriteToClient(client, sz_xvQueryEncodingsReply, (char *) rep);
+ WriteToClient(client, sz_xvQueryEncodingsReply, rep);
return Success;
}
@@ -99,7 +99,7 @@ SWriteAdaptorInfo(ClientPtr client, xvAdaptorInfo * pAdaptor)
swaps(&pAdaptor->num_ports);
swaps(&pAdaptor->num_formats);
- (void) WriteToClient(client, sz_xvAdaptorInfo, (char *) pAdaptor);
+ WriteToClient(client, sz_xvAdaptorInfo, pAdaptor);
return Success;
}
@@ -114,7 +114,7 @@ SWriteEncodingInfo(ClientPtr client, xvEncodingInfo * pEncoding)
swaps(&pEncoding->height);
swapl(&pEncoding->rate.numerator);
swapl(&pEncoding->rate.denominator);
- (void) WriteToClient(client, sz_xvEncodingInfo, (char *) pEncoding);
+ WriteToClient(client, sz_xvEncodingInfo, pEncoding);
return Success;
}
@@ -123,7 +123,7 @@ static int
SWriteFormat(ClientPtr client, xvFormat * pFormat)
{
swapl(&pFormat->visual);
- (void) WriteToClient(client, sz_xvFormat, (char *) pFormat);
+ WriteToClient(client, sz_xvFormat, pFormat);
return Success;
}
@@ -135,7 +135,7 @@ SWriteAttributeInfo(ClientPtr client, xvAttributeInfo * pAtt)
swapl(&pAtt->size);
swapl(&pAtt->min);
swapl(&pAtt->max);
- (void) WriteToClient(client, sz_xvAttributeInfo, (char *) pAtt);
+ WriteToClient(client, sz_xvAttributeInfo, pAtt);
return Success;
}
@@ -157,7 +157,7 @@ SWriteImageFormatInfo(ClientPtr client, xvImageFormatInfo * pImage)
swapl(&pImage->vert_u_period);
swapl(&pImage->vert_v_period);
- (void) WriteToClient(client, sz_xvImageFormatInfo, (char *) pImage);
+ WriteToClient(client, sz_xvImageFormatInfo, pImage);
return Success;
}
@@ -168,7 +168,7 @@ SWriteGrabPortReply(ClientPtr client, xvGrabPortReply * rep)
swaps(&rep->sequenceNumber);
swapl(&rep->length);
- (void) WriteToClient(client, sz_xvGrabPortReply, (char *) rep);
+ WriteToClient(client, sz_xvGrabPortReply, rep);
return Success;
}
@@ -180,7 +180,7 @@ SWriteGetPortAttributeReply(ClientPtr client, xvGetPortAttributeReply * rep)
swapl(&rep->length);
swapl(&rep->value);
- (void) WriteToClient(client, sz_xvGetPortAttributeReply, (char *) rep);
+ WriteToClient(client, sz_xvGetPortAttributeReply, rep);
return Success;
}
@@ -193,7 +193,7 @@ SWriteQueryBestSizeReply(ClientPtr client, xvQueryBestSizeReply * rep)
swaps(&rep->actual_width);
swaps(&rep->actual_height);
- (void) WriteToClient(client, sz_xvQueryBestSizeReply, (char *) rep);
+ WriteToClient(client, sz_xvQueryBestSizeReply, rep);
return Success;
}
@@ -207,7 +207,7 @@ SWriteQueryPortAttributesReply(ClientPtr client,
swapl(&rep->num_attributes);
swapl(&rep->text_size);
- (void) WriteToClient(client, sz_xvQueryPortAttributesReply, (char *) rep);
+ WriteToClient(client, sz_xvQueryPortAttributesReply, rep);
return Success;
}
@@ -223,7 +223,7 @@ SWriteQueryImageAttributesReply(ClientPtr client,
swaps(&rep->width);
swaps(&rep->height);
- (void) WriteToClient(client, sz_xvQueryImageAttributesReply, (char *) rep);
+ WriteToClient(client, sz_xvQueryImageAttributesReply, rep);
return Success;
}
@@ -235,66 +235,66 @@ SWriteListImageFormatsReply(ClientPtr client, xvListImageFormatsReply * rep)
swapl(&rep->length);
swapl(&rep->num_formats);
- (void) WriteToClient(client, sz_xvListImageFormatsReply, (char *) rep);
+ WriteToClient(client, sz_xvListImageFormatsReply, rep);
return Success;
}
#define _WriteQueryAdaptorsReply(_c,_d) \
if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \
- else WriteToClient(_c, sz_xvQueryAdaptorsReply, (char*)_d)
+ else WriteToClient(_c, sz_xvQueryAdaptorsReply, _d)
#define _WriteQueryExtensionReply(_c,_d) \
if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \
- else WriteToClient(_c, sz_xvQueryExtensionReply, (char*)_d)
+ else WriteToClient(_c, sz_xvQueryExtensionReply, _d)
#define _WriteQueryEncodingsReply(_c,_d) \
if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \
- else WriteToClient(_c, sz_xvQueryEncodingsReply, (char*)_d)
+ else WriteToClient(_c, sz_xvQueryEncodingsReply, _d)
#define _WriteAdaptorInfo(_c,_d) \
if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \
- else WriteToClient(_c, sz_xvAdaptorInfo, (char*)_d)
+ else WriteToClient(_c, sz_xvAdaptorInfo, _d)
#define _WriteAttributeInfo(_c,_d) \
if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \
- else WriteToClient(_c, sz_xvAttributeInfo, (char*)_d)
+ else WriteToClient(_c, sz_xvAttributeInfo, _d)
#define _WriteEncodingInfo(_c,_d) \
if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \
- else WriteToClient(_c, sz_xvEncodingInfo, (char*)_d)
+ else WriteToClient(_c, sz_xvEncodingInfo, _d)
#define _WriteFormat(_c,_d) \
if ((_c)->swapped) SWriteFormat(_c, _d); \
- else WriteToClient(_c, sz_xvFormat, (char*)_d)
+ else WriteToClient(_c, sz_xvFormat, _d)
#define _WriteGrabPortReply(_c,_d) \
if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \
- else WriteToClient(_c, sz_xvGrabPortReply, (char*)_d)
+ else WriteToClient(_c, sz_xvGrabPortReply, _d)
#define _WriteGetPortAttributeReply(_c,_d) \
if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \
- else WriteToClient(_c, sz_xvGetPortAttributeReply, (char*)_d)
+ else WriteToClient(_c, sz_xvGetPortAttributeReply, _d)
#define _WriteQueryBestSizeReply(_c,_d) \
if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \
- else WriteToClient(_c, sz_xvQueryBestSizeReply,(char*) _d)
+ else WriteToClient(_c, sz_xvQueryBestSizeReply, _d)
#define _WriteQueryPortAttributesReply(_c,_d) \
if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \
- else WriteToClient(_c, sz_xvQueryPortAttributesReply,(char*) _d)
+ else WriteToClient(_c, sz_xvQueryPortAttributesReply, _d)
#define _WriteQueryImageAttributesReply(_c,_d) \
if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \
- else WriteToClient(_c, sz_xvQueryImageAttributesReply,(char*) _d)
+ else WriteToClient(_c, sz_xvQueryImageAttributesReply, _d)
#define _WriteListImageFormatsReply(_c,_d) \
if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \
- else WriteToClient(_c, sz_xvListImageFormatsReply,(char*) _d)
+ else WriteToClient(_c, sz_xvListImageFormatsReply, _d)
#define _WriteImageFormatInfo(_c,_d) \
if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \
- else WriteToClient(_c, sz_xvImageFormatInfo, (char*)_d)
+ else WriteToClient(_c, sz_xvImageFormatInfo, _d)
#define _AllocatePort(_i,_p) \
((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success
@@ -302,17 +302,17 @@ SWriteListImageFormatsReply(ClientPtr client, xvListImageFormatsReply * rep)
static int
ProcXvQueryExtension(ClientPtr client)
{
- xvQueryExtensionReply rep;
+ xvQueryExtensionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .version = XvVersion,
+ .revision = XvRevision
+ };
/* REQUEST(xvQueryExtensionReq); */
REQUEST_SIZE_MATCH(xvQueryExtensionReq);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.version = XvVersion;
- rep.revision = XvRevision;
-
_WriteQueryExtensionReply(client, &rep);
return Success;
@@ -343,10 +343,12 @@ ProcXvQueryAdaptors(ClientPtr client)
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
XvGetScreenKey());
if (!pxvs) {
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.num_adaptors = 0;
- rep.length = 0;
+ rep = (xvQueryAdaptorsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .num_adaptors = 0
+ };
_WriteQueryAdaptorsReply(client, &rep);
@@ -355,9 +357,11 @@ ProcXvQueryAdaptors(ClientPtr client)
(*pxvs->ddQueryAdaptors) (pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.num_adaptors = pxvs->nAdaptors;
+ rep = (xvQueryAdaptorsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .num_adaptors = pxvs->nAdaptors
+ };
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
@@ -429,9 +433,11 @@ ProcXvQueryEncodings(ClientPtr client)
return status;
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.num_encodings = pPort->pAdaptor->nEncodings;
+ rep = (xvQueryEncodingsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .num_encodings = pPort->pAdaptor->nEncodings
+ };
/* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
@@ -662,11 +668,12 @@ ProcXvGrabPort(ClientPtr client)
if (status != Success) {
return status;
}
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.result = result;
+ rep = (xvGrabPortReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .result = result
+ };
_WriteGrabPortReply(client, &rep);
@@ -777,10 +784,12 @@ ProcXvGetPortAttribute(ClientPtr client)
return status;
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.value = value;
+ rep = (xvGetPortAttributeReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .value = value
+ };
_WriteGetPortAttributeReply(client, &rep);
@@ -805,17 +814,18 @@ ProcXvQueryBestSize(ClientPtr client)
return status;
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
-
(*pPort->pAdaptor->ddQueryBestSize) (client, pPort, stuff->motion,
stuff->vid_w, stuff->vid_h,
stuff->drw_w, stuff->drw_h,
&actual_width, &actual_height);
- rep.actual_width = actual_width;
- rep.actual_height = actual_height;
+ rep = (xvQueryBestSizeReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .actual_width = actual_width,
+ .actual_height = actual_height
+ };
_WriteQueryBestSizeReply(client, &rep);
@@ -841,10 +851,12 @@ ProcXvQueryPortAttributes(ClientPtr client)
return status;
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.num_attributes = pPort->pAdaptor->nAttributes;
- rep.text_size = 0;
+ rep = (xvQueryPortAttributesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .num_attributes = pPort->pAdaptor->nAttributes,
+ .text_size = 0
+ };
for (i = 0, pAtt = pPort->pAdaptor->pAttributes;
i < pPort->pAdaptor->nAttributes; i++, pAtt++) {
@@ -1017,14 +1029,14 @@ ProcXvShmPutImage(ClientPtr client)
stuff->send_event, stuff->width, stuff->height);
if ((status == Success) && stuff->send_event) {
- xShmCompletionEvent ev;
-
- ev.type = ShmCompletionCode;
- ev.drawable = stuff->drawable;
- ev.minorEvent = xv_ShmPutImage;
- ev.majorEvent = XvReqCode;
- ev.shmseg = stuff->shmseg;
- ev.offset = stuff->offset;
+ xShmCompletionEvent ev = {
+ .type = ShmCompletionCode,
+ .drawable = stuff->drawable,
+ .minorEvent = xv_ShmPutImage,
+ .majorEvent = XvReqCode,
+ .shmseg = stuff->shmseg,
+ .offset = stuff->offset
+ };
WriteEventsToClient(client, 1, (xEvent *) &ev);
}
@@ -1089,18 +1101,20 @@ ProcXvQueryImageAttributes(ClientPtr client)
&width, &height, offsets,
pitches);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = planeLength = num_planes << 1;
- rep.num_planes = num_planes;
- rep.width = width;
- rep.height = height;
- rep.data_size = size;
+ rep = (xvQueryImageAttributesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = planeLength = num_planes << 1,
+ .num_planes = num_planes,
+ .width = width,
+ .height = height,
+ .data_size = size
+ };
_WriteQueryImageAttributesReply(client, &rep);
if (client->swapped)
SwapLongs((CARD32 *) offsets, planeLength);
- WriteToClient(client, planeLength << 2, (char *) offsets);
+ WriteToClient(client, planeLength << 2, offsets);
free(offsets);
@@ -1122,11 +1136,13 @@ ProcXvListImageFormats(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.num_formats = pPort->pAdaptor->nImages;
- rep.length =
- bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo);
+ rep = (xvListImageFormatsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .num_formats = pPort->pAdaptor->nImages,
+ .length =
+ bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo)
+ };
_WriteListImageFormatsReply(client, &rep);
diff --git a/xserver/Xext/xvdix.h b/xserver/Xext/xvdix.h
index d22672620..9c6160c3b 100644
--- a/xserver/Xext/xvdix.h
+++ b/xserver/Xext/xvdix.h
@@ -55,7 +55,6 @@ SOFTWARE.
#include "scrnintstr.h"
#include <X11/extensions/Xvproto.h>
-#ifndef XorgLoader
extern _X_EXPORT unsigned long XvExtensionGeneration;
extern _X_EXPORT unsigned long XvScreenGeneration;
extern _X_EXPORT unsigned long XvResourceGeneration;
@@ -70,7 +69,6 @@ extern _X_EXPORT RESTYPE XvRTGrab;
extern _X_EXPORT RESTYPE XvRTVideoNotify;
extern _X_EXPORT RESTYPE XvRTVideoNotifyList;
extern _X_EXPORT RESTYPE XvRTPortNotify;
-#endif
typedef struct {
int numerator;
@@ -215,7 +213,7 @@ typedef struct {
DestroyWindowProcPtr DestroyWindow;
DestroyPixmapProcPtr DestroyPixmap;
CloseScreenProcPtr CloseScreen;
- Bool (*ddCloseScreen) (int, ScreenPtr);
+ Bool (*ddCloseScreen) (ScreenPtr);
int (*ddQueryAdaptors) (ScreenPtr, XvAdaptorPtr *, int *);
DevUnion devPriv;
} XvScreenRec, *XvScreenPtr;
@@ -231,11 +229,9 @@ typedef struct {
#define _XvBadPort (XvBadPort+XvErrorBase)
#define _XvBadEncoding (XvBadEncoding+XvErrorBase)
-#ifndef XorgLoader
extern _X_EXPORT int ProcXvDispatch(ClientPtr);
extern _X_EXPORT int SProcXvDispatch(ClientPtr);
-extern _X_EXPORT void XvExtensionInit(void);
extern _X_EXPORT int XvScreenInit(ScreenPtr);
extern _X_EXPORT DevPrivateKey XvGetScreenKey(void);
extern _X_EXPORT unsigned long XvGetRTPort(void);
@@ -268,6 +264,4 @@ extern _X_EXPORT int XvdiPreemptVideo(ClientPtr, XvPortPtr, DrawablePtr);
extern _X_EXPORT int XvdiMatchPort(XvPortPtr, DrawablePtr);
extern _X_EXPORT int XvdiGrabPort(ClientPtr, XvPortPtr, Time, int *);
extern _X_EXPORT int XvdiUngrabPort(ClientPtr, XvPortPtr, Time);
-#endif /* XorgLoader */
-
#endif /* XVDIX_H */
diff --git a/xserver/Xext/xvmain.c b/xserver/Xext/xvmain.c
index 48061a286..c2860b86a 100644
--- a/xserver/Xext/xvmain.c
+++ b/xserver/Xext/xvmain.c
@@ -88,6 +88,7 @@ SOFTWARE.
#include "pixmapstr.h"
#include "gc.h"
#include "extnsionst.h"
+#include "extinit.h"
#include "dixstruct.h"
#include "resource.h"
#include "opaque.h"
@@ -129,7 +130,7 @@ static void WriteSwappedVideoNotifyEvent(xvEvent *, xvEvent *);
static void WriteSwappedPortNotifyEvent(xvEvent *, xvEvent *);
static Bool CreateResourceTypes(void);
-static Bool XvCloseScreen(int, ScreenPtr);
+static Bool XvCloseScreen(ScreenPtr);
static Bool XvDestroyPixmap(PixmapPtr);
static Bool XvDestroyWindow(WindowPtr);
static void XvResetProc(ExtensionEntry *);
@@ -290,7 +291,7 @@ XvScreenInit(ScreenPtr pScreen)
}
static Bool
-XvCloseScreen(int ii, ScreenPtr pScreen)
+XvCloseScreen(ScreenPtr pScreen)
{
XvScreenPtr pxvs;
@@ -301,13 +302,13 @@ XvCloseScreen(int ii, ScreenPtr pScreen)
pScreen->DestroyWindow = pxvs->DestroyWindow;
pScreen->CloseScreen = pxvs->CloseScreen;
- (*pxvs->ddCloseScreen) (ii, pScreen);
+ (*pxvs->ddCloseScreen) (pScreen);
free(pxvs);
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL);
- return (*pScreen->CloseScreen) (ii, pScreen);
+ return (*pScreen->CloseScreen) (pScreen);
}
static void
@@ -507,19 +508,20 @@ XvdiDestroyEncoding(pointer value, XID id)
static int
XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason)
{
- xvEvent event;
XvVideoNotifyPtr pn;
dixLookupResourceByType((pointer *) &pn, pDraw->id, XvRTVideoNotifyList,
serverClient, DixReadAccess);
while (pn) {
+ xvEvent event = {
+ .u.videoNotify.reason = reason,
+ .u.videoNotify.time = currentTime.milliseconds,
+ .u.videoNotify.drawable = pDraw->id,
+ .u.videoNotify.port = pPort->id
+ };
event.u.u.type = XvEventBase + XvVideoNotify;
- event.u.videoNotify.time = currentTime.milliseconds;
- event.u.videoNotify.drawable = pDraw->id;
- event.u.videoNotify.port = pPort->id;
- event.u.videoNotify.reason = reason;
- WriteEventsToClient(pn->client, 1, (xEventPtr) & event);
+ WriteEventsToClient(pn->client, 1, (xEventPtr) &event);
pn = pn->next;
}
@@ -530,18 +532,19 @@ XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason)
int
XvdiSendPortNotify(XvPortPtr pPort, Atom attribute, INT32 value)
{
- xvEvent event;
XvPortNotifyPtr pn;
pn = pPort->pNotify;
while (pn) {
+ xvEvent event = {
+ .u.portNotify.time = currentTime.milliseconds,
+ .u.portNotify.port = pPort->id,
+ .u.portNotify.attribute = attribute,
+ .u.portNotify.value = value
+ };
event.u.u.type = XvEventBase + XvPortNotify;
- event.u.portNotify.time = currentTime.milliseconds;
- event.u.portNotify.port = pPort->id;
- event.u.portNotify.attribute = attribute;
- event.u.portNotify.value = value;
- WriteEventsToClient(pn->client, 1, (xEventPtr) & event);
+ WriteEventsToClient(pn->client, 1, (xEventPtr) &event);
pn = pn->next;
}
diff --git a/xserver/Xext/xvmc.c b/xserver/Xext/xvmc.c
index 8a1d94085..5f0123b32 100644
--- a/xserver/Xext/xvmc.c
+++ b/xserver/Xext/xvmc.c
@@ -13,6 +13,7 @@
#include "resource.h"
#include "scrnintstr.h"
#include "extnsionst.h"
+#include "extinit.h"
#include "servermd.h"
#include <X11/Xfuncproto.h>
#include "xvdix.h"
@@ -36,8 +37,6 @@ static DevPrivateKeyRec XvMCScreenKeyRec;
#define XvMCScreenKey (&XvMCScreenKeyRec)
static Bool XvMCInUse;
-unsigned long XvMCGeneration = 0;
-
int XvMCReqCode;
int XvMCEventBase;
@@ -45,6 +44,8 @@ static RESTYPE XvMCRTContext;
static RESTYPE XvMCRTSurface;
static RESTYPE XvMCRTSubpicture;
+int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr) = NULL;
+
typedef struct {
int num_adaptors;
XvMCAdaptorPtr adaptors;
@@ -109,16 +110,18 @@ XvMCDestroySubpictureRes(pointer data, XID id)
static int
ProcXvMCQueryVersion(ClientPtr client)
{
- xvmcQueryVersionReply rep;
+ xvmcQueryVersionReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .major = SERVER_XVMC_MAJOR_VERSION,
+ .minor = SERVER_XVMC_MINOR_VERSION
+ };
/* REQUEST(xvmcQueryVersionReq); */
REQUEST_SIZE_MATCH(xvmcQueryVersionReq);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.major = SERVER_XVMC_MAJOR_VERSION;
- rep.minor = SERVER_XVMC_MINOR_VERSION;
- WriteToClient(client, sizeof(xvmcQueryVersionReply), (char *) &rep);
+
+ WriteToClient(client, sizeof(xvmcQueryVersionReply), &rep);
return Success;
}
@@ -132,6 +135,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
xvmcSurfaceInfo info;
XvMCAdaptorPtr adaptor = NULL;
XvMCSurfaceInfoPtr surface;
+ int num_surfaces;
REQUEST(xvmcListSurfaceTypesReq);
REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq);
@@ -151,14 +155,17 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
}
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.num = (adaptor) ? adaptor->num_surfaces : 0;
- rep.length = bytes_to_int32(rep.num * sizeof(xvmcSurfaceInfo));
+ num_surfaces = (adaptor) ? adaptor->num_surfaces : 0;
+ rep = (xvmcListSurfaceTypesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .num = num_surfaces,
+ .length = bytes_to_int32(num_surfaces * sizeof(xvmcSurfaceInfo)),
+ };
- WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), (char *) &rep);
+ WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), &rep);
- for (i = 0; i < rep.num; i++) {
+ for (i = 0; i < num_surfaces; i++) {
surface = adaptor->surfaces[i];
info.surface_type_id = surface->surface_type_id;
info.chroma_format = surface->chroma_format;
@@ -168,7 +175,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
info.subpicture_max_height = surface->subpicture_max_height;
info.mc_type = surface->mc_type;
info.flags = surface->flags;
- WriteToClient(client, sizeof(xvmcSurfaceInfo), (char *) &info);
+ WriteToClient(client, sizeof(xvmcSurfaceInfo), &info);
}
return Success;
@@ -247,16 +254,18 @@ ProcXvMCCreateContext(ClientPtr client)
return result;
}
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.width_actual = pContext->width;
- rep.height_actual = pContext->height;
- rep.flags_return = pContext->flags;
- rep.length = dwords;
+ rep = (xvmcCreateContextReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = dwords,
+ .width_actual = pContext->width,
+ .height_actual = pContext->height,
+ .flags_return = pContext->flags
+ };
- WriteToClient(client, sizeof(xvmcCreateContextReply), (char *) &rep);
+ WriteToClient(client, sizeof(xvmcCreateContextReply), &rep);
if (dwords)
- WriteToClient(client, dwords << 2, (char *) data);
+ WriteToClient(client, dwords << 2, data);
AddResource(pContext->context_id, XvMCRTContext, pContext);
free(data);
@@ -320,14 +329,15 @@ ProcXvMCCreateSurface(ClientPtr client)
free(pSurface);
return result;
}
+ rep = (xvmcCreateSurfaceReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = dwords
+ };
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = dwords;
-
- WriteToClient(client, sizeof(xvmcCreateSurfaceReply), (char *) &rep);
+ WriteToClient(client, sizeof(xvmcCreateSurfaceReply), &rep);
if (dwords)
- WriteToClient(client, dwords << 2, (char *) data);
+ WriteToClient(client, dwords << 2, data);
AddResource(pSurface->surface_id, XvMCRTSurface, pSurface);
free(data);
@@ -435,22 +445,23 @@ ProcXvMCCreateSubpicture(ClientPtr client)
free(pSubpicture);
return result;
}
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.width_actual = pSubpicture->width;
- rep.height_actual = pSubpicture->height;
- rep.num_palette_entries = pSubpicture->num_palette_entries;
- rep.entry_bytes = pSubpicture->entry_bytes;
- rep.component_order[0] = pSubpicture->component_order[0];
- rep.component_order[1] = pSubpicture->component_order[1];
- rep.component_order[2] = pSubpicture->component_order[2];
- rep.component_order[3] = pSubpicture->component_order[3];
- rep.length = dwords;
-
- WriteToClient(client, sizeof(xvmcCreateSubpictureReply), (char *) &rep);
+ rep = (xvmcCreateSubpictureReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = dwords,
+ .width_actual = pSubpicture->width,
+ .height_actual = pSubpicture->height,
+ .num_palette_entries = pSubpicture->num_palette_entries,
+ .entry_bytes = pSubpicture->entry_bytes,
+ .component_order[0] = pSubpicture->component_order[0],
+ .component_order[1] = pSubpicture->component_order[1],
+ .component_order[2] = pSubpicture->component_order[2],
+ .component_order[3] = pSubpicture->component_order[3]
+ };
+
+ WriteToClient(client, sizeof(xvmcCreateSubpictureReply), &rep);
if (dwords)
- WriteToClient(client, dwords << 2, (char *) data);
+ WriteToClient(client, dwords << 2, data);
AddResource(pSubpicture->subpicture_id, XvMCRTSubpicture, pSubpicture);
free(data);
@@ -525,15 +536,17 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
if (!surface)
return BadMatch;
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.num = 0;
+ rep = (xvmcListSubpictureTypesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .num = 0
+ };
if (surface->compatible_subpictures)
rep.num = surface->compatible_subpictures->num_xvimages;
rep.length = bytes_to_int32(rep.num * sizeof(xvImageFormatInfo));
- WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), (char *) &rep);
+ WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), &rep);
for (i = 0; i < rep.num; i++) {
pImage = NULL;
@@ -569,7 +582,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
info.vert_v_period = pImage->vert_v_period;
memcpy(&info.comp_order, pImage->component_order, 32);
info.scanline_order = pImage->scanline_order;
- WriteToClient(client, sizeof(xvImageFormatInfo), (char *) &info);
+ WriteToClient(client, sizeof(xvImageFormatInfo), &info);
}
return Success;
@@ -595,13 +608,16 @@ ProcXvMCGetDRInfo(ClientPtr client)
pScreen = pPort->pAdaptor->pScreen;
pScreenPriv = XVMC_GET_PRIVATE(pScreen);
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.major = pScreenPriv->major;
- rep.minor = pScreenPriv->minor;
- rep.patchLevel = pScreenPriv->patchLevel;
- rep.nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1);
- rep.busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1);
+ rep = (xvmcGetDRInfoReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .major = pScreenPriv->major,
+ .minor = pScreenPriv->minor,
+ .patchLevel = pScreenPriv->patchLevel,
+ .nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1),
+ .busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1),
+ .isLocal = 1
+ };
rep.length = rep.nameLen + rep.busIDLen;
rep.nameLen <<= 2;
@@ -612,7 +628,6 @@ ProcXvMCGetDRInfo(ClientPtr client)
* segment she prepared for us.
*/
- rep.isLocal = 1;
#ifdef HAS_XVMCSHM
patternP = (CARD32 *) shmat(stuff->shmKey, NULL, SHM_RDONLY);
if (-1 != (long) patternP) {
@@ -634,7 +649,7 @@ ProcXvMCGetDRInfo(ClientPtr client)
}
#endif /* HAS_XVMCSHM */
- WriteToClient(client, sizeof(xvmcGetDRInfoReply), (char *) &rep);
+ WriteToClient(client, sizeof(xvmcGetDRInfoReply), &rep);
if (rep.length) {
WriteToClient(client, rep.nameLen, pScreenPriv->clientDriverName);
WriteToClient(client, rep.busIDLen, pScreenPriv->busID);
@@ -709,7 +724,7 @@ XvMCExtensionInit(void)
}
static Bool
-XvMCCloseScreen(int i, ScreenPtr pScreen)
+XvMCCloseScreen(ScreenPtr pScreen)
{
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
@@ -717,7 +732,7 @@ XvMCCloseScreen(int i, ScreenPtr pScreen)
free(pScreenPriv);
- return (*pScreen->CloseScreen) (i, pScreen);
+ return (*pScreen->CloseScreen) (pScreen);
}
int
diff --git a/xserver/Xext/xvmcext.h b/xserver/Xext/xvmcext.h
index 5a4261bbd..2201d7b5b 100644
--- a/xserver/Xext/xvmcext.h
+++ b/xserver/Xext/xvmcext.h
@@ -84,8 +84,7 @@ typedef struct {
XvMCDestroySubpictureProcPtr DestroySubpicture;
} XvMCAdaptorRec, *XvMCAdaptorPtr;
-#ifndef XorgLoader
-extern _X_EXPORT void XvMCExtensionInit(void);
+extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr);
extern _X_EXPORT int XvMCScreenInit(ScreenPtr pScreen,
int num, XvMCAdaptorPtr adapt);
@@ -95,6 +94,5 @@ extern _X_EXPORT XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id);
extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name,
char *busID, int major, int minor,
int patchLevel);
-#endif
#endif /* _XVMC_H */