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