1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef bbs_INT8ARR_EM_H 18#define bbs_INT8ARR_EM_H 19 20/* ---- includes ----------------------------------------------------------- */ 21 22#include "b_BasicEm/Context.h" 23#include "b_BasicEm/MemSeg.h" 24 25/* ---- related objects --------------------------------------------------- */ 26 27/* ---- typedefs ----------------------------------------------------------- */ 28 29/* ---- constants ---------------------------------------------------------- */ 30 31/* ---- object definition -------------------------------------------------- */ 32 33/** byte array */ 34struct bbs_Int8Arr 35{ 36 37 /* ---- private data --------------------------------------------------- */ 38 39 /** pointer to exclusive memory segment used for allocation */ 40 struct bbs_MemSeg* mspE; 41 42 /* ---- public data ---------------------------------------------------- */ 43 44 /** pointer to array of int8 */ 45 int8* arrPtrE; 46 47 /** current size */ 48 uint32 sizeE; 49 50 /** allocated size */ 51 uint32 allocatedSizeE; 52 53}; 54 55/* ---- associated objects ------------------------------------------------- */ 56 57/* ---- external functions ------------------------------------------------- */ 58 59/* ---- \ghd{ constructor/destructor } ------------------------------------- */ 60 61/** initializes bbs_Int8Arr */ 62void bbs_Int8Arr_init( struct bbs_Context* cpA, 63 struct bbs_Int8Arr* ptrA ); 64 65/** frees bbs_Int8Arr */ 66void bbs_Int8Arr_exit( struct bbs_Context* cpA, 67 struct bbs_Int8Arr* ptrA ); 68 69/* ---- \ghd{ operators } -------------------------------------------------- */ 70 71/** copy operator */ 72void bbs_Int8Arr_copy( struct bbs_Context* cpA, 73 struct bbs_Int8Arr* ptrA, 74 const struct bbs_Int8Arr* srcPtrA ); 75 76/** equal operator */ 77flag bbs_Int8Arr_equal( struct bbs_Context* cpA, 78 const struct bbs_Int8Arr* ptrA, 79 const struct bbs_Int8Arr* srcPtrA ); 80 81/* ---- \ghd{ query functions } -------------------------------------------- */ 82 83/** calculates the amount of heap memory needed (16bit words) if created with given parameters */ 84uint32 bbs_Int8Arr_heapSize( struct bbs_Context* cpA, 85 const struct bbs_Int8Arr* ptrA, 86 uint32 sizeA ); 87 88/* ---- \ghd{ modify functions } ------------------------------------------- */ 89 90/** allocates memory for bbs_Int8Arr */ 91void bbs_Int8Arr_create( struct bbs_Context* cpA, 92 struct bbs_Int8Arr* ptrA, 93 uint32 sizeA, 94 struct bbs_MemSeg* mspA ); 95 96/** sets array size */ 97void bbs_Int8Arr_size( struct bbs_Context* cpA, 98 struct bbs_Int8Arr* ptrA, 99 uint32 sizeA ); 100 101/* ---- \ghd{ memory I/O } ------------------------------------------------- */ 102 103/** size object needs when written to memory */ 104uint32 bbs_Int8Arr_memSize( struct bbs_Context* cpA, 105 const struct bbs_Int8Arr* ptrA ); 106 107/** writes object to memory; returns number of words (16-bit) written */ 108uint32 bbs_Int8Arr_memWrite( struct bbs_Context* cpA, 109 const struct bbs_Int8Arr* ptrA, 110 uint16* memPtrA ); 111 112/** reads object from memory; returns number of words (16-bit) written */ 113uint32 bbs_Int8Arr_memRead( struct bbs_Context* cpA, 114 struct bbs_Int8Arr* ptrA, 115 const uint16* memPtrA, 116 struct bbs_MemSeg* mspA ); 117 118/* ---- \ghd{ exec functions } --------------------------------------------- */ 119 120/** fills array with a value */ 121void bbs_Int8Arr_fill( struct bbs_Context* cpA, 122 struct bbs_Int8Arr* ptrA, 123 int8 valA ); 124 125#endif /* bbs_INT8ARR_EM_H */ 126 127