Home | History | Annotate | Download | only in b_BasicEm
      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_INT16ARR_EM_H
     18 #define bbs_INT16ARR_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 /** short array */
     34 struct bbs_Int16Arr
     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 int16 */
     45 	int16* 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_Int16Arr  */
     62 void bbs_Int16Arr_init( struct bbs_Context* cpA,
     63 					    struct bbs_Int16Arr* ptrA );
     64 
     65 /** frees bbs_Int16Arr  */
     66 void bbs_Int16Arr_exit( struct bbs_Context* cpA,
     67 					    struct bbs_Int16Arr* ptrA );
     68 
     69 /* ---- \ghd{ operators } -------------------------------------------------- */
     70 
     71 /** copy operator */
     72 void bbs_Int16Arr_copy( struct bbs_Context* cpA,
     73 					    struct bbs_Int16Arr* ptrA,
     74 						const struct bbs_Int16Arr* srcPtrA );
     75 
     76 /** equal operator */
     77 flag bbs_Int16Arr_equal( struct bbs_Context* cpA,
     78 						 const struct bbs_Int16Arr* ptrA,
     79 						 const struct bbs_Int16Arr* srcPtrA );
     80 
     81 /* ---- \ghd{ query functions } -------------------------------------------- */
     82 
     83 /** calculates the amount of heap memory needed (16bit words) if created with given parameters */
     84 uint32 bbs_Int16Arr_heapSize( struct bbs_Context* cpA,
     85 							  const struct bbs_Int16Arr* ptrA,
     86 							  uint32 sizeA );
     87 
     88 /* ---- \ghd{ modify functions } ------------------------------------------- */
     89 
     90 /** allocates memory for bbs_Int16Arr */
     91 void bbs_Int16Arr_create( struct bbs_Context* cpA,
     92 						  struct bbs_Int16Arr* ptrA,
     93 						  uint32 sizeA,
     94 						  struct bbs_MemSeg* mspA );
     95 
     96 /** allocates memory for bbs_Int16Arr,
     97 	Allocation is done for allocPtrA with extra memory to allow for alignment,
     98 	aligned memory pointer is copied to ptrA.
     99 	alignBytes must be a power of 2.
    100 	bbs_Int16Arr_heapSize does not apply !
    101 */
    102 void bbs_Int16Arr_createAligned( struct bbs_Context* cpA,
    103 								 struct bbs_Int16Arr* ptrA,
    104 								 uint32 sizeA,
    105 								 struct bbs_MemSeg* mspA,
    106 								 struct bbs_Int16Arr* allocPtrA,
    107 								 uint32 alignBytesA );
    108 
    109 /** sets array size */
    110 void bbs_Int16Arr_size( struct bbs_Context* cpA,
    111 					    struct bbs_Int16Arr* ptrA,
    112 						uint32 sizeA );
    113 
    114 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
    115 
    116 /** size object needs when written to memory */
    117 uint32 bbs_Int16Arr_memSize( struct bbs_Context* cpA,
    118 							 const struct bbs_Int16Arr* ptrA );
    119 
    120 /** writes object to memory; returns number of 16-bit words written */
    121 uint32 bbs_Int16Arr_memWrite( struct bbs_Context* cpA,
    122 							  const struct bbs_Int16Arr* ptrA,
    123 							  uint16* memPtrA );
    124 
    125 /** reads object from memory; returns number of 16-bit words read */
    126 uint32 bbs_Int16Arr_memRead( struct bbs_Context* cpA,
    127 							 struct bbs_Int16Arr* ptrA,
    128 							 const uint16* memPtrA,
    129 							 struct bbs_MemSeg* mspA );
    130 
    131 /* ---- \ghd{ exec functions } --------------------------------------------- */
    132 
    133 /** fills array with a value */
    134 void bbs_Int16Arr_fill( struct bbs_Context* cpA,
    135 					    struct bbs_Int16Arr* ptrA,
    136 						int16 valA );
    137 
    138 #endif /* bbs_INT16ARR_EM_H */
    139 
    140