From 432768f75da13ee5343957df6ce5cd316a62929f Mon Sep 17 00:00:00 2001 From: marha Date: Sat, 8 Jan 2011 19:40:59 +0000 Subject: xserver mesa libX11 xkbcomp pixman git update 8/1/2011 --- libX11/src/XlibInt.c | 2 + mesalib/Makefile | 2 +- mesalib/bin/mklib | 2048 ++++--- mesalib/configs/default | 2 +- mesalib/configure.ac | 21 +- mesalib/docs/egl.html | 10 + mesalib/docs/relnotes-7.10.html | 2753 ++++++++- mesalib/docs/relnotes-7.9.1.html | 406 ++ mesalib/include/GL/glext.h | 14 +- mesalib/src/glsl/ast.h | 6 +- mesalib/src/glsl/ast_to_hir.cpp | 87 +- mesalib/src/glsl/autogen.sh | 12 + mesalib/src/glsl/builtin_function.cpp | 28 +- mesalib/src/glsl/configure.ac | 69 + mesalib/src/glsl/glsl_lexer.cpp | 1952 +++---- mesalib/src/glsl/glsl_lexer.lpp | 4 + mesalib/src/glsl/glsl_parser.cpp | 3241 +++++------ mesalib/src/glsl/glsl_parser.h | 160 +- mesalib/src/glsl/glsl_parser.ypp | 14 + mesalib/src/glsl/glsl_parser_extras.h | 7 + mesalib/src/glsl/ir.h | 3 +- mesalib/src/mapi/mapi/table.c | 2 +- mesalib/src/mesa/main/accum.c | 1 + mesalib/src/mesa/main/api_arrayelt.c | 2 + mesalib/src/mesa/main/api_arrayelt.h | 1 + mesalib/src/mesa/main/api_noop.c | 1 + mesalib/src/mesa/main/api_noop.h | 121 +- mesalib/src/mesa/main/arrayobj.c | 2 + mesalib/src/mesa/main/atifragshader.c | 1 + mesalib/src/mesa/main/attrib.c | 1 + mesalib/src/mesa/main/bufferobj.c | 2 + mesalib/src/mesa/main/bufferobj.h | 1 + mesalib/src/mesa/main/buffers.c | 1 + mesalib/src/mesa/main/clear.c | 1 + mesalib/src/mesa/main/colormac.h | 6 +- mesalib/src/mesa/main/colortab.c | 2 + mesalib/src/mesa/main/condrender.c | 1 + mesalib/src/mesa/main/context.c | 8 + mesalib/src/mesa/main/convolve.c | 1 + mesalib/src/mesa/main/cpuinfo.c | 218 +- mesalib/src/mesa/main/dlist.h | 1 + mesalib/src/mesa/main/drawpix.c | 1 + mesalib/src/mesa/main/drawtex.c | 2 + mesalib/src/mesa/main/enable.c | 1 + mesalib/src/mesa/main/eval.c | 1 + mesalib/src/mesa/main/eval.h | 1 + mesalib/src/mesa/main/extensions.c | 1 + mesalib/src/mesa/main/fbobject.c | 29 +- mesalib/src/mesa/main/fbobject.h | 3 + mesalib/src/mesa/main/feedback.c | 1 + mesalib/src/mesa/main/feedback.h | 1 + mesalib/src/mesa/main/ffvertex_prog.c | 1 + mesalib/src/mesa/main/formats.c | 7 +- mesalib/src/mesa/main/framebuffer.c | 8 +- mesalib/src/mesa/main/framebuffer.h | 3 +- mesalib/src/mesa/main/get.c | 1 + mesalib/src/mesa/main/getstring.c | 2 + mesalib/src/mesa/main/hint.c | 1 + mesalib/src/mesa/main/histogram.c | 1 + mesalib/src/mesa/main/image.c | 2 + mesalib/src/mesa/main/imports.c | 1 + mesalib/src/mesa/main/matrix.c | 1 + mesalib/src/mesa/main/mipmap.c | 1 + mesalib/src/mesa/main/mtypes.h | 3 + mesalib/src/mesa/main/multisample.c | 1 + mesalib/src/mesa/main/nvprogram.c | 1 + mesalib/src/mesa/main/pack.c | 1 + mesalib/src/mesa/main/pixel.c | 1 + mesalib/src/mesa/main/pixelstore.c | 1 + mesalib/src/mesa/main/pixeltransfer.c | 1 + mesalib/src/mesa/main/queryobj.c | 1 + mesalib/src/mesa/main/queryobj.h | 1 + mesalib/src/mesa/main/rastpos.c | 2 + mesalib/src/mesa/main/readpix.c | 1 + mesalib/src/mesa/main/renderbuffer.c | 11 +- mesalib/src/mesa/main/renderbuffer.h | 6 +- mesalib/src/mesa/main/scissor.c | 1 + mesalib/src/mesa/main/shaderapi.c | 2 + mesalib/src/mesa/main/shaderobj.c | 2 + mesalib/src/mesa/main/shared.c | 1 + mesalib/src/mesa/main/syncobj.c | 2 + mesalib/src/mesa/main/texcompress.c | 2 + mesalib/src/mesa/main/texcompress_fxt1.c | 1 + mesalib/src/mesa/main/texcompress_fxt1.h | 123 +- mesalib/src/mesa/main/texcompress_s3tc.c | 2 + mesalib/src/mesa/main/texenv.c | 1 + mesalib/src/mesa/main/texenvprogram.c | 1 + mesalib/src/mesa/main/texfetch_tmp.h | 6 +- mesalib/src/mesa/main/texformat.c | 311 +- mesalib/src/mesa/main/texgen.c | 801 +-- mesalib/src/mesa/main/texgen.h | 169 +- mesalib/src/mesa/main/texgetimage.c | 2 + mesalib/src/mesa/main/teximage.c | 3 +- mesalib/src/mesa/main/texobj.c | 6 + mesalib/src/mesa/main/texpal.c | 409 +- mesalib/src/mesa/main/texparam.c | 2 + mesalib/src/mesa/main/texstore.c | 34 +- mesalib/src/mesa/main/transformfeedback.c | 2 + mesalib/src/mesa/main/uniforms.c | 4 +- mesalib/src/mesa/main/varray.c | 1 + mesalib/src/mesa/main/version.c | 3 +- mesalib/src/mesa/main/version.h | 6 +- mesalib/src/mesa/main/viewport.c | 1 + mesalib/src/mesa/main/vtxfmt.c | 1 + mesalib/src/mesa/main/vtxfmt.h | 1 + mesalib/src/mesa/state_tracker/st_atom.c | 4 + mesalib/src/mesa/state_tracker/st_atom_constbuf.c | 27 +- mesalib/src/mesa/state_tracker/st_cb_clear.c | 8 +- mesalib/src/mesa/state_tracker/st_cb_drawpixels.c | 1 + mesalib/src/mesa/state_tracker/st_cb_fbo.c | 6 +- mesalib/src/mesa/state_tracker/st_context.c | 7 - mesalib/src/mesa/state_tracker/st_context.h | 14 +- mesalib/src/mesa/state_tracker/st_draw_feedback.c | 15 +- mesalib/src/mesa/state_tracker/st_extensions.c | 1 + mesalib/src/mesa/state_tracker/st_manager.c | 6 +- mesalib/src/mesa/state_tracker/st_program.c | 2 + mesalib/src/mesa/swrast/s_texfilter.c | 1 - mesalib/src/mesa/swrast/s_triangle.c | 2 +- mesalib/src/mesa/vbo/vbo_context.c | 1 - pixman/pixman/pixman-sse2.c | 75 +- xkbcomp/Makefile.am | 6 +- xkbcomp/README | 44 +- xkbcomp/README.config | 195 - xkbcomp/README.enhancing | 508 -- xorg-server/Xext/geext.c | 2 - xorg-server/Xext/security.c | 2 - xorg-server/Xext/sync.c | 5820 ++++++++++---------- xorg-server/Xi/xigrabdev.c | 322 +- xorg-server/Xi/xipassivegrab.c | 2 +- xorg-server/Xi/xiselectev.c | 15 +- xorg-server/composite/compalloc.c | 38 +- xorg-server/composite/compinit.c | 62 +- xorg-server/composite/compint.h | 5 +- xorg-server/composite/compwindow.c | 34 +- xorg-server/config/udev.c | 19 +- xorg-server/dix/events.c | 15 +- xorg-server/dix/property.c | 3 + xorg-server/dix/window.c | 4 + xorg-server/doc/xml/Xserver-spec.xml | 7 +- xorg-server/exa/exa_mixed.c | 2 +- xorg-server/exa/exa_unaccel.c | 5 +- xorg-server/glx/glxdri2.c | 2 +- xorg-server/glx/unpack.h | 2 +- xorg-server/hw/dmx/glxProxy/unpack.h | 2 +- xorg-server/hw/xfree86/common/xf86AutoConfig.c | 2 +- xorg-server/hw/xfree86/common/xf86Module.h | 2 +- xorg-server/hw/xfree86/common/xf86VGAarbiter.c | 5 +- xorg-server/hw/xfree86/common/xf86VGAarbiterPriv.h | 2 +- xorg-server/hw/xfree86/dixmods/extmod/modinit.c | 2 +- xorg-server/hw/xfree86/dixmods/extmod/modinit.h | 168 +- xorg-server/hw/xfree86/dri/dri.c | 2 +- xorg-server/hw/xfree86/dri2/dri2.c | 11 + xorg-server/hw/xfree86/loader/loadmod.c | 2 +- xorg-server/hw/xfree86/modes/xf86EdidModes.c | 2432 ++++---- xorg-server/hw/xfree86/modes/xf86Modes.c | 33 +- xorg-server/hw/xfree86/os-support/linux/lnx_agp.c | 2 +- .../hw/xfree86/os-support/linux/lnx_video.c | 2 +- xorg-server/hw/xfree86/x86emu/ops.c | 63 +- xorg-server/hw/xfree86/xaa/xaaBitBlt.c | 6 +- xorg-server/include/exevents.h | 2 +- xorg-server/include/input.h | 20 +- xorg-server/include/inpututils.h | 8 - xorg-server/include/resource.h | 2 + xorg-server/include/scrnintstr.h | 3 +- xorg-server/include/windowstr.h | 3 + xorg-server/mi/micopy.c | 6 +- xorg-server/mi/misprite.c | 122 +- xorg-server/miext/damage/damage.c | 20 - xorg-server/miext/rootless/rootlessScreen.c | 5 +- xorg-server/os/access.c | 4182 +++++++------- xorg-server/os/connection.c | 1 + xorg-server/os/osdep.h | 4 + xorg-server/render/animcur.c | 26 +- xorg-server/render/mipict.c | 3 +- 174 files changed, 15392 insertions(+), 12251 deletions(-) create mode 100644 mesalib/docs/relnotes-7.9.1.html create mode 100644 mesalib/src/glsl/autogen.sh create mode 100644 mesalib/src/glsl/configure.ac delete mode 100644 xkbcomp/README.config delete mode 100644 xkbcomp/README.enhancing diff --git a/libX11/src/XlibInt.c b/libX11/src/XlibInt.c index a4adaa130..11e8dfdf8 100644 --- a/libX11/src/XlibInt.c +++ b/libX11/src/XlibInt.c @@ -883,6 +883,8 @@ void _XEnq( type = event->u.u.type & 0177; extension = ((xGenericEvent*)event)->extension; + + qelt->event.type = type; /* If an extension has registerd a generic_event_vec handler, then * it can handle event cookies. Otherwise, proceed with the normal * event handlers. diff --git a/mesalib/Makefile b/mesalib/Makefile index 76493ec14..2e4875bca 100644 --- a/mesalib/Makefile +++ b/mesalib/Makefile @@ -180,7 +180,7 @@ ultrix-gcc: # Rules for making release tarballs -VERSION=7.10-devel +VERSION=7.11-devel DIRECTORY = Mesa-$(VERSION) LIB_NAME = MesaLib-$(VERSION) GLUT_NAME = MesaGLUT-$(VERSION) diff --git a/mesalib/bin/mklib b/mesalib/bin/mklib index 2f9223ff3..082dd2d3b 100644 --- a/mesalib/bin/mklib +++ b/mesalib/bin/mklib @@ -1,1031 +1,1017 @@ -#!/bin/sh - -# Make a shared library. -# This script should be useful for projects other than Mesa. -# Improvements/fixes are welcome. - - -# Copyright (C) 1999-2006 Brian Paul 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 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 -# BRIAN PAUL 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. - - -# Clear CDPATH as the 'cd' command will echo stuff -# to stdout if it is set -unset CDPATH - -# Given a list of files, look for .a archives and unpack them. -# Return the original list of files minus the .a files plus the unpacked files. -# first param: name of a temp directory (to be deleted when finished) -# remaining params: list of .o and .a files -expand_archives() { - DIR=$1 - shift - FILES=$@ - NEWFILES="" - ORIG_DIR=`pwd` - mkdir -p "$DIR" - cd "$DIR" - for FILE in $FILES ; do - case $FILE in - *.a) - # extract the .o files from this .a archive - case $FILE in - /*) ;; - *) FILE="$ORIG_DIR/$FILE" ;; - esac - MEMBERS=`ar t $FILE` - ar x $FILE - for MEMBER in $MEMBERS ; do - NEWFILES="$NEWFILES $DIR/$MEMBER" - done - ;; - *) - # other file type, just add to list - NEWFILES="$NEWFILES $FILE" - ;; - esac - done - cd "$ORIG_DIR" - echo $NEWFILES -} - - -# Make static library with 'ar' -# params: -# options to ar -# 1 or 0 to indicate if ranlib should be run -# libname to make -# list of object files -# Return name of library we made -# Example: "make_ar_static_lib -ru 1 libfoo.a foo.o bar.o" -make_ar_static_lib() { - OPTS=$1 - shift; - RANLIB=$1 - shift; - LIBNAME=$1 - shift; - OBJECTS=$@ - - # remove existing lib, if present - rm -f ${LIBNAME} - - # make static lib - ar ${OPTS} ${LIBNAME} ${OBJECTS} - - # run ranlib - if [ ${RANLIB} = 1 ] ; then - ranlib ${LIBNAME} - fi - - echo ${LIBNAME} -} - - -# Print usage info. -usage() { - echo 'Usage: mklib [options] objects' - echo 'Create a shared library from object files.' - echo ' -o LIBRARY specifies the name of the resulting library, without' - echo ' the leading "lib" or any suffix.' - echo ' (eg: "-o GL" might result in "libGL.so" being made)' - echo ' -major N specifies major version number (default is 1)' - echo ' -minor N specifies minor version number (default is 0)' - echo ' -patch N specifies patch version number (default is 0)' - echo ' -lLIBRARY specifies a dependency on LIBRARY' - echo ' -LDIR search in DIR for library dependencies at build time' - echo ' -RDIR search in DIR for library dependencies at run time' - echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)' - echo ' Not observed on all systems at this time.' - echo ' -ldflags OPT specify any additional linker flags in OPT' - echo ' -cplusplus link with C++ runtime' - echo ' -static make a static library (default is dynamic/shared)' - echo ' -dlopen make a shared library suitable for dynamic loading' - echo ' -install DIR put resulting library file(s) in DIR' - echo ' -arch ARCH override using `uname` to determine host system' - echo ' -archopt OPT specify an extra achitecture-specific option OPT' - echo ' -altopts OPTS alternate options to override all others' - echo " -noprefix don't prefix library name with 'lib' nor add any suffix" - echo ' -exports FILE only export the symbols listed in FILE' - echo ' -id NAME Sets the id of the dylib (Darwin)' - echo ' -h, --help display this information and exit' -} - - -# -# Option defaults -# -LIBNAME="" -MAJOR=1 -MINOR=0 -PATCH="" -DEPS="" -LINK="" -LDFLAGS="" -CPLUSPLUS=0 -STATIC=0 -DLOPEN=0 -INSTALLDIR="." -ARCH="auto" -ARCHOPT="" -NOPREFIX=0 -EXPORTS="" -ID="" - -# -# Parse arguments -# -while true -do - case $1 in - '-h' | '--help') - usage - exit 1 - ;; - '-o') - shift 1; - LIBNAME=$1 - ;; - '-major') - shift 1; - MAJOR=$1 - ;; - '-minor') - shift 1; - MINOR=$1 - ;; - '-patch') - shift 1; - PATCH=$1 - ;; - '-linker') - shift 1; - LINK=$1 - ;; - '-ldflags') - shift 1; - LDFLAGS=$1 - ;; - -l*) - DEPS="$DEPS $1" - ;; - -L*) - DEPS="$DEPS $1" - ;; - -R*) - DEPS="$DEPS $1" - ;; - -Wl*) - DEPS="$DEPS $1" - ;; - -pthread) - # this is a special case (see bugzilla 10876) - DEPS="$DEPS $1" - ;; - '-pthread') - DEPS="$DEPS -pthread" - ;; - '-cplusplus') - CPLUSPLUS=1 - ;; - '-static') - STATIC=1 - ;; - '-dlopen') - DLOPEN=1 - ;; - '-install') - shift 1; - INSTALLDIR=$1 - ;; - '-arch') - shift 1; - ARCH=$1 - ;; - '-archopt') - shift 1; - ARCHOPT=$1 - ;; - '-altopts') - shift 1; - ALTOPTS=$1 - ;; - '-noprefix') - NOPREFIX=1 - ;; - '-exports') - shift 1; - EXPORTS=$1 - ;; - '-id') - shift 1; - ID=$1 - ;; - -*) - echo "mklib: Unknown option: " $1 ; - exit 1 - ;; - *) - # This should be the first object file, stop parsing - break - esac - shift 1 -done -OBJECTS=$@ - - -if [ ${ARCH} = "auto" ] ; then - ARCH=`uname` -fi - - -if [ $STATIC = 1 ]; then - # filter out linker options inside object list - NEWOBJECTS="" - for OBJ in $OBJECTS ; do - case $OBJ in - -Wl,*) - echo "mklib: warning: ignoring $OBJ for static library" - ;; - *) - NEWOBJECTS="$NEWOBJECTS $OBJ" - ;; - esac - done - OBJECTS=$NEWOBJECTS -fi - - -# -# Error checking -# -if [ "x${LIBNAME}" = "x" ] ; then - echo "mklib: Error: no library name specified (-h for help)" - exit 1 -fi -if [ "x${OBJECTS}" = "x" ] ; then - echo "mklib: Error: no object files specified (-h for help)" - exit 1 -fi - - -# -# Debugging info -# -if [ ] ; then - echo "-----------------" - echo ARCH is $ARCH - echo LIBNAME is $LIBNAME - echo MAJOR is $MAJOR - echo MINOR is $MINOR - echo PATCH is $PATCH - echo DEPS are $DEPS - echo "EXPORTS in" $EXPORTS - echo ID is $ID - echo "-----------------" -fi - - -# -# OK, make the library now -# -case $ARCH in - - 'Linux' | 'OpenBSD' | 'DragonFly' | 'GNU' | GNU/*) - # we assume gcc - - if [ "x$LINK" = "x" ] ; then - # -linker was not specified so set default link command now - if [ $CPLUSPLUS = 1 ] ; then - LINK=g++ - else - LINK=gcc - fi - fi - - if [ $NOPREFIX = 1 ] ; then - # No "lib" or ".so" part - echo "mklib: Making" $ARCH "shared library: " ${LIBNAME} - case $ARCH in 'Linux' | 'GNU' | GNU/*) - OPTS="-Xlinker -Bsymbolic -shared" - ;; - *) - OPTS="-shared" - ;; - esac - - # Check if objects are 32-bit and we're running in 64-bit - # environment. If so, pass -m32 flag to linker. - set ${OBJECTS} - ABI32=`file $1 | grep 32-bit` - if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then - OPTS="-m32 ${OPTS}" - fi - - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - - rm -f ${LIBNAME} - # make lib - ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} - # finish up - FINAL_LIBS="${LIBNAME}" - elif [ $STATIC = 1 ] ; then - # make a static .a library - LIBNAME="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a" - echo "mklib: Making" $ARCH "static library: " ${LIBNAME} - OPTS="-ru" - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - - # expand .a into .o files - NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS` - - # make static lib - FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}` - - # remove temporary extracted .o files - rm -rf ${LIBNAME}.obj - else - # make dynamic library - LIBNAME="lib${LIBNAME}" # prefix with "lib" - case $ARCH in 'Linux' | 'GNU' | GNU/*) - OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" - ;; - *) - OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" - ;; - esac - if [ $EXPORTS ] ; then - #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}" - # Make the 'exptmp' file for --version-script option - echo "{" > exptmp - echo "global:" >> exptmp - sed 's/$/;/' ${EXPORTS} >> exptmp - echo "local:" >> exptmp - echo "*;" >> exptmp - echo "};" >> exptmp - OPTS="${OPTS} -Xlinker --version-script=exptmp" - # exptmp is removed below - fi - - # Check if objects are 32-bit and we're running in 64-bit - # environment. If so, pass -m32 flag to linker. - set ${OBJECTS} - ABI32=`file $1 | grep 32-bit` - if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then - OPTS="-m32 ${OPTS}" - fi - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - - if [ x${PATCH} = "x" ] ; then - VERSION="${MAJOR}.${MINOR}" - else - VERSION="${MAJOR}.${MINOR}.${PATCH}" - fi - - echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION} - - # rm any old libs - rm -f ${LIBNAME}.so.${VERSION} - rm -f ${LIBNAME}.so.${MAJOR} - rm -f ${LIBNAME}.so - - # make lib - ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} - # make usual symlinks - ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} - ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so - # finish up - FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" -# rm -f exptmp - fi - ;; - - 'SunOS') - if [ $STATIC = 1 ] ; then - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making SunOS static library: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib -ruc 0 ${LIBNAME} ${OBJECTS}` - else - if [ $NOPREFIX = 0 ] ; then - LIBNAME="lib${LIBNAME}.so" - fi - echo "mklib: Making SunOS shared library: " ${LIBNAME} - - if [ "x$LINK" = "x" ] ; then - # -linker was not specified, choose default linker now - if [ $CPLUSPLUS = 1 ] ; then - # determine linker and options for C++ code - if [ `which c++` ] ; then - # use Sun c++ - LINK="c++" - elif [ `type g++` ] ; then - # use g++ - LINK="g++" - else - echo "mklib: warning: can't find C++ compiler, trying CC." - LINK="CC" - fi - else - # use native Sun linker for C code - LINK="ld" - fi - fi - - # linker options - if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then - # SunOS tools, -G to make shared libs - OPTS="-G" - else - # gcc linker - # Check if objects are 32-bit and we're running in 64-bit - # environment. If so, pass -m32 flag to linker. - set ${OBJECTS} - ABI32=`file $1 | grep 32-bit` - if [ "${ABI32}" ] ; then - OPTS="-m32 -shared -Wl,-Bdynamic" - else - OPTS="-m64 -shared -Wl,-Bdynamic" - fi - fi - - # If using Sun C++ compiler, need to tell it not to add runpaths - # that are specific to the build machine - if [ ${LINK} = "CC" ] ; then - OPTS="${OPTS} -norunpath" - fi - - # Solaris linker requires explicitly listing the Standard C & C++ - # libraries in the link path when building shared objects - if [ ${LINK} = "CC" ] ; then - DEPS="${DEPS} -lCrun" - fi - DEPS="${DEPS} -lc" - - if [ $EXPORTS ] ; then - # Make the 'mapfile.scope' linker mapfile - echo "{" > mapfile.scope - echo "global:" >> mapfile.scope - sed 's/$/;/' ${EXPORTS} >> mapfile.scope - echo "local:" >> mapfile.scope - echo " *;" >> mapfile.scope - echo "};" >> mapfile.scope - OPTS="${OPTS} -Wl,-Mmapfile.scope" - fi - - # Check if objects are 64-bit - # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1 - set ${OBJECTS} - if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then - ABI64=`file $1 | grep "ELF 64-bit"` - if [ "${ABI64}" ] ; then - case `uname -p` in - sparc) OPTS="${OPTS} -xarch=v9" ;; - i386) OPTS="${OPTS} -xarch=amd64" ;; - esac - fi - fi - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - - # for debug: - #echo "mklib: linker is" ${LINK} ${OPTS} - if [ $NOPREFIX = 1 ] ; then - rm -f ${LIBNAME} - ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} - FINAL_LIBS="${LIBNAME}" - else - rm -f ${LIBNAME}.${MAJOR} ${LIBNAME} - ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS} - ln -s ${LIBNAME}.${MAJOR} ${LIBNAME} - FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}" - fi - fi - ;; - - 'FreeBSD') - # we assume gcc - - if [ "x$LINK" = "x" ] ; then - # -linker was not specified so set default link command now - if [ $CPLUSPLUS = 1 ] ; then - LINK=g++ - else - LINK=gcc - fi - fi - - if [ $NOPREFIX = 1 ] ; then - # No "lib" or ".so" part - echo "mklib: Making FreeBSD shared library: " ${LIBNAME} - OPTS="-shared" - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - rm -f ${LIBNAME} - ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} - FINAL_LIBS=${LIBNAME} - elif [ $STATIC = 1 ] ; then - # make a static .a library - STLIB="lib${LIBNAME}.a" - echo "mklib: Making FreeBSD static library: " ${STLIB} - - # expand .a into .o files - NEW_OBJECTS=`expand_archives ${STLIB}.obj $OBJECTS` - - FINAL_LIBS=`make_ar_static_lib cq 1 ${STLIB} ${NEW_OBJECTS}` - - # remove temporary extracted .o files - rm -rf ${STLIB}.obj - else - # make dynamic library - SHLIB="lib${LIBNAME}.so.${MAJOR}" - OPTS="-shared -Wl,-soname,${SHLIB}" - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - echo "mklib: Making FreeBSD shared library: " ${SHLIB} - rm -f ${SHLIB} - ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS} - ln -sf ${SHLIB} "lib${LIBNAME}.so" - FINAL_LIBS="${SHLIB} lib${LIBNAME}.so" - fi - ;; - - 'NetBSD') - if [ $STATIC = 1 ] ; then - LIBNAME="lib${LIBNAME}_pic.a" - echo "mklib: Making NetBSD PIC static library: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib cq 1 ${LIBNAME} ${OBJECTS}` - else - LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}" - echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME} - rm -f ${LIBNAME} - ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS} - FINAL_LIBS=${LIBNAME} - fi - ;; - - 'IRIX' | 'IRIX64') - if [ $STATIC = 1 ] ; then - LIBNAME="lib${LIBNAME}.a" - FINAL_LIBS=`make_ar_static_lib rc 0 ${LIBNAME} ${OBJECTS}` - else - LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" - - # examine first object to determine ABI - set ${OBJECTS} - ABI_O32=`file $1 | grep 'ELF 32-bit'` - ABI_N32=`file $1 | grep 'ELF N32'` - ABI_N64=`file $1 | grep 'ELF 64-bit'` - if [ "${ABI_O32}" ] ; then - OPTS="-32 -shared -all" - ABI="o32-bit" - elif [ "${ABI_N32}" ] ; then - OPTS="-n32 -shared -all" - ABI="n32-bit" - elif [ "${ABI_N64}" ] ; then - OPTS="-64 -shared -all" - ABI="64-bit" - else - echo "Error: Unexpected IRIX ABI!" - exit 1 - fi - - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - - if [ $CPLUSPLUS = 1 ] ; then - LINK="CC" - else - LINK="ld" - fi - - echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME} - ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} - FINAL_LIBS=${LIBNAME} - fi - ;; - - 'linux-cygwin') - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making linux-cygwin library: " ${LIBNAME} - rm -f ${LIBNAME} - gnuwin32ar ruv ${LIBNAME} ${OBJECTS} - FINAL_LIBS=${LIBNAME} - ;; - - 'HP-UX') - if [ $STATIC = 1 ] ; then - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making HP-UX static library: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}` - else - # HP uses a .2 for their current GL/GLU libraries - if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then - MAJOR=2 - fi - RUNLIB="lib${LIBNAME}.${MAJOR}" - DEVLIB="lib${LIBNAME}.sl" - echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB} - ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS} - ln -s ${RUNLIB} ${DEVLIB} - FINAL_LIBS="${RUNLIB} ${DEVLIB}" - fi - ;; - - 'AIX' ) - # examine first object to determine ABI - set ${OBJECTS} - ABI_64=`file $1 | grep '64-bit'` - if [ "${ABI_64}" ] ; then - X64="-X64" - Q64="-q64" - OFILE=shr_64.o - else - OFILE=shr.o #Want to be consistent with the IBM libGL.a - fi - - if [ $STATIC = 1 ] ; then - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making AIX static library: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}` - else - EXPFILE="lib${LIBNAME}.exp" - LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries - OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}" - rm -f ${EXPFILE} ${OFILE} - NM="/bin/nm -eC ${X64}" - echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE} - ${NM} ${OBJECTS} | awk '{ - if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \ - && ( substr($1,1,1) != ".")) { - if (substr ($1, 1, 7) != "__sinit" && - substr ($1, 1, 7) != "__sterm") { - if (substr ($1, 1, 5) == "__tf1") - print (substr ($1, 7)) - else if (substr ($1, 1, 5) == "__tf9") - print (substr ($1, 15)) - else - print $1 - } - } - }' | sort -u >> ${EXPFILE} - - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - - # On AIX a shared library is linked differently when - # you want to dlopen the file - if [ $DLOPEN = "1" ] ; then - cc -G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} - else - cc ${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS} - ar ${X64} -r ${LIBNAME} ${OFILE} - fi - - FINAL_LIBS="${LIBNAME}" - fi - ;; - - 'OpenSTEP') - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making OpenSTEP static library: " ${LIBNAME} - libtool -static -o ${LIBNAME} - ${OBJECTS} - FINAL_LIBS=${LIBNAME} - ;; - - 'OSF1') - if [ $STATIC = 1 ] ; then - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making OSF/1 static library: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}` - else - VERSION="${MAJOR}.${MINOR}" - LIBNAME="lib${LIBNAME}.so" - echo "mklib: Making OSF/1 shared library: " ${LIBNAME} - if [ "x$LINK" = "x" ] ; then - if [ $CPLUSPLUS = 1 ] ; then - LINK=cxx - else - LINK=cc - fi - fi - rm -f ${LIBNAME}.${VERSION} - ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS} - ln -sf ${LIBNAME}.${VERSION} ${LIBNAME} - FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}" - fi - ;; - - 'Darwin') - if [ $STATIC = 1 ] ; then - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making Darwin static library: " ${LIBNAME} - OPTS="-ruvs" - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - - # expand .a into .o files - NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS` - - # make static lib - FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}` - - # remove temporary extracted .o files - rm -rf ${LIBNAME}.obj - - FINAL_LIBS=${LIBNAME} - else - # On Darwin a .bundle is used for a library that you want to dlopen - if [ $DLOPEN = "1" ] ; then - LIBSUFFIX="bundle" - OPTS="${ARCHOPT} -bundle -multiply_defined suppress" - else - LIBSUFFIX="dylib" - if [ -z "$ID" ] ; then - ID="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}" - fi - OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}" - fi - - if [ ${EXPORTS} ] ; then - if [ -f ${EXPORTS}".darwin" ] ; then - EXPORTS=$EXPORTS".darwin" - fi - OPTS="${OPTS} -exported_symbols_list ${EXPORTS}" - fi - - LINKNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}" - LINKNAME2="lib${LIBNAME}.${LIBSUFFIX}" - LIBNAME="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}" - - # examine first object to determine ABI - set ${OBJECTS} - ABIS=`lipo -info $1 | sed s/.*://` - for ABI in $ABIS; do - OPTS="${OPTS} -arch ${ABI}" - done - - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - - # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk - # to OPTS here? - - # determine linker - if [ $CPLUSPLUS = 1 ] ; then - LINK="g++" - else - LINK="cc" - fi - - echo "mklib: Making Darwin shared library: " ${LIBNAME} - - ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} - ln -s ${LIBNAME} ${LINKNAME} - ln -s ${LIBNAME} ${LINKNAME2} - FINAL_LIBS="${LIBNAME} ${LINKNAME} ${LINKNAME2}" - fi - ;; - - 'LynxOS') - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making LynxOS static library: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib -ru 0 ${LIBNAME} ${OBJECTS}` - ;; - - 'BeOS') - if [ $STATIC = 1 ] ; then - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making BeOS static library: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib -cru 0 ${LIBNAME} ${OBJECTS}` - else - LIBNAME="lib${LIBNAME}.so" - echo "mklib: Making BeOS shared library: " ${LIBNAME} - gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}" - mimeset -f "${LIBNAME}" - # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific. - setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!" - fi - FINAL_LIBS=${LIBNAME} - ;; - - 'QNX') - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making QNX library: " ${LIBNAME} - wlib ${LIBNAME} ${OBJECTS} - FINAL_LIBS=${LIBNAME} - ;; - - 'MorphOS') - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making MorphOS library: " ${LIBNAME} - ppc-morphos-ar rc ${LIBNAME} ${OBJECTS} - FINAL_LIBS="${LIBNAME}" - ;; - - 'icc' | 'icc-istatic') - # Intel C compiler - # This should get merged into the Linux code, above, since this isn't - # really a different architecture. - LIBNAME="lib${LIBNAME}" # prefix with "lib" - - if [ $STATIC = 1 ] ; then - echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a - LINK="ar" - OPTS="-ruv" - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - # make lib - ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} - # finish up - FINAL_LIBS="${LIBNAME}.a" - else - if [ $ARCH = icc-istatic ] ; then - OPTS="-shared -i-static -cxxlib-icc" - else - OPTS="-shared" - fi - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - VERSION="${MAJOR}.${MINOR}.${PATCH}" - echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION} - - if [ $CPLUSPLUS = 1 ] ; then - LINK="icpc" - else - LINK="icc" - fi - # rm any old libs - rm -f ${LIBNAME}.so.${VERSION} - rm -f ${LIBNAME}.so.${MAJOR} - rm -f ${LIBNAME}.so - # make lib - ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} - # make usual symlinks - ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} - ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so - # finish up - FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" - fi - ;; - - 'aix-gcc') - # AIX with gcc - if [ $STATIC = 1 ] ; then - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making AIX GCC static library: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}` - else - LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" - echo "mklib: Making AIX GCC shared library: " ${LIBNAME} - # remove old lib - rm -f ${LIBNAME} - # make the lib - gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME} - # NOTE: the application linking with this library must specify - # the -Wl,-brtl flags to gcc - FINAL_LIBS=${LIBNAME} - fi - ;; - - 'ultrix') - # XXX untested - if [ $STATIC = 0 ] ; then - echo "mklib: Warning shared libs not supported on Ultrix" - fi - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making static library for Ultrix: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}` - ;; - - CYGWIN*) - # GCC-based environment - - if [ "x$LINK" = "x" ] ; then - # -linker was not specified so set default link command now - if [ $CPLUSPLUS = 1 ] ; then - LINK=g++ - else - LINK=gcc - fi - fi - - if [ $NOPREFIX = 1 ] ; then - # No "lib" or ".so" part - echo "mklib: Making CYGWIN shared library: " ${LIBNAME} - OPTS="-shared -Wl,--enable-auto-image-base" - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - rm -f ${LIBNAME} - ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} || exit $? - FINAL_LIBS=${LIBNAME} - else - CYGNAME="cyg${LIBNAME}" # prefix with "cyg" - LIBNAME="lib${LIBNAME}" # prefix with "lib" - - if [ $STATIC = 1 ] ; then - LIBNAME=${LIBNAME}.a - echo "mklib: Making CYGWIN static library: " ${LIBNAME} - OPTS="-ru" - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - - # expand .a into .o files - NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS` - - FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}` - - # remove temporary extracted .o files - rm -rf ${LIBNAME}.obj - else - OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a" - if [ "${ALTOPTS}" ] ; then - OPTS=${ALTOPTS} - fi - echo "mklib: Making CYGWIN shared library: " ${CYGNAME}-${MAJOR}.dll - - # rm any old libs - rm -f ${CYGNAME}-${MAJOR}.dll - rm -f ${LIBNAME}-${MAJOR}.dll.a - rm -f ${LIBNAME}.dll.a - rm -f ${LIBNAME}.a - - # make lib - ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS} || exit $? - # make usual symlinks - ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a - # finish up - FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a" - # special case for installing in bin - FINAL_BINS="${CYGNAME}-${MAJOR}.dll" - fi - fi - ;; - - 'example') - # If you're adding support for a new architecture, you can - # start with this: - if [ $STATIC = 1 ] ; then - LIBNAME="lib${LIBNAME}.a" - echo "mklib: Making static library for example arch: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib rv 0 ${LIBNAME} ${OBJECTS}` - else - LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" - echo "mklib: Making shared library for example arch: " ${LIBNAME} - ld -o ${LIBNAME} ${OBJECTS} ${DEPS} - FINAL_LIBS="${LIBNAME}" - fi - ;; - - *) - echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH} - echo "mklib: Please add necessary commands to mklib script." - ;; -esac - - -# -# Put library files into installation directory if specified. -# -if [ ${INSTALLDIR} != "." ] ; then - echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR} - test -d ${INSTALLDIR} || mkdir -p ${INSTALLDIR} - mv ${FINAL_LIBS} ${INSTALLDIR}/ - - if [ "x${FINAL_BINS}" != "x" ] ; then - echo "mklib: Installing" ${FINAL_BINS} "in" ${INSTALLDIR} - mv ${FINAL_BINS} ${INSTALLDIR}/ - fi -fi +#!/bin/sh + +# Make a shared library. +# This script should be useful for projects other than Mesa. +# Improvements/fixes are welcome. + + +# Copyright (C) 1999-2006 Brian Paul 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 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 +# BRIAN PAUL 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. + + +# Clear CDPATH as the 'cd' command will echo stuff +# to stdout if it is set +unset CDPATH + +# Given a list of files, look for .a archives and unpack them. +# Return the original list of files minus the .a files plus the unpacked files. +# first param: name of a temp directory (to be deleted when finished) +# remaining params: list of .o and .a files +expand_archives() { + DIR=$1 + shift + FILES=$@ + NEWFILES="" + ORIG_DIR=`pwd` + mkdir -p "$DIR" + cd "$DIR" + for FILE in $FILES ; do + case $FILE in + *.a) + # extract the .o files from this .a archive + case $FILE in + /*) ;; + *) FILE="$ORIG_DIR/$FILE" ;; + esac + MEMBERS=`ar t $FILE` + ar x $FILE + for MEMBER in $MEMBERS ; do + NEWFILES="$NEWFILES $DIR/$MEMBER" + done + ;; + *) + # other file type, just add to list + NEWFILES="$NEWFILES $FILE" + ;; + esac + done + cd "$ORIG_DIR" + echo $NEWFILES +} + + +# Make static library with 'ar' +# params: +# options to ar +# 1 or 0 to indicate if ranlib should be run +# libname to make +# list of object files +# Return name of library we made +# Example: "make_ar_static_lib -ru 1 libfoo.a foo.o bar.o" +make_ar_static_lib() { + OPTS=$1 + shift; + RANLIB=$1 + shift; + LIBNAME=$1 + shift; + OBJECTS=$@ + + # remove existing lib, if present + rm -f ${LIBNAME} + + # make static lib + ar ${OPTS} ${LIBNAME} ${OBJECTS} + + # run ranlib + if [ ${RANLIB} = 1 ] ; then + ranlib ${LIBNAME} + fi + + echo ${LIBNAME} +} + + +# Print usage info. +usage() { + echo 'Usage: mklib [options] objects' + echo 'Create a shared library from object files.' + echo ' -o LIBRARY specifies the name of the resulting library, without' + echo ' the leading "lib" or any suffix.' + echo ' (eg: "-o GL" might result in "libGL.so" being made)' + echo ' -major N specifies major version number (default is 1)' + echo ' -minor N specifies minor version number (default is 0)' + echo ' -patch N specifies patch version number (default is 0)' + echo ' -lLIBRARY specifies a dependency on LIBRARY' + echo ' -LDIR search in DIR for library dependencies at build time' + echo ' -RDIR search in DIR for library dependencies at run time' + echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)' + echo ' Not observed on all systems at this time.' + echo ' -ldflags OPT specify any additional linker flags in OPT' + echo ' -cplusplus link with C++ runtime' + echo ' -static make a static library (default is dynamic/shared)' + echo ' -dlopen make a shared library suitable for dynamic loading' + echo ' -install DIR put resulting library file(s) in DIR' + echo ' -arch ARCH override using `uname` to determine host system' + echo ' -archopt OPT specify an extra achitecture-specific option OPT' + echo ' -altopts OPTS alternate options to override all others' + echo " -noprefix don't prefix library name with 'lib' nor add any suffix" + echo ' -exports FILE only export the symbols listed in FILE' + echo ' -id NAME Sets the id of the dylib (Darwin)' + echo ' -h, --help display this information and exit' +} + + +# +# Option defaults +# +LIBNAME="" +MAJOR=1 +MINOR=0 +PATCH="" +DEPS="" +LINK="" +LDFLAGS="" +CPLUSPLUS=0 +STATIC=0 +DLOPEN=0 +INSTALLDIR="." +ARCH="auto" +ARCHOPT="" +NOPREFIX=0 +EXPORTS="" +ID="" + +# +# Parse arguments +# +while true +do + case $1 in + '-h' | '--help') + usage + exit 1 + ;; + '-o') + shift 1; + LIBNAME=$1 + ;; + '-major') + shift 1; + MAJOR=$1 + ;; + '-minor') + shift 1; + MINOR=$1 + ;; + '-patch') + shift 1; + PATCH=$1 + ;; + '-linker') + shift 1; + LINK=$1 + ;; + '-ldflags') + shift 1; + LDFLAGS=$1 + ;; + -l*) + DEPS="$DEPS $1" + ;; + -L*) + DEPS="$DEPS $1" + ;; + -R*) + DEPS="$DEPS $1" + ;; + -Wl*) + DEPS="$DEPS $1" + ;; + -pthread) + # this is a special case (see bugzilla 10876) + DEPS="$DEPS $1" + ;; + '-pthread') + DEPS="$DEPS -pthread" + ;; + '-cplusplus') + CPLUSPLUS=1 + ;; + '-static') + STATIC=1 + ;; + '-dlopen') + DLOPEN=1 + ;; + '-install') + shift 1; + INSTALLDIR=$1 + ;; + '-arch') + shift 1; + ARCH=$1 + ;; + '-archopt') + shift 1; + ARCHOPT=$1 + ;; + '-altopts') + shift 1; + ALTOPTS=$1 + ;; + '-noprefix') + NOPREFIX=1 + ;; + '-exports') + shift 1; + EXPORTS=$1 + ;; + '-id') + shift 1; + ID=$1 + ;; + -*) + echo "mklib: Unknown option: " $1 ; + exit 1 + ;; + *) + # This should be the first object file, stop parsing + break + esac + shift 1 +done +OBJECTS=$@ + + +if [ ${ARCH} = "auto" ] ; then + ARCH=`uname` +fi + + +if [ $STATIC = 1 ]; then + # filter out linker options inside object list + NEWOBJECTS="" + for OBJ in $OBJECTS ; do + case $OBJ in + -Wl,*) + echo "mklib: warning: ignoring $OBJ for static library" + ;; + *) + NEWOBJECTS="$NEWOBJECTS $OBJ" + ;; + esac + done + OBJECTS=$NEWOBJECTS +fi + + +# +# Error checking +# +if [ "x${LIBNAME}" = "x" ] ; then + echo "mklib: Error: no library name specified (-h for help)" + exit 1 +fi +if [ "x${OBJECTS}" = "x" ] ; then + echo "mklib: Error: no object files specified (-h for help)" + exit 1 +fi + + +# +# Debugging info +# +if [ ] ; then + echo "-----------------" + echo ARCH is $ARCH + echo LIBNAME is $LIBNAME + echo MAJOR is $MAJOR + echo MINOR is $MINOR + echo PATCH is $PATCH + echo DEPS are $DEPS + echo "EXPORTS in" $EXPORTS + echo ID is $ID + echo "-----------------" +fi + + +# +# OK, make the library now +# +case $ARCH in + + 'Linux' | 'OpenBSD' | 'DragonFly' | 'GNU' | GNU/* | 'NetBSD') + # we assume gcc + + if [ "x$LINK" = "x" ] ; then + # -linker was not specified so set default link command now + if [ $CPLUSPLUS = 1 ] ; then + LINK=g++ + else + LINK=gcc + fi + fi + + if [ $NOPREFIX = 1 ] ; then + # No "lib" or ".so" part + echo "mklib: Making" $ARCH "shared library: " ${LIBNAME} + case $ARCH in 'Linux' | 'GNU' | GNU/*) + OPTS="-Xlinker -Bsymbolic -shared" + ;; + *) + OPTS="-shared" + ;; + esac + + # Check if objects are 32-bit and we're running in 64-bit + # environment. If so, pass -m32 flag to linker. + set ${OBJECTS} + ABI32=`file $1 | grep 32-bit` + if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then + OPTS="-m32 ${OPTS}" + fi + + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + + rm -f ${LIBNAME} + # make lib + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} + # finish up + FINAL_LIBS="${LIBNAME}" + elif [ $STATIC = 1 ] ; then + # make a static .a library + LIBNAME="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a" + echo "mklib: Making" $ARCH "static library: " ${LIBNAME} + OPTS="-ru" + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + + # expand .a into .o files + NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS` + + # make static lib + FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}` + + # remove temporary extracted .o files + rm -rf ${LIBNAME}.obj + else + # make dynamic library + LIBNAME="lib${LIBNAME}" # prefix with "lib" + case $ARCH in 'Linux' | 'GNU' | GNU/*) + OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" + ;; + *) + OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" + ;; + esac + if [ $EXPORTS ] ; then + #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}" + # Make the 'exptmp' file for --version-script option + echo "{" > exptmp + echo "global:" >> exptmp + sed 's/$/;/' ${EXPORTS} >> exptmp + echo "local:" >> exptmp + echo "*;" >> exptmp + echo "};" >> exptmp + OPTS="${OPTS} -Xlinker --version-script=exptmp" + # exptmp is removed below + fi + + # Check if objects are 32-bit and we're running in 64-bit + # environment. If so, pass -m32 flag to linker. + set ${OBJECTS} + ABI32=`file $1 | grep 32-bit` + if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then + OPTS="-m32 ${OPTS}" + fi + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + + if [ x${PATCH} = "x" ] ; then + VERSION="${MAJOR}.${MINOR}" + else + VERSION="${MAJOR}.${MINOR}.${PATCH}" + fi + + echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION} + + # rm any old libs + rm -f ${LIBNAME}.so.${VERSION} + rm -f ${LIBNAME}.so.${MAJOR} + rm -f ${LIBNAME}.so + + # make lib + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} + # make usual symlinks + ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} + ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so + # finish up + FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" +# rm -f exptmp + fi + ;; + + 'SunOS') + if [ $STATIC = 1 ] ; then + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making SunOS static library: " ${LIBNAME} + FINAL_LIBS=`make_ar_static_lib -ruc 0 ${LIBNAME} ${OBJECTS}` + else + if [ $NOPREFIX = 0 ] ; then + LIBNAME="lib${LIBNAME}.so" + fi + echo "mklib: Making SunOS shared library: " ${LIBNAME} + + if [ "x$LINK" = "x" ] ; then + # -linker was not specified, choose default linker now + if [ $CPLUSPLUS = 1 ] ; then + # determine linker and options for C++ code + if [ `which c++` ] ; then + # use Sun c++ + LINK="c++" + elif [ `type g++` ] ; then + # use g++ + LINK="g++" + else + echo "mklib: warning: can't find C++ compiler, trying CC." + LINK="CC" + fi + else + # use native Sun linker for C code + LINK="ld" + fi + fi + + # linker options + if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then + # SunOS tools, -G to make shared libs + OPTS="-G" + else + # gcc linker + # Check if objects are 32-bit and we're running in 64-bit + # environment. If so, pass -m32 flag to linker. + set ${OBJECTS} + ABI32=`file $1 | grep 32-bit` + if [ "${ABI32}" ] ; then + OPTS="-m32 -shared -Wl,-Bdynamic" + else + OPTS="-m64 -shared -Wl,-Bdynamic" + fi + fi + + # If using Sun C++ compiler, need to tell it not to add runpaths + # that are specific to the build machine + if [ ${LINK} = "CC" ] ; then + OPTS="${OPTS} -norunpath" + fi + + # Solaris linker requires explicitly listing the Standard C & C++ + # libraries in the link path when building shared objects + if [ ${LINK} = "CC" ] ; then + DEPS="${DEPS} -lCrun" + fi + DEPS="${DEPS} -lc" + + if [ $EXPORTS ] ; then + # Make the 'mapfile.scope' linker mapfile + echo "{" > mapfile.scope + echo "global:" >> mapfile.scope + sed 's/$/;/' ${EXPORTS} >> mapfile.scope + echo "local:" >> mapfile.scope + echo " *;" >> mapfile.scope + echo "};" >> mapfile.scope + OPTS="${OPTS} -Wl,-Mmapfile.scope" + fi + + # Check if objects are 64-bit + # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1 + set ${OBJECTS} + if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then + ABI64=`file $1 | grep "ELF 64-bit"` + if [ "${ABI64}" ] ; then + case `uname -p` in + sparc) OPTS="${OPTS} -xarch=v9" ;; + i386) OPTS="${OPTS} -xarch=amd64" ;; + esac + fi + fi + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + + # for debug: + #echo "mklib: linker is" ${LINK} ${OPTS} + if [ $NOPREFIX = 1 ] ; then + rm -f ${LIBNAME} + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} + FINAL_LIBS="${LIBNAME}" + else + rm -f ${LIBNAME}.${MAJOR} ${LIBNAME} + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS} + ln -s ${LIBNAME}.${MAJOR} ${LIBNAME} + FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}" + fi + fi + ;; + + 'FreeBSD') + # we assume gcc + + if [ "x$LINK" = "x" ] ; then + # -linker was not specified so set default link command now + if [ $CPLUSPLUS = 1 ] ; then + LINK=g++ + else + LINK=gcc + fi + fi + + if [ $NOPREFIX = 1 ] ; then + # No "lib" or ".so" part + echo "mklib: Making FreeBSD shared library: " ${LIBNAME} + OPTS="-shared" + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + rm -f ${LIBNAME} + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} + FINAL_LIBS=${LIBNAME} + elif [ $STATIC = 1 ] ; then + # make a static .a library + STLIB="lib${LIBNAME}.a" + echo "mklib: Making FreeBSD static library: " ${STLIB} + + # expand .a into .o files + NEW_OBJECTS=`expand_archives ${STLIB}.obj $OBJECTS` + + FINAL_LIBS=`make_ar_static_lib cq 1 ${STLIB} ${NEW_OBJECTS}` + + # remove temporary extracted .o files + rm -rf ${STLIB}.obj + else + # make dynamic library + SHLIB="lib${LIBNAME}.so.${MAJOR}" + OPTS="-shared -Wl,-soname,${SHLIB}" + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + echo "mklib: Making FreeBSD shared library: " ${SHLIB} + rm -f ${SHLIB} + ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS} + ln -sf ${SHLIB} "lib${LIBNAME}.so" + FINAL_LIBS="${SHLIB} lib${LIBNAME}.so" + fi + ;; + + 'IRIX' | 'IRIX64') + if [ $STATIC = 1 ] ; then + LIBNAME="lib${LIBNAME}.a" + FINAL_LIBS=`make_ar_static_lib rc 0 ${LIBNAME} ${OBJECTS}` + else + LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" + + # examine first object to determine ABI + set ${OBJECTS} + ABI_O32=`file $1 | grep 'ELF 32-bit'` + ABI_N32=`file $1 | grep 'ELF N32'` + ABI_N64=`file $1 | grep 'ELF 64-bit'` + if [ "${ABI_O32}" ] ; then + OPTS="-32 -shared -all" + ABI="o32-bit" + elif [ "${ABI_N32}" ] ; then + OPTS="-n32 -shared -all" + ABI="n32-bit" + elif [ "${ABI_N64}" ] ; then + OPTS="-64 -shared -all" + ABI="64-bit" + else + echo "Error: Unexpected IRIX ABI!" + exit 1 + fi + + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + + if [ $CPLUSPLUS = 1 ] ; then + LINK="CC" + else + LINK="ld" + fi + + echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME} + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} + FINAL_LIBS=${LIBNAME} + fi + ;; + + 'linux-cygwin') + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making linux-cygwin library: " ${LIBNAME} + rm -f ${LIBNAME} + gnuwin32ar ruv ${LIBNAME} ${OBJECTS} + FINAL_LIBS=${LIBNAME} + ;; + + 'HP-UX') + if [ $STATIC = 1 ] ; then + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making HP-UX static library: " ${LIBNAME} + FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}` + else + # HP uses a .2 for their current GL/GLU libraries + if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then + MAJOR=2 + fi + RUNLIB="lib${LIBNAME}.${MAJOR}" + DEVLIB="lib${LIBNAME}.sl" + echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB} + ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS} + ln -s ${RUNLIB} ${DEVLIB} + FINAL_LIBS="${RUNLIB} ${DEVLIB}" + fi + ;; + + 'AIX' ) + # examine first object to determine ABI + set ${OBJECTS} + ABI_64=`file $1 | grep '64-bit'` + if [ "${ABI_64}" ] ; then + X64="-X64" + Q64="-q64" + OFILE=shr_64.o + else + OFILE=shr.o #Want to be consistent with the IBM libGL.a + fi + + if [ $STATIC = 1 ] ; then + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making AIX static library: " ${LIBNAME} + FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}` + else + EXPFILE="lib${LIBNAME}.exp" + LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries + OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}" + rm -f ${EXPFILE} ${OFILE} + NM="/bin/nm -eC ${X64}" + echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE} + ${NM} ${OBJECTS} | awk '{ + if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \ + && ( substr($1,1,1) != ".")) { + if (substr ($1, 1, 7) != "__sinit" && + substr ($1, 1, 7) != "__sterm") { + if (substr ($1, 1, 5) == "__tf1") + print (substr ($1, 7)) + else if (substr ($1, 1, 5) == "__tf9") + print (substr ($1, 15)) + else + print $1 + } + } + }' | sort -u >> ${EXPFILE} + + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + + # On AIX a shared library is linked differently when + # you want to dlopen the file + if [ $DLOPEN = "1" ] ; then + cc -G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} + else + cc ${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS} + ar ${X64} -r ${LIBNAME} ${OFILE} + fi + + FINAL_LIBS="${LIBNAME}" + fi + ;; + + 'OpenSTEP') + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making OpenSTEP static library: " ${LIBNAME} + libtool -static -o ${LIBNAME} - ${OBJECTS} + FINAL_LIBS=${LIBNAME} + ;; + + 'OSF1') + if [ $STATIC = 1 ] ; then + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making OSF/1 static library: " ${LIBNAME} + FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}` + else + VERSION="${MAJOR}.${MINOR}" + LIBNAME="lib${LIBNAME}.so" + echo "mklib: Making OSF/1 shared library: " ${LIBNAME} + if [ "x$LINK" = "x" ] ; then + if [ $CPLUSPLUS = 1 ] ; then + LINK=cxx + else + LINK=cc + fi + fi + rm -f ${LIBNAME}.${VERSION} + ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS} + ln -sf ${LIBNAME}.${VERSION} ${LIBNAME} + FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}" + fi + ;; + + 'Darwin') + if [ $STATIC = 1 ] ; then + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making Darwin static library: " ${LIBNAME} + OPTS="-ruvs" + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + + # expand .a into .o files + NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS` + + # make static lib + FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}` + + # remove temporary extracted .o files + rm -rf ${LIBNAME}.obj + + FINAL_LIBS=${LIBNAME} + else + # On Darwin a .bundle is used for a library that you want to dlopen + if [ $DLOPEN = "1" ] ; then + LIBSUFFIX="bundle" + OPTS="${ARCHOPT} -bundle -multiply_defined suppress" + else + LIBSUFFIX="dylib" + if [ -z "$ID" ] ; then + ID="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}" + fi + OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}" + fi + + if [ ${EXPORTS} ] ; then + if [ -f ${EXPORTS}".darwin" ] ; then + EXPORTS=$EXPORTS".darwin" + fi + OPTS="${OPTS} -exported_symbols_list ${EXPORTS}" + fi + + LINKNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}" + LINKNAME2="lib${LIBNAME}.${LIBSUFFIX}" + LIBNAME="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}" + + # examine first object to determine ABI + set ${OBJECTS} + ABIS=`lipo -info $1 | sed s/.*://` + for ABI in $ABIS; do + OPTS="${OPTS} -arch ${ABI}" + done + + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + + # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk + # to OPTS here? + + # determine linker + if [ $CPLUSPLUS = 1 ] ; then + LINK="g++" + else + LINK="cc" + fi + + echo "mklib: Making Darwin shared library: " ${LIBNAME} + + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} + ln -s ${LIBNAME} ${LINKNAME} + ln -s ${LIBNAME} ${LINKNAME2} + FINAL_LIBS="${LIBNAME} ${LINKNAME} ${LINKNAME2}" + fi + ;; + + 'LynxOS') + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making LynxOS static library: " ${LIBNAME} + FINAL_LIBS=`make_ar_static_lib -ru 0 ${LIBNAME} ${OBJECTS}` + ;; + + 'BeOS') + if [ $STATIC = 1 ] ; then + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making BeOS static library: " ${LIBNAME} + FINAL_LIBS=`make_ar_static_lib -cru 0 ${LIBNAME} ${OBJECTS}` + else + LIBNAME="lib${LIBNAME}.so" + echo "mklib: Making BeOS shared library: " ${LIBNAME} + gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}" + mimeset -f "${LIBNAME}" + # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific. + setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!" + fi + FINAL_LIBS=${LIBNAME} + ;; + + 'QNX') + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making QNX library: " ${LIBNAME} + wlib ${LIBNAME} ${OBJECTS} + FINAL_LIBS=${LIBNAME} + ;; + + 'MorphOS') + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making MorphOS library: " ${LIBNAME} + ppc-morphos-ar rc ${LIBNAME} ${OBJECTS} + FINAL_LIBS="${LIBNAME}" + ;; + + 'icc' | 'icc-istatic') + # Intel C compiler + # This should get merged into the Linux code, above, since this isn't + # really a different architecture. + LIBNAME="lib${LIBNAME}" # prefix with "lib" + + if [ $STATIC = 1 ] ; then + echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a + LINK="ar" + OPTS="-ruv" + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + # make lib + ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} + # finish up + FINAL_LIBS="${LIBNAME}.a" + else + if [ $ARCH = icc-istatic ] ; then + OPTS="-shared -i-static -cxxlib-icc" + else + OPTS="-shared" + fi + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + VERSION="${MAJOR}.${MINOR}.${PATCH}" + echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION} + + if [ $CPLUSPLUS = 1 ] ; then + LINK="icpc" + else + LINK="icc" + fi + # rm any old libs + rm -f ${LIBNAME}.so.${VERSION} + rm -f ${LIBNAME}.so.${MAJOR} + rm -f ${LIBNAME}.so + # make lib + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} + # make usual symlinks + ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} + ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so + # finish up + FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" + fi + ;; + + 'aix-gcc') + # AIX with gcc + if [ $STATIC = 1 ] ; then + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making AIX GCC static library: " ${LIBNAME} + FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}` + else + LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" + echo "mklib: Making AIX GCC shared library: " ${LIBNAME} + # remove old lib + rm -f ${LIBNAME} + # make the lib + gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME} + # NOTE: the application linking with this library must specify + # the -Wl,-brtl flags to gcc + FINAL_LIBS=${LIBNAME} + fi + ;; + + 'ultrix') + # XXX untested + if [ $STATIC = 0 ] ; then + echo "mklib: Warning shared libs not supported on Ultrix" + fi + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making static library for Ultrix: " ${LIBNAME} + FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}` + ;; + + CYGWIN*) + # GCC-based environment + + if [ "x$LINK" = "x" ] ; then + # -linker was not specified so set default link command now + if [ $CPLUSPLUS = 1 ] ; then + LINK=g++ + else + LINK=gcc + fi + fi + + if [ $NOPREFIX = 1 ] ; then + # No "lib" or ".so" part + echo "mklib: Making CYGWIN shared library: " ${LIBNAME} + OPTS="-shared -Wl,--enable-auto-image-base" + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + rm -f ${LIBNAME} + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} || exit $? + FINAL_LIBS=${LIBNAME} + else + CYGNAME="cyg${LIBNAME}" # prefix with "cyg" + LIBNAME="lib${LIBNAME}" # prefix with "lib" + + if [ $STATIC = 1 ] ; then + LIBNAME=${LIBNAME}.a + echo "mklib: Making CYGWIN static library: " ${LIBNAME} + OPTS="-ru" + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + + # expand .a into .o files + NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS` + + FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}` + + # remove temporary extracted .o files + rm -rf ${LIBNAME}.obj + else + OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a" + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + echo "mklib: Making CYGWIN shared library: " ${CYGNAME}-${MAJOR}.dll + + # rm any old libs + rm -f ${CYGNAME}-${MAJOR}.dll + rm -f ${LIBNAME}-${MAJOR}.dll.a + rm -f ${LIBNAME}.dll.a + rm -f ${LIBNAME}.a + + # make lib + ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS} || exit $? + # make usual symlinks + ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a + # finish up + FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a" + # special case for installing in bin + FINAL_BINS="${CYGNAME}-${MAJOR}.dll" + fi + fi + ;; + + 'example') + # If you're adding support for a new architecture, you can + # start with this: + if [ $STATIC = 1 ] ; then + LIBNAME="lib${LIBNAME}.a" + echo "mklib: Making static library for example arch: " ${LIBNAME} + FINAL_LIBS=`make_ar_static_lib rv 0 ${LIBNAME} ${OBJECTS}` + else + LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" + echo "mklib: Making shared library for example arch: " ${LIBNAME} + ld -o ${LIBNAME} ${OBJECTS} ${DEPS} + FINAL_LIBS="${LIBNAME}" + fi + ;; + + *) + echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH} + echo "mklib: Please add necessary commands to mklib script." + ;; +esac + + +# +# Put library files into installation directory if specified. +# +if [ ${INSTALLDIR} != "." ] ; then + echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR} + test -d ${INSTALLDIR} || mkdir -p ${INSTALLDIR} + mv ${FINAL_LIBS} ${INSTALLDIR}/ + + if [ "x${FINAL_BINS}" != "x" ] ; then + echo "mklib: Installing" ${FINAL_BINS} "in" ${INSTALLDIR} + mv ${FINAL_BINS} ${INSTALLDIR}/ + fi +fi diff --git a/mesalib/configs/default b/mesalib/configs/default index b4532f931..1758d7a49 100644 --- a/mesalib/configs/default +++ b/mesalib/configs/default @@ -9,7 +9,7 @@ CONFIG_NAME = default # Version info MESA_MAJOR=7 -MESA_MINOR=10 +MESA_MINOR=11 MESA_TINY=0 MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY) diff --git a/mesalib/configure.ac b/mesalib/configure.ac index f0794330e..b12da45cf 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -377,14 +377,14 @@ if test "x$enable_asm" = xyes; then case "$host_cpu" in i?86) case "$host_os" in - linux* | *freebsd* | dragonfly*) + linux* | *freebsd* | dragonfly* | *netbsd*) test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86 ;; esac ;; x86_64) case "$host_os" in - linux* | *freebsd* | dragonfly*) + linux* | *freebsd* | dragonfly* | *netbsd*) test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64 ;; esac @@ -542,7 +542,7 @@ linux*) i*86|x86_64|powerpc*|sparc*) default_driver="dri";; esac ;; -*freebsd* | dragonfly*) +*freebsd* | dragonfly* | *netbsd*) case "$host_cpu" in i*86|x86_64|powerpc*|sparc*) default_driver="dri";; esac @@ -909,16 +909,13 @@ if test "$mesa_driver" = dri -o "$mesa_driver" = no; then ;; esac ;; - freebsd* | dragonfly*) + freebsd* | dragonfly* | *netbsd*) DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1" DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS" DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING" if test "x$driglx_direct" = xyes; then DEFINES="$DEFINES -DGLX_DIRECT_RENDERING" fi - if test "x$GXX" = xyes; then - CXXFLAGS="$CXXFLAGS -ansi -pedantic" - fi if test "x$DRI_DIRS" = "xyes"; then DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon tdfx \ @@ -972,7 +969,7 @@ AC_SUBST([DRI_LIB_DEPS]) case $DRI_DIRS in *i915*|*i965*) - PKG_CHECK_MODULES([INTEL], [libdrm_intel >= 2.4.21]) + PKG_CHECK_MODULES([INTEL], [libdrm_intel >= 2.4.23]) ;; esac @@ -1352,7 +1349,7 @@ if test "x$enable_gallium_egl" = xauto; then enable_gallium_egl=$enable_egl ;; *) - enable_gallium_egl=no + enable_gallium_egl=$enable_openvg ;; esac fi @@ -1467,10 +1464,6 @@ AC_SUBST([EGL_CLIENT_APIS]) if test "x$HAVE_ST_EGL" = xyes; then GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl" - # define GLX_DIRECT_RENDERING even when the driver is not dri - if test "x$mesa_driver" != xdri -a "x$driglx_direct" = xyes; then - DEFINES="$DEFINES -DGLX_DIRECT_RENDERING" - fi fi if test "x$HAVE_ST_XORG" = xyes; then @@ -1690,7 +1683,7 @@ AC_ARG_ENABLE([gallium-nouveau], [enable_gallium_nouveau="$enableval"], [enable_gallium_nouveau=no]) if test "x$enable_gallium_nouveau" = xyes; then - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50" + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50 nvc0" gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau" fi diff --git a/mesalib/docs/egl.html b/mesalib/docs/egl.html index 28ade1567..fe3fe4b77 100644 --- a/mesalib/docs/egl.html +++ b/mesalib/docs/egl.html @@ -134,6 +134,16 @@ colon-separated directories where the main library will look for drivers, in addition to the default directory. This variable is ignored for setuid/setgid binaries.

+

This variable is usually set to test an uninstalled build. For example, one +may set

+ +
+  $ export LD_LIBRARY_PATH=$mesa/lib
+  $ export EGL_DRIVERS_PATH=$mesa/lib/egl
+
+ +

to test a build without installation

+
  • EGL_DRIVER diff --git a/mesalib/docs/relnotes-7.10.html b/mesalib/docs/relnotes-7.10.html index 872ce4730..bb73975b7 100644 --- a/mesalib/docs/relnotes-7.10.html +++ b/mesalib/docs/relnotes-7.10.html @@ -1,14 +1,16 @@ + Mesa Release Notes - - + + + -

    Mesa 7.10 Release Notes / tbd

    +

    Mesa 7.10 Release Notes / January 7, 2011

    Mesa 7.10 is a new development release. @@ -28,7 +30,12 @@ for DRI hardware acceleration.

    MD5 checksums

    -tbd
    +0a70c15c135561824bdcae92bf232e43  MesaLib-7.10.tar.gz
    +33fb94eccc02cbb4d8d1365615e38e46  MesaLib-7.10.tar.bz2
    +5cafdc0eda0f9bf370b95c98df3338fa  MesaLib-7.10.zip
    +bc644be551ed585fc4f66c16b64a91c9  MesaGLUT-7.10.tar.gz
    +5c2677a155672352d62b177e4f0f92e8  MesaGLUT-7.10.tar.bz2
    +2ce5001f74496d1ba719ef74d910a5cf  MesaGLUT-7.10.zip
     
    @@ -38,19 +45,2751 @@ tbd
  • GL_ARB_texture_rg (Intel, software drivers, gallium drivers).
  • GL_EXT_separate_shader_objects extension (Intel and software drivers).
  • GL_NV_primitive_restart extension (Gallium softpipe, llvmpipe). +
  • New fragment shader back-end for i965-class hardware. +
  • Support for Sandybridge chipset in i965 DRI driver.

    Bug fixes

    +

    This list is likely incomplete.

    Changes

    +

    Adam Jackson (2):

    +
  • i965: Update renderer strings for sandybridge
  • +
  • drivers/x11: unifdef XFree86Server
  • +

    + +

    Alex Deucher (30): +

    + +

    Andre Maasikas (3): +

    + +

    Andrew Randrianasulu (2): +

    + +

    Aras Pranckevicius (2): +

    + +

    Bas Nieuwenhuizen (3): +

    + +

    Ben Skeggs (3): +

    + +

    Benjamin Franzke (2): +

    + +

    Brian Paul (296): +

    + +

    Brian Rogers (1): +

    + +

    Chad Versace (25): +

    + +

    Chia-I Wu (149): +

    + +

    Chris Wilson (2): +

    + +

    Christoph Bumiller (80): +

    + +

    Corbin Simpson (8): +

    + +

    Daniel Lichtenberger (1): +

    + +

    Daniel Vetter (21): +

    + +

    Dave Airlie (182): +

    + +

    Eric Anholt (300): +

    + +

    Fabian Bieler (2): +

    + +

    Francisco Jerez (51): +

    + +

    Fredrik Höglund (2): +

    + +

    Guillermo S. Romero (1): +

    + +

    Henri Verbeet (19): +

    + +

    Hui Qi Tay (10): +

    + +

    Ian Romanick (102): +

    + +

    Jakob Bornecrantz (27): +

    + +

    Jerome Glisse (75): +

    + +

    Joakim Sindholt (3): +

    + +

    Johann Rudloff (3): +

    + +

    John Doe (3): +

    + +

    Jon TURNEY (1): +

    + +

    José Fonseca (128): +

    + +

    Julien Cristau (1): +

    + +

    Keith Whitwell (89): +

    + +

    Kenneth Graunke (94): +

    + +

    Kristian Høgsberg (16): +

    + +

    Krzysztof Smiechowicz (1): +

    + +

    Luca Barbieri (84): +

    + +

    Lucas Stach (1): +

    + +

    Marek Olšák (100): +

    + +

    Mario Kleiner (1): +

    + +

    Mathias Fröhlich (3): +

    + +

    Michal Krol (10): +

    + +

    Nicolas Kaiser (26): +

    + +

    Orion Poplawski (1): +

    + +

    Owen W. Taylor (1): +

    + +

    Peter Clifton (3): +

    + +

    Robert Hooker (2): +

    + +

    Roland Scheidegger (16): +

    + +

    Shuang He (1): +

    + +

    Stephan Schmid (1): +

    + +

    Thomas Hellstrom (21): +

    + +

    Tilman Sauerbeck (35): +

    + +

    Timo Wiren (1): +

    + +

    Tom Fogal (3): +

    + +

    Tom Stellard (32): +

    + +

    Victor Tseng (1): +

    + +

    Viktor Novotný (6): +

    + +

    Vinson Lee (214): +

    + +

    Xavier Chantry (8): +

    + +

    Xiang, Haihao (10): +

    + +

    Zack Rusin (8): +

    + +

    Zhenyu Wang (40): +

    + +

    Zou Nan hai (1): +

    + +

    delphi (2): +

    + +

    nobled (3): +

    + +

    pontus lidman (1): +

    + +

    richard (2): +

    diff --git a/mesalib/docs/relnotes-7.9.1.html b/mesalib/docs/relnotes-7.9.1.html new file mode 100644 index 000000000..c12db4a50 --- /dev/null +++ b/mesalib/docs/relnotes-7.9.1.html @@ -0,0 +1,406 @@ + + + +Mesa Release Notes + + + + + + + + +

    Mesa 7.9.1 Release Notes / January 7, 2011

    + +

    +Mesa 7.9.1 is a bug fix release which fixes bugs found since the 7.9 release. +

    +

    +Mesa 7.9.1 implements the OpenGL 2.1 API, but the version reported by +glGetString(GL_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 2.1. +

    +

    +See the Compiling/Installing page for prerequisites +for DRI hardware acceleration. +

    + + +

    MD5 checksums

    +
    +78422843ea875ad4eac35b9b8584032b  MesaLib-7.9.1.tar.gz
    +07dc6cfb5928840b8b9df5bd1b3ae434  MesaLib-7.9.1.tar.bz2
    +c8eaea5b3c3d6dee784bd8c2db91c80f  MesaLib-7.9.1.zip
    +ee9ecae4ca56fbb2d14dc15e3a0a7640  MesaGLUT-7.9.1.tar.gz
    +41fc477d524e7dc5c84da8ef22422bea  MesaGLUT-7.9.1.tar.bz2
    +90b287229afdf19317aa989d19462e7a  MesaGLUT-7.9.1.zip
    +
    + + +

    New features

    +

    None.

    + +

    Bug fixes

    +

    This list is likely incomplete.

    + + + +

    Changes

    +

    The full set of changes can be viewed by using the following GIT command:

    + +
    +  git log mesa-7.9..mesa-7.9.1
    +
    + +

    Alex Deucher (5): +

    + +

    Aras Pranckevicius (2): +

    + +

    Brian Paul (27): +

    + +

    Chad Versace (5): +

    + +

    Chia-I Wu (10): +

    + +

    Daniel Lichtenberger (1): +

    + +

    Daniel Vetter (1): +

    + +

    Dave Airlie (1): +

    + +

    Eric Anholt (13): +

    + +

    Fabian Bieler (1): +

    + +

    Francisco Jerez (3): +

    + +

    Henri Verbeet (2): +

    + +

    Ian Romanick (33): +

    + +

    Julien Cristau (1): +

    + +

    Kenneth Graunke (19): +

    + +

    Kristian Høgsberg (1): +

    + +

    Luca Barbieri (1): +

    + +

    Marek Olšák (17): +

    + +

    Mario Kleiner (1): +

    + +

    Peter Clifton (1): +

    + +

    Robert Hooker (2): +

    + +

    Roland Scheidegger (1): +

    + +

    Thomas Hellstrom (17): +

    + +

    Tom Stellard (7): +

    + +

    Vinson Lee (1): +

    + +

    richard (1): +

    + + + diff --git a/mesalib/include/GL/glext.h b/mesalib/include/GL/glext.h index 2e2c0d612..3166ed047 100644 --- a/mesalib/include/GL/glext.h +++ b/mesalib/include/GL/glext.h @@ -29,9 +29,9 @@ extern "C" { */ /* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated $Date: 2010-11-03 18:59:30 -0700 (Wed, 03 Nov 2010) $ */ +/* glext.h last updated $Date: 2010-12-09 02:15:08 -0800 (Thu, 09 Dec 2010) $ */ /* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 66 +#define GL_GLEXT_VERSION 67 /* Function declaration macros - to move into glplatform.h */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -5026,6 +5026,12 @@ extern "C" { #define GL_DEPTH_CLAMP_FAR_AMD 0x901F #endif +#ifndef GL_EXT_texture_sRGB_decode +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif + /*************************************************************/ @@ -11031,6 +11037,10 @@ typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, cons #define GL_AMD_depth_clamp_separate 1 #endif +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#endif + #ifdef __cplusplus } diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h index 5e9c045bf..e414ac8b5 100644 --- a/mesalib/src/glsl/ast.h +++ b/mesalib/src/glsl/ast.h @@ -349,7 +349,11 @@ struct ast_type_qualifier { * qualifier is used. */ unsigned explicit_location:1; - } q; + } + /** \brief Set of flags, accessed by name. */ + q; + + /** \brief Set of flags, accessed as a bitmask. */ unsigned i; } flags; diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp index 282bc3ff5..e6ec81ed9 100644 --- a/mesalib/src/glsl/ast_to_hir.cpp +++ b/mesalib/src/glsl/ast_to_hir.cpp @@ -60,7 +60,7 @@ void _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) { _mesa_glsl_initialize_variables(instructions, state); - _mesa_glsl_initialize_functions(instructions, state); + _mesa_glsl_initialize_functions(state); state->symbols->language_version = state->language_version; @@ -1564,18 +1564,38 @@ ast_expression::hir(exec_list *instructions, } } - /* From section 4.1.7 of the GLSL 1.30 spec: + /* From page 23 (29 of the PDF) of the GLSL 1.30 spec: + * * "Samplers aggregated into arrays within a shader (using square * brackets [ ]) can only be indexed with integral constant * expressions [...]." + * + * This restriction was added in GLSL 1.30. Shaders using earlier version + * of the language should not be rejected by the compiler front-end for + * using this construct. This allows useful things such as using a loop + * counter as the index to an array of samplers. If the loop in unrolled, + * the code should compile correctly. Instead, emit a warning. */ if (array->type->is_array() && array->type->element_type()->is_sampler() && const_index == NULL) { - _mesa_glsl_error(&loc, state, "sampler arrays can only be indexed " - "with constant expressions"); - error_emitted = true; + if (state->language_version == 100) { + _mesa_glsl_warning(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is optional in GLSL ES 1.00"); + } else if (state->language_version < 130) { + _mesa_glsl_warning(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is forbidden in GLSL 1.30 and " + "later"); + } else { + _mesa_glsl_error(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is forbidden in GLSL 1.30 and " + "later"); + error_emitted = true; + } } if (error_emitted) @@ -1832,6 +1852,23 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, else if (qual->flags.q.uniform) var->mode = ir_var_uniform; + if (state->all_invariant && (state->current_function == NULL)) { + switch (state->target) { + case vertex_shader: + if (var->mode == ir_var_out) + var->invariant = true; + break; + case geometry_shader: + if ((var->mode == ir_var_in) || (var->mode == ir_var_out)) + var->invariant = true; + break; + case fragment_shader: + if (var->mode == ir_var_in) + var->invariant = true; + break; + } + } + if (qual->flags.q.flat) var->interpolation = ir_var_flat; else if (qual->flags.q.noperspective) @@ -2158,6 +2195,25 @@ ast_declarator_list::hir(exec_list *instructions, } } + /* Integer vertex outputs must be qualified with 'flat'. + * + * From section 4.3.6 of the GLSL 1.30 spec: + * "If a vertex output is a signed or unsigned integer or integer + * vector, then it must be qualified with the interpolation qualifier + * flat." + */ + if (state->language_version >= 130 + && state->target == vertex_shader + && state->current_function == NULL + && var->type->is_integer() + && var->mode == ir_var_out + && var->interpolation != ir_var_flat) { + + _mesa_glsl_error(&loc, state, "If a vertex output is an integer, " + "then it must be qualified with 'flat'"); + } + + /* Process the initializer and add its instructions to a temporary * list. This list will be added to the instruction stream (below) after * the declaration is added. This is done because in some cases (such as @@ -2344,6 +2400,27 @@ ast_declarator_list::hir(exec_list *instructions, */ earlier->origin_upper_left = var->origin_upper_left; earlier->pixel_center_integer = var->pixel_center_integer; + + /* According to section 4.3.7 of the GLSL 1.30 spec, + * the following built-in varaibles can be redeclared with an + * interpolation qualifier: + * * gl_FrontColor + * * gl_BackColor + * * gl_FrontSecondaryColor + * * gl_BackSecondaryColor + * * gl_Color + * * gl_SecondaryColor + */ + } else if (state->language_version >= 130 + && (strcmp(var->name, "gl_FrontColor") == 0 + || strcmp(var->name, "gl_BackColor") == 0 + || strcmp(var->name, "gl_FrontSecondaryColor") == 0 + || strcmp(var->name, "gl_BackSecondaryColor") == 0 + || strcmp(var->name, "gl_Color") == 0 + || strcmp(var->name, "gl_SecondaryColor") == 0) + && earlier->type == var->type + && earlier->mode == var->mode) { + earlier->interpolation = var->interpolation; } else { YYLTYPE loc = this->get_location(); _mesa_glsl_error(&loc, state, "`%s' redeclared", decl->identifier); diff --git a/mesalib/src/glsl/autogen.sh b/mesalib/src/glsl/autogen.sh new file mode 100644 index 000000000..6fcae015c --- /dev/null +++ b/mesalib/src/glsl/autogen.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd $srcdir + +autoreconf -v --install || exit 1 +cd $ORIGDIR || exit $? + +$srcdir/configure --enable-maintainer-mode "$@" diff --git a/mesalib/src/glsl/builtin_function.cpp b/mesalib/src/glsl/builtin_function.cpp index f3effe074..6a0ddbcb8 100644 --- a/mesalib/src/glsl/builtin_function.cpp +++ b/mesalib/src/glsl/builtin_function.cpp @@ -13523,7 +13523,6 @@ _mesa_glsl_release_functions(void) static void _mesa_read_profile(struct _mesa_glsl_parse_state *state, - exec_list *instructions, int profile_index, const char *prototypes, const char **functions, @@ -13542,8 +13541,7 @@ _mesa_read_profile(struct _mesa_glsl_parse_state *state, } void -_mesa_glsl_initialize_functions(exec_list *instructions, - struct _mesa_glsl_parse_state *state) +_mesa_glsl_initialize_functions(struct _mesa_glsl_parse_state *state) { if (builtin_mem_ctx == NULL) { builtin_mem_ctx = talloc_init("GLSL built-in functions"); @@ -13553,84 +13551,84 @@ _mesa_glsl_initialize_functions(exec_list *instructions, state->num_builtins_to_link = 0; if (state->target == fragment_shader && state->language_version == 100) { - _mesa_read_profile(state, instructions, 0, + _mesa_read_profile(state, 0, prototypes_for_100_frag, functions_for_100_frag, Elements(functions_for_100_frag)); } if (state->target == vertex_shader && state->language_version == 100) { - _mesa_read_profile(state, instructions, 1, + _mesa_read_profile(state, 1, prototypes_for_100_vert, functions_for_100_vert, Elements(functions_for_100_vert)); } if (state->target == fragment_shader && state->language_version == 110) { - _mesa_read_profile(state, instructions, 2, + _mesa_read_profile(state, 2, prototypes_for_110_frag, functions_for_110_frag, Elements(functions_for_110_frag)); } if (state->target == vertex_shader && state->language_version == 110) { - _mesa_read_profile(state, instructions, 3, + _mesa_read_profile(state, 3, prototypes_for_110_vert, functions_for_110_vert, Elements(functions_for_110_vert)); } if (state->target == fragment_shader && state->language_version == 120) { - _mesa_read_profile(state, instructions, 4, + _mesa_read_profile(state, 4, prototypes_for_120_frag, functions_for_120_frag, Elements(functions_for_120_frag)); } if (state->target == vertex_shader && state->language_version == 120) { - _mesa_read_profile(state, instructions, 5, + _mesa_read_profile(state, 5, prototypes_for_120_vert, functions_for_120_vert, Elements(functions_for_120_vert)); } if (state->target == fragment_shader && state->language_version == 130) { - _mesa_read_profile(state, instructions, 6, + _mesa_read_profile(state, 6, prototypes_for_130_frag, functions_for_130_frag, Elements(functions_for_130_frag)); } if (state->target == vertex_shader && state->language_version == 130) { - _mesa_read_profile(state, instructions, 7, + _mesa_read_profile(state, 7, prototypes_for_130_vert, functions_for_130_vert, Elements(functions_for_130_vert)); } if (state->target == fragment_shader && state->ARB_texture_rectangle_enable) { - _mesa_read_profile(state, instructions, 8, + _mesa_read_profile(state, 8, prototypes_for_ARB_texture_rectangle_frag, functions_for_ARB_texture_rectangle_frag, Elements(functions_for_ARB_texture_rectangle_frag)); } if (state->target == vertex_shader && state->ARB_texture_rectangle_enable) { - _mesa_read_profile(state, instructions, 9, + _mesa_read_profile(state, 9, prototypes_for_ARB_texture_rectangle_vert, functions_for_ARB_texture_rectangle_vert, Elements(functions_for_ARB_texture_rectangle_vert)); } if (state->target == fragment_shader && state->EXT_texture_array_enable) { - _mesa_read_profile(state, instructions, 10, + _mesa_read_profile(state, 10, prototypes_for_EXT_texture_array_frag, functions_for_EXT_texture_array_frag, Elements(functions_for_EXT_texture_array_frag)); } if (state->target == vertex_shader && state->EXT_texture_array_enable) { - _mesa_read_profile(state, instructions, 11, + _mesa_read_profile(state, 11, prototypes_for_EXT_texture_array_vert, functions_for_EXT_texture_array_vert, Elements(functions_for_EXT_texture_array_vert)); diff --git a/mesalib/src/glsl/configure.ac b/mesalib/src/glsl/configure.ac new file mode 100644 index 000000000..cd75fc8c1 --- /dev/null +++ b/mesalib/src/glsl/configure.ac @@ -0,0 +1,69 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT(glsl, XXXXX, idr@freedesktop.org, glsl) +AC_CONFIG_SRCDIR([Makefile.am]) +AM_CONFIG_HEADER([config.h]) +AC_CONFIG_FILES([glcpp/Makefile]) + +AM_INIT_AUTOMAKE +LT_INIT + +AM_MAINTAINER_MODE + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC +AC_PROG_MAKE_SET +AC_PROG_YACC +AC_PROG_LEX + +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +# Checks for libraries. + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. +AC_HEADER_STDC + +AH_TOP([#ifndef GLSL_CONFIG_H +#define GLSL_CONFIG_H]) +AH_BOTTOM([#endif /* GLSL_CONFIG_H */]) + +PKG_CHECK_MODULES([talloc], [talloc >= 2.0]) + +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], + [use debug compiler flags and macros @<:@default=disabled@:>@])], + [enable_debug="$enableval"], + [enable_debug=no] +) +if test "x$enable_debug" = xyes; then + DEFINES="$DEFINES -DDEBUG" + if test "x$GCC" = xyes; then + # Remove any -g or -O flags from the command line + CFLAGS=[`echo $CFLAGS | sed 's/-g[^ \t]*[ \t]*//g;s/-O[^ \t]*[ \t]*//g'`] + CFLAGS="$CFLAGS -O0 -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2" + fi + if test "x$GXX" = xyes; then + # Remove any -g flags from the command line + CXXFLAGS=[`echo $CXXFLAGS | sed 's/-g[^ \t]*[ \t]*//g;s/-O[^ \t]*[ \t]*//g'`] + CXXFLAGS="$CXXFLAGS -O0 -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2" + fi +fi + +if test "x$GXX" = xyes ; then + WARN="-Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector" +else + WARN="" +fi + +CFLAGS="$CFLAGS $WARN" +CXXFLAGS="$CXXFLAGS $WARN" +YFLAGS="-d -v" + +AC_OUTPUT([Makefile]) diff --git a/mesalib/src/glsl/glsl_lexer.cpp b/mesalib/src/glsl/glsl_lexer.cpp index 79956e076..b923af2e5 100644 --- a/mesalib/src/glsl/glsl_lexer.cpp +++ b/mesalib/src/glsl/glsl_lexer.cpp @@ -54,7 +54,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -85,6 +84,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -158,7 +159,15 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -349,8 +358,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 209 -#define YY_END_OF_BUFFER 210 +#define YY_NUM_RULES 210 +#define YY_END_OF_BUFFER 211 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -358,98 +367,100 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[813] = +static yyconst flex_int16_t yy_accept[836] = { 0, - 0, 0, 15, 15, 0, 0, 210, 208, 1, 20, - 208, 208, 208, 208, 208, 208, 208, 208, 119, 117, - 208, 208, 208, 207, 208, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 208, 1, 208, 209, 15, - 19, 209, 18, 16, 17, 13, 12, 1, 101, 110, - 102, 113, 107, 96, 109, 97, 116, 121, 108, 122, - 119, 0, 0, 124, 119, 0, 117, 117, 105, 98, - 100, 99, 106, 207, 114, 104, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 29, 207, - - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 33, 207, 207, 60, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 115, - 103, 1, 0, 0, 2, 0, 0, 0, 0, 15, - 14, 18, 17, 0, 121, 120, 0, 122, 0, 123, - 118, 111, 112, 207, 127, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 32, 207, 207, 207, - - 207, 207, 207, 207, 207, 207, 207, 25, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 61, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 0, 0, 0, 0, 14, 0, 121, 0, 120, 0, - 122, 123, 118, 207, 207, 23, 207, 207, 174, 167, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 31, - 130, 207, 207, 207, 207, 67, 207, 207, 135, 149, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - - 207, 207, 146, 170, 48, 49, 50, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 133, 125, 207, - 207, 26, 207, 207, 207, 207, 207, 207, 207, 45, - 46, 47, 94, 207, 207, 0, 0, 0, 0, 0, - 120, 207, 207, 27, 36, 37, 38, 207, 128, 207, - 22, 207, 207, 207, 207, 157, 158, 159, 207, 126, - 207, 150, 24, 160, 161, 162, 172, 154, 155, 156, - 207, 207, 207, 62, 152, 207, 207, 207, 39, 40, - 41, 207, 207, 207, 207, 207, 207, 207, 207, 207, - - 207, 207, 207, 207, 207, 207, 207, 147, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 129, 207, - 207, 169, 42, 43, 44, 207, 207, 30, 0, 0, - 0, 0, 177, 207, 207, 175, 207, 207, 207, 148, - 143, 180, 207, 207, 207, 207, 207, 207, 138, 207, - 207, 207, 95, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 207, 207, 207, 207, 153, 134, 207, 207, - 141, 35, 207, 207, 166, 68, 142, 93, 178, 136, - 207, 207, 207, 207, 207, 207, 207, 207, 0, 0, - 0, 0, 207, 207, 207, 137, 34, 207, 207, 207, - - 207, 207, 207, 181, 182, 183, 207, 207, 207, 207, - 207, 171, 207, 207, 207, 207, 207, 207, 207, 207, - 131, 207, 207, 207, 207, 207, 63, 207, 207, 64, - 207, 0, 0, 0, 0, 0, 207, 65, 28, 144, - 185, 186, 187, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 139, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 132, 189, 190, 191, 207, - 207, 151, 207, 140, 0, 0, 6, 0, 0, 0, - 11, 3, 21, 207, 207, 207, 207, 207, 207, 207, - 207, 207, 184, 145, 66, 207, 207, 207, 207, 168, - - 207, 176, 173, 206, 70, 71, 72, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 0, 0, 0, - 0, 0, 0, 207, 207, 207, 188, 207, 207, 207, - 207, 207, 81, 82, 83, 207, 207, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 192, 87, - 88, 89, 207, 4, 0, 5, 0, 0, 0, 0, - 0, 207, 207, 207, 207, 207, 207, 207, 203, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 73, 207, 207, 207, 207, 207, 207, 0, 0, 0, - 207, 207, 204, 193, 207, 194, 207, 207, 207, 84, - - 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, - 207, 205, 207, 207, 90, 0, 0, 195, 196, 207, - 199, 207, 200, 207, 207, 69, 207, 207, 207, 163, - 207, 164, 179, 207, 197, 198, 207, 207, 0, 0, - 207, 207, 207, 207, 74, 207, 75, 207, 207, 207, - 207, 207, 0, 0, 0, 207, 207, 85, 86, 207, - 76, 207, 207, 77, 207, 91, 92, 0, 0, 0, - 207, 207, 207, 207, 207, 207, 0, 0, 0, 207, - 207, 207, 207, 207, 78, 0, 0, 7, 0, 0, - 201, 202, 207, 207, 207, 0, 8, 0, 0, 207, - - 207, 165, 0, 0, 79, 80, 0, 0, 9, 0, - 10, 0 + 0, 0, 16, 16, 0, 0, 211, 209, 1, 21, + 209, 209, 209, 209, 209, 209, 209, 209, 120, 118, + 209, 209, 209, 208, 209, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 209, 1, 209, 210, 16, + 20, 210, 19, 17, 18, 14, 13, 1, 102, 111, + 103, 114, 108, 97, 110, 98, 117, 122, 109, 123, + 120, 0, 0, 125, 120, 0, 118, 118, 106, 99, + 101, 100, 107, 208, 115, 105, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 30, 208, + + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 34, 208, 208, 61, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 116, + 104, 1, 0, 0, 2, 0, 0, 0, 0, 16, + 15, 19, 18, 0, 122, 121, 0, 123, 0, 124, + 119, 112, 113, 208, 128, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 33, 208, 208, 208, + + 208, 208, 208, 208, 208, 208, 208, 26, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 62, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 0, 0, 0, 0, 15, 0, 122, 0, 121, 0, + 123, 124, 119, 208, 208, 24, 208, 208, 175, 168, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 32, + 131, 208, 208, 208, 208, 68, 208, 208, 136, 150, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + + 208, 208, 147, 171, 49, 50, 51, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 134, 126, 208, + 208, 27, 208, 208, 208, 208, 208, 208, 208, 46, + 47, 48, 95, 208, 208, 0, 0, 0, 0, 0, + 121, 208, 208, 28, 37, 38, 39, 208, 129, 208, + 23, 208, 208, 208, 208, 158, 159, 160, 208, 127, + 208, 151, 25, 161, 162, 163, 173, 155, 156, 157, + 208, 208, 208, 63, 153, 208, 208, 208, 40, 41, + 42, 208, 208, 208, 208, 208, 208, 208, 208, 208, + + 208, 208, 208, 208, 208, 208, 208, 148, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 130, 208, + 208, 170, 43, 44, 45, 208, 208, 31, 0, 0, + 0, 0, 178, 208, 208, 176, 208, 208, 208, 149, + 144, 181, 208, 208, 208, 208, 208, 208, 139, 208, + 208, 208, 96, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 208, 208, 208, 208, 154, 135, 208, 208, + 142, 36, 208, 208, 167, 69, 143, 94, 179, 137, + 208, 208, 208, 208, 208, 208, 208, 208, 0, 0, + 0, 0, 208, 208, 208, 138, 35, 208, 208, 208, + + 208, 208, 208, 182, 183, 184, 208, 208, 208, 208, + 208, 172, 208, 208, 208, 208, 208, 208, 208, 208, + 132, 208, 208, 208, 208, 208, 64, 208, 208, 65, + 208, 0, 0, 0, 0, 0, 208, 66, 29, 145, + 186, 187, 188, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 140, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 133, 190, 191, 192, 208, + 208, 152, 208, 141, 0, 0, 6, 0, 0, 0, + 12, 3, 22, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 185, 146, 67, 208, 208, 208, 208, 169, + + 208, 177, 174, 207, 71, 72, 73, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 0, 0, 0, + 0, 0, 0, 0, 208, 208, 208, 189, 208, 208, + 208, 208, 208, 82, 83, 84, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, 208, 193, + 88, 89, 90, 208, 4, 0, 5, 0, 0, 0, + 0, 0, 0, 208, 208, 208, 208, 208, 208, 208, + 204, 208, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 74, 208, 208, 208, 208, 208, 208, 0, + 0, 0, 0, 208, 208, 205, 194, 208, 195, 208, + + 208, 208, 85, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 206, 208, 208, 91, 0, 0, + 0, 196, 197, 208, 200, 208, 201, 208, 208, 70, + 208, 208, 208, 164, 208, 165, 180, 208, 198, 199, + 208, 208, 0, 0, 0, 208, 208, 208, 208, 75, + 208, 76, 208, 208, 208, 208, 208, 0, 0, 0, + 0, 208, 208, 86, 87, 208, 77, 208, 208, 78, + 208, 92, 93, 0, 0, 0, 0, 208, 208, 208, + 208, 208, 208, 0, 0, 0, 0, 208, 208, 208, + 208, 208, 79, 0, 0, 0, 7, 0, 0, 202, + + 203, 208, 208, 208, 0, 0, 8, 0, 0, 208, + 208, 166, 0, 0, 0, 80, 81, 0, 0, 0, + 9, 0, 0, 10, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 11, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -461,13 +472,13 @@ static yyconst flex_int32_t yy_ec[256] = 10, 11, 12, 1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 21, 22, 22, 23, 1, 24, 25, 26, 1, 1, 27, 28, 29, 30, 31, 32, - 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, - 33, 34, 35, 33, 36, 33, 33, 37, 33, 33, - 1, 1, 1, 38, 39, 1, 40, 41, 42, 43, + 33, 34, 34, 34, 34, 35, 34, 34, 34, 34, + 34, 36, 37, 38, 39, 34, 34, 40, 34, 34, + 1, 1, 1, 41, 42, 1, 43, 44, 45, 46, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 33, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 1, 65, 1, 1, 1, 1, 1, 1, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 34, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 1, 68, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -484,350 +495,357 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[66] = +static yyconst flex_int32_t yy_meta[69] = { 0, - 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, - 4, 5, 1, 1, 1, 1, 6, 6, 6, 6, - 5, 5, 7, 7, 7, 7, 8, 1, 7, 6, - 6, 6, 6, 5, 5, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 8, 7, 7, 1 + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, + 3, 3, 1, 1, 1, 1, 4, 4, 4, 4, + 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, + 1, 5, 4, 4, 4, 4, 3, 3, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 1 } ; -static yyconst flex_int16_t yy_base[824] = +static yyconst flex_int16_t yy_base[845] = { 0, - 0, 64, 70, 0, 1185, 1184, 1186, 1189, 65, 1189, - 1160, 1159, 128, 1158, 125, 126, 124, 1157, 140, 189, - 123, 1156, 138, 0, 127, 124, 113, 135, 144, 161, - 176, 1126, 130, 187, 140, 143, 161, 1120, 182, 174, - 202, 199, 211, 212, 1131, 130, 263, 255, 1189, 189, - 1189, 1162, 256, 1189, 0, 1189, 1189, 215, 1189, 1189, - 1189, 1189, 1189, 1189, 1189, 1189, 1189, 248, 1189, 250, - 112, 302, 319, 1189, 1189, 0, 0, 1189, 1151, 1189, - 1189, 1189, 1150, 0, 1189, 1189, 1116, 1121, 1114, 1117, - 1126, 1125, 1111, 1114, 1126, 144, 1120, 1107, 1104, 1118, - - 1104, 1101, 1101, 1107, 175, 191, 1101, 1112, 1097, 1103, - 1107, 1108, 0, 1099, 1110, 247, 1109, 1104, 1084, 230, - 1088, 1102, 1092, 241, 1085, 228, 1098, 1100, 1082, 1078, - 1086, 1083, 1072, 1081, 173, 1079, 1085, 1080, 1083, 1071, - 1074, 233, 240, 260, 1084, 1071, 1084, 239, 1077, 1189, - 1189, 307, 301, 323, 1189, 1062, 1075, 1066, 1077, 249, - 0, 368, 0, 379, 1189, 298, 390, 1189, 397, 404, - 291, 1189, 1189, 1072, 0, 1063, 1067, 1077, 1074, 270, - 1057, 1057, 1061, 291, 1072, 1069, 1069, 1067, 1064, 1055, - 1062, 1048, 1046, 1059, 1044, 1061, 0, 1058, 1045, 1053, - - 1050, 1054, 1055, 1048, 1045, 1033, 1032, 1046, 1049, 1036, - 1045, 1032, 1039, 1029, 335, 1035, 1038, 1028, 1036, 1024, - 1028, 1019, 1034, 1024, 1015, 1034, 1017, 1015, 1026, 1015, - 1010, 1008, 1022, 1007, 1009, 1006, 1018, 1017, 1020, 1001, - 306, 1010, 1005, 1003, 1013, 991, 339, 1010, 1012, 1000, - 992, 996, 1008, 991, 0, 411, 421, 438, 1189, 451, - 458, 1189, 1189, 986, 997, 0, 994, 344, 0, 0, - 987, 985, 987, 982, 991, 979, 997, 985, 350, 0, - 0, 979, 990, 989, 989, 0, 973, 353, 0, 0, - 975, 357, 983, 984, 974, 968, 967, 968, 967, 967, - - 361, 962, 0, 0, 958, 957, 956, 958, 959, 964, - 958, 954, 968, 963, 962, 961, 952, 955, 955, 947, - 950, 945, 954, 959, 944, 957, 947, 0, 0, 954, - 950, 0, 941, 941, 947, 937, 945, 426, 942, 0, - 0, 0, 0, 931, 944, 943, 942, 939, 927, 465, - 475, 939, 941, 0, 0, 0, 0, 927, 0, 927, - 0, 926, 927, 921, 932, 0, 0, 0, 922, 0, - 918, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 929, 481, 928, 0, 0, 926, 922, 918, 0, 0, - 0, 910, 443, 486, 493, 915, 911, 917, 907, 905, - - 919, 903, 903, 917, 905, 917, 912, 0, 910, 907, - 911, 894, 896, 903, 909, 904, 903, 890, 0, 892, - 893, 0, 0, 0, 0, 890, 894, 0, 888, 938, - 887, 890, 0, 878, 888, 0, 876, 876, 890, 0, - 892, 0, 497, 901, 900, 899, 869, 868, 0, 886, - 885, 880, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 868, 882, 868, 865, 0, 0, 871, 870, - 0, 0, 868, 860, 0, 0, 0, 0, 0, 0, - 857, 869, 500, 861, 868, 867, 864, 858, 851, 519, - 867, 852, 847, 861, 859, 0, 0, 851, 871, 870, - - 869, 839, 838, 495, 496, 0, 851, 854, 852, 840, - 836, 0, 849, 846, 845, 834, 833, 832, 515, 841, - 0, 854, 853, 852, 822, 821, 0, 836, 822, 0, - 833, 828, 543, 545, 873, 821, 829, 0, 0, 0, - 845, 844, 0, 825, 828, 812, 820, 810, 818, 819, - 819, 818, 803, 539, 816, 0, 817, 805, 804, 800, - 825, 824, 823, 793, 792, 0, 823, 822, 0, 803, - 806, 0, 552, 0, 792, 557, 1189, 580, 0, 590, - 499, 1189, 0, 789, 788, 798, 798, 785, 800, 783, - 798, 793, 0, 0, 0, 806, 805, 804, 774, 0, - - 774, 0, 0, 0, 559, 568, 797, 785, 788, 772, - 771, 781, 781, 794, 793, 792, 762, 767, 552, 613, - 363, 775, 763, 761, 760, 771, 0, 774, 770, 772, - 768, 754, 782, 781, 0, 766, 758, 749, 757, 747, - 758, 754, 756, 754, 754, 741, 740, 751, 0, 767, - 766, 0, 751, 1189, 391, 1189, 620, 0, 640, 750, - 732, 749, 748, 731, 723, 731, 721, 729, 0, 726, - 725, 736, 719, 722, 737, 720, 733, 734, 731, 728, - 736, 730, 729, 712, 711, 710, 721, 402, 705, 715, - 699, 698, 0, 725, 698, 723, 696, 700, 699, 0, - - 710, 713, 709, 711, 688, 702, 686, 680, 688, 671, - 662, 0, 640, 639, 0, 648, 641, 0, 0, 645, - 0, 644, 0, 650, 649, 0, 625, 633, 623, 650, - 630, 0, 0, 643, 0, 0, 642, 641, 582, 632, - 639, 638, 614, 613, 635, 608, 633, 607, 590, 607, - 586, 585, 611, 380, 526, 545, 544, 0, 0, 538, - 0, 504, 510, 0, 495, 0, 0, 550, 572, 483, - 470, 454, 462, 449, 445, 404, 419, 616, 619, 391, - 387, 404, 392, 290, 0, 617, 642, 1189, 644, 570, - 0, 0, 263, 258, 139, 645, 1189, 643, 618, 107, - - 77, 0, 23, 662, 0, 0, 663, 664, 1189, 665, - 1189, 1189, 697, 702, 707, 712, 714, 716, 722, 729, - 734, 739, 744 + 0, 67, 73, 0, 1210, 1209, 1211, 1214, 68, 1214, + 1185, 1184, 134, 1183, 131, 132, 130, 1182, 146, 198, + 129, 1181, 144, 0, 130, 113, 124, 141, 150, 126, + 181, 1148, 159, 192, 118, 129, 146, 1142, 147, 174, + 206, 192, 203, 222, 1153, 203, 221, 231, 1214, 260, + 1214, 1187, 279, 1214, 0, 1214, 1214, 270, 1214, 1214, + 1214, 1214, 1214, 1214, 1214, 1214, 1214, 244, 1214, 255, + 139, 290, 307, 1214, 1214, 0, 0, 1214, 1176, 1214, + 1214, 1214, 1175, 0, 1214, 1214, 1138, 1143, 1136, 1139, + 1148, 1147, 1133, 1136, 1148, 144, 1142, 1129, 1126, 1140, + + 1126, 1123, 1123, 1129, 219, 193, 1123, 1134, 1119, 1125, + 1129, 1130, 0, 1121, 1132, 278, 1131, 1126, 1106, 224, + 1110, 1124, 1114, 232, 1107, 271, 1120, 1122, 1104, 1100, + 1108, 1105, 1094, 1103, 234, 1101, 1107, 1102, 1105, 1093, + 1096, 226, 145, 262, 1106, 1093, 1106, 263, 1099, 1214, + 1214, 338, 331, 343, 1214, 1084, 1097, 1088, 1099, 345, + 0, 334, 0, 345, 1214, 328, 391, 1214, 352, 398, + 338, 1214, 1214, 1094, 0, 1085, 1089, 1099, 1096, 332, + 1079, 1079, 1083, 320, 1094, 1091, 1091, 1089, 1086, 1077, + 1084, 1070, 1068, 1081, 1066, 1083, 0, 1080, 1067, 1075, + + 1072, 1076, 1077, 1070, 1067, 1055, 1054, 1068, 1071, 1058, + 1067, 1054, 1061, 1051, 364, 1057, 1060, 1050, 1058, 1046, + 1050, 1041, 1056, 1046, 1037, 1056, 1039, 1037, 1048, 1037, + 1032, 1030, 1044, 1029, 1031, 1028, 1040, 1039, 1042, 1023, + 338, 1032, 1027, 1025, 1035, 1013, 403, 1032, 1034, 1022, + 1014, 1018, 1030, 1013, 0, 415, 422, 439, 1214, 446, + 455, 1214, 1214, 1008, 1019, 0, 1016, 406, 0, 0, + 1009, 1007, 1009, 1004, 1013, 1001, 1019, 1007, 409, 0, + 0, 1001, 1012, 1011, 1011, 0, 995, 429, 0, 0, + 997, 460, 1005, 1006, 996, 990, 989, 990, 989, 989, + + 463, 984, 0, 0, 980, 979, 978, 980, 981, 986, + 980, 976, 990, 985, 984, 983, 974, 977, 977, 969, + 972, 967, 976, 981, 966, 979, 969, 0, 0, 976, + 972, 0, 963, 963, 969, 959, 967, 466, 964, 0, + 0, 0, 0, 953, 966, 965, 964, 961, 949, 472, + 479, 961, 963, 0, 0, 0, 0, 949, 0, 949, + 0, 948, 949, 943, 954, 0, 0, 0, 944, 0, + 940, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 951, 487, 950, 0, 0, 948, 944, 940, 0, 0, + 0, 932, 489, 494, 499, 937, 933, 939, 929, 927, + + 941, 925, 925, 939, 927, 939, 934, 0, 932, 929, + 933, 916, 918, 925, 931, 926, 925, 912, 0, 914, + 915, 0, 0, 0, 0, 912, 916, 0, 910, 963, + 909, 912, 0, 900, 910, 0, 898, 898, 912, 0, + 914, 0, 503, 926, 925, 924, 891, 890, 0, 908, + 907, 902, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 890, 904, 890, 887, 0, 0, 893, 892, + 0, 0, 890, 882, 0, 0, 0, 0, 0, 0, + 879, 891, 506, 883, 890, 889, 886, 880, 873, 524, + 889, 874, 869, 883, 881, 0, 0, 873, 896, 895, + + 894, 861, 860, 361, 365, 0, 873, 876, 874, 862, + 858, 0, 871, 868, 867, 856, 855, 854, 519, 863, + 0, 879, 878, 877, 844, 843, 0, 858, 844, 0, + 855, 850, 547, 553, 898, 843, 851, 0, 0, 0, + 870, 869, 0, 847, 850, 834, 842, 832, 840, 841, + 841, 840, 825, 559, 838, 0, 839, 827, 826, 822, + 850, 849, 848, 815, 814, 0, 848, 847, 0, 825, + 828, 0, 562, 0, 814, 580, 1214, 587, 0, 607, + 584, 1214, 0, 811, 810, 820, 820, 807, 822, 805, + 820, 815, 0, 0, 0, 831, 830, 829, 796, 0, + + 796, 0, 0, 0, 502, 524, 820, 807, 810, 794, + 793, 803, 803, 819, 818, 817, 784, 789, 615, 640, + 550, 806, 796, 784, 782, 781, 792, 0, 795, 791, + 793, 789, 775, 806, 805, 0, 787, 779, 770, 778, + 768, 779, 775, 777, 775, 775, 762, 761, 772, 0, + 791, 790, 0, 772, 1214, 555, 1214, 647, 0, 667, + 785, 770, 752, 769, 768, 751, 743, 751, 741, 749, + 0, 746, 745, 756, 739, 742, 757, 740, 753, 754, + 751, 748, 757, 750, 749, 732, 731, 730, 741, 582, + 754, 724, 734, 718, 717, 0, 745, 717, 743, 715, + + 719, 718, 0, 729, 732, 728, 730, 711, 725, 709, + 710, 718, 701, 700, 0, 706, 705, 0, 728, 713, + 706, 0, 0, 710, 0, 709, 0, 715, 714, 0, + 690, 698, 688, 716, 695, 0, 0, 708, 0, 0, + 707, 706, 746, 611, 696, 703, 702, 678, 677, 705, + 677, 703, 689, 674, 691, 670, 669, 190, 613, 557, + 667, 687, 686, 0, 0, 681, 0, 680, 686, 0, + 671, 0, 0, 671, 590, 343, 672, 645, 644, 654, + 635, 631, 612, 612, 604, 443, 635, 576, 575, 549, + 25, 87, 0, 183, 500, 552, 1214, 636, 591, 0, + + 0, 196, 258, 254, 272, 609, 1214, 614, 598, 279, + 284, 0, 336, 348, 671, 0, 0, 362, 672, 688, + 1214, 394, 689, 1214, 408, 670, 691, 649, 651, 474, + 476, 693, 694, 1214, 1214, 704, 707, 710, 530, 591, + 713, 717, 720, 722 } ; -static yyconst flex_int16_t yy_def[824] = +static yyconst flex_int16_t yy_def[845] = { 0, - 812, 1, 812, 3, 813, 813, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 814, 812, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 815, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 816, 812, 817, - 19, 812, 812, 812, 812, 818, 20, 812, 812, 812, - 812, 812, 812, 814, 812, 812, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 819, 812, 815, 812, 812, 817, 812, 812, 812, 812, - 818, 812, 812, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 812, 812, 812, 812, 819, 812, 812, 812, 812, 812, - 812, 812, 812, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 812, 812, 812, 812, 812, - 812, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 812, 812, - 812, 812, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 812, 812, - 812, 812, 814, 814, 814, 814, 814, 814, 814, 814, - - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 812, 820, 812, 812, 812, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 812, 812, 812, 812, 821, 812, - 812, 812, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 812, 822, 812, - 821, 812, 812, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 812, 812, 812, 812, 823, 812, 812, - 812, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 823, 812, 812, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 812, 812, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 814, 812, 812, - 814, 814, 814, 814, 814, 814, 814, 814, 814, 814, - 814, 814, 812, 812, 812, 814, 814, 814, 814, 814, - 814, 814, 814, 814, 814, 814, 814, 812, 812, 812, - 814, 814, 814, 814, 814, 814, 812, 812, 812, 814, - 814, 814, 814, 814, 814, 812, 812, 812, 812, 812, - 814, 814, 814, 814, 814, 812, 812, 812, 812, 814, - - 814, 814, 812, 812, 814, 814, 812, 812, 812, 812, - 812, 0, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812 + 835, 1, 835, 3, 836, 836, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 837, 835, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 838, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 839, 835, 840, + 19, 835, 835, 835, 835, 841, 20, 835, 835, 835, + 835, 835, 835, 837, 835, 835, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 842, 835, 838, 835, 835, 840, 835, 835, 835, 835, + 841, 835, 835, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 835, 835, 835, 835, 842, 835, 835, 835, 835, 835, + 835, 835, 835, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 835, 835, 835, 835, 835, + 835, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 835, 835, + 835, 835, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 835, 835, + 835, 835, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 835, 835, 835, 835, 835, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 835, 835, 835, 835, 843, 835, + 835, 835, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 835, 835, 835, + 843, 835, 835, 835, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 835, 835, 835, 835, 844, 835, + 835, 835, 835, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 844, + 835, 835, 835, 837, 837, 837, 837, 837, 837, 837, + + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 835, 835, + 835, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 835, 835, 835, 837, 837, 837, 837, 837, + 837, 837, 837, 837, 837, 837, 837, 835, 835, 835, + 835, 837, 837, 837, 837, 837, 837, 837, 837, 837, + 837, 837, 837, 835, 835, 835, 835, 837, 837, 837, + 837, 837, 837, 835, 835, 835, 835, 837, 837, 837, + 837, 837, 837, 835, 835, 835, 835, 835, 835, 837, + + 837, 837, 837, 837, 835, 835, 835, 835, 835, 837, + 837, 837, 835, 835, 835, 837, 837, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 0, 835, 835, 835, 835, 835, + 835, 835, 835, 835 } ; -static yyconst flex_int16_t yy_nxt[1255] = +static yyconst flex_int16_t yy_nxt[1283] = { 0, 8, 9, 10, 9, 11, 8, 12, 13, 8, 8, 14, 15, 16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 8, 21, 22, 23, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 25, 24, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 24, 24, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 24, 24, 24, 46, 47, 58, 807, 58, 48, - 49, 50, 51, 50, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 52, 49, 53, 53, 53, 53, - 53, 53, 54, 49, 49, 49, 55, 55, 55, 55, - - 55, 55, 55, 55, 55, 55, 55, 49, 55, 55, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 25, 24, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 24, 24, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 24, 24, 24, 46, 47, 58, + 803, 58, 48, 49, 50, 51, 50, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 52, 49, 53, + 53, 53, 53, 53, 53, 54, 49, 49, 49, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 49, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 49, 61, 64, 806, 66, 68, - 68, 68, 68, 68, 68, 68, 79, 80, 812, 65, - 67, 85, 62, 70, 150, 71, 71, 71, 71, 71, - 71, 72, 82, 83, 86, 87, 90, 805, 91, 110, - 73, 74, 92, 812, 93, 75, 76, 111, 94, 119, - 88, 89, 121, 73, 74, 95, 122, 97, 96, 112, - 160, 98, 160, 120, 151, 183, 184, 99, 75, 802, - - 123, 76, 70, 100, 77, 77, 77, 77, 77, 77, - 77, 101, 231, 102, 124, 104, 58, 129, 58, 73, - 74, 126, 103, 105, 78, 193, 106, 130, 232, 107, - 195, 113, 73, 74, 114, 108, 194, 127, 115, 116, - 128, 131, 138, 117, 196, 139, 118, 78, 132, 133, - 160, 146, 160, 134, 140, 147, 154, 155, 142, 135, - 136, 141, 137, 143, 152, 148, 58, 144, 153, 221, - 145, 162, 162, 162, 162, 162, 162, 162, 164, 165, - 167, 168, 213, 222, 239, 240, 248, 241, 218, 249, - 214, 164, 165, 167, 168, 219, 242, 205, 156, 243, - - 206, 207, 154, 155, 208, 157, 209, 244, 152, 158, - 58, 801, 153, 269, 159, 70, 800, 72, 72, 72, - 72, 72, 72, 72, 154, 155, 263, 270, 258, 259, - 169, 169, 73, 74, 170, 170, 170, 170, 170, 170, - 170, 258, 259, 795, 156, 73, 74, 274, 275, 263, - 333, 157, 305, 306, 307, 158, 340, 341, 342, 334, - 159, 355, 356, 357, 576, 577, 156, 366, 367, 368, - 374, 375, 376, 157, 378, 379, 380, 158, 389, 390, - 391, 768, 159, 162, 162, 162, 162, 162, 162, 162, - 256, 256, 655, 656, 257, 257, 257, 257, 257, 257, - - 257, 260, 260, 655, 656, 261, 261, 261, 261, 261, - 261, 261, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 257, 257, 257, 257, - 257, 257, 257, 769, 794, 262, 257, 257, 257, 257, - 257, 257, 257, 423, 424, 425, 793, 792, 262, 350, - 350, 791, 165, 351, 351, 351, 351, 351, 351, 351, - 454, 455, 456, 786, 785, 165, 261, 261, 261, 261, - 261, 261, 261, 261, 261, 261, 261, 261, 261, 261, - 351, 351, 351, 351, 351, 351, 351, 784, 783, 168, - 351, 351, 351, 351, 351, 351, 351, 444, 445, 446, - - 581, 782, 168, 457, 458, 459, 259, 781, 447, 448, - 460, 461, 462, 499, 500, 501, 522, 523, 524, 259, - 490, 546, 548, 780, 502, 503, 779, 525, 526, 547, - 549, 561, 562, 563, 533, 534, 534, 534, 534, 534, - 534, 622, 564, 565, 576, 577, 576, 577, 776, 775, - 774, 768, 623, 655, 656, 596, 597, 598, 576, 577, - 580, 580, 580, 580, 580, 580, 580, 599, 614, 615, - 616, 798, 619, 620, 620, 620, 620, 620, 620, 579, - 617, 576, 577, 753, 773, 638, 772, 771, 658, 770, - 754, 576, 577, 639, 640, 578, 578, 578, 578, 578, - - 578, 641, 642, 769, 579, 580, 580, 580, 580, 580, - 580, 580, 753, 658, 655, 656, 777, 787, 796, 754, - 789, 655, 656, 799, 778, 788, 797, 790, 659, 659, - 659, 659, 659, 659, 659, 657, 657, 657, 657, 657, - 657, 655, 656, 787, 798, 789, 796, 767, 766, 765, - 764, 788, 790, 763, 797, 659, 659, 659, 659, 659, - 659, 659, 803, 808, 810, 808, 810, 762, 761, 760, - 804, 809, 811, 809, 811, 759, 758, 757, 756, 755, - 752, 751, 750, 749, 748, 747, 746, 745, 744, 743, - 742, 741, 740, 739, 738, 737, 799, 56, 56, 56, - - 56, 56, 56, 56, 56, 84, 84, 84, 84, 84, - 163, 163, 163, 163, 163, 68, 68, 166, 166, 171, - 171, 171, 255, 255, 736, 255, 255, 255, 255, 255, - 578, 578, 578, 735, 734, 733, 578, 621, 621, 621, - 657, 657, 657, 732, 731, 730, 657, 688, 688, 688, - 729, 728, 727, 726, 725, 724, 723, 722, 721, 720, - 719, 718, 717, 716, 715, 714, 713, 712, 711, 710, - 709, 708, 707, 706, 705, 704, 703, 702, 701, 700, - 699, 698, 697, 696, 695, 694, 693, 692, 691, 690, - 689, 687, 686, 685, 684, 683, 682, 681, 680, 679, - - 678, 677, 676, 675, 674, 673, 672, 671, 670, 669, - 668, 667, 666, 665, 664, 663, 662, 661, 660, 654, - 653, 652, 651, 650, 649, 648, 647, 646, 645, 644, - 643, 637, 636, 635, 634, 633, 632, 631, 630, 629, - 628, 627, 626, 625, 624, 618, 613, 612, 611, 610, - 609, 608, 607, 606, 605, 604, 603, 602, 601, 600, - 595, 594, 593, 592, 591, 590, 589, 588, 587, 586, - 585, 584, 583, 582, 581, 575, 574, 573, 572, 571, - 570, 569, 568, 567, 566, 560, 559, 558, 557, 556, - 555, 554, 553, 552, 551, 550, 545, 544, 543, 542, - - 541, 540, 539, 538, 537, 536, 535, 532, 531, 530, - 529, 528, 527, 521, 520, 519, 518, 517, 516, 515, - 514, 513, 512, 511, 510, 509, 508, 507, 506, 505, - 504, 498, 497, 496, 495, 494, 493, 492, 491, 490, - 489, 488, 487, 486, 485, 484, 483, 482, 481, 480, - 479, 478, 477, 476, 475, 474, 473, 472, 471, 470, - 469, 468, 467, 466, 465, 464, 463, 453, 452, 451, - 450, 449, 443, 442, 441, 440, 439, 438, 437, 436, - 435, 434, 433, 432, 431, 430, 429, 428, 427, 426, - 422, 421, 420, 419, 418, 417, 416, 415, 414, 413, - - 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, - 402, 401, 400, 399, 398, 397, 396, 395, 394, 393, - 392, 388, 387, 386, 385, 384, 383, 382, 381, 377, - 373, 372, 371, 370, 369, 365, 364, 363, 362, 361, - 360, 359, 358, 354, 353, 352, 349, 348, 347, 346, - 345, 344, 343, 339, 338, 337, 336, 335, 332, 331, - 330, 329, 328, 327, 326, 325, 324, 323, 322, 321, - 320, 319, 318, 317, 316, 315, 314, 313, 312, 311, - 310, 309, 308, 304, 303, 302, 301, 300, 299, 298, - 297, 296, 295, 294, 293, 292, 291, 290, 289, 288, - - 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, - 277, 276, 273, 272, 271, 268, 267, 266, 265, 264, - 254, 253, 252, 251, 250, 247, 246, 245, 238, 237, - 236, 235, 234, 233, 230, 229, 228, 227, 226, 225, - 224, 223, 220, 217, 216, 215, 212, 211, 210, 204, - 203, 202, 201, 200, 199, 198, 197, 192, 191, 190, - 189, 188, 187, 186, 185, 182, 181, 180, 179, 178, - 177, 176, 175, 174, 173, 172, 161, 149, 125, 109, - 81, 69, 63, 60, 59, 812, 57, 57, 7, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812 + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 49, 61, 64, 804, 66, 68, 68, 68, 68, 68, + 68, 68, 79, 80, 85, 65, 67, 87, 62, 70, + 119, 71, 71, 71, 71, 71, 71, 72, 82, 83, + 86, 121, 88, 89, 120, 122, 73, 74, 835, 101, + 90, 102, 91, 93, 75, 76, 92, 94, 123, 126, + 103, 758, 73, 74, 95, 241, 97, 96, 183, 184, + + 98, 110, 124, 835, 242, 127, 99, 75, 128, 111, + 76, 70, 100, 77, 77, 77, 77, 77, 77, 77, + 129, 112, 152, 104, 58, 805, 153, 150, 73, 74, + 130, 105, 154, 155, 106, 195, 78, 107, 138, 113, + 774, 139, 114, 108, 73, 74, 115, 116, 131, 196, + 140, 117, 810, 142, 118, 132, 133, 141, 143, 78, + 134, 160, 144, 160, 146, 145, 135, 136, 147, 137, + 151, 58, 193, 58, 164, 165, 231, 156, 148, 213, + 239, 240, 218, 194, 157, 167, 168, 214, 158, 219, + 164, 165, 232, 159, 162, 162, 162, 162, 162, 162, + + 162, 167, 168, 70, 243, 72, 72, 72, 72, 72, + 72, 72, 244, 248, 811, 221, 249, 812, 169, 169, + 73, 74, 170, 170, 170, 170, 170, 170, 170, 222, + 813, 205, 154, 155, 206, 207, 73, 74, 208, 152, + 209, 58, 816, 153, 154, 155, 160, 817, 160, 162, + 162, 162, 162, 162, 162, 162, 256, 256, 258, 259, + 257, 257, 257, 257, 257, 257, 257, 170, 170, 170, + 170, 170, 170, 170, 258, 259, 263, 156, 269, 274, + 275, 305, 306, 307, 157, 333, 818, 546, 158, 156, + 785, 548, 270, 159, 334, 819, 157, 547, 786, 263, + + 158, 549, 260, 260, 822, 159, 261, 261, 261, 261, + 261, 261, 261, 170, 170, 170, 170, 170, 170, 170, + 340, 341, 342, 355, 356, 357, 366, 367, 368, 262, + 257, 257, 257, 257, 257, 257, 257, 257, 257, 257, + 257, 257, 257, 257, 796, 262, 374, 375, 376, 825, + 350, 350, 797, 165, 351, 351, 351, 351, 351, 351, + 351, 261, 261, 261, 261, 261, 261, 261, 826, 165, + 261, 261, 261, 261, 261, 261, 261, 378, 379, 380, + 389, 390, 391, 423, 424, 425, 168, 351, 351, 351, + 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + + 351, 806, 168, 444, 445, 446, 454, 455, 456, 807, + 259, 457, 458, 459, 447, 448, 460, 461, 462, 499, + 500, 501, 522, 523, 524, 490, 259, 831, 639, 832, + 502, 503, 68, 525, 526, 561, 562, 563, 640, 533, + 534, 534, 534, 534, 534, 534, 564, 565, 576, 577, + 641, 576, 577, 796, 576, 577, 656, 657, 775, 642, + 643, 797, 578, 578, 578, 578, 578, 578, 580, 580, + 580, 580, 580, 580, 580, 596, 597, 598, 614, 615, + 616, 576, 577, 656, 657, 581, 579, 599, 576, 577, + 617, 775, 808, 166, 802, 619, 620, 620, 620, 620, + + 620, 620, 578, 578, 578, 578, 578, 578, 576, 577, + 806, 579, 759, 776, 759, 808, 656, 657, 807, 760, + 622, 760, 580, 580, 580, 580, 580, 580, 580, 623, + 658, 658, 658, 658, 658, 658, 798, 798, 801, 800, + 624, 656, 657, 799, 799, 814, 776, 809, 656, 657, + 829, 795, 829, 815, 659, 660, 660, 660, 660, 660, + 660, 660, 658, 658, 658, 658, 658, 658, 656, 657, + 809, 827, 820, 823, 794, 793, 792, 791, 828, 659, + 821, 824, 660, 660, 660, 660, 660, 660, 660, 820, + 823, 830, 827, 830, 833, 833, 790, 821, 824, 828, + + 789, 788, 834, 834, 56, 56, 56, 56, 56, 84, + 84, 84, 163, 163, 163, 171, 171, 255, 787, 255, + 255, 255, 621, 621, 690, 690, 784, 783, 782, 781, + 780, 779, 778, 777, 773, 772, 771, 770, 769, 768, + 767, 766, 765, 764, 763, 762, 761, 758, 757, 756, + 755, 754, 753, 752, 751, 750, 749, 748, 747, 746, + 745, 744, 743, 742, 741, 740, 739, 738, 737, 736, + 735, 734, 733, 732, 731, 730, 729, 728, 727, 726, + 725, 724, 723, 722, 721, 720, 719, 718, 717, 716, + 715, 714, 713, 712, 711, 710, 709, 708, 707, 706, + + 705, 704, 703, 702, 701, 700, 699, 698, 697, 696, + 695, 694, 693, 692, 691, 689, 688, 687, 686, 685, + 684, 683, 682, 681, 680, 679, 678, 677, 676, 675, + 674, 673, 672, 671, 670, 669, 668, 667, 666, 665, + 664, 663, 662, 661, 655, 654, 653, 652, 651, 650, + 649, 648, 647, 646, 645, 644, 638, 637, 636, 635, + 634, 633, 632, 631, 630, 629, 628, 627, 626, 625, + 618, 613, 612, 611, 610, 609, 608, 607, 606, 605, + 604, 603, 602, 601, 600, 595, 594, 593, 592, 591, + 590, 589, 588, 587, 586, 585, 584, 583, 582, 581, + + 575, 574, 573, 572, 571, 570, 569, 568, 567, 566, + 560, 559, 558, 557, 556, 555, 554, 553, 552, 551, + 550, 545, 544, 543, 542, 541, 540, 539, 538, 537, + 536, 535, 532, 531, 530, 529, 528, 527, 521, 520, + 519, 518, 517, 516, 515, 514, 513, 512, 511, 510, + 509, 508, 507, 506, 505, 504, 498, 497, 496, 495, + 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, + 484, 483, 482, 481, 480, 479, 478, 477, 476, 475, + 474, 473, 472, 471, 470, 469, 468, 467, 466, 465, + 464, 463, 453, 452, 451, 450, 449, 443, 442, 441, + + 440, 439, 438, 437, 436, 435, 434, 433, 432, 431, + 430, 429, 428, 427, 426, 422, 421, 420, 419, 418, + 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, + 407, 406, 405, 404, 403, 402, 401, 400, 399, 398, + 397, 396, 395, 394, 393, 392, 388, 387, 386, 385, + 384, 383, 382, 381, 377, 373, 372, 371, 370, 369, + 365, 364, 363, 362, 361, 360, 359, 358, 354, 353, + 352, 349, 348, 347, 346, 345, 344, 343, 339, 338, + 337, 336, 335, 332, 331, 330, 329, 328, 327, 326, + 325, 324, 323, 322, 321, 320, 319, 318, 317, 316, + + 315, 314, 313, 312, 311, 310, 309, 308, 304, 303, + 302, 301, 300, 299, 298, 297, 296, 295, 294, 293, + 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, + 282, 281, 280, 279, 278, 277, 276, 273, 272, 271, + 268, 267, 266, 265, 264, 254, 253, 252, 251, 250, + 247, 246, 245, 238, 237, 236, 235, 234, 233, 230, + 229, 228, 227, 226, 225, 224, 223, 220, 217, 216, + 215, 212, 211, 210, 204, 203, 202, 201, 200, 199, + 198, 197, 192, 191, 190, 189, 188, 187, 186, 185, + 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, + + 172, 161, 149, 125, 109, 81, 69, 63, 60, 59, + 835, 57, 57, 7, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835 } ; -static yyconst flex_int16_t yy_chk[1255] = +static yyconst flex_int16_t yy_chk[1283] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -835,138 +853,141 @@ static yyconst flex_int16_t yy_chk[1255] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 9, 803, 9, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 9, + 791, 9, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 13, 15, 801, 16, 17, - 17, 17, 17, 17, 17, 17, 21, 21, 71, 15, - 16, 25, 13, 19, 46, 19, 19, 19, 19, 19, - 19, 19, 23, 23, 25, 26, 27, 800, 27, 33, - 19, 19, 27, 71, 28, 19, 19, 33, 28, 35, - 26, 26, 36, 19, 19, 28, 36, 29, 28, 33, - 50, 29, 50, 35, 46, 96, 96, 29, 19, 795, - - 37, 19, 20, 29, 20, 20, 20, 20, 20, 20, - 20, 30, 135, 30, 37, 31, 58, 40, 58, 20, - 20, 39, 30, 31, 20, 105, 31, 40, 135, 31, - 106, 34, 20, 20, 34, 31, 105, 39, 34, 34, - 39, 41, 42, 34, 106, 42, 34, 20, 41, 41, - 160, 44, 160, 41, 42, 44, 48, 48, 43, 41, - 41, 42, 41, 43, 47, 44, 47, 43, 47, 126, - 43, 53, 53, 53, 53, 53, 53, 53, 68, 68, - 70, 70, 120, 126, 142, 142, 148, 143, 124, 148, - 120, 68, 68, 70, 70, 124, 143, 116, 48, 144, - - 116, 116, 153, 153, 116, 48, 116, 144, 152, 48, - 152, 794, 152, 180, 48, 72, 793, 72, 72, 72, - 72, 72, 72, 72, 154, 154, 171, 180, 166, 166, - 73, 73, 72, 72, 73, 73, 73, 73, 73, 73, - 73, 166, 166, 784, 153, 72, 72, 184, 184, 171, - 241, 153, 215, 215, 215, 153, 247, 247, 247, 241, - 153, 268, 268, 268, 621, 621, 154, 279, 279, 279, - 288, 288, 288, 154, 292, 292, 292, 154, 301, 301, - 301, 754, 154, 162, 162, 162, 162, 162, 162, 162, - 164, 164, 655, 655, 164, 164, 164, 164, 164, 164, - - 164, 167, 167, 688, 688, 167, 167, 167, 167, 167, - 167, 167, 169, 169, 169, 169, 169, 169, 169, 170, - 170, 170, 170, 170, 170, 170, 256, 256, 256, 256, - 256, 256, 256, 754, 783, 170, 257, 257, 257, 257, - 257, 257, 257, 338, 338, 338, 782, 781, 170, 258, - 258, 780, 257, 258, 258, 258, 258, 258, 258, 258, - 393, 393, 393, 777, 776, 257, 260, 260, 260, 260, - 260, 260, 260, 261, 261, 261, 261, 261, 261, 261, - 350, 350, 350, 350, 350, 350, 350, 775, 774, 261, - 351, 351, 351, 351, 351, 351, 351, 382, 382, 382, - - 581, 773, 261, 394, 394, 394, 351, 772, 382, 382, - 395, 395, 395, 443, 443, 443, 483, 483, 483, 351, - 490, 504, 505, 771, 443, 443, 770, 483, 483, 504, - 505, 519, 519, 519, 490, 490, 490, 490, 490, 490, - 490, 581, 519, 519, 533, 533, 534, 534, 765, 763, - 762, 768, 581, 619, 619, 554, 554, 554, 576, 576, - 534, 534, 534, 534, 534, 534, 534, 554, 573, 573, - 573, 790, 576, 576, 576, 576, 576, 576, 576, 533, - 573, 578, 578, 739, 760, 605, 757, 756, 619, 755, - 739, 580, 580, 605, 606, 578, 578, 578, 578, 578, - - 578, 606, 606, 768, 533, 580, 580, 580, 580, 580, - 580, 580, 753, 619, 620, 620, 769, 778, 786, 753, - 779, 657, 657, 790, 769, 778, 786, 779, 620, 620, - 620, 620, 620, 620, 620, 657, 657, 657, 657, 657, - 657, 659, 659, 787, 798, 789, 796, 752, 751, 750, - 749, 787, 789, 748, 796, 659, 659, 659, 659, 659, - 659, 659, 799, 804, 807, 808, 810, 747, 746, 745, - 799, 804, 807, 808, 810, 744, 743, 742, 741, 740, - 738, 737, 734, 731, 730, 729, 728, 727, 725, 724, - 722, 720, 717, 716, 714, 713, 798, 813, 813, 813, - - 813, 813, 813, 813, 813, 814, 814, 814, 814, 814, - 815, 815, 815, 815, 815, 816, 816, 817, 817, 818, - 818, 818, 819, 819, 711, 819, 819, 819, 819, 819, - 820, 820, 820, 710, 709, 708, 820, 821, 821, 821, - 822, 822, 822, 707, 706, 705, 822, 823, 823, 823, - 704, 703, 702, 701, 699, 698, 697, 696, 695, 694, - 692, 691, 690, 689, 687, 686, 685, 684, 683, 682, - 681, 680, 679, 678, 677, 676, 675, 674, 673, 672, - 671, 670, 668, 667, 666, 665, 664, 663, 662, 661, - 660, 653, 651, 650, 648, 647, 646, 645, 644, 643, - - 642, 641, 640, 639, 638, 637, 636, 634, 633, 632, - 631, 630, 629, 628, 626, 625, 624, 623, 622, 618, - 617, 616, 615, 614, 613, 612, 611, 610, 609, 608, - 607, 601, 599, 598, 597, 596, 592, 591, 590, 589, - 588, 587, 586, 585, 584, 575, 571, 570, 568, 567, - 565, 564, 563, 562, 561, 560, 559, 558, 557, 555, - 553, 552, 551, 550, 549, 548, 547, 546, 545, 544, - 542, 541, 537, 536, 535, 532, 531, 529, 528, 526, - 525, 524, 523, 522, 520, 518, 517, 516, 515, 514, - 513, 511, 510, 509, 508, 507, 503, 502, 501, 500, - - 499, 498, 495, 494, 493, 492, 491, 489, 488, 487, - 486, 485, 484, 482, 481, 474, 473, 470, 469, 466, - 465, 464, 463, 452, 451, 450, 448, 447, 446, 445, - 444, 441, 439, 438, 437, 435, 434, 432, 431, 430, - 429, 427, 426, 421, 420, 418, 417, 416, 415, 414, - 413, 412, 411, 410, 409, 407, 406, 405, 404, 403, - 402, 401, 400, 399, 398, 397, 396, 392, 388, 387, - 386, 383, 381, 371, 369, 365, 364, 363, 362, 360, - 358, 353, 352, 349, 348, 347, 346, 345, 344, 339, - 337, 336, 335, 334, 333, 331, 330, 327, 326, 325, - - 324, 323, 322, 321, 320, 319, 318, 317, 316, 315, - 314, 313, 312, 311, 310, 309, 308, 307, 306, 305, - 302, 300, 299, 298, 297, 296, 295, 294, 293, 291, - 287, 285, 284, 283, 282, 278, 277, 276, 275, 274, - 273, 272, 271, 267, 265, 264, 254, 253, 252, 251, - 250, 249, 248, 246, 245, 244, 243, 242, 240, 239, - 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, - 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, - 218, 217, 216, 214, 213, 212, 211, 210, 209, 208, - 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, - - 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, - 186, 185, 183, 182, 181, 179, 178, 177, 176, 174, - 159, 158, 157, 156, 149, 147, 146, 145, 141, 140, - 139, 138, 137, 136, 134, 133, 132, 131, 130, 129, - 128, 127, 125, 123, 122, 121, 119, 118, 117, 115, - 114, 112, 111, 110, 109, 108, 107, 104, 103, 102, - 101, 100, 99, 98, 97, 95, 94, 93, 92, 91, - 90, 89, 88, 87, 83, 79, 52, 45, 38, 32, - 22, 18, 14, 12, 11, 7, 6, 5, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812, 812, 812, 812, 812, 812, 812, - 812, 812, 812, 812 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 13, 15, 792, 16, 17, 17, 17, 17, 17, + 17, 17, 21, 21, 25, 15, 16, 26, 13, 19, + 35, 19, 19, 19, 19, 19, 19, 19, 23, 23, + 25, 36, 26, 26, 35, 36, 19, 19, 71, 30, + 27, 30, 27, 28, 19, 19, 27, 28, 37, 39, + 30, 758, 19, 19, 28, 143, 29, 28, 96, 96, + + 29, 33, 37, 71, 143, 39, 29, 19, 39, 33, + 19, 20, 29, 20, 20, 20, 20, 20, 20, 20, + 40, 33, 47, 31, 47, 794, 47, 46, 20, 20, + 40, 31, 48, 48, 31, 106, 20, 31, 42, 34, + 758, 42, 34, 31, 20, 20, 34, 34, 41, 106, + 42, 34, 802, 43, 34, 41, 41, 42, 43, 20, + 41, 50, 43, 50, 44, 43, 41, 41, 44, 41, + 46, 58, 105, 58, 68, 68, 135, 48, 44, 120, + 142, 142, 124, 105, 48, 70, 70, 120, 48, 124, + 68, 68, 135, 48, 53, 53, 53, 53, 53, 53, + + 53, 70, 70, 72, 144, 72, 72, 72, 72, 72, + 72, 72, 144, 148, 803, 126, 148, 804, 73, 73, + 72, 72, 73, 73, 73, 73, 73, 73, 73, 126, + 805, 116, 153, 153, 116, 116, 72, 72, 116, 152, + 116, 152, 810, 152, 154, 154, 160, 811, 160, 162, + 162, 162, 162, 162, 162, 162, 164, 164, 166, 166, + 164, 164, 164, 164, 164, 164, 164, 169, 169, 169, + 169, 169, 169, 169, 166, 166, 171, 153, 180, 184, + 184, 215, 215, 215, 153, 241, 813, 504, 153, 154, + 776, 505, 180, 153, 241, 814, 154, 504, 776, 171, + + 154, 505, 167, 167, 818, 154, 167, 167, 167, 167, + 167, 167, 167, 170, 170, 170, 170, 170, 170, 170, + 247, 247, 247, 268, 268, 268, 279, 279, 279, 170, + 256, 256, 256, 256, 256, 256, 256, 257, 257, 257, + 257, 257, 257, 257, 786, 170, 288, 288, 288, 822, + 258, 258, 786, 257, 258, 258, 258, 258, 258, 258, + 258, 260, 260, 260, 260, 260, 260, 260, 825, 257, + 261, 261, 261, 261, 261, 261, 261, 292, 292, 292, + 301, 301, 301, 338, 338, 338, 261, 350, 350, 350, + 350, 350, 350, 350, 351, 351, 351, 351, 351, 351, + + 351, 795, 261, 382, 382, 382, 393, 393, 393, 795, + 351, 394, 394, 394, 382, 382, 395, 395, 395, 443, + 443, 443, 483, 483, 483, 490, 351, 830, 605, 831, + 443, 443, 839, 483, 483, 519, 519, 519, 605, 490, + 490, 490, 490, 490, 490, 490, 519, 519, 533, 533, + 606, 621, 621, 796, 534, 534, 656, 656, 760, 606, + 606, 796, 533, 533, 533, 533, 533, 533, 534, 534, + 534, 534, 534, 534, 534, 554, 554, 554, 573, 573, + 573, 576, 576, 690, 690, 581, 533, 554, 578, 578, + 573, 775, 799, 840, 790, 576, 576, 576, 576, 576, + + 576, 576, 578, 578, 578, 578, 578, 578, 580, 580, + 806, 533, 744, 760, 759, 808, 619, 619, 806, 744, + 581, 759, 580, 580, 580, 580, 580, 580, 580, 581, + 619, 619, 619, 619, 619, 619, 787, 798, 789, 788, + 581, 620, 620, 787, 798, 809, 775, 799, 658, 658, + 828, 785, 829, 809, 619, 620, 620, 620, 620, 620, + 620, 620, 658, 658, 658, 658, 658, 658, 660, 660, + 808, 826, 815, 819, 784, 783, 782, 781, 826, 619, + 815, 819, 660, 660, 660, 660, 660, 660, 660, 820, + 823, 828, 827, 829, 832, 833, 780, 820, 823, 827, + + 779, 778, 832, 833, 836, 836, 836, 836, 836, 837, + 837, 837, 838, 838, 838, 841, 841, 842, 777, 842, + 842, 842, 843, 843, 844, 844, 774, 771, 769, 768, + 766, 763, 762, 761, 757, 756, 755, 754, 753, 752, + 751, 750, 749, 748, 747, 746, 745, 743, 742, 741, + 738, 735, 734, 733, 732, 731, 729, 728, 726, 724, + 721, 720, 719, 717, 716, 714, 713, 712, 711, 710, + 709, 708, 707, 706, 705, 704, 702, 701, 700, 699, + 698, 697, 695, 694, 693, 692, 691, 689, 688, 687, + 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, + + 676, 675, 674, 673, 672, 670, 669, 668, 667, 666, + 665, 664, 663, 662, 661, 654, 652, 651, 649, 648, + 647, 646, 645, 644, 643, 642, 641, 640, 639, 638, + 637, 635, 634, 633, 632, 631, 630, 629, 627, 626, + 625, 624, 623, 622, 618, 617, 616, 615, 614, 613, + 612, 611, 610, 609, 608, 607, 601, 599, 598, 597, + 596, 592, 591, 590, 589, 588, 587, 586, 585, 584, + 575, 571, 570, 568, 567, 565, 564, 563, 562, 561, + 560, 559, 558, 557, 555, 553, 552, 551, 550, 549, + 548, 547, 546, 545, 544, 542, 541, 537, 536, 535, + + 532, 531, 529, 528, 526, 525, 524, 523, 522, 520, + 518, 517, 516, 515, 514, 513, 511, 510, 509, 508, + 507, 503, 502, 501, 500, 499, 498, 495, 494, 493, + 492, 491, 489, 488, 487, 486, 485, 484, 482, 481, + 474, 473, 470, 469, 466, 465, 464, 463, 452, 451, + 450, 448, 447, 446, 445, 444, 441, 439, 438, 437, + 435, 434, 432, 431, 430, 429, 427, 426, 421, 420, + 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, + 407, 406, 405, 404, 403, 402, 401, 400, 399, 398, + 397, 396, 392, 388, 387, 386, 383, 381, 371, 369, + + 365, 364, 363, 362, 360, 358, 353, 352, 349, 348, + 347, 346, 345, 344, 339, 337, 336, 335, 334, 333, + 331, 330, 327, 326, 325, 324, 323, 322, 321, 320, + 319, 318, 317, 316, 315, 314, 313, 312, 311, 310, + 309, 308, 307, 306, 305, 302, 300, 299, 298, 297, + 296, 295, 294, 293, 291, 287, 285, 284, 283, 282, + 278, 277, 276, 275, 274, 273, 272, 271, 267, 265, + 264, 254, 253, 252, 251, 250, 249, 248, 246, 245, + 244, 243, 242, 240, 239, 238, 237, 236, 235, 234, + 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, + + 223, 222, 221, 220, 219, 218, 217, 216, 214, 213, + 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, + 202, 201, 200, 199, 198, 196, 195, 194, 193, 192, + 191, 190, 189, 188, 187, 186, 185, 183, 182, 181, + 179, 178, 177, 176, 174, 159, 158, 157, 156, 149, + 147, 146, 145, 141, 140, 139, 138, 137, 136, 134, + 133, 132, 131, 130, 129, 128, 127, 125, 123, 122, + 121, 119, 118, 117, 115, 114, 112, 111, 110, 109, + 108, 107, 104, 103, 102, 101, 100, 99, 98, 97, + 95, 94, 93, 92, 91, 90, 89, 88, 87, 83, + + 79, 52, 45, 38, 32, 22, 18, 14, 12, 11, + 7, 6, 5, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, + 835, 835 } ; /* The intent behind this definition is that it'll catch @@ -1055,7 +1076,7 @@ static yyconst flex_int16_t yy_chk[1255] = */ #define ES yyextra->es_shader -#line 1059 "glsl_lexer.cpp" +#line 1080 "glsl_lexer.cpp" #define INITIAL 0 #define PP 1 @@ -1182,7 +1203,12 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1201,7 +1227,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1292,7 +1318,7 @@ YY_DECL #line 95 "glsl_lexer.lpp" -#line 1296 "glsl_lexer.cpp" +#line 1322 "glsl_lexer.cpp" yylval = yylval_param; @@ -1350,13 +1376,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 813 ) + if ( yy_current_state >= 836 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 812 ); + while ( yy_current_state != 835 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1478,435 +1504,443 @@ YY_RULE_SETUP case 11: YY_RULE_SETUP #line 148 "glsl_lexer.lpp" -{ BEGIN PRAGMA; } +{ + BEGIN PP; + return PRAGMA_INVARIANT_ALL; + } YY_BREAK case 12: -/* rule 12 can match eol */ YY_RULE_SETUP -#line 150 "glsl_lexer.lpp" -{ BEGIN 0; yylineno++; yycolumn = 0; } +#line 152 "glsl_lexer.lpp" +{ BEGIN PRAGMA; } YY_BREAK case 13: +/* rule 13 can match eol */ YY_RULE_SETUP -#line 151 "glsl_lexer.lpp" -{ } +#line 154 "glsl_lexer.lpp" +{ BEGIN 0; yylineno++; yycolumn = 0; } YY_BREAK case 14: YY_RULE_SETUP -#line 153 "glsl_lexer.lpp" +#line 155 "glsl_lexer.lpp" { } YY_BREAK case 15: YY_RULE_SETUP -#line 154 "glsl_lexer.lpp" +#line 157 "glsl_lexer.lpp" { } YY_BREAK case 16: YY_RULE_SETUP -#line 155 "glsl_lexer.lpp" -return COLON; +#line 158 "glsl_lexer.lpp" +{ } YY_BREAK case 17: YY_RULE_SETUP -#line 156 "glsl_lexer.lpp" -{ - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } +#line 159 "glsl_lexer.lpp" +return COLON; YY_BREAK case 18: YY_RULE_SETUP #line 160 "glsl_lexer.lpp" { - yylval->n = strtol(yytext, NULL, 10); - return INTCONSTANT; + yylval->identifier = strdup(yytext); + return IDENTIFIER; } YY_BREAK case 19: -/* rule 19 can match eol */ YY_RULE_SETUP #line 164 "glsl_lexer.lpp" -{ BEGIN 0; yylineno++; yycolumn = 0; return EOL; } +{ + yylval->n = strtol(yytext, NULL, 10); + return INTCONSTANT; + } YY_BREAK case 20: /* rule 20 can match eol */ YY_RULE_SETUP -#line 166 "glsl_lexer.lpp" -{ yylineno++; yycolumn = 0; } +#line 168 "glsl_lexer.lpp" +{ BEGIN 0; yylineno++; yycolumn = 0; return EOL; } YY_BREAK case 21: +/* rule 21 can match eol */ YY_RULE_SETUP -#line 168 "glsl_lexer.lpp" -return ATTRIBUTE; +#line 170 "glsl_lexer.lpp" +{ yylineno++; yycolumn = 0; } YY_BREAK case 22: YY_RULE_SETUP -#line 169 "glsl_lexer.lpp" -return CONST_TOK; +#line 172 "glsl_lexer.lpp" +return ATTRIBUTE; YY_BREAK case 23: YY_RULE_SETUP -#line 170 "glsl_lexer.lpp" -return BOOL_TOK; +#line 173 "glsl_lexer.lpp" +return CONST_TOK; YY_BREAK case 24: YY_RULE_SETUP -#line 171 "glsl_lexer.lpp" -return FLOAT_TOK; +#line 174 "glsl_lexer.lpp" +return BOOL_TOK; YY_BREAK case 25: YY_RULE_SETUP -#line 172 "glsl_lexer.lpp" -return INT_TOK; +#line 175 "glsl_lexer.lpp" +return FLOAT_TOK; YY_BREAK case 26: YY_RULE_SETUP -#line 173 "glsl_lexer.lpp" -KEYWORD(130, 130, UINT_TOK); +#line 176 "glsl_lexer.lpp" +return INT_TOK; YY_BREAK case 27: YY_RULE_SETUP -#line 175 "glsl_lexer.lpp" -return BREAK; +#line 177 "glsl_lexer.lpp" +KEYWORD(130, 130, UINT_TOK); YY_BREAK case 28: YY_RULE_SETUP -#line 176 "glsl_lexer.lpp" -return CONTINUE; +#line 179 "glsl_lexer.lpp" +return BREAK; YY_BREAK case 29: YY_RULE_SETUP -#line 177 "glsl_lexer.lpp" -return DO; +#line 180 "glsl_lexer.lpp" +return CONTINUE; YY_BREAK case 30: YY_RULE_SETUP -#line 178 "glsl_lexer.lpp" -return WHILE; +#line 181 "glsl_lexer.lpp" +return DO; YY_BREAK case 31: YY_RULE_SETUP -#line 179 "glsl_lexer.lpp" -return ELSE; +#line 182 "glsl_lexer.lpp" +return WHILE; YY_BREAK case 32: YY_RULE_SETUP -#line 180 "glsl_lexer.lpp" -return FOR; +#line 183 "glsl_lexer.lpp" +return ELSE; YY_BREAK case 33: YY_RULE_SETUP -#line 181 "glsl_lexer.lpp" -return IF; +#line 184 "glsl_lexer.lpp" +return FOR; YY_BREAK case 34: YY_RULE_SETUP -#line 182 "glsl_lexer.lpp" -return DISCARD; +#line 185 "glsl_lexer.lpp" +return IF; YY_BREAK case 35: YY_RULE_SETUP -#line 183 "glsl_lexer.lpp" -return RETURN; +#line 186 "glsl_lexer.lpp" +return DISCARD; YY_BREAK case 36: YY_RULE_SETUP -#line 185 "glsl_lexer.lpp" -return BVEC2; +#line 187 "glsl_lexer.lpp" +return RETURN; YY_BREAK case 37: YY_RULE_SETUP -#line 186 "glsl_lexer.lpp" -return BVEC3; +#line 189 "glsl_lexer.lpp" +return BVEC2; YY_BREAK case 38: YY_RULE_SETUP -#line 187 "glsl_lexer.lpp" -return BVEC4; +#line 190 "glsl_lexer.lpp" +return BVEC3; YY_BREAK case 39: YY_RULE_SETUP -#line 188 "glsl_lexer.lpp" -return IVEC2; +#line 191 "glsl_lexer.lpp" +return BVEC4; YY_BREAK case 40: YY_RULE_SETUP -#line 189 "glsl_lexer.lpp" -return IVEC3; +#line 192 "glsl_lexer.lpp" +return IVEC2; YY_BREAK case 41: YY_RULE_SETUP -#line 190 "glsl_lexer.lpp" -return IVEC4; +#line 193 "glsl_lexer.lpp" +return IVEC3; YY_BREAK case 42: YY_RULE_SETUP -#line 191 "glsl_lexer.lpp" -KEYWORD(130, 130, UVEC2); +#line 194 "glsl_lexer.lpp" +return IVEC4; YY_BREAK case 43: YY_RULE_SETUP -#line 192 "glsl_lexer.lpp" -KEYWORD(130, 130, UVEC3); +#line 195 "glsl_lexer.lpp" +KEYWORD(130, 130, UVEC2); YY_BREAK case 44: YY_RULE_SETUP -#line 193 "glsl_lexer.lpp" -KEYWORD(130, 130, UVEC4); +#line 196 "glsl_lexer.lpp" +KEYWORD(130, 130, UVEC3); YY_BREAK case 45: YY_RULE_SETUP -#line 194 "glsl_lexer.lpp" -return VEC2; +#line 197 "glsl_lexer.lpp" +KEYWORD(130, 130, UVEC4); YY_BREAK case 46: YY_RULE_SETUP -#line 195 "glsl_lexer.lpp" -return VEC3; +#line 198 "glsl_lexer.lpp" +return VEC2; YY_BREAK case 47: YY_RULE_SETUP -#line 196 "glsl_lexer.lpp" -return VEC4; +#line 199 "glsl_lexer.lpp" +return VEC3; YY_BREAK case 48: YY_RULE_SETUP -#line 197 "glsl_lexer.lpp" -return MAT2X2; +#line 200 "glsl_lexer.lpp" +return VEC4; YY_BREAK case 49: YY_RULE_SETUP -#line 198 "glsl_lexer.lpp" -return MAT3X3; +#line 201 "glsl_lexer.lpp" +return MAT2X2; YY_BREAK case 50: YY_RULE_SETUP -#line 199 "glsl_lexer.lpp" -return MAT4X4; +#line 202 "glsl_lexer.lpp" +return MAT3X3; YY_BREAK case 51: YY_RULE_SETUP -#line 200 "glsl_lexer.lpp" -KEYWORD(120, 120, MAT2X2); +#line 203 "glsl_lexer.lpp" +return MAT4X4; YY_BREAK case 52: YY_RULE_SETUP -#line 201 "glsl_lexer.lpp" -KEYWORD(120, 120, MAT2X3); +#line 204 "glsl_lexer.lpp" +KEYWORD(120, 120, MAT2X2); YY_BREAK case 53: YY_RULE_SETUP -#line 202 "glsl_lexer.lpp" -KEYWORD(120, 120, MAT2X4); +#line 205 "glsl_lexer.lpp" +KEYWORD(120, 120, MAT2X3); YY_BREAK case 54: YY_RULE_SETUP -#line 203 "glsl_lexer.lpp" -KEYWORD(120, 120, MAT3X2); +#line 206 "glsl_lexer.lpp" +KEYWORD(120, 120, MAT2X4); YY_BREAK case 55: YY_RULE_SETUP -#line 204 "glsl_lexer.lpp" -KEYWORD(120, 120, MAT3X3); +#line 207 "glsl_lexer.lpp" +KEYWORD(120, 120, MAT3X2); YY_BREAK case 56: YY_RULE_SETUP -#line 205 "glsl_lexer.lpp" -KEYWORD(120, 120, MAT3X4); +#line 208 "glsl_lexer.lpp" +KEYWORD(120, 120, MAT3X3); YY_BREAK case 57: YY_RULE_SETUP -#line 206 "glsl_lexer.lpp" -KEYWORD(120, 120, MAT4X2); +#line 209 "glsl_lexer.lpp" +KEYWORD(120, 120, MAT3X4); YY_BREAK case 58: YY_RULE_SETUP -#line 207 "glsl_lexer.lpp" -KEYWORD(120, 120, MAT4X3); +#line 210 "glsl_lexer.lpp" +KEYWORD(120, 120, MAT4X2); YY_BREAK case 59: YY_RULE_SETUP -#line 208 "glsl_lexer.lpp" -KEYWORD(120, 120, MAT4X4); +#line 211 "glsl_lexer.lpp" +KEYWORD(120, 120, MAT4X3); YY_BREAK case 60: YY_RULE_SETUP -#line 210 "glsl_lexer.lpp" -return IN_TOK; +#line 212 "glsl_lexer.lpp" +KEYWORD(120, 120, MAT4X4); YY_BREAK case 61: YY_RULE_SETUP -#line 211 "glsl_lexer.lpp" -return OUT_TOK; +#line 214 "glsl_lexer.lpp" +return IN_TOK; YY_BREAK case 62: YY_RULE_SETUP -#line 212 "glsl_lexer.lpp" -return INOUT_TOK; +#line 215 "glsl_lexer.lpp" +return OUT_TOK; YY_BREAK case 63: YY_RULE_SETUP -#line 213 "glsl_lexer.lpp" -return UNIFORM; +#line 216 "glsl_lexer.lpp" +return INOUT_TOK; YY_BREAK case 64: YY_RULE_SETUP -#line 214 "glsl_lexer.lpp" -return VARYING; +#line 217 "glsl_lexer.lpp" +return UNIFORM; YY_BREAK case 65: YY_RULE_SETUP -#line 215 "glsl_lexer.lpp" -KEYWORD(120, 120, CENTROID); +#line 218 "glsl_lexer.lpp" +return VARYING; YY_BREAK case 66: YY_RULE_SETUP -#line 216 "glsl_lexer.lpp" -KEYWORD(120 || ES, 120 || ES, INVARIANT); +#line 219 "glsl_lexer.lpp" +KEYWORD(120, 120, CENTROID); YY_BREAK case 67: YY_RULE_SETUP -#line 217 "glsl_lexer.lpp" -KEYWORD(130 || ES, 130, FLAT); +#line 220 "glsl_lexer.lpp" +KEYWORD(120 || ES, 120 || ES, INVARIANT); YY_BREAK case 68: YY_RULE_SETUP -#line 218 "glsl_lexer.lpp" -KEYWORD(130, 130, SMOOTH); +#line 221 "glsl_lexer.lpp" +KEYWORD(130 || ES, 130, FLAT); YY_BREAK case 69: YY_RULE_SETUP -#line 219 "glsl_lexer.lpp" -KEYWORD(130, 130, NOPERSPECTIVE); +#line 222 "glsl_lexer.lpp" +KEYWORD(130, 130, SMOOTH); YY_BREAK case 70: YY_RULE_SETUP -#line 221 "glsl_lexer.lpp" -return SAMPLER1D; +#line 223 "glsl_lexer.lpp" +KEYWORD(130, 130, NOPERSPECTIVE); YY_BREAK case 71: YY_RULE_SETUP -#line 222 "glsl_lexer.lpp" -return SAMPLER2D; +#line 225 "glsl_lexer.lpp" +return SAMPLER1D; YY_BREAK case 72: YY_RULE_SETUP -#line 223 "glsl_lexer.lpp" -return SAMPLER3D; +#line 226 "glsl_lexer.lpp" +return SAMPLER2D; YY_BREAK case 73: YY_RULE_SETUP -#line 224 "glsl_lexer.lpp" -return SAMPLERCUBE; +#line 227 "glsl_lexer.lpp" +return SAMPLER3D; YY_BREAK case 74: YY_RULE_SETUP -#line 225 "glsl_lexer.lpp" -KEYWORD(130, 130, SAMPLER1DARRAY); +#line 228 "glsl_lexer.lpp" +return SAMPLERCUBE; YY_BREAK case 75: YY_RULE_SETUP -#line 226 "glsl_lexer.lpp" -KEYWORD(130, 130, SAMPLER2DARRAY); +#line 229 "glsl_lexer.lpp" +KEYWORD(130, 130, SAMPLER1DARRAY); YY_BREAK case 76: YY_RULE_SETUP -#line 227 "glsl_lexer.lpp" -return SAMPLER1DSHADOW; +#line 230 "glsl_lexer.lpp" +KEYWORD(130, 130, SAMPLER2DARRAY); YY_BREAK case 77: YY_RULE_SETUP -#line 228 "glsl_lexer.lpp" -return SAMPLER2DSHADOW; +#line 231 "glsl_lexer.lpp" +return SAMPLER1DSHADOW; YY_BREAK case 78: YY_RULE_SETUP -#line 229 "glsl_lexer.lpp" -KEYWORD(130, 130, SAMPLERCUBESHADOW); +#line 232 "glsl_lexer.lpp" +return SAMPLER2DSHADOW; YY_BREAK case 79: YY_RULE_SETUP -#line 230 "glsl_lexer.lpp" -KEYWORD(130, 130, SAMPLER1DARRAYSHADOW); +#line 233 "glsl_lexer.lpp" +KEYWORD(130, 130, SAMPLERCUBESHADOW); YY_BREAK case 80: YY_RULE_SETUP -#line 231 "glsl_lexer.lpp" -KEYWORD(130, 130, SAMPLER2DARRAYSHADOW); +#line 234 "glsl_lexer.lpp" +KEYWORD(130, 130, SAMPLER1DARRAYSHADOW); YY_BREAK case 81: YY_RULE_SETUP -#line 232 "glsl_lexer.lpp" -KEYWORD(130, 130, ISAMPLER1D); +#line 235 "glsl_lexer.lpp" +KEYWORD(130, 130, SAMPLER2DARRAYSHADOW); YY_BREAK case 82: YY_RULE_SETUP -#line 233 "glsl_lexer.lpp" -KEYWORD(130, 130, ISAMPLER2D); +#line 236 "glsl_lexer.lpp" +KEYWORD(130, 130, ISAMPLER1D); YY_BREAK case 83: YY_RULE_SETUP -#line 234 "glsl_lexer.lpp" -KEYWORD(130, 130, ISAMPLER3D); +#line 237 "glsl_lexer.lpp" +KEYWORD(130, 130, ISAMPLER2D); YY_BREAK case 84: YY_RULE_SETUP -#line 235 "glsl_lexer.lpp" -KEYWORD(130, 130, ISAMPLERCUBE); +#line 238 "glsl_lexer.lpp" +KEYWORD(130, 130, ISAMPLER3D); YY_BREAK case 85: YY_RULE_SETUP -#line 236 "glsl_lexer.lpp" -KEYWORD(130, 130, ISAMPLER1DARRAY); +#line 239 "glsl_lexer.lpp" +KEYWORD(130, 130, ISAMPLERCUBE); YY_BREAK case 86: YY_RULE_SETUP -#line 237 "glsl_lexer.lpp" -KEYWORD(130, 130, ISAMPLER2DARRAY); +#line 240 "glsl_lexer.lpp" +KEYWORD(130, 130, ISAMPLER1DARRAY); YY_BREAK case 87: YY_RULE_SETUP -#line 238 "glsl_lexer.lpp" -KEYWORD(130, 130, USAMPLER1D); +#line 241 "glsl_lexer.lpp" +KEYWORD(130, 130, ISAMPLER2DARRAY); YY_BREAK case 88: YY_RULE_SETUP -#line 239 "glsl_lexer.lpp" -KEYWORD(130, 130, USAMPLER2D); +#line 242 "glsl_lexer.lpp" +KEYWORD(130, 130, USAMPLER1D); YY_BREAK case 89: YY_RULE_SETUP -#line 240 "glsl_lexer.lpp" -KEYWORD(130, 130, USAMPLER3D); +#line 243 "glsl_lexer.lpp" +KEYWORD(130, 130, USAMPLER2D); YY_BREAK case 90: YY_RULE_SETUP -#line 241 "glsl_lexer.lpp" -KEYWORD(130, 130, USAMPLERCUBE); +#line 244 "glsl_lexer.lpp" +KEYWORD(130, 130, USAMPLER3D); YY_BREAK case 91: YY_RULE_SETUP -#line 242 "glsl_lexer.lpp" -KEYWORD(130, 130, USAMPLER1DARRAY); +#line 245 "glsl_lexer.lpp" +KEYWORD(130, 130, USAMPLERCUBE); YY_BREAK case 92: YY_RULE_SETUP -#line 243 "glsl_lexer.lpp" -KEYWORD(130, 130, USAMPLER2DARRAY); +#line 246 "glsl_lexer.lpp" +KEYWORD(130, 130, USAMPLER1DARRAY); YY_BREAK case 93: YY_RULE_SETUP -#line 246 "glsl_lexer.lpp" -return STRUCT; +#line 247 "glsl_lexer.lpp" +KEYWORD(130, 130, USAMPLER2DARRAY); YY_BREAK case 94: YY_RULE_SETUP -#line 247 "glsl_lexer.lpp" -return VOID_TOK; +#line 250 "glsl_lexer.lpp" +return STRUCT; YY_BREAK case 95: YY_RULE_SETUP -#line 249 "glsl_lexer.lpp" +#line 251 "glsl_lexer.lpp" +return VOID_TOK; + YY_BREAK +case 96: +YY_RULE_SETUP +#line 253 "glsl_lexer.lpp" { if ((yyextra->language_version >= 140) || yyextra->ARB_explicit_attrib_location_enable @@ -1918,124 +1952,116 @@ YY_RULE_SETUP } } YY_BREAK -case 96: -YY_RULE_SETUP -#line 260 "glsl_lexer.lpp" -return INC_OP; - YY_BREAK case 97: YY_RULE_SETUP -#line 261 "glsl_lexer.lpp" -return DEC_OP; +#line 264 "glsl_lexer.lpp" +return INC_OP; YY_BREAK case 98: YY_RULE_SETUP -#line 262 "glsl_lexer.lpp" -return LE_OP; +#line 265 "glsl_lexer.lpp" +return DEC_OP; YY_BREAK case 99: YY_RULE_SETUP -#line 263 "glsl_lexer.lpp" -return GE_OP; +#line 266 "glsl_lexer.lpp" +return LE_OP; YY_BREAK case 100: YY_RULE_SETUP -#line 264 "glsl_lexer.lpp" -return EQ_OP; +#line 267 "glsl_lexer.lpp" +return GE_OP; YY_BREAK case 101: YY_RULE_SETUP -#line 265 "glsl_lexer.lpp" -return NE_OP; +#line 268 "glsl_lexer.lpp" +return EQ_OP; YY_BREAK case 102: YY_RULE_SETUP -#line 266 "glsl_lexer.lpp" -return AND_OP; +#line 269 "glsl_lexer.lpp" +return NE_OP; YY_BREAK case 103: YY_RULE_SETUP -#line 267 "glsl_lexer.lpp" -return OR_OP; +#line 270 "glsl_lexer.lpp" +return AND_OP; YY_BREAK case 104: YY_RULE_SETUP -#line 268 "glsl_lexer.lpp" -return XOR_OP; +#line 271 "glsl_lexer.lpp" +return OR_OP; YY_BREAK case 105: YY_RULE_SETUP -#line 269 "glsl_lexer.lpp" -return LEFT_OP; +#line 272 "glsl_lexer.lpp" +return XOR_OP; YY_BREAK case 106: YY_RULE_SETUP -#line 270 "glsl_lexer.lpp" -return RIGHT_OP; +#line 273 "glsl_lexer.lpp" +return LEFT_OP; YY_BREAK case 107: YY_RULE_SETUP -#line 272 "glsl_lexer.lpp" -return MUL_ASSIGN; +#line 274 "glsl_lexer.lpp" +return RIGHT_OP; YY_BREAK case 108: YY_RULE_SETUP -#line 273 "glsl_lexer.lpp" -return DIV_ASSIGN; +#line 276 "glsl_lexer.lpp" +return MUL_ASSIGN; YY_BREAK case 109: YY_RULE_SETUP -#line 274 "glsl_lexer.lpp" -return ADD_ASSIGN; +#line 277 "glsl_lexer.lpp" +return DIV_ASSIGN; YY_BREAK case 110: YY_RULE_SETUP -#line 275 "glsl_lexer.lpp" -return MOD_ASSIGN; +#line 278 "glsl_lexer.lpp" +return ADD_ASSIGN; YY_BREAK case 111: YY_RULE_SETUP -#line 276 "glsl_lexer.lpp" -return LEFT_ASSIGN; +#line 279 "glsl_lexer.lpp" +return MOD_ASSIGN; YY_BREAK case 112: YY_RULE_SETUP -#line 277 "glsl_lexer.lpp" -return RIGHT_ASSIGN; +#line 280 "glsl_lexer.lpp" +return LEFT_ASSIGN; YY_BREAK case 113: YY_RULE_SETUP -#line 278 "glsl_lexer.lpp" -return AND_ASSIGN; +#line 281 "glsl_lexer.lpp" +return RIGHT_ASSIGN; YY_BREAK case 114: YY_RULE_SETUP -#line 279 "glsl_lexer.lpp" -return XOR_ASSIGN; +#line 282 "glsl_lexer.lpp" +return AND_ASSIGN; YY_BREAK case 115: YY_RULE_SETUP -#line 280 "glsl_lexer.lpp" -return OR_ASSIGN; +#line 283 "glsl_lexer.lpp" +return XOR_ASSIGN; YY_BREAK case 116: YY_RULE_SETUP -#line 281 "glsl_lexer.lpp" -return SUB_ASSIGN; +#line 284 "glsl_lexer.lpp" +return OR_ASSIGN; YY_BREAK case 117: YY_RULE_SETUP -#line 283 "glsl_lexer.lpp" -{ - yylval->n = strtol(yytext, NULL, 10); - return IS_UINT ? UINTCONSTANT : INTCONSTANT; - } +#line 285 "glsl_lexer.lpp" +return SUB_ASSIGN; YY_BREAK case 118: YY_RULE_SETUP #line 287 "glsl_lexer.lpp" { - yylval->n = strtol(yytext + 2, NULL, 16); + yylval->n = strtol(yytext, NULL, 10); return IS_UINT ? UINTCONSTANT : INTCONSTANT; } YY_BREAK @@ -2043,16 +2069,16 @@ case 119: YY_RULE_SETUP #line 291 "glsl_lexer.lpp" { - yylval->n = strtol(yytext, NULL, 8); + yylval->n = strtol(yytext + 2, NULL, 16); return IS_UINT ? UINTCONSTANT : INTCONSTANT; } YY_BREAK case 120: YY_RULE_SETUP -#line 296 "glsl_lexer.lpp" +#line 295 "glsl_lexer.lpp" { - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; + yylval->n = strtol(yytext, NULL, 8); + return IS_UINT ? UINTCONSTANT : INTCONSTANT; } YY_BREAK case 121: @@ -2089,426 +2115,434 @@ YY_RULE_SETUP YY_BREAK case 125: YY_RULE_SETUP -#line 317 "glsl_lexer.lpp" +#line 316 "glsl_lexer.lpp" { - yylval->n = 1; - return BOOLCONSTANT; + yylval->real = glsl_strtod(yytext, NULL); + return FLOATCONSTANT; } YY_BREAK case 126: YY_RULE_SETUP #line 321 "glsl_lexer.lpp" +{ + yylval->n = 1; + return BOOLCONSTANT; + } + YY_BREAK +case 127: +YY_RULE_SETUP +#line 325 "glsl_lexer.lpp" { yylval->n = 0; return BOOLCONSTANT; } YY_BREAK /* Reserved words in GLSL 1.10. */ -case 127: +case 128: YY_RULE_SETUP -#line 328 "glsl_lexer.lpp" +#line 332 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, ASM); YY_BREAK -case 128: +case 129: YY_RULE_SETUP -#line 329 "glsl_lexer.lpp" +#line 333 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, CLASS); YY_BREAK -case 129: +case 130: YY_RULE_SETUP -#line 330 "glsl_lexer.lpp" +#line 334 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, UNION); YY_BREAK -case 130: +case 131: YY_RULE_SETUP -#line 331 "glsl_lexer.lpp" +#line 335 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, ENUM); YY_BREAK -case 131: +case 132: YY_RULE_SETUP -#line 332 "glsl_lexer.lpp" +#line 336 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, TYPEDEF); YY_BREAK -case 132: +case 133: YY_RULE_SETUP -#line 333 "glsl_lexer.lpp" +#line 337 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, TEMPLATE); YY_BREAK -case 133: +case 134: YY_RULE_SETUP -#line 334 "glsl_lexer.lpp" +#line 338 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, THIS); YY_BREAK -case 134: +case 135: YY_RULE_SETUP -#line 335 "glsl_lexer.lpp" +#line 339 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, PACKED_TOK); YY_BREAK -case 135: +case 136: YY_RULE_SETUP -#line 336 "glsl_lexer.lpp" +#line 340 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, GOTO); YY_BREAK -case 136: +case 137: YY_RULE_SETUP -#line 337 "glsl_lexer.lpp" +#line 341 "glsl_lexer.lpp" KEYWORD(110 || ES, 130, SWITCH); YY_BREAK -case 137: +case 138: YY_RULE_SETUP -#line 338 "glsl_lexer.lpp" +#line 342 "glsl_lexer.lpp" KEYWORD(110 || ES, 130, DEFAULT); YY_BREAK -case 138: +case 139: YY_RULE_SETUP -#line 339 "glsl_lexer.lpp" +#line 343 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, INLINE_TOK); YY_BREAK -case 139: +case 140: YY_RULE_SETUP -#line 340 "glsl_lexer.lpp" +#line 344 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, NOINLINE); YY_BREAK -case 140: +case 141: YY_RULE_SETUP -#line 341 "glsl_lexer.lpp" +#line 345 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, VOLATILE); YY_BREAK -case 141: +case 142: YY_RULE_SETUP -#line 342 "glsl_lexer.lpp" +#line 346 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, PUBLIC_TOK); YY_BREAK -case 142: +case 143: YY_RULE_SETUP -#line 343 "glsl_lexer.lpp" +#line 347 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, STATIC); YY_BREAK -case 143: +case 144: YY_RULE_SETUP -#line 344 "glsl_lexer.lpp" +#line 348 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, EXTERN); YY_BREAK -case 144: +case 145: YY_RULE_SETUP -#line 345 "glsl_lexer.lpp" +#line 349 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, EXTERNAL); YY_BREAK -case 145: +case 146: YY_RULE_SETUP -#line 346 "glsl_lexer.lpp" +#line 350 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, INTERFACE); YY_BREAK -case 146: +case 147: YY_RULE_SETUP -#line 347 "glsl_lexer.lpp" +#line 351 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, LONG_TOK); YY_BREAK -case 147: +case 148: YY_RULE_SETUP -#line 348 "glsl_lexer.lpp" +#line 352 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, SHORT_TOK); YY_BREAK -case 148: +case 149: YY_RULE_SETUP -#line 349 "glsl_lexer.lpp" +#line 353 "glsl_lexer.lpp" KEYWORD(110 || ES, 400, DOUBLE_TOK); YY_BREAK -case 149: +case 150: YY_RULE_SETUP -#line 350 "glsl_lexer.lpp" +#line 354 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, HALF); YY_BREAK -case 150: +case 151: YY_RULE_SETUP -#line 351 "glsl_lexer.lpp" +#line 355 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, FIXED_TOK); YY_BREAK -case 151: +case 152: YY_RULE_SETUP -#line 352 "glsl_lexer.lpp" +#line 356 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, UNSIGNED); YY_BREAK -case 152: +case 153: YY_RULE_SETUP -#line 353 "glsl_lexer.lpp" +#line 357 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, INPUT_TOK); YY_BREAK -case 153: +case 154: YY_RULE_SETUP -#line 354 "glsl_lexer.lpp" +#line 358 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, OUTPUT); YY_BREAK -case 154: +case 155: YY_RULE_SETUP -#line 355 "glsl_lexer.lpp" +#line 359 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, HVEC2); YY_BREAK -case 155: +case 156: YY_RULE_SETUP -#line 356 "glsl_lexer.lpp" +#line 360 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, HVEC3); YY_BREAK -case 156: +case 157: YY_RULE_SETUP -#line 357 "glsl_lexer.lpp" +#line 361 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, HVEC4); YY_BREAK -case 157: +case 158: YY_RULE_SETUP -#line 358 "glsl_lexer.lpp" +#line 362 "glsl_lexer.lpp" KEYWORD(110 || ES, 400, DVEC2); YY_BREAK -case 158: +case 159: YY_RULE_SETUP -#line 359 "glsl_lexer.lpp" +#line 363 "glsl_lexer.lpp" KEYWORD(110 || ES, 400, DVEC3); YY_BREAK -case 159: +case 160: YY_RULE_SETUP -#line 360 "glsl_lexer.lpp" +#line 364 "glsl_lexer.lpp" KEYWORD(110 || ES, 400, DVEC4); YY_BREAK -case 160: +case 161: YY_RULE_SETUP -#line 361 "glsl_lexer.lpp" +#line 365 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, FVEC2); YY_BREAK -case 161: +case 162: YY_RULE_SETUP -#line 362 "glsl_lexer.lpp" +#line 366 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, FVEC3); YY_BREAK -case 162: +case 163: YY_RULE_SETUP -#line 363 "glsl_lexer.lpp" +#line 367 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, FVEC4); YY_BREAK -case 163: +case 164: YY_RULE_SETUP -#line 364 "glsl_lexer.lpp" +#line 368 "glsl_lexer.lpp" return SAMPLER2DRECT; YY_BREAK -case 164: +case 165: YY_RULE_SETUP -#line 365 "glsl_lexer.lpp" +#line 369 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, SAMPLER3DRECT); YY_BREAK -case 165: +case 166: YY_RULE_SETUP -#line 366 "glsl_lexer.lpp" +#line 370 "glsl_lexer.lpp" return SAMPLER2DRECTSHADOW; YY_BREAK -case 166: +case 167: YY_RULE_SETUP -#line 367 "glsl_lexer.lpp" +#line 371 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, SIZEOF); YY_BREAK -case 167: +case 168: YY_RULE_SETUP -#line 368 "glsl_lexer.lpp" +#line 372 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, CAST); YY_BREAK -case 168: +case 169: YY_RULE_SETUP -#line 369 "glsl_lexer.lpp" +#line 373 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, NAMESPACE); YY_BREAK -case 169: +case 170: YY_RULE_SETUP -#line 370 "glsl_lexer.lpp" +#line 374 "glsl_lexer.lpp" KEYWORD(110 || ES, 999, USING); YY_BREAK /* Additional reserved words in GLSL 1.20. */ -case 170: +case 171: YY_RULE_SETUP -#line 373 "glsl_lexer.lpp" +#line 377 "glsl_lexer.lpp" KEYWORD(120, 130 || ES, LOWP); YY_BREAK -case 171: +case 172: YY_RULE_SETUP -#line 374 "glsl_lexer.lpp" +#line 378 "glsl_lexer.lpp" KEYWORD(120, 130 || ES, MEDIUMP); YY_BREAK -case 172: +case 173: YY_RULE_SETUP -#line 375 "glsl_lexer.lpp" +#line 379 "glsl_lexer.lpp" KEYWORD(120, 130 || ES, HIGHP); YY_BREAK -case 173: +case 174: YY_RULE_SETUP -#line 376 "glsl_lexer.lpp" +#line 380 "glsl_lexer.lpp" KEYWORD(120, 130 || ES, PRECISION); YY_BREAK /* Additional reserved words in GLSL 1.30. */ -case 174: +case 175: YY_RULE_SETUP -#line 379 "glsl_lexer.lpp" +#line 383 "glsl_lexer.lpp" KEYWORD(130, 130, CASE); YY_BREAK -case 175: +case 176: YY_RULE_SETUP -#line 380 "glsl_lexer.lpp" +#line 384 "glsl_lexer.lpp" KEYWORD(130, 999, COMMON); YY_BREAK -case 176: +case 177: YY_RULE_SETUP -#line 381 "glsl_lexer.lpp" +#line 385 "glsl_lexer.lpp" KEYWORD(130, 999, PARTITION); YY_BREAK -case 177: +case 178: YY_RULE_SETUP -#line 382 "glsl_lexer.lpp" +#line 386 "glsl_lexer.lpp" KEYWORD(130, 999, ACTIVE); YY_BREAK -case 178: +case 179: YY_RULE_SETUP -#line 383 "glsl_lexer.lpp" +#line 387 "glsl_lexer.lpp" KEYWORD(130 || ES, 999, SUPERP); YY_BREAK -case 179: +case 180: YY_RULE_SETUP -#line 384 "glsl_lexer.lpp" +#line 388 "glsl_lexer.lpp" KEYWORD(130, 140, SAMPLERBUFFER); YY_BREAK -case 180: +case 181: YY_RULE_SETUP -#line 385 "glsl_lexer.lpp" +#line 389 "glsl_lexer.lpp" KEYWORD(130, 999, FILTER); YY_BREAK -case 181: +case 182: YY_RULE_SETUP -#line 386 "glsl_lexer.lpp" +#line 390 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGE1D); YY_BREAK -case 182: +case 183: YY_RULE_SETUP -#line 387 "glsl_lexer.lpp" +#line 391 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGE2D); YY_BREAK -case 183: +case 184: YY_RULE_SETUP -#line 388 "glsl_lexer.lpp" +#line 392 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGE3D); YY_BREAK -case 184: +case 185: YY_RULE_SETUP -#line 389 "glsl_lexer.lpp" +#line 393 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGECUBE); YY_BREAK -case 185: +case 186: YY_RULE_SETUP -#line 390 "glsl_lexer.lpp" +#line 394 "glsl_lexer.lpp" KEYWORD(130, 999, IIMAGE1D); YY_BREAK -case 186: +case 187: YY_RULE_SETUP -#line 391 "glsl_lexer.lpp" +#line 395 "glsl_lexer.lpp" KEYWORD(130, 999, IIMAGE2D); YY_BREAK -case 187: +case 188: YY_RULE_SETUP -#line 392 "glsl_lexer.lpp" +#line 396 "glsl_lexer.lpp" KEYWORD(130, 999, IIMAGE3D); YY_BREAK -case 188: +case 189: YY_RULE_SETUP -#line 393 "glsl_lexer.lpp" +#line 397 "glsl_lexer.lpp" KEYWORD(130, 999, IIMAGECUBE); YY_BREAK -case 189: +case 190: YY_RULE_SETUP -#line 394 "glsl_lexer.lpp" +#line 398 "glsl_lexer.lpp" KEYWORD(130, 999, UIMAGE1D); YY_BREAK -case 190: +case 191: YY_RULE_SETUP -#line 395 "glsl_lexer.lpp" +#line 399 "glsl_lexer.lpp" KEYWORD(130, 999, UIMAGE2D); YY_BREAK -case 191: +case 192: YY_RULE_SETUP -#line 396 "glsl_lexer.lpp" +#line 400 "glsl_lexer.lpp" KEYWORD(130, 999, UIMAGE3D); YY_BREAK -case 192: +case 193: YY_RULE_SETUP -#line 397 "glsl_lexer.lpp" +#line 401 "glsl_lexer.lpp" KEYWORD(130, 999, UIMAGECUBE); YY_BREAK -case 193: +case 194: YY_RULE_SETUP -#line 398 "glsl_lexer.lpp" +#line 402 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGE1DARRAY); YY_BREAK -case 194: +case 195: YY_RULE_SETUP -#line 399 "glsl_lexer.lpp" +#line 403 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGE2DARRAY); YY_BREAK -case 195: +case 196: YY_RULE_SETUP -#line 400 "glsl_lexer.lpp" +#line 404 "glsl_lexer.lpp" KEYWORD(130, 999, IIMAGE1DARRAY); YY_BREAK -case 196: +case 197: YY_RULE_SETUP -#line 401 "glsl_lexer.lpp" +#line 405 "glsl_lexer.lpp" KEYWORD(130, 999, IIMAGE2DARRAY); YY_BREAK -case 197: +case 198: YY_RULE_SETUP -#line 402 "glsl_lexer.lpp" +#line 406 "glsl_lexer.lpp" KEYWORD(130, 999, UIMAGE1DARRAY); YY_BREAK -case 198: +case 199: YY_RULE_SETUP -#line 403 "glsl_lexer.lpp" +#line 407 "glsl_lexer.lpp" KEYWORD(130, 999, UIMAGE2DARRAY); YY_BREAK -case 199: +case 200: YY_RULE_SETUP -#line 404 "glsl_lexer.lpp" +#line 408 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGE1DSHADOW); YY_BREAK -case 200: +case 201: YY_RULE_SETUP -#line 405 "glsl_lexer.lpp" +#line 409 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGE2DSHADOW); YY_BREAK -case 201: +case 202: YY_RULE_SETUP -#line 406 "glsl_lexer.lpp" +#line 410 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGE1DARRAYSHADOW); YY_BREAK -case 202: +case 203: YY_RULE_SETUP -#line 407 "glsl_lexer.lpp" +#line 411 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGE2DARRAYSHADOW); YY_BREAK -case 203: +case 204: YY_RULE_SETUP -#line 408 "glsl_lexer.lpp" +#line 412 "glsl_lexer.lpp" KEYWORD(130, 999, IMAGEBUFFER); YY_BREAK -case 204: +case 205: YY_RULE_SETUP -#line 409 "glsl_lexer.lpp" +#line 413 "glsl_lexer.lpp" KEYWORD(130, 999, IIMAGEBUFFER); YY_BREAK -case 205: +case 206: YY_RULE_SETUP -#line 410 "glsl_lexer.lpp" +#line 414 "glsl_lexer.lpp" KEYWORD(130, 999, UIMAGEBUFFER); YY_BREAK -case 206: +case 207: YY_RULE_SETUP -#line 411 "glsl_lexer.lpp" +#line 415 "glsl_lexer.lpp" KEYWORD(130, 999, ROW_MAJOR); YY_BREAK -case 207: +case 208: YY_RULE_SETUP -#line 413 "glsl_lexer.lpp" +#line 417 "glsl_lexer.lpp" { struct _mesa_glsl_parse_state *state = yyextra; void *ctx = state; @@ -2516,17 +2550,17 @@ YY_RULE_SETUP return IDENTIFIER; } YY_BREAK -case 208: +case 209: YY_RULE_SETUP -#line 420 "glsl_lexer.lpp" +#line 424 "glsl_lexer.lpp" { return yytext[0]; } YY_BREAK -case 209: +case 210: YY_RULE_SETUP -#line 422 "glsl_lexer.lpp" +#line 426 "glsl_lexer.lpp" ECHO; YY_BREAK -#line 2530 "glsl_lexer.cpp" +#line 2564 "glsl_lexer.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(PP): case YY_STATE_EOF(PRAGMA): @@ -2824,7 +2858,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 813 ) + if ( yy_current_state >= 836 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -2853,11 +2887,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 813 ) + if ( yy_current_state >= 836 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 812); + yy_is_jam = (yy_current_state == 835); return yy_is_jam ? 0 : yy_current_state; } @@ -3262,8 +3296,8 @@ YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char * yystr , yyscan_t yyscann /** Setup the input buffer state to scan the given bytes. The next call to _mesa_glsl_lex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -3669,7 +3703,7 @@ void _mesa_glsl_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 422 "glsl_lexer.lpp" +#line 426 "glsl_lexer.lpp" diff --git a/mesalib/src/glsl/glsl_lexer.lpp b/mesalib/src/glsl/glsl_lexer.lpp index 1c6de692a..35405dad6 100644 --- a/mesalib/src/glsl/glsl_lexer.lpp +++ b/mesalib/src/glsl/glsl_lexer.lpp @@ -145,6 +145,10 @@ HASH ^{SPC}#{SPC} BEGIN PP; return PRAGMA_OPTIMIZE_OFF; } +^{SPC}#{SPC}pragma{SPCP}STDGL{SPCP}invariant{SPC}\({SPC}all{SPC}\) { + BEGIN PP; + return PRAGMA_INVARIANT_ALL; + } ^{SPC}#{SPC}pragma{SPCP} { BEGIN PRAGMA; } \n { BEGIN 0; yylineno++; yycolumn = 0; } diff --git a/mesalib/src/glsl/glsl_parser.cpp b/mesalib/src/glsl/glsl_parser.cpp index df858db2b..443657968 100644 --- a/mesalib/src/glsl/glsl_parser.cpp +++ b/mesalib/src/glsl/glsl_parser.cpp @@ -1,9 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -113,7 +114,7 @@ /* Line 189 of yacc.c */ -#line 117 "glsl_parser.cpp" +#line 118 "glsl_parser.cpp" /* Enabling traces. */ #ifndef YYDEBUG @@ -257,79 +258,80 @@ PRAGMA_DEBUG_OFF = 372, PRAGMA_OPTIMIZE_ON = 373, PRAGMA_OPTIMIZE_OFF = 374, - LAYOUT_TOK = 375, - ASM = 376, - CLASS = 377, - UNION = 378, - ENUM = 379, - TYPEDEF = 380, - TEMPLATE = 381, - THIS = 382, - PACKED_TOK = 383, - GOTO = 384, - INLINE_TOK = 385, - NOINLINE = 386, - VOLATILE = 387, - PUBLIC_TOK = 388, - STATIC = 389, - EXTERN = 390, - EXTERNAL = 391, - LONG_TOK = 392, - SHORT_TOK = 393, - DOUBLE_TOK = 394, - HALF = 395, - FIXED_TOK = 396, - UNSIGNED = 397, - INPUT_TOK = 398, - OUPTUT = 399, - HVEC2 = 400, - HVEC3 = 401, - HVEC4 = 402, - DVEC2 = 403, - DVEC3 = 404, - DVEC4 = 405, - FVEC2 = 406, - FVEC3 = 407, - FVEC4 = 408, - SAMPLER2DRECT = 409, - SAMPLER3DRECT = 410, - SAMPLER2DRECTSHADOW = 411, - SIZEOF = 412, - CAST = 413, - NAMESPACE = 414, - USING = 415, - ERROR_TOK = 416, - COMMON = 417, - PARTITION = 418, - ACTIVE = 419, - SAMPLERBUFFER = 420, - FILTER = 421, - IMAGE1D = 422, - IMAGE2D = 423, - IMAGE3D = 424, - IMAGECUBE = 425, - IMAGE1DARRAY = 426, - IMAGE2DARRAY = 427, - IIMAGE1D = 428, - IIMAGE2D = 429, - IIMAGE3D = 430, - IIMAGECUBE = 431, - IIMAGE1DARRAY = 432, - IIMAGE2DARRAY = 433, - UIMAGE1D = 434, - UIMAGE2D = 435, - UIMAGE3D = 436, - UIMAGECUBE = 437, - UIMAGE1DARRAY = 438, - UIMAGE2DARRAY = 439, - IMAGE1DSHADOW = 440, - IMAGE2DSHADOW = 441, - IMAGEBUFFER = 442, - IIMAGEBUFFER = 443, - UIMAGEBUFFER = 444, - IMAGE1DARRAYSHADOW = 445, - IMAGE2DARRAYSHADOW = 446, - ROW_MAJOR = 447 + PRAGMA_INVARIANT_ALL = 375, + LAYOUT_TOK = 376, + ASM = 377, + CLASS = 378, + UNION = 379, + ENUM = 380, + TYPEDEF = 381, + TEMPLATE = 382, + THIS = 383, + PACKED_TOK = 384, + GOTO = 385, + INLINE_TOK = 386, + NOINLINE = 387, + VOLATILE = 388, + PUBLIC_TOK = 389, + STATIC = 390, + EXTERN = 391, + EXTERNAL = 392, + LONG_TOK = 393, + SHORT_TOK = 394, + DOUBLE_TOK = 395, + HALF = 396, + FIXED_TOK = 397, + UNSIGNED = 398, + INPUT_TOK = 399, + OUPTUT = 400, + HVEC2 = 401, + HVEC3 = 402, + HVEC4 = 403, + DVEC2 = 404, + DVEC3 = 405, + DVEC4 = 406, + FVEC2 = 407, + FVEC3 = 408, + FVEC4 = 409, + SAMPLER2DRECT = 410, + SAMPLER3DRECT = 411, + SAMPLER2DRECTSHADOW = 412, + SIZEOF = 413, + CAST = 414, + NAMESPACE = 415, + USING = 416, + ERROR_TOK = 417, + COMMON = 418, + PARTITION = 419, + ACTIVE = 420, + SAMPLERBUFFER = 421, + FILTER = 422, + IMAGE1D = 423, + IMAGE2D = 424, + IMAGE3D = 425, + IMAGECUBE = 426, + IMAGE1DARRAY = 427, + IMAGE2DARRAY = 428, + IIMAGE1D = 429, + IIMAGE2D = 430, + IIMAGE3D = 431, + IIMAGECUBE = 432, + IIMAGE1DARRAY = 433, + IIMAGE2DARRAY = 434, + UIMAGE1D = 435, + UIMAGE2D = 436, + UIMAGE3D = 437, + UIMAGECUBE = 438, + UIMAGE1DARRAY = 439, + UIMAGE2DARRAY = 440, + IMAGE1DSHADOW = 441, + IMAGE2DSHADOW = 442, + IMAGEBUFFER = 443, + IIMAGEBUFFER = 444, + UIMAGEBUFFER = 445, + IMAGE1DARRAYSHADOW = 446, + IMAGE2DARRAYSHADOW = 447, + ROW_MAJOR = 448 }; #endif @@ -373,7 +375,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 377 "glsl_parser.cpp" +#line 379 "glsl_parser.cpp" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -398,7 +400,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 402 "glsl_parser.cpp" +#line 404 "glsl_parser.cpp" #ifdef short # undef short @@ -448,7 +450,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -615,20 +617,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 5 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 3718 +#define YYLAST 3738 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 217 +#define YYNTOKENS 218 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 87 /* YYNRULES -- Number of rules. */ -#define YYNRULES 278 +#define YYNRULES 279 /* YYNRULES -- Number of states. */ -#define YYNSTATES 413 +#define YYNSTATES 415 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 447 +#define YYMAXUTOK 448 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -639,16 +641,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 201, 2, 2, 2, 205, 208, 2, - 193, 194, 203, 199, 198, 200, 197, 204, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 212, 214, - 206, 213, 207, 211, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 202, 2, 2, 2, 206, 209, 2, + 194, 195, 204, 200, 199, 201, 198, 205, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 213, 215, + 207, 214, 208, 212, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 195, 2, 196, 209, 2, 2, 2, 2, 2, + 2, 196, 2, 197, 210, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 215, 210, 216, 202, 2, 2, 2, + 2, 2, 2, 216, 211, 217, 203, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -680,7 +682,7 @@ static const yytype_uint8 yytranslate[] = 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, - 185, 186, 187, 188, 189, 190, 191, 192 + 185, 186, 187, 188, 189, 190, 191, 192, 193 }; #if YYDEBUG @@ -689,151 +691,151 @@ static const yytype_uint8 yytranslate[] = static const yytype_uint16 yyprhs[] = { 0, 0, 3, 4, 9, 10, 14, 17, 20, 23, - 26, 27, 30, 36, 38, 41, 43, 45, 47, 49, - 51, 53, 57, 59, 64, 66, 70, 73, 76, 78, - 80, 82, 86, 89, 92, 95, 97, 100, 104, 107, - 109, 111, 113, 115, 118, 121, 124, 126, 128, 130, - 132, 134, 138, 142, 146, 148, 152, 156, 158, 162, - 166, 168, 172, 176, 180, 184, 186, 190, 194, 196, - 200, 202, 206, 208, 212, 214, 218, 220, 224, 226, - 230, 232, 238, 240, 244, 246, 248, 250, 252, 254, - 256, 258, 260, 262, 264, 266, 268, 272, 274, 277, - 280, 285, 288, 290, 292, 295, 299, 303, 306, 312, - 316, 319, 323, 326, 327, 329, 331, 333, 335, 337, - 341, 347, 354, 362, 371, 377, 379, 382, 387, 393, - 400, 408, 413, 416, 418, 421, 426, 428, 432, 434, - 438, 440, 442, 444, 446, 448, 450, 453, 455, 458, - 461, 465, 467, 469, 471, 473, 476, 478, 480, 483, - 486, 488, 490, 493, 495, 499, 504, 506, 508, 510, - 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, - 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, - 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, - 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, - 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, - 612, 614, 616, 618, 624, 629, 631, 634, 638, 640, - 644, 646, 651, 653, 655, 657, 659, 661, 663, 665, - 667, 669, 671, 673, 676, 680, 682, 684, 687, 691, - 693, 696, 698, 701, 707, 711, 713, 715, 720, 726, - 730, 733, 739, 747, 754, 756, 758, 760, 761, 764, - 768, 771, 774, 777, 781, 784, 786, 788, 790 + 26, 29, 30, 33, 39, 41, 44, 46, 48, 50, + 52, 54, 56, 60, 62, 67, 69, 73, 76, 79, + 81, 83, 85, 89, 92, 95, 98, 100, 103, 107, + 110, 112, 114, 116, 118, 121, 124, 127, 129, 131, + 133, 135, 137, 141, 145, 149, 151, 155, 159, 161, + 165, 169, 171, 175, 179, 183, 187, 189, 193, 197, + 199, 203, 205, 209, 211, 215, 217, 221, 223, 227, + 229, 233, 235, 241, 243, 247, 249, 251, 253, 255, + 257, 259, 261, 263, 265, 267, 269, 271, 275, 277, + 280, 283, 288, 291, 293, 295, 298, 302, 306, 309, + 315, 319, 322, 326, 329, 330, 332, 334, 336, 338, + 340, 344, 350, 357, 365, 374, 380, 382, 385, 390, + 396, 403, 411, 416, 419, 421, 424, 429, 431, 435, + 437, 441, 443, 445, 447, 449, 451, 453, 456, 458, + 461, 464, 468, 470, 472, 474, 476, 479, 481, 483, + 486, 489, 491, 493, 496, 498, 502, 507, 509, 511, + 513, 515, 517, 519, 521, 523, 525, 527, 529, 531, + 533, 535, 537, 539, 541, 543, 545, 547, 549, 551, + 553, 555, 557, 559, 561, 563, 565, 567, 569, 571, + 573, 575, 577, 579, 581, 583, 585, 587, 589, 591, + 593, 595, 597, 599, 601, 603, 605, 607, 609, 611, + 613, 615, 617, 619, 621, 627, 632, 634, 637, 641, + 643, 647, 649, 654, 656, 658, 660, 662, 664, 666, + 668, 670, 672, 674, 676, 679, 683, 685, 687, 690, + 694, 696, 699, 701, 704, 710, 714, 716, 718, 723, + 729, 733, 736, 742, 750, 757, 759, 761, 763, 764, + 767, 771, 774, 777, 780, 784, 787, 789, 791, 793 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 218, 0, -1, -1, 220, 222, 219, 224, -1, -1, + 219, 0, -1, -1, 221, 223, 220, 225, -1, -1, 109, 78, 113, -1, 116, 113, -1, 117, 113, -1, - 118, 113, -1, 119, 113, -1, -1, 222, 223, -1, - 110, 76, 112, 76, 113, -1, 302, -1, 224, 302, - -1, 76, -1, 225, -1, 78, -1, 79, -1, 77, - -1, 80, -1, 193, 252, 194, -1, 226, -1, 227, - 195, 228, 196, -1, 229, -1, 227, 197, 76, -1, - 227, 84, -1, 227, 85, -1, 252, -1, 230, -1, - 231, -1, 227, 197, 231, -1, 233, 194, -1, 232, - 194, -1, 234, 74, -1, 234, -1, 234, 250, -1, - 233, 198, 250, -1, 235, 193, -1, 273, -1, 76, - -1, 81, -1, 227, -1, 84, 236, -1, 85, 236, - -1, 237, 236, -1, 199, -1, 200, -1, 201, -1, - 202, -1, 236, -1, 238, 203, 236, -1, 238, 204, - 236, -1, 238, 205, 236, -1, 238, -1, 239, 199, - 238, -1, 239, 200, 238, -1, 239, -1, 240, 82, - 239, -1, 240, 83, 239, -1, 240, -1, 241, 206, - 240, -1, 241, 207, 240, -1, 241, 86, 240, -1, - 241, 87, 240, -1, 241, -1, 242, 88, 241, -1, - 242, 89, 241, -1, 242, -1, 243, 208, 242, -1, - 243, -1, 244, 209, 243, -1, 244, -1, 245, 210, - 244, -1, 245, -1, 246, 90, 245, -1, 246, -1, - 247, 92, 246, -1, 247, -1, 248, 91, 247, -1, - 248, -1, 248, 211, 252, 212, 250, -1, 249, -1, - 236, 251, 250, -1, 213, -1, 93, -1, 94, -1, - 96, -1, 95, -1, 102, -1, 97, -1, 98, -1, - 99, -1, 100, -1, 101, -1, 250, -1, 252, 198, - 250, -1, 249, -1, 255, 214, -1, 263, 214, -1, - 108, 277, 274, 214, -1, 256, 194, -1, 258, -1, - 257, -1, 258, 260, -1, 257, 198, 260, -1, 265, - 76, 193, -1, 273, 76, -1, 273, 76, 195, 253, - 196, -1, 270, 261, 259, -1, 261, 259, -1, 270, - 261, 262, -1, 261, 262, -1, -1, 33, -1, 34, - -1, 35, -1, 273, -1, 264, -1, 263, 198, 76, - -1, 263, 198, 76, 195, 196, -1, 263, 198, 76, - 195, 253, 196, -1, 263, 198, 76, 195, 196, 213, - 283, -1, 263, 198, 76, 195, 253, 196, 213, 283, - -1, 263, 198, 76, 213, 283, -1, 265, -1, 265, - 76, -1, 265, 76, 195, 196, -1, 265, 76, 195, - 253, 196, -1, 265, 76, 195, 196, 213, 283, -1, - 265, 76, 195, 253, 196, 213, 283, -1, 265, 76, - 213, 283, -1, 103, 76, -1, 273, -1, 271, 273, - -1, 120, 193, 267, 194, -1, 268, -1, 267, 198, - 268, -1, 76, -1, 76, 213, 78, -1, 40, -1, - 39, -1, 38, -1, 4, -1, 272, -1, 266, -1, - 266, 272, -1, 269, -1, 269, 272, -1, 103, 272, - -1, 103, 269, 272, -1, 103, -1, 4, -1, 3, - -1, 37, -1, 32, 37, -1, 33, -1, 34, -1, - 32, 33, -1, 32, 34, -1, 36, -1, 274, -1, - 277, 274, -1, 275, -1, 275, 195, 196, -1, 275, - 195, 253, 196, -1, 276, -1, 278, -1, 76, -1, - 74, -1, 6, -1, 7, -1, 8, -1, 5, -1, - 29, -1, 30, -1, 31, -1, 20, -1, 21, -1, - 22, -1, 23, -1, 24, -1, 25, -1, 26, -1, - 27, -1, 28, -1, 41, -1, 42, -1, 43, -1, - 44, -1, 45, -1, 46, -1, 47, -1, 48, -1, - 49, -1, 50, -1, 51, -1, 154, -1, 52, -1, - 53, -1, 54, -1, 55, -1, 156, -1, 56, -1, - 57, -1, 58, -1, 59, -1, 60, -1, 61, -1, - 62, -1, 63, -1, 64, -1, 65, -1, 66, -1, - 67, -1, 68, -1, 69, -1, 70, -1, 71, -1, - 72, -1, 106, -1, 105, -1, 104, -1, 73, 76, - 215, 279, 216, -1, 73, 215, 279, 216, -1, 280, - -1, 279, 280, -1, 273, 281, 214, -1, 282, -1, - 281, 198, 282, -1, 76, -1, 76, 195, 253, 196, - -1, 250, -1, 254, -1, 287, -1, 286, -1, 284, - -1, 291, -1, 292, -1, 295, -1, 296, -1, 297, - -1, 301, -1, 215, 216, -1, 215, 290, 216, -1, - 289, -1, 286, -1, 215, 216, -1, 215, 290, 216, - -1, 285, -1, 290, 285, -1, 214, -1, 252, 214, - -1, 14, 193, 252, 194, 293, -1, 285, 12, 285, - -1, 285, -1, 252, -1, 265, 76, 213, 283, -1, - 17, 193, 252, 194, 287, -1, 18, 252, 212, -1, - 19, 212, -1, 75, 193, 294, 194, 288, -1, 11, - 285, 75, 193, 252, 194, 214, -1, 13, 193, 298, - 300, 194, 288, -1, 291, -1, 284, -1, 294, -1, - -1, 299, 214, -1, 299, 214, 252, -1, 10, 214, - -1, 9, 214, -1, 16, 214, -1, 16, 252, 214, - -1, 15, 214, -1, 303, -1, 254, -1, 221, -1, - 255, 289, -1 + 118, 113, -1, 119, 113, -1, 120, 113, -1, -1, + 223, 224, -1, 110, 76, 112, 76, 113, -1, 303, + -1, 225, 303, -1, 76, -1, 226, -1, 78, -1, + 79, -1, 77, -1, 80, -1, 194, 253, 195, -1, + 227, -1, 228, 196, 229, 197, -1, 230, -1, 228, + 198, 76, -1, 228, 84, -1, 228, 85, -1, 253, + -1, 231, -1, 232, -1, 228, 198, 232, -1, 234, + 195, -1, 233, 195, -1, 235, 74, -1, 235, -1, + 235, 251, -1, 234, 199, 251, -1, 236, 194, -1, + 274, -1, 76, -1, 81, -1, 228, -1, 84, 237, + -1, 85, 237, -1, 238, 237, -1, 200, -1, 201, + -1, 202, -1, 203, -1, 237, -1, 239, 204, 237, + -1, 239, 205, 237, -1, 239, 206, 237, -1, 239, + -1, 240, 200, 239, -1, 240, 201, 239, -1, 240, + -1, 241, 82, 240, -1, 241, 83, 240, -1, 241, + -1, 242, 207, 241, -1, 242, 208, 241, -1, 242, + 86, 241, -1, 242, 87, 241, -1, 242, -1, 243, + 88, 242, -1, 243, 89, 242, -1, 243, -1, 244, + 209, 243, -1, 244, -1, 245, 210, 244, -1, 245, + -1, 246, 211, 245, -1, 246, -1, 247, 90, 246, + -1, 247, -1, 248, 92, 247, -1, 248, -1, 249, + 91, 248, -1, 249, -1, 249, 212, 253, 213, 251, + -1, 250, -1, 237, 252, 251, -1, 214, -1, 93, + -1, 94, -1, 96, -1, 95, -1, 102, -1, 97, + -1, 98, -1, 99, -1, 100, -1, 101, -1, 251, + -1, 253, 199, 251, -1, 250, -1, 256, 215, -1, + 264, 215, -1, 108, 278, 275, 215, -1, 257, 195, + -1, 259, -1, 258, -1, 259, 261, -1, 258, 199, + 261, -1, 266, 76, 194, -1, 274, 76, -1, 274, + 76, 196, 254, 197, -1, 271, 262, 260, -1, 262, + 260, -1, 271, 262, 263, -1, 262, 263, -1, -1, + 33, -1, 34, -1, 35, -1, 274, -1, 265, -1, + 264, 199, 76, -1, 264, 199, 76, 196, 197, -1, + 264, 199, 76, 196, 254, 197, -1, 264, 199, 76, + 196, 197, 214, 284, -1, 264, 199, 76, 196, 254, + 197, 214, 284, -1, 264, 199, 76, 214, 284, -1, + 266, -1, 266, 76, -1, 266, 76, 196, 197, -1, + 266, 76, 196, 254, 197, -1, 266, 76, 196, 197, + 214, 284, -1, 266, 76, 196, 254, 197, 214, 284, + -1, 266, 76, 214, 284, -1, 103, 76, -1, 274, + -1, 272, 274, -1, 121, 194, 268, 195, -1, 269, + -1, 268, 199, 269, -1, 76, -1, 76, 214, 78, + -1, 40, -1, 39, -1, 38, -1, 4, -1, 273, + -1, 267, -1, 267, 273, -1, 270, -1, 270, 273, + -1, 103, 273, -1, 103, 270, 273, -1, 103, -1, + 4, -1, 3, -1, 37, -1, 32, 37, -1, 33, + -1, 34, -1, 32, 33, -1, 32, 34, -1, 36, + -1, 275, -1, 278, 275, -1, 276, -1, 276, 196, + 197, -1, 276, 196, 254, 197, -1, 277, -1, 279, + -1, 76, -1, 74, -1, 6, -1, 7, -1, 8, + -1, 5, -1, 29, -1, 30, -1, 31, -1, 20, + -1, 21, -1, 22, -1, 23, -1, 24, -1, 25, + -1, 26, -1, 27, -1, 28, -1, 41, -1, 42, + -1, 43, -1, 44, -1, 45, -1, 46, -1, 47, + -1, 48, -1, 49, -1, 50, -1, 51, -1, 155, + -1, 52, -1, 53, -1, 54, -1, 55, -1, 157, + -1, 56, -1, 57, -1, 58, -1, 59, -1, 60, + -1, 61, -1, 62, -1, 63, -1, 64, -1, 65, + -1, 66, -1, 67, -1, 68, -1, 69, -1, 70, + -1, 71, -1, 72, -1, 106, -1, 105, -1, 104, + -1, 73, 76, 216, 280, 217, -1, 73, 216, 280, + 217, -1, 281, -1, 280, 281, -1, 274, 282, 215, + -1, 283, -1, 282, 199, 283, -1, 76, -1, 76, + 196, 254, 197, -1, 251, -1, 255, -1, 288, -1, + 287, -1, 285, -1, 292, -1, 293, -1, 296, -1, + 297, -1, 298, -1, 302, -1, 216, 217, -1, 216, + 291, 217, -1, 290, -1, 287, -1, 216, 217, -1, + 216, 291, 217, -1, 286, -1, 291, 286, -1, 215, + -1, 253, 215, -1, 14, 194, 253, 195, 294, -1, + 286, 12, 286, -1, 286, -1, 253, -1, 266, 76, + 214, 284, -1, 17, 194, 253, 195, 288, -1, 18, + 253, 213, -1, 19, 213, -1, 75, 194, 295, 195, + 289, -1, 11, 286, 75, 194, 253, 195, 215, -1, + 13, 194, 299, 301, 195, 289, -1, 292, -1, 285, + -1, 295, -1, -1, 300, 215, -1, 300, 215, 253, + -1, 10, 215, -1, 9, 215, -1, 16, 215, -1, + 16, 253, 215, -1, 15, 215, -1, 304, -1, 255, + -1, 222, -1, 256, 290, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 212, 212, 211, 218, 220, 240, 241, 242, 243, - 246, 248, 252, 261, 269, 280, 284, 291, 298, 305, - 312, 319, 326, 327, 333, 337, 344, 350, 359, 363, - 367, 368, 377, 378, 382, 383, 387, 393, 405, 409, - 415, 422, 433, 434, 440, 446, 456, 457, 458, 459, - 463, 464, 470, 476, 485, 486, 492, 501, 502, 508, - 517, 518, 524, 530, 536, 545, 546, 552, 561, 562, - 571, 572, 581, 582, 591, 592, 601, 602, 611, 612, - 621, 622, 631, 632, 641, 642, 643, 644, 645, 646, - 647, 648, 649, 650, 651, 655, 659, 675, 679, 683, - 687, 701, 705, 706, 710, 715, 723, 734, 744, 759, - 766, 771, 782, 795, 798, 803, 808, 817, 821, 822, - 831, 840, 849, 858, 867, 880, 891, 900, 909, 918, - 927, 936, 945, 959, 966, 977, 984, 985, 1004, 1033, - 1074, 1079, 1084, 1092, 1100, 1101, 1102, 1107, 1108, 1113, - 1118, 1124, 1132, 1137, 1142, 1147, 1153, 1158, 1163, 1168, - 1173, 1181, 1182, 1190, 1191, 1197, 1206, 1212, 1218, 1227, - 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, - 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, - 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, - 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, - 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, - 1281, 1292, 1303, 1317, 1323, 1332, 1337, 1345, 1360, 1365, - 1373, 1379, 1388, 1392, 1398, 1399, 1403, 1404, 1405, 1406, - 1407, 1408, 1409, 1413, 1419, 1428, 1429, 1433, 1439, 1448, - 1458, 1470, 1476, 1485, 1494, 1499, 1507, 1511, 1525, 1529, - 1530, 1534, 1541, 1548, 1558, 1559, 1563, 1565, 1571, 1576, - 1585, 1591, 1597, 1603, 1609, 1618, 1619, 1620, 1624 + 0, 213, 213, 212, 219, 221, 241, 242, 243, 244, + 245, 260, 262, 266, 275, 283, 294, 298, 305, 312, + 319, 326, 333, 340, 341, 347, 351, 358, 364, 373, + 377, 381, 382, 391, 392, 396, 397, 401, 407, 419, + 423, 429, 436, 447, 448, 454, 460, 470, 471, 472, + 473, 477, 478, 484, 490, 499, 500, 506, 515, 516, + 522, 531, 532, 538, 544, 550, 559, 560, 566, 575, + 576, 585, 586, 595, 596, 605, 606, 615, 616, 625, + 626, 635, 636, 645, 646, 655, 656, 657, 658, 659, + 660, 661, 662, 663, 664, 665, 669, 673, 689, 693, + 697, 701, 715, 719, 720, 724, 729, 737, 748, 758, + 773, 780, 785, 796, 809, 812, 817, 822, 831, 835, + 836, 845, 854, 863, 872, 881, 894, 905, 914, 923, + 932, 941, 950, 959, 973, 980, 991, 998, 999, 1018, + 1047, 1088, 1093, 1098, 1106, 1114, 1115, 1116, 1121, 1122, + 1127, 1132, 1138, 1146, 1151, 1156, 1161, 1167, 1172, 1177, + 1182, 1187, 1195, 1196, 1204, 1205, 1211, 1220, 1226, 1232, + 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, + 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, + 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, + 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, + 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, + 1291, 1295, 1306, 1317, 1331, 1337, 1346, 1351, 1359, 1374, + 1379, 1387, 1393, 1402, 1406, 1412, 1413, 1417, 1418, 1419, + 1420, 1421, 1422, 1423, 1427, 1433, 1442, 1443, 1447, 1453, + 1462, 1472, 1484, 1490, 1499, 1508, 1513, 1521, 1525, 1539, + 1543, 1544, 1548, 1555, 1562, 1572, 1573, 1577, 1579, 1585, + 1590, 1599, 1605, 1611, 1617, 1623, 1632, 1633, 1634, 1638 }; #endif @@ -864,28 +866,28 @@ static const char *const yytname[] = "LOWP", "MEDIUMP", "HIGHP", "SUPERP", "PRECISION", "VERSION", "EXTENSION", "LINE", "COLON", "EOL", "INTERFACE", "OUTPUT", "PRAGMA_DEBUG_ON", "PRAGMA_DEBUG_OFF", "PRAGMA_OPTIMIZE_ON", - "PRAGMA_OPTIMIZE_OFF", "LAYOUT_TOK", "ASM", "CLASS", "UNION", "ENUM", - "TYPEDEF", "TEMPLATE", "THIS", "PACKED_TOK", "GOTO", "INLINE_TOK", - "NOINLINE", "VOLATILE", "PUBLIC_TOK", "STATIC", "EXTERN", "EXTERNAL", - "LONG_TOK", "SHORT_TOK", "DOUBLE_TOK", "HALF", "FIXED_TOK", "UNSIGNED", - "INPUT_TOK", "OUPTUT", "HVEC2", "HVEC3", "HVEC4", "DVEC2", "DVEC3", - "DVEC4", "FVEC2", "FVEC3", "FVEC4", "SAMPLER2DRECT", "SAMPLER3DRECT", - "SAMPLER2DRECTSHADOW", "SIZEOF", "CAST", "NAMESPACE", "USING", - "ERROR_TOK", "COMMON", "PARTITION", "ACTIVE", "SAMPLERBUFFER", "FILTER", - "IMAGE1D", "IMAGE2D", "IMAGE3D", "IMAGECUBE", "IMAGE1DARRAY", - "IMAGE2DARRAY", "IIMAGE1D", "IIMAGE2D", "IIMAGE3D", "IIMAGECUBE", - "IIMAGE1DARRAY", "IIMAGE2DARRAY", "UIMAGE1D", "UIMAGE2D", "UIMAGE3D", - "UIMAGECUBE", "UIMAGE1DARRAY", "UIMAGE2DARRAY", "IMAGE1DSHADOW", - "IMAGE2DSHADOW", "IMAGEBUFFER", "IIMAGEBUFFER", "UIMAGEBUFFER", - "IMAGE1DARRAYSHADOW", "IMAGE2DARRAYSHADOW", "ROW_MAJOR", "'('", "')'", - "'['", "']'", "'.'", "','", "'+'", "'-'", "'!'", "'~'", "'*'", "'/'", - "'%'", "'<'", "'>'", "'&'", "'^'", "'|'", "'?'", "':'", "'='", "';'", - "'{'", "'}'", "$accept", "translation_unit", "$@1", "version_statement", - "pragma_statement", "extension_statement_list", "extension_statement", - "external_declaration_list", "variable_identifier", "primary_expression", - "postfix_expression", "integer_expression", "function_call", - "function_call_or_method", "function_call_generic", - "function_call_header_no_parameters", + "PRAGMA_OPTIMIZE_OFF", "PRAGMA_INVARIANT_ALL", "LAYOUT_TOK", "ASM", + "CLASS", "UNION", "ENUM", "TYPEDEF", "TEMPLATE", "THIS", "PACKED_TOK", + "GOTO", "INLINE_TOK", "NOINLINE", "VOLATILE", "PUBLIC_TOK", "STATIC", + "EXTERN", "EXTERNAL", "LONG_TOK", "SHORT_TOK", "DOUBLE_TOK", "HALF", + "FIXED_TOK", "UNSIGNED", "INPUT_TOK", "OUPTUT", "HVEC2", "HVEC3", + "HVEC4", "DVEC2", "DVEC3", "DVEC4", "FVEC2", "FVEC3", "FVEC4", + "SAMPLER2DRECT", "SAMPLER3DRECT", "SAMPLER2DRECTSHADOW", "SIZEOF", + "CAST", "NAMESPACE", "USING", "ERROR_TOK", "COMMON", "PARTITION", + "ACTIVE", "SAMPLERBUFFER", "FILTER", "IMAGE1D", "IMAGE2D", "IMAGE3D", + "IMAGECUBE", "IMAGE1DARRAY", "IMAGE2DARRAY", "IIMAGE1D", "IIMAGE2D", + "IIMAGE3D", "IIMAGECUBE", "IIMAGE1DARRAY", "IIMAGE2DARRAY", "UIMAGE1D", + "UIMAGE2D", "UIMAGE3D", "UIMAGECUBE", "UIMAGE1DARRAY", "UIMAGE2DARRAY", + "IMAGE1DSHADOW", "IMAGE2DSHADOW", "IMAGEBUFFER", "IIMAGEBUFFER", + "UIMAGEBUFFER", "IMAGE1DARRAYSHADOW", "IMAGE2DARRAYSHADOW", "ROW_MAJOR", + "'('", "')'", "'['", "']'", "'.'", "','", "'+'", "'-'", "'!'", "'~'", + "'*'", "'/'", "'%'", "'<'", "'>'", "'&'", "'^'", "'|'", "'?'", "':'", + "'='", "';'", "'{'", "'}'", "$accept", "translation_unit", "$@1", + "version_statement", "pragma_statement", "extension_statement_list", + "extension_statement", "external_declaration_list", + "variable_identifier", "primary_expression", "postfix_expression", + "integer_expression", "function_call", "function_call_or_method", + "function_call_generic", "function_call_header_no_parameters", "function_call_header_with_parameters", "function_call_header", "function_identifier", "unary_expression", "unary_operator", "multiplicative_expression", "additive_expression", "shift_expression", @@ -940,76 +942,76 @@ static const yytype_uint16 yytoknum[] = 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, - 445, 446, 447, 40, 41, 91, 93, 46, 44, 43, - 45, 33, 126, 42, 47, 37, 60, 62, 38, 94, - 124, 63, 58, 61, 59, 123, 125 + 445, 446, 447, 448, 40, 41, 91, 93, 46, 44, + 43, 45, 33, 126, 42, 47, 37, 60, 62, 38, + 94, 124, 63, 58, 61, 59, 123, 125 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint16 yyr1[] = { - 0, 217, 219, 218, 220, 220, 221, 221, 221, 221, - 222, 222, 223, 224, 224, 225, 226, 226, 226, 226, - 226, 226, 227, 227, 227, 227, 227, 227, 228, 229, - 230, 230, 231, 231, 232, 232, 233, 233, 234, 235, - 235, 235, 236, 236, 236, 236, 237, 237, 237, 237, - 238, 238, 238, 238, 239, 239, 239, 240, 240, 240, - 241, 241, 241, 241, 241, 242, 242, 242, 243, 243, - 244, 244, 245, 245, 246, 246, 247, 247, 248, 248, - 249, 249, 250, 250, 251, 251, 251, 251, 251, 251, - 251, 251, 251, 251, 251, 252, 252, 253, 254, 254, - 254, 255, 256, 256, 257, 257, 258, 259, 259, 260, - 260, 260, 260, 261, 261, 261, 261, 262, 263, 263, - 263, 263, 263, 263, 263, 264, 264, 264, 264, 264, - 264, 264, 264, 265, 265, 266, 267, 267, 268, 268, - 269, 269, 269, 270, 271, 271, 271, 271, 271, 271, - 271, 271, 272, 272, 272, 272, 272, 272, 272, 272, - 272, 273, 273, 274, 274, 274, 275, 275, 275, 276, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 276, 276, 276, 276, 276, 276, 276, 276, 276, 276, - 277, 277, 277, 278, 278, 279, 279, 280, 281, 281, - 282, 282, 283, 284, 285, 285, 286, 286, 286, 286, - 286, 286, 286, 287, 287, 288, 288, 289, 289, 290, - 290, 291, 291, 292, 293, 293, 294, 294, 295, 296, - 296, 297, 297, 297, 298, 298, 299, 299, 300, 300, - 301, 301, 301, 301, 301, 302, 302, 302, 303 + 0, 218, 220, 219, 221, 221, 222, 222, 222, 222, + 222, 223, 223, 224, 225, 225, 226, 227, 227, 227, + 227, 227, 227, 228, 228, 228, 228, 228, 228, 229, + 230, 231, 231, 232, 232, 233, 233, 234, 234, 235, + 236, 236, 236, 237, 237, 237, 237, 238, 238, 238, + 238, 239, 239, 239, 239, 240, 240, 240, 241, 241, + 241, 242, 242, 242, 242, 242, 243, 243, 243, 244, + 244, 245, 245, 246, 246, 247, 247, 248, 248, 249, + 249, 250, 250, 251, 251, 252, 252, 252, 252, 252, + 252, 252, 252, 252, 252, 252, 253, 253, 254, 255, + 255, 255, 256, 257, 257, 258, 258, 259, 260, 260, + 261, 261, 261, 261, 262, 262, 262, 262, 263, 264, + 264, 264, 264, 264, 264, 264, 265, 265, 265, 265, + 265, 265, 265, 265, 266, 266, 267, 268, 268, 269, + 269, 270, 270, 270, 271, 272, 272, 272, 272, 272, + 272, 272, 272, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 274, 274, 275, 275, 275, 276, 276, 276, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 278, 278, 278, 279, 279, 280, 280, 281, 282, + 282, 283, 283, 284, 285, 286, 286, 287, 287, 287, + 287, 287, 287, 287, 288, 288, 289, 289, 290, 290, + 291, 291, 292, 292, 293, 294, 294, 295, 295, 296, + 297, 297, 298, 298, 298, 299, 299, 300, 300, 301, + 301, 302, 302, 302, 302, 302, 303, 303, 303, 304 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 0, 4, 0, 3, 2, 2, 2, 2, - 0, 2, 5, 1, 2, 1, 1, 1, 1, 1, - 1, 3, 1, 4, 1, 3, 2, 2, 1, 1, - 1, 3, 2, 2, 2, 1, 2, 3, 2, 1, - 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, - 1, 3, 3, 3, 1, 3, 3, 1, 3, 3, - 1, 3, 3, 3, 3, 1, 3, 3, 1, 3, - 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, - 1, 5, 1, 3, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 1, 2, 2, - 4, 2, 1, 1, 2, 3, 3, 2, 5, 3, - 2, 3, 2, 0, 1, 1, 1, 1, 1, 3, - 5, 6, 7, 8, 5, 1, 2, 4, 5, 6, - 7, 4, 2, 1, 2, 4, 1, 3, 1, 3, - 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, - 3, 1, 1, 1, 1, 2, 1, 1, 2, 2, - 1, 1, 2, 1, 3, 4, 1, 1, 1, 1, + 2, 0, 2, 5, 1, 2, 1, 1, 1, 1, + 1, 1, 3, 1, 4, 1, 3, 2, 2, 1, + 1, 1, 3, 2, 2, 2, 1, 2, 3, 2, + 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, + 1, 1, 3, 3, 3, 1, 3, 3, 1, 3, + 3, 1, 3, 3, 3, 3, 1, 3, 3, 1, + 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, + 3, 1, 5, 1, 3, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, + 2, 4, 2, 1, 1, 2, 3, 3, 2, 5, + 3, 2, 3, 2, 0, 1, 1, 1, 1, 1, + 3, 5, 6, 7, 8, 5, 1, 2, 4, 5, + 6, 7, 4, 2, 1, 2, 4, 1, 3, 1, + 3, 1, 1, 1, 1, 1, 1, 2, 1, 2, + 2, 3, 1, 1, 1, 1, 2, 1, 1, 2, + 2, 1, 1, 2, 1, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 5, 4, 1, 2, 3, 1, 3, - 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 3, 1, 1, 2, 3, 1, - 2, 1, 2, 5, 3, 1, 1, 4, 5, 3, - 2, 5, 7, 6, 1, 1, 1, 0, 2, 3, - 2, 2, 2, 3, 2, 1, 1, 1, 2 + 1, 1, 1, 1, 5, 4, 1, 2, 3, 1, + 3, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 2, 3, 1, 1, 2, 3, + 1, 2, 1, 2, 5, 3, 1, 1, 4, 5, + 3, 2, 5, 7, 6, 1, 1, 1, 0, 2, + 3, 2, 2, 2, 3, 2, 1, 1, 1, 2 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -1017,614 +1019,638 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint16 yydefact[] = { - 4, 0, 0, 10, 0, 1, 2, 5, 0, 0, - 11, 0, 153, 152, 173, 170, 171, 172, 177, 178, - 179, 180, 181, 182, 183, 184, 185, 174, 175, 176, - 0, 156, 157, 160, 154, 142, 141, 140, 186, 187, - 188, 189, 190, 191, 192, 193, 194, 195, 196, 198, - 199, 200, 201, 203, 204, 205, 206, 207, 208, 209, - 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, - 0, 169, 168, 151, 222, 221, 220, 0, 0, 0, - 0, 0, 0, 197, 202, 277, 3, 276, 0, 0, - 103, 113, 0, 118, 125, 145, 147, 0, 144, 133, - 161, 163, 166, 0, 167, 13, 275, 0, 158, 159, - 155, 0, 0, 132, 0, 149, 0, 6, 7, 8, - 9, 0, 14, 98, 0, 278, 101, 113, 143, 114, - 115, 116, 104, 0, 113, 0, 99, 126, 146, 148, - 134, 0, 162, 0, 0, 0, 0, 225, 150, 0, - 138, 0, 136, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 15, 19, 17, 18, 20, 41, - 0, 0, 0, 46, 47, 48, 49, 251, 0, 247, - 16, 22, 42, 24, 29, 30, 0, 0, 35, 0, - 50, 0, 54, 57, 60, 65, 68, 70, 72, 74, - 76, 78, 80, 82, 95, 0, 233, 0, 133, 236, - 249, 235, 234, 0, 237, 238, 239, 240, 241, 242, - 105, 110, 112, 117, 0, 119, 106, 0, 0, 164, - 50, 97, 0, 39, 12, 0, 230, 0, 228, 224, - 226, 100, 0, 135, 0, 271, 270, 0, 0, 0, - 274, 272, 0, 0, 0, 260, 0, 43, 44, 0, - 243, 0, 26, 27, 0, 0, 33, 32, 0, 169, - 36, 38, 85, 86, 88, 87, 90, 91, 92, 93, - 94, 89, 84, 0, 45, 0, 0, 0, 0, 0, + 4, 0, 0, 11, 0, 1, 2, 5, 0, 0, + 12, 0, 154, 153, 174, 171, 172, 173, 178, 179, + 180, 181, 182, 183, 184, 185, 186, 175, 176, 177, + 0, 157, 158, 161, 155, 143, 142, 141, 187, 188, + 189, 190, 191, 192, 193, 194, 195, 196, 197, 199, + 200, 201, 202, 204, 205, 206, 207, 208, 209, 210, + 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, + 0, 170, 169, 152, 223, 222, 221, 0, 0, 0, + 0, 0, 0, 0, 198, 203, 278, 3, 277, 0, + 0, 104, 114, 0, 119, 126, 146, 148, 0, 145, + 134, 162, 164, 167, 0, 168, 14, 276, 0, 159, + 160, 156, 0, 0, 133, 0, 150, 0, 6, 7, + 8, 9, 10, 0, 15, 99, 0, 279, 102, 114, + 144, 115, 116, 117, 105, 0, 114, 0, 100, 127, + 147, 149, 135, 0, 163, 0, 0, 0, 0, 226, + 151, 0, 139, 0, 137, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 20, 18, 19, + 21, 42, 0, 0, 0, 47, 48, 49, 50, 252, + 0, 248, 17, 23, 43, 25, 30, 31, 0, 0, + 36, 0, 51, 0, 55, 58, 61, 66, 69, 71, + 73, 75, 77, 79, 81, 83, 96, 0, 234, 0, + 134, 237, 250, 236, 235, 0, 238, 239, 240, 241, + 242, 243, 106, 111, 113, 118, 0, 120, 107, 0, + 0, 165, 51, 98, 0, 40, 13, 0, 231, 0, + 229, 225, 227, 101, 0, 136, 0, 272, 271, 0, + 0, 0, 275, 273, 0, 0, 0, 261, 0, 44, + 45, 0, 244, 0, 27, 28, 0, 0, 34, 33, + 0, 170, 37, 39, 86, 87, 89, 88, 91, 92, + 93, 94, 95, 90, 85, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 252, 248, 250, 107, - 109, 111, 0, 0, 127, 0, 232, 131, 165, 223, - 0, 0, 227, 139, 137, 0, 265, 264, 267, 0, - 273, 0, 259, 151, 256, 0, 0, 21, 244, 0, - 28, 25, 31, 37, 83, 51, 52, 53, 55, 56, - 58, 59, 63, 64, 61, 62, 66, 67, 69, 71, - 73, 75, 77, 79, 0, 96, 0, 120, 0, 124, - 0, 128, 0, 229, 0, 266, 0, 0, 0, 0, - 0, 0, 23, 0, 0, 0, 121, 129, 0, 231, - 0, 268, 0, 255, 253, 258, 0, 246, 261, 245, - 81, 108, 122, 0, 130, 0, 269, 263, 0, 257, - 123, 262, 254 + 0, 0, 0, 0, 0, 0, 0, 0, 253, 249, + 251, 108, 110, 112, 0, 0, 128, 0, 233, 132, + 166, 224, 0, 0, 228, 140, 138, 0, 266, 265, + 268, 0, 274, 0, 260, 152, 257, 0, 0, 22, + 245, 0, 29, 26, 32, 38, 84, 52, 53, 54, + 56, 57, 59, 60, 64, 65, 62, 63, 67, 68, + 70, 72, 74, 76, 78, 80, 0, 97, 0, 121, + 0, 125, 0, 129, 0, 230, 0, 267, 0, 0, + 0, 0, 0, 0, 24, 0, 0, 0, 122, 130, + 0, 232, 0, 269, 0, 256, 254, 259, 0, 247, + 262, 246, 82, 109, 123, 0, 131, 0, 270, 264, + 0, 258, 124, 263, 255 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 2, 9, 3, 85, 6, 10, 86, 180, 181, - 182, 339, 183, 184, 185, 186, 187, 188, 189, 190, - 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, - 201, 202, 203, 204, 283, 205, 232, 206, 207, 89, - 90, 91, 221, 132, 133, 222, 92, 93, 94, 95, - 151, 152, 96, 134, 97, 98, 233, 100, 101, 102, - 103, 104, 146, 147, 237, 238, 317, 209, 210, 211, - 212, 398, 399, 213, 214, 215, 394, 336, 216, 217, - 218, 328, 376, 377, 219, 105, 106 + -1, 2, 9, 3, 86, 6, 10, 87, 182, 183, + 184, 341, 185, 186, 187, 188, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + 203, 204, 205, 206, 285, 207, 234, 208, 209, 90, + 91, 92, 223, 134, 135, 224, 93, 94, 95, 96, + 153, 154, 97, 136, 98, 99, 235, 101, 102, 103, + 104, 105, 148, 149, 239, 240, 319, 211, 212, 213, + 214, 400, 401, 215, 216, 217, 396, 338, 218, 219, + 220, 330, 378, 379, 221, 106, 107 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -350 +#define YYPACT_NINF -321 static const yytype_int16 yypact[] = { - -78, -56, 54, -350, -52, -350, -37, -350, 8, 3302, - -350, -26, -350, -350, -350, -350, -350, -350, -350, -350, - -350, -350, -350, -350, -350, -350, -350, -350, -350, -350, - 88, -350, -350, -350, -350, -350, -350, -350, -350, -350, - -350, -350, -350, -350, -350, -350, -350, -350, -350, -350, - -350, -350, -350, -350, -350, -350, -350, -350, -350, -350, - -350, -350, -350, -350, -350, -350, -350, -350, -350, -350, - -66, -350, -350, 42, -350, -350, -350, 70, -4, 10, - 29, 34, -79, -350, -350, -350, 3302, -350, -19, -24, - -69, 5, -154, -350, 102, 16, 16, 3490, -350, -350, - -350, 18, -350, 3562, -350, -350, -350, 108, -350, -350, - -350, -8, 3490, -350, 16, -350, 3562, -350, -350, -350, - -350, 138, -350, -350, 387, -350, -350, 24, -350, -350, - -350, -350, -350, 3490, 147, 141, -350, -166, -350, -350, - -350, 2387, -350, 106, 3490, 144, 1772, -350, -350, 7, - 11, -87, -350, 14, 15, 1243, 30, 32, 20, 2004, - 37, 2936, 25, 39, -65, -350, -350, -350, -350, -350, - 2936, 2936, 2936, -350, -350, -350, -350, -350, 601, -350, - -350, -350, -59, -350, -350, -350, 28, -82, 3119, 43, - -30, 2936, -11, -2, 118, -74, 114, 35, 31, 36, - 148, 152, -77, -350, -350, -115, -350, 40, 52, -350, - -350, -350, -350, 815, -350, -350, -350, -350, -350, -350, - -350, -350, -350, 172, 3490, -180, -350, 2570, 2936, -350, - -350, -350, 53, -350, -350, 1888, 55, -113, -350, -350, - -350, -350, 173, -350, 138, -350, -350, 178, 1656, 2936, - -350, -350, -108, 2936, -161, -350, 2204, -350, -350, -68, - -350, 1029, -350, -350, 2936, 3418, -350, -350, 2936, 61, - -350, -350, -350, -350, -350, -350, -350, -350, -350, -350, - -350, -350, -350, 2936, -350, 2936, 2936, 2936, 2936, 2936, - 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, - 2936, 2936, 2936, 2936, 2936, 2936, -350, -350, -350, 63, - -350, -350, 2753, 2936, 46, 60, -350, -350, -350, -350, - 2936, 144, -350, -350, -350, 67, -350, -350, 2204, -55, - -350, -54, -350, 238, 65, 188, 71, -350, -350, 72, - 65, 73, -350, -350, -350, -350, -350, -350, -11, -11, - -2, -2, 118, 118, 118, 118, -74, -74, 114, 35, - 31, 36, 148, 152, -157, -350, 2936, 56, 83, -350, - 2936, 68, 84, -350, 2936, -350, 69, 90, 1243, 74, - 77, 1456, -350, 2936, 86, 2936, 79, -350, 2936, -350, - -53, 2936, 1456, 255, -350, -350, 2936, -350, -350, -350, - -350, -350, -350, 2936, -350, 80, 65, -350, 1243, -350, - -350, -350, -350 + -86, -57, 45, -321, -56, -321, -50, -321, -10, 3320, + -321, -26, -321, -321, -321, -321, -321, -321, -321, -321, + -321, -321, -321, -321, -321, -321, -321, -321, -321, -321, + 79, -321, -321, -321, -321, -321, -321, -321, -321, -321, + -321, -321, -321, -321, -321, -321, -321, -321, -321, -321, + -321, -321, -321, -321, -321, -321, -321, -321, -321, -321, + -321, -321, -321, -321, -321, -321, -321, -321, -321, -321, + -70, -321, -321, 43, -321, -321, -321, 18, -22, -12, + -5, 2, 25, -101, -321, -321, -321, 3320, -321, -43, + -55, -54, 6, -148, -321, 52, 211, 211, 3509, -321, + -321, -321, -47, -321, 3581, -321, -321, -321, 110, -321, + -321, -321, -14, 3509, -321, 211, -321, 3581, -321, -321, + -321, -321, -321, 131, -321, -321, 389, -321, -321, 15, + -321, -321, -321, -321, -321, 3509, 109, 136, -321, -152, + -321, -321, -321, 2400, -321, 105, 3509, 143, 1781, -321, + -321, 7, 9, -107, -321, 10, 12, 1249, 27, 36, + 17, 2015, 40, 2952, 22, 42, -65, -321, -321, -321, + -321, -321, 2952, 2952, 2952, -321, -321, -321, -321, -321, + 604, -321, -321, -321, -20, -321, -321, -321, 47, -92, + 3136, 46, -67, 2952, -24, -16, 111, -73, 108, 37, + 41, 39, 162, 161, -82, -321, -321, -147, -321, 44, + 61, -321, -321, -321, -321, 819, -321, -321, -321, -321, + -321, -321, -321, -321, -321, 181, 3509, -160, -321, 2584, + 2952, -321, -321, -321, 63, -321, -321, 1898, 62, -146, + -321, -321, -321, -321, 183, -321, 131, -321, -321, 187, + 1664, 2952, -321, -321, -144, 2952, -140, -321, 2216, -321, + -321, -81, -321, 1034, -321, -321, 2952, 3437, -321, -321, + 2952, 70, -321, -321, -321, -321, -321, -321, -321, -321, + -321, -321, -321, -321, -321, 2952, -321, 2952, 2952, 2952, + 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, + 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, -321, -321, + -321, 74, -321, -321, 2768, 2952, 64, 69, -321, -321, + -321, -321, 2952, 143, -321, -321, -321, 82, -321, -321, + 2216, -74, -321, -68, -321, 235, 78, 203, 85, -321, + -321, 84, 78, 88, -321, -321, -321, -321, -321, -321, + -24, -24, -16, -16, 111, 111, 111, 111, -73, -73, + 108, 37, 41, 39, 162, 161, -129, -321, 2952, 71, + 86, -321, 2952, 72, 87, -321, 2952, -321, 73, 92, + 1249, 75, 76, 1463, -321, 2952, 95, 2952, 80, -321, + 2952, -321, -63, 2952, 1463, 277, -321, -321, 2952, -321, + -321, -321, -321, -321, -321, 2952, -321, 81, 78, -321, + 1249, -321, -321, -321, -321 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -350, -350, -350, -350, -350, -350, -350, -350, -350, -350, - -350, -350, -350, -350, 22, -350, -350, -350, -350, -135, - -350, -83, -81, -104, -85, -13, -6, -5, -3, -1, - -7, -350, -133, -97, -350, -156, -193, 9, 12, -350, - -350, -350, 76, 170, 168, 81, -350, -350, -239, -350, - -350, 59, -71, -350, -350, -72, -9, 1, -350, -350, - 227, -350, 163, -139, -350, -12, -283, 62, -151, -349, - -67, -84, 223, 135, 66, -350, -350, -10, -350, -350, - -350, -350, -350, -350, -350, 229, -350 + -321, -321, -321, -321, -321, -321, -321, -321, -321, -321, + -321, -321, -321, -321, 26, -321, -321, -321, -321, -135, + -321, -91, -88, -106, -90, -3, -6, -4, -2, -1, + 0, -321, -139, -174, -321, -156, -217, 11, 13, -321, + -321, -321, 83, 170, 164, 89, -321, -321, -243, -321, + -321, 56, -71, -321, -321, -72, -9, -32, -321, -321, + 227, -321, 160, -131, -321, -15, -195, 57, -154, -320, + -69, -84, 222, 133, 66, -321, -321, -13, -321, -321, + -321, -321, -321, -321, -321, 231, -321 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -169 +#define YYTABLE_NINF -170 static const yytype_int16 yytable[] = { - 99, 115, 114, 252, 247, 254, 230, 240, 231, 128, - 111, -168, 292, 293, 303, 312, 259, 335, 87, 12, - 13, 88, 4, 138, 139, 262, 263, 226, 128, 227, - 369, 1, 397, 313, 315, 257, 258, 305, 129, 130, - 131, 305, 148, 397, 135, 12, 13, 228, 30, 31, - 32, 332, 33, 34, 5, 383, 284, 129, 130, 131, - 136, 7, 308, 272, 273, 274, 275, 276, 277, 278, - 279, 280, 281, 8, 30, 31, 32, 99, 33, 34, - 35, 36, 37, 305, 11, 321, 107, 387, 140, 335, - 305, 270, 230, 329, 231, 87, 240, 331, 88, 306, - 334, 322, 402, 145, 142, 404, 330, 243, 340, 117, - 308, 244, 267, 409, 121, 208, 268, 149, 113, 368, - 410, 108, 109, 118, 223, 110, 337, 372, -40, 127, - 305, 316, 294, 295, 304, 145, 264, 145, 265, 378, - 379, 405, 119, 305, 305, 305, 208, 120, 364, 112, - 345, 346, 347, 230, 230, 230, 230, 230, 230, 230, - 230, 230, 230, 230, 230, 230, 230, 230, 230, 208, - 126, 343, 334, 384, 74, 75, 76, 230, 137, 231, - 129, 130, 131, 282, 143, 230, 344, 231, 352, 353, - 354, 355, 285, 286, 287, 123, 124, 288, 289, -102, - 290, 291, 296, 297, 208, 348, 349, 144, 365, 350, - 351, 356, 357, 141, 150, 223, 316, 225, 390, 234, - 236, 241, 266, 248, 242, 249, 145, 393, 245, 246, - 253, 230, 256, 231, 250, 406, 271, 255, 301, 208, - 299, 12, 13, 298, 302, -39, 300, 208, 309, 318, - 320, 323, 208, 325, 123, -34, 371, 412, 366, 370, - 374, 115, 114, 305, 380, 381, -40, 408, 382, 385, - 30, 31, 32, 316, 33, 34, 35, 36, 37, 386, - 389, 388, 401, 391, 392, 358, 400, 342, 316, 178, - 396, 316, 403, 359, 411, 360, 363, 220, 361, 316, - 310, 362, 224, 324, 116, 311, 316, 235, 407, 373, - 326, 125, 395, 261, 327, 122, 0, 0, 375, 208, + 100, 116, 115, 249, 233, 254, 112, 256, 232, 305, + 130, -169, 317, 294, 295, 337, 272, 242, 261, 130, + 88, 4, 89, 1, 140, 141, 274, 275, 276, 277, + 278, 279, 280, 281, 282, 283, 314, 259, 260, 131, + 132, 133, 228, 150, 229, 5, 12, 13, 131, 132, + 133, 137, 307, 323, 315, 307, 318, 7, 286, 307, + 8, 310, 230, 399, 264, 265, 11, 138, 308, 324, + 307, 332, 144, 334, 399, 30, 31, 32, 100, 33, + 34, 35, 36, 37, 385, 151, 108, 337, 245, 142, + 233, 118, 246, 123, 232, 331, 345, 370, 88, 333, + 89, 119, 336, 269, 147, 374, 242, 270, 120, 310, + 342, 346, 109, 110, 339, 121, 111, 210, 307, 114, + 371, 380, 74, 75, 76, 307, 225, 381, 139, -41, + 306, 307, 407, 367, 296, 297, 307, 147, 122, 147, + 128, 318, 131, 132, 133, 129, 113, 284, 210, 143, + 366, 386, 347, 348, 349, 232, 232, 232, 232, 232, + 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, + 232, 210, 125, 126, 336, 233, 266, 389, 267, 232, + 287, 288, 289, 233, 290, 291, 145, 232, 354, 355, + 356, 357, 404, 292, 293, 406, 298, 299, 318, 350, + 351, -103, 146, 411, 352, 353, 210, 152, 358, 359, + 412, 402, 227, 318, 12, 13, 318, 225, 236, 238, + 392, 250, 243, 244, 318, 247, 395, 248, 147, 233, + 251, 318, 252, 232, 255, 257, 258, 408, 12, 13, + 273, 210, 268, 30, 31, 32, 300, 33, 34, 210, + 302, 301, 303, 304, 210, -40, 414, 311, 322, 125, + 320, 325, 327, 116, 115, -35, 373, 30, 31, 32, + 368, 33, 34, 35, 36, 37, 376, 307, 372, 382, + 383, 384, -41, 388, 391, 387, 390, 394, 393, 410, + 398, 180, 403, 344, 405, 361, 413, 360, 362, 222, + 226, 363, 326, 364, 117, 365, 237, 328, 375, 312, + 409, 127, 397, 263, 0, 313, 329, 377, 124, 0, + 0, 210, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, - 0, 0, 208, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 208, 0, 0, 0, 0, 0, 0, - 12, 13, 14, 15, 16, 17, 153, 154, 155, 208, - 156, 157, 158, 159, 160, 161, 162, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 163, 164, 165, 166, 167, 168, 169, 0, - 0, 170, 171, 0, 0, 0, 0, 0, 0, 0, + 0, 210, 0, 0, 210, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 210, 0, 0, 0, 0, + 0, 0, 12, 13, 14, 15, 16, 17, 155, 156, + 157, 210, 158, 159, 160, 161, 162, 163, 164, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 0, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 165, 166, 167, 168, 169, 170, + 171, 0, 0, 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 73, 74, 75, 76, 0, 77, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 82, 0, 0, + 0, 0, 73, 74, 75, 76, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 83, 0, 84, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 84, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 172, 0, 0, 0, 0, 0, 173, 174, 175, 176, + 0, 0, 0, 174, 0, 0, 0, 0, 0, 175, + 176, 177, 178, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 179, 180, 181, 12, 13, 14, + 15, 16, 17, 155, 156, 157, 0, 158, 159, 160, + 161, 162, 163, 164, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 165, + 166, 167, 168, 169, 170, 171, 0, 0, 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 177, 178, 179, 12, 13, 14, 15, 16, 17, - 153, 154, 155, 0, 156, 157, 158, 159, 160, 161, - 162, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 0, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 163, 164, 165, 166, - 167, 168, 169, 0, 0, 170, 171, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 73, 74, 75, + 76, 0, 77, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, + 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 174, 0, + 0, 0, 0, 0, 175, 176, 177, 178, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 179, + 180, 262, 12, 13, 14, 15, 16, 17, 155, 156, + 157, 0, 158, 159, 160, 161, 162, 163, 164, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 0, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 165, 166, 167, 168, 169, 170, + 171, 0, 0, 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 73, 74, 75, 76, 0, 77, + 0, 0, 73, 74, 75, 76, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, + 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 83, 0, 84, 0, 0, + 0, 0, 0, 0, 84, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 172, 0, 0, 0, 0, 0, - 173, 174, 175, 176, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 177, 178, 260, 12, 13, - 14, 15, 16, 17, 153, 154, 155, 0, 156, 157, - 158, 159, 160, 161, 162, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 0, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 163, 164, 165, 166, 167, 168, 169, 0, 0, 170, - 171, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 73, 74, - 75, 76, 0, 77, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 82, 0, 0, 0, 0, + 0, 0, 0, 174, 0, 0, 0, 0, 0, 175, + 176, 177, 178, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 179, 180, 309, 12, 13, 14, + 15, 16, 17, 155, 156, 157, 0, 158, 159, 160, + 161, 162, 163, 164, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 165, + 166, 167, 168, 169, 170, 171, 0, 0, 172, 173, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 73, 74, 75, + 76, 0, 77, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, - 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, + 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 172, 0, - 0, 0, 0, 0, 173, 174, 175, 176, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 177, - 178, 307, 12, 13, 14, 15, 16, 17, 153, 154, - 155, 0, 156, 157, 158, 159, 160, 161, 162, 18, + 0, 0, 0, 0, 0, 0, 0, 0, 174, 0, + 0, 0, 0, 0, 175, 176, 177, 178, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 179, + 180, 340, 12, 13, 14, 15, 16, 17, 155, 156, + 157, 0, 158, 159, 160, 161, 162, 163, 164, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 163, 164, 165, 166, 167, 168, - 169, 0, 0, 170, 171, 0, 0, 0, 0, 0, + 68, 69, 70, 71, 165, 166, 167, 168, 169, 170, + 171, 0, 0, 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 74, 75, 76, 0, 77, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 83, 0, 84, 0, 0, 0, 0, + 0, 0, 0, 0, 84, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 172, 0, 0, 0, 0, 0, 173, 174, - 175, 176, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 177, 178, 338, 12, 13, 14, 15, - 16, 17, 153, 154, 155, 0, 156, 157, 158, 159, - 160, 161, 162, 18, 19, 20, 21, 22, 23, 24, + 0, 0, 0, 174, 0, 0, 0, 0, 0, 175, + 176, 177, 178, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 179, 180, 12, 13, 14, 15, + 16, 17, 155, 156, 157, 0, 158, 159, 160, 161, + 162, 163, 164, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 163, 164, - 165, 166, 167, 168, 169, 0, 0, 170, 171, 0, + 64, 65, 66, 67, 68, 69, 70, 71, 165, 166, + 167, 168, 169, 170, 171, 0, 0, 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 74, 75, 76, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 83, 0, 84, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 172, 0, 0, 0, - 0, 0, 173, 174, 175, 176, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 177, 178, 12, - 13, 14, 15, 16, 17, 153, 154, 155, 0, 156, - 157, 158, 159, 160, 161, 162, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 0, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 163, 164, 165, 166, 167, 168, 169, 0, 0, - 170, 171, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, - 74, 75, 76, 0, 77, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 82, 0, 0, 0, + 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 84, 0, + 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 83, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 174, 0, 0, + 0, 0, 0, 175, 176, 177, 178, 12, 13, 14, + 15, 16, 17, 0, 0, 0, 0, 0, 179, 126, + 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 0, + 166, 167, 168, 169, 170, 171, 0, 0, 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 172, - 0, 0, 0, 0, 0, 173, 174, 175, 176, 12, - 13, 14, 15, 16, 17, 0, 0, 0, 0, 0, - 177, 124, 0, 0, 0, 0, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 0, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 0, 164, 165, 166, 167, 168, 169, 0, 0, - 170, 171, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, - 74, 75, 76, 0, 77, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 82, 14, 15, 16, - 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, - 83, 0, 84, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 0, 72, 172, - 0, 0, 0, 0, 0, 173, 174, 175, 176, 0, + 0, 0, 0, 0, 0, 0, 0, 73, 74, 75, + 76, 0, 77, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 83, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 177, 0, 0, 0, 0, 0, 74, 75, 76, 0, + 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 0, 0, 0, 0, 0, 0, 84, + 0, 85, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 0, 72, 174, 0, + 0, 0, 0, 0, 175, 176, 177, 178, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 179, + 0, 0, 0, 0, 0, 74, 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 0, 0, 0, 0, 0, 0, 83, 0, 84, 38, + 0, 0, 0, 0, 0, 0, 84, 0, 85, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 239, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 241, 0, 0, 0, 74, 75, 76, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, - 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, - 0, 0, 83, 0, 84, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 0, - 164, 165, 166, 167, 168, 169, 0, 0, 170, 171, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 319, 0, 0, 0, 74, 75, - 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, - 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 172, 0, 0, - 0, 0, 0, 173, 174, 175, 176, 12, 13, 14, - 15, 16, 17, 0, 0, 0, 0, 0, 251, 0, - 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 0, - 164, 165, 166, 167, 168, 169, 0, 0, 170, 171, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 333, 74, 75, - 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 82, 0, 0, 0, 0, 0, + 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 0, 0, 0, + 0, 0, 0, 84, 0, 85, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 0, 166, 167, 168, 169, 170, 171, 0, 0, 172, + 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 321, 0, 0, 0, 74, + 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, - 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 14, 15, 16, 17, 0, 172, 0, 0, - 0, 0, 0, 173, 174, 175, 176, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 0, 164, 165, 166, 167, 168, 169, 0, - 0, 170, 171, 0, 0, 0, 0, 0, 0, 0, + 84, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 74, 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 174, + 0, 0, 0, 0, 0, 175, 176, 177, 178, 12, + 13, 14, 15, 16, 17, 0, 0, 0, 0, 0, + 253, 0, 0, 0, 0, 0, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 0, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 0, 166, 167, 168, 169, 170, 171, 0, 0, + 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 335, + 74, 75, 76, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 83, 0, 84, 0, 0, 0, 0, 0, 0, + 0, 84, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, - 172, 0, 0, 229, 0, 0, 173, 174, 175, 176, + 174, 0, 0, 0, 0, 0, 175, 176, 177, 178, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 0, 164, 165, 166, 167, - 168, 169, 0, 0, 170, 171, 0, 0, 0, 0, + 67, 68, 69, 70, 71, 0, 166, 167, 168, 169, + 170, 171, 0, 0, 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 83, 0, 84, 0, 0, 0, + 0, 0, 0, 0, 0, 84, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 14, 15, - 16, 17, 0, 172, 0, 0, 314, 0, 0, 173, - 174, 175, 176, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 0, 164, - 165, 166, 167, 168, 169, 0, 0, 170, 171, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, + 15, 16, 17, 0, 174, 0, 0, 231, 0, 0, + 175, 176, 177, 178, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 0, + 166, 167, 168, 169, 170, 171, 0, 0, 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 74, 75, 76, + 0, 0, 0, 0, 0, 0, 0, 0, 74, 75, + 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, + 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 83, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 14, 15, 16, 17, 0, 174, 0, + 0, 316, 0, 0, 175, 176, 177, 178, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 0, 166, 167, 168, 169, 170, 171, + 0, 0, 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 74, 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 14, 15, 16, 17, 0, 172, 0, 0, 367, - 0, 0, 173, 174, 175, 176, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 0, 164, 165, 166, 167, 168, 169, 0, 0, - 170, 171, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 74, 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 84, 0, 85, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, + 17, 0, 174, 0, 0, 369, 0, 0, 175, 176, + 177, 178, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 0, 166, 167, + 168, 169, 170, 171, 0, 0, 172, 173, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 74, 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 83, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 14, 15, 16, 17, 0, 172, - 0, 0, 0, 0, 0, 173, 174, 175, 176, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 269, 0, 164, 165, 166, 167, 168, - 169, 0, 0, 170, 171, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 84, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 74, 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 14, 15, 16, 17, 0, 174, 0, 0, 0, + 0, 0, 175, 176, 177, 178, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 271, 0, 166, 167, 168, 169, 170, 171, 0, 0, + 172, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 74, 75, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 83, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 12, 13, 14, 15, 16, - 17, 0, 172, 0, 0, 0, 0, 0, 173, 174, - 175, 176, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 0, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 84, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 73, 74, 75, 76, 0, - 77, 0, 0, 0, 0, 0, 0, 0, 78, 79, - 80, 81, 82, 14, 15, 16, 17, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 0, 0, 0, 0, 0, 0, 83, 0, 84, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 0, 341, 14, 15, 16, 17, 169, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 12, 13, 14, 15, 16, 17, 0, + 174, 0, 0, 0, 0, 0, 175, 176, 177, 178, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 74, 75, 76, 0, 0, 0, 0, 0, - 0, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 28, 29, 30, 31, 32, 0, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 0, 72, 14, 15, 16, - 17, 0, 83, 0, 84, 0, 0, 0, 0, 0, - 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 74, 75, 76, 0, 0, 0, - 0, 0, 0, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 0, 72, 0, - 0, 0, 0, 0, 83, 0, 84, 0, 0, 0, + 67, 68, 69, 70, 71, 0, 72, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 73, 74, 75, 76, 0, 77, 0, + 0, 0, 0, 0, 0, 0, 78, 79, 80, 81, + 82, 83, 14, 15, 16, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, + 0, 0, 0, 0, 0, 84, 0, 85, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 0, 343, 14, 15, 16, 17, 171, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 74, 75, 76, 0, 0, 0, 0, 0, 0, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 0, 72, 14, 15, 16, 17, + 0, 0, 84, 0, 85, 0, 0, 0, 0, 0, + 0, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 74, 75, 76, 0, 0, 0, 0, + 0, 0, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 0, 72, 0, 0, + 0, 0, 0, 0, 84, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 83, 0, 84 + 0, 0, 0, 0, 0, 0, 84, 0, 85 }; static const yytype_int16 yycheck[] = { - 9, 73, 73, 159, 155, 161, 141, 146, 141, 4, - 76, 76, 86, 87, 91, 195, 172, 256, 9, 3, - 4, 9, 78, 95, 96, 84, 85, 193, 4, 195, - 313, 109, 381, 213, 227, 170, 171, 198, 33, 34, - 35, 198, 114, 392, 198, 3, 4, 213, 32, 33, - 34, 212, 36, 37, 0, 212, 191, 33, 34, 35, - 214, 113, 213, 93, 94, 95, 96, 97, 98, 99, - 100, 101, 102, 110, 32, 33, 34, 86, 36, 37, - 38, 39, 40, 198, 76, 198, 112, 370, 97, 328, - 198, 188, 227, 249, 227, 86, 235, 253, 86, 214, - 256, 214, 385, 112, 103, 388, 214, 194, 264, 113, - 261, 198, 194, 396, 193, 124, 198, 116, 76, 312, - 403, 33, 34, 113, 133, 37, 194, 320, 193, 198, - 198, 228, 206, 207, 211, 144, 195, 146, 197, 194, - 194, 194, 113, 198, 198, 198, 155, 113, 304, 215, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 178, - 194, 268, 328, 366, 104, 105, 106, 312, 76, 312, - 33, 34, 35, 213, 76, 320, 283, 320, 292, 293, - 294, 295, 203, 204, 205, 214, 215, 199, 200, 194, - 82, 83, 88, 89, 213, 288, 289, 215, 305, 290, - 291, 296, 297, 195, 76, 224, 313, 76, 374, 113, - 76, 214, 194, 193, 213, 193, 235, 378, 214, 214, - 193, 366, 193, 366, 214, 391, 193, 212, 90, 248, - 209, 3, 4, 208, 92, 193, 210, 256, 76, 196, - 195, 78, 261, 75, 214, 194, 196, 408, 195, 213, - 193, 333, 333, 198, 76, 194, 193, 12, 196, 213, - 32, 33, 34, 370, 36, 37, 38, 39, 40, 196, - 196, 213, 196, 214, 194, 298, 383, 265, 385, 215, - 213, 388, 213, 299, 214, 300, 303, 127, 301, 396, - 224, 302, 134, 244, 77, 224, 403, 144, 392, 321, - 248, 88, 379, 178, 248, 86, -1, -1, 328, 328, + 9, 73, 73, 157, 143, 161, 76, 163, 143, 91, + 4, 76, 229, 86, 87, 258, 190, 148, 174, 4, + 9, 78, 9, 109, 96, 97, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 196, 172, 173, 33, + 34, 35, 194, 115, 196, 0, 3, 4, 33, 34, + 35, 199, 199, 199, 214, 199, 230, 113, 193, 199, + 110, 215, 214, 383, 84, 85, 76, 215, 215, 215, + 199, 215, 104, 213, 394, 32, 33, 34, 87, 36, + 37, 38, 39, 40, 213, 117, 112, 330, 195, 98, + 229, 113, 199, 194, 229, 251, 270, 314, 87, 255, + 87, 113, 258, 195, 113, 322, 237, 199, 113, 263, + 266, 285, 33, 34, 195, 113, 37, 126, 199, 76, + 315, 195, 104, 105, 106, 199, 135, 195, 76, 194, + 212, 199, 195, 307, 207, 208, 199, 146, 113, 148, + 195, 315, 33, 34, 35, 199, 216, 214, 157, 196, + 306, 368, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 180, 215, 216, 330, 314, 196, 372, 198, 314, + 204, 205, 206, 322, 200, 201, 76, 322, 294, 295, + 296, 297, 387, 82, 83, 390, 88, 89, 372, 290, + 291, 195, 216, 398, 292, 293, 215, 76, 298, 299, + 405, 385, 76, 387, 3, 4, 390, 226, 113, 76, + 376, 194, 215, 214, 398, 215, 380, 215, 237, 368, + 194, 405, 215, 368, 194, 213, 194, 393, 3, 4, + 194, 250, 195, 32, 33, 34, 209, 36, 37, 258, + 211, 210, 90, 92, 263, 194, 410, 76, 196, 215, + 197, 78, 75, 335, 335, 195, 197, 32, 33, 34, + 196, 36, 37, 38, 39, 40, 194, 199, 214, 76, + 195, 197, 194, 197, 197, 214, 214, 195, 215, 12, + 214, 216, 197, 267, 214, 301, 215, 300, 302, 129, + 136, 303, 246, 304, 77, 305, 146, 250, 323, 226, + 394, 89, 381, 180, -1, 226, 250, 330, 87, -1, + -1, 330, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 378, - -1, -1, 381, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 392, -1, -1, -1, -1, -1, -1, - 3, 4, 5, 6, 7, 8, 9, 10, 11, 408, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 80, 81, -1, - -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, + -1, 380, -1, -1, 383, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 394, -1, -1, -1, -1, + -1, -1, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 410, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, -1, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 103, 104, 105, 106, -1, 108, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 120, -1, -1, + -1, -1, 103, 104, 105, 106, -1, 108, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 121, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 155, -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 193, -1, -1, -1, -1, -1, 199, 200, 201, 202, + -1, -1, -1, 194, -1, -1, -1, -1, -1, 200, + 201, 202, 203, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 215, 216, 217, 3, 4, 5, + 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 214, 215, 216, 3, 4, 5, 6, 7, 8, - 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, -1, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, -1, -1, 84, 85, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 103, 104, 105, + 106, -1, 108, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 121, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 103, 104, 105, 106, -1, 108, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 155, + -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 194, -1, + -1, -1, -1, -1, 200, 201, 202, 203, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 215, + 216, 217, 3, 4, 5, 6, 7, 8, 9, 10, + 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, -1, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 103, 104, 105, 106, -1, 108, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 121, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 193, -1, -1, -1, -1, -1, - 199, 200, 201, 202, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 214, 215, 216, 3, 4, - 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, -1, -1, 84, - 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 103, 104, - 105, 106, -1, 108, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 155, -1, 157, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 194, -1, -1, -1, -1, -1, 200, + 201, 202, 203, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 215, 216, 217, 3, 4, 5, + 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, -1, -1, 84, 85, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 103, 104, 105, + 106, -1, 108, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 121, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, - -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 155, + -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 193, -1, - -1, -1, -1, -1, 199, 200, 201, 202, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 214, - 215, 216, 3, 4, 5, 6, 7, 8, 9, 10, + -1, -1, -1, -1, -1, -1, -1, -1, 194, -1, + -1, -1, -1, -1, 200, 201, 202, 203, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 215, + 216, 217, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, 36, 37, 38, 39, 40, @@ -1635,17 +1661,17 @@ static const yytype_int16 yycheck[] = 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, 104, 105, 106, -1, 108, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 121, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, + -1, -1, -1, -1, 155, -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 193, -1, -1, -1, -1, -1, 199, 200, - 201, 202, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 214, 215, 216, 3, 4, 5, 6, + -1, -1, -1, 194, -1, -1, -1, -1, -1, 200, + 201, 202, 203, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 215, 216, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, 36, @@ -1657,129 +1683,90 @@ static const yytype_int16 yycheck[] = -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, 104, 105, 106, -1, 108, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 120, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 121, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 155, -1, + 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 193, -1, -1, -1, - -1, -1, 199, 200, 201, 202, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 214, 215, 3, - 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, -1, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, 78, 79, 80, 81, -1, -1, - 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, - 104, 105, 106, -1, 108, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 120, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 194, -1, -1, + -1, -1, -1, 200, 201, 202, 203, 3, 4, 5, + 6, 7, 8, -1, -1, -1, -1, -1, 215, 216, + -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, + 76, 77, 78, 79, 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 193, - -1, -1, -1, -1, -1, 199, 200, 201, 202, 3, - 4, 5, 6, 7, 8, -1, -1, -1, -1, -1, - 214, 215, -1, -1, -1, -1, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, -1, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, -1, 76, 77, 78, 79, 80, 81, -1, -1, - 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, - 104, 105, 106, -1, 108, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 120, 5, 6, 7, - 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, - 154, -1, 156, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, -1, 76, 193, - -1, -1, -1, -1, -1, 199, 200, 201, 202, -1, + -1, -1, -1, -1, -1, -1, -1, 103, 104, 105, + 106, -1, 108, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 121, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 214, -1, -1, -1, -1, -1, 104, 105, 106, -1, + -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, -1, -1, -1, -1, -1, -1, 155, + -1, 157, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, -1, 76, 194, -1, + -1, -1, -1, -1, 200, 201, 202, 203, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 215, + -1, -1, -1, -1, -1, 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - -1, -1, -1, -1, -1, -1, 154, -1, 156, 41, + -1, -1, -1, -1, -1, -1, 155, -1, 157, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, 76, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 216, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 217, -1, -1, -1, 104, 105, 106, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, - 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, - -1, -1, 154, -1, 156, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, - 76, 77, 78, 79, 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 216, -1, -1, -1, 104, 105, - 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 5, 6, 7, 8, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, -1, -1, -1, + -1, -1, -1, 155, -1, 157, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + -1, 76, 77, 78, 79, 80, 81, -1, -1, 84, + 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 217, -1, -1, -1, 104, + 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 154, -1, - 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 155, -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 193, -1, -1, - -1, -1, -1, 199, 200, 201, 202, 3, 4, 5, - 6, 7, 8, -1, -1, -1, -1, -1, 214, -1, - -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, - 76, 77, 78, 79, 80, 81, -1, -1, 84, 85, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 103, 104, 105, - 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 120, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 154, -1, - 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 5, 6, 7, 8, -1, 193, -1, -1, - -1, -1, -1, 199, 200, 201, 202, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, -1, 76, 77, 78, 79, 80, 81, -1, - -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 194, + -1, -1, -1, -1, -1, 200, 201, 202, 203, 3, + 4, 5, 6, 7, 8, -1, -1, -1, -1, -1, + 215, -1, -1, -1, -1, -1, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, -1, 76, 77, 78, 79, 80, 81, -1, -1, + 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, + 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 121, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, + -1, 155, -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, - 193, -1, -1, 196, -1, -1, 199, 200, 201, 202, + 194, -1, -1, -1, -1, -1, 200, 201, 202, 203, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, @@ -1793,154 +1780,173 @@ static const yytype_int16 yycheck[] = -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, + -1, -1, -1, -1, -1, 155, -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, - 7, 8, -1, 193, -1, -1, 196, -1, -1, 199, - 200, 201, 202, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, -1, 76, - 77, 78, 79, 80, 81, -1, -1, 84, 85, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, + 6, 7, 8, -1, 194, -1, -1, 197, -1, -1, + 200, 201, 202, 203, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 41, 42, 43, 44, 45, + 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, -1, + 76, 77, 78, 79, 80, 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 104, 105, 106, + -1, -1, -1, -1, -1, -1, -1, -1, 104, 105, + 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 155, + -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 5, 6, 7, 8, -1, 194, -1, + -1, 197, -1, -1, 200, 201, 202, 203, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, -1, 76, 77, 78, 79, 80, 81, + -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 5, 6, 7, 8, -1, 193, -1, -1, 196, - -1, -1, 199, 200, 201, 202, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, -1, 76, 77, 78, 79, 80, 81, -1, -1, - 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 155, -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, + 8, -1, 194, -1, -1, 197, -1, -1, 200, 201, + 202, 203, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, -1, 76, 77, + 78, 79, 80, 81, -1, -1, 84, 85, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 104, 105, 106, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 5, 6, 7, 8, -1, 193, - -1, -1, -1, -1, -1, 199, 200, 201, 202, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, -1, 76, 77, 78, 79, 80, - 81, -1, -1, 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 104, 105, 106, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 155, -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 5, 6, 7, 8, -1, 194, -1, -1, -1, + -1, -1, 200, 201, 202, 203, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, -1, 76, 77, 78, 79, 80, 81, -1, -1, + 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 104, 105, 106, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 154, -1, 156, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 3, 4, 5, 6, 7, - 8, -1, 193, -1, -1, -1, -1, -1, 199, 200, - 201, 202, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, -1, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, -1, 76, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 155, -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 103, 104, 105, 106, -1, - 108, -1, -1, -1, -1, -1, -1, -1, 116, 117, - 118, 119, 120, 5, 6, 7, 8, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - -1, -1, -1, -1, -1, -1, 154, -1, 156, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, -1, 76, 5, 6, 7, 8, 81, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 3, 4, 5, 6, 7, 8, -1, + 194, -1, -1, -1, -1, -1, 200, 201, 202, 203, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 104, 105, 106, -1, -1, -1, -1, -1, - -1, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 30, 31, 32, 33, 34, -1, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, -1, 76, 5, 6, 7, - 8, -1, 154, -1, 156, -1, -1, -1, -1, -1, - -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 104, 105, 106, -1, -1, -1, - -1, -1, -1, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, -1, 76, -1, - -1, -1, -1, -1, 154, -1, 156, -1, -1, -1, + 70, 71, 72, 73, 74, -1, 76, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 103, 104, 105, 106, -1, 108, -1, + -1, -1, -1, -1, -1, -1, 116, 117, 118, 119, + 120, 121, 5, 6, 7, 8, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + -1, -1, -1, -1, -1, 155, -1, 157, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, -1, 76, 5, 6, 7, 8, 81, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 104, 105, 106, -1, -1, -1, -1, -1, -1, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, -1, 76, 5, 6, 7, 8, + -1, -1, 155, -1, 157, -1, -1, -1, -1, -1, + -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 104, 105, 106, -1, -1, -1, -1, + -1, -1, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, -1, 76, -1, -1, + -1, -1, -1, -1, 155, -1, 157, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 154, -1, 156 + -1, -1, -1, -1, -1, -1, 155, -1, 157 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint16 yystos[] = { - 0, 109, 218, 220, 78, 0, 222, 113, 110, 219, - 223, 76, 3, 4, 5, 6, 7, 8, 20, 21, + 0, 109, 219, 221, 78, 0, 223, 113, 110, 220, + 224, 76, 3, 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 103, 104, 105, 106, 108, 116, 117, - 118, 119, 120, 154, 156, 221, 224, 254, 255, 256, - 257, 258, 263, 264, 265, 266, 269, 271, 272, 273, - 274, 275, 276, 277, 278, 302, 303, 112, 33, 34, - 37, 76, 215, 76, 269, 272, 277, 113, 113, 113, - 113, 193, 302, 214, 215, 289, 194, 198, 4, 33, - 34, 35, 260, 261, 270, 198, 214, 76, 272, 272, - 273, 195, 274, 76, 215, 273, 279, 280, 272, 274, - 76, 267, 268, 9, 10, 11, 13, 14, 15, 16, - 17, 18, 19, 75, 76, 77, 78, 79, 80, 81, - 84, 85, 193, 199, 200, 201, 202, 214, 215, 216, - 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, - 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, - 246, 247, 248, 249, 250, 252, 254, 255, 273, 284, - 285, 286, 287, 290, 291, 292, 295, 296, 297, 301, - 260, 259, 262, 273, 261, 76, 193, 195, 213, 196, - 236, 249, 253, 273, 113, 279, 76, 281, 282, 216, - 280, 214, 213, 194, 198, 214, 214, 285, 193, 193, - 214, 214, 252, 193, 252, 212, 193, 236, 236, 252, - 216, 290, 84, 85, 195, 197, 194, 194, 198, 74, - 250, 193, 93, 94, 95, 96, 97, 98, 99, 100, - 101, 102, 213, 251, 236, 203, 204, 205, 199, 200, - 82, 83, 86, 87, 206, 207, 88, 89, 208, 209, - 210, 90, 92, 91, 211, 198, 214, 216, 285, 76, - 259, 262, 195, 213, 196, 253, 250, 283, 196, 216, - 195, 198, 214, 78, 268, 75, 284, 291, 298, 252, - 214, 252, 212, 103, 252, 265, 294, 194, 216, 228, - 252, 76, 231, 250, 250, 236, 236, 236, 238, 238, - 239, 239, 240, 240, 240, 240, 241, 241, 242, 243, - 244, 245, 246, 247, 252, 250, 195, 196, 253, 283, - 213, 196, 253, 282, 193, 294, 299, 300, 194, 194, - 76, 194, 196, 212, 253, 213, 196, 283, 213, 196, - 252, 214, 194, 285, 293, 287, 213, 286, 288, 289, - 250, 196, 283, 213, 283, 194, 252, 288, 12, 283, - 283, 214, 285 + 118, 119, 120, 121, 155, 157, 222, 225, 255, 256, + 257, 258, 259, 264, 265, 266, 267, 270, 272, 273, + 274, 275, 276, 277, 278, 279, 303, 304, 112, 33, + 34, 37, 76, 216, 76, 270, 273, 278, 113, 113, + 113, 113, 113, 194, 303, 215, 216, 290, 195, 199, + 4, 33, 34, 35, 261, 262, 271, 199, 215, 76, + 273, 273, 274, 196, 275, 76, 216, 274, 280, 281, + 273, 275, 76, 268, 269, 9, 10, 11, 13, 14, + 15, 16, 17, 18, 19, 75, 76, 77, 78, 79, + 80, 81, 84, 85, 194, 200, 201, 202, 203, 215, + 216, 217, 226, 227, 228, 230, 231, 232, 233, 234, + 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, + 245, 246, 247, 248, 249, 250, 251, 253, 255, 256, + 274, 285, 286, 287, 288, 291, 292, 293, 296, 297, + 298, 302, 261, 260, 263, 274, 262, 76, 194, 196, + 214, 197, 237, 250, 254, 274, 113, 280, 76, 282, + 283, 217, 281, 215, 214, 195, 199, 215, 215, 286, + 194, 194, 215, 215, 253, 194, 253, 213, 194, 237, + 237, 253, 217, 291, 84, 85, 196, 198, 195, 195, + 199, 74, 251, 194, 93, 94, 95, 96, 97, 98, + 99, 100, 101, 102, 214, 252, 237, 204, 205, 206, + 200, 201, 82, 83, 86, 87, 207, 208, 88, 89, + 209, 210, 211, 90, 92, 91, 212, 199, 215, 217, + 286, 76, 260, 263, 196, 214, 197, 254, 251, 284, + 197, 217, 196, 199, 215, 78, 269, 75, 285, 292, + 299, 253, 215, 253, 213, 103, 253, 266, 295, 195, + 217, 229, 253, 76, 232, 251, 251, 237, 237, 237, + 239, 239, 240, 240, 241, 241, 241, 241, 242, 242, + 243, 244, 245, 246, 247, 248, 253, 251, 196, 197, + 254, 284, 214, 197, 254, 283, 194, 295, 300, 301, + 195, 195, 76, 195, 197, 213, 254, 214, 197, 284, + 214, 197, 253, 215, 195, 286, 294, 288, 214, 287, + 289, 290, 251, 197, 284, 214, 284, 195, 253, 289, + 12, 284, 284, 215, 286 }; #define yyerrok (yyerrstatus = 0) @@ -1955,18 +1961,9 @@ static const yytype_uint16 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ + Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) @@ -2023,7 +2020,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -2565,7 +2562,7 @@ YYLTYPE yylloc; YYLTYPE *yylsp; /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[3]; + YYLTYPE yyerror_range[2]; YYSIZE_T yystacksize; @@ -2612,7 +2609,7 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; @@ -2620,7 +2617,7 @@ YYLTYPE yylloc; /* User initialization code. */ -/* Line 1251 of yacc.c */ +/* Line 1242 of yacc.c */ #line 41 "glsl_parser.ypp" { yylloc.first_line = 1; @@ -2630,8 +2627,8 @@ YYLTYPE yylloc; yylloc.source = 0; } -/* Line 1251 of yacc.c */ -#line 2635 "glsl_parser.cpp" +/* Line 1242 of yacc.c */ +#line 2632 "glsl_parser.cpp" yylsp[0] = yylloc; goto yysetstate; @@ -2818,8 +2815,8 @@ yyreduce: { case 2: -/* Line 1464 of yacc.c */ -#line 212 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 213 "glsl_parser.ypp" { _mesa_glsl_initialize_types(state); ;} @@ -2827,8 +2824,8 @@ yyreduce: case 5: -/* Line 1464 of yacc.c */ -#line 221 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 222 "glsl_parser.ypp" { switch ((yyvsp[(2) - (3)].n)) { case 100: @@ -2847,10 +2844,28 @@ yyreduce: ;} break; - case 12: + case 10: + +/* Line 1455 of yacc.c */ +#line 246 "glsl_parser.ypp" + { + if (state->language_version < 120) { + _mesa_glsl_warning(& (yylsp[(1) - (2)]), state, + "pragma `invariant(all)' not supported in " + "GLSL%s %d.%02d", + state->es_shader ? " ES" : "", + state->language_version / 100, + state->language_version % 100); + } else { + state->all_invariant = true; + } + ;} + break; + + case 13: -/* Line 1464 of yacc.c */ -#line 253 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 267 "glsl_parser.ypp" { if (!_mesa_glsl_process_extension((yyvsp[(2) - (5)].identifier), & (yylsp[(2) - (5)]), (yyvsp[(4) - (5)].identifier), & (yylsp[(4) - (5)]), state)) { YYERROR; @@ -2858,10 +2873,10 @@ yyreduce: ;} break; - case 13: + case 14: -/* Line 1464 of yacc.c */ -#line 262 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 276 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -2871,10 +2886,10 @@ yyreduce: ;} break; - case 14: + case 15: -/* Line 1464 of yacc.c */ -#line 270 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 284 "glsl_parser.ypp" { /* FINISHME: The NULL test is only required because 'precision' * FINISHME: statements are not yet supported. @@ -2884,10 +2899,10 @@ yyreduce: ;} break; - case 16: + case 17: -/* Line 1464 of yacc.c */ -#line 285 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 299 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); @@ -2896,10 +2911,10 @@ yyreduce: ;} break; - case 17: + case 18: -/* Line 1464 of yacc.c */ -#line 292 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 306 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); @@ -2908,10 +2923,10 @@ yyreduce: ;} break; - case 18: + case 19: -/* Line 1464 of yacc.c */ -#line 299 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 313 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); @@ -2920,10 +2935,10 @@ yyreduce: ;} break; - case 19: + case 20: -/* Line 1464 of yacc.c */ -#line 306 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 320 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); @@ -2932,10 +2947,10 @@ yyreduce: ;} break; - case 20: + case 21: -/* Line 1464 of yacc.c */ -#line 313 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 327 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); @@ -2944,19 +2959,19 @@ yyreduce: ;} break; - case 21: + case 22: -/* Line 1464 of yacc.c */ -#line 320 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 334 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(2) - (3)].expression); ;} break; - case 23: + case 24: -/* Line 1464 of yacc.c */ -#line 328 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 342 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_array_index, (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression), NULL); @@ -2964,19 +2979,19 @@ yyreduce: ;} break; - case 24: + case 25: -/* Line 1464 of yacc.c */ -#line 334 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 348 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} break; - case 25: + case 26: -/* Line 1464 of yacc.c */ -#line 338 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 352 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), NULL, NULL); @@ -2985,10 +3000,10 @@ yyreduce: ;} break; - case 26: + case 27: -/* Line 1464 of yacc.c */ -#line 345 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 359 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_inc, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -2996,10 +3011,10 @@ yyreduce: ;} break; - case 27: + case 28: -/* Line 1464 of yacc.c */ -#line 351 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 365 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_post_dec, (yyvsp[(1) - (2)].expression), NULL, NULL); @@ -3007,10 +3022,10 @@ yyreduce: ;} break; - case 31: + case 32: -/* Line 1464 of yacc.c */ -#line 369 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 383 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -3018,10 +3033,10 @@ yyreduce: ;} break; - case 36: + case 37: -/* Line 1464 of yacc.c */ -#line 388 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 402 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (2)].expression); (yyval.expression)->set_location(yylloc); @@ -3029,10 +3044,10 @@ yyreduce: ;} break; - case 37: + case 38: -/* Line 1464 of yacc.c */ -#line 394 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 408 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (3)].expression); (yyval.expression)->set_location(yylloc); @@ -3040,10 +3055,10 @@ yyreduce: ;} break; - case 39: + case 40: -/* Line 1464 of yacc.c */ -#line 410 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 424 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_function_expression((yyvsp[(1) - (1)].type_specifier)); @@ -3051,10 +3066,10 @@ yyreduce: ;} break; - case 40: + case 41: -/* Line 1464 of yacc.c */ -#line 416 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 430 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -3063,10 +3078,10 @@ yyreduce: ;} break; - case 41: + case 42: -/* Line 1464 of yacc.c */ -#line 423 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 437 "glsl_parser.ypp" { void *ctx = state; ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); @@ -3075,10 +3090,10 @@ yyreduce: ;} break; - case 43: + case 44: -/* Line 1464 of yacc.c */ -#line 435 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 449 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_inc, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3086,10 +3101,10 @@ yyreduce: ;} break; - case 44: + case 45: -/* Line 1464 of yacc.c */ -#line 441 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 455 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_pre_dec, (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3097,10 +3112,10 @@ yyreduce: ;} break; - case 45: + case 46: -/* Line 1464 of yacc.c */ -#line 447 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 461 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(1) - (2)].n), (yyvsp[(2) - (2)].expression), NULL, NULL); @@ -3108,38 +3123,38 @@ yyreduce: ;} break; - case 46: + case 47: -/* Line 1464 of yacc.c */ -#line 456 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 470 "glsl_parser.ypp" { (yyval.n) = ast_plus; ;} break; - case 47: + case 48: -/* Line 1464 of yacc.c */ -#line 457 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 471 "glsl_parser.ypp" { (yyval.n) = ast_neg; ;} break; - case 48: + case 49: -/* Line 1464 of yacc.c */ -#line 458 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 472 "glsl_parser.ypp" { (yyval.n) = ast_logic_not; ;} break; - case 49: + case 50: -/* Line 1464 of yacc.c */ -#line 459 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 473 "glsl_parser.ypp" { (yyval.n) = ast_bit_not; ;} break; - case 51: + case 52: -/* Line 1464 of yacc.c */ -#line 465 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 479 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mul, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3147,10 +3162,10 @@ yyreduce: ;} break; - case 52: + case 53: -/* Line 1464 of yacc.c */ -#line 471 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 485 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_div, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3158,10 +3173,10 @@ yyreduce: ;} break; - case 53: + case 54: -/* Line 1464 of yacc.c */ -#line 477 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 491 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_mod, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3169,10 +3184,10 @@ yyreduce: ;} break; - case 55: + case 56: -/* Line 1464 of yacc.c */ -#line 487 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 501 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_add, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3180,10 +3195,10 @@ yyreduce: ;} break; - case 56: + case 57: -/* Line 1464 of yacc.c */ -#line 493 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 507 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_sub, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3191,10 +3206,10 @@ yyreduce: ;} break; - case 58: + case 59: -/* Line 1464 of yacc.c */ -#line 503 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 517 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3202,10 +3217,10 @@ yyreduce: ;} break; - case 59: + case 60: -/* Line 1464 of yacc.c */ -#line 509 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 523 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_rshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3213,10 +3228,10 @@ yyreduce: ;} break; - case 61: + case 62: -/* Line 1464 of yacc.c */ -#line 519 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 533 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_less, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3224,10 +3239,10 @@ yyreduce: ;} break; - case 62: + case 63: -/* Line 1464 of yacc.c */ -#line 525 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 539 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_greater, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3235,10 +3250,10 @@ yyreduce: ;} break; - case 63: + case 64: -/* Line 1464 of yacc.c */ -#line 531 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 545 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_lequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3246,10 +3261,10 @@ yyreduce: ;} break; - case 64: + case 65: -/* Line 1464 of yacc.c */ -#line 537 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 551 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_gequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3257,10 +3272,10 @@ yyreduce: ;} break; - case 66: + case 67: -/* Line 1464 of yacc.c */ -#line 547 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 561 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_equal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3268,10 +3283,10 @@ yyreduce: ;} break; - case 67: + case 68: -/* Line 1464 of yacc.c */ -#line 553 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 567 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_nequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3279,10 +3294,10 @@ yyreduce: ;} break; - case 69: + case 70: -/* Line 1464 of yacc.c */ -#line 563 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 577 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3290,10 +3305,10 @@ yyreduce: ;} break; - case 71: + case 72: -/* Line 1464 of yacc.c */ -#line 573 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 587 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3301,10 +3316,10 @@ yyreduce: ;} break; - case 73: + case 74: -/* Line 1464 of yacc.c */ -#line 583 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 597 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3312,10 +3327,10 @@ yyreduce: ;} break; - case 75: + case 76: -/* Line 1464 of yacc.c */ -#line 593 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 607 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3323,10 +3338,10 @@ yyreduce: ;} break; - case 77: + case 78: -/* Line 1464 of yacc.c */ -#line 603 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 617 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3334,10 +3349,10 @@ yyreduce: ;} break; - case 79: + case 80: -/* Line 1464 of yacc.c */ -#line 613 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 627 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); @@ -3345,10 +3360,10 @@ yyreduce: ;} break; - case 81: + case 82: -/* Line 1464 of yacc.c */ -#line 623 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 637 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression(ast_conditional, (yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression)); @@ -3356,10 +3371,10 @@ yyreduce: ;} break; - case 83: + case 84: -/* Line 1464 of yacc.c */ -#line 633 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 647 "glsl_parser.ypp" { void *ctx = state; (yyval.expression) = new(ctx) ast_expression((yyvsp[(2) - (3)].n), (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); @@ -3367,96 +3382,96 @@ yyreduce: ;} break; - case 84: + case 85: -/* Line 1464 of yacc.c */ -#line 641 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 655 "glsl_parser.ypp" { (yyval.n) = ast_assign; ;} break; - case 85: + case 86: -/* Line 1464 of yacc.c */ -#line 642 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 656 "glsl_parser.ypp" { (yyval.n) = ast_mul_assign; ;} break; - case 86: + case 87: -/* Line 1464 of yacc.c */ -#line 643 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 657 "glsl_parser.ypp" { (yyval.n) = ast_div_assign; ;} break; - case 87: + case 88: -/* Line 1464 of yacc.c */ -#line 644 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 658 "glsl_parser.ypp" { (yyval.n) = ast_mod_assign; ;} break; - case 88: + case 89: -/* Line 1464 of yacc.c */ -#line 645 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 659 "glsl_parser.ypp" { (yyval.n) = ast_add_assign; ;} break; - case 89: + case 90: -/* Line 1464 of yacc.c */ -#line 646 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 660 "glsl_parser.ypp" { (yyval.n) = ast_sub_assign; ;} break; - case 90: + case 91: -/* Line 1464 of yacc.c */ -#line 647 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 661 "glsl_parser.ypp" { (yyval.n) = ast_ls_assign; ;} break; - case 91: + case 92: -/* Line 1464 of yacc.c */ -#line 648 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 662 "glsl_parser.ypp" { (yyval.n) = ast_rs_assign; ;} break; - case 92: + case 93: -/* Line 1464 of yacc.c */ -#line 649 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 663 "glsl_parser.ypp" { (yyval.n) = ast_and_assign; ;} break; - case 93: + case 94: -/* Line 1464 of yacc.c */ -#line 650 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 664 "glsl_parser.ypp" { (yyval.n) = ast_xor_assign; ;} break; - case 94: + case 95: -/* Line 1464 of yacc.c */ -#line 651 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 665 "glsl_parser.ypp" { (yyval.n) = ast_or_assign; ;} break; - case 95: + case 96: -/* Line 1464 of yacc.c */ -#line 656 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 670 "glsl_parser.ypp" { (yyval.expression) = (yyvsp[(1) - (1)].expression); ;} break; - case 96: + case 97: -/* Line 1464 of yacc.c */ -#line 660 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 674 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (3)].expression)->oper != ast_sequence) { @@ -3471,28 +3486,28 @@ yyreduce: ;} break; - case 98: + case 99: -/* Line 1464 of yacc.c */ -#line 680 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 694 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].function); ;} break; - case 99: + case 100: -/* Line 1464 of yacc.c */ -#line 684 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 698 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (2)].declarator_list); ;} break; - case 100: + case 101: -/* Line 1464 of yacc.c */ -#line 688 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 702 "glsl_parser.ypp" { if (((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_float) && ((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_int)) { @@ -3505,30 +3520,30 @@ yyreduce: ;} break; - case 104: + case 105: -/* Line 1464 of yacc.c */ -#line 711 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 725 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (2)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(2) - (2)].parameter_declarator)->link); ;} break; - case 105: + case 106: -/* Line 1464 of yacc.c */ -#line 716 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 730 "glsl_parser.ypp" { (yyval.function) = (yyvsp[(1) - (3)].function); (yyval.function)->parameters.push_tail(& (yyvsp[(3) - (3)].parameter_declarator)->link); ;} break; - case 106: + case 107: -/* Line 1464 of yacc.c */ -#line 724 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 738 "glsl_parser.ypp" { void *ctx = state; (yyval.function) = new(ctx) ast_function(); @@ -3538,10 +3553,10 @@ yyreduce: ;} break; - case 107: + case 108: -/* Line 1464 of yacc.c */ -#line 735 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 749 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3553,10 +3568,10 @@ yyreduce: ;} break; - case 108: + case 109: -/* Line 1464 of yacc.c */ -#line 745 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 759 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3570,10 +3585,10 @@ yyreduce: ;} break; - case 109: + case 110: -/* Line 1464 of yacc.c */ -#line 760 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 774 "glsl_parser.ypp" { (yyvsp[(1) - (3)].type_qualifier).flags.i |= (yyvsp[(2) - (3)].type_qualifier).flags.i; @@ -3582,20 +3597,20 @@ yyreduce: ;} break; - case 110: + case 111: -/* Line 1464 of yacc.c */ -#line 767 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 781 "glsl_parser.ypp" { (yyval.parameter_declarator) = (yyvsp[(2) - (2)].parameter_declarator); (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier); ;} break; - case 111: + case 112: -/* Line 1464 of yacc.c */ -#line 772 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 786 "glsl_parser.ypp" { void *ctx = state; (yyvsp[(1) - (3)].type_qualifier).flags.i |= (yyvsp[(2) - (3)].type_qualifier).flags.i; @@ -3608,10 +3623,10 @@ yyreduce: ;} break; - case 112: + case 113: -/* Line 1464 of yacc.c */ -#line 783 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 797 "glsl_parser.ypp" { void *ctx = state; (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); @@ -3622,39 +3637,39 @@ yyreduce: ;} break; - case 113: + case 114: -/* Line 1464 of yacc.c */ -#line 795 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 809 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); ;} break; - case 114: + case 115: -/* Line 1464 of yacc.c */ -#line 799 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 813 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.in = 1; ;} break; - case 115: + case 116: -/* Line 1464 of yacc.c */ -#line 804 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 818 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.out = 1; ;} break; - case 116: + case 117: -/* Line 1464 of yacc.c */ -#line 809 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 823 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.in = 1; @@ -3662,10 +3677,10 @@ yyreduce: ;} break; - case 119: + case 120: -/* Line 1464 of yacc.c */ -#line 823 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 837 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (3)].identifier), false, NULL, NULL); @@ -3676,10 +3691,10 @@ yyreduce: ;} break; - case 120: + case 121: -/* Line 1464 of yacc.c */ -#line 832 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 846 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), true, NULL, NULL); @@ -3690,10 +3705,10 @@ yyreduce: ;} break; - case 121: + case 122: -/* Line 1464 of yacc.c */ -#line 841 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 855 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (6)].identifier), true, (yyvsp[(5) - (6)].expression), NULL); @@ -3704,10 +3719,10 @@ yyreduce: ;} break; - case 122: + case 123: -/* Line 1464 of yacc.c */ -#line 850 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 864 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (7)].identifier), true, NULL, (yyvsp[(7) - (7)].expression)); @@ -3718,10 +3733,10 @@ yyreduce: ;} break; - case 123: + case 124: -/* Line 1464 of yacc.c */ -#line 859 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 873 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (8)].identifier), true, (yyvsp[(5) - (8)].expression), (yyvsp[(8) - (8)].expression)); @@ -3732,10 +3747,10 @@ yyreduce: ;} break; - case 124: + case 125: -/* Line 1464 of yacc.c */ -#line 868 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 882 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), false, NULL, (yyvsp[(5) - (5)].expression)); @@ -3746,10 +3761,10 @@ yyreduce: ;} break; - case 125: + case 126: -/* Line 1464 of yacc.c */ -#line 881 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 895 "glsl_parser.ypp" { void *ctx = state; if ((yyvsp[(1) - (1)].fully_specified_type)->specifier->type_specifier != ast_struct) { @@ -3762,10 +3777,10 @@ yyreduce: ;} break; - case 126: + case 127: -/* Line 1464 of yacc.c */ -#line 892 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 906 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3776,10 +3791,10 @@ yyreduce: ;} break; - case 127: + case 128: -/* Line 1464 of yacc.c */ -#line 901 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 915 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), true, NULL, NULL); @@ -3790,10 +3805,10 @@ yyreduce: ;} break; - case 128: + case 129: -/* Line 1464 of yacc.c */ -#line 910 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 924 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (5)].identifier), true, (yyvsp[(4) - (5)].expression), NULL); @@ -3804,10 +3819,10 @@ yyreduce: ;} break; - case 129: + case 130: -/* Line 1464 of yacc.c */ -#line 919 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 933 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (6)].identifier), true, NULL, (yyvsp[(6) - (6)].expression)); @@ -3818,10 +3833,10 @@ yyreduce: ;} break; - case 130: + case 131: -/* Line 1464 of yacc.c */ -#line 928 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 942 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (7)].identifier), true, (yyvsp[(4) - (7)].expression), (yyvsp[(7) - (7)].expression)); @@ -3832,10 +3847,10 @@ yyreduce: ;} break; - case 131: + case 132: -/* Line 1464 of yacc.c */ -#line 937 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 951 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -3846,10 +3861,10 @@ yyreduce: ;} break; - case 132: + case 133: -/* Line 1464 of yacc.c */ -#line 946 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 960 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); @@ -3862,10 +3877,10 @@ yyreduce: ;} break; - case 133: + case 134: -/* Line 1464 of yacc.c */ -#line 960 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 974 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -3874,10 +3889,10 @@ yyreduce: ;} break; - case 134: + case 135: -/* Line 1464 of yacc.c */ -#line 967 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 981 "glsl_parser.ypp" { void *ctx = state; (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); @@ -3887,19 +3902,19 @@ yyreduce: ;} break; - case 135: + case 136: -/* Line 1464 of yacc.c */ -#line 978 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 992 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(3) - (4)].type_qualifier); ;} break; - case 137: + case 138: -/* Line 1464 of yacc.c */ -#line 986 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1000 "glsl_parser.ypp" { if (((yyvsp[(1) - (3)].type_qualifier).flags.i & (yyvsp[(3) - (3)].type_qualifier).flags.i) != 0) { _mesa_glsl_error(& (yylsp[(3) - (3)]), state, @@ -3917,10 +3932,10 @@ yyreduce: ;} break; - case 138: + case 139: -/* Line 1464 of yacc.c */ -#line 1005 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1019 "glsl_parser.ypp" { bool got_one = false; @@ -3951,10 +3966,10 @@ yyreduce: ;} break; - case 139: + case 140: -/* Line 1464 of yacc.c */ -#line 1034 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1048 "glsl_parser.ypp" { bool got_one = false; @@ -3994,80 +4009,80 @@ yyreduce: ;} break; - case 140: + case 141: -/* Line 1464 of yacc.c */ -#line 1075 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1089 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.smooth = 1; ;} break; - case 141: + case 142: -/* Line 1464 of yacc.c */ -#line 1080 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1094 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.flat = 1; ;} break; - case 142: + case 143: -/* Line 1464 of yacc.c */ -#line 1085 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1099 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.noperspective = 1; ;} break; - case 143: + case 144: -/* Line 1464 of yacc.c */ -#line 1093 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1107 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.constant = 1; ;} break; - case 146: + case 147: -/* Line 1464 of yacc.c */ -#line 1103 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1117 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(1) - (2)].type_qualifier); (yyval.type_qualifier).flags.i |= (yyvsp[(2) - (2)].type_qualifier).flags.i; ;} break; - case 148: + case 149: -/* Line 1464 of yacc.c */ -#line 1109 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1123 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(1) - (2)].type_qualifier); (yyval.type_qualifier).flags.i |= (yyvsp[(2) - (2)].type_qualifier).flags.i; ;} break; - case 149: + case 150: -/* Line 1464 of yacc.c */ -#line 1114 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1128 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(2) - (2)].type_qualifier); (yyval.type_qualifier).flags.q.invariant = 1; ;} break; - case 150: + case 151: -/* Line 1464 of yacc.c */ -#line 1119 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1133 "glsl_parser.ypp" { (yyval.type_qualifier) = (yyvsp[(2) - (3)].type_qualifier); (yyval.type_qualifier).flags.i |= (yyvsp[(3) - (3)].type_qualifier).flags.i; @@ -4075,50 +4090,50 @@ yyreduce: ;} break; - case 151: + case 152: -/* Line 1464 of yacc.c */ -#line 1125 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1139 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.invariant = 1; ;} break; - case 152: + case 153: -/* Line 1464 of yacc.c */ -#line 1133 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1147 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.constant = 1; ;} break; - case 153: + case 154: -/* Line 1464 of yacc.c */ -#line 1138 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1152 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.attribute = 1; ;} break; - case 154: + case 155: -/* Line 1464 of yacc.c */ -#line 1143 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1157 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.varying = 1; ;} break; - case 155: + case 156: -/* Line 1464 of yacc.c */ -#line 1148 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1162 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.centroid = 1; @@ -4126,70 +4141,70 @@ yyreduce: ;} break; - case 156: + case 157: -/* Line 1464 of yacc.c */ -#line 1154 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1168 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.in = 1; ;} break; - case 157: + case 158: -/* Line 1464 of yacc.c */ -#line 1159 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1173 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.out = 1; ;} break; - case 158: + case 159: -/* Line 1464 of yacc.c */ -#line 1164 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1178 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.centroid = 1; (yyval.type_qualifier).flags.q.in = 1; ;} break; - case 159: + case 160: -/* Line 1464 of yacc.c */ -#line 1169 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1183 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.centroid = 1; (yyval.type_qualifier).flags.q.out = 1; ;} break; - case 160: + case 161: -/* Line 1464 of yacc.c */ -#line 1174 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1188 "glsl_parser.ypp" { memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); (yyval.type_qualifier).flags.q.uniform = 1; ;} break; - case 162: + case 163: -/* Line 1464 of yacc.c */ -#line 1183 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1197 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(2) - (2)].type_specifier); (yyval.type_specifier)->precision = (yyvsp[(1) - (2)].n); ;} break; - case 164: + case 165: -/* Line 1464 of yacc.c */ -#line 1192 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1206 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (3)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -4197,10 +4212,10 @@ yyreduce: ;} break; - case 165: + case 166: -/* Line 1464 of yacc.c */ -#line 1198 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1212 "glsl_parser.ypp" { (yyval.type_specifier) = (yyvsp[(1) - (4)].type_specifier); (yyval.type_specifier)->is_array = true; @@ -4208,10 +4223,10 @@ yyreduce: ;} break; - case 166: + case 167: -/* Line 1464 of yacc.c */ -#line 1207 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1221 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].n)); @@ -4219,10 +4234,10 @@ yyreduce: ;} break; - case 167: + case 168: -/* Line 1464 of yacc.c */ -#line 1213 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1227 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].struct_specifier)); @@ -4230,10 +4245,10 @@ yyreduce: ;} break; - case 168: + case 169: -/* Line 1464 of yacc.c */ -#line 1219 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1233 "glsl_parser.ypp" { void *ctx = state; (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].identifier)); @@ -4241,367 +4256,367 @@ yyreduce: ;} break; - case 169: + case 170: -/* Line 1464 of yacc.c */ -#line 1227 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1241 "glsl_parser.ypp" { (yyval.n) = ast_void; ;} break; - case 170: + case 171: -/* Line 1464 of yacc.c */ -#line 1228 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1242 "glsl_parser.ypp" { (yyval.n) = ast_float; ;} break; - case 171: + case 172: -/* Line 1464 of yacc.c */ -#line 1229 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1243 "glsl_parser.ypp" { (yyval.n) = ast_int; ;} break; - case 172: + case 173: -/* Line 1464 of yacc.c */ -#line 1230 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1244 "glsl_parser.ypp" { (yyval.n) = ast_uint; ;} break; - case 173: + case 174: -/* Line 1464 of yacc.c */ -#line 1231 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1245 "glsl_parser.ypp" { (yyval.n) = ast_bool; ;} break; - case 174: + case 175: -/* Line 1464 of yacc.c */ -#line 1232 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1246 "glsl_parser.ypp" { (yyval.n) = ast_vec2; ;} break; - case 175: + case 176: -/* Line 1464 of yacc.c */ -#line 1233 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1247 "glsl_parser.ypp" { (yyval.n) = ast_vec3; ;} break; - case 176: + case 177: -/* Line 1464 of yacc.c */ -#line 1234 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1248 "glsl_parser.ypp" { (yyval.n) = ast_vec4; ;} break; - case 177: + case 178: -/* Line 1464 of yacc.c */ -#line 1235 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1249 "glsl_parser.ypp" { (yyval.n) = ast_bvec2; ;} break; - case 178: + case 179: -/* Line 1464 of yacc.c */ -#line 1236 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1250 "glsl_parser.ypp" { (yyval.n) = ast_bvec3; ;} break; - case 179: + case 180: -/* Line 1464 of yacc.c */ -#line 1237 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1251 "glsl_parser.ypp" { (yyval.n) = ast_bvec4; ;} break; - case 180: + case 181: -/* Line 1464 of yacc.c */ -#line 1238 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1252 "glsl_parser.ypp" { (yyval.n) = ast_ivec2; ;} break; - case 181: + case 182: -/* Line 1464 of yacc.c */ -#line 1239 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1253 "glsl_parser.ypp" { (yyval.n) = ast_ivec3; ;} break; - case 182: + case 183: -/* Line 1464 of yacc.c */ -#line 1240 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1254 "glsl_parser.ypp" { (yyval.n) = ast_ivec4; ;} break; - case 183: + case 184: -/* Line 1464 of yacc.c */ -#line 1241 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1255 "glsl_parser.ypp" { (yyval.n) = ast_uvec2; ;} break; - case 184: + case 185: -/* Line 1464 of yacc.c */ -#line 1242 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1256 "glsl_parser.ypp" { (yyval.n) = ast_uvec3; ;} break; - case 185: + case 186: -/* Line 1464 of yacc.c */ -#line 1243 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1257 "glsl_parser.ypp" { (yyval.n) = ast_uvec4; ;} break; - case 186: + case 187: -/* Line 1464 of yacc.c */ -#line 1244 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1258 "glsl_parser.ypp" { (yyval.n) = ast_mat2; ;} break; - case 187: + case 188: -/* Line 1464 of yacc.c */ -#line 1245 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1259 "glsl_parser.ypp" { (yyval.n) = ast_mat2x3; ;} break; - case 188: + case 189: -/* Line 1464 of yacc.c */ -#line 1246 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1260 "glsl_parser.ypp" { (yyval.n) = ast_mat2x4; ;} break; - case 189: + case 190: -/* Line 1464 of yacc.c */ -#line 1247 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1261 "glsl_parser.ypp" { (yyval.n) = ast_mat3x2; ;} break; - case 190: + case 191: -/* Line 1464 of yacc.c */ -#line 1248 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1262 "glsl_parser.ypp" { (yyval.n) = ast_mat3; ;} break; - case 191: + case 192: -/* Line 1464 of yacc.c */ -#line 1249 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1263 "glsl_parser.ypp" { (yyval.n) = ast_mat3x4; ;} break; - case 192: + case 193: -/* Line 1464 of yacc.c */ -#line 1250 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1264 "glsl_parser.ypp" { (yyval.n) = ast_mat4x2; ;} break; - case 193: + case 194: -/* Line 1464 of yacc.c */ -#line 1251 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1265 "glsl_parser.ypp" { (yyval.n) = ast_mat4x3; ;} break; - case 194: + case 195: -/* Line 1464 of yacc.c */ -#line 1252 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1266 "glsl_parser.ypp" { (yyval.n) = ast_mat4; ;} break; - case 195: + case 196: -/* Line 1464 of yacc.c */ -#line 1253 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1267 "glsl_parser.ypp" { (yyval.n) = ast_sampler1d; ;} break; - case 196: + case 197: -/* Line 1464 of yacc.c */ -#line 1254 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1268 "glsl_parser.ypp" { (yyval.n) = ast_sampler2d; ;} break; - case 197: + case 198: -/* Line 1464 of yacc.c */ -#line 1255 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1269 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drect; ;} break; - case 198: + case 199: -/* Line 1464 of yacc.c */ -#line 1256 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1270 "glsl_parser.ypp" { (yyval.n) = ast_sampler3d; ;} break; - case 199: + case 200: -/* Line 1464 of yacc.c */ -#line 1257 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1271 "glsl_parser.ypp" { (yyval.n) = ast_samplercube; ;} break; - case 200: + case 201: -/* Line 1464 of yacc.c */ -#line 1258 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1272 "glsl_parser.ypp" { (yyval.n) = ast_sampler1dshadow; ;} break; - case 201: + case 202: -/* Line 1464 of yacc.c */ -#line 1259 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1273 "glsl_parser.ypp" { (yyval.n) = ast_sampler2dshadow; ;} break; - case 202: + case 203: -/* Line 1464 of yacc.c */ -#line 1260 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1274 "glsl_parser.ypp" { (yyval.n) = ast_sampler2drectshadow; ;} break; - case 203: + case 204: -/* Line 1464 of yacc.c */ -#line 1261 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1275 "glsl_parser.ypp" { (yyval.n) = ast_samplercubeshadow; ;} break; - case 204: + case 205: -/* Line 1464 of yacc.c */ -#line 1262 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1276 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darray; ;} break; - case 205: + case 206: -/* Line 1464 of yacc.c */ -#line 1263 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1277 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darray; ;} break; - case 206: + case 207: -/* Line 1464 of yacc.c */ -#line 1264 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1278 "glsl_parser.ypp" { (yyval.n) = ast_sampler1darrayshadow; ;} break; - case 207: + case 208: -/* Line 1464 of yacc.c */ -#line 1265 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1279 "glsl_parser.ypp" { (yyval.n) = ast_sampler2darrayshadow; ;} break; - case 208: + case 209: -/* Line 1464 of yacc.c */ -#line 1266 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1280 "glsl_parser.ypp" { (yyval.n) = ast_isampler1d; ;} break; - case 209: + case 210: -/* Line 1464 of yacc.c */ -#line 1267 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1281 "glsl_parser.ypp" { (yyval.n) = ast_isampler2d; ;} break; - case 210: + case 211: -/* Line 1464 of yacc.c */ -#line 1268 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1282 "glsl_parser.ypp" { (yyval.n) = ast_isampler3d; ;} break; - case 211: + case 212: -/* Line 1464 of yacc.c */ -#line 1269 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1283 "glsl_parser.ypp" { (yyval.n) = ast_isamplercube; ;} break; - case 212: + case 213: -/* Line 1464 of yacc.c */ -#line 1270 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1284 "glsl_parser.ypp" { (yyval.n) = ast_isampler1darray; ;} break; - case 213: + case 214: -/* Line 1464 of yacc.c */ -#line 1271 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1285 "glsl_parser.ypp" { (yyval.n) = ast_isampler2darray; ;} break; - case 214: + case 215: -/* Line 1464 of yacc.c */ -#line 1272 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1286 "glsl_parser.ypp" { (yyval.n) = ast_usampler1d; ;} break; - case 215: + case 216: -/* Line 1464 of yacc.c */ -#line 1273 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1287 "glsl_parser.ypp" { (yyval.n) = ast_usampler2d; ;} break; - case 216: + case 217: -/* Line 1464 of yacc.c */ -#line 1274 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1288 "glsl_parser.ypp" { (yyval.n) = ast_usampler3d; ;} break; - case 217: + case 218: -/* Line 1464 of yacc.c */ -#line 1275 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1289 "glsl_parser.ypp" { (yyval.n) = ast_usamplercube; ;} break; - case 218: + case 219: -/* Line 1464 of yacc.c */ -#line 1276 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1290 "glsl_parser.ypp" { (yyval.n) = ast_usampler1darray; ;} break; - case 219: + case 220: -/* Line 1464 of yacc.c */ -#line 1277 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1291 "glsl_parser.ypp" { (yyval.n) = ast_usampler2darray; ;} break; - case 220: + case 221: -/* Line 1464 of yacc.c */ -#line 1281 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1295 "glsl_parser.ypp" { if (!state->es_shader && state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4615,10 +4630,10 @@ yyreduce: ;} break; - case 221: + case 222: -/* Line 1464 of yacc.c */ -#line 1292 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1306 "glsl_parser.ypp" { if (!state->es_shader && state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4632,10 +4647,10 @@ yyreduce: ;} break; - case 222: + case 223: -/* Line 1464 of yacc.c */ -#line 1303 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1317 "glsl_parser.ypp" { if (!state->es_shader && state->language_version < 130) _mesa_glsl_error(& (yylsp[(1) - (1)]), state, @@ -4649,10 +4664,10 @@ yyreduce: ;} break; - case 223: + case 224: -/* Line 1464 of yacc.c */ -#line 1318 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1332 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node)); @@ -4660,10 +4675,10 @@ yyreduce: ;} break; - case 224: + case 225: -/* Line 1464 of yacc.c */ -#line 1324 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1338 "glsl_parser.ypp" { void *ctx = state; (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node)); @@ -4671,30 +4686,30 @@ yyreduce: ;} break; - case 225: + case 226: -/* Line 1464 of yacc.c */ -#line 1333 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1347 "glsl_parser.ypp" { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].declarator_list); (yyvsp[(1) - (1)].declarator_list)->link.self_link(); ;} break; - case 226: + case 227: -/* Line 1464 of yacc.c */ -#line 1338 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1352 "glsl_parser.ypp" { (yyval.node) = (ast_node *) (yyvsp[(1) - (2)].node); (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); ;} break; - case 227: + case 228: -/* Line 1464 of yacc.c */ -#line 1346 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1360 "glsl_parser.ypp" { void *ctx = state; ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); @@ -4708,30 +4723,30 @@ yyreduce: ;} break; - case 228: + case 229: -/* Line 1464 of yacc.c */ -#line 1361 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1375 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (1)].declaration); (yyvsp[(1) - (1)].declaration)->link.self_link(); ;} break; - case 229: + case 230: -/* Line 1464 of yacc.c */ -#line 1366 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1380 "glsl_parser.ypp" { (yyval.declaration) = (yyvsp[(1) - (3)].declaration); (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link); ;} break; - case 230: + case 231: -/* Line 1464 of yacc.c */ -#line 1374 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1388 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL); @@ -4739,10 +4754,10 @@ yyreduce: ;} break; - case 231: + case 232: -/* Line 1464 of yacc.c */ -#line 1380 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1394 "glsl_parser.ypp" { void *ctx = state; (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL); @@ -4750,31 +4765,31 @@ yyreduce: ;} break; - case 234: + case 235: -/* Line 1464 of yacc.c */ -#line 1398 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1412 "glsl_parser.ypp" { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; - case 239: + case 240: -/* Line 1464 of yacc.c */ -#line 1406 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1420 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; - case 240: + case 241: -/* Line 1464 of yacc.c */ -#line 1407 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1421 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; - case 243: + case 244: -/* Line 1464 of yacc.c */ -#line 1414 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1428 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL); @@ -4782,10 +4797,10 @@ yyreduce: ;} break; - case 244: + case 245: -/* Line 1464 of yacc.c */ -#line 1420 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1434 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(2) - (3)].node)); @@ -4793,17 +4808,17 @@ yyreduce: ;} break; - case 245: + case 246: -/* Line 1464 of yacc.c */ -#line 1428 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1442 "glsl_parser.ypp" { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} break; - case 247: + case 248: -/* Line 1464 of yacc.c */ -#line 1434 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1448 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL); @@ -4811,10 +4826,10 @@ yyreduce: ;} break; - case 248: + case 249: -/* Line 1464 of yacc.c */ -#line 1440 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1454 "glsl_parser.ypp" { void *ctx = state; (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node)); @@ -4822,10 +4837,10 @@ yyreduce: ;} break; - case 249: + case 250: -/* Line 1464 of yacc.c */ -#line 1449 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1463 "glsl_parser.ypp" { if ((yyvsp[(1) - (1)].node) == NULL) { _mesa_glsl_error(& (yylsp[(1) - (1)]), state, " statement\n"); @@ -4837,10 +4852,10 @@ yyreduce: ;} break; - case 250: + case 251: -/* Line 1464 of yacc.c */ -#line 1459 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1473 "glsl_parser.ypp" { if ((yyvsp[(2) - (2)].node) == NULL) { _mesa_glsl_error(& (yylsp[(2) - (2)]), state, " statement\n"); @@ -4851,10 +4866,10 @@ yyreduce: ;} break; - case 251: + case 252: -/* Line 1464 of yacc.c */ -#line 1471 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1485 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement(NULL); @@ -4862,10 +4877,10 @@ yyreduce: ;} break; - case 252: + case 253: -/* Line 1464 of yacc.c */ -#line 1477 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1491 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression)); @@ -4873,10 +4888,10 @@ yyreduce: ;} break; - case 253: + case 254: -/* Line 1464 of yacc.c */ -#line 1486 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1500 "glsl_parser.ypp" { (yyval.node) = new(state) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].selection_rest_statement).then_statement, (yyvsp[(5) - (5)].selection_rest_statement).else_statement); @@ -4884,39 +4899,39 @@ yyreduce: ;} break; - case 254: + case 255: -/* Line 1464 of yacc.c */ -#line 1495 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1509 "glsl_parser.ypp" { (yyval.selection_rest_statement).then_statement = (yyvsp[(1) - (3)].node); (yyval.selection_rest_statement).else_statement = (yyvsp[(3) - (3)].node); ;} break; - case 255: + case 256: -/* Line 1464 of yacc.c */ -#line 1500 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1514 "glsl_parser.ypp" { (yyval.selection_rest_statement).then_statement = (yyvsp[(1) - (1)].node); (yyval.selection_rest_statement).else_statement = NULL; ;} break; - case 256: + case 257: -/* Line 1464 of yacc.c */ -#line 1508 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1522 "glsl_parser.ypp" { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].expression); ;} break; - case 257: + case 258: -/* Line 1464 of yacc.c */ -#line 1512 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1526 "glsl_parser.ypp" { void *ctx = state; ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); @@ -4929,10 +4944,10 @@ yyreduce: ;} break; - case 261: + case 262: -/* Line 1464 of yacc.c */ -#line 1535 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1549 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, @@ -4941,10 +4956,10 @@ yyreduce: ;} break; - case 262: + case 263: -/* Line 1464 of yacc.c */ -#line 1542 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1556 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, @@ -4953,10 +4968,10 @@ yyreduce: ;} break; - case 263: + case 264: -/* Line 1464 of yacc.c */ -#line 1549 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1563 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, @@ -4965,39 +4980,39 @@ yyreduce: ;} break; - case 267: + case 268: -/* Line 1464 of yacc.c */ -#line 1565 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1579 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; - case 268: + case 269: -/* Line 1464 of yacc.c */ -#line 1572 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1586 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node); (yyval.for_rest_statement).rest = NULL; ;} break; - case 269: + case 270: -/* Line 1464 of yacc.c */ -#line 1577 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1591 "glsl_parser.ypp" { (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node); (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression); ;} break; - case 270: + case 271: -/* Line 1464 of yacc.c */ -#line 1586 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1600 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); @@ -5005,10 +5020,10 @@ yyreduce: ;} break; - case 271: + case 272: -/* Line 1464 of yacc.c */ -#line 1592 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1606 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); @@ -5016,10 +5031,10 @@ yyreduce: ;} break; - case 272: + case 273: -/* Line 1464 of yacc.c */ -#line 1598 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1612 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); @@ -5027,10 +5042,10 @@ yyreduce: ;} break; - case 273: + case 274: -/* Line 1464 of yacc.c */ -#line 1604 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1618 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression)); @@ -5038,10 +5053,10 @@ yyreduce: ;} break; - case 274: + case 275: -/* Line 1464 of yacc.c */ -#line 1610 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1624 "glsl_parser.ypp" { void *ctx = state; (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); @@ -5049,31 +5064,31 @@ yyreduce: ;} break; - case 275: + case 276: -/* Line 1464 of yacc.c */ -#line 1618 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1632 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;} break; - case 276: + case 277: -/* Line 1464 of yacc.c */ -#line 1619 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1633 "glsl_parser.ypp" { (yyval.node) = (yyvsp[(1) - (1)].node); ;} break; - case 277: + case 278: -/* Line 1464 of yacc.c */ -#line 1620 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1634 "glsl_parser.ypp" { (yyval.node) = NULL; ;} break; - case 278: + case 279: -/* Line 1464 of yacc.c */ -#line 1625 "glsl_parser.ypp" +/* Line 1455 of yacc.c */ +#line 1639 "glsl_parser.ypp" { void *ctx = state; (yyval.function_definition) = new(ctx) ast_function_definition(); @@ -5085,8 +5100,8 @@ yyreduce: -/* Line 1464 of yacc.c */ -#line 5090 "glsl_parser.cpp" +/* Line 1455 of yacc.c */ +#line 5105 "glsl_parser.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -5158,7 +5173,7 @@ yyerrlab: #endif } - yyerror_range[1] = yylloc; + yyerror_range[0] = yylloc; if (yyerrstatus == 3) { @@ -5195,7 +5210,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[1] = yylsp[1-yylen]; + yyerror_range[0] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); @@ -5229,7 +5244,7 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - yyerror_range[1] = *yylsp; + yyerror_range[0] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp, state); YYPOPSTACK (1); @@ -5239,10 +5254,10 @@ yyerrlab1: *++yyvsp = yylval; - yyerror_range[2] = yylloc; + yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; /* Shift the error token. */ diff --git a/mesalib/src/glsl/glsl_parser.h b/mesalib/src/glsl/glsl_parser.h index 6fd70d4cb..d1f555d09 100644 --- a/mesalib/src/glsl/glsl_parser.h +++ b/mesalib/src/glsl/glsl_parser.h @@ -1,9 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -155,79 +156,80 @@ PRAGMA_DEBUG_OFF = 372, PRAGMA_OPTIMIZE_ON = 373, PRAGMA_OPTIMIZE_OFF = 374, - LAYOUT_TOK = 375, - ASM = 376, - CLASS = 377, - UNION = 378, - ENUM = 379, - TYPEDEF = 380, - TEMPLATE = 381, - THIS = 382, - PACKED_TOK = 383, - GOTO = 384, - INLINE_TOK = 385, - NOINLINE = 386, - VOLATILE = 387, - PUBLIC_TOK = 388, - STATIC = 389, - EXTERN = 390, - EXTERNAL = 391, - LONG_TOK = 392, - SHORT_TOK = 393, - DOUBLE_TOK = 394, - HALF = 395, - FIXED_TOK = 396, - UNSIGNED = 397, - INPUT_TOK = 398, - OUPTUT = 399, - HVEC2 = 400, - HVEC3 = 401, - HVEC4 = 402, - DVEC2 = 403, - DVEC3 = 404, - DVEC4 = 405, - FVEC2 = 406, - FVEC3 = 407, - FVEC4 = 408, - SAMPLER2DRECT = 409, - SAMPLER3DRECT = 410, - SAMPLER2DRECTSHADOW = 411, - SIZEOF = 412, - CAST = 413, - NAMESPACE = 414, - USING = 415, - ERROR_TOK = 416, - COMMON = 417, - PARTITION = 418, - ACTIVE = 419, - SAMPLERBUFFER = 420, - FILTER = 421, - IMAGE1D = 422, - IMAGE2D = 423, - IMAGE3D = 424, - IMAGECUBE = 425, - IMAGE1DARRAY = 426, - IMAGE2DARRAY = 427, - IIMAGE1D = 428, - IIMAGE2D = 429, - IIMAGE3D = 430, - IIMAGECUBE = 431, - IIMAGE1DARRAY = 432, - IIMAGE2DARRAY = 433, - UIMAGE1D = 434, - UIMAGE2D = 435, - UIMAGE3D = 436, - UIMAGECUBE = 437, - UIMAGE1DARRAY = 438, - UIMAGE2DARRAY = 439, - IMAGE1DSHADOW = 440, - IMAGE2DSHADOW = 441, - IMAGEBUFFER = 442, - IIMAGEBUFFER = 443, - UIMAGEBUFFER = 444, - IMAGE1DARRAYSHADOW = 445, - IMAGE2DARRAYSHADOW = 446, - ROW_MAJOR = 447 + PRAGMA_INVARIANT_ALL = 375, + LAYOUT_TOK = 376, + ASM = 377, + CLASS = 378, + UNION = 379, + ENUM = 380, + TYPEDEF = 381, + TEMPLATE = 382, + THIS = 383, + PACKED_TOK = 384, + GOTO = 385, + INLINE_TOK = 386, + NOINLINE = 387, + VOLATILE = 388, + PUBLIC_TOK = 389, + STATIC = 390, + EXTERN = 391, + EXTERNAL = 392, + LONG_TOK = 393, + SHORT_TOK = 394, + DOUBLE_TOK = 395, + HALF = 396, + FIXED_TOK = 397, + UNSIGNED = 398, + INPUT_TOK = 399, + OUPTUT = 400, + HVEC2 = 401, + HVEC3 = 402, + HVEC4 = 403, + DVEC2 = 404, + DVEC3 = 405, + DVEC4 = 406, + FVEC2 = 407, + FVEC3 = 408, + FVEC4 = 409, + SAMPLER2DRECT = 410, + SAMPLER3DRECT = 411, + SAMPLER2DRECTSHADOW = 412, + SIZEOF = 413, + CAST = 414, + NAMESPACE = 415, + USING = 416, + ERROR_TOK = 417, + COMMON = 418, + PARTITION = 419, + ACTIVE = 420, + SAMPLERBUFFER = 421, + FILTER = 422, + IMAGE1D = 423, + IMAGE2D = 424, + IMAGE3D = 425, + IMAGECUBE = 426, + IMAGE1DARRAY = 427, + IMAGE2DARRAY = 428, + IIMAGE1D = 429, + IIMAGE2D = 430, + IIMAGE3D = 431, + IIMAGECUBE = 432, + IIMAGE1DARRAY = 433, + IIMAGE2DARRAY = 434, + UIMAGE1D = 435, + UIMAGE2D = 436, + UIMAGE3D = 437, + UIMAGECUBE = 438, + UIMAGE1DARRAY = 439, + UIMAGE2DARRAY = 440, + IMAGE1DSHADOW = 441, + IMAGE2DSHADOW = 442, + IMAGEBUFFER = 443, + IIMAGEBUFFER = 444, + UIMAGEBUFFER = 445, + IMAGE1DARRAYSHADOW = 446, + IMAGE2DARRAYSHADOW = 447, + ROW_MAJOR = 448 }; #endif @@ -237,7 +239,7 @@ typedef union YYSTYPE { -/* Line 1685 of yacc.c */ +/* Line 1676 of yacc.c */ #line 52 "glsl_parser.ypp" int n; @@ -270,8 +272,8 @@ typedef union YYSTYPE -/* Line 1685 of yacc.c */ -#line 275 "glsl_parser.h" +/* Line 1676 of yacc.c */ +#line 277 "glsl_parser.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/mesalib/src/glsl/glsl_parser.ypp b/mesalib/src/glsl/glsl_parser.ypp index c72da6116..e0c5fc1c7 100644 --- a/mesalib/src/glsl/glsl_parser.ypp +++ b/mesalib/src/glsl/glsl_parser.ypp @@ -108,6 +108,7 @@ %token VERSION EXTENSION LINE COLON EOL INTERFACE OUTPUT %token PRAGMA_DEBUG_ON PRAGMA_DEBUG_OFF %token PRAGMA_OPTIMIZE_ON PRAGMA_OPTIMIZE_OFF +%token PRAGMA_INVARIANT_ALL %token LAYOUT_TOK /* Reserved words that are not actually used in the grammar. @@ -241,6 +242,19 @@ pragma_statement: | PRAGMA_DEBUG_OFF EOL | PRAGMA_OPTIMIZE_ON EOL | PRAGMA_OPTIMIZE_OFF EOL + | PRAGMA_INVARIANT_ALL EOL + { + if (state->language_version < 120) { + _mesa_glsl_warning(& @1, state, + "pragma `invariant(all)' not supported in " + "GLSL%s %d.%02d", + state->es_shader ? " ES" : "", + state->language_version / 100, + state->language_version % 100); + } else { + state->all_invariant = true; + } + } ; extension_statement_list: diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h index 50a09f16a..20637918f 100644 --- a/mesalib/src/glsl/glsl_parser_extras.h +++ b/mesalib/src/glsl/glsl_parser_extras.h @@ -108,6 +108,13 @@ struct _mesa_glsl_parse_state { /** Was there an error during compilation? */ bool error; + /** + * Are all shader inputs / outputs invariant? + * + * This is set when the 'STDGL invariant(all)' pragma is used. + */ + bool all_invariant; + /** Loop or switch statement containing the current instructions. */ class ir_instruction *loop_or_switch_nesting; class ast_iteration_statement *loop_or_switch_nesting_ast; diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h index b143827a7..d11047f1d 100644 --- a/mesalib/src/glsl/ir.h +++ b/mesalib/src/glsl/ir.h @@ -1582,8 +1582,7 @@ _mesa_glsl_initialize_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state); extern void -_mesa_glsl_initialize_functions(exec_list *instructions, - struct _mesa_glsl_parse_state *state); +_mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state); extern void _mesa_glsl_release_functions(void); diff --git a/mesalib/src/mapi/mapi/table.c b/mesalib/src/mapi/mapi/table.c index ca47d4e04..df2272c98 100644 --- a/mesalib/src/mapi/mapi/table.c +++ b/mesalib/src/mapi/mapi/table.c @@ -40,7 +40,7 @@ noop_warn(const char *name) debug = (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")); if (debug) - fprintf(stderr, "%s is no-op", name); + fprintf(stderr, "%s is no-op\n", name); } static int diff --git a/mesalib/src/mesa/main/accum.c b/mesalib/src/mesa/main/accum.c index 1e001ab42..752ef70b8 100644 --- a/mesalib/src/mesa/main/accum.c +++ b/mesalib/src/mesa/main/accum.c @@ -27,6 +27,7 @@ #include "context.h" #include "imports.h" #include "macros.h" +#include "mfeatures.h" #include "state.h" #include "mtypes.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/api_arrayelt.c b/mesalib/src/mesa/main/api_arrayelt.c index 98ae3cff7..080c20606 100644 --- a/mesalib/src/mesa/main/api_arrayelt.c +++ b/mesalib/src/mesa/main/api_arrayelt.c @@ -40,6 +40,8 @@ #include "context.h" #include "imports.h" #include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" #include "main/dispatch.h" typedef void (GLAPIENTRY *array_func)( const void * ); diff --git a/mesalib/src/mesa/main/api_arrayelt.h b/mesalib/src/mesa/main/api_arrayelt.h index 1e5c6dee0..16e938fd0 100644 --- a/mesalib/src/mesa/main/api_arrayelt.h +++ b/mesalib/src/mesa/main/api_arrayelt.h @@ -28,6 +28,7 @@ #define API_ARRAYELT_H +#include "main/mfeatures.h" #include "main/mtypes.h" #if FEATURE_arrayelt diff --git a/mesalib/src/mesa/main/api_noop.c b/mesalib/src/mesa/main/api_noop.c index f13d3641b..beffa88e4 100644 --- a/mesalib/src/mesa/main/api_noop.c +++ b/mesalib/src/mesa/main/api_noop.c @@ -30,6 +30,7 @@ #include "context.h" #include "light.h" #include "macros.h" +#include "mfeatures.h" #include "dlist.h" #include "eval.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/api_noop.h b/mesalib/src/mesa/main/api_noop.h index e7fd49baf..4af2cde6b 100644 --- a/mesalib/src/mesa/main/api_noop.h +++ b/mesalib/src/mesa/main/api_noop.h @@ -1,60 +1,61 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul 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 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 - * BRIAN PAUL 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. - */ - -#ifndef _API_NOOP_H -#define _API_NOOP_H - -#include "main/mtypes.h" - -#if FEATURE_beginend - -extern void GLAPIENTRY -_mesa_noop_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); - -extern void GLAPIENTRY -_mesa_noop_EvalMesh1(GLenum mode, GLint i1, GLint i2); - -extern void GLAPIENTRY -_mesa_noop_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); - -extern void GLAPIENTRY -_mesa_noop_Materialfv(GLenum face, GLenum pname, const GLfloat *param); - -extern void GLAPIENTRY -_mesa_noop_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount); - -extern void GLAPIENTRY -_mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, - GLenum type, - const GLvoid **indices, - GLsizei primcount, - const GLint *basevertex); - -extern void -_mesa_noop_vtxfmt_init(GLvertexformat *vfmt); - -#endif /* FEATURE_beginend */ - -#endif /* _API_NOOP_H */ +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul 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 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 + * BRIAN PAUL 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. + */ + +#ifndef _API_NOOP_H +#define _API_NOOP_H + +#include "main/mfeatures.h" +#include "main/mtypes.h" + +#if FEATURE_beginend + +extern void GLAPIENTRY +_mesa_noop_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); + +extern void GLAPIENTRY +_mesa_noop_EvalMesh1(GLenum mode, GLint i1, GLint i2); + +extern void GLAPIENTRY +_mesa_noop_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); + +extern void GLAPIENTRY +_mesa_noop_Materialfv(GLenum face, GLenum pname, const GLfloat *param); + +extern void GLAPIENTRY +_mesa_noop_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount); + +extern void GLAPIENTRY +_mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, + GLenum type, + const GLvoid **indices, + GLsizei primcount, + const GLint *basevertex); + +extern void +_mesa_noop_vtxfmt_init(GLvertexformat *vfmt); + +#endif /* FEATURE_beginend */ + +#endif /* _API_NOOP_H */ diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c index 37ecb6b97..2d85b88ae 100644 --- a/mesalib/src/mesa/main/arrayobj.c +++ b/mesalib/src/mesa/main/arrayobj.c @@ -43,11 +43,13 @@ #include "hash.h" #include "imports.h" #include "context.h" +#include "mfeatures.h" #if FEATURE_ARB_vertex_buffer_object #include "bufferobj.h" #endif #include "arrayobj.h" #include "macros.h" +#include "mtypes.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/atifragshader.c b/mesalib/src/mesa/main/atifragshader.c index f2a41e30b..1707f0b95 100644 --- a/mesalib/src/mesa/main/atifragshader.c +++ b/mesalib/src/mesa/main/atifragshader.c @@ -26,6 +26,7 @@ #include "main/hash.h" #include "main/imports.h" #include "main/macros.h" +#include "main/mfeatures.h" #include "main/enums.h" #include "main/mtypes.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index 23ba36fba..4404c9b30 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -43,6 +43,7 @@ #include "lines.h" #include "macros.h" #include "matrix.h" +#include "mfeatures.h" #include "multisample.h" #include "points.h" #include "polygon.h" diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index a70c75750..31475529e 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -39,6 +39,8 @@ #include "context.h" #include "bufferobj.h" #include "fbobject.h" +#include "mfeatures.h" +#include "mtypes.h" #include "texobj.h" diff --git a/mesalib/src/mesa/main/bufferobj.h b/mesalib/src/mesa/main/bufferobj.h index 57aa82eda..cf43ad9a2 100644 --- a/mesalib/src/mesa/main/bufferobj.h +++ b/mesalib/src/mesa/main/bufferobj.h @@ -29,6 +29,7 @@ #define BUFFEROBJ_H +#include "mfeatures.h" #include "mtypes.h" diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c index cdc174454..1ddf5b2c8 100644 --- a/mesalib/src/mesa/main/buffers.c +++ b/mesalib/src/mesa/main/buffers.c @@ -35,6 +35,7 @@ #include "colormac.h" #include "context.h" #include "enums.h" +#include "mtypes.h" #define BAD_MASK ~0u diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c index 3edcbe884..ca831476b 100644 --- a/mesalib/src/mesa/main/clear.c +++ b/mesalib/src/mesa/main/clear.c @@ -36,6 +36,7 @@ #include "colormac.h" #include "enums.h" #include "macros.h" +#include "mtypes.h" #include "state.h" diff --git a/mesalib/src/mesa/main/colormac.h b/mesalib/src/mesa/main/colormac.h index 995183aeb..ebad20fc4 100644 --- a/mesalib/src/mesa/main/colormac.h +++ b/mesalib/src/mesa/main/colormac.h @@ -198,10 +198,14 @@ do { \ ((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) | \ ((A) ? 0x80 : 0)) -#define PACK_COLOR_2101010( A, B, G, R ) \ +#define PACK_COLOR_2101010_UB( A, B, G, R ) \ (((B) << 22) | ((G) << 12) | ((R) << 2) | \ (((A) & 0xc0) << 24)) +#define PACK_COLOR_2101010_US( A, B, G, R ) \ + ((((B) >> 6) << 20) | (((G) >> 6) << 10) | ((R) >> 6) | \ + (((A) >> 14) << 30)) + #define PACK_COLOR_4444( R, G, B, A ) \ ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4)) diff --git a/mesalib/src/mesa/main/colortab.c b/mesalib/src/mesa/main/colortab.c index a18a67ce2..9c23e253b 100644 --- a/mesalib/src/mesa/main/colortab.c +++ b/mesalib/src/mesa/main/colortab.c @@ -29,6 +29,8 @@ #include "context.h" #include "image.h" #include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" #include "pack.h" #include "state.h" #include "teximage.h" diff --git a/mesalib/src/mesa/main/condrender.c b/mesalib/src/mesa/main/condrender.c index 250397854..2c5ed0269 100644 --- a/mesalib/src/mesa/main/condrender.c +++ b/mesalib/src/mesa/main/condrender.c @@ -34,6 +34,7 @@ #include "glheader.h" #include "condrender.h" #include "enums.h" +#include "mtypes.h" #include "queryobj.h" diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index a18af86a3..8a4041f68 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -955,6 +955,14 @@ _mesa_initialize_context_for_api(struct gl_context *ctx, ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; } + /* Mesa core handles all the formats that mesa core knows about. + * Drivers will want to override this list with just the formats + * they can handle, and confirm that appropriate fallbacks exist in + * _mesa_choose_tex_format(). + */ + memset(&ctx->TextureFormatSupported, GL_TRUE, + sizeof(ctx->TextureFormatSupported)); + switch (ctx->API) { case API_OPENGL: #if FEATURE_dlist diff --git a/mesalib/src/mesa/main/convolve.c b/mesalib/src/mesa/main/convolve.c index cd725bb01..1e789dd8c 100644 --- a/mesalib/src/mesa/main/convolve.c +++ b/mesalib/src/mesa/main/convolve.c @@ -36,6 +36,7 @@ #include "colormac.h" #include "convolve.h" #include "macros.h" +#include "mfeatures.h" #include "mtypes.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/cpuinfo.c b/mesalib/src/mesa/main/cpuinfo.c index 35de69b18..d19aef91b 100644 --- a/mesalib/src/mesa/main/cpuinfo.c +++ b/mesalib/src/mesa/main/cpuinfo.c @@ -1,109 +1,109 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, 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 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 - * BRIAN PAUL 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. - */ - - -#include "main/imports.h" -#include "main/cpuinfo.h" - - -/** - * This function should be called before the various "cpu_has_foo" macros - * are used. - */ -void -_mesa_get_cpu_features(void) -{ -#ifdef USE_X86_ASM - _mesa_get_x86_features(); -#endif -} - - -/** - * Return a string describing the CPU architexture and extensions that - * Mesa is using (such as SSE or Altivec). - * \return information string, free it with free() - */ -char * -_mesa_get_cpu_string(void) -{ -#define MAX_STRING 50 - char *buffer; - - buffer = (char *) malloc(MAX_STRING); - if (!buffer) - return NULL; - - buffer[0] = 0; - -#ifdef USE_X86_ASM - - if (_mesa_x86_cpu_features) { - strcat(buffer, "x86"); - } - -# ifdef USE_MMX_ASM - if (cpu_has_mmx) { - strcat(buffer, (cpu_has_mmxext) ? "/MMX+" : "/MMX"); - } -# endif -# ifdef USE_3DNOW_ASM - if (cpu_has_3dnow) { - strcat(buffer, (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!"); - } -# endif -# ifdef USE_SSE_ASM - if (cpu_has_xmm) { - strcat(buffer, (cpu_has_xmm2) ? "/SSE2" : "/SSE"); - } -# endif - -#elif defined(USE_SPARC_ASM) - - strcat(buffer, "SPARC"); - -#elif defined(USE_PPC_ASM) - - if (_mesa_ppc_cpu_features) { - strcat(buffer, (cpu_has_64) ? "PowerPC 64" : "PowerPC"); - } - -# ifdef USE_VMX_ASM - - if (cpu_has_vmx) { - strcat(buffer, "/Altivec"); - } - -# endif - - if (! cpu_has_fpu) { - strcat(buffer, "/No FPU"); - } - -#endif - - assert(strlen(buffer) < MAX_STRING); - - return buffer; -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 2009 VMware, 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 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 + * BRIAN PAUL 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. + */ + + +#include "main/compiler.h" +#include "main/cpuinfo.h" + + +/** + * This function should be called before the various "cpu_has_foo" macros + * are used. + */ +void +_mesa_get_cpu_features(void) +{ +#ifdef USE_X86_ASM + _mesa_get_x86_features(); +#endif +} + + +/** + * Return a string describing the CPU architexture and extensions that + * Mesa is using (such as SSE or Altivec). + * \return information string, free it with free() + */ +char * +_mesa_get_cpu_string(void) +{ +#define MAX_STRING 50 + char *buffer; + + buffer = (char *) malloc(MAX_STRING); + if (!buffer) + return NULL; + + buffer[0] = 0; + +#ifdef USE_X86_ASM + + if (_mesa_x86_cpu_features) { + strcat(buffer, "x86"); + } + +# ifdef USE_MMX_ASM + if (cpu_has_mmx) { + strcat(buffer, (cpu_has_mmxext) ? "/MMX+" : "/MMX"); + } +# endif +# ifdef USE_3DNOW_ASM + if (cpu_has_3dnow) { + strcat(buffer, (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!"); + } +# endif +# ifdef USE_SSE_ASM + if (cpu_has_xmm) { + strcat(buffer, (cpu_has_xmm2) ? "/SSE2" : "/SSE"); + } +# endif + +#elif defined(USE_SPARC_ASM) + + strcat(buffer, "SPARC"); + +#elif defined(USE_PPC_ASM) + + if (_mesa_ppc_cpu_features) { + strcat(buffer, (cpu_has_64) ? "PowerPC 64" : "PowerPC"); + } + +# ifdef USE_VMX_ASM + + if (cpu_has_vmx) { + strcat(buffer, "/Altivec"); + } + +# endif + + if (! cpu_has_fpu) { + strcat(buffer, "/No FPU"); + } + +#endif + + assert(strlen(buffer) < MAX_STRING); + + return buffer; +} diff --git a/mesalib/src/mesa/main/dlist.h b/mesalib/src/mesa/main/dlist.h index 784368d1a..b954e06df 100644 --- a/mesalib/src/mesa/main/dlist.h +++ b/mesalib/src/mesa/main/dlist.h @@ -33,6 +33,7 @@ #define DLIST_H +#include "main/mfeatures.h" #include "main/mtypes.h" diff --git a/mesalib/src/mesa/main/drawpix.c b/mesalib/src/mesa/main/drawpix.c index 40a1cb5df..d7628c8f7 100644 --- a/mesalib/src/mesa/main/drawpix.c +++ b/mesalib/src/mesa/main/drawpix.c @@ -30,6 +30,7 @@ #include "enums.h" #include "feedback.h" #include "framebuffer.h" +#include "mfeatures.h" #include "readpix.h" #include "state.h" #include "dispatch.h" diff --git a/mesalib/src/mesa/main/drawtex.c b/mesalib/src/mesa/main/drawtex.c index 3e91f15bc..e386e90f6 100644 --- a/mesalib/src/mesa/main/drawtex.c +++ b/mesalib/src/mesa/main/drawtex.c @@ -24,6 +24,8 @@ #include "main/drawtex.h" #include "main/state.h" #include "main/imports.h" +#include "main/mfeatures.h" +#include "main/mtypes.h" #if FEATURE_OES_draw_texture diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c index c3dbd4a29..c91337355 100644 --- a/mesalib/src/mesa/main/enable.c +++ b/mesalib/src/mesa/main/enable.c @@ -33,6 +33,7 @@ #include "enable.h" #include "light.h" #include "simple_list.h" +#include "mfeatures.h" #include "mtypes.h" #include "enums.h" #include "api_arrayelt.h" diff --git a/mesalib/src/mesa/main/eval.c b/mesalib/src/mesa/main/eval.c index d7666a630..8eeeb2aea 100644 --- a/mesalib/src/mesa/main/eval.c +++ b/mesalib/src/mesa/main/eval.c @@ -43,6 +43,7 @@ #include "context.h" #include "eval.h" #include "macros.h" +#include "mfeatures.h" #include "mtypes.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/eval.h b/mesalib/src/mesa/main/eval.h index b92e41e9f..c6a37c135 100644 --- a/mesalib/src/mesa/main/eval.h +++ b/mesalib/src/mesa/main/eval.h @@ -37,6 +37,7 @@ #define EVAL_H +#include "main/mfeatures.h" #include "main/mtypes.h" diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index 81978b3c1..4b656a70f 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -28,6 +28,7 @@ #include "imports.h" #include "context.h" #include "extensions.h" +#include "mfeatures.h" #include "mtypes.h" diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index fce9e5bba..4f7a527c3 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -40,6 +40,8 @@ #include "framebuffer.h" #include "hash.h" #include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" #include "renderbuffer.h" #include "state.h" #include "teximage.h" @@ -402,8 +404,8 @@ fbo_incomplete(const char *msg, int index) /** * Is the given base format a legal format for a color renderbuffer? */ -static GLboolean -is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat) +GLboolean +_mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat) { switch (baseFormat) { case GL_RGB: @@ -488,7 +490,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format, baseFormat = _mesa_get_format_base_format(texImage->TexFormat); if (format == GL_COLOR) { - if (!is_legal_color_format(ctx, baseFormat)) { + if (!_mesa_is_legal_color_format(ctx, baseFormat)) { att_incomplete("bad format"); att->Complete = GL_FALSE; return; @@ -542,8 +544,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format, return; } if (format == GL_COLOR) { - if (baseFormat != GL_RGB && - baseFormat != GL_RGBA) { + if (!_mesa_is_legal_color_format(ctx, baseFormat)) { att_incomplete("bad renderbuffer color format"); att->Complete = GL_FALSE; return; @@ -669,7 +670,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, f = texImg->_BaseFormat; mesaFormat = texImg->TexFormat; numImages++; - if (!is_legal_color_format(ctx, f) && + if (!_mesa_is_legal_color_format(ctx, f) && !is_legal_depth_format(ctx, f)) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; fbo_incomplete("texture attachment incomplete", -1); @@ -793,7 +794,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, fb->Height = minHeight; /* finally, update the visual info for the framebuffer */ - _mesa_update_framebuffer_visual(fb); + _mesa_update_framebuffer_visual(ctx, fb); } } @@ -1172,8 +1173,17 @@ get_component_bits(GLenum pname, GLenum baseFormat, gl_format format) switch (pname) { case GL_RENDERBUFFER_RED_SIZE_EXT: case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + if (baseFormat == GL_RGB || baseFormat == GL_RGBA || + baseFormat == GL_RG || baseFormat == GL_RED) + return _mesa_get_format_bits(format, pname); + else + return 0; case GL_RENDERBUFFER_GREEN_SIZE_EXT: case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + if (baseFormat == GL_RGB || baseFormat == GL_RGBA || baseFormat == GL_RG) + return _mesa_get_format_bits(format, pname); + else + return 0; case GL_RENDERBUFFER_BLUE_SIZE_EXT: case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: if (baseFormat == GL_RGB || baseFormat == GL_RGBA) @@ -1182,7 +1192,8 @@ get_component_bits(GLenum pname, GLenum baseFormat, gl_format format) return 0; case GL_RENDERBUFFER_ALPHA_SIZE_EXT: case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - if (baseFormat == GL_RGBA || baseFormat == GL_ALPHA) + if (baseFormat == GL_RGBA || baseFormat == GL_ALPHA || + baseFormat == GL_LUMINANCE_ALPHA) return _mesa_get_format_bits(format, pname); else return 0; @@ -1940,7 +1951,7 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, /* Some subsequent GL commands may depend on the framebuffer's visual * after the binding is updated. Update visual info now. */ - _mesa_update_framebuffer_visual(fb); + _mesa_update_framebuffer_visual(ctx, fb); } diff --git a/mesalib/src/mesa/main/fbobject.h b/mesalib/src/mesa/main/fbobject.h index 5d250fba1..0e0e348a6 100644 --- a/mesalib/src/mesa/main/fbobject.h +++ b/mesalib/src/mesa/main/fbobject.h @@ -71,6 +71,9 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb extern void _mesa_test_framebuffer_completeness(struct gl_context *ctx, struct gl_framebuffer *fb); +extern GLboolean +_mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat); + extern GLenum _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat); diff --git a/mesalib/src/mesa/main/feedback.c b/mesalib/src/mesa/main/feedback.c index 5ce0880c2..80565c62c 100644 --- a/mesalib/src/mesa/main/feedback.c +++ b/mesalib/src/mesa/main/feedback.c @@ -35,6 +35,7 @@ #include "enums.h" #include "feedback.h" #include "macros.h" +#include "mfeatures.h" #include "mtypes.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/feedback.h b/mesalib/src/mesa/main/feedback.h index 06a07725d..24ce53af4 100644 --- a/mesalib/src/mesa/main/feedback.h +++ b/mesalib/src/mesa/main/feedback.h @@ -27,6 +27,7 @@ #define FEEDBACK_H +#include "main/mfeatures.h" #include "main/mtypes.h" diff --git a/mesalib/src/mesa/main/ffvertex_prog.c b/mesalib/src/mesa/main/ffvertex_prog.c index 60b200419..281229e34 100644 --- a/mesalib/src/mesa/main/ffvertex_prog.c +++ b/mesalib/src/mesa/main/ffvertex_prog.c @@ -36,6 +36,7 @@ #include "main/glheader.h" #include "main/mtypes.h" #include "main/macros.h" +#include "main/mfeatures.h" #include "main/enums.h" #include "main/ffvertex_prog.h" #include "program/program.h" diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index b7aecb396..d17619ef1 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -40,9 +40,10 @@ struct gl_format_info const char *StrName; /** - * Base format is one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, - * GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, - * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL. + * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA, + * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, + * GL_COLOR_INDEX, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, + * GL_DEPTH_STENCIL, GL_DUDV_ATI. */ GLenum BaseFormat; diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c index f8c0c6379..5833e5d58 100644 --- a/mesalib/src/mesa/main/framebuffer.c +++ b/mesalib/src/mesa/main/framebuffer.c @@ -522,7 +522,8 @@ _mesa_update_draw_buffer_bounds(struct gl_context *ctx) * integer Z values. */ void -_mesa_update_framebuffer_visual(struct gl_framebuffer *fb) +_mesa_update_framebuffer_visual(struct gl_context *ctx, + struct gl_framebuffer *fb) { GLuint i; @@ -542,9 +543,8 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb) const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; const GLenum baseFormat = _mesa_get_format_base_format(rb->Format); const gl_format fmt = rb->Format; - - if (baseFormat == GL_RGBA || baseFormat == GL_RGB || - baseFormat == GL_ALPHA) { + + if (_mesa_is_legal_color_format(ctx, baseFormat)) { fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS); fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); diff --git a/mesalib/src/mesa/main/framebuffer.h b/mesalib/src/mesa/main/framebuffer.h index 6b705146a..261f84515 100644 --- a/mesalib/src/mesa/main/framebuffer.h +++ b/mesalib/src/mesa/main/framebuffer.h @@ -70,7 +70,8 @@ extern void _mesa_update_draw_buffer_bounds(struct gl_context *ctx); extern void -_mesa_update_framebuffer_visual(struct gl_framebuffer *fb); +_mesa_update_framebuffer_visual(struct gl_context *ctx, + struct gl_framebuffer *fb); extern void _mesa_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb, diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index cb6880a6f..f13f6572a 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -29,6 +29,7 @@ #include "extensions.h" #include "get.h" #include "macros.h" +#include "mfeatures.h" #include "mtypes.h" #include "state.h" #include "texcompress.h" diff --git a/mesalib/src/mesa/main/getstring.c b/mesalib/src/mesa/main/getstring.c index 103a4942a..e55584afc 100644 --- a/mesalib/src/mesa/main/getstring.c +++ b/mesalib/src/mesa/main/getstring.c @@ -29,6 +29,8 @@ #include "get.h" #include "enums.h" #include "extensions.h" +#include "mfeatures.h" +#include "mtypes.h" /** diff --git a/mesalib/src/mesa/main/hint.c b/mesalib/src/mesa/main/hint.c index ccec1d285..96f5f4d6b 100644 --- a/mesalib/src/mesa/main/hint.c +++ b/mesalib/src/mesa/main/hint.c @@ -29,6 +29,7 @@ #include "context.h" #include "hint.h" #include "imports.h" +#include "mtypes.h" diff --git a/mesalib/src/mesa/main/histogram.c b/mesalib/src/mesa/main/histogram.c index f12428121..fc79feb68 100644 --- a/mesalib/src/mesa/main/histogram.c +++ b/mesalib/src/mesa/main/histogram.c @@ -28,6 +28,7 @@ #include "colormac.h" #include "histogram.h" #include "macros.h" +#include "mfeatures.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c index 08d25c8d1..fa9e8b9bb 100644 --- a/mesalib/src/mesa/main/image.c +++ b/mesalib/src/mesa/main/image.c @@ -35,6 +35,8 @@ #include "image.h" #include "imports.h" #include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" /** diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c index 6bfa734b8..dcd8cf537 100644 --- a/mesalib/src/mesa/main/imports.c +++ b/mesalib/src/mesa/main/imports.c @@ -46,6 +46,7 @@ #include "imports.h" #include "context.h" +#include "mtypes.h" #include "version.h" #ifdef _GNU_SOURCE diff --git a/mesalib/src/mesa/main/matrix.c b/mesalib/src/mesa/main/matrix.c index 3fae85cad..5ac6f8108 100644 --- a/mesalib/src/mesa/main/matrix.c +++ b/mesalib/src/mesa/main/matrix.c @@ -40,6 +40,7 @@ #include "context.h" #include "enums.h" #include "macros.h" +#include "mfeatures.h" #include "matrix.h" #include "mtypes.h" #include "math/m_matrix.h" diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c index cf85782bc..d27179e86 100644 --- a/mesalib/src/mesa/main/mipmap.c +++ b/mesalib/src/mesa/main/mipmap.c @@ -30,6 +30,7 @@ #include "imports.h" #include "formats.h" #include "mipmap.h" +#include "mtypes.h" #include "teximage.h" #include "texstore.h" #include "image.h" diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 7cac96c1d..df84db93f 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -40,6 +40,7 @@ #include "glapi/glapi.h" #include "math/m_matrix.h" /* GLmatrix */ #include "main/simple_list.h" /* struct simple_node */ +#include "main/formats.h" /* MESA_FORMAT_COUNT */ /** @@ -3240,6 +3241,8 @@ struct gl_context /** software compression/decompression supported or not */ GLboolean Mesa_DXTn; + GLboolean TextureFormatSupported[MESA_FORMAT_COUNT]; + /** * Use dp4 (rather than mul/mad) instructions for position * transformation? diff --git a/mesalib/src/mesa/main/multisample.c b/mesalib/src/mesa/main/multisample.c index 824778195..4eb1ab3a3 100644 --- a/mesalib/src/mesa/main/multisample.c +++ b/mesalib/src/mesa/main/multisample.c @@ -27,6 +27,7 @@ #include "main/context.h" #include "main/macros.h" #include "main/multisample.h" +#include "main/mtypes.h" /** diff --git a/mesalib/src/mesa/main/nvprogram.c b/mesalib/src/mesa/main/nvprogram.c index 89b9bc426..6b20fdae6 100644 --- a/mesalib/src/mesa/main/nvprogram.c +++ b/mesalib/src/mesa/main/nvprogram.c @@ -42,6 +42,7 @@ #include "main/hash.h" #include "main/imports.h" #include "main/macros.h" +#include "main/mtypes.h" #include "main/nvprogram.h" #include "program/arbprogparse.h" #include "program/nvfragparse.h" diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c index f323c51f1..6463ddfbd 100644 --- a/mesalib/src/mesa/main/pack.c +++ b/mesalib/src/mesa/main/pack.c @@ -34,6 +34,7 @@ #include "enums.h" #include "image.h" #include "imports.h" +#include "mtypes.h" #include "pack.h" #include "pixeltransfer.h" #include "imports.h" diff --git a/mesalib/src/mesa/main/pixel.c b/mesalib/src/mesa/main/pixel.c index db1f05a58..2b4934fd3 100644 --- a/mesalib/src/mesa/main/pixel.c +++ b/mesalib/src/mesa/main/pixel.c @@ -33,6 +33,7 @@ #include "colormac.h" #include "context.h" #include "macros.h" +#include "mfeatures.h" #include "pixel.h" #include "mtypes.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/pixelstore.c b/mesalib/src/mesa/main/pixelstore.c index 5d90391ca..f07115e6d 100644 --- a/mesalib/src/mesa/main/pixelstore.c +++ b/mesalib/src/mesa/main/pixelstore.c @@ -32,6 +32,7 @@ #include "bufferobj.h" #include "context.h" #include "pixelstore.h" +#include "mfeatures.h" #include "mtypes.h" diff --git a/mesalib/src/mesa/main/pixeltransfer.c b/mesalib/src/mesa/main/pixeltransfer.c index 67173ce3e..092ee3a14 100644 --- a/mesalib/src/mesa/main/pixeltransfer.c +++ b/mesalib/src/mesa/main/pixeltransfer.c @@ -33,6 +33,7 @@ #include "colormac.h" #include "pixeltransfer.h" #include "imports.h" +#include "mtypes.h" /* diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c index a8e1e8101..1c45c38b9 100644 --- a/mesalib/src/mesa/main/queryobj.c +++ b/mesalib/src/mesa/main/queryobj.c @@ -28,6 +28,7 @@ #include "hash.h" #include "imports.h" #include "queryobj.h" +#include "mfeatures.h" #include "mtypes.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/queryobj.h b/mesalib/src/mesa/main/queryobj.h index 71a93de85..4e8a1455b 100644 --- a/mesalib/src/mesa/main/queryobj.h +++ b/mesalib/src/mesa/main/queryobj.h @@ -27,6 +27,7 @@ #define QUERYOBJ_H +#include "main/mfeatures.h" #include "main/mtypes.h" #include "main/hash.h" diff --git a/mesalib/src/mesa/main/rastpos.c b/mesalib/src/mesa/main/rastpos.c index 372b177c4..70f67d398 100644 --- a/mesalib/src/mesa/main/rastpos.c +++ b/mesalib/src/mesa/main/rastpos.c @@ -32,6 +32,8 @@ #include "context.h" #include "feedback.h" #include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" #include "rastpos.h" #include "state.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c index 986dbb60a..9887fd816 100644 --- a/mesalib/src/mesa/main/readpix.c +++ b/mesalib/src/mesa/main/readpix.c @@ -30,6 +30,7 @@ #include "framebuffer.h" #include "formats.h" #include "image.h" +#include "mtypes.h" #include "state.h" diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c index ddc2fe30d..0b51ac123 100644 --- a/mesalib/src/mesa/main/renderbuffer.c +++ b/mesalib/src/mesa/main/renderbuffer.c @@ -1481,7 +1481,7 @@ _mesa_add_color_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, GLboolean frontLeft, GLboolean backLeft, GLboolean frontRight, GLboolean backRight) { - GLuint b; + gl_buffer_index b; if (rgbBits > 16 || alphaBits > 16) { _mesa_problem(ctx, @@ -1545,7 +1545,7 @@ _mesa_add_alpha_renderbuffers(struct gl_context *ctx, struct gl_framebuffer *fb, GLboolean frontLeft, GLboolean backLeft, GLboolean frontRight, GLboolean backRight) { - GLuint b; + gl_buffer_index b; /* for window system framebuffers only! */ assert(fb->Name == 0); @@ -1883,10 +1883,11 @@ _mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, /** * Attach a renderbuffer to a framebuffer. + * \param bufferName one of the BUFFER_x tokens */ void _mesa_add_renderbuffer(struct gl_framebuffer *fb, - GLuint bufferName, struct gl_renderbuffer *rb) + gl_buffer_index bufferName, struct gl_renderbuffer *rb) { assert(fb); assert(rb); @@ -1916,9 +1917,11 @@ _mesa_add_renderbuffer(struct gl_framebuffer *fb, /** * Remove the named renderbuffer from the given framebuffer. + * \param bufferName one of the BUFFER_x tokens */ void -_mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName) +_mesa_remove_renderbuffer(struct gl_framebuffer *fb, + gl_buffer_index bufferName) { struct gl_renderbuffer *rb; diff --git a/mesalib/src/mesa/main/renderbuffer.h b/mesalib/src/mesa/main/renderbuffer.h index c93eef4b8..12a06a58a 100644 --- a/mesalib/src/mesa/main/renderbuffer.h +++ b/mesalib/src/mesa/main/renderbuffer.h @@ -27,6 +27,7 @@ #define RENDERBUFFER_H #include "glheader.h" +#include "mtypes.h" struct gl_context; struct gl_framebuffer; @@ -95,10 +96,11 @@ _mesa_add_soft_renderbuffers(struct gl_framebuffer *fb, extern void _mesa_add_renderbuffer(struct gl_framebuffer *fb, - GLuint bufferName, struct gl_renderbuffer *rb); + gl_buffer_index bufferName, struct gl_renderbuffer *rb); extern void -_mesa_remove_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName); +_mesa_remove_renderbuffer(struct gl_framebuffer *fb, + gl_buffer_index bufferName); extern void _mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, diff --git a/mesalib/src/mesa/main/scissor.c b/mesalib/src/mesa/main/scissor.c index 716b16b80..16e8438c5 100644 --- a/mesalib/src/mesa/main/scissor.c +++ b/mesalib/src/mesa/main/scissor.c @@ -25,6 +25,7 @@ #include "main/glheader.h" #include "main/context.h" +#include "main/mtypes.h" #include "main/scissor.h" diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index d84273263..bcc7ec019 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -41,6 +41,8 @@ #include "main/dispatch.h" #include "main/enums.h" #include "main/hash.h" +#include "main/mfeatures.h" +#include "main/mtypes.h" #include "main/shaderapi.h" #include "main/shaderobj.h" #include "program/program.h" diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c index 60f133691..efee05ac6 100644 --- a/mesalib/src/mesa/main/shaderobj.c +++ b/mesalib/src/mesa/main/shaderobj.c @@ -32,6 +32,8 @@ #include "main/glheader.h" #include "main/context.h" #include "main/hash.h" +#include "main/mfeatures.h" +#include "main/mtypes.h" #include "main/shaderobj.h" #include "program/program.h" #include "program/prog_parameter.h" diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c index bfbddaaa0..9a2b90c8e 100644 --- a/mesalib/src/mesa/main/shared.c +++ b/mesalib/src/mesa/main/shared.c @@ -30,6 +30,7 @@ #include "imports.h" +#include "mfeatures.h" #include "mtypes.h" #include "hash.h" #if FEATURE_ATI_fragment_shader diff --git a/mesalib/src/mesa/main/syncobj.c b/mesalib/src/mesa/main/syncobj.c index eaffbfb9d..676038430 100644 --- a/mesalib/src/mesa/main/syncobj.c +++ b/mesalib/src/mesa/main/syncobj.c @@ -59,8 +59,10 @@ #include "imports.h" #include "context.h" #include "macros.h" +#include "mfeatures.h" #include "get.h" #include "dispatch.h" +#include "mtypes.h" #if FEATURE_ARB_sync #include "syncobj.h" diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c index 52954ece4..eaebb06d3 100644 --- a/mesalib/src/mesa/main/texcompress.c +++ b/mesalib/src/mesa/main/texcompress.c @@ -34,6 +34,8 @@ #include "imports.h" #include "colormac.h" #include "formats.h" +#include "mfeatures.h" +#include "mtypes.h" #include "texcompress.h" diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c index e6dd7f364..261014d63 100644 --- a/mesalib/src/mesa/main/texcompress_fxt1.c +++ b/mesalib/src/mesa/main/texcompress_fxt1.c @@ -34,6 +34,7 @@ #include "colormac.h" #include "image.h" #include "macros.h" +#include "mfeatures.h" #include "mipmap.h" #include "texcompress.h" #include "texcompress_fxt1.h" diff --git a/mesalib/src/mesa/main/texcompress_fxt1.h b/mesalib/src/mesa/main/texcompress_fxt1.h index 38048b26c..a6beb07e5 100644 --- a/mesalib/src/mesa/main/texcompress_fxt1.h +++ b/mesalib/src/mesa/main/texcompress_fxt1.h @@ -1,61 +1,62 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul 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 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 - * BRIAN PAUL 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. - */ - -#ifndef TEXCOMPRESS_FXT1_H -#define TEXCOMPRESS_FXT1_H - -#include "glheader.h" -#include "texstore.h" - -struct gl_texture_image; - -#if FEATURE_texture_fxt1 - -extern GLboolean -_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS); - -extern GLboolean -_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS); - -extern void -_mesa_fetch_texel_2d_f_rgba_fxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -extern void -_mesa_fetch_texel_2d_f_rgb_fxt1(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - -#else /* FEATURE_texture_fxt1 */ - -/* these are used only in texstore_funcs[] */ -#define _mesa_texstore_rgb_fxt1 NULL -#define _mesa_texstore_rgba_fxt1 NULL - -/* these are used only in texfetch_funcs[] */ -#define _mesa_fetch_texel_2d_f_rgba_fxt1 NULL -#define _mesa_fetch_texel_2d_f_rgb_fxt1 NULL - -#endif /* FEATURE_texture_fxt1 */ - -#endif /* TEXCOMPRESS_FXT1_H */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul 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 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 + * BRIAN PAUL 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. + */ + +#ifndef TEXCOMPRESS_FXT1_H +#define TEXCOMPRESS_FXT1_H + +#include "glheader.h" +#include "mfeatures.h" +#include "texstore.h" + +struct gl_texture_image; + +#if FEATURE_texture_fxt1 + +extern GLboolean +_mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS); + +extern void +_mesa_fetch_texel_2d_f_rgba_fxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_rgb_fxt1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +#else /* FEATURE_texture_fxt1 */ + +/* these are used only in texstore_funcs[] */ +#define _mesa_texstore_rgb_fxt1 NULL +#define _mesa_texstore_rgba_fxt1 NULL + +/* these are used only in texfetch_funcs[] */ +#define _mesa_fetch_texel_2d_f_rgba_fxt1 NULL +#define _mesa_fetch_texel_2d_f_rgb_fxt1 NULL + +#endif /* FEATURE_texture_fxt1 */ + +#endif /* TEXCOMPRESS_FXT1_H */ diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c index 307ca9436..90be6c0a8 100644 --- a/mesalib/src/mesa/main/texcompress_s3tc.c +++ b/mesalib/src/mesa/main/texcompress_s3tc.c @@ -39,6 +39,8 @@ #include "dlopen.h" #include "image.h" #include "macros.h" +#include "mfeatures.h" +#include "mtypes.h" #include "texcompress.h" #include "texcompress_s3tc.h" #include "texstore.h" diff --git a/mesalib/src/mesa/main/texenv.c b/mesalib/src/mesa/main/texenv.c index 5669cc4bc..c802f6f3b 100644 --- a/mesalib/src/mesa/main/texenv.c +++ b/mesalib/src/mesa/main/texenv.c @@ -34,6 +34,7 @@ #include "main/context.h" #include "main/enums.h" #include "main/macros.h" +#include "main/mtypes.h" #include "main/texenv.h" #include "main/texstate.h" diff --git a/mesalib/src/mesa/main/texenvprogram.c b/mesalib/src/mesa/main/texenvprogram.c index aa318f7de..af631af14 100644 --- a/mesalib/src/mesa/main/texenvprogram.c +++ b/mesalib/src/mesa/main/texenvprogram.c @@ -28,6 +28,7 @@ #include "glheader.h" #include "imports.h" +#include "mtypes.h" #include "program/program.h" #include "program/prog_parameter.h" #include "program/prog_cache.h" diff --git a/mesalib/src/mesa/main/texfetch_tmp.h b/mesalib/src/mesa/main/texfetch_tmp.h index 40f56209f..9c2b36a02 100644 --- a/mesalib/src/mesa/main/texfetch_tmp.h +++ b/mesalib/src/mesa/main/texfetch_tmp.h @@ -837,7 +837,7 @@ static void store_texel_argb2101010(struct gl_texture_image *texImage, { const GLubyte *rgba = (const GLubyte *) texel; GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); - *dst = PACK_COLOR_2101010(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); + *dst = PACK_COLOR_2101010_UB(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]); } #endif @@ -899,8 +899,8 @@ static void FETCH(f_al44)( const struct gl_texture_image *texImage, const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); texel[RCOMP] = texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_FLOAT( (s & 0x0f) << 4 ); - texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xf0 ); + texel[BCOMP] = (s & 0xf) * (1.0F / 15.0F); + texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); } #if DIM == 3 diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c index 7b0b17b25..325fb9ebc 100644 --- a/mesalib/src/mesa/main/texformat.c +++ b/mesalib/src/mesa/main/texformat.c @@ -34,9 +34,15 @@ #include "context.h" +#include "mfeatures.h" +#include "mtypes.h" #include "texcompress.h" #include "texformat.h" +#define RETURN_IF_SUPPORTED(f) do { \ + if (ctx->TextureFormatSupported[f]) \ + return f; \ +} while (0) /** * Choose an appropriate texture format given the format, type and @@ -64,85 +70,132 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, /* shallow RGBA formats */ case 4: case GL_RGBA: + if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) { + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444); + } else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) { + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB1555); + } + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA8888); + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); + break; + case GL_RGBA8: - return MESA_FORMAT_RGBA8888; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA8888); + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); + break; case GL_RGB5_A1: - return MESA_FORMAT_ARGB1555; + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB1555); + break; case GL_RGBA2: - return MESA_FORMAT_ARGB4444_REV; /* just to test another format*/ + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444_REV); /* just to test another format*/ + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444); + break; case GL_RGBA4: - return MESA_FORMAT_ARGB4444; + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444); + break; /* deep RGBA formats */ case GL_RGB10_A2: - return MESA_FORMAT_ARGB2101010; - + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB2101010); + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); + break; case GL_RGBA12: case GL_RGBA16: - return MESA_FORMAT_RGBA_16; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_16); + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_16); + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA8888); + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); + break; /* shallow RGB formats */ case 3: case GL_RGB: case GL_RGB8: - return MESA_FORMAT_RGB888; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB888); + RETURN_IF_SUPPORTED(MESA_FORMAT_XRGB8888); + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); + break; case GL_R3_G3_B2: - return MESA_FORMAT_RGB332; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB332); + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB888); + RETURN_IF_SUPPORTED(MESA_FORMAT_XRGB8888); + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); + break; case GL_RGB4: - return MESA_FORMAT_RGB565_REV; /* just to test another format */ + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565_REV); /* just to test another format */ + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565); + break; case GL_RGB5: - return MESA_FORMAT_RGB565; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565); + break; /* deep RGB formats */ case GL_RGB10: case GL_RGB12: case GL_RGB16: - return MESA_FORMAT_RGBA_16; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_16); + RETURN_IF_SUPPORTED(MESA_FORMAT_XRGB8888); + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); + break; /* Alpha formats */ case GL_ALPHA: case GL_ALPHA4: case GL_ALPHA8: - return MESA_FORMAT_A8; + RETURN_IF_SUPPORTED(MESA_FORMAT_A8); + break; case GL_ALPHA12: case GL_ALPHA16: - return MESA_FORMAT_A16; + RETURN_IF_SUPPORTED(MESA_FORMAT_A16); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8); + break; /* Luminance formats */ case 1: case GL_LUMINANCE: case GL_LUMINANCE4: case GL_LUMINANCE8: - return MESA_FORMAT_L8; + RETURN_IF_SUPPORTED(MESA_FORMAT_L8); + break; case GL_LUMINANCE12: case GL_LUMINANCE16: - return MESA_FORMAT_L16; + RETURN_IF_SUPPORTED(MESA_FORMAT_L16); + RETURN_IF_SUPPORTED(MESA_FORMAT_L8); + break; /* Luminance/Alpha formats */ case GL_LUMINANCE4_ALPHA4: - return MESA_FORMAT_AL44; + RETURN_IF_SUPPORTED(MESA_FORMAT_AL44); + RETURN_IF_SUPPORTED(MESA_FORMAT_AL88); + break; case 2: case GL_LUMINANCE_ALPHA: case GL_LUMINANCE6_ALPHA2: case GL_LUMINANCE8_ALPHA8: - return MESA_FORMAT_AL88; + RETURN_IF_SUPPORTED(MESA_FORMAT_AL88); + break; case GL_LUMINANCE12_ALPHA4: case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: - return MESA_FORMAT_AL1616; + RETURN_IF_SUPPORTED(MESA_FORMAT_AL1616); + RETURN_IF_SUPPORTED(MESA_FORMAT_AL88); + break; case GL_INTENSITY: case GL_INTENSITY4: case GL_INTENSITY8: - return MESA_FORMAT_I8; + RETURN_IF_SUPPORTED(MESA_FORMAT_I8); + break; case GL_INTENSITY12: case GL_INTENSITY16: - return MESA_FORMAT_I16; + RETURN_IF_SUPPORTED(MESA_FORMAT_I16); + RETURN_IF_SUPPORTED(MESA_FORMAT_I8); + break; case GL_COLOR_INDEX: case GL_COLOR_INDEX1_EXT: @@ -151,7 +204,8 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, case GL_COLOR_INDEX12_EXT: case GL_COLOR_INDEX16_EXT: case GL_COLOR_INDEX8_EXT: - return MESA_FORMAT_CI8; + RETURN_IF_SUPPORTED(MESA_FORMAT_CI8); + break; default: ; /* fallthrough */ @@ -162,9 +216,12 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT24: case GL_DEPTH_COMPONENT32: - return MESA_FORMAT_Z32; + RETURN_IF_SUPPORTED(MESA_FORMAT_Z32); + RETURN_IF_SUPPORTED(MESA_FORMAT_S8_Z24); + break; case GL_DEPTH_COMPONENT16: - return MESA_FORMAT_Z16; + RETURN_IF_SUPPORTED(MESA_FORMAT_Z16); + RETURN_IF_SUPPORTED(MESA_FORMAT_S8_Z24); default: ; /* fallthrough */ } @@ -172,27 +229,36 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, switch (internalFormat) { case GL_COMPRESSED_ALPHA_ARB: - return MESA_FORMAT_A8; + RETURN_IF_SUPPORTED(MESA_FORMAT_A8); + break; case GL_COMPRESSED_LUMINANCE_ARB: - return MESA_FORMAT_L8; + RETURN_IF_SUPPORTED(MESA_FORMAT_L8); + break; case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: - return MESA_FORMAT_AL88; + RETURN_IF_SUPPORTED(MESA_FORMAT_AL88); + break; case GL_COMPRESSED_INTENSITY_ARB: - return MESA_FORMAT_I8; + RETURN_IF_SUPPORTED(MESA_FORMAT_I8); + break; case GL_COMPRESSED_RGB_ARB: if (ctx->Extensions.EXT_texture_compression_s3tc || ctx->Extensions.S3_s3tc) - return MESA_FORMAT_RGB_DXT1; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_DXT1); if (ctx->Extensions.TDFX_texture_compression_FXT1) - return MESA_FORMAT_RGB_FXT1; - return MESA_FORMAT_RGB888; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FXT1); + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB888); + RETURN_IF_SUPPORTED(MESA_FORMAT_XRGB8888); + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); + break; case GL_COMPRESSED_RGBA_ARB: if (ctx->Extensions.EXT_texture_compression_s3tc || ctx->Extensions.S3_s3tc) - return MESA_FORMAT_RGBA_DXT3; /* Not rgba_dxt1, see spec */ + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT3); /* Not rgba_dxt1, see spec */ if (ctx->Extensions.TDFX_texture_compression_FXT1) - return MESA_FORMAT_RGBA_FXT1; - return MESA_FORMAT_RGBA8888; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FXT1); + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA8888); + RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); + break; default: ; /* fallthrough */ } @@ -200,9 +266,9 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, if (ctx->Extensions.MESA_ycbcr_texture) { if (internalFormat == GL_YCBCR_MESA) { if (type == GL_UNSIGNED_SHORT_8_8_MESA) - return MESA_FORMAT_YCBCR; + RETURN_IF_SUPPORTED(MESA_FORMAT_YCBCR); else - return MESA_FORMAT_YCBCR_REV; + RETURN_IF_SUPPORTED(MESA_FORMAT_YCBCR_REV); } } @@ -210,9 +276,11 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, if (ctx->Extensions.TDFX_texture_compression_FXT1) { switch (internalFormat) { case GL_COMPRESSED_RGB_FXT1_3DFX: - return MESA_FORMAT_RGB_FXT1; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FXT1); + break; case GL_COMPRESSED_RGBA_FXT1_3DFX: - return MESA_FORMAT_RGBA_FXT1; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FXT1); + break; default: ; /* fallthrough */ } @@ -223,13 +291,17 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, if (ctx->Extensions.EXT_texture_compression_s3tc) { switch (internalFormat) { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return MESA_FORMAT_RGB_DXT1; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_DXT1); + break; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return MESA_FORMAT_RGBA_DXT1; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT1); + break; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - return MESA_FORMAT_RGBA_DXT3; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT3); + break; case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return MESA_FORMAT_RGBA_DXT5; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT5); + break; default: ; /* fallthrough */ } @@ -239,10 +311,12 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, switch (internalFormat) { case GL_RGB_S3TC: case GL_RGB4_S3TC: - return MESA_FORMAT_RGB_DXT1; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_DXT1); + break; case GL_RGBA_S3TC: case GL_RGBA4_S3TC: - return MESA_FORMAT_RGBA_DXT3; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT3); + break; default: ; /* fallthrough */ } @@ -252,29 +326,41 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, if (ctx->Extensions.ARB_texture_float) { switch (internalFormat) { case GL_ALPHA16F_ARB: - return MESA_FORMAT_ALPHA_FLOAT16; + RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_FLOAT16); + break; case GL_ALPHA32F_ARB: - return MESA_FORMAT_ALPHA_FLOAT32; + RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_FLOAT32); + break; case GL_LUMINANCE16F_ARB: - return MESA_FORMAT_LUMINANCE_FLOAT16; + RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_FLOAT16); + break; case GL_LUMINANCE32F_ARB: - return MESA_FORMAT_LUMINANCE_FLOAT32; + RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_FLOAT32); + break; case GL_LUMINANCE_ALPHA16F_ARB: - return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16; + RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16); + break; case GL_LUMINANCE_ALPHA32F_ARB: - return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32; + RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32); + break; case GL_INTENSITY16F_ARB: - return MESA_FORMAT_INTENSITY_FLOAT16; + RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_FLOAT16); + break; case GL_INTENSITY32F_ARB: - return MESA_FORMAT_INTENSITY_FLOAT32; + RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_FLOAT32); + break; case GL_RGB16F_ARB: - return MESA_FORMAT_RGB_FLOAT16; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FLOAT16); + break; case GL_RGB32F_ARB: - return MESA_FORMAT_RGB_FLOAT32; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FLOAT32); + break; case GL_RGBA16F_ARB: - return MESA_FORMAT_RGBA_FLOAT16; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16); + break; case GL_RGBA32F_ARB: - return MESA_FORMAT_RGBA_FLOAT32; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32); + break; default: ; /* fallthrough */ } @@ -284,7 +370,9 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, switch (internalFormat) { case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: - return MESA_FORMAT_Z24_S8; + RETURN_IF_SUPPORTED(MESA_FORMAT_Z24_S8); + RETURN_IF_SUPPORTED(MESA_FORMAT_S8_Z24); + break; default: ; /* fallthrough */ } @@ -294,7 +382,8 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, switch (internalFormat) { case GL_DUDV_ATI: case GL_DU8DV8_ATI: - return MESA_FORMAT_DUDV8; + RETURN_IF_SUPPORTED(MESA_FORMAT_DUDV8); + break; default: ; /* fallthrough */ } @@ -304,7 +393,9 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, switch (internalFormat) { case GL_RGBA_SNORM: case GL_RGBA8_SNORM: - return MESA_FORMAT_SIGNED_RGBA8888; + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888); + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888_REV); + break; default: ; /* fallthrough */ } @@ -314,24 +405,32 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, switch (internalFormat) { case GL_RED_SNORM: case GL_R8_SNORM: - return MESA_FORMAT_SIGNED_R8; + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_R8); + break; case GL_RG_SNORM: case GL_RG8_SNORM: - return MESA_FORMAT_SIGNED_RG88; + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RG88); + break; case GL_RGB_SNORM: case GL_RGB8_SNORM: - return MESA_FORMAT_SIGNED_RGBX8888; + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBX8888); + break; case GL_RGBA_SNORM: case GL_RGBA8_SNORM: - return MESA_FORMAT_SIGNED_RGBA8888; + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA8888); + break; case GL_R16_SNORM: - return MESA_FORMAT_SIGNED_R_16; + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_R_16); + break; case GL_RG16_SNORM: - return MESA_FORMAT_SIGNED_RG_16; + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RG_16); + break; case GL_RGB16_SNORM: - return MESA_FORMAT_SIGNED_RGB_16; + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGB_16); + break; case GL_RGBA16_SNORM: - return MESA_FORMAT_SIGNED_RGBA_16; + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RGBA_16); + break; default: ; /* fall-through */ } @@ -342,48 +441,68 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, switch (internalFormat) { case GL_SRGB_EXT: case GL_SRGB8_EXT: - return MESA_FORMAT_SRGB8; + RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB8); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); + break; case GL_SRGB_ALPHA_EXT: case GL_SRGB8_ALPHA8_EXT: - return MESA_FORMAT_SRGBA8; + RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA8); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); + break; case GL_SLUMINANCE_EXT: case GL_SLUMINANCE8_EXT: - return MESA_FORMAT_SL8; + RETURN_IF_SUPPORTED(MESA_FORMAT_SL8); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); + break; case GL_SLUMINANCE_ALPHA_EXT: case GL_SLUMINANCE8_ALPHA8_EXT: - return MESA_FORMAT_SLA8; + RETURN_IF_SUPPORTED(MESA_FORMAT_SLA8); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); + break; case GL_COMPRESSED_SLUMINANCE_EXT: - return MESA_FORMAT_SL8; + RETURN_IF_SUPPORTED(MESA_FORMAT_SL8); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); + break; case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: - return MESA_FORMAT_SLA8; + RETURN_IF_SUPPORTED(MESA_FORMAT_SLA8); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); + break; case GL_COMPRESSED_SRGB_EXT: #if FEATURE_texture_s3tc if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGB_DXT1; + RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB_DXT1); #endif - return MESA_FORMAT_SRGB8; + RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB8); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); + break; case GL_COMPRESSED_SRGB_ALPHA_EXT: #if FEATURE_texture_s3tc if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGBA_DXT3; /* Not srgba_dxt1, see spec */ + RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT3); /* Not srgba_dxt1, see spec */ #endif - return MESA_FORMAT_SRGBA8; + RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA8); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); + break; #if FEATURE_texture_s3tc case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGB_DXT1; + RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB_DXT1); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); break; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGBA_DXT1; + RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT1); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); break; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGBA_DXT3; + RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT3); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); break; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: if (ctx->Extensions.EXT_texture_compression_s3tc) - return MESA_FORMAT_SRGBA_DXT5; + RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT5); + RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8); break; #endif default: @@ -400,42 +519,48 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, case GL_INTENSITY32UI_EXT: case GL_LUMINANCE32UI_EXT: case GL_LUMINANCE_ALPHA32UI_EXT: - return MESA_FORMAT_RGBA_UINT32; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT32); + break; case GL_RGBA16UI_EXT: case GL_RGB16UI_EXT: case GL_ALPHA16UI_EXT: case GL_INTENSITY16UI_EXT: case GL_LUMINANCE16UI_EXT: case GL_LUMINANCE_ALPHA16UI_EXT: - return MESA_FORMAT_RGBA_UINT16; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT16); + break; case GL_RGBA8UI_EXT: case GL_RGB8UI_EXT: case GL_ALPHA8UI_EXT: case GL_INTENSITY8UI_EXT: case GL_LUMINANCE8UI_EXT: case GL_LUMINANCE_ALPHA8UI_EXT: - return MESA_FORMAT_RGBA_UINT8; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_UINT8); + break; case GL_RGBA32I_EXT: case GL_RGB32I_EXT: case GL_ALPHA32I_EXT: case GL_INTENSITY32I_EXT: case GL_LUMINANCE32I_EXT: case GL_LUMINANCE_ALPHA32I_EXT: - return MESA_FORMAT_RGBA_INT32; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT32); + break; case GL_RGBA16I_EXT: case GL_RGB16I_EXT: case GL_ALPHA16I_EXT: case GL_INTENSITY16I_EXT: case GL_LUMINANCE16I_EXT: case GL_LUMINANCE_ALPHA16I_EXT: - return MESA_FORMAT_RGBA_INT16; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT16); + break; case GL_RGBA8I_EXT: case GL_RGB8I_EXT: case GL_ALPHA8I_EXT: case GL_INTENSITY8I_EXT: case GL_LUMINANCE8I_EXT: case GL_LUMINANCE_ALPHA8I_EXT: - return MESA_FORMAT_RGBA_INT8; + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_INT8); + break; } } @@ -444,18 +569,22 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, case GL_R8: case GL_RED: case GL_COMPRESSED_RED: - return MESA_FORMAT_R8; + RETURN_IF_SUPPORTED(MESA_FORMAT_R8); + break; case GL_R16: - return MESA_FORMAT_R16; + RETURN_IF_SUPPORTED(MESA_FORMAT_R16); + break; case GL_RG: case GL_RG8: case GL_COMPRESSED_RG: - return MESA_FORMAT_RG88; + RETURN_IF_SUPPORTED(MESA_FORMAT_RG88); + break; case GL_RG16: - return MESA_FORMAT_RG1616; + RETURN_IF_SUPPORTED(MESA_FORMAT_RG1616); + break; default: ; /* fallthrough */ diff --git a/mesalib/src/mesa/main/texgen.c b/mesalib/src/mesa/main/texgen.c index 108ea4cd4..10eaa89ad 100644 --- a/mesalib/src/mesa/main/texgen.c +++ b/mesalib/src/mesa/main/texgen.c @@ -1,400 +1,401 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, 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 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 - * BRIAN PAUL 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. - */ - -/** - * \file texgen.c - * - * glTexGen-related functions - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/enums.h" -#include "main/macros.h" -#include "main/texgen.h" -#include "main/texstate.h" -#include "math/m_matrix.h" -#include "main/dispatch.h" - - -#if FEATURE_texgen - - -/** - * Return texgen state for given coordinate - */ -static struct gl_texgen * -get_texgen(struct gl_texture_unit *texUnit, GLenum coord) -{ - switch (coord) { - case GL_S: - return &texUnit->GenS; - case GL_T: - return &texUnit->GenT; - case GL_R: - return &texUnit->GenR; - case GL_Q: - return &texUnit->GenQ; - default: - return NULL; - } -} - - -void GLAPIENTRY -_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) -{ - struct gl_texture_unit *texUnit; - struct gl_texgen *texgen; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexGen %s %s %.1f(%s)...\n", - _mesa_lookup_enum_by_nr(coord), - _mesa_lookup_enum_by_nr(pname), - *params, - _mesa_lookup_enum_by_nr((GLenum) (GLint) *params)); - - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexGen(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - texgen = get_texgen(texUnit, coord); - if (!texgen) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexGen(coord)"); - return; - } - - switch (pname) { - case GL_TEXTURE_GEN_MODE: - { - GLenum mode = (GLenum) (GLint) params[0]; - GLbitfield bit = 0x0; - if (texgen->Mode == mode) - return; - switch (mode) { - case GL_OBJECT_LINEAR: - bit = TEXGEN_OBJ_LINEAR; - break; - case GL_EYE_LINEAR: - bit = TEXGEN_EYE_LINEAR; - break; - case GL_SPHERE_MAP: - if (coord == GL_S || coord == GL_T) - bit = TEXGEN_SPHERE_MAP; - break; - case GL_REFLECTION_MAP_NV: - if (coord != GL_Q) - bit = TEXGEN_REFLECTION_MAP_NV; - break; - case GL_NORMAL_MAP_NV: - if (coord != GL_Q) - bit = TEXGEN_NORMAL_MAP_NV; - break; - default: - ; /* nop */ - } - if (!bit) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); - return; - } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texgen->Mode = mode; - texgen->_ModeBit = bit; - } - break; - - case GL_OBJECT_PLANE: - { - if (TEST_EQ_4V(texgen->ObjectPlane, params)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texgen->ObjectPlane, params); - } - break; - - case GL_EYE_PLANE: - { - GLfloat tmp[4]; - /* Transform plane equation by the inverse modelview matrix */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { - _math_matrix_analyse(ctx->ModelviewMatrixStack.Top); - } - _mesa_transform_vector(tmp, params, - ctx->ModelviewMatrixStack.Top->inv); - if (TEST_EQ_4V(texgen->EyePlane, tmp)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texgen->EyePlane, tmp); - } - break; - - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); - return; - } - - if (ctx->Driver.TexGen) - ctx->Driver.TexGen( ctx, coord, pname, params ); -} - - -static void GLAPIENTRY -_mesa_TexGeniv(GLenum coord, GLenum pname, const GLint *params ) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - if (pname == GL_TEXTURE_GEN_MODE) { - p[1] = p[2] = p[3] = 0.0F; - } - else { - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - } - _mesa_TexGenfv(coord, pname, p); -} - - -static void GLAPIENTRY -_mesa_TexGend(GLenum coord, GLenum pname, GLdouble param ) -{ - GLfloat p[4]; - p[0] = (GLfloat) param; - p[1] = p[2] = p[3] = 0.0F; - _mesa_TexGenfv( coord, pname, p ); -} - -#if FEATURE_ES1 - -void GLAPIENTRY -_es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) -{ - ASSERT(coord == GL_TEXTURE_GEN_STR_OES); - _mesa_GetTexGenfv(GL_S, pname, params); -} - - -void GLAPIENTRY -_es_TexGenf(GLenum coord, GLenum pname, GLfloat param) -{ - ASSERT(coord == GL_TEXTURE_GEN_STR_OES); - /* set S, T, and R at the same time */ - _mesa_TexGenf(GL_S, pname, param); - _mesa_TexGenf(GL_T, pname, param); - _mesa_TexGenf(GL_R, pname, param); -} - - -void GLAPIENTRY -_es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) -{ - ASSERT(coord == GL_TEXTURE_GEN_STR_OES); - /* set S, T, and R at the same time */ - _mesa_TexGenfv(GL_S, pname, params); - _mesa_TexGenfv(GL_T, pname, params); - _mesa_TexGenfv(GL_R, pname, params); -} - -#endif - -static void GLAPIENTRY -_mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params ) -{ - GLfloat p[4]; - p[0] = (GLfloat) params[0]; - if (pname == GL_TEXTURE_GEN_MODE) { - p[1] = p[2] = p[3] = 0.0F; - } - else { - p[1] = (GLfloat) params[1]; - p[2] = (GLfloat) params[2]; - p[3] = (GLfloat) params[3]; - } - _mesa_TexGenfv( coord, pname, p ); -} - - -void GLAPIENTRY -_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ) -{ - GLfloat p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0.0F; - _mesa_TexGenfv(coord, pname, p); -} - - -void GLAPIENTRY -_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) -{ - GLint p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0; - _mesa_TexGeniv( coord, pname, p ); -} - - - -static void GLAPIENTRY -_mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) -{ - struct gl_texture_unit *texUnit; - struct gl_texgen *texgen; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGendv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - texgen = get_texgen(texUnit, coord); - if (!texgen) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)"); - return; - } - - switch (pname) { - case GL_TEXTURE_GEN_MODE: - params[0] = ENUM_TO_DOUBLE(texgen->Mode); - break; - case GL_OBJECT_PLANE: - COPY_4V(params, texgen->ObjectPlane); - break; - case GL_EYE_PLANE: - COPY_4V(params, texgen->EyePlane); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); - } -} - - - -void GLAPIENTRY -_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) -{ - struct gl_texture_unit *texUnit; - struct gl_texgen *texgen; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGenfv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - texgen = get_texgen(texUnit, coord); - if (!texgen) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)"); - return; - } - - switch (pname) { - case GL_TEXTURE_GEN_MODE: - params[0] = ENUM_TO_FLOAT(texgen->Mode); - break; - case GL_OBJECT_PLANE: - COPY_4V(params, texgen->ObjectPlane); - break; - case GL_EYE_PLANE: - COPY_4V(params, texgen->EyePlane); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); - } -} - - - -static void GLAPIENTRY -_mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) -{ - struct gl_texture_unit *texUnit; - struct gl_texgen *texgen; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGeniv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - texgen = get_texgen(texUnit, coord); - if (!texgen) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)"); - return; - } - - switch (pname) { - case GL_TEXTURE_GEN_MODE: - params[0] = texgen->Mode; - break; - case GL_OBJECT_PLANE: - params[0] = (GLint) texgen->ObjectPlane[0]; - params[1] = (GLint) texgen->ObjectPlane[1]; - params[2] = (GLint) texgen->ObjectPlane[2]; - params[3] = (GLint) texgen->ObjectPlane[3]; - break; - case GL_EYE_PLANE: - params[0] = (GLint) texgen->EyePlane[0]; - params[1] = (GLint) texgen->EyePlane[1]; - params[2] = (GLint) texgen->EyePlane[2]; - params[3] = (GLint) texgen->EyePlane[3]; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); - } -} - - -void -_mesa_init_texgen_dispatch(struct _glapi_table *disp) -{ - SET_GetTexGendv(disp, _mesa_GetTexGendv); - SET_GetTexGenfv(disp, _mesa_GetTexGenfv); - SET_GetTexGeniv(disp, _mesa_GetTexGeniv); - SET_TexGend(disp, _mesa_TexGend); - SET_TexGendv(disp, _mesa_TexGendv); - SET_TexGenf(disp, _mesa_TexGenf); - SET_TexGenfv(disp, _mesa_TexGenfv); - SET_TexGeni(disp, _mesa_TexGeni); - SET_TexGeniv(disp, _mesa_TexGeniv); -} - - -#endif /* FEATURE_texgen */ +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, 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 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 + * BRIAN PAUL 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. + */ + +/** + * \file texgen.c + * + * glTexGen-related functions + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/enums.h" +#include "main/macros.h" +#include "main/mfeatures.h" +#include "main/texgen.h" +#include "main/texstate.h" +#include "math/m_matrix.h" +#include "main/dispatch.h" + + +#if FEATURE_texgen + + +/** + * Return texgen state for given coordinate + */ +static struct gl_texgen * +get_texgen(struct gl_texture_unit *texUnit, GLenum coord) +{ + switch (coord) { + case GL_S: + return &texUnit->GenS; + case GL_T: + return &texUnit->GenT; + case GL_R: + return &texUnit->GenR; + case GL_Q: + return &texUnit->GenQ; + default: + return NULL; + } +} + + +void GLAPIENTRY +_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) +{ + struct gl_texture_unit *texUnit; + struct gl_texgen *texgen; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glTexGen %s %s %.1f(%s)...\n", + _mesa_lookup_enum_by_nr(coord), + _mesa_lookup_enum_by_nr(pname), + *params, + _mesa_lookup_enum_by_nr((GLenum) (GLint) *params)); + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexGen(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + texgen = get_texgen(texUnit, coord); + if (!texgen) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexGen(coord)"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + { + GLenum mode = (GLenum) (GLint) params[0]; + GLbitfield bit = 0x0; + if (texgen->Mode == mode) + return; + switch (mode) { + case GL_OBJECT_LINEAR: + bit = TEXGEN_OBJ_LINEAR; + break; + case GL_EYE_LINEAR: + bit = TEXGEN_EYE_LINEAR; + break; + case GL_SPHERE_MAP: + if (coord == GL_S || coord == GL_T) + bit = TEXGEN_SPHERE_MAP; + break; + case GL_REFLECTION_MAP_NV: + if (coord != GL_Q) + bit = TEXGEN_REFLECTION_MAP_NV; + break; + case GL_NORMAL_MAP_NV: + if (coord != GL_Q) + bit = TEXGEN_NORMAL_MAP_NV; + break; + default: + ; /* nop */ + } + if (!bit) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texgen->Mode = mode; + texgen->_ModeBit = bit; + } + break; + + case GL_OBJECT_PLANE: + { + if (TEST_EQ_4V(texgen->ObjectPlane, params)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texgen->ObjectPlane, params); + } + break; + + case GL_EYE_PLANE: + { + GLfloat tmp[4]; + /* Transform plane equation by the inverse modelview matrix */ + if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { + _math_matrix_analyse(ctx->ModelviewMatrixStack.Top); + } + _mesa_transform_vector(tmp, params, + ctx->ModelviewMatrixStack.Top->inv); + if (TEST_EQ_4V(texgen->EyePlane, tmp)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texgen->EyePlane, tmp); + } + break; + + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); + return; + } + + if (ctx->Driver.TexGen) + ctx->Driver.TexGen( ctx, coord, pname, params ); +} + + +static void GLAPIENTRY +_mesa_TexGeniv(GLenum coord, GLenum pname, const GLint *params ) +{ + GLfloat p[4]; + p[0] = (GLfloat) params[0]; + if (pname == GL_TEXTURE_GEN_MODE) { + p[1] = p[2] = p[3] = 0.0F; + } + else { + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + } + _mesa_TexGenfv(coord, pname, p); +} + + +static void GLAPIENTRY +_mesa_TexGend(GLenum coord, GLenum pname, GLdouble param ) +{ + GLfloat p[4]; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0F; + _mesa_TexGenfv( coord, pname, p ); +} + +#if FEATURE_ES1 + +void GLAPIENTRY +_es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) +{ + ASSERT(coord == GL_TEXTURE_GEN_STR_OES); + _mesa_GetTexGenfv(GL_S, pname, params); +} + + +void GLAPIENTRY +_es_TexGenf(GLenum coord, GLenum pname, GLfloat param) +{ + ASSERT(coord == GL_TEXTURE_GEN_STR_OES); + /* set S, T, and R at the same time */ + _mesa_TexGenf(GL_S, pname, param); + _mesa_TexGenf(GL_T, pname, param); + _mesa_TexGenf(GL_R, pname, param); +} + + +void GLAPIENTRY +_es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) +{ + ASSERT(coord == GL_TEXTURE_GEN_STR_OES); + /* set S, T, and R at the same time */ + _mesa_TexGenfv(GL_S, pname, params); + _mesa_TexGenfv(GL_T, pname, params); + _mesa_TexGenfv(GL_R, pname, params); +} + +#endif + +static void GLAPIENTRY +_mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params ) +{ + GLfloat p[4]; + p[0] = (GLfloat) params[0]; + if (pname == GL_TEXTURE_GEN_MODE) { + p[1] = p[2] = p[3] = 0.0F; + } + else { + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + } + _mesa_TexGenfv( coord, pname, p ); +} + + +void GLAPIENTRY +_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ) +{ + GLfloat p[4]; + p[0] = param; + p[1] = p[2] = p[3] = 0.0F; + _mesa_TexGenfv(coord, pname, p); +} + + +void GLAPIENTRY +_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) +{ + GLint p[4]; + p[0] = param; + p[1] = p[2] = p[3] = 0; + _mesa_TexGeniv( coord, pname, p ); +} + + + +static void GLAPIENTRY +_mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) +{ + struct gl_texture_unit *texUnit; + struct gl_texgen *texgen; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGendv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + texgen = get_texgen(texUnit, coord); + if (!texgen) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + params[0] = ENUM_TO_DOUBLE(texgen->Mode); + break; + case GL_OBJECT_PLANE: + COPY_4V(params, texgen->ObjectPlane); + break; + case GL_EYE_PLANE: + COPY_4V(params, texgen->EyePlane); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); + } +} + + + +void GLAPIENTRY +_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) +{ + struct gl_texture_unit *texUnit; + struct gl_texgen *texgen; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGenfv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + texgen = get_texgen(texUnit, coord); + if (!texgen) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + params[0] = ENUM_TO_FLOAT(texgen->Mode); + break; + case GL_OBJECT_PLANE: + COPY_4V(params, texgen->ObjectPlane); + break; + case GL_EYE_PLANE: + COPY_4V(params, texgen->EyePlane); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); + } +} + + + +static void GLAPIENTRY +_mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) +{ + struct gl_texture_unit *texUnit; + struct gl_texgen *texgen; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGeniv(current unit)"); + return; + } + + texUnit = _mesa_get_current_tex_unit(ctx); + + texgen = get_texgen(texUnit, coord); + if (!texgen) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + params[0] = texgen->Mode; + break; + case GL_OBJECT_PLANE: + params[0] = (GLint) texgen->ObjectPlane[0]; + params[1] = (GLint) texgen->ObjectPlane[1]; + params[2] = (GLint) texgen->ObjectPlane[2]; + params[3] = (GLint) texgen->ObjectPlane[3]; + break; + case GL_EYE_PLANE: + params[0] = (GLint) texgen->EyePlane[0]; + params[1] = (GLint) texgen->EyePlane[1]; + params[2] = (GLint) texgen->EyePlane[2]; + params[3] = (GLint) texgen->EyePlane[3]; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); + } +} + + +void +_mesa_init_texgen_dispatch(struct _glapi_table *disp) +{ + SET_GetTexGendv(disp, _mesa_GetTexGendv); + SET_GetTexGenfv(disp, _mesa_GetTexGenfv); + SET_GetTexGeniv(disp, _mesa_GetTexGeniv); + SET_TexGend(disp, _mesa_TexGend); + SET_TexGendv(disp, _mesa_TexGendv); + SET_TexGenf(disp, _mesa_TexGenf); + SET_TexGenfv(disp, _mesa_TexGenfv); + SET_TexGeni(disp, _mesa_TexGeni); + SET_TexGeniv(disp, _mesa_TexGeniv); +} + + +#endif /* FEATURE_texgen */ diff --git a/mesalib/src/mesa/main/texgen.h b/mesalib/src/mesa/main/texgen.h index 9ed802383..9160af002 100644 --- a/mesalib/src/mesa/main/texgen.h +++ b/mesalib/src/mesa/main/texgen.h @@ -1,84 +1,85 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 Brian Paul 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 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 - * BRIAN PAUL 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. - */ - - -#ifndef TEXGEN_H -#define TEXGEN_H - - -#include "compiler.h" -#include "glheader.h" - -struct _glapi_table; - - -#if FEATURE_texgen - -extern void GLAPIENTRY -_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); - -extern void GLAPIENTRY -_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ); - -extern void GLAPIENTRY -_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ); - -extern void GLAPIENTRY -_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); - -extern void -_mesa_init_texgen_dispatch(struct _glapi_table *disp); - - -extern void GLAPIENTRY -_es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params); - -extern void GLAPIENTRY -_es_TexGenf(GLenum coord, GLenum pname, GLfloat param); - -extern void GLAPIENTRY -_es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params); - - -#else /* FEATURE_texgen */ - -static void -_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) -{ -} - -static void INLINE -_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) -{ -} - -static INLINE void -_mesa_init_texgen_dispatch(struct _glapi_table *disp) -{ -} - -#endif /* FEATURE_texgen */ - - -#endif /* TEXGEN_H */ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul 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 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 + * BRIAN PAUL 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. + */ + + +#ifndef TEXGEN_H +#define TEXGEN_H + + +#include "compiler.h" +#include "glheader.h" +#include "mfeatures.h" + +struct _glapi_table; + + +#if FEATURE_texgen + +extern void GLAPIENTRY +_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); + +extern void GLAPIENTRY +_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ); + +extern void GLAPIENTRY +_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ); + +extern void GLAPIENTRY +_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); + +extern void +_mesa_init_texgen_dispatch(struct _glapi_table *disp); + + +extern void GLAPIENTRY +_es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params); + +extern void GLAPIENTRY +_es_TexGenf(GLenum coord, GLenum pname, GLfloat param); + +extern void GLAPIENTRY +_es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params); + + +#else /* FEATURE_texgen */ + +static void +_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) +{ +} + +static void INLINE +_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) +{ +} + +static INLINE void +_mesa_init_texgen_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_texgen */ + + +#endif /* TEXGEN_H */ diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index 227a670da..36bd02a6c 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -35,6 +35,8 @@ #include "context.h" #include "formats.h" #include "image.h" +#include "mfeatures.h" +#include "mtypes.h" #include "pack.h" #include "texgetimage.h" #include "teximage.h" diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index f62074a1b..a4143ba45 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -40,6 +40,7 @@ #include "image.h" #include "imports.h" #include "macros.h" +#include "mfeatures.h" #include "state.h" #include "texcompress.h" #include "texfetch.h" @@ -340,11 +341,11 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) return GL_RGBA; case GL_SLUMINANCE_ALPHA_EXT: case GL_SLUMINANCE8_ALPHA8_EXT: - case GL_COMPRESSED_SLUMINANCE_EXT: case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: return GL_LUMINANCE_ALPHA; case GL_SLUMINANCE_EXT: case GL_SLUMINANCE8_EXT: + case GL_COMPRESSED_SLUMINANCE_EXT: return GL_LUMINANCE; default: ; /* fallthrough */ diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c index 6a038514b..831dbc5b6 100644 --- a/mesalib/src/mesa/main/texobj.c +++ b/mesalib/src/mesa/main/texobj.c @@ -470,6 +470,12 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx, ASSERT(maxLevels > 0); + if (t->MaxLevel < t->BaseLevel) { + incomplete(t, "MAX_LEVEL (%d) < BASE_LEVEL (%d)", + t->MaxLevel, t->BaseLevel); + return; + } + t->_MaxLevel = baseLevel + maxLog2; t->_MaxLevel = MIN2(t->_MaxLevel, t->MaxLevel); t->_MaxLevel = MIN2(t->_MaxLevel, maxLevels - 1); diff --git a/mesalib/src/mesa/main/texpal.c b/mesalib/src/mesa/main/texpal.c index a25e7aa4f..801914462 100644 --- a/mesalib/src/mesa/main/texpal.c +++ b/mesalib/src/mesa/main/texpal.c @@ -1,204 +1,205 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - **************************************************************************/ - - -/** - * Code to convert compressed/paletted texture images to ordinary images. - * See the GL_OES_compressed_paletted_texture spec at - * http://khronos.org/registry/gles/extensions/OES/OES_compressed_paletted_texture.txt - * - * XXX this makes it impossible to add hardware support... - */ - - -#include "glheader.h" -#include "compiler.h" /* for ASSERT */ -#include "context.h" -#include "mtypes.h" -#include "imports.h" -#include "pixelstore.h" -#include "teximage.h" -#include "texpal.h" - -#if FEATURE_ES - - -static const struct cpal_format_info { - GLenum cpal_format; - GLenum format; - GLenum type; - GLuint palette_size; - GLuint size; -} formats[] = { - { GL_PALETTE4_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE, 16, 3 }, - { GL_PALETTE4_RGBA8_OES, GL_RGBA, GL_UNSIGNED_BYTE, 16, 4 }, - { GL_PALETTE4_R5_G6_B5_OES, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, 2 }, - { GL_PALETTE4_RGBA4_OES, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, 2 }, - { GL_PALETTE4_RGB5_A1_OES, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, 2 }, - { GL_PALETTE8_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE, 256, 3 }, - { GL_PALETTE8_RGBA8_OES, GL_RGBA, GL_UNSIGNED_BYTE, 256, 4 }, - { GL_PALETTE8_R5_G6_B5_OES, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 256, 2 }, - { GL_PALETTE8_RGBA4_OES, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 256, 2 }, - { GL_PALETTE8_RGB5_A1_OES, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 256, 2 } -}; - - -/** - * Get a color/entry from the palette. - */ -static GLuint -get_palette_entry(const struct cpal_format_info *info, const GLubyte *palette, - GLuint index, GLubyte *pixel) -{ - memcpy(pixel, palette + info->size * index, info->size); - return info->size; -} - - -/** - * Convert paletted texture to color texture. - */ -static void -paletted_to_color(const struct cpal_format_info *info, const GLubyte *palette, - const void *indices, GLuint num_pixels, GLubyte *image) -{ - GLubyte *pix = image; - GLuint remain, i; - - if (info->palette_size == 16) { - /* 4 bits per index */ - const GLubyte *ind = (const GLubyte *) indices; - - /* two pixels per iteration */ - remain = num_pixels % 2; - for (i = 0; i < num_pixels / 2; i++) { - pix += get_palette_entry(info, palette, (ind[i] >> 4) & 0xf, pix); - pix += get_palette_entry(info, palette, ind[i] & 0xf, pix); - } - if (remain) { - get_palette_entry(info, palette, (ind[i] >> 4) & 0xf, pix); - } - } - else { - /* 8 bits per index */ - const GLubyte *ind = (const GLubyte *) indices; - for (i = 0; i < num_pixels; i++) - pix += get_palette_entry(info, palette, ind[i], pix); - } -} - - -static const struct cpal_format_info * -cpal_get_info(GLint level, GLenum internalFormat, - GLsizei width, GLsizei height, GLsizei imageSize) -{ - const struct cpal_format_info *info; - GLint lvl, num_levels; - GLsizei w, h, expect_size; - - info = &formats[internalFormat - GL_PALETTE4_RGB8_OES]; - ASSERT(info->cpal_format == internalFormat); - - if (level > 0) { - _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, - "glCompressedTexImage2D(level=%d)", level); - return NULL; - } - - num_levels = -level + 1; - expect_size = info->palette_size * info->size; - for (lvl = 0; lvl < num_levels; lvl++) { - w = width >> lvl; - if (!w) - w = 1; - h = height >> lvl; - if (!h) - h = 1; - - if (info->palette_size == 16) - expect_size += (w * h + 1) / 2; - else - expect_size += w * h; - } - if (expect_size > imageSize) { - _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, - "glCompressedTexImage2D(imageSize=%d)", imageSize); - return NULL; - } - return info; -} - -/** - * Convert a call to glCompressedTexImage2D() where internalFormat is a - * compressed palette format into a regular GLubyte/RGBA glTexImage2D() call. - */ -void -_mesa_cpal_compressed_teximage2d(GLenum target, GLint level, - GLenum internalFormat, - GLsizei width, GLsizei height, - GLsizei imageSize, const void *palette) -{ - const struct cpal_format_info *info; - GLint lvl, num_levels; - const GLubyte *indices; - GLint saved_align, align; - GET_CURRENT_CONTEXT(ctx); - - info = cpal_get_info(level, internalFormat, width, height, imageSize); - if (!info) - return; - - info = &formats[internalFormat - GL_PALETTE4_RGB8_OES]; - ASSERT(info->cpal_format == internalFormat); - num_levels = -level + 1; - - /* first image follows the palette */ - indices = (const GLubyte *) palette + info->palette_size * info->size; - - saved_align = ctx->Unpack.Alignment; - align = saved_align; - - for (lvl = 0; lvl < num_levels; lvl++) { - GLsizei w, h; - GLuint num_texels; - GLubyte *image = NULL; - - w = width >> lvl; - if (!w) - w = 1; - h = height >> lvl; - if (!h) - h = 1; - num_texels = w * h; - if (w * info->size % align) { - _mesa_PixelStorei(GL_UNPACK_ALIGNMENT, 1); - align = 1; - } - - /* allocate and fill dest image buffer */ - if (palette) { - image = (GLubyte *) malloc(num_texels * info->size); - paletted_to_color(info, palette, indices, num_texels, image); - } - - _mesa_TexImage2D(target, lvl, info->format, w, h, 0, - info->format, info->type, image); - if (image) - free(image); - - /* advance index pointer to point to next src mipmap */ - if (info->palette_size == 16) - indices += (num_texels + 1) / 2; - else - indices += num_texels; - } - - if (saved_align != align) - _mesa_PixelStorei(GL_UNPACK_ALIGNMENT, saved_align); -} - -#endif +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + **************************************************************************/ + + +/** + * Code to convert compressed/paletted texture images to ordinary images. + * See the GL_OES_compressed_paletted_texture spec at + * http://khronos.org/registry/gles/extensions/OES/OES_compressed_paletted_texture.txt + * + * XXX this makes it impossible to add hardware support... + */ + + +#include "glheader.h" +#include "compiler.h" /* for ASSERT */ +#include "context.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "imports.h" +#include "pixelstore.h" +#include "teximage.h" +#include "texpal.h" + +#if FEATURE_ES + + +static const struct cpal_format_info { + GLenum cpal_format; + GLenum format; + GLenum type; + GLuint palette_size; + GLuint size; +} formats[] = { + { GL_PALETTE4_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE, 16, 3 }, + { GL_PALETTE4_RGBA8_OES, GL_RGBA, GL_UNSIGNED_BYTE, 16, 4 }, + { GL_PALETTE4_R5_G6_B5_OES, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, 2 }, + { GL_PALETTE4_RGBA4_OES, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, 2 }, + { GL_PALETTE4_RGB5_A1_OES, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, 2 }, + { GL_PALETTE8_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE, 256, 3 }, + { GL_PALETTE8_RGBA8_OES, GL_RGBA, GL_UNSIGNED_BYTE, 256, 4 }, + { GL_PALETTE8_R5_G6_B5_OES, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 256, 2 }, + { GL_PALETTE8_RGBA4_OES, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 256, 2 }, + { GL_PALETTE8_RGB5_A1_OES, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 256, 2 } +}; + + +/** + * Get a color/entry from the palette. + */ +static GLuint +get_palette_entry(const struct cpal_format_info *info, const GLubyte *palette, + GLuint index, GLubyte *pixel) +{ + memcpy(pixel, palette + info->size * index, info->size); + return info->size; +} + + +/** + * Convert paletted texture to color texture. + */ +static void +paletted_to_color(const struct cpal_format_info *info, const GLubyte *palette, + const void *indices, GLuint num_pixels, GLubyte *image) +{ + GLubyte *pix = image; + GLuint remain, i; + + if (info->palette_size == 16) { + /* 4 bits per index */ + const GLubyte *ind = (const GLubyte *) indices; + + /* two pixels per iteration */ + remain = num_pixels % 2; + for (i = 0; i < num_pixels / 2; i++) { + pix += get_palette_entry(info, palette, (ind[i] >> 4) & 0xf, pix); + pix += get_palette_entry(info, palette, ind[i] & 0xf, pix); + } + if (remain) { + get_palette_entry(info, palette, (ind[i] >> 4) & 0xf, pix); + } + } + else { + /* 8 bits per index */ + const GLubyte *ind = (const GLubyte *) indices; + for (i = 0; i < num_pixels; i++) + pix += get_palette_entry(info, palette, ind[i], pix); + } +} + + +static const struct cpal_format_info * +cpal_get_info(GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei imageSize) +{ + const struct cpal_format_info *info; + GLint lvl, num_levels; + GLsizei w, h, expect_size; + + info = &formats[internalFormat - GL_PALETTE4_RGB8_OES]; + ASSERT(info->cpal_format == internalFormat); + + if (level > 0) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, + "glCompressedTexImage2D(level=%d)", level); + return NULL; + } + + num_levels = -level + 1; + expect_size = info->palette_size * info->size; + for (lvl = 0; lvl < num_levels; lvl++) { + w = width >> lvl; + if (!w) + w = 1; + h = height >> lvl; + if (!h) + h = 1; + + if (info->palette_size == 16) + expect_size += (w * h + 1) / 2; + else + expect_size += w * h; + } + if (expect_size > imageSize) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, + "glCompressedTexImage2D(imageSize=%d)", imageSize); + return NULL; + } + return info; +} + +/** + * Convert a call to glCompressedTexImage2D() where internalFormat is a + * compressed palette format into a regular GLubyte/RGBA glTexImage2D() call. + */ +void +_mesa_cpal_compressed_teximage2d(GLenum target, GLint level, + GLenum internalFormat, + GLsizei width, GLsizei height, + GLsizei imageSize, const void *palette) +{ + const struct cpal_format_info *info; + GLint lvl, num_levels; + const GLubyte *indices; + GLint saved_align, align; + GET_CURRENT_CONTEXT(ctx); + + info = cpal_get_info(level, internalFormat, width, height, imageSize); + if (!info) + return; + + info = &formats[internalFormat - GL_PALETTE4_RGB8_OES]; + ASSERT(info->cpal_format == internalFormat); + num_levels = -level + 1; + + /* first image follows the palette */ + indices = (const GLubyte *) palette + info->palette_size * info->size; + + saved_align = ctx->Unpack.Alignment; + align = saved_align; + + for (lvl = 0; lvl < num_levels; lvl++) { + GLsizei w, h; + GLuint num_texels; + GLubyte *image = NULL; + + w = width >> lvl; + if (!w) + w = 1; + h = height >> lvl; + if (!h) + h = 1; + num_texels = w * h; + if (w * info->size % align) { + _mesa_PixelStorei(GL_UNPACK_ALIGNMENT, 1); + align = 1; + } + + /* allocate and fill dest image buffer */ + if (palette) { + image = (GLubyte *) malloc(num_texels * info->size); + paletted_to_color(info, palette, indices, num_texels, image); + } + + _mesa_TexImage2D(target, lvl, info->format, w, h, 0, + info->format, info->type, image); + if (image) + free(image); + + /* advance index pointer to point to next src mipmap */ + if (info->palette_size == 16) + indices += (num_texels + 1) / 2; + else + indices += num_texels; + } + + if (saved_align != align) + _mesa_PixelStorei(GL_UNPACK_ALIGNMENT, saved_align); +} + +#endif diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c index 996218b16..1d567e430 100644 --- a/mesalib/src/mesa/main/texparam.c +++ b/mesalib/src/mesa/main/texparam.c @@ -35,6 +35,8 @@ #include "main/context.h" #include "main/formats.h" #include "main/macros.h" +#include "main/mfeatures.h" +#include "main/mtypes.h" #include "main/texcompress.h" #include "main/texparam.h" #include "main/teximage.h" diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index 8759c33ae..1947d32e6 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -58,6 +58,8 @@ #include "image.h" #include "macros.h" #include "mipmap.h" +#include "mfeatures.h" +#include "mtypes.h" #include "pack.h" #include "imports.h" #include "pack.h" @@ -2063,13 +2065,14 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS) } else { /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + const GLfloat *tempImage = make_temp_float_image(ctx, dims, baseInternalFormat, baseFormat, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; GLint img, row, col; if (!tempImage) return GL_FALSE; @@ -2080,24 +2083,29 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS) + dstXoffset * texelBytes; if (baseInternalFormat == GL_RGBA) { for (row = 0; row < srcHeight; row++) { - GLuint *dstUS = (GLuint *) dstRow; + GLuint *dstUI = (GLuint *) dstRow; for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_2101010( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); + GLushort a,r,g,b; + + UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]); + UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]); + dstUI[col] = PACK_COLOR_2101010_US(a, r, g, b); src += 4; } dstRow += dstRowStride; } } else if (baseInternalFormat == GL_RGB) { for (row = 0; row < srcHeight; row++) { - GLuint *dstUS = (GLuint *) dstRow; + GLuint *dstUI = (GLuint *) dstRow; for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_2101010( 0xff, - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); + GLushort r,g,b; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]); + dstUI[col] = PACK_COLOR_2101010_US(0xffff, r, g, b); src += 4; } dstRow += dstRowStride; diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c index 6368f9325..2ff262fc6 100644 --- a/mesalib/src/mesa/main/transformfeedback.c +++ b/mesalib/src/mesa/main/transformfeedback.c @@ -34,6 +34,8 @@ #include "bufferobj.h" #include "context.h" #include "hash.h" +#include "mfeatures.h" +#include "mtypes.h" #include "transformfeedback.h" #include "shaderapi.h" #include "shaderobj.h" diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c index a6fdabea7..e55f2f1c0 100644 --- a/mesalib/src/mesa/main/uniforms.c +++ b/mesalib/src/mesa/main/uniforms.c @@ -39,6 +39,8 @@ #include "main/glheader.h" #include "main/context.h" #include "main/dispatch.h" +#include "main/mfeatures.h" +#include "main/mtypes.h" #include "main/shaderapi.h" #include "main/shaderobj.h" #include "main/uniforms.h" @@ -511,7 +513,7 @@ get_uniform_rows_cols(const struct gl_program_parameter *p, *cols = p->Size; } else { - *rows = p->Size / 4 + 1; + *rows = (p->Size + 3) / 4; if (p->Size % 4 == 0) *cols = 4; else diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c index 92367a842..2d4a6b54b 100644 --- a/mesalib/src/mesa/main/varray.c +++ b/mesalib/src/mesa/main/varray.c @@ -33,6 +33,7 @@ #include "hash.h" #include "image.h" #include "macros.h" +#include "mfeatures.h" #include "mtypes.h" #include "varray.h" #include "arrayobj.h" diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c index 99dc8b350..f18fa5fcc 100644 --- a/mesalib/src/mesa/main/version.c +++ b/mesalib/src/mesa/main/version.c @@ -22,7 +22,8 @@ */ -#include "context.h" +#include "imports.h" +#include "mtypes.h" #include "version.h" diff --git a/mesalib/src/mesa/main/version.h b/mesalib/src/mesa/main/version.h index 0dff499ef..ffe21fea5 100644 --- a/mesalib/src/mesa/main/version.h +++ b/mesalib/src/mesa/main/version.h @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.10 + * Version: 7.11 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. All Rights Reserved. @@ -33,9 +33,9 @@ struct gl_context; /* Mesa version */ #define MESA_MAJOR 7 -#define MESA_MINOR 10 +#define MESA_MINOR 11 #define MESA_PATCH 0 -#define MESA_VERSION_STRING "7.10-devel" +#define MESA_VERSION_STRING "7.11-devel" /* To make version comparison easy */ #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) diff --git a/mesalib/src/mesa/main/viewport.c b/mesalib/src/mesa/main/viewport.c index 1b4e6c339..3c3b120e4 100644 --- a/mesalib/src/mesa/main/viewport.c +++ b/mesalib/src/mesa/main/viewport.c @@ -31,6 +31,7 @@ #include "context.h" #include "macros.h" +#include "mtypes.h" #include "viewport.h" diff --git a/mesalib/src/mesa/main/vtxfmt.c b/mesalib/src/mesa/main/vtxfmt.c index 6fec7f09b..f5e10661c 100644 --- a/mesalib/src/mesa/main/vtxfmt.c +++ b/mesalib/src/mesa/main/vtxfmt.c @@ -30,6 +30,7 @@ #include "api_arrayelt.h" #include "context.h" #include "imports.h" +#include "mfeatures.h" #include "mtypes.h" #include "vtxfmt.h" #include "eval.h" diff --git a/mesalib/src/mesa/main/vtxfmt.h b/mesalib/src/mesa/main/vtxfmt.h index 235198747..d403669c2 100644 --- a/mesalib/src/mesa/main/vtxfmt.h +++ b/mesalib/src/mesa/main/vtxfmt.h @@ -34,6 +34,7 @@ #define _VTXFMT_H_ #include "compiler.h" +#include "mfeatures.h" #include "mtypes.h" #if FEATURE_beginend diff --git a/mesalib/src/mesa/state_tracker/st_atom.c b/mesalib/src/mesa/state_tracker/st_atom.c index ff1f61afe..34dff79e7 100644 --- a/mesalib/src/mesa/state_tracker/st_atom.c +++ b/mesalib/src/mesa/state_tracker/st_atom.c @@ -147,7 +147,11 @@ void st_validate_state( struct st_context *st ) /*printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st);*/ +#ifdef NDEBUG + if (0) { +#else if (1) { +#endif /* Debug version which enforces various sanity checks on the * state flags which are generated and checked to help ensure * state atoms are ordered correctly in the list. diff --git a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c index 5672215f7..87a479a22 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c +++ b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c @@ -56,7 +56,6 @@ void st_upload_constants( struct st_context *st, unsigned shader_type) { struct pipe_context *pipe = st->pipe; - struct pipe_resource **cbuf = &st->state.constants[shader_type]; assert(shader_type == PIPE_SHADER_VERTEX || shader_type == PIPE_SHADER_FRAGMENT || @@ -64,6 +63,7 @@ void st_upload_constants( struct st_context *st, /* update constants */ if (params && params->NumParameters) { + struct pipe_resource *cbuf; const uint paramBytes = params->NumParameters * sizeof(GLfloat) * 4; /* Update the constants which come from fixed-function state, such as @@ -75,11 +75,12 @@ void st_upload_constants( struct st_context *st, /* We always need to get a new buffer, to keep the drivers simple and * avoid gratuitous rendering synchronization. + * Let's use a user buffer to avoid an unnecessary copy. */ - pipe_resource_reference(cbuf, NULL ); - *cbuf = pipe_buffer_create(pipe->screen, - PIPE_BIND_CONSTANT_BUFFER, - paramBytes ); + cbuf = pipe_user_buffer_create(pipe->screen, + params->ParameterValues, + paramBytes, + PIPE_BIND_CONSTANT_BUFFER); if (ST_DEBUG & DEBUG_CONSTANTS) { debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n", @@ -88,17 +89,15 @@ void st_upload_constants( struct st_context *st, _mesa_print_parameter_list(params); } - /* load Mesa constants into the constant buffer */ - pipe_buffer_write(st->pipe, *cbuf, - 0, paramBytes, - params->ParameterValues); + st->pipe->set_constant_buffer(st->pipe, shader_type, 0, cbuf); + pipe_resource_reference(&cbuf, NULL); - st->pipe->set_constant_buffer(st->pipe, shader_type, 0, *cbuf); + st->state.constants[shader_type].ptr = params->ParameterValues; + st->state.constants[shader_type].size = paramBytes; } - else if (*cbuf) { - st->constants.tracked_state[shader_type].dirty.mesa = 0x0; - - pipe_resource_reference(cbuf, NULL); + else if (st->state.constants[shader_type].ptr) { + st->state.constants[shader_type].ptr = NULL; + st->state.constants[shader_type].size = 0; st->pipe->set_constant_buffer(st->pipe, shader_type, 0, NULL); } } diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c index 7dd63798d..3e27be271 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_clear.c +++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c @@ -470,13 +470,9 @@ st_Clear(struct gl_context *ctx, GLbitfield mask) if (mask & (1 << b)) { struct gl_renderbuffer *rb = ctx->DrawBuffer->Attachment[b].Renderbuffer; - struct st_renderbuffer *strb; + struct st_renderbuffer *strb = st_renderbuffer(rb); - assert(rb); - - strb = st_renderbuffer(rb); - - if (!strb->surface) + if (!strb || !strb->surface) continue; if (check_clear_color_with_quad( ctx, rb )) diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index 8a63192d7..c348dd343 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -34,6 +34,7 @@ #include "main/image.h" #include "main/bufferobj.h" #include "main/macros.h" +#include "main/mtypes.h" #include "main/pack.h" #include "main/texformat.h" #include "main/texstore.h" diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c index 4bc01100a..d6df2a204 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c @@ -61,7 +61,8 @@ * during window resize. */ static GLboolean -st_renderbuffer_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *rb, +st_renderbuffer_alloc_storage(struct gl_context * ctx, + struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { @@ -75,7 +76,8 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *r if (strb->format != PIPE_FORMAT_NONE) format = strb->format; else - format = st_choose_renderbuffer_format(screen, internalFormat, rb->NumSamples); + format = st_choose_renderbuffer_format(screen, internalFormat, + rb->NumSamples); /* init renderbuffer fields */ strb->Base.Width = width; diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index 4656930ac..593da8fa6 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -207,12 +207,6 @@ static void st_destroy_context_priv( struct st_context *st ) pipe_sampler_view_reference(&st->state.sampler_views[i], NULL); } - for (i = 0; i < Elements(st->state.constants); i++) { - if (st->state.constants[i]) { - pipe_resource_reference(&st->state.constants[i], NULL); - } - } - if (st->default_texture) { st->ctx->Driver.DeleteTexture(st->ctx, st->default_texture); st->default_texture = NULL; @@ -245,7 +239,6 @@ void st_destroy_context( struct st_context *st ) for (i = 0; i < PIPE_SHADER_TYPES; i++) { pipe->set_constant_buffer(pipe, i, 0, NULL); - pipe_resource_reference(&st->state.constants[i], NULL); } _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache); diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h index 348a5827d..492ee600e 100644 --- a/mesalib/src/mesa/state_tracker/st_context.h +++ b/mesalib/src/mesa/state_tracker/st_context.h @@ -92,7 +92,10 @@ struct st_context struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS]; struct pipe_sampler_state *sampler_list[PIPE_MAX_SAMPLERS]; struct pipe_clip_state clip; - struct pipe_resource *constants[PIPE_SHADER_TYPES]; + struct { + void *ptr; + unsigned size; + } constants[PIPE_SHADER_TYPES]; struct pipe_framebuffer_state framebuffer; struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; struct pipe_scissor_state scissor; @@ -105,15 +108,6 @@ struct st_context GLuint poly_stipple[32]; /**< In OpenGL's bottom-to-top order */ } state; - struct { - struct st_tracked_state tracked_state[PIPE_SHADER_TYPES]; - } constants; - - /* XXX unused: */ - struct { - struct gl_fragment_program *fragment_program; - } cb; - char vendor[100]; char renderer[100]; diff --git a/mesalib/src/mesa/state_tracker/st_draw_feedback.c b/mesalib/src/mesa/state_tracker/st_draw_feedback.c index b05e660ae..957912221 100644 --- a/mesalib/src/mesa/state_tracker/st_draw_feedback.c +++ b/mesalib/src/mesa/state_tracker/st_draw_feedback.c @@ -109,9 +109,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, struct pipe_index_buffer ibuffer; struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS]; struct pipe_transfer *ib_transfer = NULL; - struct pipe_transfer *cb_transfer; GLuint attr, i; - ubyte *mapped_constants; const void *mapped_indices = NULL; assert(draw); @@ -242,14 +240,10 @@ st_feedback_draw_vbo(struct gl_context *ctx, draw_set_mapped_index_buffer(draw, mapped_indices); } - /* map constant buffers */ - mapped_constants = pipe_buffer_map(pipe, - st->state.constants[PIPE_SHADER_VERTEX], - PIPE_TRANSFER_READ, - &cb_transfer); + /* set the constant buffer */ draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX, 0, - mapped_constants, - st->state.constants[PIPE_SHADER_VERTEX]->width0); + st->state.constants[PIPE_SHADER_VERTEX].ptr, + st->state.constants[PIPE_SHADER_VERTEX].size); /* draw here */ @@ -258,9 +252,6 @@ st_feedback_draw_vbo(struct gl_context *ctx, } - /* unmap constant buffers */ - pipe_buffer_unmap(pipe, cb_transfer); - /* * unmap vertex/index buffers */ diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index c80811a07..574730120 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -224,6 +224,7 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; ctx->Extensions.ARB_fragment_program = GL_TRUE; + ctx->Extensions.ARB_half_float_pixel = GL_TRUE; ctx->Extensions.ARB_map_buffer_range = GL_TRUE; ctx->Extensions.ARB_multisample = GL_TRUE; ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */ diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c index 74d402daa..7952bb6ff 100644 --- a/mesalib/src/mesa/state_tracker/st_manager.c +++ b/mesalib/src/mesa/state_tracker/st_manager.c @@ -513,7 +513,8 @@ st_context_flush(struct st_context_iface *stctxi, unsigned flags, } static boolean -st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target, +st_context_teximage(struct st_context_iface *stctxi, + enum st_texture_type target, int level, enum pipe_format internal_format, struct pipe_resource *tex, boolean mipmap) { @@ -865,7 +866,8 @@ st_manager_validate_framebuffers(struct st_context *st) * Add a color renderbuffer on demand. */ boolean -st_manager_add_color_renderbuffer(struct st_context *st, struct gl_framebuffer *fb, +st_manager_add_color_renderbuffer(struct st_context *st, + struct gl_framebuffer *fb, gl_buffer_index idx) { struct st_framebuffer *stfb = st_ws_framebuffer(fb); diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c index 59165be04..50beaa766 100644 --- a/mesalib/src/mesa/state_tracker/st_program.c +++ b/mesalib/src/mesa/state_tracker/st_program.c @@ -409,6 +409,7 @@ st_translate_fragment_program(struct st_context *st, assert(!(key->bitmap && key->drawpixels)); +#if FEATURE_drawpix if (key->bitmap) { /* glBitmap drawing */ struct gl_fragment_program *fp; @@ -434,6 +435,7 @@ st_translate_fragment_program(struct st_context *st, } stfp = st_fragment_program(fp); } +#endif if (!stfp->tgsi.tokens) { /* need to translate Mesa instructions to TGSI now */ diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c index f39bd8a38..503f5b732 100644 --- a/mesalib/src/mesa/swrast/s_texfilter.c +++ b/mesalib/src/mesa/swrast/s_texfilter.c @@ -27,7 +27,6 @@ #include "main/context.h" #include "main/colormac.h" #include "main/imports.h" -#include "main/texformat.h" #include "s_context.h" #include "s_texfilter.h" diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c index 93826b7ce..10a1dc1c1 100644 --- a/mesalib/src/mesa/swrast/s_triangle.c +++ b/mesalib/src/mesa/swrast/s_triangle.c @@ -34,7 +34,7 @@ #include "main/colormac.h" #include "main/imports.h" #include "main/macros.h" -#include "main/texformat.h" +#include "main/mtypes.h" #include "program/prog_instruction.h" #include "s_aatriangle.h" diff --git a/mesalib/src/mesa/vbo/vbo_context.c b/mesalib/src/mesa/vbo/vbo_context.c index 67a6091ba..bbf422f74 100644 --- a/mesalib/src/mesa/vbo/vbo_context.c +++ b/mesalib/src/mesa/vbo/vbo_context.c @@ -209,7 +209,6 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx ) void _vbo_InvalidateState( struct gl_context *ctx, GLuint new_state ) { - _ae_invalidate_state(ctx, new_state); vbo_exec_invalidate_state(ctx, new_state); } diff --git a/pixman/pixman/pixman-sse2.c b/pixman/pixman/pixman-sse2.c index 9d9b16543..b19043bbd 100644 --- a/pixman/pixman/pixman-sse2.c +++ b/pixman/pixman/pixman-sse2.c @@ -3051,37 +3051,45 @@ sse2_composite_over_8888_n_8888 (pixman_implementation_t *imp, while (w && (unsigned long)dst & 15) { uint32_t s = *src++; - uint32_t d = *dst; - - __m64 ms = unpack_32_1x64 (s); - __m64 alpha = expand_alpha_1x64 (ms); - __m64 dest = _mm_movepi64_pi64 (xmm_mask); - __m64 alpha_dst = unpack_32_1x64 (d); - - *dst++ = pack_1x64_32 ( - in_over_1x64 (&ms, &alpha, &dest, &alpha_dst)); + if (s) + { + uint32_t d = *dst; + + __m64 ms = unpack_32_1x64 (s); + __m64 alpha = expand_alpha_1x64 (ms); + __m64 dest = _mm_movepi64_pi64 (xmm_mask); + __m64 alpha_dst = unpack_32_1x64 (d); + + *dst = pack_1x64_32 ( + in_over_1x64 (&ms, &alpha, &dest, &alpha_dst)); + } + dst++; w--; } while (w >= 4) { xmm_src = load_128_unaligned ((__m128i*)src); - xmm_dst = load_128_aligned ((__m128i*)dst); - - unpack_128_2x128 (xmm_src, &xmm_src_lo, &xmm_src_hi); - unpack_128_2x128 (xmm_dst, &xmm_dst_lo, &xmm_dst_hi); - expand_alpha_2x128 (xmm_src_lo, xmm_src_hi, - &xmm_alpha_lo, &xmm_alpha_hi); - - in_over_2x128 (&xmm_src_lo, &xmm_src_hi, - &xmm_alpha_lo, &xmm_alpha_hi, - &xmm_mask, &xmm_mask, - &xmm_dst_lo, &xmm_dst_hi); - - save_128_aligned ( - (__m128i*)dst, pack_2x128_128 (xmm_dst_lo, xmm_dst_hi)); + if (!is_zero (xmm_src)) + { + xmm_dst = load_128_aligned ((__m128i*)dst); + + unpack_128_2x128 (xmm_src, &xmm_src_lo, &xmm_src_hi); + unpack_128_2x128 (xmm_dst, &xmm_dst_lo, &xmm_dst_hi); + expand_alpha_2x128 (xmm_src_lo, xmm_src_hi, + &xmm_alpha_lo, &xmm_alpha_hi); + + in_over_2x128 (&xmm_src_lo, &xmm_src_hi, + &xmm_alpha_lo, &xmm_alpha_hi, + &xmm_mask, &xmm_mask, + &xmm_dst_lo, &xmm_dst_hi); + + save_128_aligned ( + (__m128i*)dst, pack_2x128_128 (xmm_dst_lo, xmm_dst_hi)); + } + dst += 4; src += 4; w -= 4; @@ -3090,16 +3098,21 @@ sse2_composite_over_8888_n_8888 (pixman_implementation_t *imp, while (w) { uint32_t s = *src++; - uint32_t d = *dst; - __m64 ms = unpack_32_1x64 (s); - __m64 alpha = expand_alpha_1x64 (ms); - __m64 mask = _mm_movepi64_pi64 (xmm_mask); - __m64 dest = unpack_32_1x64 (d); - - *dst++ = pack_1x64_32 ( - in_over_1x64 (&ms, &alpha, &mask, &dest)); + if (s) + { + uint32_t d = *dst; + + __m64 ms = unpack_32_1x64 (s); + __m64 alpha = expand_alpha_1x64 (ms); + __m64 mask = _mm_movepi64_pi64 (xmm_mask); + __m64 dest = unpack_32_1x64 (d); + + *dst = pack_1x64_32 ( + in_over_1x64 (&ms, &alpha, &mask, &dest)); + } + dst++; w--; } } diff --git a/xkbcomp/Makefile.am b/xkbcomp/Makefile.am index 3ef361dbd..707433742 100644 --- a/xkbcomp/Makefile.am +++ b/xkbcomp/Makefile.am @@ -65,15 +65,11 @@ BUILT_SOURCES = xkbparse.c MAINTAINERCLEANFILES = ChangeLog INSTALL MAINTAINERCLEANFILES += $(BUILT_SOURCES) -EXTRA_DIST = \ - README.config \ - README.enhancing - appmandir = $(APP_MAN_DIR) appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) -EXTRA_DIST += $(appman_PRE) +EXTRA_DIST = $(appman_PRE) CLEANFILES = $(appman_DATA) SUFFIXES = .$(APP_MAN_SUFFIX) .man diff --git a/xkbcomp/README b/xkbcomp/README index 89dc3e638..0958525c6 100644 --- a/xkbcomp/README +++ b/xkbcomp/README @@ -1,24 +1,20 @@ -X Keyboard Extension --------------------- - -The X Keyboard Extension essentially replaces the core protocol definition of -keyboard. The extension makes possible to clearly and explicitly specify most -aspects of keyboard behaviour on per-key basis and to more closely track the -logical and physical state of the keyboard. It also includes a number of -keyboard controls designed to make keyboards more accessible to people with -physical impairments. - -There are five types of components in the server database corresponing to five -xkb symbolic names: symbols, geometry, keycodes, compat and types which -determine the keyboard behaviour. These five components can combined together -into a resulting keyboard mapping using the 'rules' component. - -The complete specification can be found on -http://www.x-docs.org/XKB/XKBproto.pdf - -For XKB configuration information see 'README.config' file. - -For information how to further enhance XKB configuration see 'README.enhancing' -file. - - +X Keyboard Extension +-------------------- + +The X Keyboard Extension essentially replaces the core protocol definition of +keyboard. The extension makes possible to clearly and explicitly specify most +aspects of keyboard behaviour on per-key basis and to more closely track the +logical and physical state of the keyboard. It also includes a number of +keyboard controls designed to make keyboards more accessible to people with +physical impairments. + +There are five types of components in the server database corresponing to five +xkb symbolic names: symbols, geometry, keycodes, compat and types which +determine the keyboard behaviour. These five components can combined together +into a resulting keyboard mapping using the 'rules' component. + +More information, including the complete specification, can be found on +http://www.x.org/wiki/XKB + + + diff --git a/xkbcomp/README.config b/xkbcomp/README.config deleted file mode 100644 index 2cce52157..000000000 --- a/xkbcomp/README.config +++ /dev/null @@ -1,195 +0,0 @@ - The XKB Configuration Guide - - Kamil Toman, Ivan U. Pascal - - 25 November 2002 - - Abstract - - This document describes how to configure X11R6.8 XKB from a user's - point a few. It converts basic configuration syntax and gives also - a few examples. - -1. Overview - -The XKB configuration is decomposed into a number of components. Selecting -proper parts and combining them back you can achieve most of configurations -you might need. Unless you have a completely atypical keyboard you really -don't need to touch any of xkb configuration files. - -2. Selecting XKB Configuration - -The easiest and the most natural way how to specify a keyboard mapping is to -use rules component. As its name suggests it describes a number of general -rules how to combine all bits and pieces into a valid and useful keyboard -mapping. All you need to do is to select a suitable rules file and then to -feed it with a few parameters that will adjust the keyboard behaviour to ful- -fill your needs. - -The parameters are: - - o XkbRules - files of rules to be used for keyboard mapping composition - - o XkbModel - name of model of your keyboard type - - o XkbLayout - layout(s) you intend to use - - o XkbVariant - variant(s) of layout you intend to use - - o XkbOptions - extra xkb configuration options - -The proper rules file depends on your vendor. In reality, the commonest file -of rules is xorg. For each rules file there is a description file named .lst, for instance xorg.lst which is located in xkb configuration -subdirectory rules (for example /etc/X11/xkb/rules). - -2.1 Basic Configuration - -Let's say you want to configure a PC style America keyboard with 104 keys as -described in xorg.lst. It can be done by simply writing several lines from -below to you xorg.conf configuration file (previously known as -/etc/X11/XF86Config-4 or /etc/X11/XF86Config): - - Section "InputDevice" - Identifier "Keyboard1" - Driver "kbd" - - Option "XkbModel" "pc104" - Option "XkbLayout" "us" - Option "XKbOptions" "" - EndSection - -The values of parameters XkbModel and XkbLayout are really not surprising. -The parameters XkbOptions has been explicitly set to empty set of parameters. -The parameter XkbVariant has been left out. That means the default variant -named basic is loaded. - -Of course, this can be also done at runtime using utility setxkbmap. Shell -command loading the same keyboard mapping would look like: - - setxkbmap -rules xorg -model pc104 -layout us -option "" - -The configuration and the shell command would be very analogical for most -other layouts (internationalized mappings). - -2.2 Advanced Configuration - -You can use multi-layouts xkb configuration. What does it mean? Basically it -allows to load up to four different keyboard layouts at a time. Each such -layout would reside in its own group. The groups (unlike complete keyboard -remapping) can be switched very fast from one to another by a combination of -keys. - -Let's say you want to configure your new Logitech cordless desktop keyboard, -you intend to use three different layouts at the same time - us, czech and -german (in this order), and that you are used to Alt-Shift combination for -switching among them. - -Then the configuration snippet could look like this: - - Section "InputDevice" - Identifier "Keyboard1" - Driver "kbd" - - Option "XkbModel" "logicordless" - Option "XkbLayout" "us,cz,de" - Option "XKbOptions" "grp:alt_shift_toggle" - EndSection - -Of course, this can be also done at runtime using utility setxkbmap. Shell -command loading the same keyboard mapping would look like: - - setxkbmap -rules xorg -model logicordless -layout "us,cz,de" \ - -option "grp:alt_shift_toggle" - -2.3 Even More Advanced Configuration - -Okay, let's say you are more demanding. You do like the example above but you -want it to change a bit. Let's imagine you want the czech keyboard mapping to -use another variant but basic. The configuration snippet then changes into: - - Section "InputDevice" - Identifier "Keyboard1" - Driver "kbd" - - Option "XkbModel" "logicordless" - Option "XkbLayout" "us,cz,de" - Option "XkbVariant" ",bksl," - Option "XKbOptions" "grp:alt_shift_toggle" - EndSection - -That's seems tricky but it is not. The logic for settings of variants is the -same as for layouts, that means the first and the third variant settings are -left out (set to basic), the second is set to bksl (a special variant with an -enhanced definition of the backslash key). - -Analogically, the loading runtime will change to: - - setxkmap -rules xorg -model logicordless -layout "us,cz,de" \ - -variant ",bksl," -option "grp:alt_shift_toggle" - -2.4 Basic Global Options - -See rules/*.lst files. - -3. Direct XKB Configuration - -Generally, you can directly prescribe what configuration of each of basic xkb -components should be used to form the resulting keyboard mapping. This -method is rather "brute force". You precisely need to know the structure and -the meaning of all of used configuration components. - -This method also exposes all xkb configuration details directly into -xorg.conf configuration file which is a not very fortunate fact. In rare -occasions it may be needed, though. So how does it work? - -3.1 Basic Components - -There are five basic components used to form a keyboard mapping: - - o key codes - a translation of the scan codes produced by the keyboard - into a suitable symbolic form - - o types - a specification of what various combinations of modifiers pro- - duce - - o key symbols - a translation of symbolic key codes into actual symbols - - o geometry - a description of physical keyboard geometry - - o compatibility maps - a specification of what action should each key pro- - duce in order to preserve compatibility with XKB-unware clients - -3.2 Example Configuration - -Look at the following example: - - Section "InputDevice" - Identifier "Keyboard0" - Driver "kbd" - - Option "XkbKeycodes" "xorg" - Option "XkbTypes" "default" - Option "XkbSymbols" "en_US(pc104)+de+swapcaps" - Option "XkbGeometry" "pc(pc104)" - Option "XkbCompat" "basic+pc+iso9995" - EndSection - -This configuration sets the standard X server default interpretation of key- -board keycodes, sets the default modificator types. The symbol table is com- -posed of extended US keyboard layout in its variant for pc keyboards with 104 -keys plus all keys for german layout are redefined respectively. Also the -logical meaning of Caps-lock and Control keys is swapped. The standard key- -board geometry (physical look) is set to pc style keyboard with 104 keys. The -compatibility map is set to allow basic shifting, to allow Alt keys to be -interpreted and also to allow iso9995 group shifting. - -4. Keymap XKB Configuration - -It is the formerly used way to configure xkb. The user included a special -keymap file which specified the direct xkb configuration. This method has -been obsoleted by previously described rules files which are far more flexi- -ble and allow simpler and more intuitive syntax. It is preserved merely for -compatibility reasons. Avoid using it if it is possible. - - diff --git a/xkbcomp/README.enhancing b/xkbcomp/README.enhancing deleted file mode 100644 index 746902c52..000000000 --- a/xkbcomp/README.enhancing +++ /dev/null @@ -1,508 +0,0 @@ - How to further enhance XKB configuration - - Kamil Toman, Ivan U. Pascal - - 25 November 2002 - - Abstract - - This guide is aimed to relieve one's labour to create a new (inter- - nationalized) keyboard layout. Unlike other documents this guide - accents the keymap developer's point of view. - -1. Overview - -The developer of a new layout should read the xkb protocol specification (The -X Keyboard Extension: Protocol Specification ) at least to clarify for himself some xkb-specific -terms used in this document and elsewhere in xkb configuration. Also it shows -wise to understand how the X server and a client digest their keyboard inputs -(with and without xkb). - -A useful source is also Ivan Pascal's text about xkb configuration - often referenced throughout this docu- -ment. - -Note that this document covers only enhancements which are to be made to -XFree86 version 4.3 and X11R6.7.0 and above. - -2. The Basics - -At the startup (or at later at user's command) X server starts its xkb key- -board module extension and reads data from a compiled configuration file. - -This compiled configuration file is prepared by the program xkbcomp which -behaves altogether as an ordinary compiler (see man xkbcomp). Its input are -human readable xkb configuration files which are verified and then composed -into a useful xkb configuration. Users don't need to mess with xkbcomp them- -selves, for them it is invisible. Usually, it is started upon X server -startup. - -As you probably already know, the xkb configuration consists of five main -modules: - - Keycodes - Tables that defines translation from keyboard scan codes into - reasonable symbolic names, maximum, minimum legal keycodes, sym- - bolic aliases and description of physically present LED-indica- - tors. The primary sence of this component is to allow definitions - of maps of symbols (see below) to be independent of physical key- - board scancodes. There are two main naming conventions for sym- - bolic names (always four bytes long): - - o names which express some traditional meaning like - (stands for space bar) or - - o names which express some relative positioning on a key- - board, for example (an exclamation mark on US key- - boards), on the right there are keys , etc. - - Types - Types describe how the produced key is changed by active modi- - fiers (like Shift, Control, Alt, ...). There are several prede- - fined types which cover most of used combinations. - - Compat - Compatibility component defines internal behaviour of modifiers. - Using compat component you can assign various actions (elabo- - rately described in xkb specification) to key events. This is - also the place where LED-indicators behaviour is defined. - - Symbols - For i18n purposes, this is the most important table. It defines - what values (=symbols) are assigned to what keycodes (represented - by their symbolic name, see above). There may be defined more - than one value for each key and then it depends on a key type and - on modifiers state (respective compat component) which value will - be the resulting one. - - Geometry - Geometry files aren't used by xkb itself but they may be used by - some external programs to depict a keyboard image. - -All these components have the files located in xkb configuration tree in sub- -directories with the same names (usually in /usr/lib/X11/xkb). - -3. Enhancing XKB Configuration - -Most of xkb enhancements concerns a need to define new output symbols for the -some input key events. In other words, a need to define a new symbol map (for -a new language, standard or just to feel more comfortable when typing text). - -What do you need to do? Generally, you have to define following things: - - o the map of symbols itself - - o the rules to allow users to select the new mapping - - o the description of the new layout - -First of all, it is good to go through existing layouts and to examine them -if there is something you could easily adjust to fit your needs. Even if -there is nothing similar you may get some ideas about basic concepts and used -tricks. - -3.1 Levels And Groups - -Since XFree86 4.3.0 and X11R6.7.0 you can use multi-layout concept of xkb -configuration. Though it is still in boundaries of xkb protocol and general -ideas, the keymap designer must obey new rules when creating new maps. In -exchange we get a more powerful and cleaner configuration system. - -Remember that it is the application which must decide which symbol matches -which keycode according to effective modifier state. The X server itself -sends only an input event message to. Of course, usually the general inter- -pretation is processed by Xlib, Xaw, Motif, Qt, Gtk and similar libraries. -The X server only supplies its mapping table (usually upon an application -startup). - -You can think of the X server's symbol table as of a irregular table where -each keycode has its row and where each combination of modifiers determines -exactly one column. The resulting cell then gives the proper symbolic value. -Not all keycodes need to bind different values for different combination of -modifiers. key, for instance, usually doesn't depend on any modi- -fiers so it its row has only one column defined. - -Note that in XKB there is no prior assumption that certain modifiers are -bound to certain columns. By editing proper files (see refnam (section 4.2, -page 1)) this mapping can be changed as well. - -Unlike the original X protocol the XKB approach is far more flexible. It is -comfortable to add one additional XKB term - group. You can think of a group -as of a vector of columns per each keycode (naturally the dimension of this -vector may differ for different keycodes). What is it good for? The group is -not very useful unless you intend to use more than one logically different -set of symbols (like more than one alphabet) defined in a single mapping -table. But then, the group has a natural meaning - each symbol set has its -own group and changing it means selecting a different one. XKB approach -allows up to four different groups. The columns inside each group are called -(shift) levels. The X server knows the current group and reports it together -with modifier set and with a keycode in key events. - -To sum it up: - - o for each keycode XKB keyboard map contains up to four one-dimensional - tables - groups (logically different symbol sets) - - o for each group of a keycode XKB keyboard map contains some columns - - shift levels (values reached by combinations of Shift, Ctrl, Alt, ... - modifiers) - - o different keycodes can have different number of groups - - o different groups of one keycode can have different number of shift lev- - els - - o the current group number is tracked by X server - -It is clear that if you sanely define levels, groups and sanely bind modi- -fiers and associated actions you can have simultaneously loaded up to four -different symbol sets where each of them would reside in its own group. - -The multi-layout concept provides a facility to manipulate xkb groups and -symbol definitions in a way that allows almost arbitrary composition of pre- -defined symbol tables. To keep it fully functional you have to: - - o define all symbols only in the first group - - o (re)define any modifiers with extra care to avoid strange (anisometric) - behaviour - -4. Defining New Layouts - -See Some Words About XKB internals for explanation of used xkb terms and problems -addressed by XKB extension. - -See Common notes about XKB configuration files language - for more precise -explanation of syntax of xkb configuration files. - -4.1 Predefined XKB Symbol Sets - -If you are about to define some European symbol map extension, you might want -to use on of four predefined latin alphabet layouts. - -Okay, let's assume you want extend an existing keymap and you want to over- -ride a few keys. Let's take a simple U.K. keyboard as an example (defined in -pc/gb): - - partial default alphanumeric_keys - xkb_symbols "basic" { - include "pc/latin" - - name[Group1]="Great Britain"; - - key { [ 2, quotedbl, twosuperior, oneeighth ] }; - key { [ 3, sterling, threesuperior, sterling ] }; - key { [apostrophe, at, dead_circumflex, dead_caron] }; - key { [ grave, notsign, bar, bar ] }; - key { [numbersign, asciitilde, dead_grave, dead_breve ] }; - key { type[Group1]="TWO_LEVEL", - [ ISO_Level3_Shift, Multi_key ] }; - - modifier_map Mod5 { }; - }; - -It defines a new layout in basic variant as an extension of common latin -alphabet layout. The layout (symbol set) name is set to "Great Britain". -Then there are redefinitions of a few keycodes and a modifiers binding. As -you can see the number of shift levels is the same for , , -, and keys but it differs from number of shift levels of -. - -Note that the key itself is a binding key for Mod5 and that it serves -like a shift modifier for LevelThree, together with Shift as a multi-key. It -is a good habit to respect this rule in a new similar layout. - -Okay, you could now define more variants of your new layout besides basic -simply by including (augmenting/overriding/...) the basic definition and -altering what may be needed. - -4.2 Key Types - -The differences in the number of columns (shift levels) are caused by a dif- -ferent types of keys (see the types definition in section basics). Most key- -codes have implicitly set the keytype in the included 'pc/latin' file to -'FOUR_LEVEL_ALPHABETIC'. The only exception is keycode which is -explicitly set 'TWO_LEVEL' keytype. - -All those names refer to pre-defined shift level schemes. Usually you can -choose a suitable shift level scheme from default types scheme list in proper -xkb component's subdirectory. - -The most used schemes are: - - ONE_LEVEL - The key does not depend on any modifiers. The symbol from first - level is always chosen. - - TWO_LEVEL - The key uses a modifier Shift and may have two possible values. - The second level may be chosen by Shift modifier. If Lock modi- - fier (usually Caps-lock) applies the symbol is further processed - using system-specific capitalization rules. If both Shift+Lock - modifier apply the symbol from the second level is taken and cap- - italization rules are applied (and usually have no effect). - - ALPHABETIC - The key uses modifiers Shift and Lock. It may have two possible - values. The second level may be chosen by Shift modifier. When - Lock modifier applies, the symbol from the first level is taken - and further processed using system-specific capitalization rules. - If both Shift+Lock modifier apply the symbol from the first level - is taken and no capitalization rules applied. This is often - called shift-cancels-caps behaviour. - - THREE_LEVEL - Is the same as TWO_LEVEL but it considers an extra modifier - - LevelThree which can be used to gain the symbol value from the - third level. If both Shift+LevelThree modifiers apply the value - from the third level is also taken. As in TWO_LEVEL, the Lock - modifier doesn't influence the resulting level. Only Shift and - LevelThree are taken into that consideration. If the Lock modi- - fier is active capitalization rules are applied on the resulting - symbol. - - FOUR_LEVEL - Is the same as THREE_LEVEL but unlike LEVEL_THREE if both - Shift+LevelThree modifiers apply the symbol is taken from the - fourth level. - - FOUR_LEVEL_ALPHABETIC - Is similar to FOUR_LEVEL but also defines shift-cancels-caps - behaviour as in ALPHABETIC. If Lock+LevelThree apply the symbol - from the third level is taken and the capitalization rules are - applied. If Lock+Shift+LevelThree apply the symbol from the - third level is taken and no capitalization rules are applied. - - KEYPAD - As the name suggest this scheme is primarily used for numeric - keypads. The scheme considers two modifiers - Shift and NumLock. - If none of modifiers applies the symbol from the first level is - taken. If either Shift or NumLock modifiers apply the symbol from - the second level is taken. If both Shift+NumLock modifiers apply - the symbol from the first level is taken. Again, shift-cancels- - caps variant. - - FOUR_LEVEL_KEYPAD - Is similar to KEYPAD scheme but considers also LevelThree modi- - fier. If LevelThree modifier applies the symbol from the third - level is taken. If Shift+LevelThree or NumLock+LevelThree apply - the symbol from the fourth level is taken. If all Shift+Num- - Lock+LevelThree modifiers apply the symbol from the third level - is taken. This also, shift-cancels-caps variant. - -Besides that, there are several schemes for special purposes: - - PC_BREAK - It is similar to TWO_LEVEL scheme but it considers the Control - modifier rather than Shift. That means, the symbol from the sec- - ond level is chosen by Control rather than by Shift. - - PC_SYSRQ - It is similar to TWO_LEVEL scheme but it considers the Alt modi- - fier rather than Shift. That means, the symbol from the second - level is chosen by Alt rather than by Shift. - - CTRL+ALT - The key uses modifiers Alt and Control. It may have two possible - values. If only one modifier (Alt or Control) applies the symbol - from the first level is chosen. Only if both Alt+Control modi- - fiers apply the symbol from the second level is chosen. - - SHIFT+ALT - The key uses modifiers Shift and Alt. It may have two possible - values. If only one modifier (Alt or Shift) applies the symbol - from the first level is chosen. Only if both Alt+Shift modifiers - apply the symbol from the second level is chosen. - -If needed, special caps schemes may be used. They redefine the standard -behaviour of all *ALPHABETIC types. The layouts (maps of symbols) with keys -defined in respective types then automatically change their behaviour accord- -ingly. Possible redefinitions are: - - o internal - - o internal_nocancel - - o shift - - o shift_nocancel - -None of these schemes should be used directly. They are defined merely for -'caps:' xkb options (used to globally change the layouts behaviour). - -Don't alter any of existing key types. If you need a different behaviour cre- -ate a new one. - -4.2.1 More On Definitions Of Types - -When the XKB software deals with a separate type description it gets a com- -plete list of modifiers that should be taken into account from the 'modi- -fiers=' list and expects that a set of 'map[]=' instructions that contain the mapping for -each combination of modifiers mentioned in that list. Modifiers that are not -explicitly listed are NOT taken into account when the resulting shift level -is computed. If some combination is omitted the program (subroutine) should -choose the first level for this combination (a quite reasonable behavior). - -Lets consider an example with two modifiers ModOne and ModTwo: - - type "..." { - modifiers = ModOne+ModTwo; - map[None] = Level1; - map[ModOne] = Level2; - }; - -In this case the map statements for ModTwo only and ModOne+ModTwo are omit- -ted. It means that if the ModTwo is active the subroutine can't found -explicit mapping for such combination an will use the default level i.e. -Level1. - -But in the case the type described as: - - type "..." { - modifiers = ModOne; - map[None] = Level1; - map[ModOne] = Level2; - }; - -the ModTwo will not be taken into account and the resulting level depends on -the ModOne state only. That means, ModTwo alone produces the Level1 but the -combination ModOne+ModTwo produces the Level2 as well as ModOne alone. - -What does it mean if the second modifier is the Lock? It means that in the -first case (the Lock itself is included in the list of modifiers but combina- -tions with this modifier aren't mentioned in the map statements) the internal -capitalization rules will be applied to the symbol from the first level. But -in the second case the capitalization will be applied to the symbol chosen -accordingly to he first modifier - and this can be the symbol from the first -as well as from the second level. - -Usually, all modifiers introduced in 'modifiers=' list are -used for shift level calculation and then discarded. Sometimes this is not -desirable. If you want to use a modifier for shift level calculation but you -don't want to discard it, you may list in 'preserve[]='. That means, for a given combination all listed -modifiers will be preserved. If the Lock modifier is preserved then the -resulting symbol is passed to internal capitalization routine regardless -whether it has been used for a shift level calculation or not. - -Any key type description can use both real and virtual modifiers. Since real -modifiers always have standard names it is not necessary to explicitly -declare them. Virtual modifiers can have arbitrary names and can be declared -(prior using them) directly in key type definition: - - virtual_modifiers ; - -as seen in for example basic, pc or mousekeys key type definitions. - -4.3 Rules - -Once you are finished with your symbol map you need to add it to rules file. -The rules file describes how all the five basic keycodes, types, compat, sym- -bols and geometry components should be composed to give a sensible resulting -xkb configuration. - -The main advantage of rules over formerly used keymaps is a possibility to -simply parameterize (once) fixed patterns of configurations and thus to ele- -gantly allow substitutions of various local configurations into predefined -templates. - -A pattern in a rules file (often located in /usr/lib/X11/xkb/rules) can be -parameterized with four other arguments: Model, Layout, Variant and Options. -For most cases parameters model and layout should be sufficient for choosing -a functional keyboard mapping. - -The rules file itself is composed of pattern lines and lines with rules. The -pattern line starts with an exclamation mark ('!') and describes how will the -xkb interpret the following lines (rules). A sample rules file looks like -this: - - ! model = keycodes - macintosh_old = macintosh - ... - * = xorg - - ! model = symbols - hp = +inet(%m) - microsoftpro = +inet(%m) - geniuscomfy = +inet(%m) - - ! model layout[1] = symbols - macintosh us = macintosh/us%(v[1]) - * * = pc/pc(%m)+pc/%l[1]%(v[1]) - - ! model layout[2] = symbols - macintosh us = +macintosh/us[2]%(v[2]):2 - * * = +pc/%l[2]%(v[2]):2 - - ! option = types - caps:internal = +caps(internal) - caps:internal_nocancel = +caps(internal_nocancel) - -Each rule defines what certain combination of values on the left side of -equal sign ('=') results in. For example a (keyboard) model macintosh_old -instructs xkb to take definitions of keycodes from file keycodes/macintosh -while the rest of models (represented by a wild card '*') instructs it to -take them from file keycodes/xorg. The wild card represents all possible val- -ues on the left side which were not found in any of the previous rules. The -more specialized (more complete) rules have higher precedence than general -ones, i.e. the more general rules supply reasonable default values. - -As you can see some lines contain substitution parameters - the parameters -preceded by the percent sign ('%'). The first alphabetical character after -the percent sign expands to the value which has been found on the left side. -For example +%l%(v) expands into +cz(bksl) if the respective values on the -left side were cz layout in its bksl variant. More, if the layout resp. vari- -ant parameter is followed by a pair of brackets ('[', ']') it means that xkb -should place the layout resp. variant into specified xkb group. If the brack- -ets are omitted the first group is the default value. - -So the second block of rules enhances symbol definitions for some particular -keyboard models with extra keys (for internet, multimedia, ...) . Other mod- -els are left intact. Similarly, the last block overrides some key type defi- -nitions, so the common global behaviour ''shift cancels caps'' or ''shift -doesn't cancel caps'' can be selected. The rest of rules produces special -symbols for each variant us layout of macintosh keyboard and standard pc sym- -bols in appropriate variants as a default. - -4.4 Descriptive Files of Rules - -Now you just need to add a detailed description to .xml description -file so the other users (and external programs which often parse this file) -know what is your work about. - -4.4.1 Old Descriptive Files - -The formerly used descriptive files were named .lst Its structure is -very simple and quite self descriptive but such simplicity had also some cav- -ities, for example there was no way how to describe local variants of layouts -and there were problems with the localization of descriptions. To preserve -compatibility with some older programs, new XML descriptive files can be con- -verted to old format '.lst'. - -For each parameter of rules file should be described its meaning. For the -rules file described above the .lst file could look like: - - ! model - pc104 Generic 104-key PC - microsoft Microsoft Natural - pc98 PC-98xx Series - macintosh Original Macintosh - ... - - ! layout - us U.S. English - cz Czech - de German - ... - - ! option - caps:internal uses internal capitalization. Shift cancels Caps - caps:internal_nocancel uses internal capitalization. Shift doesn't cancel Caps - -And that should be it. Enjoy creating your own xkb mapping. - - diff --git a/xorg-server/Xext/geext.c b/xorg-server/Xext/geext.c index 993b3b2ec..951daf682 100644 --- a/xorg-server/Xext/geext.c +++ b/xorg-server/Xext/geext.c @@ -33,8 +33,6 @@ #include "geext.h" #include "protocol-versions.h" -#define rClient(obj) (clients[CLIENT_ID((obj)->resource)]) - DevPrivateKeyRec GEClientPrivateKeyRec; int RT_GECLIENT = 0; diff --git a/xorg-server/Xext/security.c b/xorg-server/Xext/security.c index 183fa06c7..d687926c6 100644 --- a/xorg-server/Xext/security.c +++ b/xorg-server/Xext/security.c @@ -154,8 +154,6 @@ SecurityLookupRequestName(ClientPtr client) } -#define rClient(obj) (clients[CLIENT_ID((obj)->resource)]) - /* SecurityDeleteAuthorization * * Arguments: diff --git a/xorg-server/Xext/sync.c b/xorg-server/Xext/sync.c index d495116dc..4f80c7f30 100644 --- a/xorg-server/Xext/sync.c +++ b/xorg-server/Xext/sync.c @@ -1,2895 +1,2925 @@ -/* - -Copyright 1991, 1993, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice 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 OPEN GROUP 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. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - - -Copyright 1991, 1993 by Digital Equipment Corporation, Maynard, Massachusetts, -and Olivetti Research Limited, Cambridge, England. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Digital or Olivetti -not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. Digital and Olivetti -make no representations about the suitability of this software -for any purpose. It is provided "as is" without express or implied warranty. - -DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -*/ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include "scrnintstr.h" -#include "os.h" -#include "extnsionst.h" -#include "dixstruct.h" -#include "pixmapstr.h" -#include "resource.h" -#include "opaque.h" -#include -#include "syncsrv.h" -#include "syncsdk.h" -#include "protocol-versions.h" - -#include -#if !defined(WIN32) -#include -#endif - -#include "modinit.h" - -/* - * Local Global Variables - */ -static int SyncEventBase; -static int SyncErrorBase; -static RESTYPE RTCounter = 0; -static RESTYPE RTAwait; -static RESTYPE RTAlarm; -static RESTYPE RTAlarmClient; -static RESTYPE RTFence; -static int SyncNumSystemCounters = 0; -static SyncCounter **SysCounterList = NULL; - -#define IsSystemCounter(pCounter) \ - (pCounter && (pCounter->sync.client == NULL)) - -/* these are all the alarm attributes that pertain to the alarm's trigger */ -#define XSyncCAAllTrigger \ - (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType) - -static void SyncComputeBracketValues(SyncCounter *); - -static void SyncInitServerTime(void); - -static void SyncInitIdleTime(void); - - -/* Each counter maintains a simple linked list of triggers that are - * interested in the counter. The two functions below are used to - * delete and add triggers on this list. - */ -static void -SyncDeleteTriggerFromSyncObject(SyncTrigger *pTrigger) -{ - SyncTriggerList *pCur; - SyncTriggerList *pPrev; - SyncCounter *pCounter; - - /* pSync needs to be stored in pTrigger before calling here. */ - - if (!pTrigger->pSync) - return; - - pPrev = NULL; - pCur = pTrigger->pSync->pTriglist; - - while (pCur) - { - if (pCur->pTrigger == pTrigger) - { - if (pPrev) - pPrev->next = pCur->next; - else - pTrigger->pSync->pTriglist = pCur->next; - - free(pCur); - break; - } - - pPrev = pCur; - pCur = pCur->next; - } - - if (SYNC_COUNTER == pTrigger->pSync->type) - { - pCounter = (SyncCounter *)pTrigger->pSync; - - if (IsSystemCounter(pCounter)) - SyncComputeBracketValues(pCounter); - } else if (SYNC_FENCE == pTrigger->pSync->type) { - SyncFence* pFence = (SyncFence*) pTrigger->pSync; - pFence->funcs.DeleteTrigger(pTrigger); - } -} - - -static int -SyncAddTriggerToSyncObject(SyncTrigger *pTrigger) -{ - SyncTriggerList *pCur; - SyncCounter *pCounter; - - if (!pTrigger->pSync) - return Success; - - /* don't do anything if it's already there */ - for (pCur = pTrigger->pSync->pTriglist; pCur; pCur = pCur->next) - { - if (pCur->pTrigger == pTrigger) - return Success; - } - - if (!(pCur = malloc(sizeof(SyncTriggerList)))) - return BadAlloc; - - pCur->pTrigger = pTrigger; - pCur->next = pTrigger->pSync->pTriglist; - pTrigger->pSync->pTriglist = pCur; - - if (SYNC_COUNTER == pTrigger->pSync->type) - { - pCounter = (SyncCounter *)pTrigger->pSync; - - if (IsSystemCounter(pCounter)) - SyncComputeBracketValues(pCounter); - } else if (SYNC_FENCE == pTrigger->pSync->type) { - SyncFence* pFence = (SyncFence*) pTrigger->pSync; - pFence->funcs.AddTrigger(pTrigger); - } - - return Success; -} - - -/* Below are five possible functions that can be plugged into - * pTrigger->CheckTrigger for counter sync objects, corresponding to - * the four possible test-types, and the one possible function that - * can be plugged into pTrigger->CheckTrigger for fence sync objects. - * These functions are called after the sync object's state changes - * but are also passed the old state so they can inspect both the old - * and new values. (PositiveTransition and NegativeTransition need to - * see both pieces of information.) These functions return the truth - * value of the trigger. - * - * All of them include the condition pTrigger->pSync == NULL. - * This is because the spec says that a trigger with a sync value - * of None is always TRUE. - */ - -static Bool -SyncCheckTriggerPositiveComparison(SyncTrigger *pTrigger, CARD64 oldval) -{ - SyncCounter *pCounter; - - assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); - pCounter = (SyncCounter *)pTrigger->pSync; - - return (pCounter == NULL || - XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value)); -} - -static Bool -SyncCheckTriggerNegativeComparison(SyncTrigger *pTrigger, CARD64 oldval) -{ - SyncCounter *pCounter; - - assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); - pCounter = (SyncCounter *)pTrigger->pSync; - - return (pCounter == NULL || - XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value)); -} - -static Bool -SyncCheckTriggerPositiveTransition(SyncTrigger *pTrigger, CARD64 oldval) -{ - SyncCounter *pCounter; - - assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); - pCounter = (SyncCounter *)pTrigger->pSync; - - return (pCounter == NULL || - (XSyncValueLessThan(oldval, pTrigger->test_value) && - XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value))); -} - -static Bool -SyncCheckTriggerNegativeTransition(SyncTrigger *pTrigger, CARD64 oldval) -{ - SyncCounter *pCounter; - - assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); - pCounter = (SyncCounter *)pTrigger->pSync; - - return (pCounter == NULL || - (XSyncValueGreaterThan(oldval, pTrigger->test_value) && - XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value))); -} - -static Bool -SyncCheckTriggerFence(SyncTrigger *pTrigger, CARD64 unused) -{ - SyncFence* pFence = (SyncFence*) pTrigger->pSync; - (void)unused; - - return (pFence == NULL || - pFence->funcs.CheckTriggered(pFence)); -} - -static int -SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XID syncObject, - RESTYPE resType, Mask changes) -{ - SyncObject *pSync = pTrigger->pSync; - SyncCounter *pCounter = NULL; - int rc; - Bool newSyncObject = FALSE; - - if (changes & XSyncCACounter) - { - if (syncObject == None) - pSync = NULL; - else if (Success != (rc = dixLookupResourceByType ((pointer *)&pSync, - syncObject, resType, client, DixReadAccess))) - { - client->errorValue = syncObject; - return rc; - } - if (pSync != pTrigger->pSync) - { /* new counter for trigger */ - SyncDeleteTriggerFromSyncObject(pTrigger); - pTrigger->pSync = pSync; - newSyncObject = TRUE; - } - } - - /* if system counter, ask it what the current value is */ - - if (pSync && SYNC_COUNTER == pSync->type) - { - pCounter = (SyncCounter *)pSync; - - if (IsSystemCounter(pCounter)) - { - (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter, - &pCounter->value); - } - } - - if (changes & XSyncCAValueType) - { - if (pTrigger->value_type != XSyncRelative && - pTrigger->value_type != XSyncAbsolute) - { - client->errorValue = pTrigger->value_type; - return BadValue; - } - } - - if (changes & XSyncCATestType) - { - - if (pSync && SYNC_FENCE == pSync->type) - { - pTrigger->CheckTrigger = SyncCheckTriggerFence; - } - else - { - if (pTrigger->test_type != XSyncPositiveTransition && - pTrigger->test_type != XSyncNegativeTransition && - pTrigger->test_type != XSyncPositiveComparison && - pTrigger->test_type != XSyncNegativeComparison) - { - client->errorValue = pTrigger->test_type; - return BadValue; - } - /* select appropriate CheckTrigger function */ - - switch (pTrigger->test_type) - { - case XSyncPositiveTransition: - pTrigger->CheckTrigger = SyncCheckTriggerPositiveTransition; - break; - case XSyncNegativeTransition: - pTrigger->CheckTrigger = SyncCheckTriggerNegativeTransition; - break; - case XSyncPositiveComparison: - pTrigger->CheckTrigger = SyncCheckTriggerPositiveComparison; - break; - case XSyncNegativeComparison: - pTrigger->CheckTrigger = SyncCheckTriggerNegativeComparison; - break; - } - } - } - - if (changes & (XSyncCAValueType | XSyncCAValue)) - { - if (pTrigger->value_type == XSyncAbsolute) - pTrigger->test_value = pTrigger->wait_value; - else /* relative */ - { - Bool overflow; - if (pCounter == NULL) - return BadMatch; - - XSyncValueAdd(&pTrigger->test_value, pCounter->value, - pTrigger->wait_value, &overflow); - if (overflow) - { - client->errorValue = XSyncValueHigh32(pTrigger->wait_value); - return BadValue; - } - } - } - - /* we wait until we're sure there are no errors before registering - * a new counter on a trigger - */ - if (newSyncObject) - { - if ((rc = SyncAddTriggerToSyncObject(pTrigger)) != Success) - return rc; - } - else if (pCounter && IsSystemCounter(pCounter)) - { - SyncComputeBracketValues(pCounter); - } - - return Success; -} - -/* AlarmNotify events happen in response to actions taken on an Alarm or - * the counter used by the alarm. AlarmNotify may be sent to multiple - * clients. The alarm maintains a list of clients interested in events. - */ -static void -SyncSendAlarmNotifyEvents(SyncAlarm *pAlarm) -{ - SyncAlarmClientList *pcl; - xSyncAlarmNotifyEvent ane; - SyncTrigger *pTrigger = &pAlarm->trigger; - SyncCounter *pCounter; - - assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); - - pCounter = (SyncCounter *)pTrigger->pSync; - - UpdateCurrentTime(); - - ane.type = SyncEventBase + XSyncAlarmNotify; - ane.kind = XSyncAlarmNotify; - ane.alarm = pAlarm->alarm_id; - 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? */ - 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); - - /* send to other interested clients */ - for (pcl = pAlarm->pEventClients; pcl; pcl = pcl->next) - WriteEventsToClient(pcl->client, 1, (xEvent *) &ane); -} - - -/* CounterNotify events only occur in response to an Await. The events - * go only to the Awaiting client. - */ -static void -SyncSendCounterNotifyEvents(ClientPtr client, SyncAwait **ppAwait, - int num_events) -{ - xSyncCounterNotifyEvent *pEvents, *pev; - int i; - - if (client->clientGone) - return; - pev = pEvents = malloc(num_events * sizeof(xSyncCounterNotifyEvent)); - if (!pEvents) - return; - UpdateCurrentTime(); - for (i = 0; i < num_events; i++, ppAwait++, pev++) - { - SyncTrigger *pTrigger = &(*ppAwait)->trigger; - pev->type = SyncEventBase + XSyncCounterNotify; - pev->kind = XSyncCounterNotify; - pev->counter = pTrigger->pSync->id; - pev->wait_value_lo = XSyncValueLow32(pTrigger->test_value); - pev->wait_value_hi = XSyncValueHigh32(pTrigger->test_value); - if (SYNC_COUNTER == pTrigger->pSync->type) - { - SyncCounter *pCounter = (SyncCounter *)pTrigger->pSync; - - pev->counter_value_lo = XSyncValueLow32(pCounter->value); - pev->counter_value_hi = XSyncValueHigh32(pCounter->value); - } - else - { - pev->counter_value_lo = 0; - pev->counter_value_hi = 0; - } - - pev->time = currentTime.milliseconds; - pev->count = num_events - i - 1; /* events remaining */ - pev->destroyed = pTrigger->pSync->beingDestroyed; - } - /* swapping will be taken care of by this */ - WriteEventsToClient(client, num_events, (xEvent *)pEvents); - free(pEvents); -} - - -/* This function is called when an alarm's counter is destroyed. - * It is plugged into pTrigger->CounterDestroyed (for alarm triggers). - */ -static void -SyncAlarmCounterDestroyed(SyncTrigger *pTrigger) -{ - SyncAlarm *pAlarm = (SyncAlarm *)pTrigger; - - pAlarm->state = XSyncAlarmInactive; - SyncSendAlarmNotifyEvents(pAlarm); - pTrigger->pSync = NULL; -} - - -/* This function is called when an alarm "goes off." - * It is plugged into pTrigger->TriggerFired (for alarm triggers). - */ -static void -SyncAlarmTriggerFired(SyncTrigger *pTrigger) -{ - SyncAlarm *pAlarm = (SyncAlarm *)pTrigger; - SyncCounter *pCounter; - CARD64 new_test_value; - - assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); - pCounter = (SyncCounter *)pTrigger->pSync; - - /* no need to check alarm unless it's active */ - if (pAlarm->state != XSyncAlarmActive) - return; - - /* " if the counter value is None, or if the delta is 0 and - * the test-type is PositiveComparison or NegativeComparison, - * no change is made to value (test-value) and the alarm - * state is changed to Inactive before the event is generated." - */ - if (pCounter == NULL - || (XSyncValueIsZero(pAlarm->delta) - && (pAlarm->trigger.test_type == XSyncPositiveComparison - || pAlarm->trigger.test_type == XSyncNegativeComparison))) - pAlarm->state = XSyncAlarmInactive; - - new_test_value = pAlarm->trigger.test_value; - - if (pAlarm->state == XSyncAlarmActive) - { - Bool overflow; - CARD64 oldvalue; - SyncTrigger *paTrigger = &pAlarm->trigger; - SyncCounter *paCounter; - - assert(!paTrigger->pSync || (SYNC_COUNTER == paTrigger->pSync->type)); - paCounter = (SyncCounter *)pTrigger->pSync; - - /* "The alarm is updated by repeatedly adding delta to the - * value of the trigger and re-initializing it until it - * becomes FALSE." - */ - oldvalue = paTrigger->test_value; - - /* XXX really should do something smarter here */ - - do - { - XSyncValueAdd(&paTrigger->test_value, paTrigger->test_value, - pAlarm->delta, &overflow); - } while (!overflow && - (*paTrigger->CheckTrigger)(paTrigger, - paCounter->value)); - - new_test_value = paTrigger->test_value; - paTrigger->test_value = oldvalue; - - /* "If this update would cause value to fall outside the range - * for an INT64...no change is made to value (test-value) and - * the alarm state is changed to Inactive before the event is - * generated." - */ - if (overflow) - { - new_test_value = oldvalue; - pAlarm->state = XSyncAlarmInactive; - } - } - /* The AlarmNotify event has to have the "new state of the alarm" - * which we can't be sure of until this point. However, it has - * to have the "old" trigger test value. That's the reason for - * all the newvalue/oldvalue shuffling above. After we send the - * events, give the trigger its new test value. - */ - SyncSendAlarmNotifyEvents(pAlarm); - pTrigger->test_value = new_test_value; -} - - -/* This function is called when an Await unblocks, either as a result - * of the trigger firing OR the counter being destroyed. - * It goes into pTrigger->TriggerFired AND pTrigger->CounterDestroyed - * (for Await triggers). - */ -static void -SyncAwaitTriggerFired(SyncTrigger *pTrigger) -{ - SyncAwait *pAwait = (SyncAwait *)pTrigger; - int numwaits; - SyncAwaitUnion *pAwaitUnion; - SyncAwait **ppAwait; - int num_events = 0; - - pAwaitUnion = (SyncAwaitUnion *)pAwait->pHeader; - numwaits = pAwaitUnion->header.num_waitconditions; - ppAwait = malloc(numwaits * sizeof(SyncAwait *)); - if (!ppAwait) - goto bail; - - pAwait = &(pAwaitUnion+1)->await; - - /* "When a client is unblocked, all the CounterNotify events for - * the Await request are generated contiguously. If count is 0 - * there are no more events to follow for this request. If - * count is n, there are at least n more events to follow." - * - * Thus, it is best to find all the counters for which events - * need to be sent first, so that an accurate count field can - * be stored in the events. - */ - for ( ; numwaits; numwaits--, pAwait++) - { - CARD64 diff; - Bool overflow, diffgreater, diffequal; - - /* "A CounterNotify event with the destroyed flag set to TRUE is - * always generated if the counter for one of the triggers is - * destroyed." - */ - if (pAwait->trigger.pSync->beingDestroyed) - { - ppAwait[num_events++] = pAwait; - continue; - } - - if (SYNC_COUNTER == pAwait->trigger.pSync->type) - { - SyncCounter *pCounter = (SyncCounter *) pAwait->trigger.pSync; - - /* "The difference between the counter and the test value is - * calculated by subtracting the test value from the value of - * the counter." - */ - XSyncValueSubtract(&diff, pCounter->value, - pAwait->trigger.test_value, &overflow); - - /* "If the difference lies outside the range for an INT64, an - * event is not generated." - */ - if (overflow) - continue; - diffgreater = XSyncValueGreaterThan(diff, pAwait->event_threshold); - diffequal = XSyncValueEqual(diff, pAwait->event_threshold); - - /* "If the test-type is PositiveTransition or - * PositiveComparison, a CounterNotify event is generated if - * the difference is at least event-threshold. If the test-type - * is NegativeTransition or NegativeComparison, a CounterNotify - * event is generated if the difference is at most - * event-threshold." - */ - - if ( ((pAwait->trigger.test_type == XSyncPositiveComparison || - pAwait->trigger.test_type == XSyncPositiveTransition) - && (diffgreater || diffequal)) - || - ((pAwait->trigger.test_type == XSyncNegativeComparison || - pAwait->trigger.test_type == XSyncNegativeTransition) - && (!diffgreater) /* less or equal */ - ) - ) - { - ppAwait[num_events++] = pAwait; - } - } - } - if (num_events) - SyncSendCounterNotifyEvents(pAwaitUnion->header.client, ppAwait, - num_events); - free(ppAwait); - -bail: - /* unblock the client */ - AttendClient(pAwaitUnion->header.client); - /* delete the await */ - FreeResource(pAwaitUnion->header.delete_id, RT_NONE); -} - - -/* This function should always be used to change a counter's value so that - * any triggers depending on the counter will be checked. - */ -void -SyncChangeCounter(SyncCounter *pCounter, CARD64 newval) -{ - SyncTriggerList *ptl, *pnext; - CARD64 oldval; - - oldval = pCounter->value; - pCounter->value = newval; - - /* run through triggers to see if any become true */ - for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext) - { - pnext = ptl->next; - if ((*ptl->pTrigger->CheckTrigger)(ptl->pTrigger, oldval)) - (*ptl->pTrigger->TriggerFired)(ptl->pTrigger); - } - - if (IsSystemCounter(pCounter)) - { - SyncComputeBracketValues(pCounter); - } -} - - -/* loosely based on dix/events.c/EventSelectForWindow */ -static Bool -SyncEventSelectForAlarm(SyncAlarm *pAlarm, ClientPtr client, Bool wantevents) -{ - SyncAlarmClientList *pClients; - - if (client == pAlarm->client) /* alarm owner */ - { - pAlarm->events = wantevents; - return Success; - } - - /* see if the client is already on the list (has events selected) */ - - for (pClients = pAlarm->pEventClients; pClients; - pClients = pClients->next) - { - if (pClients->client == client) - { - /* client's presence on the list indicates desire for - * events. If the client doesn't want events, remove it - * from the list. If the client does want events, do - * nothing, since it's already got them. - */ - if (!wantevents) - { - FreeResource(pClients->delete_id, RT_NONE); - } - return Success; - } - } - - /* if we get here, this client does not currently have - * events selected on the alarm - */ - - if (!wantevents) - /* client doesn't want events, and we just discovered that it - * doesn't have them, so there's nothing to do. - */ - return Success; - - /* add new client to pAlarm->pEventClients */ - - pClients = malloc(sizeof(SyncAlarmClientList)); - if (!pClients) - return BadAlloc; - - /* register it as a resource so it will be cleaned up - * if the client dies - */ - - pClients->delete_id = FakeClientID(client->index); - if (!AddResource(pClients->delete_id, RTAlarmClient, pAlarm)) - { - free(pClients); - return BadAlloc; - } - - /* link it into list after we know all the allocations succeed */ - - pClients->next = pAlarm->pEventClients; - pAlarm->pEventClients = pClients; - pClients->client = client; - return Success; -} - -/* - * ** SyncChangeAlarmAttributes ** This is used by CreateAlarm and ChangeAlarm - */ -static int -SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm *pAlarm, Mask mask, - CARD32 *values) -{ - int status; - XSyncCounter counter; - Mask origmask = mask; - - counter = - pAlarm->trigger.pSync ? pAlarm->trigger.pSync->id : None; - - while (mask) - { - int index2 = lowbit(mask); - mask &= ~index2; - switch (index2) - { - case XSyncCACounter: - mask &= ~XSyncCACounter; - /* sanity check in SyncInitTrigger */ - counter = *values++; - break; - - case XSyncCAValueType: - mask &= ~XSyncCAValueType; - /* sanity check in SyncInitTrigger */ - pAlarm->trigger.value_type = *values++; - break; - - case XSyncCAValue: - mask &= ~XSyncCAValue; - XSyncIntsToValue(&pAlarm->trigger.wait_value, values[1], values[0]); - values += 2; - break; - - case XSyncCATestType: - mask &= ~XSyncCATestType; - /* sanity check in SyncInitTrigger */ - pAlarm->trigger.test_type = *values++; - break; - - case XSyncCADelta: - mask &= ~XSyncCADelta; - XSyncIntsToValue(&pAlarm->delta, values[1], values[0]); - values += 2; - break; - - case XSyncCAEvents: - mask &= ~XSyncCAEvents; - if ((*values != xTrue) && (*values != xFalse)) - { - client->errorValue = *values; - return BadValue; - } - status = SyncEventSelectForAlarm(pAlarm, client, - (Bool)(*values++)); - if (status != Success) - return status; - break; - - default: - client->errorValue = mask; - return BadValue; - } - } - - /* "If the test-type is PositiveComparison or PositiveTransition - * and delta is less than zero, or if the test-type is - * NegativeComparison or NegativeTransition and delta is - * greater than zero, a Match error is generated." - */ - if (origmask & (XSyncCADelta|XSyncCATestType)) - { - CARD64 zero; - XSyncIntToValue(&zero, 0); - if ((((pAlarm->trigger.test_type == XSyncPositiveComparison) || - (pAlarm->trigger.test_type == XSyncPositiveTransition)) - && XSyncValueLessThan(pAlarm->delta, zero)) - || - (((pAlarm->trigger.test_type == XSyncNegativeComparison) || - (pAlarm->trigger.test_type == XSyncNegativeTransition)) - && XSyncValueGreaterThan(pAlarm->delta, zero)) - ) - { - return BadMatch; - } - } - - /* postpone this until now, when we're sure nothing else can go wrong */ - if ((status = SyncInitTrigger(client, &pAlarm->trigger, counter, RTCounter, - origmask & XSyncCAAllTrigger)) != Success) - return status; - - /* XXX spec does not really say to do this - needs clarification */ - pAlarm->state = XSyncAlarmActive; - return Success; -} - -static SyncObject * -SyncCreate(ClientPtr client, XID id, unsigned char type) -{ - SyncObject *pSync; - RESTYPE resType; - - switch (type) { - case SYNC_COUNTER: - resType = RTCounter; - pSync = malloc(sizeof(SyncCounter)); - break; - case SYNC_FENCE: - resType = RTFence; - pSync = dixAllocateObjectWithPrivates(SyncFence, - PRIVATE_SYNC_FENCE); - break; - default: - return NULL; - } - - if (!pSync) - return NULL; - - if (!AddResource(id, resType, (pointer) pSync)) - { - switch (type) { - case SYNC_FENCE: - dixFreeObjectWithPrivates((SyncFence *)pSync, PRIVATE_SYNC_FENCE); - break; - default: - free(pSync); - } - - return NULL; - } - - pSync->client = client; - pSync->id = id; - pSync->pTriglist = NULL; - pSync->beingDestroyed = FALSE; - pSync->type = type; - - return pSync; -} - - -static SyncCounter * -SyncCreateCounter(ClientPtr client, XSyncCounter id, CARD64 initialvalue) -{ - SyncCounter *pCounter; - - if (!(pCounter = (SyncCounter *)SyncCreate(client, - id, - SYNC_COUNTER))) - return NULL; - - pCounter->value = initialvalue; - pCounter->pSysCounterInfo = NULL; - return pCounter; -} - -static int FreeCounter(void *, XID); - -/* - * ***** System Counter utilities - */ - -pointer -SyncCreateSystemCounter( - 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 */) - ) -{ - 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. - */ - if (RTCounter == 0) - { - RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter"); - if (RTCounter == 0) - { - return NULL; - } - } - - pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial); - - if (pCounter) - { - SysCounterInfo *psci; - - psci = malloc(sizeof(SysCounterInfo)); - if (!psci) - { - FreeResource(pCounter->sync.id, RT_NONE); - return pCounter; - } - pCounter->pSysCounterInfo = psci; - psci->name = name; - psci->resolution = resolution; - psci->counterType = counterType; - psci->QueryValue = QueryValue; - psci->BracketValues = BracketValues; - XSyncMaxValue(&psci->bracket_greater); - XSyncMinValue(&psci->bracket_less); - SysCounterList[SyncNumSystemCounters++] = pCounter; - } - return pCounter; -} - -void -SyncDestroySystemCounter(pointer pSysCounter) -{ - SyncCounter *pCounter = (SyncCounter *)pSysCounter; - FreeResource(pCounter->sync.id, RT_NONE); -} - -static void -SyncComputeBracketValues(SyncCounter *pCounter) -{ - SyncTriggerList *pCur; - SyncTrigger *pTrigger; - SysCounterInfo *psci; - CARD64 *pnewgtval = NULL; - CARD64 *pnewltval = NULL; - SyncCounterType ct; - - if (!pCounter) - return; - - psci = pCounter->pSysCounterInfo; - ct = pCounter->pSysCounterInfo->counterType; - if (ct == XSyncCounterNeverChanges) - return; - - XSyncMaxValue(&psci->bracket_greater); - XSyncMinValue(&psci->bracket_less); - - for (pCur = pCounter->sync.pTriglist; pCur; pCur = pCur->next) - { - pTrigger = pCur->pTrigger; - - if (pTrigger->test_type == XSyncPositiveComparison && - ct != XSyncCounterNeverIncreases) - { - if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) && - XSyncValueLessThan(pTrigger->test_value, - psci->bracket_greater)) - { - psci->bracket_greater = pTrigger->test_value; - pnewgtval = &psci->bracket_greater; - } - } - else if (pTrigger->test_type == XSyncNegativeComparison && - ct != XSyncCounterNeverDecreases) - { - if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) && - XSyncValueGreaterThan(pTrigger->test_value, - psci->bracket_less)) - { - psci->bracket_less = pTrigger->test_value; - pnewltval = &psci->bracket_less; - } - } - else if (pTrigger->test_type == XSyncNegativeTransition && - ct != XSyncCounterNeverIncreases) - { - if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) && - XSyncValueGreaterThan(pTrigger->test_value, psci->bracket_less)) - { - psci->bracket_less = pTrigger->test_value; - pnewltval = &psci->bracket_less; - } else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) && - XSyncValueLessThan(pTrigger->test_value, - psci->bracket_greater)) - { - /* - * 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. - */ - psci->bracket_greater = pTrigger->test_value; - pnewgtval = &psci->bracket_greater; - } - } - else if (pTrigger->test_type == XSyncPositiveTransition && - ct != XSyncCounterNeverDecreases) - { - if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) && - XSyncValueLessThan(pTrigger->test_value, psci->bracket_greater)) - { - psci->bracket_greater = pTrigger->test_value; - pnewgtval = &psci->bracket_greater; - } else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) && - XSyncValueGreaterThan(pTrigger->test_value, - psci->bracket_less)) - { - /* - * 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. - */ - psci->bracket_less = pTrigger->test_value; - pnewltval = &psci->bracket_less; - } - } - } /* end for each trigger */ - - if (pnewgtval || pnewltval) - { - (*psci->BracketValues)((pointer)pCounter, pnewltval, pnewgtval); - } -} - -/* - * ***** Resource delete functions - */ - -/* ARGSUSED */ -static int -FreeAlarm(void *addr, XID id) -{ - SyncAlarm *pAlarm = (SyncAlarm *) addr; - - pAlarm->state = XSyncAlarmDestroyed; - - SyncSendAlarmNotifyEvents(pAlarm); - - /* delete event selections */ - - while (pAlarm->pEventClients) - FreeResource(pAlarm->pEventClients->delete_id, RT_NONE); - - SyncDeleteTriggerFromSyncObject(&pAlarm->trigger); - - free(pAlarm); - return Success; -} - - -/* - * ** Cleanup after the destruction of a Counter - */ -/* ARGSUSED */ -static int -FreeCounter(void *env, XID id) -{ - SyncCounter *pCounter = (SyncCounter *) env; - SyncTriggerList *ptl, *pnext; - - pCounter->sync.beingDestroyed = TRUE; - /* tell all the counter's triggers that the counter has been destroyed */ - for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext) - { - (*ptl->pTrigger->CounterDestroyed)(ptl->pTrigger); - pnext = ptl->next; - free(ptl); /* destroy the trigger list as we go */ - } - if (IsSystemCounter(pCounter)) - { - int i, found = 0; - - 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; -} - -/* - * ** Cleanup after Await - */ -/* ARGSUSED */ -static int -FreeAwait(void *addr, XID id) -{ - SyncAwaitUnion *pAwaitUnion = (SyncAwaitUnion *) addr; - SyncAwait *pAwait; - int numwaits; - - pAwait = &(pAwaitUnion+1)->await; /* first await on list */ - - /* remove triggers from counters */ - - for (numwaits = pAwaitUnion->header.num_waitconditions; numwaits; - numwaits--, pAwait++) - { - /* If the counter is being destroyed, FreeCounter will delete - * the trigger list itself, so don't do it here. - */ - SyncObject *pSync = pAwait->trigger.pSync; - if (pSync && !pSync->beingDestroyed) - SyncDeleteTriggerFromSyncObject(&pAwait->trigger); - } - free(pAwaitUnion); - return Success; -} - -/* loosely based on dix/events.c/OtherClientGone */ -static int -FreeAlarmClient(void *value, XID id) -{ - SyncAlarm *pAlarm = (SyncAlarm *)value; - SyncAlarmClientList *pCur, *pPrev; - - for (pPrev = NULL, pCur = pAlarm->pEventClients; - pCur; - pPrev = pCur, pCur = pCur->next) - { - if (pCur->delete_id == id) - { - if (pPrev) - pPrev->next = pCur->next; - else - pAlarm->pEventClients = pCur->next; - free(pCur); - return Success; - } - } - FatalError("alarm client not on event list"); - /*NOTREACHED*/ -} - - -/* - * ***** Proc functions - */ - - -/* - * ** Initialize the extension - */ -static int -ProcSyncInitialize(ClientPtr client) -{ - xSyncInitializeReply rep; - int n; - - 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, n); - } - WriteToClient(client, sizeof(rep), (char *) &rep); - return Success; -} - -/* - * ** Get list of system counters available through the extension - */ -static int -ProcSyncListSystemCounters(ClientPtr client) -{ - xSyncListSystemCountersReply rep; - int i, len; - 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++) - { - char *name = SysCounterList[i]->pSysCounterInfo->name; - /* pad to 4 byte boundary */ - len += pad_to_int32(sz_xSyncSystemCounter + strlen(name)); - } - - if (len) - { - walklist = list = malloc(len); - if (!list) - return BadAlloc; - } - - rep.length = bytes_to_int32(len); - - if (client->swapped) - { - char n; - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.nCounters, n); - } - - for (i = 0; i < SyncNumSystemCounters; i++) - { - int namelen; - char *pname_in_reply; - SysCounterInfo *psci = SysCounterList[i]->pSysCounterInfo; - - walklist->counter = SysCounterList[i]->sync.id; - walklist->resolution_hi = XSyncValueHigh32(psci->resolution); - walklist->resolution_lo = XSyncValueLow32(psci->resolution); - namelen = strlen(psci->name); - walklist->name_length = namelen; - - if (client->swapped) - { - char n; - swapl(&walklist->counter, n); - swapl(&walklist->resolution_hi, n); - swapl(&walklist->resolution_lo, n); - swaps(&walklist->name_length, n); - } - - pname_in_reply = ((char *)walklist) + sz_xSyncSystemCounter; - strncpy(pname_in_reply, psci->name, namelen); - walklist = (xSyncSystemCounter *) (((char *)walklist) + - pad_to_int32(sz_xSyncSystemCounter + namelen)); - } - - WriteToClient(client, sizeof(rep), (char *) &rep); - if (len) - { - WriteToClient(client, len, (char *) list); - free(list); - } - - return Success; -} - -/* - * ** Set client Priority - */ -static int -ProcSyncSetPriority(ClientPtr client) -{ - REQUEST(xSyncSetPriorityReq); - ClientPtr priorityclient; - int rc; - - REQUEST_SIZE_MATCH(xSyncSetPriorityReq); - - if (stuff->id == None) - priorityclient = client; - else { - rc = dixLookupClient(&priorityclient, stuff->id, client, - DixSetAttrAccess); - if (rc != Success) - return rc; - } - - if (priorityclient->priority != stuff->priority) - { - priorityclient->priority = stuff->priority; - - /* The following will force the server back into WaitForSomething - * so that the change in this client's priority is immediately - * reflected. - */ - isItTimeToYield = TRUE; - dispatchException |= DE_PRIORITYCHANGE; - } - return Success; -} - -/* - * ** Get client Priority - */ -static int -ProcSyncGetPriority(ClientPtr client) -{ - REQUEST(xSyncGetPriorityReq); - xSyncGetPriorityReply rep; - ClientPtr priorityclient; - int rc; - - REQUEST_SIZE_MATCH(xSyncGetPriorityReq); - - if (stuff->id == None) - priorityclient = client; - else { - rc = dixLookupClient(&priorityclient, stuff->id, client, - DixGetAttrAccess); - if (rc != Success) - return rc; - } - - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.priority = priorityclient->priority; - - if (client->swapped) - { - char n; - swaps(&rep.sequenceNumber, n); - swapl(&rep.priority, n); - } - - WriteToClient(client, sizeof(xSyncGetPriorityReply), (char *) &rep); - - return Success; -} - -/* - * ** Create a new counter - */ -static int -ProcSyncCreateCounter(ClientPtr client) -{ - REQUEST(xSyncCreateCounterReq); - CARD64 initial; - - REQUEST_SIZE_MATCH(xSyncCreateCounterReq); - - LEGAL_NEW_RESOURCE(stuff->cid, client); - - XSyncIntsToValue(&initial, stuff->initial_value_lo, stuff->initial_value_hi); - if (!SyncCreateCounter(client, stuff->cid, initial)) - return BadAlloc; - - return Success; -} - -/* - * ** Set Counter value - */ -static int -ProcSyncSetCounter(ClientPtr client) -{ - REQUEST(xSyncSetCounterReq); - SyncCounter *pCounter; - CARD64 newvalue; - int rc; - - REQUEST_SIZE_MATCH(xSyncSetCounterReq); - - rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter, - client, DixWriteAccess); - if (rc != Success) - return rc; - - if (IsSystemCounter(pCounter)) - { - client->errorValue = stuff->cid; - return BadAccess; - } - - XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi); - SyncChangeCounter(pCounter, newvalue); - return Success; -} - -/* - * ** Change Counter value - */ -static int -ProcSyncChangeCounter(ClientPtr client) -{ - REQUEST(xSyncChangeCounterReq); - SyncCounter *pCounter; - CARD64 newvalue; - Bool overflow; - int rc; - - REQUEST_SIZE_MATCH(xSyncChangeCounterReq); - - rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter, - client, DixWriteAccess); - if (rc != Success) - return rc; - - if (IsSystemCounter(pCounter)) - { - client->errorValue = stuff->cid; - return BadAccess; - } - - XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi); - XSyncValueAdd(&newvalue, pCounter->value, newvalue, &overflow); - if (overflow) - { - /* XXX 64 bit value can't fit in 32 bits; do the best we can */ - client->errorValue = stuff->value_hi; - return BadValue; - } - SyncChangeCounter(pCounter, newvalue); - return Success; -} - -/* - * ** Destroy a counter - */ -static int -ProcSyncDestroyCounter(ClientPtr client) -{ - REQUEST(xSyncDestroyCounterReq); - SyncCounter *pCounter; - int rc; - - REQUEST_SIZE_MATCH(xSyncDestroyCounterReq); - - rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter, - client, DixDestroyAccess); - if (rc != Success) - return rc; - - if (IsSystemCounter(pCounter)) - { - client->errorValue = stuff->counter; - return BadAccess; - } - FreeResource(pCounter->sync.id, RT_NONE); - return Success; -} - -static SyncAwaitUnion* -SyncAwaitPrologue(ClientPtr client, int items) -{ - SyncAwaitUnion *pAwaitUnion; - - /* all the memory for the entire await list is allocated - * here in one chunk - */ - pAwaitUnion = malloc((items+1) * sizeof(SyncAwaitUnion)); - if (!pAwaitUnion) - return NULL; - - /* first item is the header, remainder are real wait conditions */ - - pAwaitUnion->header.delete_id = FakeClientID(client->index); - if (!AddResource(pAwaitUnion->header.delete_id, RTAwait, pAwaitUnion)) - { - free(pAwaitUnion); - return NULL; - } - - pAwaitUnion->header.client = client; - pAwaitUnion->header.num_waitconditions = 0; - - return pAwaitUnion; -} - -static void -SyncAwaitEpilogue(ClientPtr client, int items, SyncAwaitUnion *pAwaitUnion) -{ - SyncAwait *pAwait; - int i; - - IgnoreClient(client); - - /* see if any of the triggers are already true */ - - pAwait = &(pAwaitUnion+1)->await; /* skip over header */ - for (i = 0; i < items; i++, pAwait++) - { - CARD64 value; - - /* don't have to worry about NULL counters because the request - * errors before we get here out if they occur - */ - switch (pAwait->trigger.pSync->type) { - case SYNC_COUNTER: - value = ((SyncCounter *)pAwait->trigger.pSync)->value; - break; - default: - XSyncIntToValue(&value, 0); - } - - if ((*pAwait->trigger.CheckTrigger)(&pAwait->trigger, value)) - { - (*pAwait->trigger.TriggerFired)(&pAwait->trigger); - break; /* once is enough */ - } - } -} - -/* - * ** Await - */ -static int -ProcSyncAwait(ClientPtr client) -{ - REQUEST(xSyncAwaitReq); - int len, items; - int i; - xSyncWaitCondition *pProtocolWaitConds; - SyncAwaitUnion *pAwaitUnion; - SyncAwait *pAwait; - int status; - - REQUEST_AT_LEAST_SIZE(xSyncAwaitReq); - - len = client->req_len << 2; - len -= sz_xSyncAwaitReq; - items = len / sz_xSyncWaitCondition; - - if (items * sz_xSyncWaitCondition != len) - { - return BadLength; - } - if (items == 0) - { - client->errorValue = items; /* XXX protocol change */ - return BadValue; - } - - if (!(pAwaitUnion = SyncAwaitPrologue(client, items))) - return BadAlloc; - - /* don't need to do any more memory allocation for this request! */ - - pProtocolWaitConds = (xSyncWaitCondition *) & stuff[1]; - - pAwait = &(pAwaitUnion+1)->await; /* skip over header */ - for (i = 0; i < items; i++, pProtocolWaitConds++, pAwait++) - { - if (pProtocolWaitConds->counter == None) /* XXX protocol change */ - { - /* this should take care of removing any triggers created by - * this request that have already been registered on sync objects - */ - FreeResource(pAwaitUnion->header.delete_id, RT_NONE); - client->errorValue = pProtocolWaitConds->counter; - return SyncErrorBase + XSyncBadCounter; - } - - /* sanity checks are in SyncInitTrigger */ - pAwait->trigger.pSync = NULL; - pAwait->trigger.value_type = pProtocolWaitConds->value_type; - XSyncIntsToValue(&pAwait->trigger.wait_value, - pProtocolWaitConds->wait_value_lo, - pProtocolWaitConds->wait_value_hi); - pAwait->trigger.test_type = pProtocolWaitConds->test_type; - - status = SyncInitTrigger(client, &pAwait->trigger, - pProtocolWaitConds->counter, RTCounter, - XSyncCAAllTrigger); - if (status != Success) - { - /* this should take care of removing any triggers created by - * this request that have already been registered on sync objects - */ - FreeResource(pAwaitUnion->header.delete_id, RT_NONE); - return status; - } - /* this is not a mistake -- same function works for both cases */ - pAwait->trigger.TriggerFired = SyncAwaitTriggerFired; - pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired; - XSyncIntsToValue(&pAwait->event_threshold, - pProtocolWaitConds->event_threshold_lo, - pProtocolWaitConds->event_threshold_hi); - pAwait->pHeader = &pAwaitUnion->header; - pAwaitUnion->header.num_waitconditions++; - } - - SyncAwaitEpilogue(client, items, pAwaitUnion); - - return Success; -} - - -/* - * ** Query a counter - */ -static int -ProcSyncQueryCounter(ClientPtr client) -{ - REQUEST(xSyncQueryCounterReq); - xSyncQueryCounterReply rep; - SyncCounter *pCounter; - int rc; - - REQUEST_SIZE_MATCH(xSyncQueryCounterReq); - - rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, - RTCounter, client, DixReadAccess); - 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); - if (client->swapped) - { - char n; - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.value_hi, n); - swapl(&rep.value_lo, n); - } - WriteToClient(client, sizeof(xSyncQueryCounterReply), (char *) &rep); - return Success; -} - - -/* - * ** Create Alarm - */ -static int -ProcSyncCreateAlarm(ClientPtr client) -{ - REQUEST(xSyncCreateAlarmReq); - SyncAlarm *pAlarm; - int status; - unsigned long len, vmask; - SyncTrigger *pTrigger; - - REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq); - - LEGAL_NEW_RESOURCE(stuff->id, client); - - vmask = stuff->valueMask; - len = client->req_len - bytes_to_int32(sizeof(xSyncCreateAlarmReq)); - /* the "extra" call to Ones accounts for the presence of 64 bit values */ - if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta)))) - return BadLength; - - if (!(pAlarm = malloc(sizeof(SyncAlarm)))) - { - return BadAlloc; - } - - /* set up defaults */ - - pTrigger = &pAlarm->trigger; - pTrigger->pSync = NULL; - pTrigger->value_type = XSyncAbsolute; - XSyncIntToValue(&pTrigger->wait_value, 0L); - pTrigger->test_type = XSyncPositiveComparison; - pTrigger->TriggerFired = SyncAlarmTriggerFired; - pTrigger->CounterDestroyed = SyncAlarmCounterDestroyed; - status = SyncInitTrigger(client, pTrigger, None, RTCounter, - XSyncCAAllTrigger); - if (status != Success) - { - free(pAlarm); - return status; - } - - pAlarm->client = client; - pAlarm->alarm_id = stuff->id; - XSyncIntToValue(&pAlarm->delta, 1L); - pAlarm->events = TRUE; - pAlarm->state = XSyncAlarmInactive; - pAlarm->pEventClients = NULL; - status = SyncChangeAlarmAttributes(client, pAlarm, vmask, - (CARD32 *)&stuff[1]); - if (status != Success) - { - free(pAlarm); - return status; - } - - if (!AddResource(stuff->id, RTAlarm, pAlarm)) - { - free(pAlarm); - return BadAlloc; - } - - /* see if alarm already triggered. NULL counter will not trigger - * in CreateAlarm and sets alarm state to Inactive. - */ - - if (!pTrigger->pSync) - { - pAlarm->state = XSyncAlarmInactive; /* XXX protocol change */ - } - else - { - SyncCounter *pCounter; - - assert(SYNC_COUNTER == pTrigger->pSync->type); - pCounter = (SyncCounter *)pTrigger->pSync; - - if ((*pTrigger->CheckTrigger)(pTrigger, pCounter->value)) - (*pTrigger->TriggerFired)(pTrigger); - } - - return Success; -} - -/* - * ** Change Alarm - */ -static int -ProcSyncChangeAlarm(ClientPtr client) -{ - REQUEST(xSyncChangeAlarmReq); - SyncAlarm *pAlarm; - SyncCounter *pCounter = NULL; - long vmask; - int len, status; - - REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); - - status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, - client, DixWriteAccess); - if (status != Success) - return status; - - vmask = stuff->valueMask; - len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq)); - /* the "extra" call to Ones accounts for the presence of 64 bit values */ - if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta)))) - return BadLength; - - if ((status = SyncChangeAlarmAttributes(client, pAlarm, vmask, - (CARD32 *)&stuff[1])) != Success) - return status; - - if (pAlarm->trigger.pSync) - { - assert(SYNC_COUNTER == pAlarm->trigger.pSync->type); - pCounter = (SyncCounter *)pAlarm->trigger.pSync; - } - - /* see if alarm already triggered. NULL counter WILL trigger - * in ChangeAlarm. - */ - - if (!pCounter || - (*pAlarm->trigger.CheckTrigger)(&pAlarm->trigger, pCounter->value)) - { - (*pAlarm->trigger.TriggerFired)(&pAlarm->trigger); - } - return Success; -} - -static int -ProcSyncQueryAlarm(ClientPtr client) -{ - REQUEST(xSyncQueryAlarmReq); - SyncAlarm *pAlarm; - xSyncQueryAlarmReply rep; - SyncTrigger *pTrigger; - int rc; - - REQUEST_SIZE_MATCH(xSyncQueryAlarmReq); - - rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, - client, DixReadAccess); - 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); -#else - rep.value_type = XSyncAbsolute; - rep.wait_value_hi = XSyncValueHigh32(pTrigger->test_value); - rep.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; - - if (client->swapped) - { - char n; - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.counter, n); - swapl(&rep.wait_value_hi, n); - swapl(&rep.wait_value_lo, n); - swapl(&rep.test_type, n); - swapl(&rep.delta_hi, n); - swapl(&rep.delta_lo, n); - } - - WriteToClient(client, sizeof(xSyncQueryAlarmReply), (char *) &rep); - return Success; -} - -static int -ProcSyncDestroyAlarm(ClientPtr client) -{ - SyncAlarm *pAlarm; - int rc; - REQUEST(xSyncDestroyAlarmReq); - - REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq); - - rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, - client, DixDestroyAccess); - if (rc != Success) - return rc; - - FreeResource(stuff->alarm, RT_NONE); - return Success; -} - -static int -ProcSyncCreateFence(ClientPtr client) -{ - REQUEST(xSyncCreateFenceReq); - DrawablePtr pDraw; - SyncFence *pFence; - int rc; - - REQUEST_SIZE_MATCH(xSyncCreateFenceReq); - - rc = dixLookupDrawable(&pDraw, stuff->d, client, M_ANY, DixGetAttrAccess); - if (rc != Success) - return rc; - - LEGAL_NEW_RESOURCE(stuff->fid, client); - - if (!(pFence = (SyncFence *)SyncCreate(client, - stuff->fid, - SYNC_FENCE))) - return BadAlloc; - - miSyncInitFence(pDraw->pScreen, pFence, stuff->initially_triggered); - - return client->noClientException; -} - -static int -FreeFence(void *obj, XID id) -{ - SyncFence *pFence = (SyncFence *) obj; - - miSyncDestroyFence(pFence); - - return Success; -} - -int SyncVerifyFence(SyncFence **ppSyncFence, XID fid, - ClientPtr client, Mask mode) -{ - int rc = dixLookupResourceByType((pointer *)ppSyncFence, fid, RTFence, - client, mode); - - if (rc != Success) - client->errorValue = fid; - - return rc; -} - -static int -ProcSyncTriggerFence(ClientPtr client) -{ - REQUEST(xSyncTriggerFenceReq); - SyncFence *pFence; - int rc; - - REQUEST_SIZE_MATCH(xSyncTriggerFenceReq); - - rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence, - client, DixWriteAccess); - if (rc != Success) - return rc; - - miSyncTriggerFence(pFence); - - return client->noClientException; -} - -static int -ProcSyncResetFence(ClientPtr client) -{ - REQUEST(xSyncResetFenceReq); - SyncFence *pFence; - int rc; - - REQUEST_SIZE_MATCH(xSyncResetFenceReq); - - rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence, - client, DixWriteAccess); - if (rc != Success) - return rc; - - if (pFence->funcs.CheckTriggered(pFence) != TRUE) - return BadMatch; - - pFence->funcs.Reset(pFence); - - return client->noClientException; -} - -static int -ProcSyncDestroyFence(ClientPtr client) -{ - REQUEST(xSyncDestroyFenceReq); - SyncFence *pFence; - int rc; - - REQUEST_SIZE_MATCH(xSyncDestroyFenceReq); - - rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence, - client, DixDestroyAccess); - if (rc != Success) - return rc; - - FreeResource(stuff->fid, RT_NONE); - return client->noClientException; -} - -static int -ProcSyncQueryFence(ClientPtr client) -{ - REQUEST(xSyncQueryFenceReq); - xSyncQueryFenceReply rep; - SyncFence *pFence; - int rc; - - REQUEST_SIZE_MATCH(xSyncQueryFenceReq); - - rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, - RTFence, client, DixReadAccess); - if (rc != Success) - return rc; - - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - rep.triggered = pFence->funcs.CheckTriggered(pFence); - - if (client->swapped) - { - char n; - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - } - - WriteToClient(client, sizeof(xSyncQueryFenceReply), (char *) &rep); - return client->noClientException; -} - -static int -ProcSyncAwaitFence(ClientPtr client) -{ - REQUEST(xSyncAwaitFenceReq); - SyncAwaitUnion *pAwaitUnion; - SyncAwait *pAwait; - /* Use CARD32 rather than XSyncFence because XIDs are hard-coded to - * CARD32 in protocol definitions */ - CARD32 *pProtocolFences; - int status; - int len; - int items; - int i; - - REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq); - - len = client->req_len << 2; - len -= sz_xSyncAwaitFenceReq; - items = len / sizeof(CARD32); - - if (items * sizeof(CARD32) != len) - { - return BadLength; - } - if (items == 0) - { - client->errorValue = items; /* XXX protocol change */ - return BadValue; - } - - if (!(pAwaitUnion = SyncAwaitPrologue(client, items))) - return BadAlloc; - - /* don't need to do any more memory allocation for this request! */ - - pProtocolFences = (CARD32 *) & stuff[1]; - - pAwait = &(pAwaitUnion+1)->await; /* skip over header */ - for (i = 0; i < items; i++, pProtocolFences++, pAwait++) - { - if (*pProtocolFences == None) /* XXX protocol change */ - { - /* this should take care of removing any triggers created by - * this request that have already been registered on sync objects - */ - FreeResource(pAwaitUnion->header.delete_id, RT_NONE); - client->errorValue = *pProtocolFences; - return SyncErrorBase + XSyncBadCounter; - } - - pAwait->trigger.pSync = NULL; - /* Provide acceptable values for these unused fields to - * satisfy SyncInitTrigger's validation logic - */ - pAwait->trigger.value_type = XSyncAbsolute; - XSyncIntToValue(&pAwait->trigger.wait_value, 0); - pAwait->trigger.test_type = 0; - - status = SyncInitTrigger(client, &pAwait->trigger, - *pProtocolFences, RTFence, - XSyncCAAllTrigger); - if (status != Success) - { - /* this should take care of removing any triggers created by - * this request that have already been registered on sync objects - */ - FreeResource(pAwaitUnion->header.delete_id, RT_NONE); - return status; - } - /* this is not a mistake -- same function works for both cases */ - pAwait->trigger.TriggerFired = SyncAwaitTriggerFired; - pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired; - /* event_threshold is unused for fence syncs */ - XSyncIntToValue(&pAwait->event_threshold, 0); - pAwait->pHeader = &pAwaitUnion->header; - pAwaitUnion->header.num_waitconditions++; - } - - SyncAwaitEpilogue(client, items, pAwaitUnion); - - return client->noClientException; -} - -/* - * ** Given an extension request, call the appropriate request procedure - */ -static int -ProcSyncDispatch(ClientPtr client) -{ - REQUEST(xReq); - - switch (stuff->data) - { - case X_SyncInitialize: - return ProcSyncInitialize(client); - case X_SyncListSystemCounters: - return ProcSyncListSystemCounters(client); - case X_SyncCreateCounter: - return ProcSyncCreateCounter(client); - case X_SyncSetCounter: - return ProcSyncSetCounter(client); - case X_SyncChangeCounter: - return ProcSyncChangeCounter(client); - case X_SyncQueryCounter: - return ProcSyncQueryCounter(client); - case X_SyncDestroyCounter: - return ProcSyncDestroyCounter(client); - case X_SyncAwait: - return ProcSyncAwait(client); - case X_SyncCreateAlarm: - return ProcSyncCreateAlarm(client); - case X_SyncChangeAlarm: - return ProcSyncChangeAlarm(client); - case X_SyncQueryAlarm: - return ProcSyncQueryAlarm(client); - case X_SyncDestroyAlarm: - return ProcSyncDestroyAlarm(client); - case X_SyncSetPriority: - return ProcSyncSetPriority(client); - case X_SyncGetPriority: - return ProcSyncGetPriority(client); - case X_SyncCreateFence: - return ProcSyncCreateFence(client); - case X_SyncTriggerFence: - return ProcSyncTriggerFence(client); - case X_SyncResetFence: - return ProcSyncResetFence(client); - case X_SyncDestroyFence: - return ProcSyncDestroyFence(client); - case X_SyncQueryFence: - return ProcSyncQueryFence(client); - case X_SyncAwaitFence: - return ProcSyncAwaitFence(client); - default: - return BadRequest; - } -} - -/* - * Boring Swapping stuff ... - */ - -static int -SProcSyncInitialize(ClientPtr client) -{ - REQUEST(xSyncInitializeReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncInitializeReq); - - return ProcSyncInitialize(client); -} - -static int -SProcSyncListSystemCounters(ClientPtr client) -{ - REQUEST(xSyncListSystemCountersReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncListSystemCountersReq); - - return ProcSyncListSystemCounters(client); -} - -static int -SProcSyncCreateCounter(ClientPtr client) -{ - REQUEST(xSyncCreateCounterReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncCreateCounterReq); - swapl(&stuff->cid, n); - swapl(&stuff->initial_value_lo, n); - swapl(&stuff->initial_value_hi, n); - - return ProcSyncCreateCounter(client); -} - -static int -SProcSyncSetCounter(ClientPtr client) -{ - REQUEST(xSyncSetCounterReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncSetCounterReq); - swapl(&stuff->cid, n); - swapl(&stuff->value_lo, n); - swapl(&stuff->value_hi, n); - - return ProcSyncSetCounter(client); -} - -static int -SProcSyncChangeCounter(ClientPtr client) -{ - REQUEST(xSyncChangeCounterReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncChangeCounterReq); - swapl(&stuff->cid, n); - swapl(&stuff->value_lo, n); - swapl(&stuff->value_hi, n); - - return ProcSyncChangeCounter(client); -} - -static int -SProcSyncQueryCounter(ClientPtr client) -{ - REQUEST(xSyncQueryCounterReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncQueryCounterReq); - swapl(&stuff->counter, n); - - return ProcSyncQueryCounter(client); -} - -static int -SProcSyncDestroyCounter(ClientPtr client) -{ - REQUEST(xSyncDestroyCounterReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncDestroyCounterReq); - swapl(&stuff->counter, n); - - return ProcSyncDestroyCounter(client); -} - -static int -SProcSyncAwait(ClientPtr client) -{ - REQUEST(xSyncAwaitReq); - char n; - - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xSyncAwaitReq); - SwapRestL(stuff); - - return ProcSyncAwait(client); -} - -static int -SProcSyncCreateAlarm(ClientPtr client) -{ - REQUEST(xSyncCreateAlarmReq); - char n; - - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq); - swapl(&stuff->id, n); - swapl(&stuff->valueMask, n); - SwapRestL(stuff); - - return ProcSyncCreateAlarm(client); -} - -static int -SProcSyncChangeAlarm(ClientPtr client) -{ - REQUEST(xSyncChangeAlarmReq); - char n; - - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); - swapl(&stuff->alarm, n); - swapl(&stuff->valueMask, n); - SwapRestL(stuff); - return ProcSyncChangeAlarm(client); -} - -static int -SProcSyncQueryAlarm(ClientPtr client) -{ - REQUEST(xSyncQueryAlarmReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncQueryAlarmReq); - swapl(&stuff->alarm, n); - - return ProcSyncQueryAlarm(client); -} - -static int -SProcSyncDestroyAlarm(ClientPtr client) -{ - REQUEST(xSyncDestroyAlarmReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncDestroyAlarmReq); - swapl(&stuff->alarm, n); - - return ProcSyncDestroyAlarm(client); -} - -static int -SProcSyncSetPriority(ClientPtr client) -{ - REQUEST(xSyncSetPriorityReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncSetPriorityReq); - swapl(&stuff->id, n); - swapl(&stuff->priority, n); - - return ProcSyncSetPriority(client); -} - -static int -SProcSyncGetPriority(ClientPtr client) -{ - REQUEST(xSyncGetPriorityReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncGetPriorityReq); - swapl(&stuff->id, n); - - return ProcSyncGetPriority(client); -} - -static int -SProcSyncCreateFence(ClientPtr client) -{ - REQUEST(xSyncCreateFenceReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncCreateFenceReq); - swapl(&stuff->fid, n); - - return ProcSyncCreateFence(client); -} - -static int -SProcSyncTriggerFence(ClientPtr client) -{ - REQUEST(xSyncTriggerFenceReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncTriggerFenceReq); - swapl(&stuff->fid, n); - - return ProcSyncTriggerFence(client); -} - -static int -SProcSyncResetFence(ClientPtr client) -{ - REQUEST(xSyncResetFenceReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncResetFenceReq); - swapl(&stuff->fid, n); - - return ProcSyncResetFence(client); -} - -static int -SProcSyncDestroyFence(ClientPtr client) -{ - REQUEST(xSyncDestroyFenceReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncDestroyFenceReq); - swapl(&stuff->fid, n); - - return ProcSyncDestroyFence(client); -} - -static int -SProcSyncQueryFence(ClientPtr client) -{ - REQUEST(xSyncQueryFenceReq); - char n; - - swaps(&stuff->length, n); - REQUEST_SIZE_MATCH (xSyncQueryFenceReq); - swapl(&stuff->fid, n); - - return ProcSyncQueryFence(client); -} - -static int -SProcSyncAwaitFence(ClientPtr client) -{ - REQUEST(xSyncAwaitFenceReq); - char n; - - swaps(&stuff->length, n); - REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq); - SwapRestL(stuff); - - return ProcSyncAwaitFence(client); -} - -static int -SProcSyncDispatch(ClientPtr client) -{ - REQUEST(xReq); - - switch (stuff->data) - { - case X_SyncInitialize: - return SProcSyncInitialize(client); - case X_SyncListSystemCounters: - return SProcSyncListSystemCounters(client); - case X_SyncCreateCounter: - return SProcSyncCreateCounter(client); - case X_SyncSetCounter: - return SProcSyncSetCounter(client); - case X_SyncChangeCounter: - return SProcSyncChangeCounter(client); - case X_SyncQueryCounter: - return SProcSyncQueryCounter(client); - case X_SyncDestroyCounter: - return SProcSyncDestroyCounter(client); - case X_SyncAwait: - return SProcSyncAwait(client); - case X_SyncCreateAlarm: - return SProcSyncCreateAlarm(client); - case X_SyncChangeAlarm: - return SProcSyncChangeAlarm(client); - case X_SyncQueryAlarm: - return SProcSyncQueryAlarm(client); - case X_SyncDestroyAlarm: - return SProcSyncDestroyAlarm(client); - case X_SyncSetPriority: - return SProcSyncSetPriority(client); - case X_SyncGetPriority: - return SProcSyncGetPriority(client); - case X_SyncCreateFence: - return SProcSyncCreateFence(client); - case X_SyncTriggerFence: - return SProcSyncTriggerFence(client); - case X_SyncResetFence: - return SProcSyncResetFence(client); - case X_SyncDestroyFence: - return SProcSyncDestroyFence(client); - case X_SyncQueryFence: - return SProcSyncQueryFence(client); - case X_SyncAwaitFence: - return SProcSyncAwaitFence(client); - default: - return BadRequest; - } -} - -/* - * Event Swapping - */ - -static void -SCounterNotifyEvent(xSyncCounterNotifyEvent *from, xSyncCounterNotifyEvent *to) -{ - to->type = from->type; - to->kind = from->kind; - cpswaps(from->sequenceNumber, to->sequenceNumber); - cpswapl(from->counter, to->counter); - cpswapl(from->wait_value_lo, to->wait_value_lo); - cpswapl(from->wait_value_hi, to->wait_value_hi); - cpswapl(from->counter_value_lo, to->counter_value_lo); - cpswapl(from->counter_value_hi, to->counter_value_hi); - cpswapl(from->time, to->time); - cpswaps(from->count, to->count); - to->destroyed = from->destroyed; -} - - -static void -SAlarmNotifyEvent(xSyncAlarmNotifyEvent *from, xSyncAlarmNotifyEvent *to) -{ - to->type = from->type; - to->kind = from->kind; - cpswaps(from->sequenceNumber, to->sequenceNumber); - cpswapl(from->alarm, to->alarm); - cpswapl(from->counter_value_lo, to->counter_value_lo); - cpswapl(from->counter_value_hi, to->counter_value_hi); - cpswapl(from->alarm_value_lo, to->alarm_value_lo); - cpswapl(from->alarm_value_hi, to->alarm_value_hi); - cpswapl(from->time, to->time); - to->state = from->state; -} - -/* - * ** Close everything down. ** This is fairly simple for now. - */ -/* ARGSUSED */ -static void -SyncResetProc(ExtensionEntry *extEntry) -{ - free(SysCounterList); - SysCounterList = NULL; - RTCounter = 0; -} - -/* - * ** Initialise the extension. - */ -void -SyncExtensionInit(void) -{ - ExtensionEntry *extEntry; - int s; - - for (s = 0; s < screenInfo.numScreens; s++) - miSyncSetup(screenInfo.screens[s]); - - if (RTCounter == 0) - { - RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter"); - } - RTAlarm = CreateNewResourceType(FreeAlarm, "SyncAlarm"); - RTAwait = CreateNewResourceType(FreeAwait, "SyncAwait"); - RTFence = CreateNewResourceType(FreeFence, "SyncFence"); - if (RTAwait) - RTAwait |= RC_NEVERRETAIN; - RTAlarmClient = CreateNewResourceType(FreeAlarmClient, "SyncAlarmClient"); - if (RTAlarmClient) - RTAlarmClient |= RC_NEVERRETAIN; - - if (RTCounter == 0 || RTAwait == 0 || RTAlarm == 0 || - RTAlarmClient == 0 || - (extEntry = AddExtension(SYNC_NAME, - XSyncNumberEvents, XSyncNumberErrors, - ProcSyncDispatch, SProcSyncDispatch, - SyncResetProc, - StandardMinorOpcode)) == NULL) - { - ErrorF("Sync Extension %d.%d failed to Initialise\n", - SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION); - return; - } - - SyncEventBase = extEntry->eventBase; - SyncErrorBase = extEntry->errorBase; - EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent; - EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent; - - SetResourceTypeErrorValue(RTCounter, SyncErrorBase + XSyncBadCounter); - SetResourceTypeErrorValue(RTAlarm, SyncErrorBase + XSyncBadAlarm); - SetResourceTypeErrorValue(RTFence, SyncErrorBase + XSyncBadFence); - - /* - * Although SERVERTIME is implemented by the OS layer, we initialise it - * here because doing it in OsInit() is too early. The resource database - * is not initialised when OsInit() is called. This is just about OK - * because there is always a servertime counter. - */ - SyncInitServerTime(); - SyncInitIdleTime(); - -#ifdef DEBUG - fprintf(stderr, "Sync Extension %d.%d\n", - SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION); -#endif -} - - -/* - * ***** SERVERTIME implementation - should go in its own file in OS directory? - */ - - - -static pointer ServertimeCounter; -static XSyncValue Now; -static XSyncValue *pnext_time; - -#define GetTime()\ -{\ - unsigned long millis = GetTimeInMillis();\ - unsigned long maxis = XSyncValueHigh32(Now);\ - if (millis < XSyncValueLow32(Now)) maxis++;\ - XSyncIntsToValue(&Now, millis, maxis);\ -} - -/* -*** Server Block Handler -*** code inspired by multibuffer extension (now deprecated) - */ -/*ARGSUSED*/ -static void -ServertimeBlockHandler(void *env, struct timeval **wt, void *LastSelectMask) -{ - XSyncValue delay; - unsigned long timeout; - - if (pnext_time) - { - GetTime(); - - if (XSyncValueGreaterOrEqual(Now, *pnext_time)) - { - timeout = 0; - } - else - { - Bool overflow; - XSyncValueSubtract(&delay, *pnext_time, Now, &overflow); - (void)overflow; - timeout = XSyncValueLow32(delay); - } - AdjustWaitForDelay(wt, timeout); /* os/utils.c */ - } -} - -/* -*** Wakeup Handler - */ -/*ARGSUSED*/ -static void -ServertimeWakeupHandler(void *env, int rc, void *LastSelectMask) -{ - if (pnext_time) - { - GetTime(); - - if (XSyncValueGreaterOrEqual(Now, *pnext_time)) - { - SyncChangeCounter(ServertimeCounter, Now); - } - } -} - -static void -ServertimeQueryValue(void *pCounter, CARD64 *pValue_return) -{ - GetTime(); - *pValue_return = Now; -} - -static void -ServertimeBracketValues(void *pCounter, CARD64 *pbracket_less, - CARD64 *pbracket_greater) -{ - if (!pnext_time && pbracket_greater) - { - RegisterBlockAndWakeupHandlers(ServertimeBlockHandler, - ServertimeWakeupHandler, - NULL); - } - else if (pnext_time && !pbracket_greater) - { - RemoveBlockAndWakeupHandlers(ServertimeBlockHandler, - ServertimeWakeupHandler, - NULL); - } - pnext_time = pbracket_greater; -} - -static void -SyncInitServerTime(void) -{ - CARD64 resolution; - - XSyncIntsToValue(&Now, GetTimeInMillis(), 0); - XSyncIntToValue(&resolution, 4); - ServertimeCounter = SyncCreateSystemCounter("SERVERTIME", Now, resolution, - XSyncCounterNeverDecreases, - ServertimeQueryValue, ServertimeBracketValues); - pnext_time = NULL; -} - - - -/* - * IDLETIME implementation - */ - -static SyncCounter *IdleTimeCounter; -static XSyncValue *pIdleTimeValueLess; -static XSyncValue *pIdleTimeValueGreater; - -static void -IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return) -{ - CARD32 idle = GetTimeInMillis() - lastDeviceEventTime.milliseconds; - XSyncIntsToValue (pValue_return, idle, 0); -} - -static void -IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask) -{ - XSyncValue idle, old_idle; - SyncTriggerList *list = IdleTimeCounter->sync.pTriglist; - SyncTrigger *trig; - - if (!pIdleTimeValueLess && !pIdleTimeValueGreater) - return; - - old_idle = IdleTimeCounter->value; - IdleTimeQueryValue (NULL, &idle); - IdleTimeCounter->value = idle; /* push, so CheckTrigger works */ - - if (pIdleTimeValueLess && - XSyncValueLessOrEqual (idle, *pIdleTimeValueLess)) - { - /* - * 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 - * want level or edge trigger. Check the trigger list against the - * current idle time, and if any succeed, bomb out of select() - * immediately so we can reschedule. - */ - - for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) { - trig = list->pTrigger; - if (trig->CheckTrigger(trig, old_idle)) { - AdjustWaitForDelay(wt, 0); - break; - } - } - /* - * We've been called exactly on the idle time, but we have a - * NegativeTransition trigger which requires a transition from an - * idle time greater than this. Schedule a wakeup for the next - * millisecond so we won't miss a transition. - */ - if (XSyncValueEqual (idle, *pIdleTimeValueLess)) - AdjustWaitForDelay(wt, 1); - } - else if (pIdleTimeValueGreater) - { - /* - * There's a threshold in the positive direction. If we've been - * idle less than it, schedule a wakeup for sometime in the future. - * If we've been idle more than it, and someone wants to know about - * that level-triggered, schedule an immediate wakeup. - */ - unsigned long timeout = -1; - - if (XSyncValueLessThan (idle, *pIdleTimeValueGreater)) { - XSyncValue value; - Bool overflow; - - XSyncValueSubtract (&value, *pIdleTimeValueGreater, - idle, &overflow); - timeout = min(timeout, XSyncValueLow32 (value)); - } else { - for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) { - trig = list->pTrigger; - if (trig->CheckTrigger(trig, old_idle)) { - timeout = min(timeout, 0); - break; - } - } - } - - AdjustWaitForDelay (wt, timeout); - } - - IdleTimeCounter->value = old_idle; /* pop */ -} - -static void -IdleTimeWakeupHandler (pointer env, int rc, pointer LastSelectMask) -{ - XSyncValue idle; - - if (!pIdleTimeValueLess && !pIdleTimeValueGreater) - return; - - IdleTimeQueryValue (NULL, &idle); - - if ((pIdleTimeValueGreater && - XSyncValueGreaterOrEqual (idle, *pIdleTimeValueGreater)) || - (pIdleTimeValueLess && - XSyncValueLessOrEqual (idle, *pIdleTimeValueLess))) - { - SyncChangeCounter (IdleTimeCounter, idle); - } -} - -static void -IdleTimeBracketValues (pointer pCounter, CARD64 *pbracket_less, - CARD64 *pbracket_greater) -{ - Bool registered = (pIdleTimeValueLess || pIdleTimeValueGreater); - - if (registered && !pbracket_less && !pbracket_greater) - { - RemoveBlockAndWakeupHandlers(IdleTimeBlockHandler, - IdleTimeWakeupHandler, - NULL); - } - else if (!registered && (pbracket_less || pbracket_greater)) - { - RegisterBlockAndWakeupHandlers(IdleTimeBlockHandler, - IdleTimeWakeupHandler, - NULL); - } - - pIdleTimeValueGreater = pbracket_greater; - pIdleTimeValueLess = pbracket_less; -} - -static void -SyncInitIdleTime (void) -{ - CARD64 resolution; - XSyncValue idle; - - IdleTimeQueryValue (NULL, &idle); - XSyncIntToValue (&resolution, 4); - - IdleTimeCounter = SyncCreateSystemCounter ("IDLETIME", idle, resolution, - XSyncCounterUnrestricted, - IdleTimeQueryValue, - IdleTimeBracketValues); - - pIdleTimeValueLess = pIdleTimeValueGreater = NULL; -} +/* + +Copyright 1991, 1993, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice 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 OPEN GROUP 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. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + + +Copyright 1991, 1993 by Digital Equipment Corporation, Maynard, Massachusetts, +and Olivetti Research Limited, Cambridge, England. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Digital or Olivetti +not be used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. Digital and Olivetti +make no representations about the suitability of this software +for any purpose. It is provided "as is" without express or implied warranty. + +DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +*/ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include + +#include +#include +#include +#include "scrnintstr.h" +#include "os.h" +#include "extnsionst.h" +#include "dixstruct.h" +#include "pixmapstr.h" +#include "resource.h" +#include "opaque.h" +#include +#include "syncsrv.h" +#include "syncsdk.h" +#include "protocol-versions.h" + +#include +#if !defined(WIN32) +#include +#endif + +#include "modinit.h" + +/* + * Local Global Variables + */ +static int SyncEventBase; +static int SyncErrorBase; +static RESTYPE RTCounter = 0; +static RESTYPE RTAwait; +static RESTYPE RTAlarm; +static RESTYPE RTAlarmClient; +static RESTYPE RTFence; +static int SyncNumSystemCounters = 0; +static SyncCounter **SysCounterList = NULL; +static int SyncNumInvalidCounterWarnings = 0; +#define MAX_INVALID_COUNTER_WARNINGS 5 + +static const char *WARN_INVALID_COUNTER_COMPARE = +"Warning: Non-counter XSync object using Counter-only\n" +" comparison. Result will never be true.\n"; + +static const char *WARN_INVALID_COUNTER_ALARM = +"Warning: Non-counter XSync object used in alarm. This is\n" +" the result of a programming error in the X server.\n"; + +#define IsSystemCounter(pCounter) \ + (pCounter && (pCounter->sync.client == NULL)) + +/* these are all the alarm attributes that pertain to the alarm's trigger */ +#define XSyncCAAllTrigger \ + (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType) + +static void SyncComputeBracketValues(SyncCounter *); + +static void SyncInitServerTime(void); + +static void SyncInitIdleTime(void); + +static Bool +SyncCheckWarnIsCounter(const SyncObject* pSync, const char *warning) +{ + if (pSync && (SYNC_COUNTER != pSync->type)) + { + if (SyncNumInvalidCounterWarnings++ < MAX_INVALID_COUNTER_WARNINGS) + { + ErrorF("%s", warning); + ErrorF(" Counter type: %d\n", pSync->type); + } + + return FALSE; + } + + return TRUE; +} + +/* Each counter maintains a simple linked list of triggers that are + * interested in the counter. The two functions below are used to + * delete and add triggers on this list. + */ +static void +SyncDeleteTriggerFromSyncObject(SyncTrigger *pTrigger) +{ + SyncTriggerList *pCur; + SyncTriggerList *pPrev; + SyncCounter *pCounter; + + /* pSync needs to be stored in pTrigger before calling here. */ + + if (!pTrigger->pSync) + return; + + pPrev = NULL; + pCur = pTrigger->pSync->pTriglist; + + while (pCur) + { + if (pCur->pTrigger == pTrigger) + { + if (pPrev) + pPrev->next = pCur->next; + else + pTrigger->pSync->pTriglist = pCur->next; + + free(pCur); + break; + } + + pPrev = pCur; + pCur = pCur->next; + } + + if (SYNC_COUNTER == pTrigger->pSync->type) + { + pCounter = (SyncCounter *)pTrigger->pSync; + + if (IsSystemCounter(pCounter)) + SyncComputeBracketValues(pCounter); + } else if (SYNC_FENCE == pTrigger->pSync->type) { + SyncFence* pFence = (SyncFence*) pTrigger->pSync; + pFence->funcs.DeleteTrigger(pTrigger); + } +} + + +static int +SyncAddTriggerToSyncObject(SyncTrigger *pTrigger) +{ + SyncTriggerList *pCur; + SyncCounter *pCounter; + + if (!pTrigger->pSync) + return Success; + + /* don't do anything if it's already there */ + for (pCur = pTrigger->pSync->pTriglist; pCur; pCur = pCur->next) + { + if (pCur->pTrigger == pTrigger) + return Success; + } + + if (!(pCur = malloc(sizeof(SyncTriggerList)))) + return BadAlloc; + + pCur->pTrigger = pTrigger; + pCur->next = pTrigger->pSync->pTriglist; + pTrigger->pSync->pTriglist = pCur; + + if (SYNC_COUNTER == pTrigger->pSync->type) + { + pCounter = (SyncCounter *)pTrigger->pSync; + + if (IsSystemCounter(pCounter)) + SyncComputeBracketValues(pCounter); + } else if (SYNC_FENCE == pTrigger->pSync->type) { + SyncFence* pFence = (SyncFence*) pTrigger->pSync; + pFence->funcs.AddTrigger(pTrigger); + } + + return Success; +} + + +/* Below are five possible functions that can be plugged into + * pTrigger->CheckTrigger for counter sync objects, corresponding to + * the four possible test-types, and the one possible function that + * can be plugged into pTrigger->CheckTrigger for fence sync objects. + * These functions are called after the sync object's state changes + * but are also passed the old state so they can inspect both the old + * and new values. (PositiveTransition and NegativeTransition need to + * see both pieces of information.) These functions return the truth + * value of the trigger. + * + * All of them include the condition pTrigger->pSync == NULL. + * This is because the spec says that a trigger with a sync value + * of None is always TRUE. + */ + +static Bool +SyncCheckTriggerPositiveComparison(SyncTrigger *pTrigger, CARD64 oldval) +{ + SyncCounter *pCounter; + + /* Non-counter sync objects should never get here because they + * never trigger this comparison. */ + if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_COMPARE)) + return FALSE; + + pCounter = (SyncCounter *)pTrigger->pSync; + + return (pCounter == NULL || + XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value)); +} + +static Bool +SyncCheckTriggerNegativeComparison(SyncTrigger *pTrigger, CARD64 oldval) +{ + SyncCounter *pCounter; + + /* Non-counter sync objects should never get here because they + * never trigger this comparison. */ + if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_COMPARE)) + return FALSE; + + pCounter = (SyncCounter *)pTrigger->pSync; + + return (pCounter == NULL || + XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value)); +} + +static Bool +SyncCheckTriggerPositiveTransition(SyncTrigger *pTrigger, CARD64 oldval) +{ + SyncCounter *pCounter; + + /* Non-counter sync objects should never get here because they + * never trigger this comparison. */ + if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_COMPARE)) + return FALSE; + + pCounter = (SyncCounter *)pTrigger->pSync; + + return (pCounter == NULL || + (XSyncValueLessThan(oldval, pTrigger->test_value) && + XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value))); +} + +static Bool +SyncCheckTriggerNegativeTransition(SyncTrigger *pTrigger, CARD64 oldval) +{ + SyncCounter *pCounter; + + /* Non-counter sync objects should never get here because they + * never trigger this comparison. */ + if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_COMPARE)) + return FALSE; + + pCounter = (SyncCounter *)pTrigger->pSync; + + return (pCounter == NULL || + (XSyncValueGreaterThan(oldval, pTrigger->test_value) && + XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value))); +} + +static Bool +SyncCheckTriggerFence(SyncTrigger *pTrigger, CARD64 unused) +{ + SyncFence* pFence = (SyncFence*) pTrigger->pSync; + (void)unused; + + return (pFence == NULL || + pFence->funcs.CheckTriggered(pFence)); +} + +static int +SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XID syncObject, + RESTYPE resType, Mask changes) +{ + SyncObject *pSync = pTrigger->pSync; + SyncCounter *pCounter = NULL; + int rc; + Bool newSyncObject = FALSE; + + if (changes & XSyncCACounter) + { + if (syncObject == None) + pSync = NULL; + else if (Success != (rc = dixLookupResourceByType ((pointer *)&pSync, + syncObject, resType, client, DixReadAccess))) + { + client->errorValue = syncObject; + return rc; + } + if (pSync != pTrigger->pSync) + { /* new counter for trigger */ + SyncDeleteTriggerFromSyncObject(pTrigger); + pTrigger->pSync = pSync; + newSyncObject = TRUE; + } + } + + /* if system counter, ask it what the current value is */ + + if (pSync && SYNC_COUNTER == pSync->type) + { + pCounter = (SyncCounter *)pSync; + + if (IsSystemCounter(pCounter)) + { + (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter, + &pCounter->value); + } + } + + if (changes & XSyncCAValueType) + { + if (pTrigger->value_type != XSyncRelative && + pTrigger->value_type != XSyncAbsolute) + { + client->errorValue = pTrigger->value_type; + return BadValue; + } + } + + if (changes & XSyncCATestType) + { + + if (pSync && SYNC_FENCE == pSync->type) + { + pTrigger->CheckTrigger = SyncCheckTriggerFence; + } + else + { + /* select appropriate CheckTrigger function */ + + switch (pTrigger->test_type) + { + case XSyncPositiveTransition: + pTrigger->CheckTrigger = SyncCheckTriggerPositiveTransition; + break; + case XSyncNegativeTransition: + pTrigger->CheckTrigger = SyncCheckTriggerNegativeTransition; + break; + case XSyncPositiveComparison: + pTrigger->CheckTrigger = SyncCheckTriggerPositiveComparison; + break; + case XSyncNegativeComparison: + pTrigger->CheckTrigger = SyncCheckTriggerNegativeComparison; + break; + default: + client->errorValue = pTrigger->test_type; + return BadValue; + } + } + } + + if (changes & (XSyncCAValueType | XSyncCAValue)) + { + if (pTrigger->value_type == XSyncAbsolute) + pTrigger->test_value = pTrigger->wait_value; + else /* relative */ + { + Bool overflow; + if (pCounter == NULL) + return BadMatch; + + XSyncValueAdd(&pTrigger->test_value, pCounter->value, + pTrigger->wait_value, &overflow); + if (overflow) + { + client->errorValue = XSyncValueHigh32(pTrigger->wait_value); + return BadValue; + } + } + } + + /* we wait until we're sure there are no errors before registering + * a new counter on a trigger + */ + if (newSyncObject) + { + if ((rc = SyncAddTriggerToSyncObject(pTrigger)) != Success) + return rc; + } + else if (pCounter && IsSystemCounter(pCounter)) + { + SyncComputeBracketValues(pCounter); + } + + return Success; +} + +/* AlarmNotify events happen in response to actions taken on an Alarm or + * the counter used by the alarm. AlarmNotify may be sent to multiple + * clients. The alarm maintains a list of clients interested in events. + */ +static void +SyncSendAlarmNotifyEvents(SyncAlarm *pAlarm) +{ + SyncAlarmClientList *pcl; + xSyncAlarmNotifyEvent ane; + SyncTrigger *pTrigger = &pAlarm->trigger; + SyncCounter *pCounter; + + if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_ALARM)) + return; + + pCounter = (SyncCounter *)pTrigger->pSync; + + UpdateCurrentTime(); + + ane.type = SyncEventBase + XSyncAlarmNotify; + ane.kind = XSyncAlarmNotify; + ane.alarm = pAlarm->alarm_id; + 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? */ + 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); + + /* send to other interested clients */ + for (pcl = pAlarm->pEventClients; pcl; pcl = pcl->next) + WriteEventsToClient(pcl->client, 1, (xEvent *) &ane); +} + + +/* CounterNotify events only occur in response to an Await. The events + * go only to the Awaiting client. + */ +static void +SyncSendCounterNotifyEvents(ClientPtr client, SyncAwait **ppAwait, + int num_events) +{ + xSyncCounterNotifyEvent *pEvents, *pev; + int i; + + if (client->clientGone) + return; + pev = pEvents = malloc(num_events * sizeof(xSyncCounterNotifyEvent)); + if (!pEvents) + return; + UpdateCurrentTime(); + for (i = 0; i < num_events; i++, ppAwait++, pev++) + { + SyncTrigger *pTrigger = &(*ppAwait)->trigger; + pev->type = SyncEventBase + XSyncCounterNotify; + pev->kind = XSyncCounterNotify; + pev->counter = pTrigger->pSync->id; + pev->wait_value_lo = XSyncValueLow32(pTrigger->test_value); + pev->wait_value_hi = XSyncValueHigh32(pTrigger->test_value); + if (SYNC_COUNTER == pTrigger->pSync->type) + { + SyncCounter *pCounter = (SyncCounter *)pTrigger->pSync; + + pev->counter_value_lo = XSyncValueLow32(pCounter->value); + pev->counter_value_hi = XSyncValueHigh32(pCounter->value); + } + else + { + pev->counter_value_lo = 0; + pev->counter_value_hi = 0; + } + + pev->time = currentTime.milliseconds; + pev->count = num_events - i - 1; /* events remaining */ + pev->destroyed = pTrigger->pSync->beingDestroyed; + } + /* swapping will be taken care of by this */ + WriteEventsToClient(client, num_events, (xEvent *)pEvents); + free(pEvents); +} + + +/* This function is called when an alarm's counter is destroyed. + * It is plugged into pTrigger->CounterDestroyed (for alarm triggers). + */ +static void +SyncAlarmCounterDestroyed(SyncTrigger *pTrigger) +{ + SyncAlarm *pAlarm = (SyncAlarm *)pTrigger; + + pAlarm->state = XSyncAlarmInactive; + SyncSendAlarmNotifyEvents(pAlarm); + pTrigger->pSync = NULL; +} + + +/* This function is called when an alarm "goes off." + * It is plugged into pTrigger->TriggerFired (for alarm triggers). + */ +static void +SyncAlarmTriggerFired(SyncTrigger *pTrigger) +{ + SyncAlarm *pAlarm = (SyncAlarm *)pTrigger; + SyncCounter *pCounter; + CARD64 new_test_value; + + if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_ALARM)) + return; + + pCounter = (SyncCounter *)pTrigger->pSync; + + /* no need to check alarm unless it's active */ + if (pAlarm->state != XSyncAlarmActive) + return; + + /* " if the counter value is None, or if the delta is 0 and + * the test-type is PositiveComparison or NegativeComparison, + * no change is made to value (test-value) and the alarm + * state is changed to Inactive before the event is generated." + */ + if (pCounter == NULL + || (XSyncValueIsZero(pAlarm->delta) + && (pAlarm->trigger.test_type == XSyncPositiveComparison + || pAlarm->trigger.test_type == XSyncNegativeComparison))) + pAlarm->state = XSyncAlarmInactive; + + new_test_value = pAlarm->trigger.test_value; + + if (pAlarm->state == XSyncAlarmActive) + { + Bool overflow; + CARD64 oldvalue; + SyncTrigger *paTrigger = &pAlarm->trigger; + SyncCounter *paCounter; + + if (!SyncCheckWarnIsCounter(paTrigger->pSync, + WARN_INVALID_COUNTER_ALARM)) + return; + + paCounter = (SyncCounter *)pTrigger->pSync; + + /* "The alarm is updated by repeatedly adding delta to the + * value of the trigger and re-initializing it until it + * becomes FALSE." + */ + oldvalue = paTrigger->test_value; + + /* XXX really should do something smarter here */ + + do + { + XSyncValueAdd(&paTrigger->test_value, paTrigger->test_value, + pAlarm->delta, &overflow); + } while (!overflow && + (*paTrigger->CheckTrigger)(paTrigger, + paCounter->value)); + + new_test_value = paTrigger->test_value; + paTrigger->test_value = oldvalue; + + /* "If this update would cause value to fall outside the range + * for an INT64...no change is made to value (test-value) and + * the alarm state is changed to Inactive before the event is + * generated." + */ + if (overflow) + { + new_test_value = oldvalue; + pAlarm->state = XSyncAlarmInactive; + } + } + /* The AlarmNotify event has to have the "new state of the alarm" + * which we can't be sure of until this point. However, it has + * to have the "old" trigger test value. That's the reason for + * all the newvalue/oldvalue shuffling above. After we send the + * events, give the trigger its new test value. + */ + SyncSendAlarmNotifyEvents(pAlarm); + pTrigger->test_value = new_test_value; +} + + +/* This function is called when an Await unblocks, either as a result + * of the trigger firing OR the counter being destroyed. + * It goes into pTrigger->TriggerFired AND pTrigger->CounterDestroyed + * (for Await triggers). + */ +static void +SyncAwaitTriggerFired(SyncTrigger *pTrigger) +{ + SyncAwait *pAwait = (SyncAwait *)pTrigger; + int numwaits; + SyncAwaitUnion *pAwaitUnion; + SyncAwait **ppAwait; + int num_events = 0; + + pAwaitUnion = (SyncAwaitUnion *)pAwait->pHeader; + numwaits = pAwaitUnion->header.num_waitconditions; + ppAwait = malloc(numwaits * sizeof(SyncAwait *)); + if (!ppAwait) + goto bail; + + pAwait = &(pAwaitUnion+1)->await; + + /* "When a client is unblocked, all the CounterNotify events for + * the Await request are generated contiguously. If count is 0 + * there are no more events to follow for this request. If + * count is n, there are at least n more events to follow." + * + * Thus, it is best to find all the counters for which events + * need to be sent first, so that an accurate count field can + * be stored in the events. + */ + for ( ; numwaits; numwaits--, pAwait++) + { + CARD64 diff; + Bool overflow, diffgreater, diffequal; + + /* "A CounterNotify event with the destroyed flag set to TRUE is + * always generated if the counter for one of the triggers is + * destroyed." + */ + if (pAwait->trigger.pSync->beingDestroyed) + { + ppAwait[num_events++] = pAwait; + continue; + } + + if (SYNC_COUNTER == pAwait->trigger.pSync->type) + { + SyncCounter *pCounter = (SyncCounter *) pAwait->trigger.pSync; + + /* "The difference between the counter and the test value is + * calculated by subtracting the test value from the value of + * the counter." + */ + XSyncValueSubtract(&diff, pCounter->value, + pAwait->trigger.test_value, &overflow); + + /* "If the difference lies outside the range for an INT64, an + * event is not generated." + */ + if (overflow) + continue; + diffgreater = XSyncValueGreaterThan(diff, pAwait->event_threshold); + diffequal = XSyncValueEqual(diff, pAwait->event_threshold); + + /* "If the test-type is PositiveTransition or + * PositiveComparison, a CounterNotify event is generated if + * the difference is at least event-threshold. If the test-type + * is NegativeTransition or NegativeComparison, a CounterNotify + * event is generated if the difference is at most + * event-threshold." + */ + + if ( ((pAwait->trigger.test_type == XSyncPositiveComparison || + pAwait->trigger.test_type == XSyncPositiveTransition) + && (diffgreater || diffequal)) + || + ((pAwait->trigger.test_type == XSyncNegativeComparison || + pAwait->trigger.test_type == XSyncNegativeTransition) + && (!diffgreater) /* less or equal */ + ) + ) + { + ppAwait[num_events++] = pAwait; + } + } + } + if (num_events) + SyncSendCounterNotifyEvents(pAwaitUnion->header.client, ppAwait, + num_events); + free(ppAwait); + +bail: + /* unblock the client */ + AttendClient(pAwaitUnion->header.client); + /* delete the await */ + FreeResource(pAwaitUnion->header.delete_id, RT_NONE); +} + + +/* This function should always be used to change a counter's value so that + * any triggers depending on the counter will be checked. + */ +void +SyncChangeCounter(SyncCounter *pCounter, CARD64 newval) +{ + SyncTriggerList *ptl, *pnext; + CARD64 oldval; + + oldval = pCounter->value; + pCounter->value = newval; + + /* run through triggers to see if any become true */ + for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext) + { + pnext = ptl->next; + if ((*ptl->pTrigger->CheckTrigger)(ptl->pTrigger, oldval)) + (*ptl->pTrigger->TriggerFired)(ptl->pTrigger); + } + + if (IsSystemCounter(pCounter)) + { + SyncComputeBracketValues(pCounter); + } +} + + +/* loosely based on dix/events.c/EventSelectForWindow */ +static Bool +SyncEventSelectForAlarm(SyncAlarm *pAlarm, ClientPtr client, Bool wantevents) +{ + SyncAlarmClientList *pClients; + + if (client == pAlarm->client) /* alarm owner */ + { + pAlarm->events = wantevents; + return Success; + } + + /* see if the client is already on the list (has events selected) */ + + for (pClients = pAlarm->pEventClients; pClients; + pClients = pClients->next) + { + if (pClients->client == client) + { + /* client's presence on the list indicates desire for + * events. If the client doesn't want events, remove it + * from the list. If the client does want events, do + * nothing, since it's already got them. + */ + if (!wantevents) + { + FreeResource(pClients->delete_id, RT_NONE); + } + return Success; + } + } + + /* if we get here, this client does not currently have + * events selected on the alarm + */ + + if (!wantevents) + /* client doesn't want events, and we just discovered that it + * doesn't have them, so there's nothing to do. + */ + return Success; + + /* add new client to pAlarm->pEventClients */ + + pClients = malloc(sizeof(SyncAlarmClientList)); + if (!pClients) + return BadAlloc; + + /* register it as a resource so it will be cleaned up + * if the client dies + */ + + pClients->delete_id = FakeClientID(client->index); + + /* link it into list after we know all the allocations succeed */ + pClients->next = pAlarm->pEventClients; + pAlarm->pEventClients = pClients; + pClients->client = client; + + if (!AddResource(pClients->delete_id, RTAlarmClient, pAlarm)) + return BadAlloc; + + return Success; +} + +/* + * ** SyncChangeAlarmAttributes ** This is used by CreateAlarm and ChangeAlarm + */ +static int +SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm *pAlarm, Mask mask, + CARD32 *values) +{ + int status; + XSyncCounter counter; + Mask origmask = mask; + + counter = + pAlarm->trigger.pSync ? pAlarm->trigger.pSync->id : None; + + while (mask) + { + int index2 = lowbit(mask); + mask &= ~index2; + switch (index2) + { + case XSyncCACounter: + mask &= ~XSyncCACounter; + /* sanity check in SyncInitTrigger */ + counter = *values++; + break; + + case XSyncCAValueType: + mask &= ~XSyncCAValueType; + /* sanity check in SyncInitTrigger */ + pAlarm->trigger.value_type = *values++; + break; + + case XSyncCAValue: + mask &= ~XSyncCAValue; + XSyncIntsToValue(&pAlarm->trigger.wait_value, values[1], values[0]); + values += 2; + break; + + case XSyncCATestType: + mask &= ~XSyncCATestType; + /* sanity check in SyncInitTrigger */ + pAlarm->trigger.test_type = *values++; + break; + + case XSyncCADelta: + mask &= ~XSyncCADelta; + XSyncIntsToValue(&pAlarm->delta, values[1], values[0]); + values += 2; + break; + + case XSyncCAEvents: + mask &= ~XSyncCAEvents; + if ((*values != xTrue) && (*values != xFalse)) + { + client->errorValue = *values; + return BadValue; + } + status = SyncEventSelectForAlarm(pAlarm, client, + (Bool)(*values++)); + if (status != Success) + return status; + break; + + default: + client->errorValue = mask; + return BadValue; + } + } + + /* "If the test-type is PositiveComparison or PositiveTransition + * and delta is less than zero, or if the test-type is + * NegativeComparison or NegativeTransition and delta is + * greater than zero, a Match error is generated." + */ + if (origmask & (XSyncCADelta|XSyncCATestType)) + { + CARD64 zero; + XSyncIntToValue(&zero, 0); + if ((((pAlarm->trigger.test_type == XSyncPositiveComparison) || + (pAlarm->trigger.test_type == XSyncPositiveTransition)) + && XSyncValueLessThan(pAlarm->delta, zero)) + || + (((pAlarm->trigger.test_type == XSyncNegativeComparison) || + (pAlarm->trigger.test_type == XSyncNegativeTransition)) + && XSyncValueGreaterThan(pAlarm->delta, zero)) + ) + { + return BadMatch; + } + } + + /* postpone this until now, when we're sure nothing else can go wrong */ + if ((status = SyncInitTrigger(client, &pAlarm->trigger, counter, RTCounter, + origmask & XSyncCAAllTrigger)) != Success) + return status; + + /* XXX spec does not really say to do this - needs clarification */ + pAlarm->state = XSyncAlarmActive; + return Success; +} + +static SyncObject * +SyncCreate(ClientPtr client, XID id, unsigned char type) +{ + SyncObject *pSync; + + switch (type) { + case SYNC_COUNTER: + pSync = malloc(sizeof(SyncCounter)); + break; + case SYNC_FENCE: + pSync = (SyncObject*)dixAllocateObjectWithPrivates(SyncFence, + PRIVATE_SYNC_FENCE); + break; + default: + return NULL; + } + + if (!pSync) + return NULL; + + pSync->client = client; + pSync->id = id; + pSync->pTriglist = NULL; + pSync->beingDestroyed = FALSE; + pSync->type = type; + + return pSync; +} + + +static SyncCounter * +SyncCreateCounter(ClientPtr client, XSyncCounter id, CARD64 initialvalue) +{ + SyncCounter *pCounter; + + if (!(pCounter = (SyncCounter *)SyncCreate(client, + id, + SYNC_COUNTER))) + return NULL; + + pCounter->value = initialvalue; + pCounter->pSysCounterInfo = NULL; + + if (!AddResource(id, RTCounter, (pointer) pCounter)) + return NULL; + + return pCounter; +} + +static int FreeCounter(void *, XID); + +/* + * ***** System Counter utilities + */ + +pointer +SyncCreateSystemCounter( + 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 */) + ) +{ + 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. + */ + if (RTCounter == 0) + { + RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter"); + if (RTCounter == 0) + { + return NULL; + } + } + + pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial); + + if (pCounter) + { + SysCounterInfo *psci; + + psci = malloc(sizeof(SysCounterInfo)); + if (!psci) + { + FreeResource(pCounter->sync.id, RT_NONE); + return pCounter; + } + pCounter->pSysCounterInfo = psci; + psci->name = name; + psci->resolution = resolution; + psci->counterType = counterType; + psci->QueryValue = QueryValue; + psci->BracketValues = BracketValues; + XSyncMaxValue(&psci->bracket_greater); + XSyncMinValue(&psci->bracket_less); + SysCounterList[SyncNumSystemCounters++] = pCounter; + } + return pCounter; +} + +void +SyncDestroySystemCounter(pointer pSysCounter) +{ + SyncCounter *pCounter = (SyncCounter *)pSysCounter; + FreeResource(pCounter->sync.id, RT_NONE); +} + +static void +SyncComputeBracketValues(SyncCounter *pCounter) +{ + SyncTriggerList *pCur; + SyncTrigger *pTrigger; + SysCounterInfo *psci; + CARD64 *pnewgtval = NULL; + CARD64 *pnewltval = NULL; + SyncCounterType ct; + + if (!pCounter) + return; + + psci = pCounter->pSysCounterInfo; + ct = pCounter->pSysCounterInfo->counterType; + if (ct == XSyncCounterNeverChanges) + return; + + XSyncMaxValue(&psci->bracket_greater); + XSyncMinValue(&psci->bracket_less); + + for (pCur = pCounter->sync.pTriglist; pCur; pCur = pCur->next) + { + pTrigger = pCur->pTrigger; + + if (pTrigger->test_type == XSyncPositiveComparison && + ct != XSyncCounterNeverIncreases) + { + if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) && + XSyncValueLessThan(pTrigger->test_value, + psci->bracket_greater)) + { + psci->bracket_greater = pTrigger->test_value; + pnewgtval = &psci->bracket_greater; + } + } + else if (pTrigger->test_type == XSyncNegativeComparison && + ct != XSyncCounterNeverDecreases) + { + if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) && + XSyncValueGreaterThan(pTrigger->test_value, + psci->bracket_less)) + { + psci->bracket_less = pTrigger->test_value; + pnewltval = &psci->bracket_less; + } + } + else if (pTrigger->test_type == XSyncNegativeTransition && + ct != XSyncCounterNeverIncreases) + { + if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) && + XSyncValueGreaterThan(pTrigger->test_value, psci->bracket_less)) + { + psci->bracket_less = pTrigger->test_value; + pnewltval = &psci->bracket_less; + } else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) && + XSyncValueLessThan(pTrigger->test_value, + psci->bracket_greater)) + { + /* + * 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. + */ + psci->bracket_greater = pTrigger->test_value; + pnewgtval = &psci->bracket_greater; + } + } + else if (pTrigger->test_type == XSyncPositiveTransition && + ct != XSyncCounterNeverDecreases) + { + if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) && + XSyncValueLessThan(pTrigger->test_value, psci->bracket_greater)) + { + psci->bracket_greater = pTrigger->test_value; + pnewgtval = &psci->bracket_greater; + } else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) && + XSyncValueGreaterThan(pTrigger->test_value, + psci->bracket_less)) + { + /* + * 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. + */ + psci->bracket_less = pTrigger->test_value; + pnewltval = &psci->bracket_less; + } + } + } /* end for each trigger */ + + if (pnewgtval || pnewltval) + { + (*psci->BracketValues)((pointer)pCounter, pnewltval, pnewgtval); + } +} + +/* + * ***** Resource delete functions + */ + +/* ARGSUSED */ +static int +FreeAlarm(void *addr, XID id) +{ + SyncAlarm *pAlarm = (SyncAlarm *) addr; + + pAlarm->state = XSyncAlarmDestroyed; + + SyncSendAlarmNotifyEvents(pAlarm); + + /* delete event selections */ + + while (pAlarm->pEventClients) + FreeResource(pAlarm->pEventClients->delete_id, RT_NONE); + + SyncDeleteTriggerFromSyncObject(&pAlarm->trigger); + + free(pAlarm); + return Success; +} + + +/* + * ** Cleanup after the destruction of a Counter + */ +/* ARGSUSED */ +static int +FreeCounter(void *env, XID id) +{ + SyncCounter *pCounter = (SyncCounter *) env; + SyncTriggerList *ptl, *pnext; + + pCounter->sync.beingDestroyed = TRUE; + /* tell all the counter's triggers that the counter has been destroyed */ + for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext) + { + (*ptl->pTrigger->CounterDestroyed)(ptl->pTrigger); + pnext = ptl->next; + free(ptl); /* destroy the trigger list as we go */ + } + if (IsSystemCounter(pCounter)) + { + int i, found = 0; + + 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; +} + +/* + * ** Cleanup after Await + */ +/* ARGSUSED */ +static int +FreeAwait(void *addr, XID id) +{ + SyncAwaitUnion *pAwaitUnion = (SyncAwaitUnion *) addr; + SyncAwait *pAwait; + int numwaits; + + pAwait = &(pAwaitUnion+1)->await; /* first await on list */ + + /* remove triggers from counters */ + + for (numwaits = pAwaitUnion->header.num_waitconditions; numwaits; + numwaits--, pAwait++) + { + /* If the counter is being destroyed, FreeCounter will delete + * the trigger list itself, so don't do it here. + */ + SyncObject *pSync = pAwait->trigger.pSync; + if (pSync && !pSync->beingDestroyed) + SyncDeleteTriggerFromSyncObject(&pAwait->trigger); + } + free(pAwaitUnion); + return Success; +} + +/* loosely based on dix/events.c/OtherClientGone */ +static int +FreeAlarmClient(void *value, XID id) +{ + SyncAlarm *pAlarm = (SyncAlarm *)value; + SyncAlarmClientList *pCur, *pPrev; + + for (pPrev = NULL, pCur = pAlarm->pEventClients; + pCur; + pPrev = pCur, pCur = pCur->next) + { + if (pCur->delete_id == id) + { + if (pPrev) + pPrev->next = pCur->next; + else + pAlarm->pEventClients = pCur->next; + free(pCur); + return Success; + } + } + FatalError("alarm client not on event list"); + /*NOTREACHED*/ +} + + +/* + * ***** Proc functions + */ + + +/* + * ** Initialize the extension + */ +static int +ProcSyncInitialize(ClientPtr client) +{ + xSyncInitializeReply rep; + int n; + + 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, n); + } + WriteToClient(client, sizeof(rep), (char *) &rep); + return Success; +} + +/* + * ** Get list of system counters available through the extension + */ +static int +ProcSyncListSystemCounters(ClientPtr client) +{ + xSyncListSystemCountersReply rep; + int i, len; + 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++) + { + char *name = SysCounterList[i]->pSysCounterInfo->name; + /* pad to 4 byte boundary */ + len += pad_to_int32(sz_xSyncSystemCounter + strlen(name)); + } + + if (len) + { + walklist = list = malloc(len); + if (!list) + return BadAlloc; + } + + rep.length = bytes_to_int32(len); + + if (client->swapped) + { + char n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.nCounters, n); + } + + for (i = 0; i < SyncNumSystemCounters; i++) + { + int namelen; + char *pname_in_reply; + SysCounterInfo *psci = SysCounterList[i]->pSysCounterInfo; + + walklist->counter = SysCounterList[i]->sync.id; + walklist->resolution_hi = XSyncValueHigh32(psci->resolution); + walklist->resolution_lo = XSyncValueLow32(psci->resolution); + namelen = strlen(psci->name); + walklist->name_length = namelen; + + if (client->swapped) + { + char n; + swapl(&walklist->counter, n); + swapl(&walklist->resolution_hi, n); + swapl(&walklist->resolution_lo, n); + swaps(&walklist->name_length, n); + } + + pname_in_reply = ((char *)walklist) + sz_xSyncSystemCounter; + strncpy(pname_in_reply, psci->name, namelen); + walklist = (xSyncSystemCounter *) (((char *)walklist) + + pad_to_int32(sz_xSyncSystemCounter + namelen)); + } + + WriteToClient(client, sizeof(rep), (char *) &rep); + if (len) + { + WriteToClient(client, len, (char *) list); + free(list); + } + + return Success; +} + +/* + * ** Set client Priority + */ +static int +ProcSyncSetPriority(ClientPtr client) +{ + REQUEST(xSyncSetPriorityReq); + ClientPtr priorityclient; + int rc; + + REQUEST_SIZE_MATCH(xSyncSetPriorityReq); + + if (stuff->id == None) + priorityclient = client; + else { + rc = dixLookupClient(&priorityclient, stuff->id, client, + DixSetAttrAccess); + if (rc != Success) + return rc; + } + + if (priorityclient->priority != stuff->priority) + { + priorityclient->priority = stuff->priority; + + /* The following will force the server back into WaitForSomething + * so that the change in this client's priority is immediately + * reflected. + */ + isItTimeToYield = TRUE; + dispatchException |= DE_PRIORITYCHANGE; + } + return Success; +} + +/* + * ** Get client Priority + */ +static int +ProcSyncGetPriority(ClientPtr client) +{ + REQUEST(xSyncGetPriorityReq); + xSyncGetPriorityReply rep; + ClientPtr priorityclient; + int rc; + + REQUEST_SIZE_MATCH(xSyncGetPriorityReq); + + if (stuff->id == None) + priorityclient = client; + else { + rc = dixLookupClient(&priorityclient, stuff->id, client, + DixGetAttrAccess); + if (rc != Success) + return rc; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.priority = priorityclient->priority; + + if (client->swapped) + { + char n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.priority, n); + } + + WriteToClient(client, sizeof(xSyncGetPriorityReply), (char *) &rep); + + return Success; +} + +/* + * ** Create a new counter + */ +static int +ProcSyncCreateCounter(ClientPtr client) +{ + REQUEST(xSyncCreateCounterReq); + CARD64 initial; + + REQUEST_SIZE_MATCH(xSyncCreateCounterReq); + + LEGAL_NEW_RESOURCE(stuff->cid, client); + + XSyncIntsToValue(&initial, stuff->initial_value_lo, stuff->initial_value_hi); + if (!SyncCreateCounter(client, stuff->cid, initial)) + return BadAlloc; + + return Success; +} + +/* + * ** Set Counter value + */ +static int +ProcSyncSetCounter(ClientPtr client) +{ + REQUEST(xSyncSetCounterReq); + SyncCounter *pCounter; + CARD64 newvalue; + int rc; + + REQUEST_SIZE_MATCH(xSyncSetCounterReq); + + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter, + client, DixWriteAccess); + if (rc != Success) + return rc; + + if (IsSystemCounter(pCounter)) + { + client->errorValue = stuff->cid; + return BadAccess; + } + + XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi); + SyncChangeCounter(pCounter, newvalue); + return Success; +} + +/* + * ** Change Counter value + */ +static int +ProcSyncChangeCounter(ClientPtr client) +{ + REQUEST(xSyncChangeCounterReq); + SyncCounter *pCounter; + CARD64 newvalue; + Bool overflow; + int rc; + + REQUEST_SIZE_MATCH(xSyncChangeCounterReq); + + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter, + client, DixWriteAccess); + if (rc != Success) + return rc; + + if (IsSystemCounter(pCounter)) + { + client->errorValue = stuff->cid; + return BadAccess; + } + + XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi); + XSyncValueAdd(&newvalue, pCounter->value, newvalue, &overflow); + if (overflow) + { + /* XXX 64 bit value can't fit in 32 bits; do the best we can */ + client->errorValue = stuff->value_hi; + return BadValue; + } + SyncChangeCounter(pCounter, newvalue); + return Success; +} + +/* + * ** Destroy a counter + */ +static int +ProcSyncDestroyCounter(ClientPtr client) +{ + REQUEST(xSyncDestroyCounterReq); + SyncCounter *pCounter; + int rc; + + REQUEST_SIZE_MATCH(xSyncDestroyCounterReq); + + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter, + client, DixDestroyAccess); + if (rc != Success) + return rc; + + if (IsSystemCounter(pCounter)) + { + client->errorValue = stuff->counter; + return BadAccess; + } + FreeResource(pCounter->sync.id, RT_NONE); + return Success; +} + +static SyncAwaitUnion* +SyncAwaitPrologue(ClientPtr client, int items) +{ + SyncAwaitUnion *pAwaitUnion; + + /* all the memory for the entire await list is allocated + * here in one chunk + */ + pAwaitUnion = malloc((items+1) * sizeof(SyncAwaitUnion)); + if (!pAwaitUnion) + return NULL; + + /* first item is the header, remainder are real wait conditions */ + + pAwaitUnion->header.delete_id = FakeClientID(client->index); + pAwaitUnion->header.client = client; + pAwaitUnion->header.num_waitconditions = 0; + + if (!AddResource(pAwaitUnion->header.delete_id, RTAwait, pAwaitUnion)) + return NULL; + + return pAwaitUnion; +} + +static void +SyncAwaitEpilogue(ClientPtr client, int items, SyncAwaitUnion *pAwaitUnion) +{ + SyncAwait *pAwait; + int i; + + IgnoreClient(client); + + /* see if any of the triggers are already true */ + + pAwait = &(pAwaitUnion+1)->await; /* skip over header */ + for (i = 0; i < items; i++, pAwait++) + { + CARD64 value; + + /* don't have to worry about NULL counters because the request + * errors before we get here out if they occur + */ + switch (pAwait->trigger.pSync->type) { + case SYNC_COUNTER: + value = ((SyncCounter *)pAwait->trigger.pSync)->value; + break; + default: + XSyncIntToValue(&value, 0); + } + + if ((*pAwait->trigger.CheckTrigger)(&pAwait->trigger, value)) + { + (*pAwait->trigger.TriggerFired)(&pAwait->trigger); + break; /* once is enough */ + } + } +} + +/* + * ** Await + */ +static int +ProcSyncAwait(ClientPtr client) +{ + REQUEST(xSyncAwaitReq); + int len, items; + int i; + xSyncWaitCondition *pProtocolWaitConds; + SyncAwaitUnion *pAwaitUnion; + SyncAwait *pAwait; + int status; + + REQUEST_AT_LEAST_SIZE(xSyncAwaitReq); + + len = client->req_len << 2; + len -= sz_xSyncAwaitReq; + items = len / sz_xSyncWaitCondition; + + if (items * sz_xSyncWaitCondition != len) + { + return BadLength; + } + if (items == 0) + { + client->errorValue = items; /* XXX protocol change */ + return BadValue; + } + + if (!(pAwaitUnion = SyncAwaitPrologue(client, items))) + return BadAlloc; + + /* don't need to do any more memory allocation for this request! */ + + pProtocolWaitConds = (xSyncWaitCondition *) & stuff[1]; + + pAwait = &(pAwaitUnion+1)->await; /* skip over header */ + for (i = 0; i < items; i++, pProtocolWaitConds++, pAwait++) + { + if (pProtocolWaitConds->counter == None) /* XXX protocol change */ + { + /* this should take care of removing any triggers created by + * this request that have already been registered on sync objects + */ + FreeResource(pAwaitUnion->header.delete_id, RT_NONE); + client->errorValue = pProtocolWaitConds->counter; + return SyncErrorBase + XSyncBadCounter; + } + + /* sanity checks are in SyncInitTrigger */ + pAwait->trigger.pSync = NULL; + pAwait->trigger.value_type = pProtocolWaitConds->value_type; + XSyncIntsToValue(&pAwait->trigger.wait_value, + pProtocolWaitConds->wait_value_lo, + pProtocolWaitConds->wait_value_hi); + pAwait->trigger.test_type = pProtocolWaitConds->test_type; + + status = SyncInitTrigger(client, &pAwait->trigger, + pProtocolWaitConds->counter, RTCounter, + XSyncCAAllTrigger); + if (status != Success) + { + /* this should take care of removing any triggers created by + * this request that have already been registered on sync objects + */ + FreeResource(pAwaitUnion->header.delete_id, RT_NONE); + return status; + } + /* this is not a mistake -- same function works for both cases */ + pAwait->trigger.TriggerFired = SyncAwaitTriggerFired; + pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired; + XSyncIntsToValue(&pAwait->event_threshold, + pProtocolWaitConds->event_threshold_lo, + pProtocolWaitConds->event_threshold_hi); + pAwait->pHeader = &pAwaitUnion->header; + pAwaitUnion->header.num_waitconditions++; + } + + SyncAwaitEpilogue(client, items, pAwaitUnion); + + return Success; +} + + +/* + * ** Query a counter + */ +static int +ProcSyncQueryCounter(ClientPtr client) +{ + REQUEST(xSyncQueryCounterReq); + xSyncQueryCounterReply rep; + SyncCounter *pCounter; + int rc; + + REQUEST_SIZE_MATCH(xSyncQueryCounterReq); + + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, + RTCounter, client, DixReadAccess); + 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); + if (client->swapped) + { + char n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.value_hi, n); + swapl(&rep.value_lo, n); + } + WriteToClient(client, sizeof(xSyncQueryCounterReply), (char *) &rep); + return Success; +} + + +/* + * ** Create Alarm + */ +static int +ProcSyncCreateAlarm(ClientPtr client) +{ + REQUEST(xSyncCreateAlarmReq); + SyncAlarm *pAlarm; + int status; + unsigned long len, vmask; + SyncTrigger *pTrigger; + + REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq); + + LEGAL_NEW_RESOURCE(stuff->id, client); + + vmask = stuff->valueMask; + len = client->req_len - bytes_to_int32(sizeof(xSyncCreateAlarmReq)); + /* the "extra" call to Ones accounts for the presence of 64 bit values */ + if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta)))) + return BadLength; + + if (!(pAlarm = malloc(sizeof(SyncAlarm)))) + { + return BadAlloc; + } + + /* set up defaults */ + + pTrigger = &pAlarm->trigger; + pTrigger->pSync = NULL; + pTrigger->value_type = XSyncAbsolute; + XSyncIntToValue(&pTrigger->wait_value, 0L); + pTrigger->test_type = XSyncPositiveComparison; + pTrigger->TriggerFired = SyncAlarmTriggerFired; + pTrigger->CounterDestroyed = SyncAlarmCounterDestroyed; + status = SyncInitTrigger(client, pTrigger, None, RTCounter, + XSyncCAAllTrigger); + if (status != Success) + { + free(pAlarm); + return status; + } + + pAlarm->client = client; + pAlarm->alarm_id = stuff->id; + XSyncIntToValue(&pAlarm->delta, 1L); + pAlarm->events = TRUE; + pAlarm->state = XSyncAlarmInactive; + pAlarm->pEventClients = NULL; + status = SyncChangeAlarmAttributes(client, pAlarm, vmask, + (CARD32 *)&stuff[1]); + if (status != Success) + { + free(pAlarm); + return status; + } + + if (!AddResource(stuff->id, RTAlarm, pAlarm)) + return BadAlloc; + + /* see if alarm already triggered. NULL counter will not trigger + * in CreateAlarm and sets alarm state to Inactive. + */ + + if (!pTrigger->pSync) + { + pAlarm->state = XSyncAlarmInactive; /* XXX protocol change */ + } + else + { + SyncCounter *pCounter; + + if (!SyncCheckWarnIsCounter(pTrigger->pSync, + WARN_INVALID_COUNTER_ALARM)) + { + FreeResource(stuff->id, RT_NONE); + return BadAlloc; + } + + pCounter = (SyncCounter *)pTrigger->pSync; + + if ((*pTrigger->CheckTrigger)(pTrigger, pCounter->value)) + (*pTrigger->TriggerFired)(pTrigger); + } + + return Success; +} + +/* + * ** Change Alarm + */ +static int +ProcSyncChangeAlarm(ClientPtr client) +{ + REQUEST(xSyncChangeAlarmReq); + SyncAlarm *pAlarm; + SyncCounter *pCounter = NULL; + long vmask; + int len, status; + + REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); + + status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, + client, DixWriteAccess); + if (status != Success) + return status; + + vmask = stuff->valueMask; + len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq)); + /* the "extra" call to Ones accounts for the presence of 64 bit values */ + if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta)))) + return BadLength; + + if ((status = SyncChangeAlarmAttributes(client, pAlarm, vmask, + (CARD32 *)&stuff[1])) != Success) + return status; + + if (SyncCheckWarnIsCounter(pAlarm->trigger.pSync, + WARN_INVALID_COUNTER_ALARM)) + pCounter = (SyncCounter *)pAlarm->trigger.pSync; + + /* see if alarm already triggered. NULL counter WILL trigger + * in ChangeAlarm. + */ + + if (!pCounter || + (*pAlarm->trigger.CheckTrigger)(&pAlarm->trigger, pCounter->value)) + { + (*pAlarm->trigger.TriggerFired)(&pAlarm->trigger); + } + return Success; +} + +static int +ProcSyncQueryAlarm(ClientPtr client) +{ + REQUEST(xSyncQueryAlarmReq); + SyncAlarm *pAlarm; + xSyncQueryAlarmReply rep; + SyncTrigger *pTrigger; + int rc; + + REQUEST_SIZE_MATCH(xSyncQueryAlarmReq); + + rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, + client, DixReadAccess); + 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); +#else + rep.value_type = XSyncAbsolute; + rep.wait_value_hi = XSyncValueHigh32(pTrigger->test_value); + rep.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; + + if (client->swapped) + { + char n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.counter, n); + swapl(&rep.wait_value_hi, n); + swapl(&rep.wait_value_lo, n); + swapl(&rep.test_type, n); + swapl(&rep.delta_hi, n); + swapl(&rep.delta_lo, n); + } + + WriteToClient(client, sizeof(xSyncQueryAlarmReply), (char *) &rep); + return Success; +} + +static int +ProcSyncDestroyAlarm(ClientPtr client) +{ + SyncAlarm *pAlarm; + int rc; + REQUEST(xSyncDestroyAlarmReq); + + REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq); + + rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, + client, DixDestroyAccess); + if (rc != Success) + return rc; + + FreeResource(stuff->alarm, RT_NONE); + return Success; +} + +static int +ProcSyncCreateFence(ClientPtr client) +{ + REQUEST(xSyncCreateFenceReq); + DrawablePtr pDraw; + SyncFence *pFence; + int rc; + + REQUEST_SIZE_MATCH(xSyncCreateFenceReq); + + rc = dixLookupDrawable(&pDraw, stuff->d, client, M_ANY, DixGetAttrAccess); + if (rc != Success) + return rc; + + LEGAL_NEW_RESOURCE(stuff->fid, client); + + if (!(pFence = (SyncFence *)SyncCreate(client, + stuff->fid, + SYNC_FENCE))) + return BadAlloc; + + miSyncInitFence(pDraw->pScreen, pFence, stuff->initially_triggered); + + if (!AddResource(stuff->fid, RTFence, (pointer) pFence)) + return BadAlloc; + + return client->noClientException; +} + +static int +FreeFence(void *obj, XID id) +{ + SyncFence *pFence = (SyncFence *) obj; + + miSyncDestroyFence(pFence); + + return Success; +} + +int SyncVerifyFence(SyncFence **ppSyncFence, XID fid, + ClientPtr client, Mask mode) +{ + int rc = dixLookupResourceByType((pointer *)ppSyncFence, fid, RTFence, + client, mode); + + if (rc != Success) + client->errorValue = fid; + + return rc; +} + +static int +ProcSyncTriggerFence(ClientPtr client) +{ + REQUEST(xSyncTriggerFenceReq); + SyncFence *pFence; + int rc; + + REQUEST_SIZE_MATCH(xSyncTriggerFenceReq); + + rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence, + client, DixWriteAccess); + if (rc != Success) + return rc; + + miSyncTriggerFence(pFence); + + return client->noClientException; +} + +static int +ProcSyncResetFence(ClientPtr client) +{ + REQUEST(xSyncResetFenceReq); + SyncFence *pFence; + int rc; + + REQUEST_SIZE_MATCH(xSyncResetFenceReq); + + rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence, + client, DixWriteAccess); + if (rc != Success) + return rc; + + if (pFence->funcs.CheckTriggered(pFence) != TRUE) + return BadMatch; + + pFence->funcs.Reset(pFence); + + return client->noClientException; +} + +static int +ProcSyncDestroyFence(ClientPtr client) +{ + REQUEST(xSyncDestroyFenceReq); + SyncFence *pFence; + int rc; + + REQUEST_SIZE_MATCH(xSyncDestroyFenceReq); + + rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence, + client, DixDestroyAccess); + if (rc != Success) + return rc; + + FreeResource(stuff->fid, RT_NONE); + return client->noClientException; +} + +static int +ProcSyncQueryFence(ClientPtr client) +{ + REQUEST(xSyncQueryFenceReq); + xSyncQueryFenceReply rep; + SyncFence *pFence; + int rc; + + REQUEST_SIZE_MATCH(xSyncQueryFenceReq); + + rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, + RTFence, client, DixReadAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rep.triggered = pFence->funcs.CheckTriggered(pFence); + + if (client->swapped) + { + char n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + } + + WriteToClient(client, sizeof(xSyncQueryFenceReply), (char *) &rep); + return client->noClientException; +} + +static int +ProcSyncAwaitFence(ClientPtr client) +{ + REQUEST(xSyncAwaitFenceReq); + SyncAwaitUnion *pAwaitUnion; + SyncAwait *pAwait; + /* Use CARD32 rather than XSyncFence because XIDs are hard-coded to + * CARD32 in protocol definitions */ + CARD32 *pProtocolFences; + int status; + int len; + int items; + int i; + + REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq); + + len = client->req_len << 2; + len -= sz_xSyncAwaitFenceReq; + items = len / sizeof(CARD32); + + if (items * sizeof(CARD32) != len) + { + return BadLength; + } + if (items == 0) + { + client->errorValue = items; + return BadValue; + } + + if (!(pAwaitUnion = SyncAwaitPrologue(client, items))) + return BadAlloc; + + /* don't need to do any more memory allocation for this request! */ + + pProtocolFences = (CARD32 *) & stuff[1]; + + pAwait = &(pAwaitUnion+1)->await; /* skip over header */ + for (i = 0; i < items; i++, pProtocolFences++, pAwait++) + { + if (*pProtocolFences == None) + { + /* this should take care of removing any triggers created by + * this request that have already been registered on sync objects + */ + FreeResource(pAwaitUnion->header.delete_id, RT_NONE); + client->errorValue = *pProtocolFences; + return SyncErrorBase + XSyncBadFence; + } + + pAwait->trigger.pSync = NULL; + /* Provide acceptable values for these unused fields to + * satisfy SyncInitTrigger's validation logic + */ + pAwait->trigger.value_type = XSyncAbsolute; + XSyncIntToValue(&pAwait->trigger.wait_value, 0); + pAwait->trigger.test_type = 0; + + status = SyncInitTrigger(client, &pAwait->trigger, + *pProtocolFences, RTFence, + XSyncCAAllTrigger); + if (status != Success) + { + /* this should take care of removing any triggers created by + * this request that have already been registered on sync objects + */ + FreeResource(pAwaitUnion->header.delete_id, RT_NONE); + return status; + } + /* this is not a mistake -- same function works for both cases */ + pAwait->trigger.TriggerFired = SyncAwaitTriggerFired; + pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired; + /* event_threshold is unused for fence syncs */ + XSyncIntToValue(&pAwait->event_threshold, 0); + pAwait->pHeader = &pAwaitUnion->header; + pAwaitUnion->header.num_waitconditions++; + } + + SyncAwaitEpilogue(client, items, pAwaitUnion); + + return client->noClientException; +} + +/* + * ** Given an extension request, call the appropriate request procedure + */ +static int +ProcSyncDispatch(ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) + { + case X_SyncInitialize: + return ProcSyncInitialize(client); + case X_SyncListSystemCounters: + return ProcSyncListSystemCounters(client); + case X_SyncCreateCounter: + return ProcSyncCreateCounter(client); + case X_SyncSetCounter: + return ProcSyncSetCounter(client); + case X_SyncChangeCounter: + return ProcSyncChangeCounter(client); + case X_SyncQueryCounter: + return ProcSyncQueryCounter(client); + case X_SyncDestroyCounter: + return ProcSyncDestroyCounter(client); + case X_SyncAwait: + return ProcSyncAwait(client); + case X_SyncCreateAlarm: + return ProcSyncCreateAlarm(client); + case X_SyncChangeAlarm: + return ProcSyncChangeAlarm(client); + case X_SyncQueryAlarm: + return ProcSyncQueryAlarm(client); + case X_SyncDestroyAlarm: + return ProcSyncDestroyAlarm(client); + case X_SyncSetPriority: + return ProcSyncSetPriority(client); + case X_SyncGetPriority: + return ProcSyncGetPriority(client); + case X_SyncCreateFence: + return ProcSyncCreateFence(client); + case X_SyncTriggerFence: + return ProcSyncTriggerFence(client); + case X_SyncResetFence: + return ProcSyncResetFence(client); + case X_SyncDestroyFence: + return ProcSyncDestroyFence(client); + case X_SyncQueryFence: + return ProcSyncQueryFence(client); + case X_SyncAwaitFence: + return ProcSyncAwaitFence(client); + default: + return BadRequest; + } +} + +/* + * Boring Swapping stuff ... + */ + +static int +SProcSyncInitialize(ClientPtr client) +{ + REQUEST(xSyncInitializeReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncInitializeReq); + + return ProcSyncInitialize(client); +} + +static int +SProcSyncListSystemCounters(ClientPtr client) +{ + REQUEST(xSyncListSystemCountersReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncListSystemCountersReq); + + return ProcSyncListSystemCounters(client); +} + +static int +SProcSyncCreateCounter(ClientPtr client) +{ + REQUEST(xSyncCreateCounterReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncCreateCounterReq); + swapl(&stuff->cid, n); + swapl(&stuff->initial_value_lo, n); + swapl(&stuff->initial_value_hi, n); + + return ProcSyncCreateCounter(client); +} + +static int +SProcSyncSetCounter(ClientPtr client) +{ + REQUEST(xSyncSetCounterReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncSetCounterReq); + swapl(&stuff->cid, n); + swapl(&stuff->value_lo, n); + swapl(&stuff->value_hi, n); + + return ProcSyncSetCounter(client); +} + +static int +SProcSyncChangeCounter(ClientPtr client) +{ + REQUEST(xSyncChangeCounterReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncChangeCounterReq); + swapl(&stuff->cid, n); + swapl(&stuff->value_lo, n); + swapl(&stuff->value_hi, n); + + return ProcSyncChangeCounter(client); +} + +static int +SProcSyncQueryCounter(ClientPtr client) +{ + REQUEST(xSyncQueryCounterReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncQueryCounterReq); + swapl(&stuff->counter, n); + + return ProcSyncQueryCounter(client); +} + +static int +SProcSyncDestroyCounter(ClientPtr client) +{ + REQUEST(xSyncDestroyCounterReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncDestroyCounterReq); + swapl(&stuff->counter, n); + + return ProcSyncDestroyCounter(client); +} + +static int +SProcSyncAwait(ClientPtr client) +{ + REQUEST(xSyncAwaitReq); + char n; + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xSyncAwaitReq); + SwapRestL(stuff); + + return ProcSyncAwait(client); +} + +static int +SProcSyncCreateAlarm(ClientPtr client) +{ + REQUEST(xSyncCreateAlarmReq); + char n; + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq); + swapl(&stuff->id, n); + swapl(&stuff->valueMask, n); + SwapRestL(stuff); + + return ProcSyncCreateAlarm(client); +} + +static int +SProcSyncChangeAlarm(ClientPtr client) +{ + REQUEST(xSyncChangeAlarmReq); + char n; + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); + swapl(&stuff->alarm, n); + swapl(&stuff->valueMask, n); + SwapRestL(stuff); + return ProcSyncChangeAlarm(client); +} + +static int +SProcSyncQueryAlarm(ClientPtr client) +{ + REQUEST(xSyncQueryAlarmReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncQueryAlarmReq); + swapl(&stuff->alarm, n); + + return ProcSyncQueryAlarm(client); +} + +static int +SProcSyncDestroyAlarm(ClientPtr client) +{ + REQUEST(xSyncDestroyAlarmReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncDestroyAlarmReq); + swapl(&stuff->alarm, n); + + return ProcSyncDestroyAlarm(client); +} + +static int +SProcSyncSetPriority(ClientPtr client) +{ + REQUEST(xSyncSetPriorityReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncSetPriorityReq); + swapl(&stuff->id, n); + swapl(&stuff->priority, n); + + return ProcSyncSetPriority(client); +} + +static int +SProcSyncGetPriority(ClientPtr client) +{ + REQUEST(xSyncGetPriorityReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncGetPriorityReq); + swapl(&stuff->id, n); + + return ProcSyncGetPriority(client); +} + +static int +SProcSyncCreateFence(ClientPtr client) +{ + REQUEST(xSyncCreateFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncCreateFenceReq); + swapl(&stuff->fid, n); + + return ProcSyncCreateFence(client); +} + +static int +SProcSyncTriggerFence(ClientPtr client) +{ + REQUEST(xSyncTriggerFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncTriggerFenceReq); + swapl(&stuff->fid, n); + + return ProcSyncTriggerFence(client); +} + +static int +SProcSyncResetFence(ClientPtr client) +{ + REQUEST(xSyncResetFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncResetFenceReq); + swapl(&stuff->fid, n); + + return ProcSyncResetFence(client); +} + +static int +SProcSyncDestroyFence(ClientPtr client) +{ + REQUEST(xSyncDestroyFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncDestroyFenceReq); + swapl(&stuff->fid, n); + + return ProcSyncDestroyFence(client); +} + +static int +SProcSyncQueryFence(ClientPtr client) +{ + REQUEST(xSyncQueryFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncQueryFenceReq); + swapl(&stuff->fid, n); + + return ProcSyncQueryFence(client); +} + +static int +SProcSyncAwaitFence(ClientPtr client) +{ + REQUEST(xSyncAwaitFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq); + SwapRestL(stuff); + + return ProcSyncAwaitFence(client); +} + +static int +SProcSyncDispatch(ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) + { + case X_SyncInitialize: + return SProcSyncInitialize(client); + case X_SyncListSystemCounters: + return SProcSyncListSystemCounters(client); + case X_SyncCreateCounter: + return SProcSyncCreateCounter(client); + case X_SyncSetCounter: + return SProcSyncSetCounter(client); + case X_SyncChangeCounter: + return SProcSyncChangeCounter(client); + case X_SyncQueryCounter: + return SProcSyncQueryCounter(client); + case X_SyncDestroyCounter: + return SProcSyncDestroyCounter(client); + case X_SyncAwait: + return SProcSyncAwait(client); + case X_SyncCreateAlarm: + return SProcSyncCreateAlarm(client); + case X_SyncChangeAlarm: + return SProcSyncChangeAlarm(client); + case X_SyncQueryAlarm: + return SProcSyncQueryAlarm(client); + case X_SyncDestroyAlarm: + return SProcSyncDestroyAlarm(client); + case X_SyncSetPriority: + return SProcSyncSetPriority(client); + case X_SyncGetPriority: + return SProcSyncGetPriority(client); + case X_SyncCreateFence: + return SProcSyncCreateFence(client); + case X_SyncTriggerFence: + return SProcSyncTriggerFence(client); + case X_SyncResetFence: + return SProcSyncResetFence(client); + case X_SyncDestroyFence: + return SProcSyncDestroyFence(client); + case X_SyncQueryFence: + return SProcSyncQueryFence(client); + case X_SyncAwaitFence: + return SProcSyncAwaitFence(client); + default: + return BadRequest; + } +} + +/* + * Event Swapping + */ + +static void +SCounterNotifyEvent(xSyncCounterNotifyEvent *from, xSyncCounterNotifyEvent *to) +{ + to->type = from->type; + to->kind = from->kind; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->counter, to->counter); + cpswapl(from->wait_value_lo, to->wait_value_lo); + cpswapl(from->wait_value_hi, to->wait_value_hi); + cpswapl(from->counter_value_lo, to->counter_value_lo); + cpswapl(from->counter_value_hi, to->counter_value_hi); + cpswapl(from->time, to->time); + cpswaps(from->count, to->count); + to->destroyed = from->destroyed; +} + + +static void +SAlarmNotifyEvent(xSyncAlarmNotifyEvent *from, xSyncAlarmNotifyEvent *to) +{ + to->type = from->type; + to->kind = from->kind; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->alarm, to->alarm); + cpswapl(from->counter_value_lo, to->counter_value_lo); + cpswapl(from->counter_value_hi, to->counter_value_hi); + cpswapl(from->alarm_value_lo, to->alarm_value_lo); + cpswapl(from->alarm_value_hi, to->alarm_value_hi); + cpswapl(from->time, to->time); + to->state = from->state; +} + +/* + * ** Close everything down. ** This is fairly simple for now. + */ +/* ARGSUSED */ +static void +SyncResetProc(ExtensionEntry *extEntry) +{ + free(SysCounterList); + SysCounterList = NULL; + RTCounter = 0; +} + +/* + * ** Initialise the extension. + */ +void +SyncExtensionInit(void) +{ + ExtensionEntry *extEntry; + int s; + + for (s = 0; s < screenInfo.numScreens; s++) + miSyncSetup(screenInfo.screens[s]); + + if (RTCounter == 0) + { + RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter"); + } + RTAlarm = CreateNewResourceType(FreeAlarm, "SyncAlarm"); + RTAwait = CreateNewResourceType(FreeAwait, "SyncAwait"); + RTFence = CreateNewResourceType(FreeFence, "SyncFence"); + if (RTAwait) + RTAwait |= RC_NEVERRETAIN; + RTAlarmClient = CreateNewResourceType(FreeAlarmClient, "SyncAlarmClient"); + if (RTAlarmClient) + RTAlarmClient |= RC_NEVERRETAIN; + + if (RTCounter == 0 || RTAwait == 0 || RTAlarm == 0 || + RTAlarmClient == 0 || + (extEntry = AddExtension(SYNC_NAME, + XSyncNumberEvents, XSyncNumberErrors, + ProcSyncDispatch, SProcSyncDispatch, + SyncResetProc, + StandardMinorOpcode)) == NULL) + { + ErrorF("Sync Extension %d.%d failed to Initialise\n", + SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION); + return; + } + + SyncEventBase = extEntry->eventBase; + SyncErrorBase = extEntry->errorBase; + EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent; + EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent; + + SetResourceTypeErrorValue(RTCounter, SyncErrorBase + XSyncBadCounter); + SetResourceTypeErrorValue(RTAlarm, SyncErrorBase + XSyncBadAlarm); + SetResourceTypeErrorValue(RTFence, SyncErrorBase + XSyncBadFence); + + /* + * Although SERVERTIME is implemented by the OS layer, we initialise it + * here because doing it in OsInit() is too early. The resource database + * is not initialised when OsInit() is called. This is just about OK + * because there is always a servertime counter. + */ + SyncInitServerTime(); + SyncInitIdleTime(); + +#ifdef DEBUG + fprintf(stderr, "Sync Extension %d.%d\n", + SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION); +#endif +} + + +/* + * ***** SERVERTIME implementation - should go in its own file in OS directory? + */ + + + +static pointer ServertimeCounter; +static XSyncValue Now; +static XSyncValue *pnext_time; + +#define GetTime()\ +{\ + unsigned long millis = GetTimeInMillis();\ + unsigned long maxis = XSyncValueHigh32(Now);\ + if (millis < XSyncValueLow32(Now)) maxis++;\ + XSyncIntsToValue(&Now, millis, maxis);\ +} + +/* +*** Server Block Handler +*** code inspired by multibuffer extension (now deprecated) + */ +/*ARGSUSED*/ +static void +ServertimeBlockHandler(void *env, struct timeval **wt, void *LastSelectMask) +{ + XSyncValue delay; + unsigned long timeout; + + if (pnext_time) + { + GetTime(); + + if (XSyncValueGreaterOrEqual(Now, *pnext_time)) + { + timeout = 0; + } + else + { + Bool overflow; + XSyncValueSubtract(&delay, *pnext_time, Now, &overflow); + (void)overflow; + timeout = XSyncValueLow32(delay); + } + AdjustWaitForDelay(wt, timeout); /* os/utils.c */ + } +} + +/* +*** Wakeup Handler + */ +/*ARGSUSED*/ +static void +ServertimeWakeupHandler(void *env, int rc, void *LastSelectMask) +{ + if (pnext_time) + { + GetTime(); + + if (XSyncValueGreaterOrEqual(Now, *pnext_time)) + { + SyncChangeCounter(ServertimeCounter, Now); + } + } +} + +static void +ServertimeQueryValue(void *pCounter, CARD64 *pValue_return) +{ + GetTime(); + *pValue_return = Now; +} + +static void +ServertimeBracketValues(void *pCounter, CARD64 *pbracket_less, + CARD64 *pbracket_greater) +{ + if (!pnext_time && pbracket_greater) + { + RegisterBlockAndWakeupHandlers(ServertimeBlockHandler, + ServertimeWakeupHandler, + NULL); + } + else if (pnext_time && !pbracket_greater) + { + RemoveBlockAndWakeupHandlers(ServertimeBlockHandler, + ServertimeWakeupHandler, + NULL); + } + pnext_time = pbracket_greater; +} + +static void +SyncInitServerTime(void) +{ + CARD64 resolution; + + XSyncIntsToValue(&Now, GetTimeInMillis(), 0); + XSyncIntToValue(&resolution, 4); + ServertimeCounter = SyncCreateSystemCounter("SERVERTIME", Now, resolution, + XSyncCounterNeverDecreases, + ServertimeQueryValue, ServertimeBracketValues); + pnext_time = NULL; +} + + + +/* + * IDLETIME implementation + */ + +static SyncCounter *IdleTimeCounter; +static XSyncValue *pIdleTimeValueLess; +static XSyncValue *pIdleTimeValueGreater; + +static void +IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return) +{ + CARD32 idle = GetTimeInMillis() - lastDeviceEventTime.milliseconds; + XSyncIntsToValue (pValue_return, idle, 0); +} + +static void +IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask) +{ + XSyncValue idle, old_idle; + SyncTriggerList *list = IdleTimeCounter->sync.pTriglist; + SyncTrigger *trig; + + if (!pIdleTimeValueLess && !pIdleTimeValueGreater) + return; + + old_idle = IdleTimeCounter->value; + IdleTimeQueryValue (NULL, &idle); + IdleTimeCounter->value = idle; /* push, so CheckTrigger works */ + + if (pIdleTimeValueLess && + XSyncValueLessOrEqual (idle, *pIdleTimeValueLess)) + { + /* + * 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 + * want level or edge trigger. Check the trigger list against the + * current idle time, and if any succeed, bomb out of select() + * immediately so we can reschedule. + */ + + for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) { + trig = list->pTrigger; + if (trig->CheckTrigger(trig, old_idle)) { + AdjustWaitForDelay(wt, 0); + break; + } + } + /* + * We've been called exactly on the idle time, but we have a + * NegativeTransition trigger which requires a transition from an + * idle time greater than this. Schedule a wakeup for the next + * millisecond so we won't miss a transition. + */ + if (XSyncValueEqual (idle, *pIdleTimeValueLess)) + AdjustWaitForDelay(wt, 1); + } + else if (pIdleTimeValueGreater) + { + /* + * There's a threshold in the positive direction. If we've been + * idle less than it, schedule a wakeup for sometime in the future. + * If we've been idle more than it, and someone wants to know about + * that level-triggered, schedule an immediate wakeup. + */ + unsigned long timeout = -1; + + if (XSyncValueLessThan (idle, *pIdleTimeValueGreater)) { + XSyncValue value; + Bool overflow; + + XSyncValueSubtract (&value, *pIdleTimeValueGreater, + idle, &overflow); + timeout = min(timeout, XSyncValueLow32 (value)); + } else { + for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) { + trig = list->pTrigger; + if (trig->CheckTrigger(trig, old_idle)) { + timeout = min(timeout, 0); + break; + } + } + } + + AdjustWaitForDelay (wt, timeout); + } + + IdleTimeCounter->value = old_idle; /* pop */ +} + +static void +IdleTimeWakeupHandler (pointer env, int rc, pointer LastSelectMask) +{ + XSyncValue idle; + + if (!pIdleTimeValueLess && !pIdleTimeValueGreater) + return; + + IdleTimeQueryValue (NULL, &idle); + + if ((pIdleTimeValueGreater && + XSyncValueGreaterOrEqual (idle, *pIdleTimeValueGreater)) || + (pIdleTimeValueLess && + XSyncValueLessOrEqual (idle, *pIdleTimeValueLess))) + { + SyncChangeCounter (IdleTimeCounter, idle); + } +} + +static void +IdleTimeBracketValues (pointer pCounter, CARD64 *pbracket_less, + CARD64 *pbracket_greater) +{ + Bool registered = (pIdleTimeValueLess || pIdleTimeValueGreater); + + if (registered && !pbracket_less && !pbracket_greater) + { + RemoveBlockAndWakeupHandlers(IdleTimeBlockHandler, + IdleTimeWakeupHandler, + NULL); + } + else if (!registered && (pbracket_less || pbracket_greater)) + { + RegisterBlockAndWakeupHandlers(IdleTimeBlockHandler, + IdleTimeWakeupHandler, + NULL); + } + + pIdleTimeValueGreater = pbracket_greater; + pIdleTimeValueLess = pbracket_less; +} + +static void +SyncInitIdleTime (void) +{ + CARD64 resolution; + XSyncValue idle; + + IdleTimeQueryValue (NULL, &idle); + XSyncIntToValue (&resolution, 4); + + IdleTimeCounter = SyncCreateSystemCounter ("IDLETIME", idle, resolution, + XSyncCounterUnrestricted, + IdleTimeQueryValue, + IdleTimeBracketValues); + + pIdleTimeValueLess = pIdleTimeValueGreater = NULL; +} diff --git a/xorg-server/Xi/xigrabdev.c b/xorg-server/Xi/xigrabdev.c index 24ededcb1..05c732c89 100644 --- a/xorg-server/Xi/xigrabdev.c +++ b/xorg-server/Xi/xigrabdev.c @@ -1,161 +1,161 @@ -/* - * Copyright © 2009 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 - * 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. - * - * Author: Peter Hutterer - */ - -/*********************************************************************** - * - * Request to grab or ungrab input device. - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include -#include - -#include "exglobals.h" /* BadDevice */ -#include "exevents.h" -#include "xigrabdev.h" - -int -SProcXIGrabDevice(ClientPtr client) -{ - char n; - - REQUEST(xXIGrabDeviceReq); - - swaps(&stuff->length, n); - swaps(&stuff->deviceid, n); - swapl(&stuff->grab_window, n); - swapl(&stuff->cursor, n); - swapl(&stuff->time, n); - swaps(&stuff->mask_len, n); - - return ProcXIGrabDevice(client); -} - -int -ProcXIGrabDevice(ClientPtr client) -{ - DeviceIntPtr dev; - xXIGrabDeviceReply rep; - int ret = Success; - uint8_t status; - GrabMask mask; - int mask_len; - - REQUEST(xXIGrabDeviceReq); - REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq); - - ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); - if (ret != Success) - return ret; - - if (!IsMaster(dev)) - stuff->paired_device_mode = GrabModeAsync; - - if (XICheckInvalidMaskBits((unsigned char*)&stuff[1], - stuff->mask_len * 4) != Success) - return BadValue; - - mask_len = min(sizeof(mask.xi2mask[stuff->deviceid]), stuff->mask_len * 4); - memset(mask.xi2mask, 0, sizeof(mask.xi2mask)); - memcpy(mask.xi2mask, (char*)&stuff[1], mask_len); - - ret = GrabDevice(client, dev, stuff->grab_mode, - stuff->paired_device_mode, - stuff->grab_window, - stuff->owner_events, - stuff->time, - &mask, - GRABTYPE_XI2, - stuff->cursor, - None /* confineTo */, - &status); - - if (ret != Success) - return ret; - - rep.repType = X_Reply; - rep.RepType = X_XIGrabDevice; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.status = status; - - - WriteReplyToClient(client, sizeof(rep), &rep); - return ret; -} - -int -SProcXIUngrabDevice(ClientPtr client) -{ - char n; - - REQUEST(xXIUngrabDeviceReq); - - swaps(&stuff->length, n); - swaps(&stuff->deviceid, n); - swapl(&stuff->time, n); - - return ProcXIUngrabDevice(client); -} - -int -ProcXIUngrabDevice(ClientPtr client) -{ - DeviceIntPtr dev; - GrabPtr grab; - int ret = Success; - TimeStamp time; - - REQUEST(xXIUngrabDeviceReq); - - ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); - if (ret != Success) - return ret; - - grab = dev->deviceGrab.grab; - - time = ClientTimeToServerTime(stuff->time); - if ((CompareTimeStamps(time, currentTime) != LATER) && - (CompareTimeStamps(time, dev->deviceGrab.grabTime) != EARLIER) && - (grab) && SameClient(grab, client) && grab->grabtype == GRABTYPE_XI2) - (*dev->deviceGrab.DeactivateGrab) (dev); - - return Success; -} - -void SRepXIGrabDevice(ClientPtr client, int size, xXIGrabDeviceReply * rep) -{ - char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - WriteToClient(client, size, (char *)rep); -} +/* + * Copyright © 2009 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 + * 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. + * + * Author: Peter Hutterer + */ + +/*********************************************************************** + * + * Request to grab or ungrab input device. + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include +#include + +#include "exglobals.h" /* BadDevice */ +#include "exevents.h" +#include "xigrabdev.h" + +int +SProcXIGrabDevice(ClientPtr client) +{ + char n; + + REQUEST(xXIGrabDeviceReq); + + swaps(&stuff->length, n); + swaps(&stuff->deviceid, n); + swapl(&stuff->grab_window, n); + swapl(&stuff->cursor, n); + swapl(&stuff->time, n); + swaps(&stuff->mask_len, n); + + return ProcXIGrabDevice(client); +} + +int +ProcXIGrabDevice(ClientPtr client) +{ + DeviceIntPtr dev; + xXIGrabDeviceReply rep; + int ret = Success; + uint8_t status; + GrabMask mask; + int mask_len; + + REQUEST(xXIGrabDeviceReq); + REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq); + + ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); + if (ret != Success) + return ret; + + if (!IsMaster(dev)) + stuff->paired_device_mode = GrabModeAsync; + + if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1], + stuff->mask_len * 4) != Success) + return BadValue; + + mask_len = min(sizeof(mask.xi2mask[stuff->deviceid]), stuff->mask_len * 4); + memset(mask.xi2mask, 0, sizeof(mask.xi2mask)); + memcpy(mask.xi2mask, (char*)&stuff[1], mask_len); + + ret = GrabDevice(client, dev, stuff->grab_mode, + stuff->paired_device_mode, + stuff->grab_window, + stuff->owner_events, + stuff->time, + &mask, + GRABTYPE_XI2, + stuff->cursor, + None /* confineTo */, + &status); + + if (ret != Success) + return ret; + + rep.repType = X_Reply; + rep.RepType = X_XIGrabDevice; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.status = status; + + + WriteReplyToClient(client, sizeof(rep), &rep); + return ret; +} + +int +SProcXIUngrabDevice(ClientPtr client) +{ + char n; + + REQUEST(xXIUngrabDeviceReq); + + swaps(&stuff->length, n); + swaps(&stuff->deviceid, n); + swapl(&stuff->time, n); + + return ProcXIUngrabDevice(client); +} + +int +ProcXIUngrabDevice(ClientPtr client) +{ + DeviceIntPtr dev; + GrabPtr grab; + int ret = Success; + TimeStamp time; + + REQUEST(xXIUngrabDeviceReq); + + ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); + if (ret != Success) + return ret; + + grab = dev->deviceGrab.grab; + + time = ClientTimeToServerTime(stuff->time); + if ((CompareTimeStamps(time, currentTime) != LATER) && + (CompareTimeStamps(time, dev->deviceGrab.grabTime) != EARLIER) && + (grab) && SameClient(grab, client) && grab->grabtype == GRABTYPE_XI2) + (*dev->deviceGrab.DeactivateGrab) (dev); + + return Success; +} + +void SRepXIGrabDevice(ClientPtr client, int size, xXIGrabDeviceReply * rep) +{ + char n; + + swaps(&rep->sequenceNumber, n); + swapl(&rep->length, n); + WriteToClient(client, size, (char *)rep); +} diff --git a/xorg-server/Xi/xipassivegrab.c b/xorg-server/Xi/xipassivegrab.c index fc3b9e7eb..6b689f45e 100644 --- a/xorg-server/Xi/xipassivegrab.c +++ b/xorg-server/Xi/xipassivegrab.c @@ -118,7 +118,7 @@ ProcXIPassiveGrabDevice(ClientPtr client) return BadValue; } - if (XICheckInvalidMaskBits((unsigned char*)&stuff[1], + if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1], stuff->mask_len * 4) != Success) return BadValue; diff --git a/xorg-server/Xi/xiselectev.c b/xorg-server/Xi/xiselectev.c index 6a810bce4..6f26b3d08 100644 --- a/xorg-server/Xi/xiselectev.c +++ b/xorg-server/Xi/xiselectev.c @@ -42,14 +42,19 @@ * * @return BadValue if at least one invalid bit is set or Success otherwise. */ -int XICheckInvalidMaskBits(unsigned char *mask, int len) +int XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len) { if (len >= XIMaskLen(XI2LASTEVENT)) { int i; for (i = XI2LASTEVENT + 1; i < len * 8; i++) + { if (BitIsOn(mask, i)) + { + client->errorValue = i; return BadValue; + } + } } return Success; @@ -126,7 +131,10 @@ ProcXISelectEvents(ClientPtr client) { unsigned char *bits = (unsigned char*)&evmask[1]; if (BitIsOn(bits, XI_HierarchyChanged)) + { + client->errorValue = XI_HierarchyChanged; return BadValue; + } } /* Raw events may only be selected on root windows */ @@ -138,10 +146,13 @@ ProcXISelectEvents(ClientPtr client) BitIsOn(bits, XI_RawButtonPress) || BitIsOn(bits, XI_RawButtonRelease) || BitIsOn(bits, XI_RawMotion)) + { + client->errorValue = XI_RawKeyPress; return BadValue; + } } - if (XICheckInvalidMaskBits((unsigned char*)&evmask[1], + if (XICheckInvalidMaskBits(client, (unsigned char*)&evmask[1], evmask->mask_len * 4) != Success) return BadValue; diff --git a/xorg-server/composite/compalloc.c b/xorg-server/composite/compalloc.c index 4d0d4ad1c..745166621 100644 --- a/xorg-server/composite/compalloc.c +++ b/xorg-server/composite/compalloc.c @@ -47,6 +47,30 @@ #include "compint.h" +static void +compScreenUpdate (ScreenPtr pScreen) +{ + compCheckTree (pScreen); + compPaintChildrenToWindow (pScreen->root); +} + +static void +compBlockHandler (int i, + pointer blockData, + pointer pTimeout, + pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[i]; + CompScreenPtr cs = GetCompScreen (pScreen); + + pScreen->BlockHandler = cs->BlockHandler; + compScreenUpdate (pScreen); + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + + /* Next damage will restore the block handler */ + cs->BlockHandler = NULL; +} + static void compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure) { @@ -55,8 +79,20 @@ compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure) CompScreenPtr cs = GetCompScreen (pScreen); CompWindowPtr cw = GetCompWindow (pWin); - cs->damaged = TRUE; + if (!cs->BlockHandler) { + cs->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = compBlockHandler; + } cw->damaged = TRUE; + + /* Mark the ancestors */ + pWin = pWin->parent; + while (pWin) { + if (pWin->damagedDescendants) + break; + pWin->damagedDescendants = TRUE; + pWin = pWin->parent; + } } static void diff --git a/xorg-server/composite/compinit.c b/xorg-server/composite/compinit.c index 98b8d0565..291b759be 100644 --- a/xorg-server/composite/compinit.c +++ b/xorg-server/composite/compinit.c @@ -61,7 +61,6 @@ compCloseScreen (int index, ScreenPtr pScreen) free(cs->alternateVisuals); pScreen->CloseScreen = cs->CloseScreen; - pScreen->BlockHandler = cs->BlockHandler; pScreen->InstallColormap = cs->InstallColormap; pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes; pScreen->ReparentWindow = cs->ReparentWindow; @@ -78,6 +77,9 @@ compCloseScreen (int index, ScreenPtr pScreen) pScreen->CopyWindow = cs->CopyWindow; pScreen->PositionWindow = cs->PositionWindow; + pScreen->GetImage = cs->GetImage; + pScreen->SourceValidate = cs->SourceValidate; + free(cs); dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, NULL); ret = (*pScreen->CloseScreen) (index, pScreen); @@ -131,32 +133,40 @@ compChangeWindowAttributes(WindowPtr pWin, unsigned long mask) } static void -compScreenUpdate (ScreenPtr pScreen) +compGetImage (DrawablePtr pDrawable, + int sx, int sy, + int w, int h, + unsigned int format, + unsigned long planemask, + char *pdstLine) { - CompScreenPtr cs = GetCompScreen (pScreen); + ScreenPtr pScreen = pDrawable->pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); - compCheckTree (pScreen); - if (cs->damaged) - { - compWindowUpdate (pScreen->root); - cs->damaged = FALSE; - } + pScreen->GetImage = cs->GetImage; + if (pDrawable->type == DRAWABLE_WINDOW) + compPaintChildrenToWindow ((WindowPtr) pDrawable); + (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine); + cs->GetImage = pScreen->GetImage; + pScreen->GetImage = compGetImage; } -static void -compBlockHandler (int i, - pointer blockData, - pointer pTimeout, - pointer pReadmask) +static void compSourceValidate(DrawablePtr pDrawable, + int x, int y, + int width, int height, + unsigned int subWindowMode) { - ScreenPtr pScreen = screenInfo.screens[i]; - CompScreenPtr cs = GetCompScreen (pScreen); + ScreenPtr pScreen = pDrawable->pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); - pScreen->BlockHandler = cs->BlockHandler; - compScreenUpdate (pScreen); - (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); - cs->BlockHandler = pScreen->BlockHandler; - pScreen->BlockHandler = compBlockHandler; + pScreen->SourceValidate = cs->SourceValidate; + if (pDrawable->type == DRAWABLE_WINDOW && subWindowMode == IncludeInferiors) + compPaintChildrenToWindow ((WindowPtr) pDrawable); + if (pScreen->SourceValidate) + (*pScreen->SourceValidate) (pDrawable, x, y, width, height, + subWindowMode); + cs->SourceValidate = pScreen->SourceValidate; + pScreen->SourceValidate = compSourceValidate; } /* @@ -331,7 +341,6 @@ compScreenInit (ScreenPtr pScreen) if (!cs) return FALSE; - cs->damaged = FALSE; cs->overlayWid = FakeClientID(0); cs->pOverlayWin = NULL; cs->pOverlayClients = NULL; @@ -387,12 +396,17 @@ compScreenInit (ScreenPtr pScreen) cs->ChangeWindowAttributes = pScreen->ChangeWindowAttributes; pScreen->ChangeWindowAttributes = compChangeWindowAttributes; - cs->BlockHandler = pScreen->BlockHandler; - pScreen->BlockHandler = compBlockHandler; + cs->BlockHandler = NULL; cs->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = compCloseScreen; + cs->GetImage = pScreen->GetImage; + pScreen->GetImage = compGetImage; + + cs->SourceValidate = pScreen->SourceValidate; + pScreen->SourceValidate = compSourceValidate; + dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, cs); RegisterRealChildHeadProc(CompositeRealChildHead); diff --git a/xorg-server/composite/compint.h b/xorg-server/composite/compint.h index a85d62faa..55cd6459e 100644 --- a/xorg-server/composite/compint.h +++ b/xorg-server/composite/compint.h @@ -152,7 +152,6 @@ typedef struct _CompScreen { ScreenBlockHandlerProcPtr BlockHandler; CloseScreenProcPtr CloseScreen; - Bool damaged; int numAlternateVisuals; VisualID *alternateVisuals; @@ -160,6 +159,8 @@ typedef struct _CompScreen { Window overlayWid; CompOverlayClientPtr pOverlayClients; + GetImageProcPtr GetImage; + SourceValidateProcPtr SourceValidate; } CompScreenRec, *CompScreenPtr; extern DevPrivateKeyRec CompScreenPrivateKeyRec; @@ -314,7 +315,7 @@ void compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); void -compWindowUpdate (WindowPtr pWin); +compPaintChildrenToWindow (WindowPtr pWin); WindowPtr CompositeRealChildHead (WindowPtr pWin); diff --git a/xorg-server/composite/compwindow.c b/xorg-server/composite/compwindow.c index 11df8b39d..ef1f7f154 100644 --- a/xorg-server/composite/compwindow.c +++ b/xorg-server/composite/compwindow.c @@ -653,9 +653,10 @@ compWindowFormat (WindowPtr pWin) } static void -compWindowUpdateAutomatic (WindowPtr pWin, ScreenPtr pScreen) +compWindowUpdateAutomatic (WindowPtr pWin) { CompWindowPtr cw = GetCompWindow (pWin); + ScreenPtr pScreen = pWin->drawable.pScreen; WindowPtr pParent = pWin->parent; PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin); PictFormatPtr pSrcFormat = compWindowFormat (pWin); @@ -678,7 +679,8 @@ compWindowUpdateAutomatic (WindowPtr pWin, ScreenPtr pScreen) /* * First move the region from window to screen coordinates */ - RegionTranslate(pRegion, pWin->drawable.x, pWin->drawable.y); + RegionTranslate(pRegion, + pWin->drawable.x, pWin->drawable.y); /* * Clip against the "real" border clip @@ -688,7 +690,8 @@ compWindowUpdateAutomatic (WindowPtr pWin, ScreenPtr pScreen) /* * Now translate from screen to dest coordinates */ - RegionTranslate(pRegion, -pParent->drawable.x, -pParent->drawable.y); + RegionTranslate(pRegion, + -pParent->drawable.x, -pParent->drawable.y); /* * Clip the picture @@ -717,26 +720,35 @@ compWindowUpdateAutomatic (WindowPtr pWin, ScreenPtr pScreen) DamageEmpty (cw->damage); } -static int -compWindowUpdateVisit(WindowPtr pWin, void *data) +static void +compPaintWindowToParent (WindowPtr pWin) { + compPaintChildrenToWindow (pWin); + if (pWin->redirectDraw != RedirectDrawNone) { - CompWindowPtr cw = GetCompWindow(pWin); + CompWindowPtr cw = GetCompWindow(pWin); + if (cw->damaged) { - compWindowUpdateAutomatic(pWin, data); + compWindowUpdateAutomatic (pWin); cw->damaged = FALSE; } } - - return WT_WALKCHILDREN; } void -compWindowUpdate (WindowPtr pWin) +compPaintChildrenToWindow (WindowPtr pWin) { - TraverseTree(pWin, compWindowUpdateVisit, pWin->drawable.pScreen); + WindowPtr pChild; + + if (!pWin->damagedDescendants) + return; + + for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib) + compPaintWindowToParent (pChild); + + pWin->damagedDescendants = FALSE; } WindowPtr diff --git a/xorg-server/config/udev.c b/xorg-server/config/udev.c index 43e653d2b..eeacff162 100644 --- a/xorg-server/config/udev.c +++ b/xorg-server/config/udev.c @@ -94,6 +94,7 @@ device_added(struct udev_device *udev_device) if (parent) { const char *ppath = udev_device_get_devnode(parent); const char *product = udev_device_get_property_value(parent, "PRODUCT"); + const char *pnp_id = udev_device_get_sysattr_value(parent, "id"); unsigned int usb_vendor, usb_model; name = udev_device_get_sysattr_value(parent, "name"); @@ -103,8 +104,9 @@ device_added(struct udev_device *udev_device) LOG_PROPERTY(ppath, "NAME", name); } - attrs.pnp_id = udev_device_get_sysattr_value(parent, "id"); - LOG_SYSATTR(ppath, "id", attrs.pnp_id); + if (pnp_id) + attrs.pnp_id = strdup(pnp_id); + LOG_SYSATTR(ppath, "id", pnp_id); /* construct USB ID in lowercase hex - "0000:ffff" */ if (product && sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) { @@ -118,12 +120,13 @@ device_added(struct udev_device *udev_device) if (!name) name = "(unnamed)"; else - attrs.product = name; + attrs.product = strdup(name); add_option(&options, "name", name); add_option(&options, "path", path); add_option(&options, "device", path); - attrs.device = path; + if (path) + attrs.device = strdup(path); tags_prop = udev_device_get_property_value(udev_device, "ID_INPUT.tags"); LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop); @@ -162,7 +165,7 @@ device_added(struct udev_device *udev_device) add_option(&options, "xkb_options", value); } else if (!strcmp(key, "ID_VENDOR")) { LOG_PROPERTY(path, key, value); - attrs.vendor = value; + attrs.vendor = strdup(value); } else if (!strcmp(key, "ID_INPUT_KEY")) { LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_KEYBOARD; @@ -202,6 +205,10 @@ device_added(struct udev_device *udev_device) } free(attrs.usb_id); + free(attrs.pnp_id); + free(attrs.product); + free(attrs.device); + free(attrs.vendor); if (attrs.tags) { char **tag = attrs.tags; while (*tag) { @@ -307,7 +314,7 @@ config_udev_fini(void) udev = udev_monitor_get_udev(udev_monitor); RemoveGeneralSocket(udev_monitor_get_fd(udev_monitor)); - RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, udev_monitor); + RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL); udev_monitor_unref(udev_monitor); udev_monitor = NULL; udev_unref(udev); diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c index 0667cc293..361d6102a 100644 --- a/xorg-server/dix/events.c +++ b/xorg-server/dix/events.c @@ -195,8 +195,6 @@ typedef const char *string; #define XE_KBPTR (xE->u.keyButtonPointer) -#define rClient(obj) (clients[CLIENT_ID((obj)->resource)]) - CallbackListPtr EventCallback; CallbackListPtr DeviceEventCallback; @@ -2291,17 +2289,6 @@ FixUpEventFromWindow( } } -/** - * Return masks for EventIsDeliverable. - * @defgroup EventIsDeliverable return flags - * @{ - */ -#define XI_MASK (1 << 0) /**< XI mask set on window */ -#define CORE_MASK (1 << 1) /**< Core mask set on window */ -#define DONT_PROPAGATE_MASK (1 << 2) /**< DontPropagate mask set on window */ -#define XI2_MASK (1 << 3) /**< XI2 mask set on window */ -/* @} */ - /** * Check if a given event is deliverable at all on a given window. * @@ -2315,7 +2302,7 @@ FixUpEventFromWindow( * @return Bitmask of ::XI2_MASK, ::XI_MASK, ::CORE_MASK, and * ::DONT_PROPAGATE_MASK. */ -static int +int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win) { int rc = 0; diff --git a/xorg-server/dix/property.c b/xorg-server/dix/property.c index 2ba3f4419..53b9821a9 100644 --- a/xorg-server/dix/property.c +++ b/xorg-server/dix/property.c @@ -424,6 +424,9 @@ DeleteAllWindowProperties(WindowPtr pWin) dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); pProp = pNextProp; } + + if (pWin->optional) + pWin->optional->userProps = NULL; } static int diff --git a/xorg-server/dix/window.c b/xorg-server/dix/window.c index 399e08635..c2cee9198 100644 --- a/xorg-server/dix/window.c +++ b/xorg-server/dix/window.c @@ -298,6 +298,10 @@ SetWindowToDefaults(WindowPtr pWin) #ifdef ROOTLESS pWin->rootlessUnhittable = FALSE; #endif + +#ifdef COMPOSITE + pWin->damagedDescendants = FALSE; +#endif } static void diff --git a/xorg-server/doc/xml/Xserver-spec.xml b/xorg-server/doc/xml/Xserver-spec.xml index c31a8c4e2..a48e88754 100644 --- a/xorg-server/doc/xml/Xserver-spec.xml +++ b/xorg-server/doc/xml/Xserver-spec.xml @@ -2954,16 +2954,17 @@ The sample server implementation is in Xserver/fb/fbscreen.c. pScreen->SourceValidate(pDrawable, x, y, width, height) DrawablePtr pDrawable; int x, y, width, height; + unsigned int subWindowMode; SourceValidate should be called by CopyArea/CopyPlane primitives when -the source drawable is not the same as the destination, and the -SourceValidate function pointer in the screen is non-null. If you know that +the SourceValidate function pointer in the screen is non-null. If you know that you will never need SourceValidate, you can avoid this check. Currently, SourceValidate is used by the mi software cursor code to remove the cursor from the screen when the source rectangle overlaps the cursor position. x,y,width,height describe the source rectangle (source relative, that is) -for the copy operation. +for the copy operation. subWindowMode comes from the GC or source Picture. +
    diff --git a/xorg-server/exa/exa_mixed.c b/xorg-server/exa/exa_mixed.c index 52144c9ad..9ab9c0dcf 100644 --- a/xorg-server/exa/exa_mixed.c +++ b/xorg-server/exa/exa_mixed.c @@ -98,7 +98,7 @@ exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth, pExaPixmap->use_gpu_copy = FALSE; if (w == 1 && h == 1) { - pExaPixmap->sys_ptr = malloc((pPixmap->drawable.bitsPerPixel + 7) / 8); + pExaPixmap->sys_ptr = malloc(paddedWidth); /* Set up damage tracking */ pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL, diff --git a/xorg-server/exa/exa_unaccel.c b/xorg-server/exa/exa_unaccel.c index e53a371a7..354733921 100644 --- a/xorg-server/exa/exa_unaccel.c +++ b/xorg-server/exa/exa_unaccel.c @@ -438,7 +438,8 @@ ExaSrcValidate(DrawablePtr pDrawable, int x, int y, int width, - int height) + int height, + unsigned int subWindowMode) { ScreenPtr pScreen = pDrawable->pScreen; ExaScreenPriv(pScreen); @@ -464,7 +465,7 @@ ExaSrcValidate(DrawablePtr pDrawable, if (pExaScr->SavedSourceValidate) { swap(pExaScr, pScreen, SourceValidate); - pScreen->SourceValidate(pDrawable, x, y, width, height); + pScreen->SourceValidate(pDrawable, x, y, width, height, subWindowMode); swap(pExaScr, pScreen, SourceValidate); } } diff --git a/xorg-server/glx/glxdri2.c b/xorg-server/glx/glxdri2.c index ce8014396..c9c316be5 100644 --- a/xorg-server/glx/glxdri2.c +++ b/xorg-server/glx/glxdri2.c @@ -594,7 +594,7 @@ static const __DRIextension *loader_extensions[] = { &systemTimeExtension.base, &loaderExtension.base, #ifdef __DRI_USE_INVALIDATE - &dri2UseInvalidate, + &dri2UseInvalidate.base, #endif NULL }; diff --git a/xorg-server/glx/unpack.h b/xorg-server/glx/unpack.h index 7e6a55105..a5f211555 100644 --- a/xorg-server/glx/unpack.h +++ b/xorg-server/glx/unpack.h @@ -47,7 +47,7 @@ ** Fetch a double from potentially unaligned memory. */ #ifdef __GLX_ALIGN64 -#define __GLX_MEM_COPY(dst,src,n) if (src != NULL && dst != NULL) memcpy(dst,src,n) +#define __GLX_MEM_COPY(dst,src,n) memmove(dst,src,n) #define __GLX_GET_DOUBLE(dst,src) __GLX_MEM_COPY(&dst,src,8) #else #define __GLX_GET_DOUBLE(dst,src) (dst) = *((GLdouble*)(src)) diff --git a/xorg-server/hw/dmx/glxProxy/unpack.h b/xorg-server/hw/dmx/glxProxy/unpack.h index b89a53411..c592c3d92 100644 --- a/xorg-server/hw/dmx/glxProxy/unpack.h +++ b/xorg-server/hw/dmx/glxProxy/unpack.h @@ -43,7 +43,7 @@ ** Fetch a double from potentially unaligned memory. */ #ifdef __GLX_ALIGN64 -#define __GLX_MEM_COPY(dst,src,n) memcpy(dst,src,n) +#define __GLX_MEM_COPY(dst,src,n) memmove(dst,src,n) #define __GLX_GET_DOUBLE(dst,src) __GLX_MEM_COPY(&dst,src,8) #else #define __GLX_GET_DOUBLE(dst,src) (dst) = *((GLdouble*)(src)) diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c index 384f08103..1b9253269 100644 --- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c +++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c @@ -120,7 +120,7 @@ FreeList(const char ***list, int *lines) int i; for (i = 0; i < *lines; i++) { - free((*list)[i]); + free((char *)((*list)[i])); } free(*list); *list = NULL; diff --git a/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h index fb6f9673d..0e7be4dd7 100644 --- a/xorg-server/hw/xfree86/common/xf86Module.h +++ b/xorg-server/hw/xfree86/common/xf86Module.h @@ -83,7 +83,7 @@ typedef enum { */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4) #define ABI_VIDEODRV_VERSION SET_ABI_VERSION(9, 0) -#define ABI_XINPUT_VERSION SET_ABI_VERSION(12, 0) +#define ABI_XINPUT_VERSION SET_ABI_VERSION(12, 1) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(5, 0) #define ABI_FONT_VERSION SET_ABI_VERSION(0, 6) diff --git a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c index 50ea6ca9e..0aa6f2cf4 100644 --- a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c +++ b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c @@ -325,13 +325,14 @@ VGAarbiterGetSpans ( static void VGAarbiterSourceValidate ( DrawablePtr pDrawable, - int x, int y, int width, int height ) + int x, int y, int width, int height, + unsigned int subWindowMode ) { ScreenPtr pScreen = pDrawable->pScreen; SCREEN_PROLOG (SourceValidate); VGAGet(pScreen); if (pScreen->SourceValidate) - (*pScreen->SourceValidate) (pDrawable, x, y, width, height); + (*pScreen->SourceValidate) (pDrawable, x, y, width, height, subWindowMode); VGAPut(); SCREEN_EPILOG (SourceValidate, VGAarbiterSourceValidate); } diff --git a/xorg-server/hw/xfree86/common/xf86VGAarbiterPriv.h b/xorg-server/hw/xfree86/common/xf86VGAarbiterPriv.h index 0107a4952..13fde5e79 100644 --- a/xorg-server/hw/xfree86/common/xf86VGAarbiterPriv.h +++ b/xorg-server/hw/xfree86/common/xf86VGAarbiterPriv.h @@ -149,7 +149,7 @@ static void VGAarbiterGetImage (DrawablePtr pDrawable, int sx, int sy, int w, static void VGAarbiterGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart); static void VGAarbiterSourceValidate (DrawablePtr pDrawable, int x, int y, - int width, int height); + int width, int height, unsigned int subWindowMode); static void VGAarbiterCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); static void VGAarbiterClearToBackground (WindowPtr pWin, int x, int y, int w, diff --git a/xorg-server/hw/xfree86/dixmods/extmod/modinit.c b/xorg-server/hw/xfree86/dixmods/extmod/modinit.c index ee3e52855..632454f37 100644 --- a/xorg-server/hw/xfree86/dixmods/extmod/modinit.c +++ b/xorg-server/hw/xfree86/dixmods/extmod/modinit.c @@ -146,7 +146,7 @@ extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin) for (i = 0; extensionModules[i].name != NULL; i++) { if (opts) { char *s; - if (Xasprinf(&s, "omit%s", extensionModules[i].name) != -1) { + if (asprintf(&s, "omit%s", extensionModules[i].name) != -1) { pointer o; o = xf86FindOption(opts, s); free(s); diff --git a/xorg-server/hw/xfree86/dixmods/extmod/modinit.h b/xorg-server/hw/xfree86/dixmods/extmod/modinit.h index 1154e4601..9753e6f14 100644 --- a/xorg-server/hw/xfree86/dixmods/extmod/modinit.h +++ b/xorg-server/hw/xfree86/dixmods/extmod/modinit.h @@ -1,82 +1,86 @@ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef INITARGS -#define INITARGS void -#endif - -#include - -#ifdef XTEST -extern void XTestExtensionInit(INITARGS); -#include -#endif - -#if 1 -extern void XTestExtension1Init(INITARGS); -#endif - -#ifdef SCREENSAVER -extern void ScreenSaverExtensionInit (INITARGS); -#include -#endif - -#ifdef XF86VIDMODE -extern void XFree86VidModeExtensionInit(INITARGS); -#include -#endif - -#ifdef XFreeXDGA -extern void XFree86DGAExtensionInit(INITARGS); -extern void XFree86DGARegister(INITARGS); -#include -#endif - -#ifdef DPMSExtension -extern void DPMSExtensionInit(INITARGS); -#include -#endif - -#ifdef XV -extern void XvExtensionInit(INITARGS); -extern void XvMCExtensionInit(INITARGS); -extern void XvRegister(INITARGS); -#include -#include -#endif - -#ifdef RES -extern void ResExtensionInit(INITARGS); -#include -#endif - -#ifdef SHM -extern void ShmExtensionInit(INITARGS); -#include -extern void ShmRegisterFuncs( - ScreenPtr pScreen, - ShmFuncsPtr funcs); -#endif - -#ifdef XSELINUX -extern void SELinuxExtensionInit(INITARGS); -#include "xselinux.h" -#endif - -#ifdef XEVIE -extern void XevieExtensionInit(INITARGS); -#endif - -#if 1 -extern void SecurityExtensionInit(INITARGS); -#endif - -#if 1 -extern void PanoramiXExtensionInit(int argc, char *argv[]); -#endif - -#if 1 -extern void XkbExtensionInit(INITARGS); -#endif + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef INITARGS +#define INITARGS void +#endif + +#include + +#ifdef XTEST +extern void XTestExtensionInit(INITARGS); +#include +#endif + +#if 1 +extern void XTestExtension1Init(INITARGS); +#endif + +#if 1 +extern void XCMiscExtensionInit(INITARGS); +#endif + +#ifdef SCREENSAVER +extern void ScreenSaverExtensionInit (INITARGS); +#include +#endif + +#ifdef XF86VIDMODE +extern void XFree86VidModeExtensionInit(INITARGS); +#include +#endif + +#ifdef XFreeXDGA +extern void XFree86DGAExtensionInit(INITARGS); +extern void XFree86DGARegister(INITARGS); +#include +#endif + +#ifdef DPMSExtension +extern void DPMSExtensionInit(INITARGS); +#include +#endif + +#ifdef XV +extern void XvExtensionInit(INITARGS); +extern void XvMCExtensionInit(INITARGS); +extern void XvRegister(INITARGS); +#include +#include +#endif + +#ifdef RES +extern void ResExtensionInit(INITARGS); +#include +#endif + +#ifdef SHM +extern void ShmExtensionInit(INITARGS); +#include +extern void ShmRegisterFuncs( + ScreenPtr pScreen, + ShmFuncsPtr funcs); +#endif + +#ifdef XSELINUX +extern void SELinuxExtensionInit(INITARGS); +#include "xselinux.h" +#endif + +#ifdef XEVIE +extern void XevieExtensionInit(INITARGS); +#endif + +#if 1 +extern void SecurityExtensionInit(INITARGS); +#endif + +#if 1 +extern void PanoramiXExtensionInit(int argc, char *argv[]); +#endif + +#if 1 +extern void XkbExtensionInit(INITARGS); +#endif diff --git a/xorg-server/hw/xfree86/dri/dri.c b/xorg-server/hw/xfree86/dri/dri.c index 9ca5ecd0b..38241f904 100644 --- a/xorg-server/hw/xfree86/dri/dri.c +++ b/xorg-server/hw/xfree86/dri/dri.c @@ -431,7 +431,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer) { if (drmAddMap( pDRIPriv->drmFD, - (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress, + (uintptr_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress, pDRIPriv->pDriverInfo->frameBufferSize, DRM_FRAME_BUFFER, 0, diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c index 578773a5a..aba2202d6 100644 --- a/xorg-server/hw/xfree86/dri2/dri2.c +++ b/xorg-server/hw/xfree86/dri2/dri2.c @@ -640,6 +640,17 @@ DRI2CanFlip(DrawablePtr pDraw) if (!RegionEqual(&pWin->clipList, &pRoot->winSize)) return FALSE; + /* Does the window match the pixmap exactly? */ + if (pDraw->x != 0 || + pDraw->y != 0 || +#ifdef COMPOSITE + pDraw->x != pWinPixmap->screen_x || + pDraw->y != pWinPixmap->screen_y || +#endif + pDraw->width != pWinPixmap->drawable.width || + pDraw->height != pWinPixmap->drawable.height) + return FALSE; + return TRUE; } diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c index dbc16eab7..271cb5b79 100644 --- a/xorg-server/hw/xfree86/loader/loadmod.c +++ b/xorg-server/hw/xfree86/loader/loadmod.c @@ -374,7 +374,7 @@ FreeSubdirs(const char **subdirs) if (subdirs) { for (s = subdirs; *s; s++) - free(*s); + free((char *)*s); free(subdirs); } } diff --git a/xorg-server/hw/xfree86/modes/xf86EdidModes.c b/xorg-server/hw/xfree86/modes/xf86EdidModes.c index d9ece7a14..9e0dc9d32 100644 --- a/xorg-server/hw/xfree86/modes/xf86EdidModes.c +++ b/xorg-server/hw/xfree86/modes/xf86EdidModes.c @@ -1,1216 +1,1216 @@ -/* - * Copyright 2006 Luc Verhaegen. - * 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 - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * 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 NON-INFRINGEMENT. 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. - */ - -/** - * @file This file covers code to convert a xf86MonPtr containing EDID-probed - * information into a list of modes, including applying monitor-specific - * quirks to fix broken EDID data. - */ -#ifdef HAVE_XORG_CONFIG_H -#include -#else -#ifdef HAVE_CONFIG_H -#include -#endif -#endif - -#define _PARSE_EDID_ -#include "xf86.h" -#include "xf86DDC.h" -#include -#include "property.h" -#include "propertyst.h" -#include "xf86Crtc.h" -#include -#include - -static void handle_detailed_rblank(struct detailed_monitor_section *det_mon, - void *data) -{ - if (det_mon->type == DS_RANGES) - if (det_mon->section.ranges.supported_blanking & CVT_REDUCED) - *(Bool*)data = TRUE; -} - -static Bool -xf86MonitorSupportsReducedBlanking(xf86MonPtr DDC) -{ - /* EDID 1.4 explicitly defines RB support */ - if (DDC->ver.revision >= 4) { - Bool ret = FALSE; - - xf86ForEachDetailedBlock(DDC, handle_detailed_rblank, &ret); - return ret; - } - - /* For anything older, assume digital means RB support. Boo. */ - if (DDC->features.input_type) - return TRUE; - - return FALSE; -} - -static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC) -{ - /* Belinea 10 15 55 */ - if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && - ((DDC->vendor.prod_id == 1516) || - (DDC->vendor.prod_id == 0x77e))) - return TRUE; - - /* Acer AL1706 */ - if (memcmp (DDC->vendor.name, "ACR", 4) == 0 && - DDC->vendor.prod_id == 44358) - return TRUE; - - /* Bug #10814: Samsung SyncMaster 225BW */ - if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && - DDC->vendor.prod_id == 596) - return TRUE; - - /* Bug #10545: Samsung SyncMaster 226BW */ - if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && - DDC->vendor.prod_id == 638) - return TRUE; - - /* Acer F51 */ - if (memcmp (DDC->vendor.name, "API", 4) == 0 && - DDC->vendor.prod_id == 0x7602) - return TRUE; - - - return FALSE; -} - -static Bool quirk_prefer_large_75 (int scrnIndex, xf86MonPtr DDC) -{ - /* Bug #11603: Funai Electronics PM36B */ - if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && - DDC->vendor.prod_id == 13600) - return TRUE; - - return FALSE; -} - -static Bool quirk_detailed_h_in_cm (int scrnIndex, xf86MonPtr DDC) -{ - /* Bug #11603: Funai Electronics PM36B */ - if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && - DDC->vendor.prod_id == 13600) - return TRUE; - - return FALSE; -} - -static Bool quirk_detailed_v_in_cm (int scrnIndex, xf86MonPtr DDC) -{ - /* Bug #11603: Funai Electronics PM36B */ - if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && - DDC->vendor.prod_id == 13600) - return TRUE; - - /* Bug #21000: LGPhilipsLCD LP154W01-TLAJ */ - if (memcmp (DDC->vendor.name, "LPL", 4) == 0 && - DDC->vendor.prod_id == 47360) - return TRUE; - - /* Bug #10304: LGPhilipsLCD LP154W01-A5 */ - if (memcmp(DDC->vendor.name, "LPL", 4) == 0 && - DDC->vendor.prod_id == 0) - return TRUE; - - /* Bug #24482: LGPhilipsLCD LP154W01-TLA1 */ - if (memcmp(DDC->vendor.name, "LPL", 4) == 0 && - DDC->vendor.prod_id == 0x2a00) - return TRUE; - - /* Bug #28414: HP Compaq NC8430 LP154W01-TLA8 */ - if (memcmp (DDC->vendor.name, "LPL", 4) == 0 && - DDC->vendor.prod_id == 5750) - return TRUE; - - /* Bug #21750: Samsung Syncmaster 2333HD */ - if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && - DDC->vendor.prod_id == 1157) - return TRUE; - - return FALSE; -} - -static Bool quirk_detailed_use_maximum_size (int scrnIndex, xf86MonPtr DDC) -{ - /* Bug #21324: Iiyama Vision Master 450 */ - if (memcmp (DDC->vendor.name, "IVM", 4) == 0 && - DDC->vendor.prod_id == 6400) - return TRUE; - - return FALSE; -} - -static Bool quirk_135_clock_too_high (int scrnIndex, xf86MonPtr DDC) -{ - /* Envision Peripherals, Inc. EN-7100e. See bug #9550. */ - if (memcmp (DDC->vendor.name, "EPI", 4) == 0 && - DDC->vendor.prod_id == 59264) - return TRUE; - - return FALSE; -} - -static Bool quirk_first_detailed_preferred (int scrnIndex, xf86MonPtr DDC) -{ - /* Philips 107p5 CRT. Reported on xorg@ with pastebin. */ - if (memcmp (DDC->vendor.name, "PHL", 4) == 0 && - DDC->vendor.prod_id == 57364) - return TRUE; - - /* Proview AY765C 17" LCD. See bug #15160*/ - if (memcmp (DDC->vendor.name, "PTS", 4) == 0 && - DDC->vendor.prod_id == 765) - return TRUE; - - /* ACR of some sort RH #284231 */ - if (memcmp (DDC->vendor.name, "ACR", 4) == 0 && - DDC->vendor.prod_id == 2423) - return TRUE; - - /* Peacock Ergovision 19. See rh#492359 */ - if (memcmp (DDC->vendor.name, "PEA", 4) == 0 && - DDC->vendor.prod_id == 9003) - return TRUE; - - return FALSE; -} - -static Bool quirk_detailed_sync_pp(int scrnIndex, xf86MonPtr DDC) -{ - /* Bug #12439: Samsung SyncMaster 205BW */ - if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && - DDC->vendor.prod_id == 541) - return TRUE; - return FALSE; -} - -/* This should probably be made more generic */ -static Bool quirk_dvi_single_link(int scrnIndex, xf86MonPtr DDC) -{ - /* Red Hat bug #453106: Apple 23" Cinema Display */ - if (memcmp (DDC->vendor.name, "APL", 4) == 0 && - DDC->vendor.prod_id == 0x921c) - return TRUE; - return FALSE; -} - -typedef struct { - Bool (*detect) (int scrnIndex, xf86MonPtr DDC); - ddc_quirk_t quirk; - char *description; -} ddc_quirk_map_t; - -static const ddc_quirk_map_t ddc_quirks[] = { - { - quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60, - "Detailed timing is not preferred, use largest mode at 60Hz" - }, - { - quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH, - "Recommended 135MHz pixel clock is too high" - }, - { - quirk_prefer_large_75, DDC_QUIRK_PREFER_LARGE_75, - "Detailed timing is not preferred, use largest mode at 75Hz" - }, - { - quirk_detailed_h_in_cm, DDC_QUIRK_DETAILED_H_IN_CM, - "Detailed timings give horizontal size in cm." - }, - { - quirk_detailed_v_in_cm, DDC_QUIRK_DETAILED_V_IN_CM, - "Detailed timings give vertical size in cm." - }, - { - quirk_detailed_use_maximum_size, DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE, - "Use maximum size instead of detailed timing sizes." - }, - { - quirk_first_detailed_preferred, DDC_QUIRK_FIRST_DETAILED_PREFERRED, - "First detailed timing was not marked as preferred." - }, - { - quirk_detailed_sync_pp, DDC_QUIRK_DETAILED_SYNC_PP, - "Use +hsync +vsync for detailed timing." - }, - { - quirk_dvi_single_link, DDC_QUIRK_DVI_SINGLE_LINK, - "Forcing maximum pixel clock to single DVI link." - }, - { - NULL, DDC_QUIRK_NONE, - "No known quirks" - }, -}; - -/* - * These more or less come from the DMT spec. The 720x400 modes are - * inferred from historical 80x25 practice. The 640x480@67 and 832x624@75 - * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode - * should be 1152x870, again for the Mac, but instead we use the x864 DMT - * mode. - * - * The DMT modes have been fact-checked; the rest are mild guesses. - */ -#define MODEPREFIX NULL, NULL, NULL, 0, M_T_DRIVER -#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0 - -static const DisplayModeRec DDCEstablishedModes[17] = { - { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ - { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ - { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ - { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ - { MODEPREFIX, 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */ - { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ - { MODEPREFIX, 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */ - { MODEPREFIX, 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */ - { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ - { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ - { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ - { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ - { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */ - { MODEPREFIX, 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */ - { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ - { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ - { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ -}; - -static DisplayModePtr -DDCModesFromEstablished(int scrnIndex, struct established_timings *timing, - ddc_quirk_t quirks) -{ - DisplayModePtr Modes = NULL, Mode = NULL; - CARD32 bits = (timing->t1) | (timing->t2 << 8) | - ((timing->t_manu & 0x80) << 9); - int i; - - for (i = 0; i < 17; i++) { - if (bits & (0x01 << i)) { - Mode = xf86DuplicateMode(&DDCEstablishedModes[i]); - Modes = xf86ModesAdd(Modes, Mode); - } - } - - return Modes; -} - -/* Autogenerated from the DMT spec */ -const DisplayModeRec DMTModes[] = { - { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 350, 382, 385, 445, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x350@85Hz */ - { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 400, 401, 404, 445, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 640x400@85Hz */ - { MODEPREFIX, 35500, 720, 756, 828, 936, 0, 400, 401, 404, 446, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@85Hz */ - { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ - { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ - { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ - { MODEPREFIX, 36000, 640, 696, 752, 832, 0, 480, 481, 484, 509, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@85Hz */ - { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ - { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ - { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ - { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ - { MODEPREFIX, 56250, 800, 832, 896, 1048, 0, 600, 601, 604, 631, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@85Hz */ - { MODEPREFIX, 73250, 800, 848, 880, 960, 0, 600, 603, 607, 636, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 800x600@120Hz RB */ - { MODEPREFIX, 33750, 848, 864, 976, 1088, 0, 480, 486, 494, 517, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 848x480@60Hz */ - { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz (interlaced) */ - { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ - { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ - { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ - { MODEPREFIX, 94500, 1024, 1072, 1168, 1376, 0, 768, 769, 772, 808, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@85Hz */ - { MODEPREFIX, 115500, 1024, 1072, 1104, 1184, 0, 768, 771, 775, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@120Hz RB */ - { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ - { MODEPREFIX, 68250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 790, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@60Hz RB */ - { MODEPREFIX, 79500, 1280, 1344, 1472, 1664, 0, 768, 771, 778, 798, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@60Hz */ - { MODEPREFIX, 102250, 1280, 1360, 1488, 1696, 0, 768, 771, 778, 805, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@75Hz */ - { MODEPREFIX, 117500, 1280, 1360, 1496, 1712, 0, 768, 771, 778, 809, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@85Hz */ - { MODEPREFIX, 140250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@120Hz RB */ - { MODEPREFIX, 71000, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 823, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@60Hz RB */ - { MODEPREFIX, 83500, 1280, 1352, 1480, 1680, 0, 800, 803, 809, 831, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@60Hz */ - { MODEPREFIX, 106500, 1280, 1360, 1488, 1696, 0, 800, 803, 809, 838, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@75Hz */ - { MODEPREFIX, 122500, 1280, 1360, 1496, 1712, 0, 800, 803, 809, 843, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@85Hz */ - { MODEPREFIX, 146250, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 847, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@120Hz RB */ - { MODEPREFIX, 108000, 1280, 1376, 1488, 1800, 0, 960, 961, 964, 1000, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@60Hz */ - { MODEPREFIX, 148500, 1280, 1344, 1504, 1728, 0, 960, 961, 964, 1011, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@85Hz */ - { MODEPREFIX, 175500, 1280, 1328, 1360, 1440, 0, 960, 963, 967, 1017, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x960@120Hz RB */ - { MODEPREFIX, 108000, 1280, 1328, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@60Hz */ - { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ - { MODEPREFIX, 157500, 1280, 1344, 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@85Hz */ - { MODEPREFIX, 187250, 1280, 1328, 1360, 1440, 0, 1024, 1027, 1034, 1084, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x1024@120Hz RB */ - { MODEPREFIX, 85500, 1360, 1424, 1536, 1792, 0, 768, 771, 777, 795, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1360x768@60Hz */ - { MODEPREFIX, 148250, 1360, 1408, 1440, 1520, 0, 768, 771, 776, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1360x768@120Hz RB */ - { MODEPREFIX, 101000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@60Hz RB */ - { MODEPREFIX, 121750, 1400, 1488, 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@60Hz */ - { MODEPREFIX, 156000, 1400, 1504, 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@75Hz */ - { MODEPREFIX, 179500, 1400, 1504, 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@85Hz */ - { MODEPREFIX, 208000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@120Hz RB */ - { MODEPREFIX, 88750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 926, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@60Hz RB */ - { MODEPREFIX, 106500, 1440, 1520, 1672, 1904, 0, 900, 903, 909, 934, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@60Hz */ - { MODEPREFIX, 136750, 1440, 1536, 1688, 1936, 0, 900, 903, 909, 942, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@75Hz */ - { MODEPREFIX, 157000, 1440, 1544, 1696, 1952, 0, 900, 903, 909, 948, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@85Hz */ - { MODEPREFIX, 182750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 953, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@120Hz RB */ - { MODEPREFIX, 162000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@60Hz */ - { MODEPREFIX, 175500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@65Hz */ - { MODEPREFIX, 189000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@70Hz */ - { MODEPREFIX, 202500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@75Hz */ - { MODEPREFIX, 229500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@85Hz */ - { MODEPREFIX, 268250, 1600, 1648, 1680, 1760, 0, 1200, 1203, 1207, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1600x1200@120Hz RB */ - { MODEPREFIX, 119000, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@60Hz RB */ - { MODEPREFIX, 146250, 1680, 1784, 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@60Hz */ - { MODEPREFIX, 187000, 1680, 1800, 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@75Hz */ - { MODEPREFIX, 214750, 1680, 1808, 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@85Hz */ - { MODEPREFIX, 245500, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@120Hz RB */ - { MODEPREFIX, 204750, 1792, 1920, 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@60Hz */ - { MODEPREFIX, 261000, 1792, 1888, 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@75Hz */ - { MODEPREFIX, 333250, 1792, 1840, 1872, 1952, 0, 1344, 1347, 1351, 1423, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1792x1344@120Hz RB */ - { MODEPREFIX, 218250, 1856, 1952, 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@60Hz */ - { MODEPREFIX, 288000, 1856, 1984, 2208, 2560, 0, 1392, 1393, 1396, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@75Hz */ - { MODEPREFIX, 356500, 1856, 1904, 1936, 2016, 0, 1392, 1395, 1399, 1474, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1856x1392@120Hz RB */ - { MODEPREFIX, 154000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1235, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@60Hz RB */ - { MODEPREFIX, 193250, 1920, 2056, 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@60Hz */ - { MODEPREFIX, 245250, 1920, 2056, 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@75Hz */ - { MODEPREFIX, 281250, 1920, 2064, 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@85Hz */ - { MODEPREFIX, 317000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@120Hz RB */ - { MODEPREFIX, 234000, 1920, 2048, 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@60Hz */ - { MODEPREFIX, 297000, 1920, 2064, 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@75Hz */ - { MODEPREFIX, 380500, 1920, 1968, 2000, 2080, 0, 1440, 1443, 1447, 1525, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1440@120Hz RB */ - { MODEPREFIX, 268500, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1646, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@60Hz RB */ - { MODEPREFIX, 348500, 2560, 2752, 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@60Hz */ - { MODEPREFIX, 443250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@75Hz */ - { MODEPREFIX, 505250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@85Hz */ - { MODEPREFIX, 552750, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@120Hz RB */ -}; - -#define LEVEL_DMT 0 -#define LEVEL_GTF 1 -#define LEVEL_CVT 2 - -static int -MonitorStandardTimingLevel(xf86MonPtr DDC) -{ - if (DDC->ver.revision >= 2) { - if (DDC->ver.revision >= 4 && CVT_SUPPORTED(DDC->features.msc)) { - return LEVEL_CVT; - } - return LEVEL_GTF; - } - return LEVEL_DMT; -} - -static int -ModeRefresh(const DisplayModeRec *mode) -{ - return (int)(xf86ModeVRefresh(mode) + 0.5); -} - -/* - * If rb is not set, then we'll not consider reduced-blanking modes as - * part of the DMT pool. For the 'standard' EDID mode descriptor there's - * no way to specify whether the mode should be RB or not. - */ -DisplayModePtr -FindDMTMode(int hsize, int vsize, int refresh, Bool rb) -{ - int i; - const DisplayModeRec *ret; - - for (i = 0; i < sizeof(DMTModes) / sizeof(DisplayModeRec); i++) { - ret = &DMTModes[i]; - - if (!rb && xf86ModeIsReduced(ret)) - continue; - - if (ret->HDisplay == hsize && - ret->VDisplay == vsize && - refresh == ModeRefresh(ret)) - return xf86DuplicateMode(ret); - } - - return NULL; -} - -/* - * Appendix B of the EDID 1.4 spec defines the right thing to do here. - * If the timing given here matches a mode defined in the VESA DMT standard, - * we _must_ use that. If the device supports CVT modes, then we should - * generate a CVT timing. If both of the above fail, use GTF. - * - * There are some wrinkles here. EDID 1.1 and 1.0 sinks can't really - * "support" GTF, since it wasn't a standard yet; so if they ask for a - * timing in this section that isn't defined in DMT, returning a GTF mode - * may not actually be valid. EDID 1.3 sinks often report support for - * some CVT modes, but they are not required to support CVT timings for - * modes in the standard timing descriptor, so we should _not_ treat them - * as CVT-compliant (unless specified in an extension block I suppose). - * - * EDID 1.4 requires that all sink devices support both GTF and CVT timings - * for modes in this section, but does say that CVT is preferred. - */ -static DisplayModePtr -DDCModesFromStandardTiming(struct std_timings *timing, ddc_quirk_t quirks, - int timing_level, Bool rb) -{ - DisplayModePtr Modes = NULL, Mode = NULL; - int i, hsize, vsize, refresh; - - for (i = 0; i < STD_TIMINGS; i++) { - hsize = timing[i].hsize; - vsize = timing[i].vsize; - refresh = timing[i].refresh; - - /* HDTV hack, because you can't say 1366 */ - if (refresh == 60 && - ((hsize == 1360 && vsize == 765) || - (hsize == 1368 && vsize == 769))) { - Mode = xf86CVTMode(1366, 768, 60, FALSE, FALSE); - Mode->HDisplay = 1366; - Mode->HSyncStart--; - Mode->HSyncEnd--; - } else if (hsize && vsize && refresh) { - Mode = FindDMTMode(hsize, vsize, refresh, rb); - - if (!Mode) { - if (timing_level == LEVEL_CVT) - /* pass rb here too? */ - Mode = xf86CVTMode(hsize, vsize, refresh, FALSE, FALSE); - else if (timing_level == LEVEL_GTF) - Mode = xf86GTFMode(hsize, vsize, refresh, FALSE, FALSE); - } - - } - - if (Mode) { - Mode->type = M_T_DRIVER; - Modes = xf86ModesAdd(Modes, Mode); - } - Mode = NULL; - } - - return Modes; -} - -static void -DDCModeDoInterlaceQuirks(DisplayModePtr mode) -{ - /* - * EDID is delightfully ambiguous about how interlaced modes are to be - * encoded. X's internal representation is of frame height, but some - * HDTV detailed timings are encoded as field height. - * - * The format list here is from CEA, in frame size. Technically we - * should be checking refresh rate too. Whatever. - */ - static const struct { - int w, h; - } cea_interlaced[] = { - { 1920, 1080 }, - { 720, 480 }, - { 1440, 480 }, - { 2880, 480 }, - { 720, 576 }, - { 1440, 576 }, - { 2880, 576 }, - }; - static const int n_modes = sizeof(cea_interlaced)/sizeof(cea_interlaced[0]); - int i; - - for (i = 0; i < n_modes; i++) { - if ((mode->HDisplay == cea_interlaced[i].w) && - (mode->VDisplay == cea_interlaced[i].h / 2)) { - mode->VDisplay *= 2; - mode->VSyncStart *= 2; - mode->VSyncEnd *= 2; - mode->VTotal *= 2; - mode->VTotal |= 1; - } - } - - mode->Flags |= V_INTERLACE; -} - -/* - * - */ -static DisplayModePtr -DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, - Bool preferred, ddc_quirk_t quirks) -{ - DisplayModePtr Mode; - - /* - * Refuse to create modes that are insufficiently large. 64 is a random - * number, maybe the spec says something about what the minimum is. In - * particular I see this frequently with _old_ EDID, 1.0 or so, so maybe - * our parser is just being too aggresive there. - */ - if (timing->h_active < 64 || timing->v_active < 64) { - xf86DrvMsg(scrnIndex, X_INFO, - "%s: Ignoring tiny %dx%d mode\n", __func__, - timing->h_active, timing->v_active); - return NULL; - } - - /* We don't do stereo */ - if (timing->stereo) { - xf86DrvMsg(scrnIndex, X_INFO, - "%s: Ignoring: We don't handle stereo.\n", __func__); - return NULL; - } - - /* We only do seperate sync currently */ - if (timing->sync != 0x03) { - xf86DrvMsg(scrnIndex, X_INFO, - "%s: %dx%d Warning: We only handle separate" - " sync.\n", __func__, timing->h_active, timing->v_active); - } - - Mode = xnfcalloc(1, sizeof(DisplayModeRec)); - - Mode->type = M_T_DRIVER; - if (preferred) - Mode->type |= M_T_PREFERRED; - - if( ( quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH ) && - timing->clock == 135000000 ) - Mode->Clock = 108880; - else - Mode->Clock = timing->clock / 1000.0; - - Mode->HDisplay = timing->h_active; - Mode->HSyncStart = timing->h_active + timing->h_sync_off; - Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width; - Mode->HTotal = timing->h_active + timing->h_blanking; - - Mode->VDisplay = timing->v_active; - Mode->VSyncStart = timing->v_active + timing->v_sync_off; - Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; - Mode->VTotal = timing->v_active + timing->v_blanking; - - /* perform basic check on the detail timing */ - if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) { - free(Mode); - return NULL; - } - - /* We ignore h/v_size and h/v_border for now. */ - - if (timing->interlaced) - DDCModeDoInterlaceQuirks(Mode); - - if (quirks & DDC_QUIRK_DETAILED_SYNC_PP) - Mode->Flags |= V_PVSYNC | V_PHSYNC; - else { - if (timing->misc & 0x02) - Mode->Flags |= V_PVSYNC; - else - Mode->Flags |= V_NVSYNC; - - if (timing->misc & 0x01) - Mode->Flags |= V_PHSYNC; - else - Mode->Flags |= V_NHSYNC; - } - - xf86SetModeDefaultName(Mode); - - return Mode; -} - -static DisplayModePtr -DDCModesFromCVT(int scrnIndex, struct cvt_timings *t) -{ - DisplayModePtr modes = NULL; - int i; - - for (i = 0; i < 4; i++) { - if (t[i].height) { - if (t[i].rates & 0x10) - modes = xf86ModesAdd(modes, - xf86CVTMode(t[i].width, t[i].height, 50, 0, 0)); - if (t[i].rates & 0x08) - modes = xf86ModesAdd(modes, - xf86CVTMode(t[i].width, t[i].height, 60, 0, 0)); - if (t[i].rates & 0x04) - modes = xf86ModesAdd(modes, - xf86CVTMode(t[i].width, t[i].height, 75, 0, 0)); - if (t[i].rates & 0x02) - modes = xf86ModesAdd(modes, - xf86CVTMode(t[i].width, t[i].height, 85, 0, 0)); - if (t[i].rates & 0x01) - modes = xf86ModesAdd(modes, - xf86CVTMode(t[i].width, t[i].height, 60, 1, 0)); - } else break; - } - - return modes; -} - -static const struct { - short w; - short h; - short r; - short rb; -} EstIIIModes[] = { - /* byte 6 */ - { 640, 350, 85, 0 }, - { 640, 400, 85, 0 }, - { 720, 400, 85, 0 }, - { 640, 480, 85, 0 }, - { 848, 480, 60, 0 }, - { 800, 600, 85, 0 }, - { 1024, 768, 85, 0 }, - { 1152, 864, 75, 0 }, - /* byte 7 */ - { 1280, 768, 60, 1 }, - { 1280, 768, 60, 0 }, - { 1280, 768, 75, 0 }, - { 1280, 768, 85, 0 }, - { 1280, 960, 60, 0 }, - { 1280, 960, 85, 0 }, - { 1280, 1024, 60, 0 }, - { 1280, 1024, 85, 0 }, - /* byte 8 */ - { 1360, 768, 60, 0 }, - { 1440, 900, 60, 1 }, - { 1440, 900, 60, 0 }, - { 1440, 900, 75, 0 }, - { 1440, 900, 85, 0 }, - { 1400, 1050, 60, 1 }, - { 1400, 1050, 60, 0 }, - { 1400, 1050, 75, 0 }, - /* byte 9 */ - { 1400, 1050, 85, 0 }, - { 1680, 1050, 60, 1 }, - { 1680, 1050, 60, 0 }, - { 1680, 1050, 75, 0 }, - { 1680, 1050, 85, 0 }, - { 1600, 1200, 60, 0 }, - { 1600, 1200, 65, 0 }, - { 1600, 1200, 70, 0 }, - /* byte 10 */ - { 1600, 1200, 75, 0 }, - { 1600, 1200, 85, 0 }, - { 1792, 1344, 60, 0 }, - { 1792, 1344, 85, 0 }, - { 1856, 1392, 60, 0 }, - { 1856, 1392, 75, 0 }, - { 1920, 1200, 60, 1 }, - { 1920, 1200, 60, 0 }, - /* byte 11 */ - { 1920, 1200, 75, 0 }, - { 1920, 1200, 85, 0 }, - { 1920, 1440, 60, 0 }, - { 1920, 1440, 75, 0 }, -}; - -static DisplayModePtr -DDCModesFromEstIII(unsigned char *est) -{ - DisplayModePtr modes = NULL; - int i, j, m; - - for (i = 0; i < 6; i++) { - for (j = 7; j > 0; j--) { - if (est[i] & (1 << j)) { - m = (i * 8) + (7 - j); - modes = xf86ModesAdd(modes, - FindDMTMode(EstIIIModes[m].w, - EstIIIModes[m].h, - EstIIIModes[m].r, - EstIIIModes[m].rb)); - } - } - } - - return modes; -} - -/* - * This is only valid when the sink claims to be continuous-frequency - * but does not supply a detailed range descriptor. Such sinks are - * arguably broken. Currently the mode validation code isn't aware of - * this; the non-RANDR code even punts the decision of optional sync - * range checking to the driver. Loss. - */ -static void -DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes) -{ - DisplayModePtr Mode = Modes; - - if (!Monitor || !Modes) - return; - - /* set up the ranges for scanning through the modes */ - Monitor->nHsync = 1; - Monitor->hsync[0].lo = 1024.0; - Monitor->hsync[0].hi = 0.0; - - Monitor->nVrefresh = 1; - Monitor->vrefresh[0].lo = 1024.0; - Monitor->vrefresh[0].hi = 0.0; - - while (Mode) { - if (!Mode->HSync) - Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal); - - if (!Mode->VRefresh) - Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / - ((float) (Mode->HTotal * Mode->VTotal)); - - if (Mode->HSync < Monitor->hsync[0].lo) - Monitor->hsync[0].lo = Mode->HSync; - - if (Mode->HSync > Monitor->hsync[0].hi) - Monitor->hsync[0].hi = Mode->HSync; - - if (Mode->VRefresh < Monitor->vrefresh[0].lo) - Monitor->vrefresh[0].lo = Mode->VRefresh; - - if (Mode->VRefresh > Monitor->vrefresh[0].hi) - Monitor->vrefresh[0].hi = Mode->VRefresh; - - Mode = Mode->next; - } -} - -ddc_quirk_t -xf86DDCDetectQuirks(int scrnIndex, xf86MonPtr DDC, Bool verbose) -{ - ddc_quirk_t quirks; - int i; - - quirks = DDC_QUIRK_NONE; - for (i = 0; ddc_quirks[i].detect; i++) { - if (ddc_quirks[i].detect (scrnIndex, DDC)) { - if (verbose) { - xf86DrvMsg (scrnIndex, X_INFO, " EDID quirk: %s\n", - ddc_quirks[i].description); - } - quirks |= ddc_quirks[i].quirk; - } - } - - return quirks; -} - -void xf86DetTimingApplyQuirks(struct detailed_monitor_section *det_mon, - ddc_quirk_t quirks, - int hsize, int vsize) -{ - if (det_mon->type != DT) - return; - - if (quirks & DDC_QUIRK_DETAILED_H_IN_CM) - det_mon->section.d_timings.h_size *= 10; - - if (quirks & DDC_QUIRK_DETAILED_V_IN_CM) - det_mon->section.d_timings.v_size *= 10; - - if (quirks & DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE) { - det_mon->section.d_timings.h_size = 10 * hsize; - det_mon->section.d_timings.v_size = 10 * vsize; - } -} - -/** - * Applies monitor-specific quirks to the decoded EDID information. - * - * Note that some quirks applying to the mode list are still implemented in - * xf86DDCGetModes. - */ -void -xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC) -{ - ddc_quirk_t quirks = xf86DDCDetectQuirks (scrnIndex, DDC, FALSE); - int i; - - for (i = 0; i < DET_TIMINGS; i++) { - xf86DetTimingApplyQuirks(DDC->det_mon + i, quirks, - DDC->features.hsize, - DDC->features.vsize); - } -} - -/** - * Walks the modes list, finding the mode with the largest area which is - * closest to the target refresh rate, and marks it as the only preferred mode. -*/ -static void -xf86DDCSetPreferredRefresh(int scrnIndex, DisplayModePtr modes, - float target_refresh) -{ - DisplayModePtr mode, best = modes; - - for (mode = modes; mode; mode = mode->next) - { - mode->type &= ~M_T_PREFERRED; - - if (mode == best) continue; - - if (mode->HDisplay * mode->VDisplay > - best->HDisplay * best->VDisplay) - { - best = mode; - continue; - } - if (mode->HDisplay * mode->VDisplay == - best->HDisplay * best->VDisplay) - { - double mode_refresh = xf86ModeVRefresh (mode); - double best_refresh = xf86ModeVRefresh (best); - double mode_dist = fabs(mode_refresh - target_refresh); - double best_dist = fabs(best_refresh - target_refresh); - - if (mode_dist < best_dist) - { - best = mode; - continue; - } - } - } - if (best) - best->type |= M_T_PREFERRED; -} - -#define CEA_VIDEO_MODES_NUM 64 -static const DisplayModeRec CEAVideoModes[CEA_VIDEO_MODES_NUM] = { - { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 1:640x480@60Hz */ - { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 2:720x480@60Hz */ - { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 3:720x480@60Hz */ - { MODEPREFIX, 74250, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 4: 1280x720@60Hz */ - { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 5:1920x1080i@60Hz */ - { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 6:1440x480i@60Hz */ - { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 7:1440x480i@60Hz */ - { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 8:1440x240@60Hz */ - { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 9:1440x240@60Hz */ - { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 10:2880x480i@60Hz */ - { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 11:2880x480i@60Hz */ - { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 12:2880x240@60Hz */ - { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 13:2880x240@60Hz */ - { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 14:1440x480@60Hz */ - { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 15:1440x480@60Hz */ - { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 16:1920x1080@60Hz */ - { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 17:720x576@50Hz */ - { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 18:720x576@50Hz */ - { MODEPREFIX, 74250, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 19: 1280x720@50Hz */ - { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 20:1920x1080i@50Hz */ - { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 21:1440x576i@50Hz */ - { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 22:1440x576i@50Hz */ - { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 23:1440x288@50Hz */ - { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 24:1440x288@50Hz */ - { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 25:2880x576i@50Hz */ - { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 26:2880x576i@50Hz */ - { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 27:2880x288@50Hz */ - { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 28:2880x288@50Hz */ - { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 29:1440x576@50Hz */ - { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 30:1440x576@50Hz */ - { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 31:1920x1080@50Hz */ - { MODEPREFIX, 74250, 1920, 2558, 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 32:1920x1080@24Hz */ - { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 33:1920x1080@25Hz */ - { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 34:1920x1080@30Hz */ - { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 35:2880x480@60Hz */ - { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 36:2880x480@60Hz */ - { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 37:2880x576@50Hz */ - { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 38:2880x576@50Hz */ - { MODEPREFIX, 72000, 1920, 1952, 2120, 2304, 0, 1080, 1126, 1136, 1250, 0, V_PHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 39:1920x1080i@50Hz */ - { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 40:1920x1080i@100Hz */ - { MODEPREFIX, 148500, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 41:1280x720@100Hz */ - { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 42:720x576@100Hz */ - { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 43:720x576@100Hz */ - { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 44:1440x576i@100Hz */ - { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 45:1440x576i@100Hz */ - { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 46:1920x1080i@120Hz */ - { MODEPREFIX, 148500, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 47:1280x720@120Hz */ - { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 48:720x480@120Hz */ - { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 49:720x480@120Hz */ - { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 50:1440x480i@120Hz */ - { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 51:1440x480i@120Hz */ - { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 52:720x576@200Hz */ - { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 53:720x576@200Hz */ - { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 54:1440x576i@200Hz */ - { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 55:1440x576i@200Hz */ - { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 56:720x480@240Hz */ - { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 57:720x480@240Hz */ - { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 58:1440x480i@240 */ - { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 59:1440x480i@240 */ - { MODEPREFIX, 59400, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 60: 1280x720@24Hz */ - { MODEPREFIX, 74250, 3700, 3740, 1430, 3960, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 61: 1280x720@25Hz */ - { MODEPREFIX, 74250, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 62: 1280x720@30Hz */ - { MODEPREFIX, 297000, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 63: 1920x1080@120Hz */ - { MODEPREFIX, 297000, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 64:1920x1080@100Hz */ -}; - -/* chose mode line by cea short video descriptor*/ -static void handle_cea_svd(struct cea_video_block *video, void *data) -{ - DisplayModePtr Mode; - DisplayModePtr *Modes = (DisplayModePtr *) data; - int vid; - - vid = video ->video_code & 0x7f; - if (vid < CEA_VIDEO_MODES_NUM) { - Mode = xf86DuplicateMode(CEAVideoModes + vid); - *Modes = xf86ModesAdd(*Modes, Mode); - } -} - -static DisplayModePtr -DDCModesFromCEAExtension(int scrnIndex, xf86MonPtr MonPtr) -{ - DisplayModePtr Modes = NULL; - - xf86ForEachVideoBlock(MonPtr, - handle_cea_svd, - &Modes); - - return Modes; -} - -struct det_modes_parameter { - xf86MonPtr DDC; - ddc_quirk_t quirks; - DisplayModePtr Modes; - Bool rb; - Bool preferred; - int timing_level; -}; - -static void handle_detailed_modes(struct detailed_monitor_section *det_mon, - void *data) -{ - DisplayModePtr Mode; - struct det_modes_parameter *p = (struct det_modes_parameter *)data; - - xf86DetTimingApplyQuirks(det_mon,p->quirks, - p->DDC->features.hsize, - p->DDC->features.vsize); - - switch (det_mon->type) { - case DT: - Mode = DDCModeFromDetailedTiming(p->DDC->scrnIndex, - &det_mon->section.d_timings, - p->preferred, - p->quirks); - p->preferred = FALSE; - p->Modes = xf86ModesAdd(p->Modes, Mode); - break; - case DS_STD_TIMINGS: - Mode = DDCModesFromStandardTiming(det_mon->section.std_t, - p->quirks, p->timing_level,p->rb); - p->Modes = xf86ModesAdd(p->Modes, Mode); - break; - case DS_CVT: - Mode = DDCModesFromCVT(p->DDC->scrnIndex, det_mon->section.cvt); - p->Modes = xf86ModesAdd(p->Modes, Mode); - break; - case DS_EST_III: - Mode = DDCModesFromEstIII(det_mon->section.est_iii); - p->Modes = xf86ModesAdd(p->Modes, Mode); - break; - default: - break; - } -} - -DisplayModePtr -xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC) -{ - DisplayModePtr Modes = NULL, Mode; - ddc_quirk_t quirks; - Bool preferred, rb; - int timing_level; - struct det_modes_parameter p; - - xf86DrvMsg (scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n", - DDC->vendor.name, DDC->vendor.prod_id); - - quirks = xf86DDCDetectQuirks(scrnIndex, DDC, TRUE); - - preferred = PREFERRED_TIMING_MODE(DDC->features.msc); - if (DDC->ver.revision >= 4) - preferred = TRUE; - if (quirks & DDC_QUIRK_FIRST_DETAILED_PREFERRED) - preferred = TRUE; - if (quirks & (DDC_QUIRK_PREFER_LARGE_60 | DDC_QUIRK_PREFER_LARGE_75)) - preferred = FALSE; - - rb = xf86MonitorSupportsReducedBlanking(DDC); - - timing_level = MonitorStandardTimingLevel(DDC); - - p.quirks = quirks; - p.DDC = DDC; - p.Modes = Modes; - p.rb = rb; - p.preferred = preferred; - p.timing_level = timing_level; - xf86ForEachDetailedBlock(DDC, handle_detailed_modes, &p); - Modes = p.Modes; - - /* Add established timings */ - Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1, quirks); - Modes = xf86ModesAdd(Modes, Mode); - - /* Add standard timings */ - Mode = DDCModesFromStandardTiming(DDC->timings2, quirks, timing_level, rb); - Modes = xf86ModesAdd(Modes, Mode); - - /* Add cea-extension mode timings */ - Mode = DDCModesFromCEAExtension(scrnIndex,DDC); - Modes = xf86ModesAdd(Modes, Mode); - - if (quirks & DDC_QUIRK_PREFER_LARGE_60) - xf86DDCSetPreferredRefresh(scrnIndex, Modes, 60); - - if (quirks & DDC_QUIRK_PREFER_LARGE_75) - xf86DDCSetPreferredRefresh(scrnIndex, Modes, 75); - - Modes = xf86PruneDuplicateModes(Modes); - - return Modes; -} - -struct det_mon_parameter { - MonPtr Monitor; - ddc_quirk_t quirks; - Bool have_hsync; - Bool have_vrefresh; - Bool have_maxpixclock; -}; - -static void handle_detailed_monset(struct detailed_monitor_section *det_mon, - void *data) -{ - int clock; - struct det_mon_parameter *p = (struct det_mon_parameter *)data; - int scrnIndex = ((xf86MonPtr)(p->Monitor->DDC))->scrnIndex; - - switch (det_mon->type) { - case DS_RANGES: - if (!p->have_hsync) { - if (!p->Monitor->nHsync) - xf86DrvMsg(scrnIndex, X_INFO, - "Using EDID range info for horizontal sync\n"); - p->Monitor->hsync[p->Monitor->nHsync].lo = - det_mon->section.ranges.min_h; - p->Monitor->hsync[p->Monitor->nHsync].hi = - det_mon->section.ranges.max_h; - p->Monitor->nHsync++; - } else { - xf86DrvMsg(scrnIndex, X_INFO, - "Using hsync ranges from config file\n"); - } - - if (!p->have_vrefresh) { - if (!p->Monitor->nVrefresh) - xf86DrvMsg(scrnIndex, X_INFO, - "Using EDID range info for vertical refresh\n"); - p->Monitor->vrefresh[p->Monitor->nVrefresh].lo = - det_mon->section.ranges.min_v; - p->Monitor->vrefresh[p->Monitor->nVrefresh].hi = - det_mon->section.ranges.max_v; - p->Monitor->nVrefresh++; - } else { - xf86DrvMsg(scrnIndex, X_INFO, - "Using vrefresh ranges from config file\n"); - } - - clock = det_mon->section.ranges.max_clock * 1000; - if (p->quirks & DDC_QUIRK_DVI_SINGLE_LINK) - clock = min(clock, 165000); - if (!p->have_maxpixclock && clock > p->Monitor->maxPixClock) - p->Monitor->maxPixClock = clock; - - break; - default: - break; - } -} - -/* - * Fill out MonPtr with xf86MonPtr information. - */ -void -xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) -{ - DisplayModePtr Modes = NULL, Mode; - struct det_mon_parameter p; - - if (!Monitor || !DDC) - return; - - Monitor->DDC = DDC; - - if (Monitor->widthmm <= 0 || Monitor->heightmm <= 0) { - Monitor->widthmm = 10 * DDC->features.hsize; - Monitor->heightmm = 10 * DDC->features.vsize; - } - - Monitor->reducedblanking = xf86MonitorSupportsReducedBlanking(DDC); - - Modes = xf86DDCGetModes(scrnIndex, DDC); - - /* Go through the detailed monitor sections */ - p.Monitor = Monitor; - p.quirks = xf86DDCDetectQuirks(scrnIndex, Monitor->DDC, FALSE); - p.have_hsync = (Monitor->nHsync != 0); - p.have_vrefresh = (Monitor->nVrefresh != 0); - p.have_maxpixclock = (Monitor->maxPixClock != 0); - xf86ForEachDetailedBlock(DDC, handle_detailed_monset, &p); - - if (Modes) { - /* Print Modes */ - xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n"); - - Mode = Modes; - while (Mode) { - xf86PrintModeline(scrnIndex, Mode); - Mode = Mode->next; - } - - /* Do we still need ranges to be filled in? */ - if (!Monitor->nHsync || !Monitor->nVrefresh) - DDCGuessRangesFromModes(scrnIndex, Monitor, Modes); - - /* look for last Mode */ - Mode = Modes; - - while (Mode->next) - Mode = Mode->next; - - /* add to MonPtr */ - if (Monitor->Modes) { - Monitor->Last->next = Modes; - Modes->prev = Monitor->Last; - Monitor->Last = Mode; - } else { - Monitor->Modes = Modes; - Monitor->Last = Mode; - } - } -} +/* + * Copyright 2006 Luc Verhaegen. + * 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 + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * 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 NON-INFRINGEMENT. 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. + */ + +/** + * @file This file covers code to convert a xf86MonPtr containing EDID-probed + * information into a list of modes, including applying monitor-specific + * quirks to fix broken EDID data. + */ +#ifdef HAVE_XORG_CONFIG_H +#include +#else +#ifdef HAVE_CONFIG_H +#include +#endif +#endif + +#define _PARSE_EDID_ +#include "xf86.h" +#include "xf86DDC.h" +#include +#include "property.h" +#include "propertyst.h" +#include "xf86Crtc.h" +#include +#include + +static void handle_detailed_rblank(struct detailed_monitor_section *det_mon, + void *data) +{ + if (det_mon->type == DS_RANGES) + if (det_mon->section.ranges.supported_blanking & CVT_REDUCED) + *(Bool*)data = TRUE; +} + +static Bool +xf86MonitorSupportsReducedBlanking(xf86MonPtr DDC) +{ + /* EDID 1.4 explicitly defines RB support */ + if (DDC->ver.revision >= 4) { + Bool ret = FALSE; + + xf86ForEachDetailedBlock(DDC, handle_detailed_rblank, &ret); + return ret; + } + + /* For anything older, assume digital means RB support. Boo. */ + if (DDC->features.input_type) + return TRUE; + + return FALSE; +} + +static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC) +{ + /* Belinea 10 15 55 */ + if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && + ((DDC->vendor.prod_id == 1516) || + (DDC->vendor.prod_id == 0x77e))) + return TRUE; + + /* Acer AL1706 */ + if (memcmp (DDC->vendor.name, "ACR", 4) == 0 && + DDC->vendor.prod_id == 44358) + return TRUE; + + /* Bug #10814: Samsung SyncMaster 225BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 596) + return TRUE; + + /* Bug #10545: Samsung SyncMaster 226BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 638) + return TRUE; + + /* Acer F51 */ + if (memcmp (DDC->vendor.name, "API", 4) == 0 && + DDC->vendor.prod_id == 0x7602) + return TRUE; + + + return FALSE; +} + +static Bool quirk_prefer_large_75 (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #11603: Funai Electronics PM36B */ + if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && + DDC->vendor.prod_id == 13600) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_h_in_cm (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #11603: Funai Electronics PM36B */ + if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && + DDC->vendor.prod_id == 13600) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_v_in_cm (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #11603: Funai Electronics PM36B */ + if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && + DDC->vendor.prod_id == 13600) + return TRUE; + + /* Bug #21000: LGPhilipsLCD LP154W01-TLAJ */ + if (memcmp (DDC->vendor.name, "LPL", 4) == 0 && + DDC->vendor.prod_id == 47360) + return TRUE; + + /* Bug #10304: LGPhilipsLCD LP154W01-A5 */ + if (memcmp(DDC->vendor.name, "LPL", 4) == 0 && + DDC->vendor.prod_id == 0) + return TRUE; + + /* Bug #24482: LGPhilipsLCD LP154W01-TLA1 */ + if (memcmp(DDC->vendor.name, "LPL", 4) == 0 && + DDC->vendor.prod_id == 0x2a00) + return TRUE; + + /* Bug #28414: HP Compaq NC8430 LP154W01-TLA8 */ + if (memcmp (DDC->vendor.name, "LPL", 4) == 0 && + DDC->vendor.prod_id == 5750) + return TRUE; + + /* Bug #21750: Samsung Syncmaster 2333HD */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 1157) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_use_maximum_size (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #21324: Iiyama Vision Master 450 */ + if (memcmp (DDC->vendor.name, "IVM", 4) == 0 && + DDC->vendor.prod_id == 6400) + return TRUE; + + return FALSE; +} + +static Bool quirk_135_clock_too_high (int scrnIndex, xf86MonPtr DDC) +{ + /* Envision Peripherals, Inc. EN-7100e. See bug #9550. */ + if (memcmp (DDC->vendor.name, "EPI", 4) == 0 && + DDC->vendor.prod_id == 59264) + return TRUE; + + return FALSE; +} + +static Bool quirk_first_detailed_preferred (int scrnIndex, xf86MonPtr DDC) +{ + /* Philips 107p5 CRT. Reported on xorg@ with pastebin. */ + if (memcmp (DDC->vendor.name, "PHL", 4) == 0 && + DDC->vendor.prod_id == 57364) + return TRUE; + + /* Proview AY765C 17" LCD. See bug #15160*/ + if (memcmp (DDC->vendor.name, "PTS", 4) == 0 && + DDC->vendor.prod_id == 765) + return TRUE; + + /* ACR of some sort RH #284231 */ + if (memcmp (DDC->vendor.name, "ACR", 4) == 0 && + DDC->vendor.prod_id == 2423) + return TRUE; + + /* Peacock Ergovision 19. See rh#492359 */ + if (memcmp (DDC->vendor.name, "PEA", 4) == 0 && + DDC->vendor.prod_id == 9003) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_sync_pp(int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #12439: Samsung SyncMaster 205BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 541) + return TRUE; + return FALSE; +} + +/* This should probably be made more generic */ +static Bool quirk_dvi_single_link(int scrnIndex, xf86MonPtr DDC) +{ + /* Red Hat bug #453106: Apple 23" Cinema Display */ + if (memcmp (DDC->vendor.name, "APL", 4) == 0 && + DDC->vendor.prod_id == 0x921c) + return TRUE; + return FALSE; +} + +typedef struct { + Bool (*detect) (int scrnIndex, xf86MonPtr DDC); + ddc_quirk_t quirk; + char *description; +} ddc_quirk_map_t; + +static const ddc_quirk_map_t ddc_quirks[] = { + { + quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60, + "Detailed timing is not preferred, use largest mode at 60Hz" + }, + { + quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH, + "Recommended 135MHz pixel clock is too high" + }, + { + quirk_prefer_large_75, DDC_QUIRK_PREFER_LARGE_75, + "Detailed timing is not preferred, use largest mode at 75Hz" + }, + { + quirk_detailed_h_in_cm, DDC_QUIRK_DETAILED_H_IN_CM, + "Detailed timings give horizontal size in cm." + }, + { + quirk_detailed_v_in_cm, DDC_QUIRK_DETAILED_V_IN_CM, + "Detailed timings give vertical size in cm." + }, + { + quirk_detailed_use_maximum_size, DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE, + "Use maximum size instead of detailed timing sizes." + }, + { + quirk_first_detailed_preferred, DDC_QUIRK_FIRST_DETAILED_PREFERRED, + "First detailed timing was not marked as preferred." + }, + { + quirk_detailed_sync_pp, DDC_QUIRK_DETAILED_SYNC_PP, + "Use +hsync +vsync for detailed timing." + }, + { + quirk_dvi_single_link, DDC_QUIRK_DVI_SINGLE_LINK, + "Forcing maximum pixel clock to single DVI link." + }, + { + NULL, DDC_QUIRK_NONE, + "No known quirks" + }, +}; + +/* + * These more or less come from the DMT spec. The 720x400 modes are + * inferred from historical 80x25 practice. The 640x480@67 and 832x624@75 + * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode + * should be 1152x870, again for the Mac, but instead we use the x864 DMT + * mode. + * + * The DMT modes have been fact-checked; the rest are mild guesses. + */ +#define MODEPREFIX NULL, NULL, NULL, 0, M_T_DRIVER +#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0 + +static const DisplayModeRec DDCEstablishedModes[17] = { + { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ + { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ + { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ + { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ + { MODEPREFIX, 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */ + { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ + { MODEPREFIX, 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */ + { MODEPREFIX, 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */ + { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ + { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ + { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ + { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ + { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */ + { MODEPREFIX, 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */ + { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ + { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ + { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ +}; + +static DisplayModePtr +DDCModesFromEstablished(int scrnIndex, struct established_timings *timing, + ddc_quirk_t quirks) +{ + DisplayModePtr Modes = NULL, Mode = NULL; + CARD32 bits = (timing->t1) | (timing->t2 << 8) | + ((timing->t_manu & 0x80) << 9); + int i; + + for (i = 0; i < 17; i++) { + if (bits & (0x01 << i)) { + Mode = xf86DuplicateMode(&DDCEstablishedModes[i]); + Modes = xf86ModesAdd(Modes, Mode); + } + } + + return Modes; +} + +/* Autogenerated from the DMT spec */ +const DisplayModeRec DMTModes[] = { + { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 350, 382, 385, 445, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x350@85Hz */ + { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 400, 401, 404, 445, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 640x400@85Hz */ + { MODEPREFIX, 35500, 720, 756, 828, 936, 0, 400, 401, 404, 446, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@85Hz */ + { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ + { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ + { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ + { MODEPREFIX, 36000, 640, 696, 752, 832, 0, 480, 481, 484, 509, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@85Hz */ + { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ + { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ + { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ + { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ + { MODEPREFIX, 56250, 800, 832, 896, 1048, 0, 600, 601, 604, 631, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@85Hz */ + { MODEPREFIX, 73250, 800, 848, 880, 960, 0, 600, 603, 607, 636, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 800x600@120Hz RB */ + { MODEPREFIX, 33750, 848, 864, 976, 1088, 0, 480, 486, 494, 517, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 848x480@60Hz */ + { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz (interlaced) */ + { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ + { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ + { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ + { MODEPREFIX, 94500, 1024, 1072, 1168, 1376, 0, 768, 769, 772, 808, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@85Hz */ + { MODEPREFIX, 115500, 1024, 1072, 1104, 1184, 0, 768, 771, 775, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@120Hz RB */ + { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ + { MODEPREFIX, 68250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 790, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@60Hz RB */ + { MODEPREFIX, 79500, 1280, 1344, 1472, 1664, 0, 768, 771, 778, 798, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@60Hz */ + { MODEPREFIX, 102250, 1280, 1360, 1488, 1696, 0, 768, 771, 778, 805, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@75Hz */ + { MODEPREFIX, 117500, 1280, 1360, 1496, 1712, 0, 768, 771, 778, 809, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@85Hz */ + { MODEPREFIX, 140250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@120Hz RB */ + { MODEPREFIX, 71000, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 823, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@60Hz RB */ + { MODEPREFIX, 83500, 1280, 1352, 1480, 1680, 0, 800, 803, 809, 831, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@60Hz */ + { MODEPREFIX, 106500, 1280, 1360, 1488, 1696, 0, 800, 803, 809, 838, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@75Hz */ + { MODEPREFIX, 122500, 1280, 1360, 1496, 1712, 0, 800, 803, 809, 843, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@85Hz */ + { MODEPREFIX, 146250, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 847, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@120Hz RB */ + { MODEPREFIX, 108000, 1280, 1376, 1488, 1800, 0, 960, 961, 964, 1000, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@60Hz */ + { MODEPREFIX, 148500, 1280, 1344, 1504, 1728, 0, 960, 961, 964, 1011, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@85Hz */ + { MODEPREFIX, 175500, 1280, 1328, 1360, 1440, 0, 960, 963, 967, 1017, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x960@120Hz RB */ + { MODEPREFIX, 108000, 1280, 1328, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@60Hz */ + { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ + { MODEPREFIX, 157500, 1280, 1344, 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@85Hz */ + { MODEPREFIX, 187250, 1280, 1328, 1360, 1440, 0, 1024, 1027, 1034, 1084, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x1024@120Hz RB */ + { MODEPREFIX, 85500, 1360, 1424, 1536, 1792, 0, 768, 771, 777, 795, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1360x768@60Hz */ + { MODEPREFIX, 148250, 1360, 1408, 1440, 1520, 0, 768, 771, 776, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1360x768@120Hz RB */ + { MODEPREFIX, 101000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@60Hz RB */ + { MODEPREFIX, 121750, 1400, 1488, 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@60Hz */ + { MODEPREFIX, 156000, 1400, 1504, 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@75Hz */ + { MODEPREFIX, 179500, 1400, 1504, 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@85Hz */ + { MODEPREFIX, 208000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@120Hz RB */ + { MODEPREFIX, 88750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 926, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@60Hz RB */ + { MODEPREFIX, 106500, 1440, 1520, 1672, 1904, 0, 900, 903, 909, 934, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@60Hz */ + { MODEPREFIX, 136750, 1440, 1536, 1688, 1936, 0, 900, 903, 909, 942, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@75Hz */ + { MODEPREFIX, 157000, 1440, 1544, 1696, 1952, 0, 900, 903, 909, 948, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@85Hz */ + { MODEPREFIX, 182750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 953, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@120Hz RB */ + { MODEPREFIX, 162000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@60Hz */ + { MODEPREFIX, 175500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@65Hz */ + { MODEPREFIX, 189000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@70Hz */ + { MODEPREFIX, 202500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@75Hz */ + { MODEPREFIX, 229500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@85Hz */ + { MODEPREFIX, 268250, 1600, 1648, 1680, 1760, 0, 1200, 1203, 1207, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1600x1200@120Hz RB */ + { MODEPREFIX, 119000, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@60Hz RB */ + { MODEPREFIX, 146250, 1680, 1784, 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@60Hz */ + { MODEPREFIX, 187000, 1680, 1800, 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@75Hz */ + { MODEPREFIX, 214750, 1680, 1808, 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@85Hz */ + { MODEPREFIX, 245500, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@120Hz RB */ + { MODEPREFIX, 204750, 1792, 1920, 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@60Hz */ + { MODEPREFIX, 261000, 1792, 1888, 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@75Hz */ + { MODEPREFIX, 333250, 1792, 1840, 1872, 1952, 0, 1344, 1347, 1351, 1423, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1792x1344@120Hz RB */ + { MODEPREFIX, 218250, 1856, 1952, 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@60Hz */ + { MODEPREFIX, 288000, 1856, 1984, 2208, 2560, 0, 1392, 1393, 1396, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@75Hz */ + { MODEPREFIX, 356500, 1856, 1904, 1936, 2016, 0, 1392, 1395, 1399, 1474, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1856x1392@120Hz RB */ + { MODEPREFIX, 154000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1235, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@60Hz RB */ + { MODEPREFIX, 193250, 1920, 2056, 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@60Hz */ + { MODEPREFIX, 245250, 1920, 2056, 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@75Hz */ + { MODEPREFIX, 281250, 1920, 2064, 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@85Hz */ + { MODEPREFIX, 317000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@120Hz RB */ + { MODEPREFIX, 234000, 1920, 2048, 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@60Hz */ + { MODEPREFIX, 297000, 1920, 2064, 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@75Hz */ + { MODEPREFIX, 380500, 1920, 1968, 2000, 2080, 0, 1440, 1443, 1447, 1525, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1440@120Hz RB */ + { MODEPREFIX, 268500, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1646, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@60Hz RB */ + { MODEPREFIX, 348500, 2560, 2752, 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@60Hz */ + { MODEPREFIX, 443250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@75Hz */ + { MODEPREFIX, 505250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@85Hz */ + { MODEPREFIX, 552750, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@120Hz RB */ +}; + +#define LEVEL_DMT 0 +#define LEVEL_GTF 1 +#define LEVEL_CVT 2 + +static int +MonitorStandardTimingLevel(xf86MonPtr DDC) +{ + if (DDC->ver.revision >= 2) { + if (DDC->ver.revision >= 4 && CVT_SUPPORTED(DDC->features.msc)) { + return LEVEL_CVT; + } + return LEVEL_GTF; + } + return LEVEL_DMT; +} + +static int +ModeRefresh(const DisplayModeRec *mode) +{ + return (int)(xf86ModeVRefresh(mode) + 0.5); +} + +/* + * If rb is not set, then we'll not consider reduced-blanking modes as + * part of the DMT pool. For the 'standard' EDID mode descriptor there's + * no way to specify whether the mode should be RB or not. + */ +DisplayModePtr +FindDMTMode(int hsize, int vsize, int refresh, Bool rb) +{ + int i; + const DisplayModeRec *ret; + + for (i = 0; i < sizeof(DMTModes) / sizeof(DisplayModeRec); i++) { + ret = &DMTModes[i]; + + if (!rb && xf86ModeIsReduced(ret)) + continue; + + if (ret->HDisplay == hsize && + ret->VDisplay == vsize && + refresh == ModeRefresh(ret)) + return xf86DuplicateMode(ret); + } + + return NULL; +} + +/* + * Appendix B of the EDID 1.4 spec defines the right thing to do here. + * If the timing given here matches a mode defined in the VESA DMT standard, + * we _must_ use that. If the device supports CVT modes, then we should + * generate a CVT timing. If both of the above fail, use GTF. + * + * There are some wrinkles here. EDID 1.1 and 1.0 sinks can't really + * "support" GTF, since it wasn't a standard yet; so if they ask for a + * timing in this section that isn't defined in DMT, returning a GTF mode + * may not actually be valid. EDID 1.3 sinks often report support for + * some CVT modes, but they are not required to support CVT timings for + * modes in the standard timing descriptor, so we should _not_ treat them + * as CVT-compliant (unless specified in an extension block I suppose). + * + * EDID 1.4 requires that all sink devices support both GTF and CVT timings + * for modes in this section, but does say that CVT is preferred. + */ +static DisplayModePtr +DDCModesFromStandardTiming(struct std_timings *timing, ddc_quirk_t quirks, + int timing_level, Bool rb) +{ + DisplayModePtr Modes = NULL, Mode = NULL; + int i, hsize, vsize, refresh; + + for (i = 0; i < STD_TIMINGS; i++) { + hsize = timing[i].hsize; + vsize = timing[i].vsize; + refresh = timing[i].refresh; + + /* HDTV hack, because you can't say 1366 */ + if (refresh == 60 && + ((hsize == 1360 && vsize == 765) || + (hsize == 1368 && vsize == 769))) { + Mode = xf86CVTMode(1366, 768, 60, FALSE, FALSE); + Mode->HDisplay = 1366; + Mode->HSyncStart--; + Mode->HSyncEnd--; + } else if (hsize && vsize && refresh) { + Mode = FindDMTMode(hsize, vsize, refresh, rb); + + if (!Mode) { + if (timing_level == LEVEL_CVT) + /* pass rb here too? */ + Mode = xf86CVTMode(hsize, vsize, refresh, FALSE, FALSE); + else if (timing_level == LEVEL_GTF) + Mode = xf86GTFMode(hsize, vsize, refresh, FALSE, FALSE); + } + + } + + if (Mode) { + Mode->type = M_T_DRIVER; + Modes = xf86ModesAdd(Modes, Mode); + } + Mode = NULL; + } + + return Modes; +} + +static void +DDCModeDoInterlaceQuirks(DisplayModePtr mode) +{ + /* + * EDID is delightfully ambiguous about how interlaced modes are to be + * encoded. X's internal representation is of frame height, but some + * HDTV detailed timings are encoded as field height. + * + * The format list here is from CEA, in frame size. Technically we + * should be checking refresh rate too. Whatever. + */ + static const struct { + int w, h; + } cea_interlaced[] = { + { 1920, 1080 }, + { 720, 480 }, + { 1440, 480 }, + { 2880, 480 }, + { 720, 576 }, + { 1440, 576 }, + { 2880, 576 }, + }; + static const int n_modes = sizeof(cea_interlaced)/sizeof(cea_interlaced[0]); + int i; + + for (i = 0; i < n_modes; i++) { + if ((mode->HDisplay == cea_interlaced[i].w) && + (mode->VDisplay == cea_interlaced[i].h / 2)) { + mode->VDisplay *= 2; + mode->VSyncStart *= 2; + mode->VSyncEnd *= 2; + mode->VTotal *= 2; + mode->VTotal |= 1; + } + } + + mode->Flags |= V_INTERLACE; +} + +/* + * + */ +static DisplayModePtr +DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, + Bool preferred, ddc_quirk_t quirks) +{ + DisplayModePtr Mode; + + /* + * Refuse to create modes that are insufficiently large. 64 is a random + * number, maybe the spec says something about what the minimum is. In + * particular I see this frequently with _old_ EDID, 1.0 or so, so maybe + * our parser is just being too aggresive there. + */ + if (timing->h_active < 64 || timing->v_active < 64) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: Ignoring tiny %dx%d mode\n", __func__, + timing->h_active, timing->v_active); + return NULL; + } + + /* We don't do stereo */ + if (timing->stereo) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: Ignoring: We don't handle stereo.\n", __func__); + return NULL; + } + + /* We only do seperate sync currently */ + if (timing->sync != 0x03) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: %dx%d Warning: We only handle separate" + " sync.\n", __func__, timing->h_active, timing->v_active); + } + + Mode = xnfcalloc(1, sizeof(DisplayModeRec)); + + Mode->type = M_T_DRIVER; + if (preferred) + Mode->type |= M_T_PREFERRED; + + if( ( quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH ) && + timing->clock == 135000000 ) + Mode->Clock = 108880; + else + Mode->Clock = timing->clock / 1000.0; + + Mode->HDisplay = timing->h_active; + Mode->HSyncStart = timing->h_active + timing->h_sync_off; + Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width; + Mode->HTotal = timing->h_active + timing->h_blanking; + + Mode->VDisplay = timing->v_active; + Mode->VSyncStart = timing->v_active + timing->v_sync_off; + Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; + Mode->VTotal = timing->v_active + timing->v_blanking; + + /* perform basic check on the detail timing */ + if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) { + free(Mode); + return NULL; + } + + /* We ignore h/v_size and h/v_border for now. */ + + if (timing->interlaced) + DDCModeDoInterlaceQuirks(Mode); + + if (quirks & DDC_QUIRK_DETAILED_SYNC_PP) + Mode->Flags |= V_PVSYNC | V_PHSYNC; + else { + if (timing->misc & 0x02) + Mode->Flags |= V_PVSYNC; + else + Mode->Flags |= V_NVSYNC; + + if (timing->misc & 0x01) + Mode->Flags |= V_PHSYNC; + else + Mode->Flags |= V_NHSYNC; + } + + xf86SetModeDefaultName(Mode); + + return Mode; +} + +static DisplayModePtr +DDCModesFromCVT(int scrnIndex, struct cvt_timings *t) +{ + DisplayModePtr modes = NULL; + int i; + + for (i = 0; i < 4; i++) { + if (t[i].height) { + if (t[i].rates & 0x10) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 50, 0, 0)); + if (t[i].rates & 0x08) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 60, 0, 0)); + if (t[i].rates & 0x04) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 75, 0, 0)); + if (t[i].rates & 0x02) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 85, 0, 0)); + if (t[i].rates & 0x01) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 60, 1, 0)); + } else break; + } + + return modes; +} + +static const struct { + short w; + short h; + short r; + short rb; +} EstIIIModes[] = { + /* byte 6 */ + { 640, 350, 85, 0 }, + { 640, 400, 85, 0 }, + { 720, 400, 85, 0 }, + { 640, 480, 85, 0 }, + { 848, 480, 60, 0 }, + { 800, 600, 85, 0 }, + { 1024, 768, 85, 0 }, + { 1152, 864, 75, 0 }, + /* byte 7 */ + { 1280, 768, 60, 1 }, + { 1280, 768, 60, 0 }, + { 1280, 768, 75, 0 }, + { 1280, 768, 85, 0 }, + { 1280, 960, 60, 0 }, + { 1280, 960, 85, 0 }, + { 1280, 1024, 60, 0 }, + { 1280, 1024, 85, 0 }, + /* byte 8 */ + { 1360, 768, 60, 0 }, + { 1440, 900, 60, 1 }, + { 1440, 900, 60, 0 }, + { 1440, 900, 75, 0 }, + { 1440, 900, 85, 0 }, + { 1400, 1050, 60, 1 }, + { 1400, 1050, 60, 0 }, + { 1400, 1050, 75, 0 }, + /* byte 9 */ + { 1400, 1050, 85, 0 }, + { 1680, 1050, 60, 1 }, + { 1680, 1050, 60, 0 }, + { 1680, 1050, 75, 0 }, + { 1680, 1050, 85, 0 }, + { 1600, 1200, 60, 0 }, + { 1600, 1200, 65, 0 }, + { 1600, 1200, 70, 0 }, + /* byte 10 */ + { 1600, 1200, 75, 0 }, + { 1600, 1200, 85, 0 }, + { 1792, 1344, 60, 0 }, + { 1792, 1344, 85, 0 }, + { 1856, 1392, 60, 0 }, + { 1856, 1392, 75, 0 }, + { 1920, 1200, 60, 1 }, + { 1920, 1200, 60, 0 }, + /* byte 11 */ + { 1920, 1200, 75, 0 }, + { 1920, 1200, 85, 0 }, + { 1920, 1440, 60, 0 }, + { 1920, 1440, 75, 0 }, +}; + +static DisplayModePtr +DDCModesFromEstIII(unsigned char *est) +{ + DisplayModePtr modes = NULL; + int i, j, m; + + for (i = 0; i < 6; i++) { + for (j = 7; j > 0; j--) { + if (est[i] & (1 << j)) { + m = (i * 8) + (7 - j); + modes = xf86ModesAdd(modes, + FindDMTMode(EstIIIModes[m].w, + EstIIIModes[m].h, + EstIIIModes[m].r, + EstIIIModes[m].rb)); + } + } + } + + return modes; +} + +/* + * This is only valid when the sink claims to be continuous-frequency + * but does not supply a detailed range descriptor. Such sinks are + * arguably broken. Currently the mode validation code isn't aware of + * this; the non-RANDR code even punts the decision of optional sync + * range checking to the driver. Loss. + */ +static void +DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes) +{ + DisplayModePtr Mode = Modes; + + if (!Monitor || !Modes) + return; + + /* set up the ranges for scanning through the modes */ + Monitor->nHsync = 1; + Monitor->hsync[0].lo = 1024.0; + Monitor->hsync[0].hi = 0.0; + + Monitor->nVrefresh = 1; + Monitor->vrefresh[0].lo = 1024.0; + Monitor->vrefresh[0].hi = 0.0; + + while (Mode) { + if (!Mode->HSync) + Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal); + + if (!Mode->VRefresh) + Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / + ((float) (Mode->HTotal * Mode->VTotal)); + + if (Mode->HSync < Monitor->hsync[0].lo) + Monitor->hsync[0].lo = Mode->HSync; + + if (Mode->HSync > Monitor->hsync[0].hi) + Monitor->hsync[0].hi = Mode->HSync; + + if (Mode->VRefresh < Monitor->vrefresh[0].lo) + Monitor->vrefresh[0].lo = Mode->VRefresh; + + if (Mode->VRefresh > Monitor->vrefresh[0].hi) + Monitor->vrefresh[0].hi = Mode->VRefresh; + + Mode = Mode->next; + } +} + +ddc_quirk_t +xf86DDCDetectQuirks(int scrnIndex, xf86MonPtr DDC, Bool verbose) +{ + ddc_quirk_t quirks; + int i; + + quirks = DDC_QUIRK_NONE; + for (i = 0; ddc_quirks[i].detect; i++) { + if (ddc_quirks[i].detect (scrnIndex, DDC)) { + if (verbose) { + xf86DrvMsg (scrnIndex, X_INFO, " EDID quirk: %s\n", + ddc_quirks[i].description); + } + quirks |= ddc_quirks[i].quirk; + } + } + + return quirks; +} + +void xf86DetTimingApplyQuirks(struct detailed_monitor_section *det_mon, + ddc_quirk_t quirks, + int hsize, int vsize) +{ + if (det_mon->type != DT) + return; + + if (quirks & DDC_QUIRK_DETAILED_H_IN_CM) + det_mon->section.d_timings.h_size *= 10; + + if (quirks & DDC_QUIRK_DETAILED_V_IN_CM) + det_mon->section.d_timings.v_size *= 10; + + if (quirks & DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE) { + det_mon->section.d_timings.h_size = 10 * hsize; + det_mon->section.d_timings.v_size = 10 * vsize; + } +} + +/** + * Applies monitor-specific quirks to the decoded EDID information. + * + * Note that some quirks applying to the mode list are still implemented in + * xf86DDCGetModes. + */ +void +xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC) +{ + ddc_quirk_t quirks = xf86DDCDetectQuirks (scrnIndex, DDC, FALSE); + int i; + + for (i = 0; i < DET_TIMINGS; i++) { + xf86DetTimingApplyQuirks(DDC->det_mon + i, quirks, + DDC->features.hsize, + DDC->features.vsize); + } +} + +/** + * Walks the modes list, finding the mode with the largest area which is + * closest to the target refresh rate, and marks it as the only preferred mode. +*/ +static void +xf86DDCSetPreferredRefresh(int scrnIndex, DisplayModePtr modes, + float target_refresh) +{ + DisplayModePtr mode, best = modes; + + for (mode = modes; mode; mode = mode->next) + { + mode->type &= ~M_T_PREFERRED; + + if (mode == best) continue; + + if (mode->HDisplay * mode->VDisplay > + best->HDisplay * best->VDisplay) + { + best = mode; + continue; + } + if (mode->HDisplay * mode->VDisplay == + best->HDisplay * best->VDisplay) + { + double mode_refresh = xf86ModeVRefresh (mode); + double best_refresh = xf86ModeVRefresh (best); + double mode_dist = fabs(mode_refresh - target_refresh); + double best_dist = fabs(best_refresh - target_refresh); + + if (mode_dist < best_dist) + { + best = mode; + continue; + } + } + } + if (best) + best->type |= M_T_PREFERRED; +} + +#define CEA_VIDEO_MODES_NUM 64 +static const DisplayModeRec CEAVideoModes[CEA_VIDEO_MODES_NUM] = { + { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 1:640x480@60Hz */ + { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 2:720x480@60Hz */ + { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 3:720x480@60Hz */ + { MODEPREFIX, 74250, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 4: 1280x720@60Hz */ + { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 5:1920x1080i@60Hz */ + { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 6:1440x480i@60Hz */ + { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 7:1440x480i@60Hz */ + { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 8:1440x240@60Hz */ + { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 9:1440x240@60Hz */ + { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 10:2880x480i@60Hz */ + { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 11:2880x480i@60Hz */ + { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 12:2880x240@60Hz */ + { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 13:2880x240@60Hz */ + { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 14:1440x480@60Hz */ + { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 15:1440x480@60Hz */ + { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 16:1920x1080@60Hz */ + { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 17:720x576@50Hz */ + { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 18:720x576@50Hz */ + { MODEPREFIX, 74250, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 19: 1280x720@50Hz */ + { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 20:1920x1080i@50Hz */ + { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 21:1440x576i@50Hz */ + { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 22:1440x576i@50Hz */ + { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 23:1440x288@50Hz */ + { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 24:1440x288@50Hz */ + { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 25:2880x576i@50Hz */ + { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 26:2880x576i@50Hz */ + { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 27:2880x288@50Hz */ + { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 28:2880x288@50Hz */ + { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 29:1440x576@50Hz */ + { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 30:1440x576@50Hz */ + { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 31:1920x1080@50Hz */ + { MODEPREFIX, 74250, 1920, 2558, 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 32:1920x1080@24Hz */ + { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 33:1920x1080@25Hz */ + { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 34:1920x1080@30Hz */ + { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 35:2880x480@60Hz */ + { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 36:2880x480@60Hz */ + { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 37:2880x576@50Hz */ + { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 38:2880x576@50Hz */ + { MODEPREFIX, 72000, 1920, 1952, 2120, 2304, 0, 1080, 1126, 1136, 1250, 0, V_PHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 39:1920x1080i@50Hz */ + { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 40:1920x1080i@100Hz */ + { MODEPREFIX, 148500, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 41:1280x720@100Hz */ + { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 42:720x576@100Hz */ + { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 43:720x576@100Hz */ + { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 44:1440x576i@100Hz */ + { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 45:1440x576i@100Hz */ + { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 46:1920x1080i@120Hz */ + { MODEPREFIX, 148500, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 47:1280x720@120Hz */ + { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 48:720x480@120Hz */ + { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 49:720x480@120Hz */ + { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 50:1440x480i@120Hz */ + { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 51:1440x480i@120Hz */ + { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 52:720x576@200Hz */ + { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 53:720x576@200Hz */ + { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 54:1440x576i@200Hz */ + { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 55:1440x576i@200Hz */ + { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 56:720x480@240Hz */ + { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 57:720x480@240Hz */ + { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 58:1440x480i@240 */ + { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 59:1440x480i@240 */ + { MODEPREFIX, 59400, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 60: 1280x720@24Hz */ + { MODEPREFIX, 74250, 1280, 3700, 3740, 3960, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 61: 1280x720@25Hz */ + { MODEPREFIX, 74250, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 62: 1280x720@30Hz */ + { MODEPREFIX, 297000, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 63: 1920x1080@120Hz */ + { MODEPREFIX, 297000, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 64:1920x1080@100Hz */ +}; + +/* chose mode line by cea short video descriptor*/ +static void handle_cea_svd(struct cea_video_block *video, void *data) +{ + DisplayModePtr Mode; + DisplayModePtr *Modes = (DisplayModePtr *) data; + int vid; + + vid = video ->video_code & 0x7f; + if (vid < CEA_VIDEO_MODES_NUM) { + Mode = xf86DuplicateMode(CEAVideoModes + vid); + *Modes = xf86ModesAdd(*Modes, Mode); + } +} + +static DisplayModePtr +DDCModesFromCEAExtension(int scrnIndex, xf86MonPtr MonPtr) +{ + DisplayModePtr Modes = NULL; + + xf86ForEachVideoBlock(MonPtr, + handle_cea_svd, + &Modes); + + return Modes; +} + +struct det_modes_parameter { + xf86MonPtr DDC; + ddc_quirk_t quirks; + DisplayModePtr Modes; + Bool rb; + Bool preferred; + int timing_level; +}; + +static void handle_detailed_modes(struct detailed_monitor_section *det_mon, + void *data) +{ + DisplayModePtr Mode; + struct det_modes_parameter *p = (struct det_modes_parameter *)data; + + xf86DetTimingApplyQuirks(det_mon,p->quirks, + p->DDC->features.hsize, + p->DDC->features.vsize); + + switch (det_mon->type) { + case DT: + Mode = DDCModeFromDetailedTiming(p->DDC->scrnIndex, + &det_mon->section.d_timings, + p->preferred, + p->quirks); + p->preferred = FALSE; + p->Modes = xf86ModesAdd(p->Modes, Mode); + break; + case DS_STD_TIMINGS: + Mode = DDCModesFromStandardTiming(det_mon->section.std_t, + p->quirks, p->timing_level,p->rb); + p->Modes = xf86ModesAdd(p->Modes, Mode); + break; + case DS_CVT: + Mode = DDCModesFromCVT(p->DDC->scrnIndex, det_mon->section.cvt); + p->Modes = xf86ModesAdd(p->Modes, Mode); + break; + case DS_EST_III: + Mode = DDCModesFromEstIII(det_mon->section.est_iii); + p->Modes = xf86ModesAdd(p->Modes, Mode); + break; + default: + break; + } +} + +DisplayModePtr +xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC) +{ + DisplayModePtr Modes = NULL, Mode; + ddc_quirk_t quirks; + Bool preferred, rb; + int timing_level; + struct det_modes_parameter p; + + xf86DrvMsg (scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n", + DDC->vendor.name, DDC->vendor.prod_id); + + quirks = xf86DDCDetectQuirks(scrnIndex, DDC, TRUE); + + preferred = PREFERRED_TIMING_MODE(DDC->features.msc); + if (DDC->ver.revision >= 4) + preferred = TRUE; + if (quirks & DDC_QUIRK_FIRST_DETAILED_PREFERRED) + preferred = TRUE; + if (quirks & (DDC_QUIRK_PREFER_LARGE_60 | DDC_QUIRK_PREFER_LARGE_75)) + preferred = FALSE; + + rb = xf86MonitorSupportsReducedBlanking(DDC); + + timing_level = MonitorStandardTimingLevel(DDC); + + p.quirks = quirks; + p.DDC = DDC; + p.Modes = Modes; + p.rb = rb; + p.preferred = preferred; + p.timing_level = timing_level; + xf86ForEachDetailedBlock(DDC, handle_detailed_modes, &p); + Modes = p.Modes; + + /* Add established timings */ + Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1, quirks); + Modes = xf86ModesAdd(Modes, Mode); + + /* Add standard timings */ + Mode = DDCModesFromStandardTiming(DDC->timings2, quirks, timing_level, rb); + Modes = xf86ModesAdd(Modes, Mode); + + /* Add cea-extension mode timings */ + Mode = DDCModesFromCEAExtension(scrnIndex,DDC); + Modes = xf86ModesAdd(Modes, Mode); + + if (quirks & DDC_QUIRK_PREFER_LARGE_60) + xf86DDCSetPreferredRefresh(scrnIndex, Modes, 60); + + if (quirks & DDC_QUIRK_PREFER_LARGE_75) + xf86DDCSetPreferredRefresh(scrnIndex, Modes, 75); + + Modes = xf86PruneDuplicateModes(Modes); + + return Modes; +} + +struct det_mon_parameter { + MonPtr Monitor; + ddc_quirk_t quirks; + Bool have_hsync; + Bool have_vrefresh; + Bool have_maxpixclock; +}; + +static void handle_detailed_monset(struct detailed_monitor_section *det_mon, + void *data) +{ + int clock; + struct det_mon_parameter *p = (struct det_mon_parameter *)data; + int scrnIndex = ((xf86MonPtr)(p->Monitor->DDC))->scrnIndex; + + switch (det_mon->type) { + case DS_RANGES: + if (!p->have_hsync) { + if (!p->Monitor->nHsync) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for horizontal sync\n"); + p->Monitor->hsync[p->Monitor->nHsync].lo = + det_mon->section.ranges.min_h; + p->Monitor->hsync[p->Monitor->nHsync].hi = + det_mon->section.ranges.max_h; + p->Monitor->nHsync++; + } else { + xf86DrvMsg(scrnIndex, X_INFO, + "Using hsync ranges from config file\n"); + } + + if (!p->have_vrefresh) { + if (!p->Monitor->nVrefresh) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for vertical refresh\n"); + p->Monitor->vrefresh[p->Monitor->nVrefresh].lo = + det_mon->section.ranges.min_v; + p->Monitor->vrefresh[p->Monitor->nVrefresh].hi = + det_mon->section.ranges.max_v; + p->Monitor->nVrefresh++; + } else { + xf86DrvMsg(scrnIndex, X_INFO, + "Using vrefresh ranges from config file\n"); + } + + clock = det_mon->section.ranges.max_clock * 1000; + if (p->quirks & DDC_QUIRK_DVI_SINGLE_LINK) + clock = min(clock, 165000); + if (!p->have_maxpixclock && clock > p->Monitor->maxPixClock) + p->Monitor->maxPixClock = clock; + + break; + default: + break; + } +} + +/* + * Fill out MonPtr with xf86MonPtr information. + */ +void +xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) +{ + DisplayModePtr Modes = NULL, Mode; + struct det_mon_parameter p; + + if (!Monitor || !DDC) + return; + + Monitor->DDC = DDC; + + if (Monitor->widthmm <= 0 || Monitor->heightmm <= 0) { + Monitor->widthmm = 10 * DDC->features.hsize; + Monitor->heightmm = 10 * DDC->features.vsize; + } + + Monitor->reducedblanking = xf86MonitorSupportsReducedBlanking(DDC); + + Modes = xf86DDCGetModes(scrnIndex, DDC); + + /* Go through the detailed monitor sections */ + p.Monitor = Monitor; + p.quirks = xf86DDCDetectQuirks(scrnIndex, Monitor->DDC, FALSE); + p.have_hsync = (Monitor->nHsync != 0); + p.have_vrefresh = (Monitor->nVrefresh != 0); + p.have_maxpixclock = (Monitor->maxPixClock != 0); + xf86ForEachDetailedBlock(DDC, handle_detailed_monset, &p); + + if (Modes) { + /* Print Modes */ + xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n"); + + Mode = Modes; + while (Mode) { + xf86PrintModeline(scrnIndex, Mode); + Mode = Mode->next; + } + + /* Do we still need ranges to be filled in? */ + if (!Monitor->nHsync || !Monitor->nVrefresh) + DDCGuessRangesFromModes(scrnIndex, Monitor, Modes); + + /* look for last Mode */ + Mode = Modes; + + while (Mode->next) + Mode = Mode->next; + + /* add to MonPtr */ + if (Monitor->Modes) { + Monitor->Last->next = Modes; + Modes->prev = Monitor->Last; + Monitor->Last = Mode; + } else { + Monitor->Modes = Modes; + Monitor->Last = Mode; + } + } +} diff --git a/xorg-server/hw/xfree86/modes/xf86Modes.c b/xorg-server/hw/xfree86/modes/xf86Modes.c index 335bb43ee..45308f484 100644 --- a/xorg-server/hw/xfree86/modes/xf86Modes.c +++ b/xorg-server/hw/xfree86/modes/xf86Modes.c @@ -355,15 +355,32 @@ xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList, { DisplayModePtr mode; - for (mode = modeList; mode != NULL; mode = mode->next) { - if (maxPitch > 0 && mode->HDisplay > maxPitch) - mode->status = MODE_BAD_WIDTH; - - if (maxX > 0 && mode->HDisplay > maxX) - mode->status = MODE_VIRTUAL_X; + if (maxPitch <= 0) + maxPitch = MAXINT; + if (maxX <= 0) + maxX = MAXINT; + if (maxY <= 0) + maxY = MAXINT; - if (maxY > 0 && mode->VDisplay > maxY) - mode->status = MODE_VIRTUAL_Y; + for (mode = modeList; mode != NULL; mode = mode->next) { + if ((xf86ModeWidth(mode, RR_Rotate_0) > maxPitch || + xf86ModeWidth(mode, RR_Rotate_0) > maxX || + xf86ModeHeight(mode, RR_Rotate_0) > maxY) && + (xf86ModeWidth(mode, RR_Rotate_90) > maxPitch || + xf86ModeWidth(mode, RR_Rotate_90) > maxX || + xf86ModeHeight(mode, RR_Rotate_90) > maxY)) { + if (xf86ModeWidth(mode, RR_Rotate_0) > maxPitch || + xf86ModeWidth(mode, RR_Rotate_90) > maxPitch) + mode->status = MODE_BAD_WIDTH; + + if (xf86ModeWidth(mode, RR_Rotate_0) > maxX || + xf86ModeWidth(mode, RR_Rotate_90) > maxX) + mode->status = MODE_VIRTUAL_X; + + if (xf86ModeHeight(mode, RR_Rotate_0) > maxY || + xf86ModeHeight(mode, RR_Rotate_90) > maxY) + mode->status = MODE_VIRTUAL_Y; + } if (mode->next == modeList) break; diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c index 705bb5ea0..dcc878060 100644 --- a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c @@ -264,7 +264,7 @@ xf86DeallocateGARTMemory(int screenNum, int key) } #ifdef __linux__ - if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) { + if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)(uintptr_t)key) != 0) { #else if (ioctl(gartFd, AGPIOC_DEALLOCATE, &key) != 0) { #endif diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c index 0311bdf15..697c9fe30 100644 --- a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c @@ -461,7 +461,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) " (0x%08lx,0x%lx) (%s)\n", Base, Size, strerror(errno)); } - DebugF("base: %lx aligned base: %lx\n",base, base + alignOff); + DebugF("base: %lx aligned base: %lx\n",base, (char *)base + alignOff); return (char *)base + alignOff; } #endif /* !(__sparc__) */ diff --git a/xorg-server/hw/xfree86/x86emu/ops.c b/xorg-server/hw/xfree86/x86emu/ops.c index c0cfbd8c1..a55398275 100644 --- a/xorg-server/hw/xfree86/x86emu/ops.c +++ b/xorg-server/hw/xfree86/x86emu/ops.c @@ -7065,15 +7065,20 @@ Handles opcode 0x9a ****************************************************************************/ static void x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1)) { - u16 farseg, faroff; + u32 farseg, faroff; START_OF_INSTR(); - DECODE_PRINTF("CALL\t"); + DECODE_PRINTF("CALL\t"); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + faroff = fetch_long_imm(); + farseg = fetch_word_imm(); + } else { faroff = fetch_word_imm(); farseg = fetch_word_imm(); - DECODE_PRINTF2("%04x:", farseg); - DECODE_PRINTF2("%04x\n", faroff); - CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff, "FAR "); + } + DECODE_PRINTF2("%04x:", farseg); + DECODE_PRINTF2("%04x\n", faroff); + CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff, "FAR "); /* XXX * @@ -7084,8 +7089,12 @@ static void x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1)) TRACE_AND_STEP(); push_word(M.x86.R_CS); M.x86.R_CS = farseg; - push_word(M.x86.R_IP); - M.x86.R_IP = faroff; + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(M.x86.R_EIP); + } else { + push_word(M.x86.R_IP); + } + M.x86.R_EIP = faroff & 0xffff; DECODE_CLEAR_SEGOVR(); END_OF_INSTR(); } @@ -9670,17 +9679,30 @@ Handles opcode 0xe8 ****************************************************************************/ static void x86emuOp_call_near_IMM(u8 X86EMU_UNUSED(op1)) { - s16 ip; + s16 ip16; + s32 ip32; START_OF_INSTR(); - DECODE_PRINTF("CALL\t"); - ip = (s16) fetch_word_imm(); - ip += (s16) M.x86.R_IP; /* CHECK SIGN */ - DECODE_PRINTF2("%04x\n", (u16)ip); - CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip, ""); + DECODE_PRINTF("CALL\t"); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + ip32 = (s32) fetch_long_imm(); + ip32 += (s16) M.x86.R_IP; /* CHECK SIGN */ + DECODE_PRINTF2("%04x\n", (u16)ip32); + CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip32, ""); + } else { + ip16 = (s16) fetch_word_imm(); + ip16 += (s16) M.x86.R_IP; /* CHECK SIGN */ + DECODE_PRINTF2("%04x\n", (u16)ip16); + CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip16, ""); + } TRACE_AND_STEP(); - push_word(M.x86.R_IP); - M.x86.R_IP = ip; + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + push_long(M.x86.R_EIP); + M.x86.R_EIP = ip32 & 0xffff; + } else { + push_word(M.x86.R_IP); + M.x86.R_EIP = ip16; + } DECODE_CLEAR_SEGOVR(); END_OF_INSTR(); } @@ -9718,16 +9740,21 @@ Handles opcode 0xea ****************************************************************************/ static void x86emuOp_jump_far_IMM(u8 X86EMU_UNUSED(op1)) { - u16 cs, ip; + u16 cs; + u32 ip; START_OF_INSTR(); DECODE_PRINTF("JMP\tFAR "); - ip = fetch_word_imm(); + if (M.x86.mode & SYSMODE_PREFIX_DATA) { + ip = fetch_long_imm(); + } else { + ip = fetch_word_imm(); + } cs = fetch_word_imm(); DECODE_PRINTF2("%04x:", cs); DECODE_PRINTF2("%04x\n", ip); TRACE_AND_STEP(); - M.x86.R_IP = ip; + M.x86.R_EIP = ip & 0xffff; M.x86.R_CS = cs; DECODE_CLEAR_SEGOVR(); END_OF_INSTR(); diff --git a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c index cc7e810ca..126a4ee65 100644 --- a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c +++ b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c @@ -54,10 +54,10 @@ XAABitBlt( origDest.x = dstx; origDest.y = dsty; - if((pSrcDrawable != pDstDrawable) && - pSrcDrawable->pScreen->SourceValidate) { + if (pSrcDrawable->pScreen->SourceValidate) { (*pSrcDrawable->pScreen->SourceValidate) ( - pSrcDrawable, srcx, srcy, width, height); + pSrcDrawable, srcx, srcy, width, height, + pGC->subWindowMode); } srcx += pSrcDrawable->x; diff --git a/xorg-server/include/exevents.h b/xorg-server/include/exevents.h index b972cbedf..2b859a3bd 100644 --- a/xorg-server/include/exevents.h +++ b/xorg-server/include/exevents.h @@ -307,6 +307,6 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client, unsigned int len, unsigned char* mask); extern int -XICheckInvalidMaskBits(unsigned char *mask, int len); +XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len); #endif /* EXEVENTS_H */ diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h index a7fdc6671..31aad9aa4 100644 --- a/xorg-server/include/input.h +++ b/xorg-server/include/input.h @@ -532,6 +532,18 @@ void FixUpEventFromWindow(DeviceIntPtr pDev, WindowPtr pWin, Window child, Bool calcChild); +extern int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, + WindowPtr win); +/** + * Return masks for EventIsDeliverable. + * @defgroup EventIsDeliverable return flags + * @{ + */ +#define XI_MASK (1 << 0) /**< XI mask set on window */ +#define CORE_MASK (1 << 1) /**< Core mask set on window */ +#define DONT_PROPAGATE_MASK (1 << 2) /**< DontPropagate mask set on window */ +#define XI2_MASK (1 << 3) /**< XI2 mask set on window */ +/* @} */ /* Implemented by the DDX. */ extern _X_EXPORT int NewInputDeviceRequest( @@ -554,7 +566,6 @@ extern _X_HIDDEN void valuator_set_mode(DeviceIntPtr dev, int axis, int mode); xfixes/cursor.c uses it to determine if the cursor is enabled */ extern Bool EnableCursor; -/* For server-internal functions, see inpututil.h */ extern _X_EXPORT ValuatorMask *valuator_mask_new(int num_valuators); extern _X_EXPORT void valuator_mask_set_range(ValuatorMask *mask, int first_valuator, int num_valuators, @@ -563,5 +574,12 @@ extern _X_EXPORT void valuator_mask_set(ValuatorMask *mask, int valuator, int data); extern _X_EXPORT void valuator_mask_zero(ValuatorMask *mask); +extern _X_EXPORT int valuator_mask_size(const ValuatorMask *mask); +extern _X_EXPORT int valuator_mask_isset(const ValuatorMask *mask, int bit); +extern _X_EXPORT void valuator_mask_unset(ValuatorMask *mask, int bit); +extern _X_EXPORT int valuator_mask_num_valuators(const ValuatorMask *mask); +extern _X_EXPORT void valuator_mask_copy(ValuatorMask *dest, + const ValuatorMask *src); +extern _X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valnum); #endif /* INPUT_H */ diff --git a/xorg-server/include/inpututils.h b/xorg-server/include/inpututils.h index e59bf2860..af07afeb0 100644 --- a/xorg-server/include/inpututils.h +++ b/xorg-server/include/inpututils.h @@ -37,12 +37,4 @@ struct _ValuatorMask { int valuators[MAX_VALUATORS]; /* valuator data */ }; -/* server-internal */ -extern _X_HIDDEN int valuator_mask_size(const ValuatorMask *mask); -extern _X_HIDDEN int valuator_mask_isset(const ValuatorMask *mask, int bit); -extern _X_HIDDEN void valuator_mask_unset(ValuatorMask *mask, int bit); -extern _X_HIDDEN int valuator_mask_num_valuators(const ValuatorMask *mask); -extern _X_HIDDEN void valuator_mask_copy(ValuatorMask *dest, const ValuatorMask *src); -extern _X_HIDDEN int valuator_mask_get(const ValuatorMask *mask, int valnum); - #endif diff --git a/xorg-server/include/resource.h b/xorg-server/include/resource.h index aa719aa0a..a09679ad6 100644 --- a/xorg-server/include/resource.h +++ b/xorg-server/include/resource.h @@ -121,6 +121,8 @@ typedef unsigned long RESTYPE; #define BAD_RESOURCE 0xe0000000 +#define rClient(obj) (clients[CLIENT_ID((obj)->resource)]) + /* Resource state callback */ extern _X_EXPORT CallbackListPtr ResourceStateCallback; diff --git a/xorg-server/include/scrnintstr.h b/xorg-server/include/scrnintstr.h index 8d7c7db8b..fdb904fa2 100644 --- a/xorg-server/include/scrnintstr.h +++ b/xorg-server/include/scrnintstr.h @@ -135,7 +135,8 @@ typedef void (* SourceValidateProcPtr)( int /*x*/, int /*y*/, int /*width*/, - int /*height*/); + int /*height*/, + unsigned int /*subWindowMode*/); typedef Bool (* CreateWindowProcPtr)( WindowPtr /*pWindow*/); diff --git a/xorg-server/include/windowstr.h b/xorg-server/include/windowstr.h index fd97c3a55..e967223b4 100644 --- a/xorg-server/include/windowstr.h +++ b/xorg-server/include/windowstr.h @@ -167,6 +167,9 @@ typedef struct _Window { #ifdef ROOTLESS unsigned rootlessUnhittable:1; /* doesn't hit-test */ #endif +#ifdef COMPOSITE + unsigned damagedDescendants:1; /* some descendants are damaged */ +#endif } WindowRec; /* diff --git a/xorg-server/mi/micopy.c b/xorg-server/mi/micopy.c index da52bc659..ce01249e8 100644 --- a/xorg-server/mi/micopy.c +++ b/xorg-server/mi/micopy.c @@ -183,10 +183,10 @@ miDoCopy (DrawablePtr pSrcDrawable, return NULL; } - if ((pSrcDrawable != pDstDrawable) && - pSrcDrawable->pScreen->SourceValidate) + if (pSrcDrawable->pScreen->SourceValidate) { - (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, xIn, yIn, widthSrc, heightSrc); + (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, xIn, yIn, widthSrc, heightSrc, + pGC->subWindowMode); } /* Compute source clip region */ diff --git a/xorg-server/mi/misprite.c b/xorg-server/mi/misprite.c index 9a4bf49c7..0dce0a266 100644 --- a/xorg-server/mi/misprite.c +++ b/xorg-server/mi/misprite.c @@ -96,6 +96,7 @@ typedef struct { VisualPtr pVisual; DamagePtr pDamage; /* damage tracking structure */ Bool damageRegistered; + int numberOfCursors; } miSpriteScreenRec, *miSpriteScreenPtr; #define SOURCE_COLOR 0 @@ -184,6 +185,8 @@ miSpriteIsDown(miCursorInfoPtr pDevCursor) static DevPrivateKeyRec miSpriteScreenKeyRec; #define miSpriteScreenKey (&miSpriteScreenKeyRec) +#define GetSpriteScreen(pScreen) \ + (dixLookupPrivate(&(pScreen)->devPrivates, miSpriteScreenKey)) static DevPrivateKeyRec miSpriteDevPrivatesKeyRec; #define miSpriteDevPrivatesKey (&miSpriteDevPrivatesKeyRec) @@ -195,7 +198,8 @@ static void miSpriteGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart); static void miSpriteSourceValidate(DrawablePtr pDrawable, int x, int y, - int width, int height); + int width, int height, + unsigned int subWindowMode); static void miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc); @@ -214,11 +218,10 @@ static Bool miSpriteDeviceCursorInitialize(DeviceIntPtr pDev, static void miSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen); -#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \ - ((miSpriteScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \ - miSpriteScreenKey))->field) -#define SCREEN_EPILOGUE(pScreen, field)\ - ((pScreen)->field = miSprite##field) +#define SCREEN_PROLOGUE(pPriv, pScreen, field) ((pScreen)->field = \ + (pPriv)->field) +#define SCREEN_EPILOGUE(pPriv, pScreen, field)\ + ((pPriv)->field = (pScreen)->field, (pScreen)->field = miSprite##field) /* * pointer-sprite method table @@ -253,6 +256,15 @@ static void miSpriteSaveUnderCursor(DeviceIntPtr pDev, static void miSpriteRestoreCursor(DeviceIntPtr pDev, ScreenPtr pScreen); +static void +miSpriteRegisterBlockHandler(ScreenPtr pScreen, miSpriteScreenPtr pScreenPriv) +{ + if (!pScreenPriv->BlockHandler) { + pScreenPriv->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = miSpriteBlockHandler; + } +} + static void miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure) { @@ -330,7 +342,7 @@ miSpriteInitialize (ScreenPtr pScreen, pScreenPriv->InstallColormap = pScreen->InstallColormap; pScreenPriv->StoreColors = pScreen->StoreColors; - pScreenPriv->BlockHandler = pScreen->BlockHandler; + pScreenPriv->BlockHandler = NULL; pScreenPriv->DeviceCursorInitialize = pScreen->DeviceCursorInitialize; pScreenPriv->DeviceCursorCleanup = pScreen->DeviceCursorCleanup; @@ -344,6 +356,7 @@ miSpriteInitialize (ScreenPtr pScreen, pScreenPriv->colors[MASK_COLOR].green = 0; pScreenPriv->colors[MASK_COLOR].blue = 0; pScreenPriv->damageRegistered = 0; + pScreenPriv->numberOfCursors = 0; dixSetPrivate(&pScreen->devPrivates, miSpriteScreenKey, pScreenPriv); @@ -356,8 +369,6 @@ miSpriteInitialize (ScreenPtr pScreen, pScreen->InstallColormap = miSpriteInstallColormap; pScreen->StoreColors = miSpriteStoreColors; - pScreen->BlockHandler = miSpriteBlockHandler; - return TRUE; } @@ -373,14 +384,12 @@ miSpriteInitialize (ScreenPtr pScreen, static Bool miSpriteCloseScreen (int i, ScreenPtr pScreen) { - miSpriteScreenPtr pScreenPriv; + miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); - pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey); pScreen->CloseScreen = pScreenPriv->CloseScreen; pScreen->GetImage = pScreenPriv->GetImage; pScreen->GetSpans = pScreenPriv->GetSpans; pScreen->SourceValidate = pScreenPriv->SourceValidate; - pScreen->BlockHandler = pScreenPriv->BlockHandler; pScreen->InstallColormap = pScreenPriv->InstallColormap; pScreen->StoreColors = pScreenPriv->StoreColors; @@ -396,11 +405,12 @@ miSpriteGetImage (DrawablePtr pDrawable, int sx, int sy, int w, int h, unsigned int format, unsigned long planemask, char *pdstLine) { - ScreenPtr pScreen = pDrawable->pScreen; - DeviceIntPtr pDev; - miCursorInfoPtr pCursorInfo; + ScreenPtr pScreen = pDrawable->pScreen; + DeviceIntPtr pDev; + miCursorInfoPtr pCursorInfo; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); - SCREEN_PROLOGUE (pScreen, GetImage); + SCREEN_PROLOGUE (pPriv, pScreen, GetImage); if (pDrawable->type == DRAWABLE_WINDOW) { @@ -423,7 +433,7 @@ miSpriteGetImage (DrawablePtr pDrawable, int sx, int sy, int w, int h, (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine); - SCREEN_EPILOGUE (pScreen, GetImage); + SCREEN_EPILOGUE (pPriv, pScreen, GetImage); } static void @@ -433,8 +443,9 @@ miSpriteGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, ScreenPtr pScreen = pDrawable->pScreen; DeviceIntPtr pDev; miCursorInfoPtr pCursorInfo; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); - SCREEN_PROLOGUE (pScreen, GetSpans); + SCREEN_PROLOGUE (pPriv, pScreen, GetSpans); if (pDrawable->type == DRAWABLE_WINDOW) { @@ -474,18 +485,19 @@ miSpriteGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); - SCREEN_EPILOGUE (pScreen, GetSpans); + SCREEN_EPILOGUE (pPriv, pScreen, GetSpans); } static void miSpriteSourceValidate (DrawablePtr pDrawable, int x, int y, int width, - int height) + int height, unsigned int subWindowMode) { ScreenPtr pScreen = pDrawable->pScreen; DeviceIntPtr pDev; miCursorInfoPtr pCursorInfo; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); - SCREEN_PROLOGUE (pScreen, SourceValidate); + SCREEN_PROLOGUE (pPriv, pScreen, SourceValidate); if (pDrawable->type == DRAWABLE_WINDOW) { @@ -506,9 +518,9 @@ miSpriteSourceValidate (DrawablePtr pDrawable, int x, int y, int width, } if (pScreen->SourceValidate) - (*pScreen->SourceValidate) (pDrawable, x, y, width, height); + (*pScreen->SourceValidate) (pDrawable, x, y, width, height, subWindowMode); - SCREEN_EPILOGUE (pScreen, SourceValidate); + SCREEN_EPILOGUE (pPriv, pScreen, SourceValidate); } static void @@ -517,8 +529,9 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) ScreenPtr pScreen = pWindow->drawable.pScreen; DeviceIntPtr pDev; miCursorInfoPtr pCursorInfo; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); - SCREEN_PROLOGUE (pScreen, CopyWindow); + SCREEN_PROLOGUE (pPriv, pScreen, CopyWindow); for(pDev = inputInfo.devices; pDev; pDev = pDev->next) { @@ -538,7 +551,7 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) } (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc); - SCREEN_EPILOGUE (pScreen, CopyWindow); + SCREEN_EPILOGUE (pPriv, pScreen, CopyWindow); } static void @@ -546,16 +559,10 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout, pointer pReadmask) { ScreenPtr pScreen = screenInfo.screens[i]; - miSpriteScreenPtr pPriv; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); DeviceIntPtr pDev; miCursorInfoPtr pCursorInfo; - - pPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey); - SCREEN_PROLOGUE(pScreen, BlockHandler); - - (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); - - SCREEN_EPILOGUE(pScreen, BlockHandler); + Bool WorkToDo = FALSE; for(pDev = inputInfo.devices; pDev; pDev = pDev->next) { @@ -566,7 +573,7 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout, && pCursorInfo->pScreen == pScreen && pCursorInfo->shouldBeUp) { - SPRITE_DEBUG (("BlockHandler restore\n")); + SPRITE_DEBUG (("BlockHandler save")); miSpriteSaveUnderCursor (pDev, pScreen); } } @@ -582,23 +589,33 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout, { SPRITE_DEBUG (("BlockHandler restore\n")); miSpriteRestoreCursor (pDev, pScreen); + if (!pCursorInfo->isUp) + WorkToDo = TRUE; } } } + + SCREEN_PROLOGUE(pPriv, pScreen, BlockHandler); + + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + + if (WorkToDo) + SCREEN_EPILOGUE(pPriv, pScreen, BlockHandler); + else + pPriv->BlockHandler = NULL; } static void miSpriteInstallColormap (ColormapPtr pMap) { ScreenPtr pScreen = pMap->pScreen; - miSpriteScreenPtr pPriv; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); - pPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey); - SCREEN_PROLOGUE(pScreen, InstallColormap); + SCREEN_PROLOGUE(pPriv, pScreen, InstallColormap); (*pScreen->InstallColormap) (pMap); - SCREEN_EPILOGUE(pScreen, InstallColormap); + SCREEN_EPILOGUE(pPriv, pScreen, InstallColormap); /* InstallColormap can be called before devices are initialized. */ pPriv->pInstalledMap = pMap; @@ -624,19 +641,18 @@ static void miSpriteStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef) { ScreenPtr pScreen = pMap->pScreen; - miSpriteScreenPtr pPriv; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); int i; int updated; VisualPtr pVisual; DeviceIntPtr pDev; miCursorInfoPtr pCursorInfo; - pPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey); - SCREEN_PROLOGUE(pScreen, StoreColors); + SCREEN_PROLOGUE(pPriv, pScreen, StoreColors); (*pScreen->StoreColors) (pMap, ndef, pdef); - SCREEN_EPILOGUE(pScreen, StoreColors); + SCREEN_EPILOGUE(pPriv, pScreen, StoreColors); if (pPriv->pColormap == pMap) { @@ -706,8 +722,7 @@ miSpriteStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef) static void miSpriteFindColors (miCursorInfoPtr pDevCursor, ScreenPtr pScreen) { - miSpriteScreenPtr pScreenPriv = - dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey); + miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); CursorPtr pCursor; xColorItem *sourceColor, *maskColor; @@ -772,22 +787,32 @@ static void miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y) { - miCursorInfoPtr pPointer; + miCursorInfoPtr pPointer; + miSpriteScreenPtr pScreenPriv; if (!IsMaster(pDev) && !pDev->u.master) return; pPointer = MISPRITE(pDev); + pScreenPriv = GetSpriteScreen(pScreen); if (!pCursor) { + if (pPointer->shouldBeUp) + --pScreenPriv->numberOfCursors; pPointer->shouldBeUp = FALSE; if (pPointer->isUp) miSpriteRemoveCursor (pDev, pScreen); + if (pScreenPriv->numberOfCursors == 0) + miSpriteDisableDamage(pScreen, pScreenPriv); pPointer->pCursor = 0; return; } + if (!pPointer->shouldBeUp) + pScreenPriv->numberOfCursors++; pPointer->shouldBeUp = TRUE; + if (!pPointer->isUp) + miSpriteRegisterBlockHandler(pScreen, pScreenPriv); if (pPointer->x == x && pPointer->y == y && pPointer->pCursor == pCursor && @@ -884,10 +909,11 @@ miSpriteRemoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen) return; DamageDrawInternal (pScreen, TRUE); - pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey); + pScreenPriv = GetSpriteScreen(pScreen); pCursorInfo = MISPRITE(pDev); miSpriteIsDown(pCursorInfo); + miSpriteRegisterBlockHandler(pScreen, pScreenPriv); pCursorInfo->pCacheWin = NullWindow; miSpriteDisableDamage(pScreen, pScreenPriv); if (!miDCRestoreUnderCursor(pDev, @@ -922,7 +948,7 @@ miSpriteSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen) return; DamageDrawInternal (pScreen, TRUE); - pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey); + pScreenPriv = GetSpriteScreen(pScreen); pCursorInfo = MISPRITE(pDev); miSpriteComputeSaved (pDev, pScreen); @@ -963,7 +989,7 @@ miSpriteRestoreCursor (DeviceIntPtr pDev, ScreenPtr pScreen) return; DamageDrawInternal (pScreen, TRUE); - pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey); + pScreenPriv = GetSpriteScreen(pScreen); pCursorInfo = MISPRITE(pDev); miSpriteComputeSaved (pDev, pScreen); diff --git a/xorg-server/miext/damage/damage.c b/xorg-server/miext/damage/damage.c index 263ca8afa..0d5fab5bd 100644 --- a/xorg-server/miext/damage/damage.c +++ b/xorg-server/miext/damage/damage.c @@ -891,16 +891,6 @@ damageCopyArea(DrawablePtr pSrc, RegionPtr ret; DAMAGE_GC_OP_PROLOGUE(pGC, pDst); - /* The driver will only call SourceValidate() when pSrc != pDst, - * but the software sprite (misprite.c) always need to know when a - * drawable is copied so it can remove the sprite. See #1030. */ - if ((pSrc == pDst) && pSrc->pScreen->SourceValidate && - pSrc->type == DRAWABLE_WINDOW && - ((WindowPtr)pSrc)->viewable) - { - (*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height); - } - if (checkGCDamage (pDst, pGC)) { BoxRec box; @@ -937,16 +927,6 @@ damageCopyPlane(DrawablePtr pSrc, RegionPtr ret; DAMAGE_GC_OP_PROLOGUE(pGC, pDst); - /* The driver will only call SourceValidate() when pSrc != pDst, - * but the software sprite (misprite.c) always need to know when a - * drawable is copied so it can remove the sprite. See #1030. */ - if ((pSrc == pDst) && pSrc->pScreen->SourceValidate && - pSrc->type == DRAWABLE_WINDOW && - ((WindowPtr)pSrc)->viewable) - { - (*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height); - } - if (checkGCDamage (pDst, pGC)) { BoxRec box; diff --git a/xorg-server/miext/rootless/rootlessScreen.c b/xorg-server/miext/rootless/rootlessScreen.c index 364a75ac8..ca4f00c3e 100644 --- a/xorg-server/miext/rootless/rootlessScreen.c +++ b/xorg-server/miext/rootless/rootlessScreen.c @@ -223,7 +223,8 @@ out: * here and leave StopDrawing for the block handler. */ static void -RootlessSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h) +RootlessSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h, + unsigned int subWindowMode) { SCREEN_UNWRAP(pDrawable->pScreen, SourceValidate); if (pDrawable->type == DRAWABLE_WINDOW) { @@ -231,7 +232,7 @@ RootlessSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h) RootlessStartDrawing(pWin); } if (pDrawable->pScreen->SourceValidate) { - pDrawable->pScreen->SourceValidate(pDrawable, x, y, w, h); + pDrawable->pScreen->SourceValidate(pDrawable, x, y, w, h, subWindowMode); } SCREEN_WRAP(pDrawable->pScreen, SourceValidate); } diff --git a/xorg-server/os/access.c b/xorg-server/os/access.c index d43fdf8e4..b7e698c3b 100644 --- a/xorg-server/os/access.c +++ b/xorg-server/os/access.c @@ -1,2087 +1,2095 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -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, and/or sell copies of the Software, and to permit persons -to whom the Software is furnished to do so, provided that the above -copyright notice(s) and this permission notice appear in all copies of -the Software and that both the above copyright notice(s) and this -permission notice appear in supporting documentation. - -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 -OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL -INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING -FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -Except as contained in this notice, the name of a copyright holder -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -of the copyright holder. - -X Window System is a trademark of The Open Group. - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ - -/* - * Copyright (c) 2004, Oracle and/or its affiliates. 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 -#endif - -#ifdef WIN32 -#include -#endif - -#include -#include -#define XSERV_t -#define TRANS_SERVER -#define TRANS_REOPEN -#include -#include -#include -#include -#include "misc.h" -#include "site.h" -#include -#include -#ifndef WIN32 -#include -#include -#include - -#if defined(TCPCONN) || defined(STREAMSCONN) -#include -#endif /* TCPCONN || STREAMSCONN */ - -#ifdef HAS_GETPEERUCRED -# include -# ifdef sun -# include -# endif -#endif - -#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__) -# include -#endif -#if defined(SYSV) && defined(__i386__) -# include -#endif -#ifdef __GNU__ -#undef SIOCGIFCONF -#include -#else /*!__GNU__*/ -# include -#endif /*__GNU__ */ - -#ifdef SVR4 -#include -#include -#endif - -#include - -#ifdef CSRG_BASED -#include -#if (BSD >= 199103) -#define VARIABLE_IFREQ -#endif -#endif - -#ifdef BSD44SOCKETS -#ifndef VARIABLE_IFREQ -#define VARIABLE_IFREQ -#endif -#endif - -#ifdef HAS_GETIFADDRS -#include -#endif - -/* Solaris provides an extended interface SIOCGLIFCONF. Other systems - * may have this as well, but the code has only been tested on Solaris - * so far, so we only enable it there. Other platforms may be added as - * needed. - * - * Test for Solaris commented out -- TSI @ UQV 2003.06.13 - */ -#ifdef SIOCGLIFCONF -/* #if defined(sun) */ -#define USE_SIOCGLIFCONF -/* #endif */ -#endif - -#endif /* WIN32 */ - -#ifndef PATH_MAX -#include -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif -#endif -#endif - - -#define X_INCLUDE_NETDB_H -#include - -#include "dixstruct.h" -#include "osdep.h" - -#include "xace.h" - -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif -#endif - -Bool defeatAccessControl = FALSE; - -#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len) -#define acopy(a1, a2, len) memmove((char *)(a2), (char *)(a1), len) -#define addrEqual(fam, address, length, host) \ - ((fam) == (host)->family &&\ - (length) == (host)->len &&\ - !acmp (address, (host)->addr, length)) - -static int ConvertAddr(struct sockaddr * /*saddr*/, - int * /*len*/, - pointer * /*addr*/); - -static int CheckAddr(int /*family*/, - const void * /*pAddr*/, - unsigned /*length*/); - -static Bool NewHost(int /*family*/, - const void * /*addr*/, - int /*len*/, - int /* addingLocalHosts */); - -/* XFree86 bug #156: To keep track of which hosts were explicitly requested in - /etc/X.hosts, we've added a requested field to the HOST struct, - and a LocalHostRequested variable. These default to FALSE, but are set - to TRUE in ResetHosts when reading in /etc/X.hosts. They are - checked in DisableLocalHost(), which is called to disable the default - local host entries when stronger authentication is turned on. */ - -typedef struct _host { - short family; - short len; - unsigned char *addr; - struct _host *next; - int requested; -} HOST; - -#define MakeHost(h,l) (h)=malloc(sizeof *(h)+(l));\ - if (h) { \ - (h)->addr=(unsigned char *) ((h) + 1);\ - (h)->requested = FALSE; \ - } -#define FreeHost(h) free(h) -static HOST *selfhosts = NULL; -static HOST *validhosts = NULL; -static int AccessEnabled = DEFAULT_ACCESS_CONTROL; -static int LocalHostEnabled = FALSE; -static int LocalHostRequested = FALSE; -static int UsingXdmcp = FALSE; - -/* FamilyServerInterpreted implementation */ -static Bool siAddrMatch(int family, pointer addr, int len, HOST *host, - ClientPtr client); -static int siCheckAddr(const char *addrString, int length); -static void siTypesInitialize(void); - -/* - * called when authorization is not enabled to add the - * local host to the access list - */ - -void -EnableLocalHost (void) -{ - if (!UsingXdmcp) - { - LocalHostEnabled = TRUE; - AddLocalHosts (); - } -} - -/* - * called when authorization is enabled to keep us secure - */ -void -DisableLocalHost (void) -{ - HOST *self; - - if (!LocalHostRequested) /* Fix for XFree86 bug #156 */ - LocalHostEnabled = FALSE; - for (self = selfhosts; self; self = self->next) { - if (!self->requested) /* Fix for XFree86 bug #156 */ - (void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr); - } -} - -/* - * called at init time when XDMCP will be used; xdmcp always - * adds local hosts manually when needed - */ - -void -AccessUsingXdmcp (void) -{ - UsingXdmcp = TRUE; - LocalHostEnabled = FALSE; -} - - -#if defined(SVR4) && !defined(sun) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF) - -/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */ - -static int -ifioctl (int fd, int cmd, char *arg) -{ - struct strioctl ioc; - int ret; - - memset((char *) &ioc, 0, sizeof(ioc)); - ioc.ic_cmd = cmd; - ioc.ic_timout = 0; - if (cmd == SIOCGIFCONF) - { - ioc.ic_len = ((struct ifconf *) arg)->ifc_len; - ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf; - } - else - { - ioc.ic_len = sizeof(struct ifreq); - ioc.ic_dp = arg; - } - ret = ioctl(fd, I_STR, (char *) &ioc); - if (ret >= 0 && cmd == SIOCGIFCONF) -#ifdef SVR4 - ((struct ifconf *) arg)->ifc_len = ioc.ic_len; -#endif - return ret; -} -#else -#define ifioctl ioctl -#endif - -/* - * DefineSelf (fd): - * - * Define this host for access control. Find all the hosts the OS knows about - * for this fd and add them to the selfhosts list. - */ - -#if !defined(SIOCGIFCONF) -void -DefineSelf (int fd) -{ -#if !defined(TCPCONN) && !defined(STREAMSCONN) && !defined(UNIXCONN) - return; -#else - register int n; - int len; - caddr_t addr; - int family; - register HOST *host; - -#ifndef WIN32 - struct utsname name; -#else - struct { - char nodename[512]; - } name; -#endif - - register struct hostent *hp; - - union { - struct sockaddr sa; - struct sockaddr_in in; -#if defined(IPv6) && defined(AF_INET6) - struct sockaddr_in6 in6; -#endif - } saddr; - - struct sockaddr_in *inetaddr; - struct sockaddr_in6 *inet6addr; - struct sockaddr_in broad_addr; -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgethostbynameparams hparams; -#endif - - /* Why not use gethostname()? Well, at least on my system, I've had to - * make an ugly kernel patch to get a name longer than 8 characters, and - * uname() lets me access to the whole string (it smashes release, you - * see), whereas gethostname() kindly truncates it for me. - */ -#ifndef WIN32 - uname(&name); -#else - gethostname(name.nodename, sizeof(name.nodename)); -#endif - - hp = _XGethostbyname(name.nodename, hparams); - if (hp != NULL) - { - saddr.sa.sa_family = hp->h_addrtype; - switch (hp->h_addrtype) { - case AF_INET: - inetaddr = (struct sockaddr_in *) (&(saddr.sa)); - acopy ( hp->h_addr, &(inetaddr->sin_addr), hp->h_length); - len = sizeof(saddr.sa); - break; -#if defined(IPv6) && defined(AF_INET6) - case AF_INET6: - inet6addr = (struct sockaddr_in6 *) (&(saddr.sa)); - acopy ( hp->h_addr, &(inet6addr->sin6_addr), hp->h_length); - len = sizeof(saddr.in6); - break; -#endif - default: - goto DefineLocalHost; - } - family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr); - if ( family != -1 && family != FamilyLocal ) - { - for (host = selfhosts; - host && !addrEqual (family, addr, len, host); - host = host->next) ; - if (!host) - { - /* add this host to the host list. */ - MakeHost(host,len) - if (host) - { - host->family = family; - host->len = len; - acopy ( addr, host->addr, len); - host->next = selfhosts; - selfhosts = host; - } -#ifdef XDMCP - /* - * If this is an Internet Address, but not the localhost - * address (127.0.0.1), nor the bogus address (0.0.0.0), - * register it. - */ - if (family == FamilyInternet && - !(len == 4 && - ((addr[0] == 127) || - (addr[0] == 0 && addr[1] == 0 && - addr[2] == 0 && addr[3] == 0))) - ) - { - XdmcpRegisterConnection (family, (char *)addr, len); - broad_addr = *inetaddr; - ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr = - htonl (INADDR_BROADCAST); - XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) - &broad_addr); - } -#if defined(IPv6) && defined(AF_INET6) - else if (family == FamilyInternet6 && - !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))) - { - XdmcpRegisterConnection (family, (char *)addr, len); - } -#endif - -#endif /* XDMCP */ - } - } - } - /* - * now add a host of family FamilyLocalHost... - */ -DefineLocalHost: - for (host = selfhosts; - host && !addrEqual(FamilyLocalHost, "", 0, host); - host = host->next); - if (!host) - { - MakeHost(host, 0); - if (host) - { - host->family = FamilyLocalHost; - host->len = 0; - acopy("", host->addr, 0); - host->next = selfhosts; - selfhosts = host; - } - } -#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN */ -} - -#else - -#ifdef USE_SIOCGLIFCONF -#define ifr_type struct lifreq -#else -#define ifr_type struct ifreq -#endif - -#ifdef VARIABLE_IFREQ -#define ifr_size(p) (sizeof (struct ifreq) + \ - (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \ - p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0)) -#define ifraddr_size(a) (a.sa_len) -#else -#define ifr_size(p) (sizeof (ifr_type)) -#define ifraddr_size(a) (sizeof (a)) -#endif - -#if defined(IPv6) && defined(AF_INET6) -#include -#endif - -#if defined(IPv6) && defined(AF_INET6) -static void -in6_fillscopeid(struct sockaddr_in6 *sin6) -{ -#if defined(__KAME__) - if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { - sin6->sin6_scope_id = - ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]); - sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0; - } -#endif -} -#endif - -void -DefineSelf (int fd) -{ -#ifndef HAS_GETIFADDRS - char *cp, *cplim; -# ifdef USE_SIOCGLIFCONF - struct sockaddr_storage buf[16]; - struct lifconf ifc; - register struct lifreq *ifr; -# ifdef SIOCGLIFNUM - struct lifnum ifn; -# endif -# else /* !USE_SIOCGLIFCONF */ - char buf[2048]; - struct ifconf ifc; - register struct ifreq *ifr; -# endif - void * bufptr = buf; -#else /* HAS_GETIFADDRS */ - struct ifaddrs * ifap, *ifr; -#endif - int len; - unsigned char * addr; - int family; - register HOST *host; - -#ifndef HAS_GETIFADDRS - - len = sizeof(buf); - -#ifdef USE_SIOCGLIFCONF - -#ifdef SIOCGLIFNUM - ifn.lifn_family = AF_UNSPEC; - ifn.lifn_flags = 0; - if (ioctl (fd, SIOCGLIFNUM, (char *) &ifn) < 0) - Error ("Getting interface count"); - if (len < (ifn.lifn_count * sizeof(struct lifreq))) { - len = ifn.lifn_count * sizeof(struct lifreq); - bufptr = malloc(len); - } -#endif - - ifc.lifc_family = AF_UNSPEC; - ifc.lifc_flags = 0; - ifc.lifc_len = len; - ifc.lifc_buf = bufptr; - -#define IFC_IOCTL_REQ SIOCGLIFCONF -#define IFC_IFC_REQ ifc.lifc_req -#define IFC_IFC_LEN ifc.lifc_len -#define IFR_IFR_ADDR ifr->lifr_addr -#define IFR_IFR_NAME ifr->lifr_name - -#else /* Use SIOCGIFCONF */ - ifc.ifc_len = len; - ifc.ifc_buf = bufptr; - -#define IFC_IOCTL_REQ SIOCGIFCONF -#define IFC_IFC_REQ ifc.ifc_req -#define IFC_IFC_LEN ifc.ifc_len -#define IFR_IFR_ADDR ifr->ifr_addr -#define IFR_IFR_NAME ifr->ifr_name -#endif - - if (ifioctl (fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0) - Error ("Getting interface configuration (4)"); - - cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN; - - for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr)) - { - ifr = (ifr_type *) cp; - len = ifraddr_size (IFR_IFR_ADDR); - family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR, - &len, (pointer *)&addr); - if (family == -1 || family == FamilyLocal) - continue; -#if defined(IPv6) && defined(AF_INET6) - if (family == FamilyInternet6) - in6_fillscopeid((struct sockaddr_in6 *)&IFR_IFR_ADDR); -#endif - for (host = selfhosts; - host && !addrEqual (family, addr, len, host); - host = host->next) - ; - if (host) - continue; - MakeHost(host,len) - if (host) - { - host->family = family; - host->len = len; - acopy(addr, host->addr, len); - host->next = selfhosts; - selfhosts = host; - } -#ifdef XDMCP - { -#ifdef USE_SIOCGLIFCONF - struct sockaddr_storage broad_addr; -#else - struct sockaddr broad_addr; -#endif - - /* - * If this isn't an Internet Address, don't register it. - */ - if (family != FamilyInternet -#if defined(IPv6) && defined(AF_INET6) - && family != FamilyInternet6 -#endif - ) - continue; - - /* - * ignore 'localhost' entries as they're not useful - * on the other end of the wire - */ - if (family == FamilyInternet && - addr[0] == 127 && addr[1] == 0 && - addr[2] == 0 && addr[3] == 1) - continue; -#if defined(IPv6) && defined(AF_INET6) - else if (family == FamilyInternet6 && - IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)) - continue; -#endif - - /* - * Ignore '0.0.0.0' entries as they are - * returned by some OSes for unconfigured NICs but they are - * not useful on the other end of the wire. - */ - if (len == 4 && - addr[0] == 0 && addr[1] == 0 && - addr[2] == 0 && addr[3] == 0) - continue; - - XdmcpRegisterConnection (family, (char *)addr, len); - -#if defined(IPv6) && defined(AF_INET6) - /* IPv6 doesn't support broadcasting, so we drop out here */ - if (family == FamilyInternet6) - continue; -#endif - - broad_addr = IFR_IFR_ADDR; - - ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr = - htonl (INADDR_BROADCAST); -#if defined(USE_SIOCGLIFCONF) && defined(SIOCGLIFBRDADDR) - { - struct lifreq broad_req; - - broad_req = *ifr; - if (ioctl (fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 && - (broad_req.lifr_flags & IFF_BROADCAST) && - (broad_req.lifr_flags & IFF_UP) - ) - { - broad_req = *ifr; - if (ioctl (fd, SIOCGLIFBRDADDR, &broad_req) != -1) - broad_addr = broad_req.lifr_broadaddr; - else - continue; - } - else - continue; - } - -#elif defined(SIOCGIFBRDADDR) - { - struct ifreq broad_req; - - broad_req = *ifr; - if (ifioctl (fd, SIOCGIFFLAGS, (pointer) &broad_req) != -1 && - (broad_req.ifr_flags & IFF_BROADCAST) && - (broad_req.ifr_flags & IFF_UP) - ) - { - broad_req = *ifr; - if (ifioctl (fd, SIOCGIFBRDADDR, (pointer) &broad_req) != -1) - broad_addr = broad_req.ifr_addr; - else - continue; - } - else - continue; - } -#endif /* SIOCGIFBRDADDR */ - XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr); - } -#endif /* XDMCP */ - } - if (bufptr != buf) - free(bufptr); -#else /* HAS_GETIFADDRS */ - if (getifaddrs(&ifap) < 0) { - ErrorF("Warning: getifaddrs returns %s\n", strerror(errno)); - return; - } - for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) { - if (!ifr->ifa_addr) - continue; - len = sizeof(*(ifr->ifa_addr)); - family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len, - (pointer *)&addr); - if (family == -1 || family == FamilyLocal) - continue; -#if defined(IPv6) && defined(AF_INET6) - if (family == FamilyInternet6) - in6_fillscopeid((struct sockaddr_in6 *)ifr->ifa_addr); -#endif - - for (host = selfhosts; - host != NULL && !addrEqual(family, addr, len, host); - host = host->next) - ; - if (host != NULL) - continue; - MakeHost(host, len); - if (host != NULL) { - host->family = family; - host->len = len; - acopy(addr, host->addr, len); - host->next = selfhosts; - selfhosts = host; - } -#ifdef XDMCP - { - /* - * If this isn't an Internet Address, don't register it. - */ - if (family != FamilyInternet -#if defined(IPv6) && defined(AF_INET6) - && family != FamilyInternet6 -#endif - ) - continue; - - /* - * ignore 'localhost' entries as they're not useful - * on the other end of the wire - */ - if (ifr->ifa_flags & IFF_LOOPBACK) - continue; - - if (family == FamilyInternet && - addr[0] == 127 && addr[1] == 0 && - addr[2] == 0 && addr[3] == 1) - continue; - - /* - * Ignore '0.0.0.0' entries as they are - * returned by some OSes for unconfigured NICs but they are - * not useful on the other end of the wire. - */ - if (len == 4 && - addr[0] == 0 && addr[1] == 0 && - addr[2] == 0 && addr[3] == 0) - continue; -#if defined(IPv6) && defined(AF_INET6) - else if (family == FamilyInternet6 && - IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)) - continue; -#endif - XdmcpRegisterConnection(family, (char *)addr, len); -#if defined(IPv6) && defined(AF_INET6) - if (family == FamilyInternet6) - /* IPv6 doesn't support broadcasting, so we drop out here */ - continue; -#endif - if ((ifr->ifa_flags & IFF_BROADCAST) && - (ifr->ifa_flags & IFF_UP) && - ifr->ifa_broadaddr) - XdmcpRegisterBroadcastAddress( - (struct sockaddr_in *) ifr->ifa_broadaddr); - else - continue; - } -#endif /* XDMCP */ - - } /* for */ - freeifaddrs(ifap); -#endif /* HAS_GETIFADDRS */ - - /* - * add something of FamilyLocalHost - */ - for (host = selfhosts; - host && !addrEqual(FamilyLocalHost, "", 0, host); - host = host->next); - if (!host) - { - MakeHost(host, 0); - if (host) - { - host->family = FamilyLocalHost; - host->len = 0; - acopy("", host->addr, 0); - host->next = selfhosts; - selfhosts = host; - } - } -} -#endif /* hpux && !HAS_IFREQ */ - -#ifdef XDMCP -void -AugmentSelf(pointer from, int len) -{ - int family; - pointer addr; - register HOST *host; - - family = ConvertAddr(from, &len, (pointer *)&addr); - if (family == -1 || family == FamilyLocal) - return; - for (host = selfhosts; host; host = host->next) - { - if (addrEqual(family, addr, len, host)) - return; - } - MakeHost(host,len) - if (!host) - return; - host->family = family; - host->len = len; - acopy(addr, host->addr, len); - host->next = selfhosts; - selfhosts = host; -} -#endif - -void -AddLocalHosts (void) -{ - HOST *self; - - for (self = selfhosts; self; self = self->next) - /* Fix for XFree86 bug #156: pass addingLocal = TRUE to - * NewHost to tell that we are adding the default local - * host entries and not to flag the entries as being - * explicitely requested */ - (void) NewHost (self->family, self->addr, self->len, TRUE); -} - -/* Reset access control list to initial hosts */ -void -ResetHosts (char *display) -{ - register HOST *host; - char lhostname[120], ohostname[120]; - char *hostname = ohostname; - char fname[PATH_MAX + 1]; - int fnamelen; - FILE *fd; - char *ptr; - int i, hostlen; -#if (defined(TCPCONN) || defined(STREAMSCONN) ) && \ - (!defined(IPv6) || !defined(AF_INET6)) - union { - struct sockaddr sa; -#if defined(TCPCONN) || defined(STREAMSCONN) - struct sockaddr_in in; -#endif /* TCPCONN || STREAMSCONN */ - } saddr; -#endif - int family = 0; - pointer addr; - int len; - - siTypesInitialize(); - AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL; - LocalHostEnabled = FALSE; - while ((host = validhosts) != 0) - { - validhosts = host->next; - FreeHost (host); - } - -#if defined WIN32 && defined __MINGW32__ -#define ETC_HOST_PREFIX "X" -#else -#define ETC_HOST_PREFIX "/etc/X" -#endif -#define ETC_HOST_SUFFIX ".hosts" - fnamelen = strlen(ETC_HOST_PREFIX) + strlen(ETC_HOST_SUFFIX) + - strlen(display) + 1; - if (fnamelen > sizeof(fname)) - FatalError("Display name `%s' is too long\n", display); - snprintf(fname, sizeof(fname), ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX, - display); - - if ((fd = fopen (fname, "r")) != 0) - { - while (fgets (ohostname, sizeof (ohostname), fd)) - { - family = FamilyWild; - if (*ohostname == '#') - continue; - if ((ptr = strchr(ohostname, '\n')) != 0) - *ptr = 0; - hostlen = strlen(ohostname) + 1; - for (i = 0; i < hostlen; i++) - lhostname[i] = tolower(ohostname[i]); - hostname = ohostname; - if (!strncmp("local:", lhostname, 6)) - { - family = FamilyLocalHost; - NewHost(family, "", 0, FALSE); - LocalHostRequested = TRUE; /* Fix for XFree86 bug #156 */ - } -#if defined(TCPCONN) || defined(STREAMSCONN) - else if (!strncmp("inet:", lhostname, 5)) - { - family = FamilyInternet; - hostname = ohostname + 5; - } -#if defined(IPv6) && defined(AF_INET6) - else if (!strncmp("inet6:", lhostname, 6)) - { - family = FamilyInternet6; - hostname = ohostname + 6; - } -#endif -#endif -#ifdef SECURE_RPC - else if (!strncmp("nis:", lhostname, 4)) - { - family = FamilyNetname; - hostname = ohostname + 4; - } -#endif - else if (!strncmp("si:", lhostname, 3)) - { - family = FamilyServerInterpreted; - hostname = ohostname + 3; - hostlen -= 3; - } - - - if (family == FamilyServerInterpreted) - { - len = siCheckAddr(hostname, hostlen); - if (len >= 0) { - NewHost(family, hostname, len, FALSE); - } - } - else -#ifdef SECURE_RPC - if ((family == FamilyNetname) || (strchr(hostname, '@'))) - { - SecureRPCInit (); - (void) NewHost (FamilyNetname, hostname, strlen (hostname), FALSE); - } - else -#endif /* SECURE_RPC */ -#if defined(TCPCONN) || defined(STREAMSCONN) - { -#if defined(IPv6) && defined(AF_INET6) - if ( (family == FamilyInternet) || (family == FamilyInternet6) || - (family == FamilyWild) ) - { - struct addrinfo *addresses; - struct addrinfo *a; - int f; - - if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) { - for (a = addresses ; a != NULL ; a = a->ai_next) { - len = a->ai_addrlen; - f = ConvertAddr(a->ai_addr,&len,(pointer *)&addr); - if ( (family == f) || - ((family == FamilyWild) && (f != -1)) ) { - NewHost(f, addr, len, FALSE); - } - } - freeaddrinfo(addresses); - } - } -#else -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgethostbynameparams hparams; -#endif - register struct hostent *hp; - - /* host name */ - if ((family == FamilyInternet && - ((hp = _XGethostbyname(hostname, hparams)) != 0)) || - ((hp = _XGethostbyname(hostname, hparams)) != 0)) - { - saddr.sa.sa_family = hp->h_addrtype; - len = sizeof(saddr.sa); - if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1) - { -#ifdef h_addr /* new 4.3bsd version of gethostent */ - char **list; - - /* iterate over the addresses */ - for (list = hp->h_addr_list; *list; list++) - (void) NewHost (family, (pointer)*list, len, FALSE); -#else - (void) NewHost (family, (pointer)hp->h_addr, len, FALSE); -#endif - } - } -#endif /* IPv6 */ - } -#endif /* TCPCONN || STREAMSCONN */ - family = FamilyWild; - } - fclose (fd); - } -} - -/* Is client on the local host */ -Bool LocalClient(ClientPtr client) -{ - int alen, family, notused; - Xtransaddr *from = NULL; - pointer addr; - register HOST *host; - - if (!client->osPrivate) - return FALSE; - if (!((OsCommPtr)client->osPrivate)->trans_conn) - return FALSE; - - if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn, - ¬used, &alen, &from)) - { - family = ConvertAddr ((struct sockaddr *) from, - &alen, (pointer *)&addr); - if (family == -1) - { - free(from); - return FALSE; - } - if (family == FamilyLocal) - { - free(from); - return TRUE; - } - for (host = selfhosts; host; host = host->next) - { - if (addrEqual (family, addr, alen, host)) - return TRUE; - } - free(from); - } - return FALSE; -} - -/* - * Return the uid and gid of a connected local client - * - * Used by XShm to test access rights to shared memory segments - */ -int -LocalClientCred(ClientPtr client, int *pUid, int *pGid) -{ - LocalClientCredRec *lcc; - int ret = GetLocalClientCreds(client, &lcc); - - if (ret == 0) { -#ifdef HAVE_GETZONEID /* only local if in the same zone */ - if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) { - FreeLocalClientCreds(lcc); - return -1; - } -#endif - if ((lcc->fieldsSet & LCC_UID_SET) && (pUid != NULL)) - *pUid = lcc->euid; - if ((lcc->fieldsSet & LCC_GID_SET) && (pGid != NULL)) - *pGid = lcc->egid; - FreeLocalClientCreds(lcc); - } - return ret; -} - -/* - * Return the uid and all gids of a connected local client - * Allocates a LocalClientCredRec - caller must call FreeLocalClientCreds - * - * Used by localuser & localgroup ServerInterpreted access control forms below - * Used by AuthAudit to log who local connections came from - */ -int -GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp) -{ -#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED) - int fd; - XtransConnInfo ci; - LocalClientCredRec *lcc; -#ifdef HAS_GETPEEREID - uid_t uid; - gid_t gid; -#elif defined(HAS_GETPEERUCRED) - ucred_t *peercred = NULL; - const gid_t *gids; -#elif defined(SO_PEERCRED) - struct ucred peercred; - socklen_t so_len = sizeof(peercred); -#endif - - if (client == NULL) - return -1; - ci = ((OsCommPtr)client->osPrivate)->trans_conn; -#if !(defined(sun) && defined(HAS_GETPEERUCRED)) - /* Most implementations can only determine peer credentials for Unix - * domain sockets - Solaris getpeerucred can work with a bit more, so - * we just let it tell us if the connection type is supported or not - */ - if (!_XSERVTransIsLocal(ci)) { - return -1; - } -#endif - - *lccp = calloc(1, sizeof(LocalClientCredRec)); - if (*lccp == NULL) - return -1; - lcc = *lccp; - - fd = _XSERVTransGetConnectionNumber(ci); -#ifdef HAS_GETPEEREID - if (getpeereid(fd, &uid, &gid) == -1) { - FreeLocalClientCreds(lcc); - return -1; - } - lcc->euid = uid; - lcc->egid = gid; - lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET; - return 0; -#elif defined(HAS_GETPEERUCRED) - if (getpeerucred(fd, &peercred) < 0) { - FreeLocalClientCreds(lcc); - return -1; - } - lcc->euid = ucred_geteuid(peercred); - if (lcc->euid != -1) - lcc->fieldsSet |= LCC_UID_SET; - lcc->egid = ucred_getegid(peercred); - if (lcc->egid != -1) - lcc->fieldsSet |= LCC_GID_SET; - lcc->pid = ucred_getpid(peercred); - if (lcc->pid != -1) - lcc->fieldsSet |= LCC_PID_SET; -#ifdef HAVE_GETZONEID - lcc->zoneid = ucred_getzoneid(peercred); - if (lcc->zoneid != -1) - lcc->fieldsSet |= LCC_ZID_SET; -#endif - lcc->nSuppGids = ucred_getgroups(peercred, &gids); - if (lcc->nSuppGids > 0) { - lcc->pSuppGids = calloc(lcc->nSuppGids, sizeof(int)); - if (lcc->pSuppGids == NULL) { - lcc->nSuppGids = 0; - } else { - int i; - for (i = 0 ; i < lcc->nSuppGids; i++) { - (lcc->pSuppGids)[i] = (int) gids[i]; - } - } - } else { - lcc->nSuppGids = 0; - } - ucred_free(peercred); - return 0; -#elif defined(SO_PEERCRED) - if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) == -1) { - FreeLocalClientCreds(lcc); - return -1; - } - lcc->euid = peercred.uid; - lcc->egid = peercred.gid; - lcc->pid = peercred.pid; - lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET | LCC_PID_SET; - return 0; -#endif -#else - /* No system call available to get the credentials of the peer */ -#define NO_LOCAL_CLIENT_CRED - return -1; -#endif -} - -void -FreeLocalClientCreds(LocalClientCredRec *lcc) -{ - if (lcc != NULL) { - if (lcc->nSuppGids > 0) { - free(lcc->pSuppGids); - } - free(lcc); - } -} - -static int -AuthorizedClient(ClientPtr client) -{ - int rc; - - if (!client || defeatAccessControl) - return Success; - - /* untrusted clients can't change host access */ - rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); - if (rc != Success) - return rc; - - return LocalClient(client) ? Success : BadAccess; -} - -/* Add a host to the access control list. This is the external interface - * called from the dispatcher */ - -int -AddHost (ClientPtr client, - int family, - unsigned length, /* of bytes in pAddr */ - const void * pAddr) -{ - int rc, len; - - rc = AuthorizedClient(client); - if (rc != Success) - return rc; - switch (family) { - case FamilyLocalHost: - len = length; - LocalHostEnabled = TRUE; - break; -#ifdef SECURE_RPC - case FamilyNetname: - len = length; - SecureRPCInit (); - break; -#endif - case FamilyInternet: -#if defined(IPv6) && defined(AF_INET6) - case FamilyInternet6: -#endif - case FamilyDECnet: - case FamilyChaos: - case FamilyServerInterpreted: - if ((len = CheckAddr (family, pAddr, length)) < 0) - { - client->errorValue = length; - return BadValue; - } - break; - case FamilyLocal: - default: - client->errorValue = family; - return BadValue; - } - if (NewHost (family, pAddr, len, FALSE)) - return Success; - return BadAlloc; -} - -Bool -ForEachHostInFamily (int family, - Bool (*func)( - unsigned char * /* addr */, - short /* len */, - pointer /* closure */), - pointer closure) -{ - HOST *host; - - for (host = validhosts; host; host = host->next) - if (family == host->family && func (host->addr, host->len, closure)) - return TRUE; - return FALSE; -} - -/* Add a host to the access control list. This is the internal interface - * called when starting or resetting the server */ -static Bool -NewHost (int family, - const void * addr, - int len, - int addingLocalHosts) -{ - register HOST *host; - - for (host = validhosts; host; host = host->next) - { - if (addrEqual (family, addr, len, host)) - return TRUE; - } - if (!addingLocalHosts) { /* Fix for XFree86 bug #156 */ - for (host = selfhosts; host; host = host->next) { - if (addrEqual (family, addr, len, host)) { - host->requested = TRUE; - break; - } - } - } - MakeHost(host,len) - if (!host) - return FALSE; - host->family = family; - host->len = len; - acopy(addr, host->addr, len); - host->next = validhosts; - validhosts = host; - return TRUE; -} - -/* Remove a host from the access control list */ - -int -RemoveHost ( - ClientPtr client, - int family, - unsigned length, /* of bytes in pAddr */ - pointer pAddr) -{ - int rc, len; - register HOST *host, **prev; - - rc = AuthorizedClient(client); - if (rc != Success) - return rc; - switch (family) { - case FamilyLocalHost: - len = length; - LocalHostEnabled = FALSE; - break; -#ifdef SECURE_RPC - case FamilyNetname: - len = length; - break; -#endif - case FamilyInternet: -#if defined(IPv6) && defined(AF_INET6) - case FamilyInternet6: -#endif - case FamilyDECnet: - case FamilyChaos: - case FamilyServerInterpreted: - if ((len = CheckAddr (family, pAddr, length)) < 0) - { - client->errorValue = length; - return BadValue; - } - break; - case FamilyLocal: - default: - client->errorValue = family; - return BadValue; - } - for (prev = &validhosts; - (host = *prev) && (!addrEqual (family, pAddr, len, host)); - prev = &host->next) - ; - if (host) - { - *prev = host->next; - FreeHost (host); - } - return Success; -} - -/* Get all hosts in the access control list */ -int -GetHosts ( - pointer *data, - int *pnHosts, - int *pLen, - BOOL *pEnabled) -{ - int len; - register int n = 0; - register unsigned char *ptr; - register HOST *host; - int nHosts = 0; - - *pEnabled = AccessEnabled ? EnableAccess : DisableAccess; - for (host = validhosts; host; host = host->next) - { - nHosts++; - n += pad_to_int32(host->len) + sizeof(xHostEntry); - } - if (n) - { - *data = ptr = malloc(n); - if (!ptr) - { - return BadAlloc; - } - for (host = validhosts; host; host = host->next) - { - len = host->len; - ((xHostEntry *)ptr)->family = host->family; - ((xHostEntry *)ptr)->length = len; - ptr += sizeof(xHostEntry); - acopy (host->addr, ptr, len); - ptr += pad_to_int32(len); - } - } else { - *data = NULL; - } - *pnHosts = nHosts; - *pLen = n; - return Success; -} - -/* Check for valid address family and length, and return address length. */ - -/*ARGSUSED*/ -static int -CheckAddr ( - int family, - const void * pAddr, - unsigned length) -{ - int len; - - switch (family) - { -#if defined(TCPCONN) || defined(STREAMSCONN) - case FamilyInternet: - if (length == sizeof (struct in_addr)) - len = length; - else - len = -1; - break; -#if defined(IPv6) && defined(AF_INET6) - case FamilyInternet6: - if (length == sizeof (struct in6_addr)) - len = length; - else - len = -1; - break; -#endif -#endif - case FamilyServerInterpreted: - len = siCheckAddr(pAddr, length); - break; - default: - len = -1; - } - return len; -} - -/* Check if a host is not in the access control list. - * Returns 1 if host is invalid, 0 if we've found it. */ - -int -InvalidHost ( - register struct sockaddr *saddr, - int len, - ClientPtr client) -{ - int family; - pointer addr; - register HOST *selfhost, *host; - - if (!AccessEnabled) /* just let them in */ - return 0; - family = ConvertAddr (saddr, &len, (pointer *)&addr); - if (family == -1) - return 1; - if (family == FamilyLocal) - { - if (!LocalHostEnabled) - { - /* - * check to see if any local address is enabled. This - * implicitly enables local connections. - */ - for (selfhost = selfhosts; selfhost; selfhost=selfhost->next) - { - for (host = validhosts; host; host=host->next) - { - if (addrEqual (selfhost->family, selfhost->addr, - selfhost->len, host)) - return 0; - } - } - } else - return 0; - } - for (host = validhosts; host; host = host->next) - { - if ((host->family == FamilyServerInterpreted)) { - if (siAddrMatch (family, addr, len, host, client)) { - return 0; - } - } else { - if (addrEqual (family, addr, len, host)) - return 0; - } - - } - return 1; -} - -static int -ConvertAddr ( - register struct sockaddr *saddr, - int *len, - pointer *addr) -{ - if (*len == 0) - return FamilyLocal; - switch (saddr->sa_family) - { - case AF_UNSPEC: -#if defined(UNIXCONN) || defined(LOCALCONN) - case AF_UNIX: -#endif - return FamilyLocal; -#if defined(TCPCONN) || defined(STREAMSCONN) - case AF_INET: -#ifdef WIN32 - if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr) - return FamilyLocal; -#endif - *len = sizeof (struct in_addr); - *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr); - return FamilyInternet; -#if defined(IPv6) && defined(AF_INET6) - case AF_INET6: - { - struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr; - if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) { - *len = sizeof (struct in_addr); - *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]); - return FamilyInternet; - } else { - *len = sizeof (struct in6_addr); - *addr = (pointer) &(saddr6->sin6_addr); - return FamilyInternet6; - } - } -#endif -#endif - default: - return -1; - } -} - -int -ChangeAccessControl( - ClientPtr client, - int fEnabled) -{ - int rc = AuthorizedClient(client); - if (rc != Success) - return rc; - AccessEnabled = fEnabled; - return Success; -} - -/* returns FALSE if xhost + in effect, else TRUE */ -int -GetAccessControl(void) -{ - return AccessEnabled; -} - -/***************************************************************************** - * FamilyServerInterpreted host entry implementation - * - * Supports an extensible system of host types which the server can interpret - * See the IPv6 extensions to the X11 protocol spec for the definition. - * - * Currently supported schemes: - * - * hostname - hostname as defined in IETF RFC 2396 - * ipv6 - IPv6 literal address as defined in IETF RFC's 3513 and - * - * See xc/doc/specs/SIAddresses for formal definitions of each type. - */ - -/* These definitions and the siTypeAdd function could be exported in the - * future to enable loading additional host types, but that was not done for - * the initial implementation. - */ -typedef Bool (*siAddrMatchFunc)(int family, pointer addr, int len, - const char *siAddr, int siAddrlen, ClientPtr client, void *siTypePriv); -typedef int (*siCheckAddrFunc)(const char *addrString, int length, - void *siTypePriv); - -struct siType { - struct siType * next; - const char * typeName; - siAddrMatchFunc addrMatch; - siCheckAddrFunc checkAddr; - void * typePriv; /* Private data for type routines */ -}; - -static struct siType *siTypeList; - -static int -siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch, - siCheckAddrFunc checkAddr, void *typePriv) -{ - struct siType *s, *p; - - if ((typeName == NULL) || (addrMatch == NULL) || (checkAddr == NULL)) - return BadValue; - - for (s = siTypeList, p = NULL; s != NULL ; p = s, s = s->next) { - if (strcmp(typeName, s->typeName) == 0) { - s->addrMatch = addrMatch; - s->checkAddr = checkAddr; - s->typePriv = typePriv; - return Success; - } - } - - s = malloc(sizeof(struct siType)); - if (s == NULL) - return BadAlloc; - - if (p == NULL) - siTypeList = s; - else - p->next = s; - - s->next = NULL; - s->typeName = typeName; - s->addrMatch = addrMatch; - s->checkAddr = checkAddr; - s->typePriv = typePriv; - return Success; -} - -/* Checks to see if a host matches a server-interpreted host entry */ -static Bool -siAddrMatch(int family, pointer addr, int len, HOST *host, ClientPtr client) -{ - Bool matches = FALSE; - struct siType *s; - const char *valueString; - int addrlen; - - valueString = (const char *) memchr(host->addr, '\0', host->len); - if (valueString != NULL) { - for (s = siTypeList; s != NULL ; s = s->next) { - if (strcmp((char *) host->addr, s->typeName) == 0) { - addrlen = host->len - (strlen((char *)host->addr) + 1); - matches = s->addrMatch(family, addr, len, - valueString + 1, addrlen, client, s->typePriv); - break; - } - } -#ifdef FAMILY_SI_DEBUG - ErrorF( - "Xserver: siAddrMatch(): type = %s, value = %*.*s -- %s\n", - host->addr, addrlen, addrlen, valueString + 1, - (matches) ? "accepted" : "rejected"); -#endif - } - return matches; -} - -static int -siCheckAddr(const char *addrString, int length) -{ - const char *valueString; - int addrlen, typelen; - int len = -1; - struct siType *s; - - /* Make sure there is a \0 byte inside the specified length - to separate the address type from the address value. */ - valueString = (const char *) memchr(addrString, '\0', length); - if (valueString != NULL) { - /* Make sure the first string is a recognized address type, - * and the second string is a valid address of that type. - */ - typelen = strlen(addrString) + 1; - addrlen = length - typelen; - - for (s = siTypeList; s != NULL ; s = s->next) { - if (strcmp(addrString, s->typeName) == 0) { - len = s->checkAddr(valueString + 1, addrlen, s->typePriv); - if (len >= 0) { - len += typelen; - } - break; - } - } -#ifdef FAMILY_SI_DEBUG - { - const char *resultMsg; - - if (s == NULL) { - resultMsg = "type not registered"; - } else { - if (len == -1) - resultMsg = "rejected"; - else - resultMsg = "accepted"; - } - - ErrorF("Xserver: siCheckAddr(): type = %s, value = %*.*s, len = %d -- %s\n", - addrString, addrlen, addrlen, valueString + 1, len, resultMsg); - } -#endif - } - return len; -} - - -/*** - * Hostname server-interpreted host type - * - * Stored as hostname string, explicitly defined to be resolved ONLY - * at access check time, to allow for hosts with dynamic addresses - * but static hostnames, such as found in some DHCP & mobile setups. - * - * Hostname must conform to IETF RFC 2396 sec. 3.2.2, which defines it as: - * hostname = *( domainlabel "." ) toplabel [ "." ] - * domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum - * toplabel = alpha | alpha *( alphanum | "-" ) alphanum - */ - -#ifdef NI_MAXHOST -# define SI_HOSTNAME_MAXLEN NI_MAXHOST -#else -# ifdef MAXHOSTNAMELEN -# define SI_HOSTNAME_MAXLEN MAXHOSTNAMELEN -# else -# define SI_HOSTNAME_MAXLEN 256 -# endif -#endif - -static Bool -siHostnameAddrMatch(int family, pointer addr, int len, - const char *siAddr, int siAddrLen, ClientPtr client, void *typePriv) -{ - Bool res = FALSE; - -/* Currently only supports checking against IPv4 & IPv6 connections, but - * support for other address families, such as DECnet, could be added if - * desired. - */ -#if defined(IPv6) && defined(AF_INET6) - if ((family == FamilyInternet) || (family == FamilyInternet6)) { - char hostname[SI_HOSTNAME_MAXLEN]; - struct addrinfo *addresses; - struct addrinfo *a; - int f, hostaddrlen; - pointer hostaddr; - - if (siAddrLen >= sizeof(hostname)) - return FALSE; - - strncpy(hostname, siAddr, siAddrLen); - hostname[siAddrLen] = '\0'; - - if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) { - for (a = addresses ; a != NULL ; a = a->ai_next) { - hostaddrlen = a->ai_addrlen; - f = ConvertAddr(a->ai_addr,&hostaddrlen,&hostaddr); - if ((f == family) && (len == hostaddrlen) && - (acmp (addr, hostaddr, len) == 0) ) { - res = TRUE; - break; - } - } - freeaddrinfo(addresses); - } - } -#else /* IPv6 not supported, use gethostbyname instead for IPv4 */ - if (family == FamilyInternet) { - register struct hostent *hp; -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgethostbynameparams hparams; -#endif - char hostname[SI_HOSTNAME_MAXLEN]; - int f, hostaddrlen; - pointer hostaddr; - const char **addrlist; - - if (siAddrLen >= sizeof(hostname)) - return FALSE; - - strncpy(hostname, siAddr, siAddrLen); - hostname[siAddrLen] = '\0'; - - if ((hp = _XGethostbyname(hostname, hparams)) != NULL) { -#ifdef h_addr /* new 4.3bsd version of gethostent */ - /* iterate over the addresses */ - for (addrlist = hp->h_addr_list; *addrlist; addrlist++) -#else - addrlist = &hp->h_addr; -#endif - { - struct sockaddr_in sin; - - sin.sin_family = hp->h_addrtype; - acopy ( *addrlist, &(sin.sin_addr), hp->h_length); - hostaddrlen = sizeof(sin); - f = ConvertAddr ((struct sockaddr *)&sin, - &hostaddrlen, &hostaddr); - if ((f == family) && (len == hostaddrlen) && - (acmp (addr, hostaddr, len) == 0) ) { - res = TRUE; - break; - } - } - } - } -#endif - return res; -} - - -static int -siHostnameCheckAddr(const char *valueString, int length, void *typePriv) -{ - /* Check conformance of hostname to RFC 2396 sec. 3.2.2 definition. - * We do not use ctype functions here to avoid locale-specific - * character sets. Hostnames must be pure ASCII. - */ - int len = length; - int i; - Bool dotAllowed = FALSE; - Bool dashAllowed = FALSE; - - if ((length <= 0) || (length >= SI_HOSTNAME_MAXLEN)) { - len = -1; - } else { - for (i = 0; i < length; i++) { - char c = valueString[i]; - - if (c == 0x2E) { /* '.' */ - if (dotAllowed == FALSE) { - len = -1; - break; - } else { - dotAllowed = FALSE; - dashAllowed = FALSE; - } - } else if (c == 0x2D) { /* '-' */ - if (dashAllowed == FALSE) { - len = -1; - break; - } else { - dotAllowed = FALSE; - } - } else if (((c >= 0x30) && (c <= 0x3A)) /* 0-9 */ || - ((c >= 0x61) && (c <= 0x7A)) /* a-z */ || - ((c >= 0x41) && (c <= 0x5A)) /* A-Z */) { - dotAllowed = TRUE; - dashAllowed = TRUE; - } else { /* Invalid character */ - len = -1; - break; - } - } - } - return len; -} - -#if defined(IPv6) && defined(AF_INET6) -/*** - * "ipv6" server interpreted type - * - * Currently supports only IPv6 literal address as specified in IETF RFC 3513 - * - * Once draft-ietf-ipv6-scoping-arch-00.txt becomes an RFC, support will be - * added for the scoped address format it specifies. - */ - -/* Maximum length of an IPv6 address string - increase when adding support - * for scoped address qualifiers. Includes room for trailing NUL byte. - */ -#define SI_IPv6_MAXLEN INET6_ADDRSTRLEN - -static Bool -siIPv6AddrMatch(int family, pointer addr, int len, - const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv) -{ - struct in6_addr addr6; - char addrbuf[SI_IPv6_MAXLEN]; - - if ((family != FamilyInternet6) || (len != sizeof(addr6))) - return FALSE; - - memcpy(addrbuf, siAddr, siAddrlen); - addrbuf[siAddrlen] = '\0'; - - if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) { - perror("inet_pton"); - return FALSE; - } - - if (memcmp(addr, &addr6, len) == 0) { - return TRUE; - } else { - return FALSE; - } -} - -static int -siIPv6CheckAddr(const char *addrString, int length, void *typePriv) -{ - int len; - - /* Minimum length is 3 (smallest legal address is "::1") */ - if (length < 3) { - /* Address is too short! */ - len = -1; - } else if (length >= SI_IPv6_MAXLEN) { - /* Address is too long! */ - len = -1; - } else { - /* Assume inet_pton is sufficient validation */ - struct in6_addr addr6; - char addrbuf[SI_IPv6_MAXLEN]; - - memcpy(addrbuf, addrString, length); - addrbuf[length] = '\0'; - - if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) { - perror("inet_pton"); - len = -1; - } else { - len = length; - } - } - return len; -} -#endif /* IPv6 */ - -#if !defined(NO_LOCAL_CLIENT_CRED) -/*** - * "localuser" & "localgroup" server interpreted types - * - * Allows local connections from a given local user or group - */ - -#include -#include - -#define LOCAL_USER 1 -#define LOCAL_GROUP 2 - -typedef struct { - int credType; -} siLocalCredPrivRec, *siLocalCredPrivPtr; - -static siLocalCredPrivRec siLocalUserPriv = { LOCAL_USER }; -static siLocalCredPrivRec siLocalGroupPriv = { LOCAL_GROUP }; - -static Bool -siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id) -{ - Bool parsedOK = FALSE; - char *addrbuf = malloc(len + 1); - - if (addrbuf == NULL) { - return FALSE; - } - - memcpy(addrbuf, addr, len); - addrbuf[len] = '\0'; - - if (addr[0] == '#') { /* numeric id */ - char *cp; - errno = 0; - *id = strtol(addrbuf + 1, &cp, 0); - if ((errno == 0) && (cp != (addrbuf+1))) { - parsedOK = TRUE; - } - } else { /* non-numeric name */ - if (lcPriv->credType == LOCAL_USER) { - struct passwd *pw = getpwnam(addrbuf); - - if (pw != NULL) { - *id = (int) pw->pw_uid; - parsedOK = TRUE; - } - } else { /* group */ - struct group *gr = getgrnam(addrbuf); - - if (gr != NULL) { - *id = (int) gr->gr_gid; - parsedOK = TRUE; - } - } - } - - free(addrbuf); - return parsedOK; -} - -static Bool -siLocalCredAddrMatch(int family, pointer addr, int len, - const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv) -{ - int siAddrId; - LocalClientCredRec *lcc; - siLocalCredPrivPtr lcPriv = (siLocalCredPrivPtr) typePriv; - - if (GetLocalClientCreds(client, &lcc) == -1) { - return FALSE; - } - -#ifdef HAVE_GETZONEID /* Ensure process is in the same zone */ - if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) { - FreeLocalClientCreds(lcc); - return FALSE; - } -#endif - - if (siLocalCredGetId(siAddr, siAddrlen, lcPriv, &siAddrId) == FALSE) { - FreeLocalClientCreds(lcc); - return FALSE; - } - - if (lcPriv->credType == LOCAL_USER) { - if ((lcc->fieldsSet & LCC_UID_SET) && (lcc->euid == siAddrId)) { - FreeLocalClientCreds(lcc); - return TRUE; - } - } else { - if ((lcc->fieldsSet & LCC_GID_SET) && (lcc->egid == siAddrId)) { - FreeLocalClientCreds(lcc); - return TRUE; - } - if (lcc->pSuppGids != NULL) { - int i; - - for (i = 0 ; i < lcc->nSuppGids; i++) { - if (lcc->pSuppGids[i] == siAddrId) { - FreeLocalClientCreds(lcc); - return TRUE; - } - } - } - } - FreeLocalClientCreds(lcc); - return FALSE; -} - -static int -siLocalCredCheckAddr(const char *addrString, int length, void *typePriv) -{ - int len = length; - int id; - - if (siLocalCredGetId(addrString, length, - (siLocalCredPrivPtr)typePriv, &id) == FALSE) { - len = -1; - } - return len; -} -#endif /* localuser */ - -static void -siTypesInitialize(void) -{ - siTypeAdd("hostname", siHostnameAddrMatch, siHostnameCheckAddr, NULL); -#if defined(IPv6) && defined(AF_INET6) - siTypeAdd("ipv6", siIPv6AddrMatch, siIPv6CheckAddr, NULL); -#endif -#if !defined(NO_LOCAL_CLIENT_CRED) - siTypeAdd("localuser", siLocalCredAddrMatch, siLocalCredCheckAddr, - &siLocalUserPriv); - siTypeAdd("localgroup", siLocalCredAddrMatch, siLocalCredCheckAddr, - &siLocalGroupPriv); -#endif -} +/*********************************************************** + +Copyright 1987, 1998 The Open Group + +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, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +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 +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL +INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING +FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +X Window System is a trademark of The Open Group. + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +/* + * Copyright (c) 2004, Oracle and/or its affiliates. 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 +#endif + +#ifdef WIN32 +#include +#endif + +#include +#include +#define XSERV_t +#define TRANS_SERVER +#define TRANS_REOPEN +#include +#include +#include +#include +#include "misc.h" +#include "site.h" +#include +#include +#ifndef WIN32 +#include +#include +#include + +#if defined(TCPCONN) || defined(STREAMSCONN) +#include +#endif /* TCPCONN || STREAMSCONN */ + +#ifdef HAS_GETPEERUCRED +# include +# ifdef sun +# include +# endif +#endif + +#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__) +# include +#endif +#if defined(SYSV) && defined(__i386__) +# include +#endif +#ifdef __GNU__ +#undef SIOCGIFCONF +#include +#else /*!__GNU__*/ +# include +#endif /*__GNU__ */ + +#ifdef SVR4 +#include +#include +#endif + +#include + +#ifdef CSRG_BASED +#include +#if (BSD >= 199103) +#define VARIABLE_IFREQ +#endif +#endif + +#ifdef BSD44SOCKETS +#ifndef VARIABLE_IFREQ +#define VARIABLE_IFREQ +#endif +#endif + +#ifdef HAS_GETIFADDRS +#include +#endif + +/* Solaris provides an extended interface SIOCGLIFCONF. Other systems + * may have this as well, but the code has only been tested on Solaris + * so far, so we only enable it there. Other platforms may be added as + * needed. + * + * Test for Solaris commented out -- TSI @ UQV 2003.06.13 + */ +#ifdef SIOCGLIFCONF +/* #if defined(sun) */ +#define USE_SIOCGLIFCONF +/* #endif */ +#endif + +#endif /* WIN32 */ + +#ifndef PATH_MAX +#include +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else +#define PATH_MAX 1024 +#endif +#endif +#endif + + +#define X_INCLUDE_NETDB_H +#include + +#include "dixstruct.h" +#include "osdep.h" + +#include "xace.h" + +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else +#define PATH_MAX 1024 +#endif +#endif + +Bool defeatAccessControl = FALSE; + +#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len) +#define acopy(a1, a2, len) memmove((char *)(a2), (char *)(a1), len) +#define addrEqual(fam, address, length, host) \ + ((fam) == (host)->family &&\ + (length) == (host)->len &&\ + !acmp (address, (host)->addr, length)) + +static int ConvertAddr(struct sockaddr * /*saddr*/, + int * /*len*/, + pointer * /*addr*/); + +static int CheckAddr(int /*family*/, + const void * /*pAddr*/, + unsigned /*length*/); + +static Bool NewHost(int /*family*/, + const void * /*addr*/, + int /*len*/, + int /* addingLocalHosts */); + +/* XFree86 bug #156: To keep track of which hosts were explicitly requested in + /etc/X.hosts, we've added a requested field to the HOST struct, + and a LocalHostRequested variable. These default to FALSE, but are set + to TRUE in ResetHosts when reading in /etc/X.hosts. They are + checked in DisableLocalHost(), which is called to disable the default + local host entries when stronger authentication is turned on. */ + +typedef struct _host { + short family; + short len; + unsigned char *addr; + struct _host *next; + int requested; +} HOST; + +#define MakeHost(h,l) (h)=malloc(sizeof *(h)+(l));\ + if (h) { \ + (h)->addr=(unsigned char *) ((h) + 1);\ + (h)->requested = FALSE; \ + } +#define FreeHost(h) free(h) +static HOST *selfhosts = NULL; +static HOST *validhosts = NULL; +static int AccessEnabled = DEFAULT_ACCESS_CONTROL; +static int LocalHostEnabled = FALSE; +static int LocalHostRequested = FALSE; +static int UsingXdmcp = FALSE; + +/* FamilyServerInterpreted implementation */ +static Bool siAddrMatch(int family, pointer addr, int len, HOST *host, + ClientPtr client); +static int siCheckAddr(const char *addrString, int length); +static void siTypesInitialize(void); + +/* + * called when authorization is not enabled to add the + * local host to the access list + */ + +void +EnableLocalHost (void) +{ + if (!UsingXdmcp) + { + LocalHostEnabled = TRUE; + AddLocalHosts (); + } +} + +/* + * called when authorization is enabled to keep us secure + */ +void +DisableLocalHost (void) +{ + HOST *self; + + if (!LocalHostRequested) /* Fix for XFree86 bug #156 */ + LocalHostEnabled = FALSE; + for (self = selfhosts; self; self = self->next) { + if (!self->requested) /* Fix for XFree86 bug #156 */ + (void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr); + } +} + +/* + * called at init time when XDMCP will be used; xdmcp always + * adds local hosts manually when needed + */ + +void +AccessUsingXdmcp (void) +{ + UsingXdmcp = TRUE; + LocalHostEnabled = FALSE; +} + + +#if defined(SVR4) && !defined(sun) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF) + +/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */ + +static int +ifioctl (int fd, int cmd, char *arg) +{ + struct strioctl ioc; + int ret; + + memset((char *) &ioc, 0, sizeof(ioc)); + ioc.ic_cmd = cmd; + ioc.ic_timout = 0; + if (cmd == SIOCGIFCONF) + { + ioc.ic_len = ((struct ifconf *) arg)->ifc_len; + ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf; + } + else + { + ioc.ic_len = sizeof(struct ifreq); + ioc.ic_dp = arg; + } + ret = ioctl(fd, I_STR, (char *) &ioc); + if (ret >= 0 && cmd == SIOCGIFCONF) +#ifdef SVR4 + ((struct ifconf *) arg)->ifc_len = ioc.ic_len; +#endif + return ret; +} +#else +#define ifioctl ioctl +#endif + +/* + * DefineSelf (fd): + * + * Define this host for access control. Find all the hosts the OS knows about + * for this fd and add them to the selfhosts list. + */ + +#if !defined(SIOCGIFCONF) +void +DefineSelf (int fd) +{ +#if !defined(TCPCONN) && !defined(STREAMSCONN) && !defined(UNIXCONN) + return; +#else + register int n; + int len; + caddr_t addr; + int family; + register HOST *host; + +#ifndef WIN32 + struct utsname name; +#else + struct { + char nodename[512]; + } name; +#endif + + register struct hostent *hp; + + union { + struct sockaddr sa; + struct sockaddr_in in; +#if defined(IPv6) && defined(AF_INET6) + struct sockaddr_in6 in6; +#endif + } saddr; + + struct sockaddr_in *inetaddr; + struct sockaddr_in6 *inet6addr; + struct sockaddr_in broad_addr; +#ifdef XTHREADS_NEEDS_BYNAMEPARAMS + _Xgethostbynameparams hparams; +#endif + + /* Why not use gethostname()? Well, at least on my system, I've had to + * make an ugly kernel patch to get a name longer than 8 characters, and + * uname() lets me access to the whole string (it smashes release, you + * see), whereas gethostname() kindly truncates it for me. + */ +#ifndef WIN32 + uname(&name); +#else + gethostname(name.nodename, sizeof(name.nodename)); +#endif + + hp = _XGethostbyname(name.nodename, hparams); + if (hp != NULL) + { + saddr.sa.sa_family = hp->h_addrtype; + switch (hp->h_addrtype) { + case AF_INET: + inetaddr = (struct sockaddr_in *) (&(saddr.sa)); + acopy ( hp->h_addr, &(inetaddr->sin_addr), hp->h_length); + len = sizeof(saddr.sa); + break; +#if defined(IPv6) && defined(AF_INET6) + case AF_INET6: + inet6addr = (struct sockaddr_in6 *) (&(saddr.sa)); + acopy ( hp->h_addr, &(inet6addr->sin6_addr), hp->h_length); + len = sizeof(saddr.in6); + break; +#endif + default: + goto DefineLocalHost; + } + family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr); + if ( family != -1 && family != FamilyLocal ) + { + for (host = selfhosts; + host && !addrEqual (family, addr, len, host); + host = host->next) ; + if (!host) + { + /* add this host to the host list. */ + MakeHost(host,len) + if (host) + { + host->family = family; + host->len = len; + acopy ( addr, host->addr, len); + host->next = selfhosts; + selfhosts = host; + } +#ifdef XDMCP + /* + * If this is an Internet Address, but not the localhost + * address (127.0.0.1), nor the bogus address (0.0.0.0), + * register it. + */ + if (family == FamilyInternet && + !(len == 4 && + ((addr[0] == 127) || + (addr[0] == 0 && addr[1] == 0 && + addr[2] == 0 && addr[3] == 0))) + ) + { + XdmcpRegisterConnection (family, (char *)addr, len); + broad_addr = *inetaddr; + ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr = + htonl (INADDR_BROADCAST); + XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) + &broad_addr); + } +#if defined(IPv6) && defined(AF_INET6) + else if (family == FamilyInternet6 && + !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))) + { + XdmcpRegisterConnection (family, (char *)addr, len); + } +#endif + +#endif /* XDMCP */ + } + } + } + /* + * now add a host of family FamilyLocalHost... + */ +DefineLocalHost: + for (host = selfhosts; + host && !addrEqual(FamilyLocalHost, "", 0, host); + host = host->next); + if (!host) + { + MakeHost(host, 0); + if (host) + { + host->family = FamilyLocalHost; + host->len = 0; + acopy("", host->addr, 0); + host->next = selfhosts; + selfhosts = host; + } + } +#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN */ +} + +#else + +#ifdef USE_SIOCGLIFCONF +#define ifr_type struct lifreq +#else +#define ifr_type struct ifreq +#endif + +#ifdef VARIABLE_IFREQ +#define ifr_size(p) (sizeof (struct ifreq) + \ + (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \ + p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0)) +#define ifraddr_size(a) (a.sa_len) +#else +#define ifr_size(p) (sizeof (ifr_type)) +#define ifraddr_size(a) (sizeof (a)) +#endif + +#if defined(IPv6) && defined(AF_INET6) +#include +#endif + +#if defined(IPv6) && defined(AF_INET6) +static void +in6_fillscopeid(struct sockaddr_in6 *sin6) +{ +#if defined(__KAME__) + if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { + sin6->sin6_scope_id = + ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]); + sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0; + } +#endif +} +#endif + +void +DefineSelf (int fd) +{ +#ifndef HAS_GETIFADDRS + char *cp, *cplim; +# ifdef USE_SIOCGLIFCONF + struct sockaddr_storage buf[16]; + struct lifconf ifc; + register struct lifreq *ifr; +# ifdef SIOCGLIFNUM + struct lifnum ifn; +# endif +# else /* !USE_SIOCGLIFCONF */ + char buf[2048]; + struct ifconf ifc; + register struct ifreq *ifr; +# endif + void * bufptr = buf; +#else /* HAS_GETIFADDRS */ + struct ifaddrs * ifap, *ifr; +#endif + int len; + unsigned char * addr; + int family; + register HOST *host; + +#ifndef HAS_GETIFADDRS + + len = sizeof(buf); + +#ifdef USE_SIOCGLIFCONF + +#ifdef SIOCGLIFNUM + ifn.lifn_family = AF_UNSPEC; + ifn.lifn_flags = 0; + if (ioctl (fd, SIOCGLIFNUM, (char *) &ifn) < 0) + Error ("Getting interface count"); + if (len < (ifn.lifn_count * sizeof(struct lifreq))) { + len = ifn.lifn_count * sizeof(struct lifreq); + bufptr = malloc(len); + } +#endif + + ifc.lifc_family = AF_UNSPEC; + ifc.lifc_flags = 0; + ifc.lifc_len = len; + ifc.lifc_buf = bufptr; + +#define IFC_IOCTL_REQ SIOCGLIFCONF +#define IFC_IFC_REQ ifc.lifc_req +#define IFC_IFC_LEN ifc.lifc_len +#define IFR_IFR_ADDR ifr->lifr_addr +#define IFR_IFR_NAME ifr->lifr_name + +#else /* Use SIOCGIFCONF */ + ifc.ifc_len = len; + ifc.ifc_buf = bufptr; + +#define IFC_IOCTL_REQ SIOCGIFCONF +#define IFC_IFC_REQ ifc.ifc_req +#define IFC_IFC_LEN ifc.ifc_len +#define IFR_IFR_ADDR ifr->ifr_addr +#define IFR_IFR_NAME ifr->ifr_name +#endif + + if (ifioctl (fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0) + Error ("Getting interface configuration (4)"); + + cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN; + + for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr)) + { + ifr = (ifr_type *) cp; + len = ifraddr_size (IFR_IFR_ADDR); + family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR, + &len, (pointer *)&addr); + if (family == -1 || family == FamilyLocal) + continue; +#if defined(IPv6) && defined(AF_INET6) + if (family == FamilyInternet6) + in6_fillscopeid((struct sockaddr_in6 *)&IFR_IFR_ADDR); +#endif + for (host = selfhosts; + host && !addrEqual (family, addr, len, host); + host = host->next) + ; + if (host) + continue; + MakeHost(host,len) + if (host) + { + host->family = family; + host->len = len; + acopy(addr, host->addr, len); + host->next = selfhosts; + selfhosts = host; + } +#ifdef XDMCP + { +#ifdef USE_SIOCGLIFCONF + struct sockaddr_storage broad_addr; +#else + struct sockaddr broad_addr; +#endif + + /* + * If this isn't an Internet Address, don't register it. + */ + if (family != FamilyInternet +#if defined(IPv6) && defined(AF_INET6) + && family != FamilyInternet6 +#endif + ) + continue; + + /* + * ignore 'localhost' entries as they're not useful + * on the other end of the wire + */ + if (family == FamilyInternet && + addr[0] == 127 && addr[1] == 0 && + addr[2] == 0 && addr[3] == 1) + continue; +#if defined(IPv6) && defined(AF_INET6) + else if (family == FamilyInternet6 && + IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)) + continue; +#endif + + /* + * Ignore '0.0.0.0' entries as they are + * returned by some OSes for unconfigured NICs but they are + * not useful on the other end of the wire. + */ + if (len == 4 && + addr[0] == 0 && addr[1] == 0 && + addr[2] == 0 && addr[3] == 0) + continue; + + XdmcpRegisterConnection (family, (char *)addr, len); + +#if defined(IPv6) && defined(AF_INET6) + /* IPv6 doesn't support broadcasting, so we drop out here */ + if (family == FamilyInternet6) + continue; +#endif + + broad_addr = IFR_IFR_ADDR; + + ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr = + htonl (INADDR_BROADCAST); +#if defined(USE_SIOCGLIFCONF) && defined(SIOCGLIFBRDADDR) + { + struct lifreq broad_req; + + broad_req = *ifr; + if (ioctl (fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 && + (broad_req.lifr_flags & IFF_BROADCAST) && + (broad_req.lifr_flags & IFF_UP) + ) + { + broad_req = *ifr; + if (ioctl (fd, SIOCGLIFBRDADDR, &broad_req) != -1) + broad_addr = broad_req.lifr_broadaddr; + else + continue; + } + else + continue; + } + +#elif defined(SIOCGIFBRDADDR) + { + struct ifreq broad_req; + + broad_req = *ifr; + if (ifioctl (fd, SIOCGIFFLAGS, (pointer) &broad_req) != -1 && + (broad_req.ifr_flags & IFF_BROADCAST) && + (broad_req.ifr_flags & IFF_UP) + ) + { + broad_req = *ifr; + if (ifioctl (fd, SIOCGIFBRDADDR, (pointer) &broad_req) != -1) + broad_addr = broad_req.ifr_addr; + else + continue; + } + else + continue; + } +#endif /* SIOCGIFBRDADDR */ + XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr); + } +#endif /* XDMCP */ + } + if (bufptr != buf) + free(bufptr); +#else /* HAS_GETIFADDRS */ + if (getifaddrs(&ifap) < 0) { + ErrorF("Warning: getifaddrs returns %s\n", strerror(errno)); + return; + } + for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) { + if (!ifr->ifa_addr) + continue; + len = sizeof(*(ifr->ifa_addr)); + family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len, + (pointer *)&addr); + if (family == -1 || family == FamilyLocal) + continue; +#if defined(IPv6) && defined(AF_INET6) + if (family == FamilyInternet6) + in6_fillscopeid((struct sockaddr_in6 *)ifr->ifa_addr); +#endif + + for (host = selfhosts; + host != NULL && !addrEqual(family, addr, len, host); + host = host->next) + ; + if (host != NULL) + continue; + MakeHost(host, len); + if (host != NULL) { + host->family = family; + host->len = len; + acopy(addr, host->addr, len); + host->next = selfhosts; + selfhosts = host; + } +#ifdef XDMCP + { + /* + * If this isn't an Internet Address, don't register it. + */ + if (family != FamilyInternet +#if defined(IPv6) && defined(AF_INET6) + && family != FamilyInternet6 +#endif + ) + continue; + + /* + * ignore 'localhost' entries as they're not useful + * on the other end of the wire + */ + if (ifr->ifa_flags & IFF_LOOPBACK) + continue; + + if (family == FamilyInternet && + addr[0] == 127 && addr[1] == 0 && + addr[2] == 0 && addr[3] == 1) + continue; + + /* + * Ignore '0.0.0.0' entries as they are + * returned by some OSes for unconfigured NICs but they are + * not useful on the other end of the wire. + */ + if (len == 4 && + addr[0] == 0 && addr[1] == 0 && + addr[2] == 0 && addr[3] == 0) + continue; +#if defined(IPv6) && defined(AF_INET6) + else if (family == FamilyInternet6 && + IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)) + continue; +#endif + XdmcpRegisterConnection(family, (char *)addr, len); +#if defined(IPv6) && defined(AF_INET6) + if (family == FamilyInternet6) + /* IPv6 doesn't support broadcasting, so we drop out here */ + continue; +#endif + if ((ifr->ifa_flags & IFF_BROADCAST) && + (ifr->ifa_flags & IFF_UP) && + ifr->ifa_broadaddr) + XdmcpRegisterBroadcastAddress( + (struct sockaddr_in *) ifr->ifa_broadaddr); + else + continue; + } +#endif /* XDMCP */ + + } /* for */ + freeifaddrs(ifap); +#endif /* HAS_GETIFADDRS */ + + /* + * add something of FamilyLocalHost + */ + for (host = selfhosts; + host && !addrEqual(FamilyLocalHost, "", 0, host); + host = host->next); + if (!host) + { + MakeHost(host, 0); + if (host) + { + host->family = FamilyLocalHost; + host->len = 0; + acopy("", host->addr, 0); + host->next = selfhosts; + selfhosts = host; + } + } +} +#endif /* hpux && !HAS_IFREQ */ + +#ifdef XDMCP +void +AugmentSelf(pointer from, int len) +{ + int family; + pointer addr; + register HOST *host; + + family = ConvertAddr(from, &len, (pointer *)&addr); + if (family == -1 || family == FamilyLocal) + return; + for (host = selfhosts; host; host = host->next) + { + if (addrEqual(family, addr, len, host)) + return; + } + MakeHost(host,len) + if (!host) + return; + host->family = family; + host->len = len; + acopy(addr, host->addr, len); + host->next = selfhosts; + selfhosts = host; +} +#endif + +void +AddLocalHosts (void) +{ + HOST *self; + + for (self = selfhosts; self; self = self->next) + /* Fix for XFree86 bug #156: pass addingLocal = TRUE to + * NewHost to tell that we are adding the default local + * host entries and not to flag the entries as being + * explicitely requested */ + (void) NewHost (self->family, self->addr, self->len, TRUE); +} + +/* Reset access control list to initial hosts */ +void +ResetHosts (char *display) +{ + register HOST *host; + char lhostname[120], ohostname[120]; + char *hostname = ohostname; + char fname[PATH_MAX + 1]; + int fnamelen; + FILE *fd; + char *ptr; + int i, hostlen; +#if (defined(TCPCONN) || defined(STREAMSCONN) ) && \ + (!defined(IPv6) || !defined(AF_INET6)) + union { + struct sockaddr sa; +#if defined(TCPCONN) || defined(STREAMSCONN) + struct sockaddr_in in; +#endif /* TCPCONN || STREAMSCONN */ + } saddr; +#endif + int family = 0; + pointer addr; + int len; + + siTypesInitialize(); + AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL; + LocalHostEnabled = FALSE; + while ((host = validhosts) != 0) + { + validhosts = host->next; + FreeHost (host); + } + +#if defined WIN32 && defined __MINGW32__ +#define ETC_HOST_PREFIX "X" +#else +#define ETC_HOST_PREFIX "/etc/X" +#endif +#define ETC_HOST_SUFFIX ".hosts" + fnamelen = strlen(ETC_HOST_PREFIX) + strlen(ETC_HOST_SUFFIX) + + strlen(display) + 1; + if (fnamelen > sizeof(fname)) + FatalError("Display name `%s' is too long\n", display); + snprintf(fname, sizeof(fname), ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX, + display); + + if ((fd = fopen (fname, "r")) != 0) + { + while (fgets (ohostname, sizeof (ohostname), fd)) + { + family = FamilyWild; + if (*ohostname == '#') + continue; + if ((ptr = strchr(ohostname, '\n')) != 0) + *ptr = 0; + hostlen = strlen(ohostname) + 1; + for (i = 0; i < hostlen; i++) + lhostname[i] = tolower(ohostname[i]); + hostname = ohostname; + if (!strncmp("local:", lhostname, 6)) + { + family = FamilyLocalHost; + NewHost(family, "", 0, FALSE); + LocalHostRequested = TRUE; /* Fix for XFree86 bug #156 */ + } +#if defined(TCPCONN) || defined(STREAMSCONN) + else if (!strncmp("inet:", lhostname, 5)) + { + family = FamilyInternet; + hostname = ohostname + 5; + } +#if defined(IPv6) && defined(AF_INET6) + else if (!strncmp("inet6:", lhostname, 6)) + { + family = FamilyInternet6; + hostname = ohostname + 6; + } +#endif +#endif +#ifdef SECURE_RPC + else if (!strncmp("nis:", lhostname, 4)) + { + family = FamilyNetname; + hostname = ohostname + 4; + } +#endif + else if (!strncmp("si:", lhostname, 3)) + { + family = FamilyServerInterpreted; + hostname = ohostname + 3; + hostlen -= 3; + } + + + if (family == FamilyServerInterpreted) + { + len = siCheckAddr(hostname, hostlen); + if (len >= 0) { + NewHost(family, hostname, len, FALSE); + } + } + else +#ifdef SECURE_RPC + if ((family == FamilyNetname) || (strchr(hostname, '@'))) + { + SecureRPCInit (); + (void) NewHost (FamilyNetname, hostname, strlen (hostname), FALSE); + } + else +#endif /* SECURE_RPC */ +#if defined(TCPCONN) || defined(STREAMSCONN) + { +#if defined(IPv6) && defined(AF_INET6) + if ( (family == FamilyInternet) || (family == FamilyInternet6) || + (family == FamilyWild) ) + { + struct addrinfo *addresses; + struct addrinfo *a; + int f; + + if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) { + for (a = addresses ; a != NULL ; a = a->ai_next) { + len = a->ai_addrlen; + f = ConvertAddr(a->ai_addr,&len,(pointer *)&addr); + if ( (family == f) || + ((family == FamilyWild) && (f != -1)) ) { + NewHost(f, addr, len, FALSE); + } + } + freeaddrinfo(addresses); + } + } +#else +#ifdef XTHREADS_NEEDS_BYNAMEPARAMS + _Xgethostbynameparams hparams; +#endif + register struct hostent *hp; + + /* host name */ + if ((family == FamilyInternet && + ((hp = _XGethostbyname(hostname, hparams)) != 0)) || + ((hp = _XGethostbyname(hostname, hparams)) != 0)) + { + saddr.sa.sa_family = hp->h_addrtype; + len = sizeof(saddr.sa); + if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1) + { +#ifdef h_addr /* new 4.3bsd version of gethostent */ + char **list; + + /* iterate over the addresses */ + for (list = hp->h_addr_list; *list; list++) + (void) NewHost (family, (pointer)*list, len, FALSE); +#else + (void) NewHost (family, (pointer)hp->h_addr, len, FALSE); +#endif + } + } +#endif /* IPv6 */ + } +#endif /* TCPCONN || STREAMSCONN */ + family = FamilyWild; + } + fclose (fd); + } +} + +/* Is client on the local host */ +Bool +ComputeLocalClient(ClientPtr client) +{ + int alen, family, notused; + Xtransaddr *from = NULL; + pointer addr; + register HOST *host; + OsCommPtr oc = (OsCommPtr) client->osPrivate; + + if (!oc->trans_conn) + return FALSE; + + if (!_XSERVTransGetPeerAddr (oc->trans_conn, ¬used, &alen, &from)) + { + family = ConvertAddr ((struct sockaddr *) from, + &alen, (pointer *)&addr); + if (family == -1) + { + free(from); + return FALSE; + } + if (family == FamilyLocal) + { + free(from); + return TRUE; + } + for (host = selfhosts; host; host = host->next) + { + if (addrEqual (family, addr, alen, host)) { + free(from); + return TRUE; + } + } + free(from); + } + return FALSE; +} + +Bool LocalClient(ClientPtr client) +{ + if (!client->osPrivate) + return FALSE; + return ((OsCommPtr)client->osPrivate)->local_client; +} + +/* + * Return the uid and gid of a connected local client + * + * Used by XShm to test access rights to shared memory segments + */ +int +LocalClientCred(ClientPtr client, int *pUid, int *pGid) +{ + LocalClientCredRec *lcc; + int ret = GetLocalClientCreds(client, &lcc); + + if (ret == 0) { +#ifdef HAVE_GETZONEID /* only local if in the same zone */ + if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) { + FreeLocalClientCreds(lcc); + return -1; + } +#endif + if ((lcc->fieldsSet & LCC_UID_SET) && (pUid != NULL)) + *pUid = lcc->euid; + if ((lcc->fieldsSet & LCC_GID_SET) && (pGid != NULL)) + *pGid = lcc->egid; + FreeLocalClientCreds(lcc); + } + return ret; +} + +/* + * Return the uid and all gids of a connected local client + * Allocates a LocalClientCredRec - caller must call FreeLocalClientCreds + * + * Used by localuser & localgroup ServerInterpreted access control forms below + * Used by AuthAudit to log who local connections came from + */ +int +GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp) +{ +#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED) + int fd; + XtransConnInfo ci; + LocalClientCredRec *lcc; +#ifdef HAS_GETPEEREID + uid_t uid; + gid_t gid; +#elif defined(HAS_GETPEERUCRED) + ucred_t *peercred = NULL; + const gid_t *gids; +#elif defined(SO_PEERCRED) + struct ucred peercred; + socklen_t so_len = sizeof(peercred); +#endif + + if (client == NULL) + return -1; + ci = ((OsCommPtr)client->osPrivate)->trans_conn; +#if !(defined(sun) && defined(HAS_GETPEERUCRED)) + /* Most implementations can only determine peer credentials for Unix + * domain sockets - Solaris getpeerucred can work with a bit more, so + * we just let it tell us if the connection type is supported or not + */ + if (!_XSERVTransIsLocal(ci)) { + return -1; + } +#endif + + *lccp = calloc(1, sizeof(LocalClientCredRec)); + if (*lccp == NULL) + return -1; + lcc = *lccp; + + fd = _XSERVTransGetConnectionNumber(ci); +#ifdef HAS_GETPEEREID + if (getpeereid(fd, &uid, &gid) == -1) { + FreeLocalClientCreds(lcc); + return -1; + } + lcc->euid = uid; + lcc->egid = gid; + lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET; + return 0; +#elif defined(HAS_GETPEERUCRED) + if (getpeerucred(fd, &peercred) < 0) { + FreeLocalClientCreds(lcc); + return -1; + } + lcc->euid = ucred_geteuid(peercred); + if (lcc->euid != -1) + lcc->fieldsSet |= LCC_UID_SET; + lcc->egid = ucred_getegid(peercred); + if (lcc->egid != -1) + lcc->fieldsSet |= LCC_GID_SET; + lcc->pid = ucred_getpid(peercred); + if (lcc->pid != -1) + lcc->fieldsSet |= LCC_PID_SET; +#ifdef HAVE_GETZONEID + lcc->zoneid = ucred_getzoneid(peercred); + if (lcc->zoneid != -1) + lcc->fieldsSet |= LCC_ZID_SET; +#endif + lcc->nSuppGids = ucred_getgroups(peercred, &gids); + if (lcc->nSuppGids > 0) { + lcc->pSuppGids = calloc(lcc->nSuppGids, sizeof(int)); + if (lcc->pSuppGids == NULL) { + lcc->nSuppGids = 0; + } else { + int i; + for (i = 0 ; i < lcc->nSuppGids; i++) { + (lcc->pSuppGids)[i] = (int) gids[i]; + } + } + } else { + lcc->nSuppGids = 0; + } + ucred_free(peercred); + return 0; +#elif defined(SO_PEERCRED) + if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) == -1) { + FreeLocalClientCreds(lcc); + return -1; + } + lcc->euid = peercred.uid; + lcc->egid = peercred.gid; + lcc->pid = peercred.pid; + lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET | LCC_PID_SET; + return 0; +#endif +#else + /* No system call available to get the credentials of the peer */ +#define NO_LOCAL_CLIENT_CRED + return -1; +#endif +} + +void +FreeLocalClientCreds(LocalClientCredRec *lcc) +{ + if (lcc != NULL) { + if (lcc->nSuppGids > 0) { + free(lcc->pSuppGids); + } + free(lcc); + } +} + +static int +AuthorizedClient(ClientPtr client) +{ + int rc; + + if (!client || defeatAccessControl) + return Success; + + /* untrusted clients can't change host access */ + rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); + if (rc != Success) + return rc; + + return LocalClient(client) ? Success : BadAccess; +} + +/* Add a host to the access control list. This is the external interface + * called from the dispatcher */ + +int +AddHost (ClientPtr client, + int family, + unsigned length, /* of bytes in pAddr */ + const void * pAddr) +{ + int rc, len; + + rc = AuthorizedClient(client); + if (rc != Success) + return rc; + switch (family) { + case FamilyLocalHost: + len = length; + LocalHostEnabled = TRUE; + break; +#ifdef SECURE_RPC + case FamilyNetname: + len = length; + SecureRPCInit (); + break; +#endif + case FamilyInternet: +#if defined(IPv6) && defined(AF_INET6) + case FamilyInternet6: +#endif + case FamilyDECnet: + case FamilyChaos: + case FamilyServerInterpreted: + if ((len = CheckAddr (family, pAddr, length)) < 0) + { + client->errorValue = length; + return BadValue; + } + break; + case FamilyLocal: + default: + client->errorValue = family; + return BadValue; + } + if (NewHost (family, pAddr, len, FALSE)) + return Success; + return BadAlloc; +} + +Bool +ForEachHostInFamily (int family, + Bool (*func)( + unsigned char * /* addr */, + short /* len */, + pointer /* closure */), + pointer closure) +{ + HOST *host; + + for (host = validhosts; host; host = host->next) + if (family == host->family && func (host->addr, host->len, closure)) + return TRUE; + return FALSE; +} + +/* Add a host to the access control list. This is the internal interface + * called when starting or resetting the server */ +static Bool +NewHost (int family, + const void * addr, + int len, + int addingLocalHosts) +{ + register HOST *host; + + for (host = validhosts; host; host = host->next) + { + if (addrEqual (family, addr, len, host)) + return TRUE; + } + if (!addingLocalHosts) { /* Fix for XFree86 bug #156 */ + for (host = selfhosts; host; host = host->next) { + if (addrEqual (family, addr, len, host)) { + host->requested = TRUE; + break; + } + } + } + MakeHost(host,len) + if (!host) + return FALSE; + host->family = family; + host->len = len; + acopy(addr, host->addr, len); + host->next = validhosts; + validhosts = host; + return TRUE; +} + +/* Remove a host from the access control list */ + +int +RemoveHost ( + ClientPtr client, + int family, + unsigned length, /* of bytes in pAddr */ + pointer pAddr) +{ + int rc, len; + register HOST *host, **prev; + + rc = AuthorizedClient(client); + if (rc != Success) + return rc; + switch (family) { + case FamilyLocalHost: + len = length; + LocalHostEnabled = FALSE; + break; +#ifdef SECURE_RPC + case FamilyNetname: + len = length; + break; +#endif + case FamilyInternet: +#if defined(IPv6) && defined(AF_INET6) + case FamilyInternet6: +#endif + case FamilyDECnet: + case FamilyChaos: + case FamilyServerInterpreted: + if ((len = CheckAddr (family, pAddr, length)) < 0) + { + client->errorValue = length; + return BadValue; + } + break; + case FamilyLocal: + default: + client->errorValue = family; + return BadValue; + } + for (prev = &validhosts; + (host = *prev) && (!addrEqual (family, pAddr, len, host)); + prev = &host->next) + ; + if (host) + { + *prev = host->next; + FreeHost (host); + } + return Success; +} + +/* Get all hosts in the access control list */ +int +GetHosts ( + pointer *data, + int *pnHosts, + int *pLen, + BOOL *pEnabled) +{ + int len; + register int n = 0; + register unsigned char *ptr; + register HOST *host; + int nHosts = 0; + + *pEnabled = AccessEnabled ? EnableAccess : DisableAccess; + for (host = validhosts; host; host = host->next) + { + nHosts++; + n += pad_to_int32(host->len) + sizeof(xHostEntry); + } + if (n) + { + *data = ptr = malloc(n); + if (!ptr) + { + return BadAlloc; + } + for (host = validhosts; host; host = host->next) + { + len = host->len; + ((xHostEntry *)ptr)->family = host->family; + ((xHostEntry *)ptr)->length = len; + ptr += sizeof(xHostEntry); + acopy (host->addr, ptr, len); + ptr += pad_to_int32(len); + } + } else { + *data = NULL; + } + *pnHosts = nHosts; + *pLen = n; + return Success; +} + +/* Check for valid address family and length, and return address length. */ + +/*ARGSUSED*/ +static int +CheckAddr ( + int family, + const void * pAddr, + unsigned length) +{ + int len; + + switch (family) + { +#if defined(TCPCONN) || defined(STREAMSCONN) + case FamilyInternet: + if (length == sizeof (struct in_addr)) + len = length; + else + len = -1; + break; +#if defined(IPv6) && defined(AF_INET6) + case FamilyInternet6: + if (length == sizeof (struct in6_addr)) + len = length; + else + len = -1; + break; +#endif +#endif + case FamilyServerInterpreted: + len = siCheckAddr(pAddr, length); + break; + default: + len = -1; + } + return len; +} + +/* Check if a host is not in the access control list. + * Returns 1 if host is invalid, 0 if we've found it. */ + +int +InvalidHost ( + register struct sockaddr *saddr, + int len, + ClientPtr client) +{ + int family; + pointer addr; + register HOST *selfhost, *host; + + if (!AccessEnabled) /* just let them in */ + return 0; + family = ConvertAddr (saddr, &len, (pointer *)&addr); + if (family == -1) + return 1; + if (family == FamilyLocal) + { + if (!LocalHostEnabled) + { + /* + * check to see if any local address is enabled. This + * implicitly enables local connections. + */ + for (selfhost = selfhosts; selfhost; selfhost=selfhost->next) + { + for (host = validhosts; host; host=host->next) + { + if (addrEqual (selfhost->family, selfhost->addr, + selfhost->len, host)) + return 0; + } + } + } else + return 0; + } + for (host = validhosts; host; host = host->next) + { + if ((host->family == FamilyServerInterpreted)) { + if (siAddrMatch (family, addr, len, host, client)) { + return 0; + } + } else { + if (addrEqual (family, addr, len, host)) + return 0; + } + + } + return 1; +} + +static int +ConvertAddr ( + register struct sockaddr *saddr, + int *len, + pointer *addr) +{ + if (*len == 0) + return FamilyLocal; + switch (saddr->sa_family) + { + case AF_UNSPEC: +#if defined(UNIXCONN) || defined(LOCALCONN) + case AF_UNIX: +#endif + return FamilyLocal; +#if defined(TCPCONN) || defined(STREAMSCONN) + case AF_INET: +#ifdef WIN32 + if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr) + return FamilyLocal; +#endif + *len = sizeof (struct in_addr); + *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr); + return FamilyInternet; +#if defined(IPv6) && defined(AF_INET6) + case AF_INET6: + { + struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr; + if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) { + *len = sizeof (struct in_addr); + *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]); + return FamilyInternet; + } else { + *len = sizeof (struct in6_addr); + *addr = (pointer) &(saddr6->sin6_addr); + return FamilyInternet6; + } + } +#endif +#endif + default: + return -1; + } +} + +int +ChangeAccessControl( + ClientPtr client, + int fEnabled) +{ + int rc = AuthorizedClient(client); + if (rc != Success) + return rc; + AccessEnabled = fEnabled; + return Success; +} + +/* returns FALSE if xhost + in effect, else TRUE */ +int +GetAccessControl(void) +{ + return AccessEnabled; +} + +/***************************************************************************** + * FamilyServerInterpreted host entry implementation + * + * Supports an extensible system of host types which the server can interpret + * See the IPv6 extensions to the X11 protocol spec for the definition. + * + * Currently supported schemes: + * + * hostname - hostname as defined in IETF RFC 2396 + * ipv6 - IPv6 literal address as defined in IETF RFC's 3513 and + * + * See xc/doc/specs/SIAddresses for formal definitions of each type. + */ + +/* These definitions and the siTypeAdd function could be exported in the + * future to enable loading additional host types, but that was not done for + * the initial implementation. + */ +typedef Bool (*siAddrMatchFunc)(int family, pointer addr, int len, + const char *siAddr, int siAddrlen, ClientPtr client, void *siTypePriv); +typedef int (*siCheckAddrFunc)(const char *addrString, int length, + void *siTypePriv); + +struct siType { + struct siType * next; + const char * typeName; + siAddrMatchFunc addrMatch; + siCheckAddrFunc checkAddr; + void * typePriv; /* Private data for type routines */ +}; + +static struct siType *siTypeList; + +static int +siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch, + siCheckAddrFunc checkAddr, void *typePriv) +{ + struct siType *s, *p; + + if ((typeName == NULL) || (addrMatch == NULL) || (checkAddr == NULL)) + return BadValue; + + for (s = siTypeList, p = NULL; s != NULL ; p = s, s = s->next) { + if (strcmp(typeName, s->typeName) == 0) { + s->addrMatch = addrMatch; + s->checkAddr = checkAddr; + s->typePriv = typePriv; + return Success; + } + } + + s = malloc(sizeof(struct siType)); + if (s == NULL) + return BadAlloc; + + if (p == NULL) + siTypeList = s; + else + p->next = s; + + s->next = NULL; + s->typeName = typeName; + s->addrMatch = addrMatch; + s->checkAddr = checkAddr; + s->typePriv = typePriv; + return Success; +} + +/* Checks to see if a host matches a server-interpreted host entry */ +static Bool +siAddrMatch(int family, pointer addr, int len, HOST *host, ClientPtr client) +{ + Bool matches = FALSE; + struct siType *s; + const char *valueString; + int addrlen; + + valueString = (const char *) memchr(host->addr, '\0', host->len); + if (valueString != NULL) { + for (s = siTypeList; s != NULL ; s = s->next) { + if (strcmp((char *) host->addr, s->typeName) == 0) { + addrlen = host->len - (strlen((char *)host->addr) + 1); + matches = s->addrMatch(family, addr, len, + valueString + 1, addrlen, client, s->typePriv); + break; + } + } +#ifdef FAMILY_SI_DEBUG + ErrorF( + "Xserver: siAddrMatch(): type = %s, value = %*.*s -- %s\n", + host->addr, addrlen, addrlen, valueString + 1, + (matches) ? "accepted" : "rejected"); +#endif + } + return matches; +} + +static int +siCheckAddr(const char *addrString, int length) +{ + const char *valueString; + int addrlen, typelen; + int len = -1; + struct siType *s; + + /* Make sure there is a \0 byte inside the specified length + to separate the address type from the address value. */ + valueString = (const char *) memchr(addrString, '\0', length); + if (valueString != NULL) { + /* Make sure the first string is a recognized address type, + * and the second string is a valid address of that type. + */ + typelen = strlen(addrString) + 1; + addrlen = length - typelen; + + for (s = siTypeList; s != NULL ; s = s->next) { + if (strcmp(addrString, s->typeName) == 0) { + len = s->checkAddr(valueString + 1, addrlen, s->typePriv); + if (len >= 0) { + len += typelen; + } + break; + } + } +#ifdef FAMILY_SI_DEBUG + { + const char *resultMsg; + + if (s == NULL) { + resultMsg = "type not registered"; + } else { + if (len == -1) + resultMsg = "rejected"; + else + resultMsg = "accepted"; + } + + ErrorF("Xserver: siCheckAddr(): type = %s, value = %*.*s, len = %d -- %s\n", + addrString, addrlen, addrlen, valueString + 1, len, resultMsg); + } +#endif + } + return len; +} + + +/*** + * Hostname server-interpreted host type + * + * Stored as hostname string, explicitly defined to be resolved ONLY + * at access check time, to allow for hosts with dynamic addresses + * but static hostnames, such as found in some DHCP & mobile setups. + * + * Hostname must conform to IETF RFC 2396 sec. 3.2.2, which defines it as: + * hostname = *( domainlabel "." ) toplabel [ "." ] + * domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum + * toplabel = alpha | alpha *( alphanum | "-" ) alphanum + */ + +#ifdef NI_MAXHOST +# define SI_HOSTNAME_MAXLEN NI_MAXHOST +#else +# ifdef MAXHOSTNAMELEN +# define SI_HOSTNAME_MAXLEN MAXHOSTNAMELEN +# else +# define SI_HOSTNAME_MAXLEN 256 +# endif +#endif + +static Bool +siHostnameAddrMatch(int family, pointer addr, int len, + const char *siAddr, int siAddrLen, ClientPtr client, void *typePriv) +{ + Bool res = FALSE; + +/* Currently only supports checking against IPv4 & IPv6 connections, but + * support for other address families, such as DECnet, could be added if + * desired. + */ +#if defined(IPv6) && defined(AF_INET6) + if ((family == FamilyInternet) || (family == FamilyInternet6)) { + char hostname[SI_HOSTNAME_MAXLEN]; + struct addrinfo *addresses; + struct addrinfo *a; + int f, hostaddrlen; + pointer hostaddr; + + if (siAddrLen >= sizeof(hostname)) + return FALSE; + + strncpy(hostname, siAddr, siAddrLen); + hostname[siAddrLen] = '\0'; + + if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) { + for (a = addresses ; a != NULL ; a = a->ai_next) { + hostaddrlen = a->ai_addrlen; + f = ConvertAddr(a->ai_addr,&hostaddrlen,&hostaddr); + if ((f == family) && (len == hostaddrlen) && + (acmp (addr, hostaddr, len) == 0) ) { + res = TRUE; + break; + } + } + freeaddrinfo(addresses); + } + } +#else /* IPv6 not supported, use gethostbyname instead for IPv4 */ + if (family == FamilyInternet) { + register struct hostent *hp; +#ifdef XTHREADS_NEEDS_BYNAMEPARAMS + _Xgethostbynameparams hparams; +#endif + char hostname[SI_HOSTNAME_MAXLEN]; + int f, hostaddrlen; + pointer hostaddr; + const char **addrlist; + + if (siAddrLen >= sizeof(hostname)) + return FALSE; + + strncpy(hostname, siAddr, siAddrLen); + hostname[siAddrLen] = '\0'; + + if ((hp = _XGethostbyname(hostname, hparams)) != NULL) { +#ifdef h_addr /* new 4.3bsd version of gethostent */ + /* iterate over the addresses */ + for (addrlist = hp->h_addr_list; *addrlist; addrlist++) +#else + addrlist = &hp->h_addr; +#endif + { + struct sockaddr_in sin; + + sin.sin_family = hp->h_addrtype; + acopy ( *addrlist, &(sin.sin_addr), hp->h_length); + hostaddrlen = sizeof(sin); + f = ConvertAddr ((struct sockaddr *)&sin, + &hostaddrlen, &hostaddr); + if ((f == family) && (len == hostaddrlen) && + (acmp (addr, hostaddr, len) == 0) ) { + res = TRUE; + break; + } + } + } + } +#endif + return res; +} + + +static int +siHostnameCheckAddr(const char *valueString, int length, void *typePriv) +{ + /* Check conformance of hostname to RFC 2396 sec. 3.2.2 definition. + * We do not use ctype functions here to avoid locale-specific + * character sets. Hostnames must be pure ASCII. + */ + int len = length; + int i; + Bool dotAllowed = FALSE; + Bool dashAllowed = FALSE; + + if ((length <= 0) || (length >= SI_HOSTNAME_MAXLEN)) { + len = -1; + } else { + for (i = 0; i < length; i++) { + char c = valueString[i]; + + if (c == 0x2E) { /* '.' */ + if (dotAllowed == FALSE) { + len = -1; + break; + } else { + dotAllowed = FALSE; + dashAllowed = FALSE; + } + } else if (c == 0x2D) { /* '-' */ + if (dashAllowed == FALSE) { + len = -1; + break; + } else { + dotAllowed = FALSE; + } + } else if (((c >= 0x30) && (c <= 0x3A)) /* 0-9 */ || + ((c >= 0x61) && (c <= 0x7A)) /* a-z */ || + ((c >= 0x41) && (c <= 0x5A)) /* A-Z */) { + dotAllowed = TRUE; + dashAllowed = TRUE; + } else { /* Invalid character */ + len = -1; + break; + } + } + } + return len; +} + +#if defined(IPv6) && defined(AF_INET6) +/*** + * "ipv6" server interpreted type + * + * Currently supports only IPv6 literal address as specified in IETF RFC 3513 + * + * Once draft-ietf-ipv6-scoping-arch-00.txt becomes an RFC, support will be + * added for the scoped address format it specifies. + */ + +/* Maximum length of an IPv6 address string - increase when adding support + * for scoped address qualifiers. Includes room for trailing NUL byte. + */ +#define SI_IPv6_MAXLEN INET6_ADDRSTRLEN + +static Bool +siIPv6AddrMatch(int family, pointer addr, int len, + const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv) +{ + struct in6_addr addr6; + char addrbuf[SI_IPv6_MAXLEN]; + + if ((family != FamilyInternet6) || (len != sizeof(addr6))) + return FALSE; + + memcpy(addrbuf, siAddr, siAddrlen); + addrbuf[siAddrlen] = '\0'; + + if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) { + perror("inet_pton"); + return FALSE; + } + + if (memcmp(addr, &addr6, len) == 0) { + return TRUE; + } else { + return FALSE; + } +} + +static int +siIPv6CheckAddr(const char *addrString, int length, void *typePriv) +{ + int len; + + /* Minimum length is 3 (smallest legal address is "::1") */ + if (length < 3) { + /* Address is too short! */ + len = -1; + } else if (length >= SI_IPv6_MAXLEN) { + /* Address is too long! */ + len = -1; + } else { + /* Assume inet_pton is sufficient validation */ + struct in6_addr addr6; + char addrbuf[SI_IPv6_MAXLEN]; + + memcpy(addrbuf, addrString, length); + addrbuf[length] = '\0'; + + if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) { + perror("inet_pton"); + len = -1; + } else { + len = length; + } + } + return len; +} +#endif /* IPv6 */ + +#if !defined(NO_LOCAL_CLIENT_CRED) +/*** + * "localuser" & "localgroup" server interpreted types + * + * Allows local connections from a given local user or group + */ + +#include +#include + +#define LOCAL_USER 1 +#define LOCAL_GROUP 2 + +typedef struct { + int credType; +} siLocalCredPrivRec, *siLocalCredPrivPtr; + +static siLocalCredPrivRec siLocalUserPriv = { LOCAL_USER }; +static siLocalCredPrivRec siLocalGroupPriv = { LOCAL_GROUP }; + +static Bool +siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id) +{ + Bool parsedOK = FALSE; + char *addrbuf = malloc(len + 1); + + if (addrbuf == NULL) { + return FALSE; + } + + memcpy(addrbuf, addr, len); + addrbuf[len] = '\0'; + + if (addr[0] == '#') { /* numeric id */ + char *cp; + errno = 0; + *id = strtol(addrbuf + 1, &cp, 0); + if ((errno == 0) && (cp != (addrbuf+1))) { + parsedOK = TRUE; + } + } else { /* non-numeric name */ + if (lcPriv->credType == LOCAL_USER) { + struct passwd *pw = getpwnam(addrbuf); + + if (pw != NULL) { + *id = (int) pw->pw_uid; + parsedOK = TRUE; + } + } else { /* group */ + struct group *gr = getgrnam(addrbuf); + + if (gr != NULL) { + *id = (int) gr->gr_gid; + parsedOK = TRUE; + } + } + } + + free(addrbuf); + return parsedOK; +} + +static Bool +siLocalCredAddrMatch(int family, pointer addr, int len, + const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv) +{ + int siAddrId; + LocalClientCredRec *lcc; + siLocalCredPrivPtr lcPriv = (siLocalCredPrivPtr) typePriv; + + if (GetLocalClientCreds(client, &lcc) == -1) { + return FALSE; + } + +#ifdef HAVE_GETZONEID /* Ensure process is in the same zone */ + if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) { + FreeLocalClientCreds(lcc); + return FALSE; + } +#endif + + if (siLocalCredGetId(siAddr, siAddrlen, lcPriv, &siAddrId) == FALSE) { + FreeLocalClientCreds(lcc); + return FALSE; + } + + if (lcPriv->credType == LOCAL_USER) { + if ((lcc->fieldsSet & LCC_UID_SET) && (lcc->euid == siAddrId)) { + FreeLocalClientCreds(lcc); + return TRUE; + } + } else { + if ((lcc->fieldsSet & LCC_GID_SET) && (lcc->egid == siAddrId)) { + FreeLocalClientCreds(lcc); + return TRUE; + } + if (lcc->pSuppGids != NULL) { + int i; + + for (i = 0 ; i < lcc->nSuppGids; i++) { + if (lcc->pSuppGids[i] == siAddrId) { + FreeLocalClientCreds(lcc); + return TRUE; + } + } + } + } + FreeLocalClientCreds(lcc); + return FALSE; +} + +static int +siLocalCredCheckAddr(const char *addrString, int length, void *typePriv) +{ + int len = length; + int id; + + if (siLocalCredGetId(addrString, length, + (siLocalCredPrivPtr)typePriv, &id) == FALSE) { + len = -1; + } + return len; +} +#endif /* localuser */ + +static void +siTypesInitialize(void) +{ + siTypeAdd("hostname", siHostnameAddrMatch, siHostnameCheckAddr, NULL); +#if defined(IPv6) && defined(AF_INET6) + siTypeAdd("ipv6", siIPv6AddrMatch, siIPv6CheckAddr, NULL); +#endif +#if !defined(NO_LOCAL_CLIENT_CRED) + siTypeAdd("localuser", siLocalCredAddrMatch, siLocalCredCheckAddr, + &siLocalUserPriv); + siTypeAdd("localgroup", siLocalCredAddrMatch, siLocalCredCheckAddr, + &siLocalGroupPriv); +#endif +} diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c index 8026423f7..4eb2c15c7 100644 --- a/xorg-server/os/connection.c +++ b/xorg-server/os/connection.c @@ -746,6 +746,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time) free(oc); return NullClient; } + oc->local_client = ComputeLocalClient(client); #if !defined(WIN32) ConnectionTranslation[fd] = client->index; #else diff --git a/xorg-server/os/osdep.h b/xorg-server/os/osdep.h index 491a746d4..d7756b67a 100644 --- a/xorg-server/os/osdep.h +++ b/xorg-server/os/osdep.h @@ -172,6 +172,7 @@ typedef struct _osComm { XID auth_id; /* authorization id */ CARD32 conn_time; /* timestamp if not established, else 0 */ struct _XtransConnInfo *trans_conn; /* transport connection object */ + Bool local_client; } OsCommRec, *OsCommPtr; extern int FlushClient( @@ -217,6 +218,9 @@ typedef long int fd_mask; #define ffs mffs extern int mffs(fd_mask); +/* in access.c */ +extern Bool ComputeLocalClient(ClientPtr client); + /* in auth.c */ extern void GenerateRandomData (int len, char *buf); diff --git a/xorg-server/render/animcur.c b/xorg-server/render/animcur.c index 505c65c18..fddd9f81b 100644 --- a/xorg-server/render/animcur.c +++ b/xorg-server/render/animcur.c @@ -95,8 +95,6 @@ AnimCurCloseScreen (int index, ScreenPtr pScreen) Bool ret; Unwrap(as, pScreen, CloseScreen); - - Unwrap(as, pScreen, BlockHandler); Unwrap(as, pScreen, CursorLimits); Unwrap(as, pScreen, DisplayCursor); @@ -150,6 +148,7 @@ AnimCurScreenBlockHandler (int screenNum, ScreenPtr pScreen = screenInfo.screens[screenNum]; AnimCurScreenPtr as = GetAnimCurScreen(pScreen); DeviceIntPtr dev; + Bool activeDevice = FALSE; CARD32 now = 0, soonest = ~0; /* earliest time to wakeup again */ @@ -157,7 +156,10 @@ AnimCurScreenBlockHandler (int screenNum, { if (IsPointerDevice(dev) && pScreen == dev->spriteInfo->anim.pScreen) { - if (!now) now = GetTimeInMillis (); + if (!activeDevice) { + now = GetTimeInMillis (); + activeDevice = TRUE; + } if ((INT32) (now - dev->spriteInfo->anim.time) >= 0) { @@ -187,12 +189,15 @@ AnimCurScreenBlockHandler (int screenNum, } } - if (now) + if (activeDevice) AdjustWaitForDelay (pTimeout, soonest - now); Unwrap (as, pScreen, BlockHandler); (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask); - Wrap (as, pScreen, BlockHandler, AnimCurScreenBlockHandler); + if (activeDevice) + Wrap (as, pScreen, BlockHandler, AnimCurScreenBlockHandler); + else + as->BlockHandler = NULL; } static Bool @@ -218,6 +223,9 @@ AnimCurDisplayCursor (DeviceIntPtr pDev, pDev->spriteInfo->anim.time = GetTimeInMillis () + ac->elts[0].delay; pDev->spriteInfo->anim.pCursor = pCursor; pDev->spriteInfo->anim.pScreen = pScreen; + + if (!as->BlockHandler) + Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler); } } else @@ -244,8 +252,12 @@ AnimCurSetCursorPosition (DeviceIntPtr pDev, Bool ret; Unwrap (as, pScreen, SetCursorPosition); - if (pDev->spriteInfo->anim.pCursor) + if (pDev->spriteInfo->anim.pCursor) { pDev->spriteInfo->anim.pScreen = pScreen; + + if (!as->BlockHandler) + Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler); + } ret = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent); Wrap (as, pScreen, SetCursorPosition, AnimCurSetCursorPosition); return ret; @@ -330,7 +342,7 @@ AnimCurInit (ScreenPtr pScreen) return FALSE; Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen); - Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler); + as->BlockHandler = NULL; Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits); Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor); diff --git a/xorg-server/render/mipict.c b/xorg-server/render/mipict.c index 0f8076243..56d874e25 100644 --- a/xorg-server/render/mipict.c +++ b/xorg-server/render/mipict.c @@ -386,7 +386,8 @@ miCompositeSourceValidate (PicturePtr pPicture, } x += pPicture->pDrawable->x; y += pPicture->pDrawable->y; - (*pScreen->SourceValidate) (pDrawable, x, y, width, height); + (*pScreen->SourceValidate) (pDrawable, x, y, width, height, + pPicture->subWindowMode); } } -- cgit v1.2.3