Commit 5e535080 authored by Norbert Lange via Xenomai's avatar Norbert Lange via Xenomai Committed by Jan Kiszka

Rename __ctz to xenomai_count_trailing_zeros

Because of conflicts with libc++ (v1/bit include file).
Simplify the macro as there shouldn't be any bad cornercases
Signed-off-by: default avatarNorbert Lange <norbert.lange@andritz.com>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 865b8ecc
...@@ -71,27 +71,16 @@ ...@@ -71,27 +71,16 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void __invalid_operand_size(void); void __invalid_operand_size(void);
#define __ctz(__v) \ #define xenomai_count_trailing_zeros(x) \
({ \ ((x) == 0 ? (int)(sizeof(x) * __CHAR_BIT__) \
int __ret; \ : sizeof(x) <= sizeof(unsigned int) ? \
if (!__v) \ __builtin_ctz((unsigned int)x) \
__ret = sizeof(__v) * 8; \ : sizeof(x) <= sizeof(unsigned long) ? \
else \ __builtin_ctzl((unsigned long)x) \
switch (sizeof(__v)) { \ : __builtin_ctzll(x))
case sizeof(int): \
__ret = __builtin_ctz((unsigned int)__v); \
break; \
case sizeof(long long): \
__ret = __builtin_ctzll(__v); \
break; \
default: \
__invalid_operand_size(); \
} \
__ret; \
})
#define xenomai_count_leading_zeros(__v) \ #define xenomai_count_leading_zeros(__v) \
({ \ ({ \
...@@ -111,9 +100,9 @@ void __invalid_operand_size(void); ...@@ -111,9 +100,9 @@ void __invalid_operand_size(void);
} \ } \
__ret; \ __ret; \
}) })
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _BOILERPLATE_COMPILER_H */ #endif /* _BOILERPLATE_COMPILER_H */
...@@ -476,7 +476,7 @@ void *heapmem_alloc(struct heap_memory *heap, size_t size) ...@@ -476,7 +476,7 @@ void *heapmem_alloc(struct heap_memory *heap, size_t size)
bmask = ext->pagemap[pg].map; bmask = ext->pagemap[pg].map;
if (bmask == -1U) if (bmask == -1U)
break; break;
b = __ctz(~bmask); b = xenomai_count_trailing_zeros(~bmask);
/* /*
* Got one block from the heading per-bucket * Got one block from the heading per-bucket
......
...@@ -529,7 +529,7 @@ static void *sheapmem_alloc(struct shared_heap_memory *heap, size_t size) ...@@ -529,7 +529,7 @@ static void *sheapmem_alloc(struct shared_heap_memory *heap, size_t size)
bmask = ext->pagemap[pg].map; bmask = ext->pagemap[pg].map;
if (bmask == -1U) if (bmask == -1U)
break; break;
b = __ctz(~bmask); b = xenomai_count_trailing_zeros(~bmask);
/* /*
* Got one block from the heading per-bucket * Got one block from the heading per-bucket
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment