Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 93327c3

Browse files
committed
Ensure no macro leakage between .c files
1 parent ccb0ec7 commit 93327c3

File tree

6 files changed

+22
-0
lines changed

6 files changed

+22
-0
lines changed

clzdi2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
// On 64-bit architectures with neither a native clz instruction nor a native
2323
// ctz instruction, gcc resolves __builtin_clz to __clzdi2 rather than
2424
// __clzsi2, leading to infinite recursion.
25+
#ifdef __builtin_clz
26+
#undef __builtin_clz
27+
#endif
2528
#define __builtin_clz(a) __clzsi2(a)
2629
extern int __clzsi2(si_int);
2730
#endif

ctzdi2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
// On 64-bit architectures with neither a native clz instruction nor a native
2323
// ctz instruction, gcc resolves __builtin_ctz to __ctzdi2 rather than
2424
// __ctzsi2, leading to infinite recursion.
25+
#ifdef __builtin_ctz
26+
#undef __builtin_ctz
27+
#endif
2528
#define __builtin_ctz(a) __ctzsi2(a)
2629
extern int __ctzsi2(si_int);
2730
#endif

udivdi3.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
// Returns: a / b
1818

19+
#ifdef
1920
#undef clz
21+
#endif
2022
#define clz(a) (sizeof(a) == sizeof(unsigned long long) ? __builtin_clzll(a) : clzsi(a))
2123

2224
// Adapted from Figure 3-40 of The PowerPC Compiler Writer's Guide
@@ -47,3 +49,5 @@ COMPILER_RT_ABI du_int __udivdi3(du_int n, du_int d) {
4749
n = (n << 1) | carry;
4850
return n;
4951
}
52+
53+
#undef clz

udivsi3.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
// Returns: a / b
1818

19+
#ifdef
1920
#undef clz
21+
#endif
2022
#define clz(a) (sizeof(a) == sizeof(unsigned long long) ? __builtin_clzll(a) : clzsi(a))
2123

2224
// Adapted from Figure 3-40 of The PowerPC Compiler Writer's Guide
@@ -48,6 +50,8 @@ COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d) {
4850
return n;
4951
}
5052

53+
#undef clz
54+
5155
#if defined(__ARM_EABI__)
5256
COMPILER_RT_ALIAS(__udivsi3, __aeabi_uidiv)
5357
#endif

umoddi3.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
// Returns: a % b
1818

19+
#ifdef clz
1920
#undef clz
21+
#endif
2022
#define clz(a) (sizeof(a) == sizeof(unsigned long long) ? __builtin_clzll(a) : clzsi(a))
2123

2224
// Mostly identical to __udivdi3 but the return values are different.
@@ -46,3 +48,5 @@ COMPILER_RT_ABI du_int __umoddi3(du_int n, du_int d) {
4648
}
4749
return r;
4850
}
51+
52+
#undef clz

umodsi3.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
// Returns: a % b
1818

19+
#ifdef clz
1920
#undef clz
21+
#endif
2022
#define clz(a) (sizeof(a) == sizeof(unsigned long long) ? __builtin_clzll(a) : clzsi(a))
2123

2224
// Mostly identical to __udivsi3 but the return values are different.
@@ -46,3 +48,5 @@ COMPILER_RT_ABI su_int __umodsi3(su_int n, su_int d) {
4648
}
4749
return r;
4850
}
51+
52+
#undef clz

0 commit comments

Comments
 (0)