Skip to content

Commit

Permalink
ensure Clz/Ctz functions remain visible
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
Axel Heider committed Apr 18, 2024
1 parent e69c60a commit 8da913e
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,34 +413,43 @@ static UNUSED CONST inline unsigned ctz64(uint64_t x)
return count;
}

// GCC's builtins will emit calls to these functions when the platform does
// not provide suitable inline assembly.
// These are only provided when the relevant config items are set.
// We define these separately from `ctz32` etc. so that we can verify all of
// `ctz32` etc. without necessarily linking them into the kernel binary.
// The compiler builtins will emit calls to these functions when the platform
// does not provide suitable inline assembly. These are only provided when the
// relevant config items are set. We define these separately from `ctz32` etc.
// so that we can verify all of `ctz32` etc. without necessarily linking them
// into the kernel binary. Explicitly using 'VISIBLE' is required for
// CONFIG_KERNEL_FWHOLE_PROGRAM, otherwise the symbols are removed due to
// inlining, which leads to linking failures evenutally.

#ifdef CONFIG_KERNEL_FWHOLE_PROGRAM
#define CxZxi2_VISIBLE VISIBLE
#else
#define CxZxi2_VISIBLE
#endif

#ifdef CONFIG_CLZ_32
CONST int __clzsi2(uint32_t x)
CONST int CxZxi2_VISIBLE __clzsi2(uint32_t x)
{
return clz32(x);
}
#endif

#ifdef CONFIG_CLZ_64
CONST int __clzdi2(uint64_t x)
CONST int CxZxi2_VISIBLE __clzdi2(uint64_t x)
{
return clz64(x);
}
#endif

#ifdef CONFIG_CTZ_32
CONST int __ctzsi2(uint32_t x)
CONST int CxZxi2_VISIBLE __ctzsi2(uint32_t x)
{
return ctz32(x);
}
#endif

#ifdef CONFIG_CTZ_64
CONST int __ctzdi2(uint64_t x)
CONST int CxZxi2_VISIBLE __ctzdi2(uint64_t x)
{
return ctz64(x);
}
Expand Down

0 comments on commit 8da913e

Please sign in to comment.