rt-thread-official/bsp/hpmicro/libraries/hpm_sdk/utils/hpm_ffssi.c

23 lines
316 B
C

/*
* Copyright (c) 2021 hpmicro
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include "hpm_common.h"
int __ffssi2(int x)
{
int i = 0;
if (!x) {
return 0;
}
for (i = 0; (i < sizeof(x) * 8 - 1); i++) {
if ((x >> i) & 1) {
break;
}
}
return i + 1;
}