PageRenderTime 542ms CodeModel.GetById 131ms app.highlight 296ms RepoModel.GetById 108ms app.codeStats 1ms

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