summaryrefslogtreecommitdiff
path: root/xserver/os
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2010-07-27 19:02:39 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2010-07-27 19:02:39 +0000
commit269d40cbcc43b41f621ca6d91c182952f60ec48e (patch)
tree872f2fddd3f2207e57a28595e73886713ce4a77a /xserver/os
parent917a2249b787451cad3f9697872aeccfd0da3324 (diff)
Update to xserver 1.8. Tested by many. Ok oga@, todd@.
Diffstat (limited to 'xserver/os')
-rw-r--r--xserver/os/Makefile.am25
-rw-r--r--xserver/os/Makefile.in177
-rw-r--r--xserver/os/WaitFor.c17
-rw-r--r--xserver/os/access.c57
-rw-r--r--xserver/os/backtrace.c48
-rw-r--r--xserver/os/connection.c49
-rw-r--r--xserver/os/io.c35
-rw-r--r--xserver/os/log.c81
-rw-r--r--xserver/os/mitauth.c4
-rw-r--r--xserver/os/osdep.h10
-rw-r--r--xserver/os/osinit.c121
-rw-r--r--xserver/os/rpcauth.c4
-rw-r--r--xserver/os/utils.c188
-rw-r--r--xserver/os/xdmauth.c8
-rw-r--r--xserver/os/xdmcp.c9
-rw-r--r--xserver/os/xsha1.c168
16 files changed, 726 insertions, 275 deletions
diff --git a/xserver/os/Makefile.am b/xserver/os/Makefile.am
index 02d806252..000c3885e 100644
--- a/xserver/os/Makefile.am
+++ b/xserver/os/Makefile.am
@@ -1,13 +1,21 @@
-noinst_LTLIBRARIES = libos.la
+noinst_LTLIBRARIES = libos.la liblog.la
-AM_CFLAGS = $(DIX_CFLAGS)
+AM_CFLAGS = $(DIX_CFLAGS) $(SHA1_CFLAGS)
SECURERPC_SRCS = rpcauth.c
XDMCP_SRCS = xdmcp.c
STRLCAT_SRCS = strlcat.c strlcpy.c
-XORG_SRCS = log.c
PRIVSEP_SRCS = privsep.c
+# Build a convenience library liblog.la that will be added into
+# libos.la. The split is done so that log.c can be built with
+# different compiler options.
+liblog_la_SOURCES = log.c
+# Add flags needed for proper backtraces of functions marked with GCC
+# __attribute__((noreturn)). Currently those flags are needed for
+# FatalError and AbortServer in log.c.
+liblog_la_CFLAGS = $(AM_CFLAGS) $(ARM_BACKTRACE_CFLAGS)
+
libos_la_SOURCES = \
WaitFor.c \
access.c \
@@ -23,9 +31,10 @@ libos_la_SOURCES = \
strcasecmp.c \
strcasestr.c \
xdmauth.c \
+ xsha1.c \
xstrans.c \
- xprintf.c \
- $(XORG_SRCS)
+ xprintf.c
+libos_la_LIBADD = @SHA1_LIBS@ $(DLOPEN_LIBS) liblog.la
if SECURE_RPC
libos_la_SOURCES += $(SECURERPC_SRCS)
@@ -46,15 +55,15 @@ endif
EXTRA_DIST = $(SECURERPC_SRCS) $(INTERNALMALLOC_SRCS) \
$(XDMCP_SRCS) $(STRLCAT_SRCS)
-if XSERVER_DTRACE
+if SPECIAL_DTRACE_OBJECTS
# Generate dtrace object code for probes in libos & libdix
dtrace.o: $(top_srcdir)/dix/Xserver.d $(am_libos_la_OBJECTS)
- $(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d .libs/*.o ../dix/.libs/*.o
+ $(AM_V_GEN)$(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d .libs/*.o ../dix/.libs/*.o
noinst_PROGRAMS = os.O
os.O: dtrace.o $(am_libos_la_OBJECTS)
- ld -r -o $@ dtrace.o .libs/*.o
+ $(AM_V_GEN)ld -r -o $@ dtrace.o .libs/*.o
endif
os.c:
diff --git a/xserver/os/Makefile.in b/xserver/os/Makefile.in
index 948604961..b6d665a50 100644
--- a/xserver/os/Makefile.in
+++ b/xserver/os/Makefile.in
@@ -41,12 +41,12 @@ host_triplet = @host@
@XDMCP_TRUE@am__append_2 = $(XDMCP_SRCS)
@NEED_STRLCAT_TRUE@am__append_3 = $(STRLCAT_SRCS)
@X_PRIVSEP_TRUE@am__append_4 = $(PRIVSEP_SRCS)
-@XSERVER_DTRACE_TRUE@noinst_PROGRAMS = os.O$(EXEEXT)
+@SPECIAL_DTRACE_OBJECTS_TRUE@noinst_PROGRAMS = os.O$(EXEEXT)
subdir = os
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \
+ $(top_srcdir)/m4/dolt.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(install_sh) -d
@@ -56,34 +56,38 @@ CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
$(top_builddir)/include/xorg-config.h \
$(top_builddir)/include/xkb-config.h \
$(top_builddir)/include/xwin-config.h \
- $(top_builddir)/include/kdrive-config.h
+ $(top_builddir)/include/kdrive-config.h \
+ $(top_builddir)/include/version-config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
-libos_la_LIBADD =
+liblog_la_LIBADD =
+am_liblog_la_OBJECTS = liblog_la-log.lo
+liblog_la_OBJECTS = $(am_liblog_la_OBJECTS)
+am__DEPENDENCIES_1 =
+libos_la_DEPENDENCIES = $(am__DEPENDENCIES_1) liblog.la
am__libos_la_SOURCES_DIST = WaitFor.c access.c auth.c backtrace.c \
connection.c io.c mitauth.c oscolor.c osdep.h osinit.c utils.c \
- strcasecmp.c strcasestr.c xdmauth.c xstrans.c xprintf.c log.c \
- rpcauth.c xdmcp.c strlcat.c strlcpy.c privsep.c
-am__objects_1 = log.lo
-am__objects_2 = rpcauth.lo
-@SECURE_RPC_TRUE@am__objects_3 = $(am__objects_2)
-am__objects_4 = xdmcp.lo
-@XDMCP_TRUE@am__objects_5 = $(am__objects_4)
-am__objects_6 = strlcat.lo strlcpy.lo
-@NEED_STRLCAT_TRUE@am__objects_7 = $(am__objects_6)
-am__objects_8 = privsep.lo
-@X_PRIVSEP_TRUE@am__objects_9 = $(am__objects_8)
+ strcasecmp.c strcasestr.c xdmauth.c xsha1.c xstrans.c \
+ xprintf.c rpcauth.c xdmcp.c strlcat.c strlcpy.c privsep.c
+am__objects_1 = rpcauth.lo
+@SECURE_RPC_TRUE@am__objects_2 = $(am__objects_1)
+am__objects_3 = xdmcp.lo
+@XDMCP_TRUE@am__objects_4 = $(am__objects_3)
+am__objects_5 = strlcat.lo strlcpy.lo
+@NEED_STRLCAT_TRUE@am__objects_6 = $(am__objects_5)
+am__objects_7 = privsep.lo
+@X_PRIVSEP_TRUE@am__objects_8 = $(am__objects_7)
am_libos_la_OBJECTS = WaitFor.lo access.lo auth.lo backtrace.lo \
connection.lo io.lo mitauth.lo oscolor.lo osinit.lo utils.lo \
- strcasecmp.lo strcasestr.lo xdmauth.lo xstrans.lo xprintf.lo \
- $(am__objects_1) $(am__objects_3) $(am__objects_5) \
- $(am__objects_7) $(am__objects_9)
+ strcasecmp.lo strcasestr.lo xdmauth.lo xsha1.lo xstrans.lo \
+ xprintf.lo $(am__objects_2) $(am__objects_4) $(am__objects_6) \
+ $(am__objects_8)
libos_la_OBJECTS = $(am_libos_la_OBJECTS)
PROGRAMS = $(noinst_PROGRAMS)
os_O_SOURCES = os.c
os_O_OBJECTS = os.$(OBJEXT)
os_O_LDADD = $(LDADD)
-DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include -I$(top_builddir)/include
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -91,8 +95,8 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(libos_la_SOURCES) os.c
-DIST_SOURCES = $(am__libos_la_SOURCES_DIST) os.c
+SOURCES = $(liblog_la_SOURCES) $(libos_la_SOURCES) os.c
+DIST_SOURCES = $(liblog_la_SOURCES) $(am__libos_la_SOURCES_DIST) os.c
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -109,12 +113,13 @@ ALPHA_VIDEO_TRUE = @ALPHA_VIDEO_TRUE@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
-APPLE_APPLICATION_ID = @APPLE_APPLICATION_ID@
APPLE_APPLICATION_NAME = @APPLE_APPLICATION_NAME@
APP_MAN_DIR = @APP_MAN_DIR@
APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
AR = @AR@
+ARM_BACKTRACE_CFLAGS = @ARM_BACKTRACE_CFLAGS@
ARM_VIDEO_FALSE = @ARM_VIDEO_FALSE@
ARM_VIDEO_TRUE = @ARM_VIDEO_TRUE@
AS = @AS@
@@ -142,6 +147,7 @@ CCAS = @CCAS@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
+CHANGELOG_CMD = @CHANGELOG_CMD@
COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
COMPOSITE_FALSE = @COMPOSITE_FALSE@
COMPOSITE_TRUE = @COMPOSITE_TRUE@
@@ -151,8 +157,11 @@ CONFIG_HAL_FALSE = @CONFIG_HAL_FALSE@
CONFIG_HAL_TRUE = @CONFIG_HAL_TRUE@
CONFIG_NEED_DBUS_FALSE = @CONFIG_NEED_DBUS_FALSE@
CONFIG_NEED_DBUS_TRUE = @CONFIG_NEED_DBUS_TRUE@
+CONFIG_UDEV_FALSE = @CONFIG_UDEV_FALSE@
+CONFIG_UDEV_TRUE = @CONFIG_UDEV_TRUE@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CWARNFLAGS = @CWARNFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -166,6 +175,7 @@ DBUS_LIBS = @DBUS_LIBS@
DEBUG_FALSE = @DEBUG_FALSE@
DEBUG_TRUE = @DEBUG_TRUE@
DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
DEFS = @DEFS@
@@ -175,7 +185,9 @@ DGA_FALSE = @DGA_FALSE@
DGA_LIBS = @DGA_LIBS@
DGA_TRUE = @DGA_TRUE@
DIX_CFLAGS = @DIX_CFLAGS@
+DIX_LIB = @DIX_LIB@
DLLTOOL = @DLLTOOL@
+DLOPEN_LIBS = @DLOPEN_LIBS@
DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
@@ -191,6 +203,7 @@ DMX_BUILD_USB_TRUE = @DMX_BUILD_USB_TRUE@
DMX_FALSE = @DMX_FALSE@
DMX_TRUE = @DMX_TRUE@
DOLT_BASH = @DOLT_BASH@
+DOXYGEN = @DOXYGEN@
DPMSExtension_FALSE = @DPMSExtension_FALSE@
DPMSExtension_TRUE = @DPMSExtension_TRUE@
DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
@@ -203,8 +216,10 @@ 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_FALSE = @DRI_FALSE@
+DRI_LIBS = @DRI_LIBS@
DRI_TRUE = @DRI_TRUE@
DSYMUTIL = @DSYMUTIL@
DTRACE = @DTRACE@
@@ -220,8 +235,17 @@ FBDEVHW_TRUE = @FBDEVHW_TRUE@
FFLAGS = @FFLAGS@
FILE_MAN_DIR = @FILE_MAN_DIR@
FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FONT100DPIDIR = @FONT100DPIDIR@
+FONT75DPIDIR = @FONT75DPIDIR@
+FONTMISCDIR = @FONTMISCDIR@
+FONTOTFDIR = @FONTOTFDIR@
+FONTROOTDIR = @FONTROOTDIR@
+FONTTTFDIR = @FONTTTFDIR@
+FONTTYPE1DIR = @FONTTYPE1DIR@
FREEBSD_KLDLOAD_FALSE = @FREEBSD_KLDLOAD_FALSE@
FREEBSD_KLDLOAD_TRUE = @FREEBSD_KLDLOAD_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
GLX_DEFINES = @GLX_DEFINES@
GLX_FALSE = @GLX_FALSE@
@@ -231,18 +255,17 @@ GL_LIBS = @GL_LIBS@
GREP = @GREP@
HAL_CFLAGS = @HAL_CFLAGS@
HAL_LIBS = @HAL_LIBS@
-HAVE_AGL_FRAMEWORK_FALSE = @HAVE_AGL_FRAMEWORK_FALSE@
-HAVE_AGL_FRAMEWORK_TRUE = @HAVE_AGL_FRAMEWORK_TRUE@
HAVE_DBUS_FALSE = @HAVE_DBUS_FALSE@
HAVE_DBUS_TRUE = @HAVE_DBUS_TRUE@
-HAVE_XPLUGIN_FALSE = @HAVE_XPLUGIN_FALSE@
-HAVE_XPLUGIN_TRUE = @HAVE_XPLUGIN_TRUE@
+HAVE_DOXYGEN_FALSE = @HAVE_DOXYGEN_FALSE@
+HAVE_DOXYGEN_TRUE = @HAVE_DOXYGEN_TRUE@
HP300_VIDEO_FALSE = @HP300_VIDEO_FALSE@
HP300_VIDEO_TRUE = @HP300_VIDEO_TRUE@
HPPA_VIDEO_FALSE = @HPPA_VIDEO_FALSE@
HPPA_VIDEO_TRUE = @HPPA_VIDEO_TRUE@
I386_VIDEO_FALSE = @I386_VIDEO_FALSE@
I386_VIDEO_TRUE = @I386_VIDEO_TRUE@
+INSTALL_CMD = @INSTALL_CMD@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_LIBXF86CONFIG_FALSE = @INSTALL_LIBXF86CONFIG_FALSE@
INSTALL_LIBXF86CONFIG_TRUE = @INSTALL_LIBXF86CONFIG_TRUE@
@@ -251,6 +274,8 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_SETUID_FALSE = @INSTALL_SETUID_FALSE@
INSTALL_SETUID_TRUE = @INSTALL_SETUID_TRUE@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INT10MODULE_FALSE = @INT10MODULE_FALSE@
+INT10MODULE_TRUE = @INT10MODULE_TRUE@
INT10_STUB_FALSE = @INT10_STUB_FALSE@
INT10_STUB_TRUE = @INT10_STUB_TRUE@
INT10_VM86_FALSE = @INT10_VM86_FALSE@
@@ -263,20 +288,23 @@ KDRIVELINUX_FALSE = @KDRIVELINUX_FALSE@
KDRIVELINUX_TRUE = @KDRIVELINUX_TRUE@
KDRIVEOPENBSD_FALSE = @KDRIVEOPENBSD_FALSE@
KDRIVEOPENBSD_TRUE = @KDRIVEOPENBSD_TRUE@
-KDRIVEVESA_FALSE = @KDRIVEVESA_FALSE@
-KDRIVEVESA_TRUE = @KDRIVEVESA_TRUE@
KDRIVEWSCONS_FALSE = @KDRIVEWSCONS_FALSE@
KDRIVEWSCONS_TRUE = @KDRIVEWSCONS_TRUE@
KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_EVDEV_FALSE = @KDRIVE_EVDEV_FALSE@
+KDRIVE_EVDEV_TRUE = @KDRIVE_EVDEV_TRUE@
KDRIVE_FALSE = @KDRIVE_FALSE@
-KDRIVE_HW_FALSE = @KDRIVE_HW_FALSE@
-KDRIVE_HW_TRUE = @KDRIVE_HW_TRUE@
KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_KBD_FALSE = @KDRIVE_KBD_FALSE@
+KDRIVE_KBD_TRUE = @KDRIVE_KBD_TRUE@
KDRIVE_LIBS = @KDRIVE_LIBS@
KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_MOUSE_FALSE = @KDRIVE_MOUSE_FALSE@
+KDRIVE_MOUSE_TRUE = @KDRIVE_MOUSE_TRUE@
KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
KDRIVE_TRUE = @KDRIVE_TRUE@
+LAUNCHD_ID_PREFIX = @LAUNCHD_ID_PREFIX@
LDFLAGS = @LDFLAGS@
LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
LEX = @LEX@
@@ -305,12 +333,12 @@ LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAIN_LIB = @MAIN_LIB@
MAKEINFO = @MAKEINFO@
MAKE_HTML = @MAKE_HTML@
MAKE_PDF = @MAKE_PDF@
MAKE_PS = @MAKE_PS@
MAKE_TEXT = @MAKE_TEXT@
-MESA_SOURCE = @MESA_SOURCE@
MISC_MAN_DIR = @MISC_MAN_DIR@
MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
MITSHM_FALSE = @MITSHM_FALSE@
@@ -329,6 +357,9 @@ OBJCFLAGS = @OBJCFLAGS@
OBJCLINK = @OBJCLINK@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+OS_LIB = @OS_LIB@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
@@ -357,34 +388,51 @@ SCREENSAVER_TRUE = @SCREENSAVER_TRUE@
SECURE_RPC_FALSE = @SECURE_RPC_FALSE@
SECURE_RPC_TRUE = @SECURE_RPC_TRUE@
SED = @SED@
+SELINUX_CFLAGS = @SELINUX_CFLAGS@
+SELINUX_LIBS = @SELINUX_LIBS@
SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
SET_MAKE = @SET_MAKE@
SGI_VIDEO_FALSE = @SGI_VIDEO_FALSE@
SGI_VIDEO_TRUE = @SGI_VIDEO_TRUE@
+SHA1_CFLAGS = @SHA1_CFLAGS@
+SHA1_LIBS = @SHA1_LIBS@
SHELL = @SHELL@
SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
SOLARIS_ASM_INLINE_FALSE = @SOLARIS_ASM_INLINE_FALSE@
SOLARIS_ASM_INLINE_TRUE = @SOLARIS_ASM_INLINE_TRUE@
SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
-SOLARIS_USL_CONSOLE_FALSE = @SOLARIS_USL_CONSOLE_FALSE@
-SOLARIS_USL_CONSOLE_TRUE = @SOLARIS_USL_CONSOLE_TRUE@
+SOLARIS_VT_FALSE = @SOLARIS_VT_FALSE@
+SOLARIS_VT_TRUE = @SOLARIS_VT_TRUE@
SPARC64_VIDEO_FALSE = @SPARC64_VIDEO_FALSE@
SPARC64_VIDEO_TRUE = @SPARC64_VIDEO_TRUE@
+SPECIAL_DTRACE_OBJECTS_FALSE = @SPECIAL_DTRACE_OBJECTS_FALSE@
+SPECIAL_DTRACE_OBJECTS_TRUE = @SPECIAL_DTRACE_OBJECTS_TRUE@
STANDALONE_XPBPROXY_FALSE = @STANDALONE_XPBPROXY_FALSE@
STANDALONE_XPBPROXY_TRUE = @STANDALONE_XPBPROXY_TRUE@
STRIP = @STRIP@
+SYSCONFDIR = @SYSCONFDIR@
TSLIB_CFLAGS = @TSLIB_CFLAGS@
TSLIB_FALSE = @TSLIB_FALSE@
TSLIB_LIBS = @TSLIB_LIBS@
TSLIB_TRUE = @TSLIB_TRUE@
+UDEV_CFLAGS = @UDEV_CFLAGS@
+UDEV_LIBS = @UDEV_LIBS@
+UNITTESTS_FALSE = @UNITTESTS_FALSE@
+UNITTESTS_TRUE = @UNITTESTS_TRUE@
UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
-VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
-VENDOR_NAME = @VENDOR_NAME@
+VBE_FALSE = @VBE_FALSE@
+VBE_TRUE = @VBE_TRUE@
VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
-VENDOR_RELEASE = @VENDOR_RELEASE@
VERSION = @VERSION@
+VGAHW_FALSE = @VGAHW_FALSE@
+VGAHW_TRUE = @VGAHW_TRUE@
+WINDOWSWM_CFLAGS = @WINDOWSWM_CFLAGS@
+WINDOWSWM_LIBS = @WINDOWSWM_LIBS@
+WINDRES = @WINDRES@
X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XAA_FALSE = @XAA_FALSE@
+XAA_TRUE = @XAA_TRUE@
XACE_FALSE = @XACE_FALSE@
XACE_TRUE = @XACE_TRUE@
XCALIBRATE_FALSE = @XCALIBRATE_FALSE@
@@ -409,6 +457,7 @@ XEPHYR_LIBS = @XEPHYR_LIBS@
XEPHYR_TRUE = @XEPHYR_TRUE@
XF86BIGFONT_FALSE = @XF86BIGFONT_FALSE@
XF86BIGFONT_TRUE = @XF86BIGFONT_TRUE@
+XF86CONFIGDIR = @XF86CONFIGDIR@
XF86CONFIGFILE = @XF86CONFIGFILE@
XF86UTILS_FALSE = @XF86UTILS_FALSE@
XF86UTILS_TRUE = @XF86UTILS_TRUE@
@@ -451,15 +500,14 @@ XORG_TRUE = @XORG_TRUE@
XPBPROXY_CFLAGS = @XPBPROXY_CFLAGS@
XPBPROXY_LIBS = @XPBPROXY_LIBS@
XQUARTZ_FALSE = @XQUARTZ_FALSE@
+XQUARTZ_SPARKLE = @XQUARTZ_SPARKLE@
+XQUARTZ_SPARKLE_FALSE = @XQUARTZ_SPARKLE_FALSE@
+XQUARTZ_SPARKLE_TRUE = @XQUARTZ_SPARKLE_TRUE@
XQUARTZ_TRUE = @XQUARTZ_TRUE@
XREGISTRY_FALSE = @XREGISTRY_FALSE@
XREGISTRY_TRUE = @XREGISTRY_TRUE@
XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
-XSDLSERVER_FALSE = @XSDLSERVER_FALSE@
-XSDLSERVER_TRUE = @XSDLSERVER_TRUE@
-XSDL_INCS = @XSDL_INCS@
-XSDL_LIBS = @XSDL_LIBS@
XSELINUX_FALSE = @XSELINUX_FALSE@
XSELINUX_TRUE = @XSELINUX_TRUE@
XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
@@ -507,10 +555,10 @@ X_PRIVSEP_FALSE = @X_PRIVSEP_FALSE@
X_PRIVSEP_TRUE = @X_PRIVSEP_TRUE@
YACC = @YACC@
YFLAGS = @YFLAGS@
+__XCONFIGDIR__ = @__XCONFIGDIR__@
__XCONFIGFILE__ = @__XCONFIGFILE__@
abi_ansic = @abi_ansic@
abi_extension = @abi_extension@
-abi_font = @abi_font@
abi_videodrv = @abi_videodrv@
abi_xinput = @abi_xinput@
ac_ct_CC = @ac_ct_CC@
@@ -565,20 +613,31 @@ psdir = @psdir@
sbindir = @sbindir@
sdkdir = @sdkdir@
sharedstatedir = @sharedstatedir@
+symbol_visibility = @symbol_visibility@
sysconfdir = @sysconfdir@
+sysconfigdir = @sysconfigdir@
target_alias = @target_alias@
-noinst_LTLIBRARIES = libos.la
-AM_CFLAGS = $(DIX_CFLAGS)
+noinst_LTLIBRARIES = libos.la liblog.la
+AM_CFLAGS = $(DIX_CFLAGS) $(SHA1_CFLAGS)
SECURERPC_SRCS = rpcauth.c
XDMCP_SRCS = xdmcp.c
STRLCAT_SRCS = strlcat.c strlcpy.c
-XORG_SRCS = log.c
PRIVSEP_SRCS = privsep.c
+
+# Build a convenience library liblog.la that will be added into
+# libos.la. The split is done so that log.c can be built with
+# different compiler options.
+liblog_la_SOURCES = log.c
+# Add flags needed for proper backtraces of functions marked with GCC
+# __attribute__((noreturn)). Currently those flags are needed for
+# FatalError and AbortServer in log.c.
+liblog_la_CFLAGS = $(AM_CFLAGS) $(ARM_BACKTRACE_CFLAGS)
libos_la_SOURCES = WaitFor.c access.c auth.c backtrace.c connection.c \
io.c mitauth.c oscolor.c osdep.h osinit.c utils.c strcasecmp.c \
- strcasestr.c xdmauth.c xstrans.c xprintf.c $(XORG_SRCS) \
+ strcasestr.c xdmauth.c xsha1.c xstrans.c xprintf.c \
$(am__append_1) $(am__append_2) $(am__append_3) \
$(am__append_4)
+libos_la_LIBADD = @SHA1_LIBS@ $(DLOPEN_LIBS) liblog.la
EXTRA_DIST = $(SECURERPC_SRCS) $(INTERNALMALLOC_SRCS) \
$(XDMCP_SRCS) $(STRLCAT_SRCS)
@@ -625,6 +684,8 @@ clean-noinstLTLIBRARIES:
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
+liblog.la: $(liblog_la_OBJECTS) $(liblog_la_DEPENDENCIES)
+ $(LINK) $(liblog_la_LDFLAGS) $(liblog_la_OBJECTS) $(liblog_la_LIBADD) $(LIBS)
libos.la: $(libos_la_OBJECTS) $(libos_la_DEPENDENCIES)
$(LINK) $(libos_la_LDFLAGS) $(libos_la_OBJECTS) $(libos_la_LIBADD) $(LIBS)
@@ -634,9 +695,9 @@ clean-noinstPROGRAMS:
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
-@XSERVER_DTRACE_FALSE@os.O$(EXEEXT): $(os_O_OBJECTS) $(os_O_DEPENDENCIES)
-@XSERVER_DTRACE_FALSE@ @rm -f os.O$(EXEEXT)
-@XSERVER_DTRACE_FALSE@ $(LINK) $(os_O_LDFLAGS) $(os_O_OBJECTS) $(os_O_LDADD) $(LIBS)
+@SPECIAL_DTRACE_OBJECTS_FALSE@os.O$(EXEEXT): $(os_O_OBJECTS) $(os_O_DEPENDENCIES)
+@SPECIAL_DTRACE_OBJECTS_FALSE@ @rm -f os.O$(EXEEXT)
+@SPECIAL_DTRACE_OBJECTS_FALSE@ $(LINK) $(os_O_LDFLAGS) $(os_O_OBJECTS) $(os_O_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -650,7 +711,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backtrace.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblog_la-log.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mitauth.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/os.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oscolor.Plo@am__quote@
@@ -665,6 +726,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdmauth.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdmcp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xprintf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xsha1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrans.Plo@am__quote@
.c.o:
@@ -688,6 +750,13 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+liblog_la-log.lo: log.c
+@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblog_la_CFLAGS) $(CFLAGS) -MT liblog_la-log.lo -MD -MP -MF "$(DEPDIR)/liblog_la-log.Tpo" -c -o liblog_la-log.lo `test -f 'log.c' || echo '$(srcdir)/'`log.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/liblog_la-log.Tpo" "$(DEPDIR)/liblog_la-log.Plo"; else rm -f "$(DEPDIR)/liblog_la-log.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='log.c' object='liblog_la-log.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblog_la_CFLAGS) $(CFLAGS) -c -o liblog_la-log.lo `test -f 'log.c' || echo '$(srcdir)/'`log.c
+
mostlyclean-libtool:
-rm -f *.lo
@@ -867,11 +936,11 @@ uninstall-am: uninstall-info-am
# Generate dtrace object code for probes in libos & libdix
-@XSERVER_DTRACE_TRUE@dtrace.o: $(top_srcdir)/dix/Xserver.d $(am_libos_la_OBJECTS)
-@XSERVER_DTRACE_TRUE@ $(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d .libs/*.o ../dix/.libs/*.o
+@SPECIAL_DTRACE_OBJECTS_TRUE@dtrace.o: $(top_srcdir)/dix/Xserver.d $(am_libos_la_OBJECTS)
+@SPECIAL_DTRACE_OBJECTS_TRUE@ $(AM_V_GEN)$(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d .libs/*.o ../dix/.libs/*.o
-@XSERVER_DTRACE_TRUE@os.O: dtrace.o $(am_libos_la_OBJECTS)
-@XSERVER_DTRACE_TRUE@ ld -r -o $@ dtrace.o .libs/*.o
+@SPECIAL_DTRACE_OBJECTS_TRUE@os.O: dtrace.o $(am_libos_la_OBJECTS)
+@SPECIAL_DTRACE_OBJECTS_TRUE@ $(AM_V_GEN)ld -r -o $@ dtrace.o .libs/*.o
os.c:
touch $@
diff --git a/xserver/os/WaitFor.c b/xserver/os/WaitFor.c
index 8afc958ea..dfe85e515 100644
--- a/xserver/os/WaitFor.c
+++ b/xserver/os/WaitFor.c
@@ -92,6 +92,8 @@ SOFTWARE.
#define GetErrno() errno
#endif
+/* like ffs, but uses fd_mask instead of int as argument, so it works
+ when fd_mask is longer than an int, such as common 64-bit platforms */
/* modifications by raphael */
int
mffs(fd_mask mask)
@@ -109,12 +111,7 @@ mffs(fd_mask mask)
}
#ifdef DPMSExtension
-#ifdef HAVE_X11_EXTENSIONS_DPMSCONST_H
#include <X11/extensions/dpmsconst.h>
-#else
-#define DPMS_SERVER
-#include <X11/extensions/dpms.h>
-#endif
#endif
struct _OsTimerRec {
@@ -340,7 +337,7 @@ WaitForSomething(int *pClientsReady)
{
int client_priority, client_index;
- curclient = ffs (clientsReadable.fds_bits[i]) - 1;
+ curclient = mffs (clientsReadable.fds_bits[i]) - 1;
client_index = /* raphael: modified */
ConnectionTranslation[curclient + (i * (sizeof(fd_mask) * 8))];
#else
@@ -425,7 +422,7 @@ DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev)
TimerSet(timer, 0, newTime, timer->callback, timer->arg);
}
-_X_EXPORT OsTimerPtr
+OsTimerPtr
TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
OsTimerCallback func, pointer arg)
{
@@ -434,7 +431,7 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
if (!timer)
{
- timer = (OsTimerPtr)xalloc(sizeof(struct _OsTimerRec));
+ timer = xalloc(sizeof(struct _OsTimerRec));
if (!timer)
return NULL;
}
@@ -496,7 +493,7 @@ TimerForce(OsTimerPtr timer)
}
-_X_EXPORT void
+void
TimerCancel(OsTimerPtr timer)
{
OsTimerPtr *prev;
@@ -513,7 +510,7 @@ TimerCancel(OsTimerPtr timer)
}
}
-_X_EXPORT void
+void
TimerFree(OsTimerPtr timer)
{
if (!timer)
diff --git a/xserver/os/access.c b/xserver/os/access.c
index 50fc5f9f2..3572da0c9 100644
--- a/xserver/os/access.c
+++ b/xserver/os/access.c
@@ -1,7 +1,6 @@
/***********************************************************
Copyright 1987, 1998 The Open Group
-Copyright 2004 Sun Microsystems, Inc.
All rights reserved.
@@ -54,6 +53,29 @@ SOFTWARE.
******************************************************************/
+/*
+ * Copyright © 2004 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
@@ -216,7 +238,7 @@ typedef struct _host {
int requested;
} HOST;
-#define MakeHost(h,l) (h)=(HOST *) xalloc(sizeof *(h)+(l));\
+#define MakeHost(h,l) (h)=xalloc(sizeof *(h)+(l));\
if (h) { \
(h)->addr=(unsigned char *) ((h) + 1);\
(h)->requested = FALSE; \
@@ -415,8 +437,7 @@ DefineSelf (int fd)
*/
if (family == FamilyInternet &&
!(len == 4 &&
- ((addr[0] == 127 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 1) ||
+ ((addr[0] == 127) ||
(addr[0] == 0 && addr[1] == 0 &&
addr[2] == 0 && addr[3] == 0)))
)
@@ -744,7 +765,8 @@ DefineSelf (int fd)
continue;
#endif /* DNETCONN */
len = sizeof(*(ifr->ifa_addr));
- family = ConvertAddr(ifr->ifa_addr, &len, (pointer *)&addr);
+ family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len,
+ (pointer *)&addr);
if (family == -1 || family == FamilyLocal)
continue;
#if defined(IPv6) && defined(AF_INET6)
@@ -768,7 +790,6 @@ DefineSelf (int fd)
}
#ifdef XDMCP
{
- struct sockaddr broad_addr;
/*
* If this isn't an Internet Address, don't register it.
*/
@@ -812,12 +833,12 @@ DefineSelf (int fd)
continue;
#endif
if ((ifr->ifa_flags & IFF_BROADCAST) &&
- (ifr->ifa_flags & IFF_UP))
- broad_addr = *ifr->ifa_broadaddr;
+ (ifr->ifa_flags & IFF_UP) &&
+ ifr->ifa_broadaddr)
+ XdmcpRegisterBroadcastAddress(
+ (struct sockaddr_in *) ifr->ifa_broadaddr);
else
continue;
- XdmcpRegisterBroadcastAddress((struct sockaddr_in *)
- &broad_addr);
}
#endif /* XDMCP */
@@ -1095,7 +1116,7 @@ ResetHosts (char *display)
}
/* Is client on the local host */
-_X_EXPORT Bool LocalClient(ClientPtr client)
+Bool LocalClient(ClientPtr client)
{
int alen, family, notused;
Xtransaddr *from = NULL;
@@ -1109,12 +1130,12 @@ _X_EXPORT Bool LocalClient(ClientPtr client)
&alen, (pointer *)&addr);
if (family == -1)
{
- xfree ((char *) from);
+ xfree (from);
return FALSE;
}
if (family == FamilyLocal)
{
- xfree ((char *) from);
+ xfree (from);
return TRUE;
}
for (host = selfhosts; host; host = host->next)
@@ -1122,7 +1143,7 @@ _X_EXPORT Bool LocalClient(ClientPtr client)
if (addrEqual (family, addr, alen, host))
return TRUE;
}
- xfree ((char *) from);
+ xfree (from);
}
return FALSE;
}
@@ -1458,11 +1479,11 @@ GetHosts (
for (host = validhosts; host; host = host->next)
{
nHosts++;
- n += (((host->len + 3) >> 2) << 2) + sizeof(xHostEntry);
+ n += pad_to_int32(host->len) + sizeof(xHostEntry);
}
if (n)
{
- *data = ptr = (pointer) xalloc (n);
+ *data = ptr = xalloc (n);
if (!ptr)
{
return(BadAlloc);
@@ -1474,7 +1495,7 @@ GetHosts (
((xHostEntry *)ptr)->length = len;
ptr += sizeof(xHostEntry);
acopy (host->addr, ptr, len);
- ptr += ((len + 3) >> 2) << 2;
+ ptr += pad_to_int32(len);
}
} else {
*data = NULL;
@@ -1721,7 +1742,7 @@ siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch,
}
}
- s = (struct siType *) xalloc(sizeof(struct siType));
+ s = xalloc(sizeof(struct siType));
if (s == NULL)
return BadAlloc;
diff --git a/xserver/os/backtrace.c b/xserver/os/backtrace.c
index b52dcded8..7ca6dab6d 100644
--- a/xserver/os/backtrace.c
+++ b/xserver/os/backtrace.c
@@ -2,22 +2,23 @@
* Copyright 2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software")
- * to deal in the software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * them Software is furnished to do so, subject to the following conditions:
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTIBILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
@@ -28,19 +29,30 @@
#include "misc.h"
#ifdef HAVE_BACKTRACE
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <dlfcn.h>
#include <execinfo.h>
void xorg_backtrace(void)
{
- void *array[32]; /* deeper nesting than this means something's wrong */
- size_t size, i;
- char **strings;
+ void *array[64];
+ const char *mod;
+ int size, i;
+ Dl_info info;
ErrorF("\nBacktrace:\n");
- size = backtrace(array, 32);
- strings = backtrace_symbols(array, size);
- for (i = 0; i < size; i++)
- ErrorF("%d: %s\n", i, strings[i]);
- free(strings);
+ size = backtrace(array, 64);
+ for (i = 0; i < size; i++) {
+ dladdr(array[i], &info);
+ mod = (info.dli_fname && *info.dli_fname) ? info.dli_fname : "(vdso)";
+ if (info.dli_saddr)
+ ErrorF("%d: %s (%s+0x%lx) [%p]\n", i, mod,
+ info.dli_sname, (long unsigned int)((char *) array[i] - (char *) info.dli_saddr), array[i]);
+ else
+ ErrorF("%d: %s (%p+0x%lx) [%p]\n", i, mod,
+ info.dli_fbase, (long unsigned int)((char *) array[i] - (char *) info.dli_fbase), array[i]);
+ }
}
#else /* not glibc or glibc < 2.1 */
diff --git a/xserver/os/connection.c b/xserver/os/connection.c
index 7dcfe9781..37dd399a1 100644
--- a/xserver/os/connection.c
+++ b/xserver/os/connection.c
@@ -146,7 +146,7 @@ Bool NewOutputPending; /* not yet attempted to write some new output */
Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
-Bool PartialNetwork; /* continue even if unable to bind all addrs */
+Bool PartialNetwork; /* continue even if unable to bind all addrs */
static Pid_t ParentProcess;
static Bool debug_conns = FALSE;
@@ -156,7 +156,7 @@ static fd_set GrabImperviousClients;
static fd_set SavedAllClients;
static fd_set SavedAllSockets;
static fd_set SavedClientsWithInput;
-_X_EXPORT int GrabInProgress = 0;
+int GrabInProgress = 0;
#if !defined(WIN32)
int *ConnectionTranslation = NULL;
@@ -172,7 +172,6 @@ int *ConnectionTranslation = NULL;
#define MAXSOCKS 500
#undef MAXSELECT
#define MAXSELECT 500
-#define MAXFD 500
struct _ct_node {
struct _ct_node *next;
@@ -227,7 +226,7 @@ void SetConnectionTranslation(int conn, int client)
}
node = &((*node)->next);
}
- *node = (struct _ct_node*)xalloc(sizeof(struct _ct_node));
+ *node = xalloc(sizeof(struct _ct_node));
(*node)->next = NULL;
(*node)->key = conn;
(*node)->value = client;
@@ -346,15 +345,6 @@ InitParentProcess(void)
RunFromSmartParent = TRUE;
OsSignal(SIGUSR1, handler);
ParentProcess = getppid ();
-#ifdef __UNIXOS2__
- /*
- * fg030505: under OS/2, xinit is not the parent process but
- * the "grant parent" process of the server because execvpe()
- * presents us an additional process number;
- * GetPPID(pid) is part of libemxfix
- */
- ParentProcess = GetPPID (ParentProcess);
-#endif /* __UNIXOS2__ */
#endif
}
@@ -411,7 +401,7 @@ CreateWellKnownSockets(void)
}
else
{
- ListenTransFds = (int *) xalloc (ListenTransCount * sizeof (int));
+ ListenTransFds = xalloc (ListenTransCount * sizeof (int));
for (i = 0; i < ListenTransCount; i++)
{
@@ -649,7 +639,7 @@ AuthorizationIDOfClient(ClientPtr client)
*
*****************************************************************/
-char *
+char *
ClientAuthorized(ClientPtr client,
unsigned int proto_n, char *auth_proto,
unsigned int string_n, char *auth_string)
@@ -693,7 +683,7 @@ ClientAuthorized(ClientPtr client,
proto_n, auth_proto, auth_id);
}
- xfree ((char *) from);
+ xfree (from);
}
if (auth_id == (XID) ~0L) {
@@ -715,7 +705,7 @@ ClientAuthorized(ClientPtr client,
AuthAudit(client, TRUE, (struct sockaddr *) from, fromlen,
proto_n, auth_proto, auth_id);
- xfree ((char *) from);
+ xfree (from);
}
}
priv->auth_id = auth_id;
@@ -751,7 +741,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
#endif
)
return NullClient;
- oc = (OsCommPtr)xalloc(sizeof(OsCommRec));
+ oc = xalloc(sizeof(OsCommRec));
if (!oc)
return NullClient;
oc->trans_conn = trans_conn;
@@ -841,7 +831,7 @@ EstablishNewConnections(ClientPtr clientUnused, pointer closure)
int status;
#ifndef WIN32
- curconn = ffs (readyconnections.fds_bits[i]) - 1;
+ curconn = mffs (readyconnections.fds_bits[i]) - 1;
readyconnections.fds_bits[i] &= ~((fd_mask)1 << curconn);
curconn += (i * (sizeof(fd_mask)*8));
#else
@@ -1006,7 +996,7 @@ CheckConnections(void)
mask = AllClients.fds_bits[i];
while (mask)
{
- curoff = ffs (mask) - 1;
+ curoff = mffs (mask) - 1;
curclient = curoff + (i * (sizeof(fd_mask)*8));
FD_ZERO(&tmask);
FD_SET(curclient, &tmask);
@@ -1060,7 +1050,7 @@ CloseDownConnection(ClientPtr client)
AuditF("client %d disconnected\n", client->index);
}
-_X_EXPORT void
+void
AddGeneralSocket(int fd)
{
FD_SET(fd, &AllSockets);
@@ -1068,14 +1058,14 @@ AddGeneralSocket(int fd)
FD_SET(fd, &SavedAllSockets);
}
-_X_EXPORT void
+void
AddEnabledDevice(int fd)
{
FD_SET(fd, &EnabledDevices);
AddGeneralSocket(fd);
}
-_X_EXPORT void
+void
RemoveGeneralSocket(int fd)
{
FD_CLR(fd, &AllSockets);
@@ -1083,7 +1073,7 @@ RemoveGeneralSocket(int fd)
FD_CLR(fd, &SavedAllSockets);
}
-_X_EXPORT void
+void
RemoveEnabledDevice(int fd)
{
FD_CLR(fd, &EnabledDevices);
@@ -1155,7 +1145,7 @@ ListenToAllClients(void)
* Must have cooresponding call to AttendClient.
****************/
-_X_EXPORT void
+void
IgnoreClient (ClientPtr client)
{
OsCommPtr oc = (OsCommPtr)client->osPrivate;
@@ -1190,7 +1180,7 @@ IgnoreClient (ClientPtr client)
* Adds one client back into the input masks.
****************/
-_X_EXPORT void
+void
AttendClient (ClientPtr client)
{
OsCommPtr oc = (OsCommPtr)client->osPrivate;
@@ -1264,13 +1254,14 @@ MakeClientGrabPervious(ClientPtr client)
#ifdef XQUARTZ
/* Add a fd (from launchd) to our listeners */
-_X_EXPORT void ListenOnOpenFD(int fd, int noxauth) {
+void ListenOnOpenFD(int fd, int noxauth) {
char port[256];
XtransConnInfo ciptr;
+ const char *display_env = getenv("DISPLAY");
- if(!strncmp(getenv("DISPLAY"), "/tmp/launch", 11)) {
+ if(display_env && (strncmp(display_env, "/tmp/launch", 11) == 0)) {
/* Make the path the launchd socket if our DISPLAY is set right */
- strcpy(port, getenv("DISPLAY"));
+ strcpy(port, display_env);
} else {
/* Just some default so things don't break and die. */
sprintf(port, ":%d", atoi(display));
diff --git a/xserver/os/io.c b/xserver/os/io.c
index f07993e5a..64b64ae75 100644
--- a/xserver/os/io.c
+++ b/xserver/os/io.c
@@ -73,7 +73,6 @@ SOFTWARE.
#include <sys/uio.h>
#endif
#include <X11/X.h>
-#define NEED_REPLIES
#include <X11/Xproto.h>
#include "os.h"
#include "osdep.h"
@@ -82,8 +81,8 @@ SOFTWARE.
#include "dixstruct.h"
#include "misc.h"
-_X_EXPORT CallbackListPtr ReplyCallback;
-_X_EXPORT CallbackListPtr FlushCallback;
+CallbackListPtr ReplyCallback;
+CallbackListPtr FlushCallback;
static ConnectionInputPtr AllocateInputBuffer(void);
static ConnectionOutputPtr AllocateOutputBuffer(void);
@@ -106,7 +105,7 @@ static OsCommPtr AvailableInput = (OsCommPtr)NULL;
#define get_req_len(req,cli) ((cli)->swapped ? \
lswaps((req)->length) : (req)->length)
-#include <X11/extensions/bigreqstr.h>
+#include <X11/extensions/bigreqsproto.h>
#define get_big_req_len(req,cli) ((cli)->swapped ? \
lswapl(((xBigReq *)(req))->length) : \
@@ -274,7 +273,7 @@ ReadRequestFromClient(ClientPtr client)
if (gotnow < sizeof(xBigReq))
{
/* Still need more data to tell just how big. */
- needed = sizeof(xBigReq) >> 2; /* needed is in CARD32s now */
+ needed = bytes_to_int32(sizeof(xBigReq)); /* needed is in CARD32s now */
need_header = TRUE;
}
else
@@ -378,7 +377,7 @@ ReadRequestFromClient(ClientPtr client)
{
move_header = TRUE;
if (gotnow < sizeof(xBigReq))
- needed = sizeof(xBigReq) >> 2;
+ needed = bytes_to_int32(sizeof(xBigReq));
else
needed = get_big_req_len(request, client);
}
@@ -446,7 +445,7 @@ ReadRequestFromClient(ClientPtr client)
oci->bufptr += (sizeof(xBigReq) - sizeof(xReq));
*(xReq *)oci->bufptr = *request;
oci->lenLastReq -= (sizeof(xBigReq) - sizeof(xReq));
- client->req_len -= (sizeof(xBigReq) - sizeof(xReq)) >> 2;
+ client->req_len -= bytes_to_int32(sizeof(xBigReq) - sizeof(xReq));
}
client->requestBuffer = (pointer)oci->bufptr;
#ifdef DEBUG_COMMUNICATION
@@ -539,7 +538,7 @@ InsertFakeRequest(ClientPtr client, char *data, int count)
*
**********************/
-_X_EXPORT void
+void
ResetCurrentRequest(ClientPtr client)
{
OsCommPtr oc = (OsCommPtr)client->osPrivate;
@@ -679,7 +678,7 @@ FlushIfCriticalOutputPending(void)
FlushAllOutput();
}
-_X_EXPORT void
+void
SetCriticalOutputPending(void)
{
CriticalOutputPending = TRUE;
@@ -696,7 +695,7 @@ SetCriticalOutputPending(void)
* this routine as int.
*****************/
-_X_EXPORT int
+int
WriteToClient (ClientPtr who, int count, const void *__buf)
{
OsCommPtr oc = (OsCommPtr)who->osPrivate;
@@ -1012,14 +1011,14 @@ AllocateInputBuffer(void)
{
ConnectionInputPtr oci;
- oci = (ConnectionInputPtr)xalloc(sizeof(ConnectionInput));
+ oci = xalloc(sizeof(ConnectionInput));
if (!oci)
- return (ConnectionInputPtr)NULL;
- oci->buffer = (char *)xalloc(BUFSIZE);
+ return NULL;
+ oci->buffer = xalloc(BUFSIZE);
if (!oci->buffer)
{
xfree(oci);
- return (ConnectionInputPtr)NULL;
+ return NULL;
}
oci->size = BUFSIZE;
oci->bufptr = oci->buffer;
@@ -1033,14 +1032,14 @@ AllocateOutputBuffer(void)
{
ConnectionOutputPtr oco;
- oco = (ConnectionOutputPtr)xalloc(sizeof(ConnectionOutput));
+ oco = xalloc(sizeof(ConnectionOutput));
if (!oco)
- return (ConnectionOutputPtr)NULL;
- oco->buf = (unsigned char *) xcalloc(1, BUFSIZE);
+ return NULL;
+ oco->buf = xcalloc(1, BUFSIZE);
if (!oco->buf)
{
xfree(oco);
- return (ConnectionOutputPtr)NULL;
+ return NULL;
}
oco->size = BUFSIZE;
oco->count = 0;
diff --git a/xserver/os/log.c b/xserver/os/log.c
index abd2b187d..d4455fddf 100644
--- a/xserver/os/log.c
+++ b/xserver/os/log.c
@@ -98,6 +98,9 @@ OR PERFORMANCE OF THIS SOFTWARE.
#define getpid(x) _getpid(x)
#endif
+#ifdef XF86BIGFONT
+#include "xf86bigfontsrv.h"
+#endif
#ifdef DDXOSVERRORF
void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL;
@@ -114,6 +117,19 @@ static char *saveBuffer = NULL;
static int bufferSize = 0, bufferUnused = 0, bufferPos = 0;
static Bool needBuffer = TRUE;
+#ifdef __APPLE__
+#include <AvailabilityMacros.h>
+
+static char __crashreporter_info_buff__[4096] = {0};
+static const char *__crashreporter_info__ = &__crashreporter_info_buff__[0];
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+// This is actually a toolchain requirement, but I'm not sure the correct check,
+// but it should be fine to just only include it for Leopard and later. This line
+// just tells the linker to never strip this symbol (such as for space optimization)
+asm (".desc ___crashreporter_info__, 0x10");
+#endif
+#endif
+
/* Prefix strings for log messages. */
#ifndef X_UNKNOWN_STRING
#define X_UNKNOWN_STRING "(\?\?)"
@@ -187,7 +203,7 @@ LogInit(const char *fname, const char *backup)
snprintf(oldLog, len1, "%s%s", logFileName, suffix);
free(suffix);
if (rename(logFileName, oldLog) == -1) {
- FatalError("Cannot move old log file (\"%s\" to \"%s\"\n",
+ FatalError("Cannot move old log file \"%s\" to \"%s\"\n",
logFileName, oldLog);
}
free(oldLog);
@@ -253,11 +269,19 @@ LogSetParameter(LogParameter param, int value)
/* This function does the actual log message writes. */
-_X_EXPORT void
+void
LogVWrite(int verb, const char *f, va_list args)
{
static char tmpBuffer[1024];
int len = 0;
+ static Bool newline = TRUE;
+
+ if (newline) {
+ sprintf(tmpBuffer, "[%10.3f] ", GetTimeInMillis() / 1000.0);
+ len = strlen(tmpBuffer);
+ if (logFile)
+ fwrite(tmpBuffer, len, 1, logFile);
+ }
/*
* Since a va_list can only be processed once, write the string to a
@@ -268,6 +292,7 @@ LogVWrite(int verb, const char *f, va_list args)
vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
len = strlen(tmpBuffer);
}
+ newline = (tmpBuffer[len-1] == '\n');
if ((verb < 0 || logVerbosity >= verb) && len > 0)
write(2, tmpBuffer, len);
if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {
@@ -300,7 +325,7 @@ LogVWrite(int verb, const char *f, va_list args)
}
}
-_X_EXPORT void
+void
LogWrite(int verb, const char *f, ...)
{
va_list args;
@@ -310,7 +335,7 @@ LogWrite(int verb, const char *f, ...)
va_end(args);
}
-_X_EXPORT void
+void
LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
{
const char *s = X_UNKNOWN_STRING;
@@ -365,7 +390,7 @@ LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
}
/* Log message with verbosity level specified. */
-_X_EXPORT void
+void
LogMessageVerb(MessageType type, int verb, const char *format, ...)
{
va_list ap;
@@ -376,7 +401,7 @@ LogMessageVerb(MessageType type, int verb, const char *format, ...)
}
/* Log a message with the standard verbosity level of 1. */
-_X_EXPORT void
+void
LogMessage(MessageType type, const char *format, ...)
{
va_list ap;
@@ -393,13 +418,16 @@ void AbortServer(void) __attribute__((noreturn));
void
AbortServer(void)
{
+#ifdef XF86BIGFONT
+ XF86BigfontCleanup();
+#endif
CloseWellKnownConnections();
OsCleanup(TRUE);
CloseDownDevices();
AbortDDX();
fflush(stderr);
if (CoreDump)
- abort();
+ OsAbort();
exit (1);
}
@@ -412,7 +440,7 @@ static int nrepeat = 0;
static int oldlen = -1;
static OsTimerPtr auditTimer = NULL;
-void
+void
FreeAuditTimer(void)
{
if (auditTimer != NULL) {
@@ -502,7 +530,7 @@ VAuditF(const char *f, va_list args)
free(prefix);
}
-_X_EXPORT void
+void
FatalError(const char *f, ...)
{
va_list args;
@@ -514,6 +542,9 @@ FatalError(const char *f, ...)
ErrorF("\nFatal server error:\n");
va_start(args, f);
+#ifdef __APPLE__
+ (void)vsnprintf(__crashreporter_info_buff__, sizeof(__crashreporter_info_buff__), f, args);
+#endif
VErrorF(f, args);
va_end(args);
ErrorF("\n");
@@ -523,11 +554,11 @@ FatalError(const char *f, ...)
beenhere = TRUE;
AbortServer();
} else
- abort();
+ OsAbort();
/*NOTREACHED*/
}
-_X_EXPORT void
+void
VErrorF(const char *f, va_list args)
{
#ifdef DDXOSVERRORF
@@ -540,7 +571,7 @@ VErrorF(const char *f, va_list args)
#endif
}
-_X_EXPORT void
+void
ErrorF(const char * f, ...)
{
va_list args;
@@ -552,7 +583,7 @@ ErrorF(const char * f, ...)
/* A perror() workalike. */
-_X_EXPORT void
+void
Error(char *str)
{
char *err = NULL;
@@ -566,7 +597,7 @@ Error(char *str)
return;
snprintf(err, len, "%s: ", str);
strlcat(err, strerror(saveErrno), len);
- LogWrite(-1, "%s", err);
+ LogWrite(-1, err);
free(err);
} else
LogWrite(-1, "%s", strerror(saveErrno));
@@ -576,16 +607,16 @@ void
LogPrintMarkers(void)
{
/* Show what the message marker symbols mean. */
- ErrorF("Markers: ");
- LogMessageVerb(X_PROBED, -1, "probed, ");
- LogMessageVerb(X_CONFIG, -1, "from config file, ");
- LogMessageVerb(X_DEFAULT, -1, "default setting,\n\t");
- LogMessageVerb(X_CMDLINE, -1, "from command line, ");
- LogMessageVerb(X_NOTICE, -1, "notice, ");
- LogMessageVerb(X_INFO, -1, "informational,\n\t");
- LogMessageVerb(X_WARNING, -1, "warning, ");
- LogMessageVerb(X_ERROR, -1, "error, ");
- LogMessageVerb(X_NOT_IMPLEMENTED, -1, "not implemented, ");
- LogMessageVerb(X_UNKNOWN, -1, "unknown.\n");
+ LogWrite(0, "Markers: ");
+ LogMessageVerb(X_PROBED, 0, "probed, ");
+ LogMessageVerb(X_CONFIG, 0, "from config file, ");
+ LogMessageVerb(X_DEFAULT, 0, "default setting,\n\t");
+ LogMessageVerb(X_CMDLINE, 0, "from command line, ");
+ LogMessageVerb(X_NOTICE, 0, "notice, ");
+ LogMessageVerb(X_INFO, 0, "informational,\n\t");
+ LogMessageVerb(X_WARNING, 0, "warning, ");
+ LogMessageVerb(X_ERROR, 0, "error, ");
+ LogMessageVerb(X_NOT_IMPLEMENTED, 0, "not implemented, ");
+ LogMessageVerb(X_UNKNOWN, 0, "unknown.\n");
}
diff --git a/xserver/os/mitauth.c b/xserver/os/mitauth.c
index db66c44fb..a7968cbd7 100644
--- a/xserver/os/mitauth.c
+++ b/xserver/os/mitauth.c
@@ -55,10 +55,10 @@ MitAddCookie (
{
struct auth *new;
- new = (struct auth *) xalloc (sizeof (struct auth));
+ new = xalloc (sizeof (struct auth));
if (!new)
return 0;
- new->data = (char *) xalloc ((unsigned) data_length);
+ new->data = xalloc ((unsigned) data_length);
if (!new->data) {
xfree(new);
return 0;
diff --git a/xserver/os/osdep.h b/xserver/os/osdep.h
index e719f9a70..7b1c69995 100644
--- a/xserver/os/osdep.h
+++ b/xserver/os/osdep.h
@@ -56,7 +56,9 @@ SOFTWARE.
#define BUFSIZE 4096
#define BUFWATERMARK 8192
+#if defined(XDMCP) || defined(HASXDMAUTH)
#include <X11/Xdmcp.h>
+#endif
#ifdef _POSIX_SOURCE
#include <limits.h>
@@ -109,9 +111,11 @@ SOFTWARE.
#include <stddef.h>
+#if defined(XDMCP) || defined(HASXDMAUTH)
typedef Bool (*ValidatorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
typedef Bool (*GeneratorFunc)(ARRAY8Ptr Auth, ARRAY8Ptr Data, int packet_type);
typedef Bool (*AddAuthorFunc)(unsigned name_length, char *name, unsigned data_length, char *data);
+#endif
typedef struct _connectionInput {
struct _connectionInput *next;
@@ -196,7 +200,7 @@ extern int *ConnectionTranslation;
#else
extern int GetConnectionTranslation(int conn);
extern void SetConnectionTranslation(int conn, int client);
-extern void ClearConnectionTranslation();
+extern void ClearConnectionTranslation(void);
#endif
extern Bool NewOutputPending;
@@ -204,7 +208,7 @@ extern Bool AnyClientsWriteBlocked;
extern WorkQueuePtr workQueue;
-/* added by raphael */
+/* in WaitFor.c */
#ifdef WIN32
typedef long int fd_mask;
#endif
@@ -244,6 +248,7 @@ extern int SecureRPCRemove (AuthRemCArgs);
extern int SecureRPCReset (AuthRstCArgs);
#endif
+#ifdef XDMCP
/* in xdmcp.c */
extern void XdmcpUseMsg (void);
extern int XdmcpOptions(int argc, char **argv, int i);
@@ -268,6 +273,7 @@ extern void XdmcpRegisterAuthentication (
struct sockaddr_in;
extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr);
+#endif
#ifdef HASXDMAUTH
extern void XdmAuthenticationInit (char *cookie, int cookie_length);
diff --git a/xserver/os/osinit.c b/xserver/os/osinit.c
index bbef0e7db..b85fa73b7 100644
--- a/xserver/os/osinit.c
+++ b/xserver/os/osinit.c
@@ -54,6 +54,15 @@ SOFTWARE.
#include "os.h"
#include "osdep.h"
#include <X11/Xos.h>
+#include <signal.h>
+#include <errno.h>
+#ifdef HAVE_DLFCN_H
+# include <dlfcn.h>
+#endif
+#ifdef HAVE_BACKTRACE
+#include <execinfo.h>
+#endif
+
#include "dixstruct.h"
@@ -88,6 +97,66 @@ int limitStackSpace = -1;
int limitNoFile = -1;
#endif
+static OsSigWrapperPtr OsSigWrapper = NULL;
+
+OsSigWrapperPtr
+OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper)
+{
+ OsSigWrapperPtr oldSigWrapper = OsSigWrapper;
+
+ OsSigWrapper = newSigWrapper;
+
+ return oldSigWrapper;
+}
+
+/*
+ * OsSigHandler --
+ * Catch unexpected signals and exit or continue cleanly.
+ */
+static void
+#ifdef SA_SIGINFO
+OsSigHandler(int signo, siginfo_t *sip, void *unused)
+#else
+OsSigHandler(int signo)
+#endif
+{
+#ifdef RTLD_DI_SETSIGNAL
+ const char *dlerr = dlerror();
+
+ if (dlerr) {
+ LogMessage(X_ERROR, "Dynamic loader error: %s\n", dlerr);
+ }
+#endif /* RTLD_DI_SETSIGNAL */
+
+ if (OsSigWrapper != NULL) {
+ if (OsSigWrapper(signo) == 0) {
+ /* ddx handled signal and wants us to continue */
+ return;
+ }
+ }
+
+ /* log, cleanup, and abort */
+ xorg_backtrace();
+
+#ifdef SA_SIGINFO
+ if (sip->si_code == SI_USER) {
+ ErrorF("Recieved signal %d sent by process %ld, uid %ld\n",
+ signo, (long) sip->si_pid, (long) sip->si_uid);
+ } else {
+ switch (signo) {
+ case SIGSEGV:
+ case SIGBUS:
+ case SIGILL:
+ case SIGFPE:
+ ErrorF("%s at address %p\n", strsignal(signo), sip->si_addr);
+ }
+ }
+#endif
+
+ FatalError("Caught signal %d (%s). Server aborting\n",
+ signo, strsignal(signo));
+}
+
void
OsInit(void)
{
@@ -96,11 +165,57 @@ OsInit(void)
static char* devnull = "/dev/null";
char fname[PATH_MAX];
-#ifdef macII
- set42sig();
+ if (!been_here) {
+ struct sigaction act, oact;
+ int i;
+ int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS,
+#ifdef SIGSYS
+ SIGSYS,
+#endif
+#ifdef SIGXCPU
+ SIGXCPU,
+#endif
+#ifdef SIGXFSZ
+ SIGXFSZ,
+#endif
+#ifdef SIGEMT
+ SIGEMT,
+#endif
+ 0 /* must be last */ };
+ sigemptyset(&act.sa_mask);
+#ifdef SA_SIGINFO
+ act.sa_sigaction = OsSigHandler;
+ act.sa_flags = SA_SIGINFO;
+#else
+ act.sa_handler = OsSigHandler;
+ act.sa_flags = 0;
+#endif
+ for (i = 0; siglist[i] != 0; i++) {
+ if (sigaction(siglist[i], &act, &oact)) {
+ ErrorF("failed to install signal handler for signal %d: %s\n",
+ siglist[i], strerror(errno));
+ }
+ }
+#ifdef HAVE_BACKTRACE
+ /*
+ * initialize the backtracer, since the ctor calls dlopen(), which
+ * calls malloc(), which isn't signal-safe.
+ */
+ do {
+ void *array;
+ backtrace(&array, 1);
+ } while (0);
+#endif
+
+#ifdef RTLD_DI_SETSIGNAL
+ /* Tell runtime linker to send a signal we can catch instead of SIGKILL
+ * for failures to load libraries/modules at runtime so we can clean up
+ * after ourselves.
+ */
+ int failure_signal = SIGQUIT;
+ dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
#endif
- if (!been_here) {
#if !defined(__SCO__) && !defined(__CYGWIN__) && !defined(__UNIXWARE__)
fclose(stdin);
fclose(stdout);
diff --git a/xserver/os/rpcauth.c b/xserver/os/rpcauth.c
index b41c2baed..935d1b1d0 100644
--- a/xserver/os/rpcauth.c
+++ b/xserver/os/rpcauth.c
@@ -66,7 +66,7 @@ authdes_ezdecode(char *inmsg, int len)
XDR xdr;
SVCXPRT xprt;
- temp_inmsg = (char *) xalloc(len);
+ temp_inmsg = xalloc(len);
memmove(temp_inmsg, inmsg, len);
memset((char *)&msg, 0, sizeof(msg));
@@ -79,7 +79,7 @@ authdes_ezdecode(char *inmsg, int len)
why = AUTH_FAILED;
xdrmem_create(&xdr, temp_inmsg, len, XDR_DECODE);
- if ((r.rq_clntcred = (caddr_t) xalloc(MAX_AUTH_BYTES)) == NULL)
+ if ((r.rq_clntcred = xalloc(MAX_AUTH_BYTES)) == NULL)
goto bad1;
r.rq_xprt = &xprt;
diff --git a/xserver/os/utils.c b/xserver/os/utils.c
index bf08518ef..a635c0528 100644
--- a/xserver/os/utils.c
+++ b/xserver/os/utils.c
@@ -56,6 +56,11 @@ OR PERFORMANCE OF THIS SOFTWARE.
#ifdef __CYGWIN__
#include <stdlib.h>
#include <signal.h>
+/*
+ Sigh... We really need a prototype for this to know it is stdcall,
+ but #include-ing <windows.h> here is not a good idea...
+*/
+__stdcall unsigned long GetTickCount(void);
#endif
#if defined(WIN32) && !defined(__CYGWIN__)
@@ -113,85 +118,82 @@ OR PERFORMANCE OF THIS SOFTWARE.
#include "dixstruct.h"
-#ifdef XKB
-#include <xkbsrv.h>
-#endif
+#include "xkbsrv.h"
#ifdef RENDER
#include "picture.h"
#endif
-_X_EXPORT Bool noTestExtensions;
+Bool noTestExtensions;
#ifdef COMPOSITE
-_X_EXPORT Bool noCompositeExtension = FALSE;
+Bool noCompositeExtension = FALSE;
#endif
#ifdef DAMAGE
-_X_EXPORT Bool noDamageExtension = FALSE;
+Bool noDamageExtension = FALSE;
#endif
#ifdef DBE
-_X_EXPORT Bool noDbeExtension = FALSE;
+Bool noDbeExtension = FALSE;
#endif
#ifdef DPMSExtension
-_X_EXPORT Bool noDPMSExtension = FALSE;
+Bool noDPMSExtension = FALSE;
#endif
#ifdef GLXEXT
-_X_EXPORT Bool noGlxExtension = FALSE;
-_X_EXPORT Bool noGlxVisualInit = FALSE;
+Bool noGlxExtension = FALSE;
+Bool noGlxVisualInit = FALSE;
#endif
#ifdef SCREENSAVER
-_X_EXPORT Bool noScreenSaverExtension = FALSE;
+Bool noScreenSaverExtension = FALSE;
#endif
#ifdef MITSHM
-_X_EXPORT Bool noMITShmExtension = FALSE;
+Bool noMITShmExtension = FALSE;
#endif
#ifdef MULTIBUFFER
-_X_EXPORT Bool noMultibufferExtension = FALSE;
+Bool noMultibufferExtension = FALSE;
#endif
#ifdef RANDR
-_X_EXPORT Bool noRRExtension = FALSE;
+Bool noRRExtension = FALSE;
#endif
#ifdef RENDER
-_X_EXPORT Bool noRenderExtension = FALSE;
+Bool noRenderExtension = FALSE;
#endif
#ifdef XCSECURITY
-_X_EXPORT Bool noSecurityExtension = FALSE;
+Bool noSecurityExtension = FALSE;
#endif
#ifdef RES
-_X_EXPORT Bool noResExtension = FALSE;
+Bool noResExtension = FALSE;
#endif
#ifdef XF86BIGFONT
-_X_EXPORT Bool noXFree86BigfontExtension = FALSE;
+Bool noXFree86BigfontExtension = FALSE;
#endif
#ifdef XFreeXDGA
-_X_EXPORT Bool noXFree86DGAExtension = FALSE;
+Bool noXFree86DGAExtension = FALSE;
#endif
#ifdef XF86DRI
-_X_EXPORT Bool noXFree86DRIExtension = FALSE;
+Bool noXFree86DRIExtension = FALSE;
#endif
#ifdef XF86VIDMODE
-_X_EXPORT Bool noXFree86VidModeExtension = FALSE;
+Bool noXFree86VidModeExtension = FALSE;
#endif
#ifdef XFIXES
-_X_EXPORT Bool noXFixesExtension = FALSE;
+Bool noXFixesExtension = FALSE;
#endif
-/* |noXkbExtension| is defined in xc/programs/Xserver/xkb/xkbInit.c */
#ifdef PANORAMIX
/* Xinerama is disabled by default unless enabled via +xinerama */
-_X_EXPORT Bool noPanoramiXExtension = TRUE;
+Bool noPanoramiXExtension = TRUE;
#endif
#ifdef XSELINUX
-_X_EXPORT Bool noSELinuxExtension = FALSE;
-_X_EXPORT int selinuxEnforcingState = SELINUX_MODE_DEFAULT;
+Bool noSELinuxExtension = FALSE;
+int selinuxEnforcingState = SELINUX_MODE_DEFAULT;
#endif
#ifdef XV
-_X_EXPORT Bool noXvExtension = FALSE;
+Bool noXvExtension = FALSE;
#endif
#ifdef DRI2
-_X_EXPORT Bool noDRI2Extension = FALSE;
+Bool noDRI2Extension = FALSE;
#endif
-_X_EXPORT Bool noGEExtension = FALSE;
+Bool noGEExtension = FALSE;
#define X_INCLUDE_NETDB_H
#include <X11/Xos_r.h>
@@ -213,9 +215,7 @@ int auditTrailLevel = 1;
static char *dev_tty_from_init = NULL; /* since we need to parse it anyway */
OsSigHandlerPtr
-OsSignal(sig, handler)
- int sig;
- OsSigHandlerPtr handler;
+OsSignal(int sig, OsSigHandlerPtr handler)
{
struct sigaction act, oact;
@@ -418,8 +418,7 @@ ChownLock(uid_t uid, gid_t gid)
/* Force connections to close on SIGHUP from init */
-/*ARGSUSED*/
-SIGVAL
+void
AutoResetServer (int sig)
{
int olderrno = errno;
@@ -431,8 +430,7 @@ AutoResetServer (int sig)
/* Force connections to close and then exit on SIGTERM, SIGINT */
-/*ARGSUSED*/
-_X_EXPORT SIGVAL
+void
GiveUp(int sig)
{
int olderrno = errno;
@@ -442,14 +440,14 @@ GiveUp(int sig)
errno = olderrno;
}
-#if defined WIN32 && defined __MINGW32__
-_X_EXPORT CARD32
+#if (defined WIN32 && defined __MINGW32__) || defined(__CYGWIN__)
+CARD32
GetTimeInMillis (void)
{
return GetTickCount ();
}
#else
-_X_EXPORT CARD32
+CARD32
GetTimeInMillis(void)
{
struct timeval tv;
@@ -465,7 +463,7 @@ GetTimeInMillis(void)
}
#endif
-_X_EXPORT void
+void
AdjustWaitForDelay (pointer waitTime, unsigned long newdelay)
{
static struct timeval delay_val;
@@ -492,7 +490,7 @@ AdjustWaitForDelay (pointer waitTime, unsigned long newdelay)
void UseMsg(void)
{
ErrorF("use: X [:<display>] [option]\n");
- ErrorF("-a # mouse acceleration (pixels)\n");
+ ErrorF("-a # default pointer acceleration (factor)\n");
ErrorF("-ac disable access control restrictions\n");
ErrorF("-audit int set audit trail level\n");
ErrorF("-auth file select authorization file\n");
@@ -502,10 +500,10 @@ void UseMsg(void)
ErrorF("-c turns off key-click\n");
ErrorF("c # key-click volume (0-100)\n");
ErrorF("-cc int default color visual class\n");
+ ErrorF("-nocursor disable the cursor\n");
ErrorF("-core generate core dump on fatal error\n");
ErrorF("-dpi int screen resolution in dots per inch\n");
#ifdef DPMSExtension
- ErrorF("dpms enables VESA DPMS monitor control\n");
ErrorF("-dpms disables VESA DPMS monitor control\n");
#endif
ErrorF("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n");
@@ -524,9 +522,7 @@ void UseMsg(void)
#ifdef RLIMIT_STACK
ErrorF("-ls int limit stack space to N Kb\n");
#endif
-#ifdef SERVER_LOCK
ErrorF("-nolock disable the locking mechanism\n");
-#endif
#ifndef NOLOGOHACK
ErrorF("-logo enable logo in screen saver\n");
ErrorF("nologo disable logo in screen saver\n");
@@ -548,7 +544,7 @@ void UseMsg(void)
ErrorF("-retard start with black background and no cursor\n");
#endif
ErrorF("-s # screen-saver timeout (minutes)\n");
- ErrorF("-t # mouse threshold (pixels)\n");
+ ErrorF("-t # default pointer threshold (pixels/t)\n");
ErrorF("-terminate terminate at server reset\n");
ErrorF("-to # connection time out\n");
ErrorF("-tst disable testing extensions\n");
@@ -557,7 +553,6 @@ void UseMsg(void)
ErrorF("-v screen-saver without video blanking\n");
ErrorF("-wm WhenMapped default backing-store\n");
ErrorF("-wr create root window with white background\n");
- ErrorF("-x string loads named extension at init time \n");
ErrorF("-maxbigreqsize set maximal bigrequest size \n");
#ifdef PANORAMIX
ErrorF("+xinerama Enable XINERAMA extension\n");
@@ -570,9 +565,7 @@ void UseMsg(void)
#ifdef XDMCP
XdmcpUseMsg();
#endif
-#ifdef XKB
XkbUseMsg();
-#endif
ddxUseMsg();
}
@@ -688,7 +681,11 @@ ProcessCommandLine(int argc, char *argv[])
#endif
CoreDump = TRUE;
}
- else if ( strcmp( argv[i], "-dpi") == 0)
+ else if ( strcmp( argv[i], "-nocursor") == 0)
+ {
+ EnableCursor = FALSE;
+ }
+ else if ( strcmp( argv[i], "-dpi") == 0)
{
if(++i < argc)
monitorResolution = atoi(argv[i]);
@@ -697,7 +694,7 @@ ProcessCommandLine(int argc, char *argv[])
}
#ifdef DPMSExtension
else if ( strcmp( argv[i], "dpms") == 0)
- DPMSEnabledSwitch = TRUE;
+ /* ignored for compatibility */ ;
else if ( strcmp( argv[i], "-dpms") == 0)
DPMSDisabledSwitch = TRUE;
#endif
@@ -741,13 +738,11 @@ ProcessCommandLine(int argc, char *argv[])
UseMsg();
exit(0);
}
-#ifdef XKB
else if ( (skip=XkbProcessArguments(argc,argv,i))!=0 ) {
if (skip>0)
i+= skip-1;
else UseMsg();
}
-#endif
#ifdef RLIMIT_DATA
else if ( strcmp( argv[i], "-ld") == 0)
{
@@ -783,7 +778,6 @@ ProcessCommandLine(int argc, char *argv[])
UseMsg();
}
#endif
-#ifdef SERVER_LOCK
else if ( strcmp ( argv[i], "-nolock") == 0)
{
#if !defined(WIN32) && !defined(__CYGWIN__)
@@ -793,7 +787,6 @@ ProcessCommandLine(int argc, char *argv[])
#endif
nolock = TRUE;
}
-#endif
#ifndef NOLOGOHACK
else if ( strcmp( argv[i], "-logo") == 0)
{
@@ -915,14 +908,6 @@ ProcessCommandLine(int argc, char *argv[])
PanoramiXExtensionDisabledHack = TRUE;
}
#endif
- else if ( strcmp( argv[i], "-x") == 0)
- {
- if(++i >= argc)
- UseMsg();
- /* For U**x, which doesn't support dynamic loading, there's nothing
- * to do when we see a -x. Either the extension is linked in or
- * it isn't */
- }
else if ( strcmp( argv[i], "-I") == 0)
{
/* ignore all remaining arguments */
@@ -1074,9 +1059,7 @@ set_font_authorizations(char **authorizations, int *authlen, pointer client)
#endif /* TCPCONN */
}
-#ifndef INTERNAL_MALLOC
-
-_X_EXPORT void *
+void *
Xalloc(unsigned long amount)
{
void *ptr;
@@ -1095,7 +1078,7 @@ Xalloc(unsigned long amount)
* "no failure" realloc
*****************/
-_X_EXPORT void *
+void *
XNFalloc(unsigned long amount)
{
void *ptr;
@@ -1114,7 +1097,7 @@ XNFalloc(unsigned long amount)
* Xcalloc
*****************/
-_X_EXPORT void *
+void *
Xcalloc(unsigned long amount)
{
void *ret;
@@ -1129,7 +1112,7 @@ Xcalloc(unsigned long amount)
* XNFcalloc
*****************/
-_X_EXPORT void *
+void *
XNFcalloc(unsigned long amount)
{
void *ret;
@@ -1146,7 +1129,7 @@ XNFcalloc(unsigned long amount)
* Xrealloc
*****************/
-_X_EXPORT void *
+void *
Xrealloc(pointer ptr, unsigned long amount)
{
if ((long)amount <= 0)
@@ -1169,7 +1152,7 @@ Xrealloc(pointer ptr, unsigned long amount)
* "no failure" realloc
*****************/
-_X_EXPORT void *
+void *
XNFrealloc(pointer ptr, unsigned long amount)
{
if ((ptr = Xrealloc(ptr, amount)) == NULL)
@@ -1185,13 +1168,12 @@ XNFrealloc(pointer ptr, unsigned long amount)
* calls free
*****************/
-_X_EXPORT void
+void
Xfree(pointer ptr)
{
if (ptr)
free(ptr);
}
-#endif /* !INTERNAL_MALLOC */
char *
@@ -1211,7 +1193,7 @@ Xstrdup(const char *s)
}
-_X_EXPORT char *
+char *
XNFstrdup(const char *s)
{
char *sd;
@@ -1356,6 +1338,20 @@ OsReleaseSignals (void)
#endif
}
+/*
+ * Pending signals may interfere with core dumping. Provide a
+ * mechanism to block signals when aborting.
+ */
+
+void
+OsAbort (void)
+{
+#ifndef __APPLE__
+ OsBlockSignals();
+#endif
+ abort();
+}
+
#if !defined(WIN32)
/*
* "safer" versions of system(3), popen(3) and pclose(3) which give up
@@ -1439,7 +1435,7 @@ Popen(char *command, char *type)
if ((*type != 'r' && *type != 'w') || type[1])
return NULL;
- if ((cur = (struct pid *)xalloc(sizeof(struct pid))) == NULL)
+ if ((cur = xalloc(sizeof(struct pid))) == NULL)
return NULL;
if (pipe(pdes) < 0) {
@@ -1525,7 +1521,7 @@ Fopen(char *file, char *type)
if ((*type != 'r' && *type != 'w') || type[1])
return NULL;
- if ((cur = (struct pid *)xalloc(sizeof(struct pid))) == NULL)
+ if ((cur = xalloc(sizeof(struct pid))) == NULL)
return NULL;
if (pipe(pdes) < 0) {
@@ -1644,7 +1640,7 @@ Pclose(pointer iop)
return pid == -1 ? -1 : pstat;
}
-int
+int
Fclose(pointer iop)
{
#ifdef HAS_SAVED_IDS_AND_SETEUID
@@ -1912,6 +1908,46 @@ CheckUserAuthorization(void)
#endif
}
+/*
+ * Tokenize a string into a NULL terminated array of strings. Always returns
+ * an allocated array unless an error occurs.
+ */
+char**
+xstrtokenize(const char *str, const char *separators)
+{
+ char **list, **nlist;
+ char *tok, *tmp;
+ unsigned num = 0, n;
+
+ if (!str)
+ return NULL;
+ list = calloc(1, sizeof(*list));
+ if (!list)
+ return NULL;
+ tmp = strdup(str);
+ if (!tmp)
+ goto error;
+ for (tok = strtok(tmp, separators); tok; tok = strtok(NULL, separators)) {
+ nlist = realloc(list, (num + 2) * sizeof(*list));
+ if (!nlist)
+ goto error;
+ list = nlist;
+ list[num] = strdup(tok);
+ if (!list[num])
+ goto error;
+ list[++num] = NULL;
+ }
+ free(tmp);
+ return list;
+
+error:
+ free(tmp);
+ for (n = 0; n < num; n++)
+ free(list[n]);
+ free(list);
+ return NULL;
+}
+
#ifdef __SCO__
#include <fcntl.h>
diff --git a/xserver/os/xdmauth.c b/xserver/os/xdmauth.c
index 8cbcd581f..e19e4f93d 100644
--- a/xserver/os/xdmauth.c
+++ b/xserver/os/xdmauth.c
@@ -259,7 +259,7 @@ XdmAuthorizationValidate (unsigned char *plain, int length,
*reason = "Bad XDM authorization key length";
return NULL;
}
- client = (XdmClientAuthPtr) xalloc (sizeof (XdmClientAuthRec));
+ client = xalloc (sizeof (XdmClientAuthRec));
if (!client)
return NULL;
XdmClientAuthDecode (plain, client);
@@ -363,7 +363,7 @@ XdmAddCookie (unsigned short data_length, char *data, XID id)
/* the first octet of the key must be zero */
if (key_bits[0] != '\0')
return 0;
- new = (XdmAuthorizationPtr) xalloc (sizeof (XdmAuthorizationRec));
+ new = xalloc (sizeof (XdmAuthorizationRec));
if (!new)
return 0;
new->next = xdmAuth;
@@ -385,7 +385,7 @@ XdmCheckCookie (unsigned short cookie_length, char *cookie,
/* Auth packets must be a multiple of 8 bytes long */
if (cookie_length & 7)
return (XID) -1;
- plain = (unsigned char *) xalloc (cookie_length);
+ plain = xalloc (cookie_length);
if (!plain)
return (XID) -1;
for (auth = xdmAuth; auth; auth=auth->next) {
@@ -430,7 +430,7 @@ XdmToID (unsigned short cookie_length, char *cookie)
XdmClientAuthPtr client;
unsigned char *plain;
- plain = (unsigned char *) xalloc (cookie_length);
+ plain = xalloc (cookie_length);
if (!plain)
return (XID) -1;
for (auth = xdmAuth; auth; auth=auth->next) {
diff --git a/xserver/os/xdmcp.c b/xserver/os/xdmcp.c
index 18e13e954..1c6ec7888 100644
--- a/xserver/os/xdmcp.c
+++ b/xserver/os/xdmcp.c
@@ -391,8 +391,7 @@ XdmcpRegisterAuthentication (
AuthenticationNames.length + 1) &&
XdmcpReallocARRAYofARRAY8 (&AuthenticationDatas,
AuthenticationDatas.length + 1) &&
- (newFuncs = (AuthenticationFuncsPtr) xalloc (
- (AuthenticationNames.length + 1) * sizeof (AuthenticationFuncsRec)))))
+ (newFuncs = xalloc ((AuthenticationNames.length + 1) * sizeof (AuthenticationFuncsRec)))))
{
XdmcpDisposeARRAY8 (&AuthenticationName);
XdmcpDisposeARRAY8 (&AuthenticationData);
@@ -534,7 +533,7 @@ XdmcpRegisterAuthorization (char *name, int namelen)
ARRAY8 authName;
int i;
- authName.data = (CARD8 *) xalloc (namelen * sizeof (CARD8));
+ authName.data = xalloc (namelen * sizeof (CARD8));
if (!authName.data)
return;
if (!XdmcpReallocARRAYofARRAY8 (&AuthorizationNames, AuthorizationNames.length +1))
@@ -1592,9 +1591,7 @@ get_fromaddr_by_name(
#if defined(IPv6) && defined(AF_INET6)
static int
-get_mcast_options(argc, argv, i)
- int argc, i;
- char **argv;
+get_mcast_options(int argc, char **argv, int i)
{
char *address = XDM_DEFAULT_MCAST_ADDR6;
int hopcount = 1;
diff --git a/xserver/os/xsha1.c b/xserver/os/xsha1.c
new file mode 100644
index 000000000..355862fb1
--- /dev/null
+++ b/xserver/os/xsha1.c
@@ -0,0 +1,168 @@
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "os.h"
+#include "xsha1.h"
+
+#if defined(HAVE_SHA1_IN_LIBMD) /* Use libmd for SHA1 */ \
+ || defined(HAVE_SHA1_IN_LIBC) /* Use libc for SHA1 */
+
+# include <sha1.h>
+
+void *x_sha1_init(void)
+{
+ SHA1_CTX *ctx = xalloc(sizeof(*ctx));
+ if (!ctx)
+ return NULL;
+ SHA1Init(ctx);
+ return ctx;
+}
+
+int x_sha1_update(void *ctx, void *data, int size)
+{
+ SHA1_CTX *sha1_ctx = ctx;
+ SHA1Update(sha1_ctx, data, size);
+ return 1;
+}
+
+int x_sha1_final(void *ctx, unsigned char result[20])
+{
+ SHA1_CTX *sha1_ctx = ctx;
+ SHA1Final(result, sha1_ctx);
+ xfree(sha1_ctx);
+ return 1;
+}
+
+#elif defined(HAVE_SHA1_IN_COMMONCRYPTO) /* Use CommonCrypto for SHA1 */
+
+#include <CommonCrypto/CommonDigest.h>
+
+void *x_sha1_init(void)
+{
+ CC_SHA1_CTX *ctx = xalloc(sizeof(*ctx));
+ if (!ctx)
+ return NULL;
+ CC_SHA1_Init(ctx);
+ return ctx;
+}
+
+int x_sha1_update(void *ctx, void *data, int size)
+{
+ CC_SHA1_CTX *sha1_ctx = ctx;
+ CC_SHA1_Update(sha1_ctx, data, size);
+ return 1;
+}
+
+int x_sha1_final(void *ctx, unsigned char result[20])
+{
+ CC_SHA1_CTX *sha1_ctx = ctx;
+ CC_SHA1_Final(result, sha1_ctx);
+ xfree(sha1_ctx);
+ return 1;
+}
+
+#elif defined(HAVE_SHA1_IN_LIBGCRYPT) /* Use libgcrypt for SHA1 */
+
+# include <gcrypt.h>
+
+void *x_sha1_init(void)
+{
+ static int init;
+ gcry_md_hd_t h;
+ gcry_error_t err;
+
+ if (!init) {
+ if (!gcry_check_version(NULL))
+ return NULL;
+ gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
+ gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
+ init = 1;
+ }
+
+ err = gcry_md_open(&h, GCRY_MD_SHA1, 0);
+ if (err)
+ return NULL;
+ return h;
+}
+
+int x_sha1_update(void *ctx, void *data, int size)
+{
+ gcry_md_hd_t h = ctx;
+ gcry_md_write(h, data, size);
+ return 1;
+}
+
+int x_sha1_final(void *ctx, unsigned char result[20])
+{
+ gcry_md_hd_t h = ctx;
+ memcpy(result, gcry_md_read(h, GCRY_MD_SHA1), 20);
+ gcry_md_close(h);
+ return 1;
+}
+
+#elif defined(HAVE_SHA1_IN_LIBSHA1) /* Use libsha1 */
+
+# include <libsha1.h>
+
+void *x_sha1_init(void)
+{
+ sha1_ctx *ctx = xalloc(sizeof(*ctx));
+ if(!ctx)
+ return NULL;
+ sha1_begin(ctx);
+ return ctx;
+}
+
+int x_sha1_update(void *ctx, void *data, int size)
+{
+ sha1_hash(data, size, ctx);
+ return 1;
+}
+
+int x_sha1_final(void *ctx, unsigned char result[20])
+{
+ sha1_end(result, ctx);
+ xfree(ctx);
+ return 1;
+}
+
+#else /* Use OpenSSL's libcrypto */
+
+# include <stddef.h> /* buggy openssl/sha.h wants size_t */
+# include <openssl/sha.h>
+
+void *x_sha1_init(void)
+{
+ int ret;
+ SHA_CTX *ctx = xalloc(sizeof(*ctx));
+ if (!ctx)
+ return NULL;
+ ret = SHA1_Init(ctx);
+ if (!ret) {
+ xfree(ctx);
+ return NULL;
+ }
+ return ctx;
+}
+
+int x_sha1_update(void *ctx, void *data, int size)
+{
+ int ret;
+ SHA_CTX *sha_ctx = ctx;
+ ret = SHA1_Update(sha_ctx, data, size);
+ if (!ret)
+ xfree(sha_ctx);
+ return ret;
+}
+
+int x_sha1_final(void *ctx, unsigned char result[20])
+{
+ int ret;
+ SHA_CTX *sha_ctx = ctx;
+ ret = SHA1_Final(result, sha_ctx);
+ xfree(sha_ctx);
+ return ret;
+}
+
+#endif