• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_UINT16ARR_EM_H
18 #define bbs_UINT16ARR_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 */
34 struct bbs_UInt16Arr
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 uint16 */
45 	uint16* 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_UInt16Arr  */
62 void bbs_UInt16Arr_init( struct bbs_Context* cpA,
63 						 struct bbs_UInt16Arr* ptrA );
64 
65 /** frees bbs_UInt16Arr  */
66 void bbs_UInt16Arr_exit( struct bbs_Context* cpA,
67 						 struct bbs_UInt16Arr* ptrA );
68 
69 /* ---- \ghd{ operators } -------------------------------------------------- */
70 
71 /** copy operator */
72 void bbs_UInt16Arr_copy( struct bbs_Context* cpA,
73 						 struct bbs_UInt16Arr* ptrA,
74 						 const struct bbs_UInt16Arr* srcPtrA );
75 
76 /** equal operator */
77 flag bbs_UInt16Arr_equal( struct bbs_Context* cpA,
78 						  const struct bbs_UInt16Arr* ptrA,
79 						  const struct bbs_UInt16Arr* srcPtrA );
80 
81 /* ---- \ghd{ query functions } -------------------------------------------- */
82 
83 /** computes check sum for bbs_UInt16Arr (for debugging) */
84 uint32 bbs_UInt16Arr_checkSum( struct bbs_Context* cpA,
85 							   const struct bbs_UInt16Arr* ptrA,
86 							   uint32 startIndexA, uint32 sizeA );
87 
88 /** calculates the amount of heap memory needed (16bit words) if created with given parameters */
89 uint32 bbs_UInt16Arr_heapSize( struct bbs_Context* cpA,
90 							   const struct bbs_UInt16Arr* ptrA,
91 							   uint32 sizeA );
92 
93 /* ---- \ghd{ modify functions } ------------------------------------------- */
94 
95 /** allocates memory for bbs_UInt16Arr */
96 void bbs_UInt16Arr_create( struct bbs_Context* cpA,
97 						   struct bbs_UInt16Arr* ptrA,
98 						   uint32 sizeA,
99 						   struct bbs_MemSeg* mspA );
100 
101 /** sets array size */
102 void bbs_UInt16Arr_size( struct bbs_Context* cpA,
103 						 struct bbs_UInt16Arr* ptrA, uint32 sizeA );
104 
105 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
106 
107 /** size object needs when written to memory */
108 uint32 bbs_UInt16Arr_memSize( struct bbs_Context* cpA,
109 							  const struct bbs_UInt16Arr* ptrA );
110 
111 /** writes object to memory; returns number of bytes written */
112 uint32 bbs_UInt16Arr_memWrite( struct bbs_Context* cpA,
113 							   const struct bbs_UInt16Arr* ptrA, uint16* memPtrA );
114 
115 /** reads object from memory; returns number of bytes read */
116 uint32 bbs_UInt16Arr_memRead( struct bbs_Context* cpA,
117 							  struct bbs_UInt16Arr* ptrA,
118 							  const uint16* memPtrA,
119 							  struct bbs_MemSeg* mspA );
120 
121 /* ---- \ghd{ exec functions } --------------------------------------------- */
122 
123 /** fills array with a value */
124 void bbs_UInt16Arr_fill( struct bbs_Context* cpA,
125 						 struct bbs_UInt16Arr* ptrA,
126 						 uint16 valA );
127 
128 #endif /* bbs_UINT16ARR_EM_H */
129 
130