summaryrefslogtreecommitdiff
path: root/bsp/hpmicro/libraries/hpm_sdk/utils/hpm_ffssi.c
blob: 3db7cd3651927eddda4c91fc7b7aa203fbc6a2b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * 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;
}