mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: posix: Fix ffs() and fls() impl in POSIX
The GCC builtins act slightly differently than the Linux versions of these functions. This patch adds the necessary glue to emulate the Linux versions identically. JIRA NVGPU-525 Change-Id: Idadbecdfd516c68f3d3eb20eca495dc1eaa02c5b Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1741951 GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
0b0b820911
commit
2ac6fb4253
@@ -29,14 +29,15 @@
|
|||||||
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
|
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
|
||||||
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
|
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
|
||||||
|
|
||||||
unsigned long __nvgpu_posix_fls(unsigned long word)
|
|
||||||
{
|
|
||||||
return __builtin_clzl(word);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long __nvgpu_posix_ffs(unsigned long word)
|
unsigned long __nvgpu_posix_ffs(unsigned long word)
|
||||||
{
|
{
|
||||||
return __builtin_ffsl(word);
|
return (__builtin_ffsl(word) - 1) &
|
||||||
|
((sizeof(unsigned long) * 8UL) - 1UL);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long __nvgpu_posix_fls(unsigned long word)
|
||||||
|
{
|
||||||
|
return ((sizeof(unsigned long) * 8UL) - 1UL) - __builtin_clzl(word);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long __find_next_bit(const unsigned long *addr,
|
static unsigned long __find_next_bit(const unsigned long *addr,
|
||||||
|
|||||||
Reference in New Issue
Block a user