Skip to contentSkip to conversation

rte_reciprocal: make arg to rte_reciprocal_divide_u64 const

PATCH Applied Stephen Hemminger 3 participants 6 messages Mar 21, 2019 – Apr 3, 2019 Broadcom iproc Arm architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rte_reciprocal: make arg to rte_reciprocal_divide_u64 const

The divisor is not modified here. Doesn't really matter for optimizaton since the function is inline already; but helps with expressing intent.

---
 lib/librte_eal/common/include/rte_reciprocal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/include/rte_reciprocal.h +1 -1
index 3492c73bafea..63e16fde0aa8 100644
@@ -77,7 +77,7 @@ mullhi_u64(uint64_t x, uint64_t y)
 }
 
 static __rte_always_inline uint64_t
-rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R)
+rte_reciprocal_divide_u64(uint64_t a, const struct rte_reciprocal_u64 *R)
 {
 	uint64_t t = mullhi_u64(a, R->m);
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Stephen Hemminger

The divisor is not modified here. Doesn't really matter for optimizaton since the function is inline already; but helps with expressing intent.

---
  lib/librte_eal/common/include/rte_reciprocal.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/include/rte_reciprocal.h +0 -0
index 3492c73bafea..63e16fde0aa8 100644

lib/librte_eal/common/include/rte_reciprocal.h mullhi_u64(uint64_t x, uint64_t y) · line 83

Quoted 8 lines
lib/librte_eal/common/include/rte_reciprocal.h +1 -1
@@ -77,7 +77,7 @@ mullhi_u64(uint64_t x, uint64_t y)
  }
 
  static __rte_always_inline uint64_t
-rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R)
+rte_reciprocal_divide_u64(uint64_t a, const struct rte_reciprocal_u64 *R)
  {
  	uint64_t t = mullhi_u64(a, R->m);
 
#3 lore raw
In reply to Stephen Hemminger

21/03/2019 20:59, Stephen Hemminger:

lib/librte_eal/common/include/rte_reciprocal.h mullhi_u64(uint64_t x, uint64_t y) · line 80

Quoted 9 lines

The divisor is not modified here. Doesn't really matter for optimizaton since the function is inline already; but helps with expressing intent.

---
static __rte_always_inline uint64_t

lib/librte_eal/common/include/rte_reciprocal.h +1 -1
-rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R)
+rte_reciprocal_divide_u64(uint64_t a, const struct rte_reciprocal_u64 *R)

Why not doing the same change for rte_reciprocal_divide()?

Should we advertise such API change?

#4 lore raw
Quoted 5 lines · On Wed, 27 Mar 2019 12:14:44 +0100 Thomas Monjalon <[email protected]> wrote:

21/03/2019 20:59, Stephen Hemminger:

Quoted 4 lines

The divisor is not modified here. Doesn't really matter for optimizaton since the function is inline already; but helps with expressing intent.

Quoted 7 lines

lib/librte_eal/common/include/rte_reciprocal.h mullhi_u64(uint64_t x, uint64_t y) · line 80

Quoted 5 lines

---
static __rte_always_inline uint64_t

lib/librte_eal/common/include/rte_reciprocal.h +1 -1
-rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R)
+rte_reciprocal_divide_u64(uint64_t a, const struct rte_reciprocal_u64 *R)  

Why not doing the same change for rte_reciprocal_divide()?

It doesn't make sense for rte_reciprocal_divide since rte_reciprocal_divide is call by value (ie doesn't take a pointer).

Quoted 1 line

Should we advertise such API change?

No. Since constant is always less intrusive than previous version all cases will work the same.

#5 lore raw

02/04/2019 17:26, Stephen Hemminger:

Quoted 15 lines
Quoted 5 lines · On Wed, 27 Mar 2019 12:14:44 +0100 Thomas Monjalon <[email protected]> wrote:

21/03/2019 20:59, Stephen Hemminger:

Quoted 4 lines

The divisor is not modified here. Doesn't really matter for optimizaton since the function is inline already; but helps with expressing intent.

Quoted 7 lines

lib/librte_eal/common/include/rte_reciprocal.h mullhi_u64(uint64_t x, uint64_t y) · line 80

Quoted 5 lines

---
static __rte_always_inline uint64_t

lib/librte_eal/common/include/rte_reciprocal.h +1 -1
-rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R)
+rte_reciprocal_divide_u64(uint64_t a, const struct rte_reciprocal_u64 *R)  

Why not doing the same change for rte_reciprocal_divide()?

Quoted 2 lines

It doesn't make sense for rte_reciprocal_divide since rte_reciprocal_divide is call by value (ie doesn't take a pointer).

Oh, you're right.

Quoted 4 lines
Quoted 1 line

Should we advertise such API change?

No. Since constant is always less intrusive than previous version all cases will work the same.

Yes OK