summaryrefslogtreecommitdiff
path: root/core/riscv-rv32i/__builtin.c
blob: 4bf495a0114bfde816c08b64977f6c2cf91caeb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* Copyright 2019 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "common.h"

/*
 * __builtin_ffs:
 * Returns one plus the index of the least significant 1-bit of x,
 * or if x is zero, returns zero.
 */
int __keep __ffssi2(int x)
{
	return 32 - __builtin_clz(x & -x);
}