rename reverse_bits to bits and move functions to count bits in there
This commit is contained in:
@@ -16,7 +16,7 @@ add_subdirectory(nr)
|
||||
add_subdirectory(LOG)
|
||||
add_subdirectory(threadPool)
|
||||
add_subdirectory(time_manager)
|
||||
add_library(utils utils.c system.c time_meas.c time_stat.c tuntap_if.c reverse_bits.c fsn.c)
|
||||
add_library(utils utils.c system.c time_meas.c time_stat.c tuntap_if.c bits.c fsn.c)
|
||||
target_include_directories(utils PUBLIC .)
|
||||
target_link_libraries(utils PRIVATE ${T_LIB})
|
||||
add_subdirectory(barrier)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
|
||||
*/
|
||||
|
||||
#include "reverse_bits.h"
|
||||
#include "bits.h"
|
||||
// we avoid assertions.h as it necessitates othe dependencies (e.g., exit_function)
|
||||
#include <assert.h>
|
||||
#include <simde/x86/gfni.h>
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
|
||||
*/
|
||||
|
||||
#ifndef BITS_H_
|
||||
#define BITS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "assertions.h"
|
||||
|
||||
uint64_t reverse_bits(uint64_t in, int n_bits);
|
||||
void reverse_bits_u8(uint8_t const* in, size_t sz, uint8_t* out);
|
||||
|
||||
static inline int count_bits(uint8_t *arr, int sz)
|
||||
{
|
||||
AssertFatal(sz % sizeof(int) == 0, "to implement if needed\n");
|
||||
int ret = 0;
|
||||
for (uint *ptr = (uint *)arr; (uint8_t *)ptr < arr + sz; ptr++)
|
||||
ret += __builtin_popcount(*ptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __attribute__((always_inline)) inline int count_bits64(uint64_t v)
|
||||
{
|
||||
return __builtin_popcountll(v);
|
||||
}
|
||||
|
||||
static __attribute__((always_inline)) inline int count_bits64_with_mask(uint64_t v, int start, int num)
|
||||
{
|
||||
uint64_t mask = ((1LL << num) - 1) << start;
|
||||
return count_bits64(v & mask);
|
||||
}
|
||||
#endif /* BITS_H_ */
|
||||
@@ -262,28 +262,7 @@ static inline int get_num_dmrs(uint16_t dmrs_mask )
|
||||
return(num_dmrs);
|
||||
}
|
||||
|
||||
static inline int count_bits(uint8_t *arr, int sz)
|
||||
{
|
||||
AssertFatal(sz % sizeof(int) == 0, "to implement if needed\n");
|
||||
int ret = 0;
|
||||
for (uint *ptr = (uint *)arr; (uint8_t *)ptr < arr + sz; ptr++)
|
||||
ret += __builtin_popcount(*ptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __attribute__((always_inline)) inline int count_bits64(uint64_t v)
|
||||
{
|
||||
return __builtin_popcountll(v);
|
||||
}
|
||||
|
||||
static __attribute__((always_inline)) inline int count_bits64_with_mask(uint64_t v, int start, int num)
|
||||
{
|
||||
uint64_t mask = ((1LL << num) - 1) << start;
|
||||
return count_bits64(v & mask);
|
||||
}
|
||||
|
||||
void warn_higher_threequarter_fs(const int n_rb, const int mu);
|
||||
|
||||
uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn);
|
||||
uint32_t to_nrarfcn(uint64_t dl_CarrierFreq);
|
||||
uint8_t set_ssb_case(int scs, int nr_band);
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
|
||||
*/
|
||||
|
||||
#ifndef REVERSE_BITS_H_
|
||||
#define REVERSE_BITS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
uint64_t reverse_bits(uint64_t in, int n_bits);
|
||||
void reverse_bits_u8(uint8_t const* in, size_t sz, uint8_t* out);
|
||||
|
||||
#endif /* REVERSE_BITS_H_ */
|
||||
Reference in New Issue
Block a user