1706f2543Smrg/* 2706f2543Smrg * (C) Copyright IBM Corporation 2005, 2006 3706f2543Smrg * All Rights Reserved. 4706f2543Smrg * 5706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a 6706f2543Smrg * copy of this software and associated documentation files (the "Software"), 7706f2543Smrg * to deal in the Software without restriction, including without limitation 8706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sub license, 9706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the 10706f2543Smrg * Software is furnished to do so, subject to the following conditions: 11706f2543Smrg * 12706f2543Smrg * The above copyright notice and this permission notice (including the next 13706f2543Smrg * paragraph) shall be included in all copies or substantial portions of the 14706f2543Smrg * Software. 15706f2543Smrg * 16706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19706f2543Smrg * IBM, 20706f2543Smrg * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21706f2543Smrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22706f2543Smrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23706f2543Smrg * SOFTWARE. 24706f2543Smrg */ 25706f2543Smrg 26706f2543Smrg/** 27706f2543Smrg * \file indirect_table.h 28706f2543Smrg * 29706f2543Smrg * \author Ian Romanick <idr@us.ibm.com> 30706f2543Smrg */ 31706f2543Smrg 32706f2543Smrg#ifndef INDIRECT_TABLE_H 33706f2543Smrg#define INDIRECT_TABLE_H 34706f2543Smrg 35706f2543Smrg#include <inttypes.h> 36706f2543Smrg 37706f2543Smrg/** 38706f2543Smrg */ 39706f2543Smrgstruct __glXDispatchInfo { 40706f2543Smrg /** 41706f2543Smrg * Number of significant bits in the protocol opcode. Opcodes with values 42706f2543Smrg * larger than ((1 << bits) - 1) are invalid. 43706f2543Smrg */ 44706f2543Smrg unsigned bits; 45706f2543Smrg 46706f2543Smrg /** 47706f2543Smrg */ 48706f2543Smrg const int_fast16_t * dispatch_tree; 49706f2543Smrg 50706f2543Smrg /** 51706f2543Smrg * Array of protocol decode and dispatch functions index by the opcode 52706f2543Smrg * search tree (i.e., \c dispatch_tree). The first element in each pair 53706f2543Smrg * is the non-byte-swapped version, and the second element is the 54706f2543Smrg * byte-swapped version. 55706f2543Smrg */ 56706f2543Smrg const void *(*dispatch_functions)[2]; 57706f2543Smrg 58706f2543Smrg /** 59706f2543Smrg * Pointer to size validation data. This table is indexed with the same 60706f2543Smrg * value as ::dispatch_functions. 61706f2543Smrg * 62706f2543Smrg * The first element in the pair is the size, in bytes, of the fixed-size 63706f2543Smrg * portion of the protocol. 64706f2543Smrg * 65706f2543Smrg * For opcodes that have a variable-size portion, the second value is an 66706f2543Smrg * index in \c size_func_table to calculate that size. If there is no 67706f2543Smrg * variable-size portion, this index will be ~0. 68706f2543Smrg * 69706f2543Smrg * \note 70706f2543Smrg * If size checking is not to be performed on this type of protocol 71706f2543Smrg * data, this pointer will be \c NULL. 72706f2543Smrg */ 73706f2543Smrg const int_fast16_t (*size_table)[2]; 74706f2543Smrg 75706f2543Smrg /** 76706f2543Smrg * Array of functions used to calculate the variable-size portion of 77706f2543Smrg * protocol messages. Indexed by the second element of the entries 78706f2543Smrg * in \c ::size_table. 79706f2543Smrg * 80706f2543Smrg * \note 81706f2543Smrg * If size checking is not to be performed on this type of protocol 82706f2543Smrg * data, this pointer will be \c NULL. 83706f2543Smrg */ 84706f2543Smrg const gl_proto_size_func *size_func_table; 85706f2543Smrg}; 86706f2543Smrg 87706f2543Smrg/** 88706f2543Smrg * Sentinel value for an empty leaf in the \c dispatch_tree. 89706f2543Smrg */ 90706f2543Smrg#define EMPTY_LEAF INT_FAST16_MIN 91706f2543Smrg 92706f2543Smrg/** 93706f2543Smrg * Declare the index \c x as a leaf index. 94706f2543Smrg */ 95706f2543Smrg#define LEAF(x) -x 96706f2543Smrg 97706f2543Smrg/** 98706f2543Smrg * Determine if an index is a leaf index. 99706f2543Smrg */ 100706f2543Smrg#define IS_LEAF_INDEX(x) ((x) <= 0) 101706f2543Smrg 102706f2543Smrgextern const struct __glXDispatchInfo Single_dispatch_info; 103706f2543Smrgextern const struct __glXDispatchInfo Render_dispatch_info; 104706f2543Smrgextern const struct __glXDispatchInfo VendorPriv_dispatch_info; 105706f2543Smrg 106706f2543Smrg#endif /* INDIRECT_TABLE_H */ 107