| 1 | /* |
| 2 | * (C) Copyright IBM Corporation 2005, 2006 |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sub license, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the next |
| 13 | * paragraph) shall be included in all copies or substantial portions of the |
| 14 | * Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 19 | * IBM, |
| 20 | * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF |
| 22 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | * SOFTWARE. |
| 24 | */ |
| 25 | |
| 26 | /** |
| 27 | * \file indirect_table.h |
| 28 | * |
| 29 | * \author Ian Romanick <idr@us.ibm.com> |
| 30 | */ |
| 31 | |
| 32 | #ifndef INDIRECT_TABLE_H |
| 33 | #define INDIRECT_TABLE_H |
| 34 | |
| 35 | #include <inttypes.h> |
| 36 | |
| 37 | /** |
| 38 | */ |
| 39 | struct __glXDispatchInfo { |
| 40 | /** |
| 41 | * Number of significant bits in the protocol opcode. Opcodes with values |
| 42 | * larger than ((1 << bits) - 1) are invalid. |
| 43 | */ |
| 44 | unsigned bits; |
| 45 | |
| 46 | /** |
| 47 | */ |
| 48 | const int_fast16_t *dispatch_tree; |
| 49 | |
| 50 | /** |
| 51 | * Array of protocol decode and dispatch functions index by the opcode |
| 52 | * search tree (i.e., \c dispatch_tree). The first element in each pair |
| 53 | * is the non-byte-swapped version, and the second element is the |
| 54 | * byte-swapped version. |
| 55 | */ |
| 56 | const void *(*dispatch_functions)[2]; |
| 57 | |
| 58 | /** |
| 59 | * Pointer to size validation data. This table is indexed with the same |
| 60 | * value as ::dispatch_functions. |
| 61 | * |
| 62 | * The first element in the pair is the size, in bytes, of the fixed-size |
| 63 | * portion of the protocol. |
| 64 | * |
| 65 | * For opcodes that have a variable-size portion, the second value is an |
| 66 | * index in \c size_func_table to calculate that size. If there is no |
| 67 | * variable-size portion, this index will be ~0. |
| 68 | * |
| 69 | * \note |
| 70 | * If size checking is not to be performed on this type of protocol |
| 71 | * data, this pointer will be \c NULL. |
| 72 | */ |
| 73 | const int_fast16_t(*size_table)[2]; |
| 74 | |
| 75 | /** |
| 76 | * Array of functions used to calculate the variable-size portion of |
| 77 | * protocol messages. Indexed by the second element of the entries |
| 78 | * in \c ::size_table. |
| 79 | * |
| 80 | * \note |
| 81 | * If size checking is not to be performed on this type of protocol |
| 82 | * data, this pointer will be \c NULL. |
| 83 | */ |
| 84 | const gl_proto_size_func *size_func_table; |
| 85 | }; |
| 86 | |
| 87 | /** |
| 88 | * Sentinel value for an empty leaf in the \c dispatch_tree. |
| 89 | */ |
| 90 | #define EMPTY_LEAF INT_FAST16_MIN |
| 91 | |
| 92 | /** |
| 93 | * Declare the index \c x as a leaf index. |
| 94 | */ |
| 95 | #define LEAF(x) -x |
| 96 | |
| 97 | /** |
| 98 | * Determine if an index is a leaf index. |
| 99 | */ |
| 100 | #define IS_LEAF_INDEX(x) ((x) <= 0) |
| 101 | |
| 102 | extern const struct __glXDispatchInfo Single_dispatch_info; |
| 103 | extern const struct __glXDispatchInfo Render_dispatch_info; |
| 104 | extern const struct __glXDispatchInfo VendorPriv_dispatch_info; |
| 105 | |
| 106 | #endif /* INDIRECT_TABLE_H */ |