/opengles/src/codegen/segment.h

http://ftk.googlecode.com/ · C Header · 126 lines · 43 code · 27 blank · 56 comment · 1 complexity · e07ccfe0e6856ef05cbd87cf77a22802 MD5 · raw file

  1. #ifndef CODEGEN_SGEMENT_H
  2. #define CODEGEN_SGEMENT_H 1
  3. /****************************************************************************/
  4. /* */
  5. /* Copyright (c) 2004, Hans-Martin Will. All rights reserved. */
  6. /* */
  7. /* Redistribution and use in source and binary forms, with or without */
  8. /* modification, are permitted provided that the following conditions are */
  9. /* met: */
  10. /* */
  11. /* * Redistributions of source code must retain the above copyright */
  12. /* notice, this list of conditions and the following disclaimer. */
  13. /* */
  14. /* * Redistributions in binary form must reproduce the above copyright */
  15. /* notice, this list of conditions and the following disclaimer in the */
  16. /* documentation and/or other materials provided with the distribution. */
  17. /* */
  18. /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
  19. /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
  20. /* LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
  21. /* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER */
  22. /* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
  23. /* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, */
  24. /* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
  25. /* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  26. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
  27. /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
  28. /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
  29. /* */
  30. /****************************************************************************/
  31. #include "codegen.h"
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. #if defined(__GCC32__) && defined(__cplusplus)
  36. struct cg_segment_t;
  37. #else
  38. typedef struct cg_segment_t cg_segment_t;
  39. #endif
  40. /************************************************************************/
  41. /* Code segment data structure */
  42. /************************************************************************/
  43. cg_segment_t * cg_segment_create(const char * name);
  44. /************************************************************************/
  45. /* Create a named segment. The name is really for debugging only. */
  46. /************************************************************************/
  47. void cg_segment_destroy(cg_segment_t * segment);
  48. /************************************************************************/
  49. /* Destroy the segment and all associated data */
  50. /************************************************************************/
  51. const char * cg_segment_name(cg_segment_t * segment);
  52. /************************************************************************/
  53. /* Return the name of the segment */
  54. /************************************************************************/
  55. size_t cg_segment_size(cg_segment_t * segment);
  56. /************************************************************************/
  57. /* Retrieve the current size of a segement */
  58. /************************************************************************/
  59. size_t cg_segment_align(cg_segment_t * segment, size_t alignment);
  60. /************************************************************************/
  61. /* Align the memory segment to the given alignment boundary. */
  62. /* The adjusted size is returned. */
  63. /************************************************************************/
  64. /****************************************************************************/
  65. /* Emit (append) data to the target segment */
  66. /****************************************************************************/
  67. void cg_segment_emit_u8(cg_segment_t * segment, U8 byte);
  68. void cg_segment_emit_u16(cg_segment_t * segment, U16 half_word);
  69. void cg_segment_emit_u32(cg_segment_t * segment, U32 word);
  70. void cg_segment_emit_i8(cg_segment_t * segment, I8 byte);
  71. void cg_segment_emit_i16(cg_segment_t * segment, I16 half_word);
  72. void cg_segment_emit_i32(cg_segment_t * segment, I32 word);
  73. void cg_segment_emit_block(cg_segment_t * segment, const void * p, size_t size);
  74. /****************************************************************************/
  75. /* Set data in the target segment */
  76. /****************************************************************************/
  77. void cg_segment_set_u8(cg_segment_t * segment, size_t offset, U8 byte);
  78. void cg_segment_set_u16(cg_segment_t * segment, size_t offset, U16 half_word);
  79. void cg_segment_set_u32(cg_segment_t * segment, size_t offset, U32 word);
  80. void cg_segment_set_i8(cg_segment_t * segment, size_t offset, I8 byte);
  81. void cg_segment_set_i16(cg_segment_t * segment, size_t offset, I16 half_word);
  82. void cg_segment_set_i32(cg_segment_t * segment, size_t offset, I32 word);
  83. void cg_segment_set_block(cg_segment_t * segment, size_t offset, const void * p,
  84. size_t size);
  85. /****************************************************************************/
  86. /* Retrieve data from the target segment */
  87. /****************************************************************************/
  88. U8 cg_segment_get_u8(cg_segment_t * segment, size_t offset);
  89. U16 cg_segment_get_u16(cg_segment_t * segment, size_t offset);
  90. U32 cg_segment_get_u32(cg_segment_t * segment, size_t offset);
  91. I8 cg_segment_get_i8(cg_segment_t * segment, size_t offset);
  92. I16 cg_segment_get_i16(cg_segment_t * segment, size_t offset);
  93. I32 cg_segment_get_i32(cg_segment_t * segment, size_t offset);
  94. void cg_segment_get_block(cg_segment_t * segment, size_t offset, void * p,
  95. size_t size);
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif //ndef CODEGEN_SGEMENT_H