Skip to content

Commit

Permalink
Revert "Remove useless define from clzdi2 and ctzdi2"
Browse files Browse the repository at this point in the history
This reverts commit 1d54852.
  • Loading branch information
mintsuki committed Aug 10, 2024
1 parent 1d54852 commit 2cf5ef4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions clzdi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@

// Returns: the number of leading 0-bits

#if !defined(__clang__) && \
((defined(__sparc__) && defined(__arch64__)) || defined(__mips64) || \
(defined(__riscv) && __SIZEOF_POINTER__ >= 8))
// On 64-bit architectures with neither a native clz instruction nor a native
// ctz instruction, gcc resolves __builtin_clz to __clzdi2 rather than
// __clzsi2, leading to infinite recursion.
#define __builtin_clz(a) __clzsi2(a)
extern int __clzsi2(si_int);
#endif

// Precondition: a != 0

COMPILER_RT_ABI int __clzdi2(di_int a) {
Expand Down
10 changes: 10 additions & 0 deletions ctzdi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@

// Returns: the number of trailing 0-bits

#if !defined(__clang__) && \
((defined(__sparc__) && defined(__arch64__)) || defined(__mips64) || \
(defined(__riscv) && __SIZEOF_POINTER__ >= 8))
// On 64-bit architectures with neither a native clz instruction nor a native
// ctz instruction, gcc resolves __builtin_ctz to __ctzdi2 rather than
// __ctzsi2, leading to infinite recursion.
#define __builtin_ctz(a) __ctzsi2(a)
extern int __ctzsi2(si_int);
#endif

// Precondition: a != 0

COMPILER_RT_ABI int __ctzdi2(di_int a) {
Expand Down

0 comments on commit 2cf5ef4

Please sign in to comment.