• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __HVB_GM_COMMON_H__
16 #define __HVB_GM_COMMON_H__
17 
18 #include <stdint.h>
19 #include "hvb_gm_log.h"
20 
21 #ifndef htobe32
22 #define htobe32(value)                                            \
23     ((((value)&0x000000FF) << 24) | (((value)&0x0000FF00) << 8) | (((value)&0x00FF0000) >> 8) | \
24         (((value)&0xFF000000) >> 24))
25 #endif
26 
27 #ifndef word2byte
28 #define word2byte(w)              ((w) * sizeof(uint32_t))
29 #endif
30 
31 #ifndef byte2bit
32 #define byte2bit(bytes)     ((bytes) << 3)
33 #endif
34 
35 #ifndef u16_inv
36 #define u16_inv(v)          ((((v) & 0x00FF) << 8) | (((v) & 0xFF00) >> 8))
37 #endif
38 
39 #ifndef array_size
40 #define array_size(x)       (sizeof(x) / sizeof((x)[0]))
41 #endif
42 
43 #endif
44