diff mbox series

[4/5] ring: rename local variables for Windows compatibility

Message ID 20210915214052.143098-5-dmitry.kozliuk@gmail.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series lib: Windows compatibility renaming | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Dmitry Kozlyuk Sept. 15, 2021, 9:40 p.m. UTC
Windows SDK headers define `max` macro which breaks the definitions
of `max` variable inside inline functions. Rename the variables
to allow inclusion of both DPDK and Windows headers in the same file.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 lib/ring/rte_ring_c11_pvt.h      | 8 ++++----
 lib/ring/rte_ring_generic_pvt.h  | 8 ++++----
 lib/ring/rte_ring_rts_elem_pvt.h | 6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)

Comments

Honnappa Nagarahalli Sept. 15, 2021, 10:31 p.m. UTC | #1
<snip>

> 
> Windows SDK headers define `max` macro which breaks the definitions of
> `max` variable inside inline functions. Rename the variables to allow inclusion
> of both DPDK and Windows headers in the same file.
Minor comment, typically we include the error message in the commit log. In this case, even though it is obvious, it does not hurt to include it.

> 
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

> ---
>  lib/ring/rte_ring_c11_pvt.h      | 8 ++++----
>  lib/ring/rte_ring_generic_pvt.h  | 8 ++++----  lib/ring/rte_ring_rts_elem_pvt.h
> | 6 +++---
>  3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/lib/ring/rte_ring_c11_pvt.h b/lib/ring/rte_ring_c11_pvt.h index
> 37e0b2afd6..ec6be12154 100644
> --- a/lib/ring/rte_ring_c11_pvt.h
> +++ b/lib/ring/rte_ring_c11_pvt.h
> @@ -58,13 +58,13 @@ __rte_ring_move_prod_head(struct rte_ring *r,
> unsigned int is_sp,  {
>  	const uint32_t capacity = r->capacity;
>  	uint32_t cons_tail;
> -	unsigned int max = n;
> +	unsigned int maximum = n;
>  	int success;
> 
>  	*old_head = __atomic_load_n(&r->prod.head, __ATOMIC_RELAXED);
>  	do {
>  		/* Reset n to the initial burst count */
> -		n = max;
> +		n = maximum;
> 
>  		/* Ensure the head is read before tail */
>  		__atomic_thread_fence(__ATOMIC_ACQUIRE);
> @@ -132,7 +132,7 @@ __rte_ring_move_cons_head(struct rte_ring *r, int
> is_sc,
>  		uint32_t *old_head, uint32_t *new_head,
>  		uint32_t *entries)
>  {
> -	unsigned int max = n;
> +	unsigned int maximum = n;
>  	uint32_t prod_tail;
>  	int success;
> 
> @@ -140,7 +140,7 @@ __rte_ring_move_cons_head(struct rte_ring *r, int
> is_sc,
>  	*old_head = __atomic_load_n(&r->cons.head, __ATOMIC_RELAXED);
>  	do {
>  		/* Restore n as it may change every loop */
> -		n = max;
> +		n = maximum;
> 
>  		/* Ensure the head is read before tail */
>  		__atomic_thread_fence(__ATOMIC_ACQUIRE);
> diff --git a/lib/ring/rte_ring_generic_pvt.h b/lib/ring/rte_ring_generic_pvt.h
> index c95ad7e12c..beb3140e78 100644
> --- a/lib/ring/rte_ring_generic_pvt.h
> +++ b/lib/ring/rte_ring_generic_pvt.h
> @@ -58,12 +58,12 @@ __rte_ring_move_prod_head(struct rte_ring *r,
> unsigned int is_sp,
>  		uint32_t *free_entries)
>  {
>  	const uint32_t capacity = r->capacity;
> -	unsigned int max = n;
> +	unsigned int maximum = n;
>  	int success;
> 
>  	do {
>  		/* Reset n to the initial burst count */
> -		n = max;
> +		n = maximum;
> 
>  		*old_head = r->prod.head;
> 
> @@ -127,13 +127,13 @@ __rte_ring_move_cons_head(struct rte_ring *r,
> unsigned int is_sc,
>  		uint32_t *old_head, uint32_t *new_head,
>  		uint32_t *entries)
>  {
> -	unsigned int max = n;
> +	unsigned int maximum = n;
>  	int success;
> 
>  	/* move cons.head atomically */
>  	do {
>  		/* Restore n as it may change every loop */
> -		n = max;
> +		n = maximum;
> 
>  		*old_head = r->cons.head;
> 
> diff --git a/lib/ring/rte_ring_rts_elem_pvt.h
> b/lib/ring/rte_ring_rts_elem_pvt.h
> index 7164213ee0..6241f28dc0 100644
> --- a/lib/ring/rte_ring_rts_elem_pvt.h
> +++ b/lib/ring/rte_ring_rts_elem_pvt.h
> @@ -53,11 +53,11 @@ static __rte_always_inline void
> __rte_ring_rts_head_wait(const struct rte_ring_rts_headtail *ht,
>  	union __rte_ring_rts_poscnt *h)
>  {
> -	uint32_t max;
> +	uint32_t maximum;
> 
> -	max = ht->htd_max;
> +	maximum = ht->htd_max;
> 
> -	while (h->val.pos - ht->tail.val.pos > max) {
> +	while (h->val.pos - ht->tail.val.pos > maximum) {
>  		rte_pause();
>  		h->raw = __atomic_load_n(&ht->head.raw,
> __ATOMIC_ACQUIRE);
>  	}
> --
> 2.29.3
diff mbox series

Patch

diff --git a/lib/ring/rte_ring_c11_pvt.h b/lib/ring/rte_ring_c11_pvt.h
index 37e0b2afd6..ec6be12154 100644
--- a/lib/ring/rte_ring_c11_pvt.h
+++ b/lib/ring/rte_ring_c11_pvt.h
@@ -58,13 +58,13 @@  __rte_ring_move_prod_head(struct rte_ring *r, unsigned int is_sp,
 {
 	const uint32_t capacity = r->capacity;
 	uint32_t cons_tail;
-	unsigned int max = n;
+	unsigned int maximum = n;
 	int success;
 
 	*old_head = __atomic_load_n(&r->prod.head, __ATOMIC_RELAXED);
 	do {
 		/* Reset n to the initial burst count */
-		n = max;
+		n = maximum;
 
 		/* Ensure the head is read before tail */
 		__atomic_thread_fence(__ATOMIC_ACQUIRE);
@@ -132,7 +132,7 @@  __rte_ring_move_cons_head(struct rte_ring *r, int is_sc,
 		uint32_t *old_head, uint32_t *new_head,
 		uint32_t *entries)
 {
-	unsigned int max = n;
+	unsigned int maximum = n;
 	uint32_t prod_tail;
 	int success;
 
@@ -140,7 +140,7 @@  __rte_ring_move_cons_head(struct rte_ring *r, int is_sc,
 	*old_head = __atomic_load_n(&r->cons.head, __ATOMIC_RELAXED);
 	do {
 		/* Restore n as it may change every loop */
-		n = max;
+		n = maximum;
 
 		/* Ensure the head is read before tail */
 		__atomic_thread_fence(__ATOMIC_ACQUIRE);
diff --git a/lib/ring/rte_ring_generic_pvt.h b/lib/ring/rte_ring_generic_pvt.h
index c95ad7e12c..beb3140e78 100644
--- a/lib/ring/rte_ring_generic_pvt.h
+++ b/lib/ring/rte_ring_generic_pvt.h
@@ -58,12 +58,12 @@  __rte_ring_move_prod_head(struct rte_ring *r, unsigned int is_sp,
 		uint32_t *free_entries)
 {
 	const uint32_t capacity = r->capacity;
-	unsigned int max = n;
+	unsigned int maximum = n;
 	int success;
 
 	do {
 		/* Reset n to the initial burst count */
-		n = max;
+		n = maximum;
 
 		*old_head = r->prod.head;
 
@@ -127,13 +127,13 @@  __rte_ring_move_cons_head(struct rte_ring *r, unsigned int is_sc,
 		uint32_t *old_head, uint32_t *new_head,
 		uint32_t *entries)
 {
-	unsigned int max = n;
+	unsigned int maximum = n;
 	int success;
 
 	/* move cons.head atomically */
 	do {
 		/* Restore n as it may change every loop */
-		n = max;
+		n = maximum;
 
 		*old_head = r->cons.head;
 
diff --git a/lib/ring/rte_ring_rts_elem_pvt.h b/lib/ring/rte_ring_rts_elem_pvt.h
index 7164213ee0..6241f28dc0 100644
--- a/lib/ring/rte_ring_rts_elem_pvt.h
+++ b/lib/ring/rte_ring_rts_elem_pvt.h
@@ -53,11 +53,11 @@  static __rte_always_inline void
 __rte_ring_rts_head_wait(const struct rte_ring_rts_headtail *ht,
 	union __rte_ring_rts_poscnt *h)
 {
-	uint32_t max;
+	uint32_t maximum;
 
-	max = ht->htd_max;
+	maximum = ht->htd_max;
 
-	while (h->val.pos - ht->tail.val.pos > max) {
+	while (h->val.pos - ht->tail.val.pos > maximum) {
 		rte_pause();
 		h->raw = __atomic_load_n(&ht->head.raw, __ATOMIC_ACQUIRE);
 	}