field_compression.h (2992B)
1 /*! \file field_compression.h 2 * 3 * BCM FIELD Compression library Shim layer 4 */ 5 /* 6 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 7 * 8 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 9 */ 10 #ifndef _BCM_FIELD_COMPRESSION_H 11 #define _BCM_FIELD_COMPRESSION_H 12 13 #include <sal/core/alloc.h> 14 #include <sal/core/libc.h> 15 #include <shared/error.h> 16 17 /* 18 * SHR 19 */ 20 #define SHR_E_NONE _SHR_E_NONE 21 #define SHR_E_INTERNAL _SHR_E_INTERNAL 22 #define SHR_E_MEMORY _SHR_E_MEMORY 23 #define SHR_E_UNIT _SHR_E_UNIT 24 #define SHR_E_PARAM _SHR_E_PARAM 25 #define SHR_E_EMPTY _SHR_E_EMPTY 26 #define SHR_E_FULL _SHR_E_FULL 27 #define SHR_E_NOT_FOUND _SHR_E_NOT_FOUND 28 #define SHR_E_EXISTS _SHR_E_EXISTS 29 #define SHR_E_TIMEOUT _SHR_E_TIMEOUT 30 #define SHR_E_BUSY _SHR_E_BUSY 31 #define SHR_E_FAIL _SHR_E_FAIL 32 #define SHR_E_DISABLED _SHR_E_DISABLED 33 #define SHR_E_BADID _SHR_E_BADID 34 #define SHR_E_RESOURCE _SHR_E_RESOURCE 35 #define SHR_E_CONFIG _SHR_E_CONFIG 36 #define SHR_E_UNAVAIL _SHR_E_UNAVAIL 37 #define SHR_E_INIT _SHR_E_INIT 38 #define SHR_E_PORT _SHR_E_PORT 39 #define SHR_E_IO _SHR_E_IO 40 #define SHR_E_ACCESS _SHR_E_ACCESS 41 #define SHR_E_NO_HANDLER _SHR_E_NO_HANDLER 42 #define SHR_E_PARTIAL _SHR_E_PARTIAL 43 44 #define SHR_SUCCESS(rv) _SHR_E_SUCCESS(rv) 45 #define SHR_FAILURE(rv) _SHR_E_FAILURE(rv) 46 47 #define _BCM_FIELD_COMP_NULL_CHECK(_ptr) \ 48 do { \ 49 if ((_ptr) == NULL) { \ 50 goto exit; \ 51 } \ 52 } while (0) 53 54 #define _BCM_FIELD_COMP_ALLOC(_ptr, _sz, _str) \ 55 do \ 56 { \ 57 if ((_ptr) == NULL) { \ 58 (_ptr) = sal_alloc(_sz, _str); \ 59 } else { \ 60 goto exit; \ 61 } \ 62 _BCM_FIELD_COMP_NULL_CHECK(_ptr); \ 63 sal_memset(_ptr, 0, _sz); \ 64 } while(0) 65 66 #define _BCM_FIELD_COMP_FREE(_ptr) \ 67 do { \ 68 if ((_ptr) != NULL) { \ 69 sal_free((void *)(_ptr)); \ 70 (_ptr) = NULL; \ 71 } \ 72 } while (0) 73 74 #endif /* _BCM_FIELD_COMPRESSION_H */ 75