Skip to contentSkip to conversation

Rename __clz to xenomai_count_leading_zeros

PATCH Applied Giulio Moro 2 participants 3 messages Nov 22, 2018 – Nov 23, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Rename __clz to xenomai_count_leading_zeros

Quoted 1 line

From 398a77d3d172c10cda9826a7cc2a15266ff4c6a9 Mon Sep 17 00:00:00 2001

From: Giulio Moro <[email protected]>
Date: Sat, 10 Nov 2018 20:23:10 +0000
Subject: [PATCH] Rename __clz to xenomai_count_leading_zeros.

This is to avoid namespace conflicts (e.g.: with Clang's arm_acle.h)

---
 include/boilerplate/compiler.h    | 2 +-
 lib/boilerplate/heapmem.c         | 3 ++-
 lib/copperplate/heapobj-heapmem.c | 3 ++-
 lib/copperplate/heapobj-pshared.c | 3 ++-
 4 files changed, 7 insertions(+), 4 deletions(-)
include/boilerplate/compiler.h +1 -1
index ffeb6a4db..0fcc17be1 100644
@@ -93,7 +93,7 @@ void __invalid_operand_size(void);
 		__ret;							\
 	})
 
-#define __clz(__v)							\
+#define xenomai_count_leading_zeros(__v)				\
 	({								\
 		int __ret;						\
 		if (!__v)						\
lib/boilerplate/heapmem.c +2 -1
index 9b5e1a636..8728e0d15 100644
@@ -435,7 +435,8 @@ void *heapmem_alloc(struct heap_memory *heap, size_t size)
 		bsize = size = HEAPMEM_MIN_ALIGN;
 		log2size = HEAPMEM_MIN_LOG2;
 	} else {
-		log2size = sizeof(size) * CHAR_BIT - 1 - __clz(size);
+		log2size = sizeof(size) * CHAR_BIT - 1 -
+			xenomai_count_leading_zeros(size);
 		if (log2size < HEAPMEM_PAGE_SHIFT) {
 			if (size & (size - 1))
 				log2size++;
lib/copperplate/heapobj-heapmem.c +2 -1
index 2b99b3d39..2737fa7ac 100644
@@ -68,7 +68,8 @@ int __heapobj_init_private(struct heapobj *hobj, const char *name,
 int heapobj_init_array_private(struct heapobj *hobj, const char *name,
 			       size_t size, int elems)
 {
-	size_t log2 = sizeof(size) * CHAR_BIT - 1 - __clz(size);
+	size_t log2 = sizeof(size) * CHAR_BIT - 1 -
+		xenomai_count_leading_zeros(size);
 
 	/*
 	 * Heapmem aligns individual object sizes on the next ^2
lib/copperplate/heapobj-pshared.c +2 -1
index 77b45844f..5310d9092 100644
@@ -488,7 +488,8 @@ static void *sheapmem_alloc(struct shared_heap_memory *heap, size_t size)
 		bsize = size = SHEAPMEM_MIN_ALIGN;
 		log2size = SHEAPMEM_MIN_LOG2;
 	} else {
-		log2size = sizeof(size) * CHAR_BIT - 1 - __clz(size);
+		log2size = sizeof(size) * CHAR_BIT - 1 -
+			xenomai_count_leading_zeros(size);
 		if (log2size < SHEAPMEM_PAGE_SHIFT) {
 			if (size & (size - 1))
 				log2size++;

--
2.11.0

Applied
#1 lore raw
Quoted 71 lines · Giulio Moro via Xenomai

From 398a77d3d172c10cda9826a7cc2a15266ff4c6a9 Mon Sep 17 00:00:00 2001
From: Giulio Moro <[email protected]>
Date: Sat, 10 Nov 2018 20:23:10 +0000
Subject: [PATCH] Rename __clz to xenomai_count_leading_zeros.

This is to avoid namespace conflicts (e.g.: with Clang's arm_acle.h)

---
  include/boilerplate/compiler.h    | 2 +-
  lib/boilerplate/heapmem.c         | 3 ++-
  lib/copperplate/heapobj-heapmem.c | 3 ++-
  lib/copperplate/heapobj-pshared.c | 3 ++-
  4 files changed, 7 insertions(+), 4 deletions(-)
include/boilerplate/compiler.h +1 -1
index ffeb6a4db..0fcc17be1 100644
@@ -93,7 +93,7 @@ void __invalid_operand_size(void);
  		__ret;							\
  	})
 
-#define __clz(__v)							\
+#define xenomai_count_leading_zeros(__v)				\
  	({								\
  		int __ret;						\
  		if (!__v)						\
lib/boilerplate/heapmem.c +2 -1
index 9b5e1a636..8728e0d15 100644
@@ -435,7 +435,8 @@ void *heapmem_alloc(struct heap_memory *heap, size_t size)
  		bsize = size = HEAPMEM_MIN_ALIGN;
  		log2size = HEAPMEM_MIN_LOG2;
  	} else {
-		log2size = sizeof(size) * CHAR_BIT - 1 - __clz(size);
+		log2size = sizeof(size) * CHAR_BIT - 1 -
+			xenomai_count_leading_zeros(size);
  		if (log2size < HEAPMEM_PAGE_SHIFT) {
  			if (size & (size - 1))
  				log2size++;
lib/copperplate/heapobj-heapmem.c +2 -1
index 2b99b3d39..2737fa7ac 100644
@@ -68,7 +68,8 @@ int __heapobj_init_private(struct heapobj *hobj, const char *name,
  int heapobj_init_array_private(struct heapobj *hobj, const char *name,
  			       size_t size, int elems)
  {
-	size_t log2 = sizeof(size) * CHAR_BIT - 1 - __clz(size);
+	size_t log2 = sizeof(size) * CHAR_BIT - 1 -
+		xenomai_count_leading_zeros(size);
 
  	/*
  	 * Heapmem aligns individual object sizes on the next ^2
lib/copperplate/heapobj-pshared.c +2 -2
index 77b45844f..5310d9092 100644
@@ -488,7 +488,8 @@ static void *sheapmem_alloc(struct shared_heap_memory *heap, size_t size)
  		bsize = size = SHEAPMEM_MIN_ALIGN;
  		log2size = SHEAPMEM_MIN_LOG2;
  	} else {
-		log2size = sizeof(size) * CHAR_BIT - 1 - __clz(size);
+		log2size = sizeof(size) * CHAR_BIT - 1 -
+			xenomai_count_leading_zeros(size);
  		if (log2size < SHEAPMEM_PAGE_SHIFT) {
  			if (size & (size - 1))
  				log2size++;
--
Quoted 3 lines

2.11.0

Thanks, applied to next.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#2 lore raw

PATCH 1/1 Rename __clz to xenomai_count_leading_zeros

From: Giulio Moro <[email protected]>

This is to avoid namespace conflicts (e.g.: with Clang's arm_acle.h)

[Jan: back-ported to 3.0.x]
---
 include/boilerplate/compiler.h    | 2 +-
 lib/copperplate/heapobj-pshared.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
include/boilerplate/compiler.h +1 -1
index bcef7d4cc8..846cd79e82 100644
@@ -83,7 +83,7 @@ void __invalid_operand_size(void);
 		__ret;							\
 	})
 
-#define __clz(__v)							\
+#define xenomai_count_leading_zeros(__v)				\
 	({								\
 		int __ret;						\
 		if (!__v)						\
lib/copperplate/heapobj-pshared.c +2 -1
index d4324dfd11..0d640ca5b5 100644
@@ -439,7 +439,8 @@ static void *alloc_block(struct shared_heap *heap, size_t size)
 	 */
 	if (size <= HOBJ_PAGE_SIZE * 2) {
 		/* Find log2(size). */
-		log2size = sizeof(size) * 8 - 1 - __clz(size);
+		log2size = sizeof(size) * 8 - 1 -
+			xenomai_count_leading_zeros(size);
 		if (size & (size - 1))
 			log2size++;
 		/* That is the actual block size we need. */
Signature · 1 line
2.16.4