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