zephyr/scripts/native_simulator/common/src/nsi_internal.h
Alberto Escolar Piedras bc5da1a158 native simulator: Get latest from upstream
Align with native_simulator's upstream main
d32b2504ad2b6d6d541bc71a0f9b16ab7b6a3831

Which includes:
* d32b250 Minor format fix
* 7b4f35b native HW counter: Provide new API to reset and control
* 4f815cb INT CNTLR: Bugfix for more than 32 interrupts
* 1d36254 Provide new 64 version of nsi_find_lsb_set

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-20 15:20:43 +02:00

53 lines
1.3 KiB
C

/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef NSI_COMMON_SRC_NSI_INTERNAL_H
#define NSI_COMMON_SRC_NSI_INTERNAL_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief find least significant bit set in a 32-bit word
*
* This routine finds the first bit set starting from the least significant bit
* in the argument passed in and returns the index of that bit. Bits are
* numbered starting at 1 from the least significant bit. A return value of
* zero indicates that the value passed is zero.
*
* @return least significant bit set, 0 if @a op is 0
*/
static inline unsigned int nsi_find_lsb_set(uint32_t op)
{
return __builtin_ffs(op);
}
/**
* @brief find least significant bit set in a 64-bit word
*
* This routine finds the first bit set starting from the least significant bit
* in the argument passed in and returns the index of that bit. Bits are
* numbered starting at 1 from the least significant bit. A return value of
* zero indicates that the value passed is zero.
*
* @return least significant bit set, 0 if @a op is 0
*/
static inline unsigned int nsi_find_lsb_set64(uint64_t op)
{
return __builtin_ffsll(op);
}
#ifdef __cplusplus
}
#endif
#endif /* NSI_COMMON_SRC_NSI_INTERNAL_H */