staging: wilc1000: remove WILC_Uint32
[deliverable/linux.git] / drivers / staging / wilc1000 / wilc_memory.h
1 #ifndef __WILC_MEMORY_H__
2 #define __WILC_MEMORY_H__
3
4 /*!
5 * @file wilc_memory.h
6 * @brief Memory OS wrapper functionality
7 * @author syounan
8 * @sa wilc_oswrapper.h top level OS wrapper file
9 * @date 16 Aug 2010
10 * @version 1.0
11 */
12
13 /*!
14 * @struct tstrWILC_MemoryAttrs
15 * @brief Memory API options
16 * @author syounan
17 * @date 16 Aug 2010
18 * @version 1.0
19 */
20 typedef struct {
21 } tstrWILC_MemoryAttrs;
22
23 /*!
24 * @brief Allocates a given size of bytes
25 * @param[in] u32Size size of memory in bytes to be allocated
26 * @param[in] strAttrs Optional attributes, NULL for default
27 * if not NULL, pAllocationPool should point to the pool to use for
28 * this allocation. if NULL memory will be allocated directly from
29 * the system
30 * @param[in] pcFileName file name of the calling code for debugging
31 * @param[in] u32LineNo line number of the calling code for debugging
32 * @return The new allocated block, NULL if allocation fails
33 * @note It is recommended to use of of the wrapper macros instead of
34 * calling this function directly
35 * @sa sttrWILC_MemoryAttrs
36 * @sa WILC_MALLOC
37 * @sa WILC_MALLOC_EX
38 * @sa WILC_NEW
39 * @sa WILC_NEW_EX
40 * @author syounan
41 * @date 16 Aug 2010
42 * @version 1.0
43 */
44 void *WILC_MemoryAlloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
45 WILC_Char *pcFileName, u32 u32LineNo);
46
47 /*!
48 * @brief Allocates a given size of bytes and zero filling it
49 * @param[in] u32Size size of memory in bytes to be allocated
50 * @param[in] strAttrs Optional attributes, NULL for default
51 * if not NULL, pAllocationPool should point to the pool to use for
52 * this allocation. if NULL memory will be allocated directly from
53 * the system
54 * @param[in] pcFileName file name of the calling code for debugging
55 * @param[in] u32LineNo line number of the calling code for debugging
56 * @return The new allocated block, NULL if allocation fails
57 * @note It is recommended to use of of the wrapper macros instead of
58 * calling this function directly
59 * @sa sttrWILC_MemoryAttrs
60 * @sa WILC_CALLOC
61 * @sa WILC_CALLOC_EX
62 * @sa WILC_NEW_0
63 * @sa WILC_NEW_0_EX
64 * @author syounan
65 * @date 16 Aug 2010
66 * @version 1.0
67 */
68 void *WILC_MemoryCalloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
69 WILC_Char *pcFileName, u32 u32LineNo);
70
71 /*!
72 * @brief Reallocates a given block to a new size
73 * @param[in] pvOldBlock the old memory block, if NULL then this function
74 * behaves as a new allocation function
75 * @param[in] u32NewSize size of the new memory block in bytes, if zero then
76 * this function behaves as a free function
77 * @param[in] strAttrs Optional attributes, NULL for default
78 * if pAllocationPool!=NULL and pvOldBlock==NULL, pAllocationPool
79 * should point to the pool to use for this allocation.
80 * if pAllocationPool==NULL and pvOldBlock==NULL memory will be
81 * allocated directly from the system
82 * if and pvOldBlock!=NULL, pAllocationPool will not be inspected
83 * and reallocation is done from the same pool as the original block
84 * @param[in] pcFileName file name of the calling code for debugging
85 * @param[in] u32LineNo line number of the calling code for debugging
86 * @return The new allocated block, possibly same as pvOldBlock
87 * @note It is recommended to use of of the wrapper macros instead of
88 * calling this function directly
89 * @sa sttrWILC_MemoryAttrs
90 * @sa WILC_REALLOC
91 * @sa WILC_REALLOC_EX
92 * @author syounan
93 * @date 16 Aug 2010
94 * @version 1.0
95 */
96 void *WILC_MemoryRealloc(void *pvOldBlock, u32 u32NewSize,
97 tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, u32 u32LineNo);
98
99 /*!
100 * @brief Frees given block
101 * @param[in] pvBlock the memory block to be freed
102 * @param[in] strAttrs Optional attributes, NULL for default
103 * @param[in] pcFileName file name of the calling code for debugging
104 * @param[in] u32LineNo line number of the calling code for debugging
105 * @note It is recommended to use of of the wrapper macros instead of
106 * calling this function directly
107 * @sa sttrWILC_MemoryAttrs
108 * @sa WILC_FREE
109 * @sa WILC_FREE_EX
110 * @sa WILC_FREE_SET_NULL
111 * @sa WILC_FREE_IF_TRUE
112 * @author syounan
113 * @date 16 Aug 2010
114 * @version 1.0
115 */
116 void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs,
117 WILC_Char *pcFileName, u32 u32LineNo);
118
119 /*!
120 * @brief standrad malloc wrapper with custom attributes
121 */
122 #define WILC_MALLOC_EX(__size__, __attrs__) \
123 (WILC_MemoryAlloc( \
124 (__size__), __attrs__, NULL, 0))
125
126 /*!
127 * @brief standrad calloc wrapper with custom attributes
128 */
129 #define WILC_CALLOC_EX(__size__, __attrs__) \
130 (WILC_MemoryCalloc( \
131 (__size__), __attrs__, NULL, 0))
132
133 /*!
134 * @brief standrad realloc wrapper with custom attributes
135 */
136 #define WILC_REALLOC_EX(__ptr__, __new_size__, __attrs__) \
137 (WILC_MemoryRealloc( \
138 (__ptr__), (__new_size__), __attrs__, NULL, 0))
139 /*!
140 * @brief standrad free wrapper with custom attributes
141 */
142 #define WILC_FREE_EX(__ptr__, __attrs__) \
143 (WILC_MemoryFree( \
144 (__ptr__), __attrs__, NULL, 0))
145
146 /*!
147 * @brief Allocates a block (with custom attributes) of given type and number of
148 * elements
149 */
150 #define WILC_NEW_EX(__struct_type__, __n_structs__, __attrs__) \
151 ((__struct_type__ *)WILC_MALLOC_EX( \
152 sizeof(__struct_type__) * (u32)(__n_structs__), __attrs__))
153
154 /*!
155 * @brief Allocates a block (with custom attributes) of given type and number of
156 * elements and Zero-fills it
157 */
158 #define WILC_NEW_0_EX(__struct_type__, __n_structs__, __attrs__) \
159 ((__struct_type__ *)WILC_CALLOC_EX( \
160 sizeof(__struct_type__) * (u32)(__n_structs__), __attrs__))
161
162 /*!
163 * @brief Frees a block (with custom attributes), also setting the original pointer
164 * to NULL
165 */
166 #define WILC_FREE_SET_NULL_EX(__ptr__, __attrs__) do { \
167 if (__ptr__ != NULL) { \
168 WILC_FREE_EX(__ptr__, __attrs__); \
169 __ptr__ = NULL; \
170 } \
171 } while (0)
172
173 /*!
174 * @brief Frees a block (with custom attributes) if the pointer expression evaluates
175 * to true
176 */
177 #define WILC_FREE_IF_TRUE_EX(__ptr__, __attrs__) do { \
178 if (__ptr__ != NULL) { \
179 WILC_FREE_EX(__ptr__, __attrs__); \
180 } \
181 } while (0)
182
183 /*!
184 * @brief standrad malloc wrapper with default attributes
185 */
186 #define WILC_MALLOC(__size__) \
187 WILC_MALLOC_EX(__size__, NULL)
188
189 /*!
190 * @brief standrad calloc wrapper with default attributes
191 */
192 #define WILC_CALLOC(__size__) \
193 WILC_CALLOC_EX(__size__, NULL)
194
195 /*!
196 * @brief standrad realloc wrapper with default attributes
197 */
198 #define WILC_REALLOC(__ptr__, __new_size__) \
199 WILC_REALLOC_EX(__ptr__, __new_size__, NULL)
200
201 /*!
202 * @brief standrad free wrapper with default attributes
203 */
204 #define WILC_FREE(__ptr__) \
205 WILC_FREE_EX(__ptr__, NULL)
206
207 /*!
208 * @brief Allocates a block (with default attributes) of given type and number of
209 * elements
210 */
211 #define WILC_NEW(__struct_type__, __n_structs__) \
212 WILC_NEW_EX(__struct_type__, __n_structs__, NULL)
213
214 /*!
215 * @brief Allocates a block (with default attributes) of given type and number of
216 * elements and Zero-fills it
217 */
218 #define WILC_NEW_0(__struct_type__, __n_structs__) \
219 WILC_NEW_O_EX(__struct_type__, __n_structs__, NULL)
220
221 /*!
222 * @brief Frees a block (with default attributes), also setting the original pointer
223 * to NULL
224 */
225 #define WILC_FREE_SET_NULL(__ptr__) \
226 WILC_FREE_SET_NULL_EX(__ptr__, NULL)
227
228 /*!
229 * @brief Frees a block (with default attributes) if the pointer expression evaluates
230 * to true
231 */
232 #define WILC_FREE_IF_TRUE(__ptr__) \
233 WILC_FREE_IF_TRUE_EX(__ptr__, NULL)
234
235
236 #endif
237
This page took 0.040896 seconds and 5 git commands to generate.