indirect_table.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. * \file indirect_table.h
  27. *
  28. * \author Ian Romanick <idr@us.ibm.com>
  29. */
  30. #ifndef INDIRECT_TABLE_H
  31. #define INDIRECT_TABLE_H
  32. #include <inttypes.h>
  33. /**
  34. */
  35. struct __glXDispatchInfo {
  36. /**
  37. * Number of significant bits in the protocol opcode. Opcodes with values
  38. * larger than ((1 << bits) - 1) are invalid.
  39. */
  40. unsigned bits;
  41. /**
  42. */
  43. const int_fast16_t *dispatch_tree;
  44. /**
  45. * Array of protocol decode and dispatch functions index by the opcode
  46. * search tree (i.e., \c dispatch_tree). The first element in each pair
  47. * is the non-byte-swapped version, and the second element is the
  48. * byte-swapped version.
  49. */
  50. const void *(*dispatch_functions)[2];
  51. /**
  52. * Pointer to size validation data. This table is indexed with the same
  53. * value as ::dispatch_functions.
  54. *
  55. * The first element in the pair is the size, in bytes, of the fixed-size
  56. * portion of the protocol.
  57. *
  58. * For opcodes that have a variable-size portion, the second value is an
  59. * index in \c size_func_table to calculate that size. If there is no
  60. * variable-size portion, this index will be ~0.
  61. *
  62. * \note
  63. * If size checking is not to be performed on this type of protocol
  64. * data, this pointer will be \c NULL.
  65. */
  66. const int_fast16_t(*size_table)[2];
  67. /**
  68. * Array of functions used to calculate the variable-size portion of
  69. * protocol messages. Indexed by the second element of the entries
  70. * in \c ::size_table.
  71. *
  72. * \note
  73. * If size checking is not to be performed on this type of protocol
  74. * data, this pointer will be \c NULL.
  75. */
  76. const gl_proto_size_func *size_func_table;
  77. };
  78. /**
  79. * Sentinel value for an empty leaf in the \c dispatch_tree.
  80. */
  81. #define EMPTY_LEAF INT_FAST16_MIN
  82. /**
  83. * Declare the index \c x as a leaf index.
  84. */
  85. #define LEAF(x) -x
  86. /**
  87. * Determine if an index is a leaf index.
  88. */
  89. #define IS_LEAF_INDEX(x) ((x) <= 0)
  90. extern const struct __glXDispatchInfo Single_dispatch_info;
  91. extern const struct __glXDispatchInfo Render_dispatch_info;
  92. extern const struct __glXDispatchInfo VendorPriv_dispatch_info;
  93. #endif /* INDIRECT_TABLE_H */