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