• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
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  * Description: oam log printing interface
15  */
16 
17 #ifndef __WLAN_UTIL_COMMON_H__
18 #define __WLAN_UTIL_COMMON_H__
19 
20 #include "wlan_util_common_rom.h"
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27 
28 /* ****************************************************************************
29  函 数 名  : oal_bit_get_num_one_byte
30  功能描述  : 获取单字节中的bit1的个数
31 **************************************************************************** */
oal_bit_get_num_one_byte(osal_u8 byte)32 static inline osal_u8 oal_bit_get_num_one_byte(osal_u8 byte)
33 {
34     osal_u8 byte_data = byte;
35 
36     byte_data = (byte_data & 0x55) + ((byte_data >> 1) & 0x55); /* 0x55掩码, 1移位数 */
37     byte_data = (byte_data & 0x33) + ((byte_data >> 2) & 0x33); /* 0x33掩码, 2移位数 */
38     byte_data = (byte_data & 0x0F) + ((byte_data >> 4) & 0x0F); /* 0x0F掩码, 4移位数 */
39 
40     return byte_data;
41 }
42 
43 #ifdef __cplusplus
44 #if __cplusplus
45 }
46 #endif
47 #endif
48 
49 #endif /* end of wlan_util_common.h */
50