Adding new commiter to ODU-High repo
[o-du/l2.git] / src / cm / cm_mblk.h
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18 \f
19 /********************************************************************20**
20   
21      Name:     common memory allocation library 
22   
23      Type:     C include file
24   
25      Desc:     Hash Defines 
26  
27      File:     cm_mblk.h
28  
29 *********************************************************************21*/
30   
31 #ifndef __CMMBLKH__
32 #define __CMMBLKH__
33
34 /* Hash defines for alignment bytes */
35 #define CM_ALIGNBOUNDARY_FOUR     4   /* Align 32 bit */ 
36 #define CM_ALIGNBOUNDARY_EIGHT    8   /* Align 64 bit */
37
38 /* Macro Definitions */
39
40 #define CM_INIT_MEMCP(_memCp,_maxSize,_sMem) \
41 { \
42   _memCp->first = NULLP; \
43   _memCp->last = NULLP; \
44   _memCp->count = 0;\
45   _memCp->memCb.maxSize = _maxSize;\
46   _memCp->memCb.memAllocated = 0; \
47   _memCp->memCb.initPtr = NULLP; \
48   _memCp->memCb.runPtr = NULLP; \
49   _memCp->memCb.sMem.region = _sMem->region; \
50   _memCp->memCb.sMem.pool = _sMem->pool; \
51 }
52
53 #define CM_INIT_MEMCPVAR(_memCp) \
54 { \
55   _memCp->first = NULLP; \
56   _memCp->last = NULLP; \
57   _memCp->count = 0;\
58   _memCp->memCb.memAllocated = 0; \
59   _memCp->memCb.initPtr = NULLP; \
60   _memCp->memCb.runPtr = NULLP; \
61 }
62
63 #ifdef ALIGN_64BIT
64 #define CM_ALIGN_SIZE(_size) \
65 { \
66   if( (_size % CM_ALIGNBOUNDARY_EIGHT) ) \
67      _size = _size + ( CM_ALIGNBOUNDARY_EIGHT -  \
68                   (_size % CM_ALIGNBOUNDARY_EIGHT)); \
69 }
70 #else
71 #define CM_ALIGN_SIZE(_size) \
72 { \
73   if( (_size % CM_ALIGNBOUNDARY_FOUR) ) \
74     _size = _size + ( CM_ALIGNBOUNDARY_FOUR -  \
75                   (_size % CM_ALIGNBOUNDARY_FOUR)); \
76 }
77 #endif  /* ALIGN_64BIT */
78
79 #define CMCHKUNPKPTR(func, val, ptr, mBuf) \
80    { \
81       S16 ret; \
82       if ((ret = func(val, ptr, mBuf)) != ROK) \
83          return (ret); \
84    }
85
86 #define CMGETMBLK(ptr, size, pptr) \
87    { \
88       S16 ret; \
89       ret = cmGetMem( ptr, size, pptr); \
90       if (ret != ROK) \
91       { \
92           return RFAILED; \
93       } \
94    }
95
96 #endif /* __CMMBLKH__ */
97
98 \f 
99 /********************************************************************30**
100   
101          End of file
102 **********************************************************************/