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