deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * (C) Copyright IBM Corporation 2005, 2006
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * All Rights Reserved.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Permission is hereby granted, free of charge, to any person obtaining a
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * copy of this software and associated documentation files (the "Software"),
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * to deal in the Software without restriction, including without limitation
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * the rights to use, copy, modify, merge, publish, distribute, sub license,
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * and/or sell copies of the Software, and to permit persons to whom the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Software is furnished to do so, subject to the following conditions:
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * The above copyright notice and this permission notice (including the next
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * paragraph) shall be included in all copies or substantial portions of the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Software.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * IBM,
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * SOFTWARE.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/**
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * \file indirect_table.h
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * \author Ian Romanick <idr@us.ibm.com>
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#ifndef INDIRECT_TABLE_H
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define INDIRECT_TABLE_H
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#include <inttypes.h>
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/**
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncstruct __glXDispatchInfo {
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync /**
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Number of significant bits in the protocol opcode. Opcodes with values
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * larger than ((1 << bits) - 1) are invalid.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync unsigned bits;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync /**
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync const int_fast16_t * dispatch_tree;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync /**
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Array of protocol decode and dispatch functions index by the opcode
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * search tree (i.e., \c dispatch_tree). The first element in each pair
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * is the non-byte-swapped version, and the second element is the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * byte-swapped version.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync const void *(*dispatch_functions)[2];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync /**
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Pointer to size validation data. This table is indexed with the same
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * value as ::dispatch_functions.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * The first element in the pair is the size, in bytes, of the fixed-size
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * portion of the protocol.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * For opcodes that have a variable-size portion, the second value is an
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * index in \c size_func_table to calculate that size. If there is no
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * variable-size portion, this index will be ~0.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * \note
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * If size checking is not to be performed on this type of protocol
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * data, this pointer will be \c NULL.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync const int_fast16_t (*size_table)[2];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync /**
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Array of functions used to calculate the variable-size portion of
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * protocol messages. Indexed by the second element of the entries
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * in \c ::size_table.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * \note
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * If size checking is not to be performed on this type of protocol
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * data, this pointer will be \c NULL.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync const gl_proto_size_func *size_func_table;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync};
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/**
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Sentinel value for an empty leaf in the \c dispatch_tree.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define EMPTY_LEAF INT_FAST16_MIN
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/**
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Declare the index \c x as a leaf index.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define LEAF(x) -x
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/**
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Determine if an index is a leaf index.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define IS_LEAF_INDEX(x) ((x) <= 0)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern const struct __glXDispatchInfo Single_dispatch_info;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern const struct __glXDispatchInfo Render_dispatch_info;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern const struct __glXDispatchInfo VendorPriv_dispatch_info;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* INDIRECT_TABLE_H */