Skip to contentSkip to conversation

eal/x86: fix memcpy alignment mask definition

PATCH Superseded Morten Brørup 4 participants 8 messages Sep 4 – Sep 23

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal/x86: fix memcpy alignment mask definition

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal purposes, but it is publicly exposed when including the header file, potentially colliding with existing definitions with the same name. Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the definition.

Furthermore, the superfluous function declaration at the top of the file was removed, and its description was moved to the function definition, to improve search results with source code browsers.

Fixes f5472703c0bd ("eal: optimize aligned memcpy on x86")
---
 lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 20 deletions(-)
lib/eal/x86/include/rte_memcpy.h +17 -20
index 8ed8c55010..41fb08ab95 100644
@@ -32,21 +32,6 @@ extern "C" {
 #define RTE_MEMCPY_AVX
 #endif
 
-/**
- * Copy bytes from one location to another. The locations must not overlap.
- *
- * @param dst
- *   Pointer to the destination of the data.
- * @param src
- *   Pointer to the source data.
- * @param n
- *   Number of bytes to copy.
- * @return
- *   Pointer to the destination data.
- */
-static __rte_always_inline void *
-rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
-
 /**
  * Copy bytes from one location to another,
  * locations must not overlap.
@@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t *__rte_restrict src)
  * AVX512 implementation below
  */
 
-#define ALIGNMENT_MASK 0x3F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * AVX implementation below
  */
 
-#define ALIGNMENT_MASK 0x1F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * SSE implementation below
  */
 
-#define ALIGNMENT_MASK 0x0F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
 
 /**
  * Macro for copying unaligned block from one location to another with constant load offset,
@@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void *__rte_restrict dst, const void *__rte_rest
 	return ret;
 }
 
+/**
+ * Copy bytes from one location to another. The locations must not overlap.
+ *
+ * @param dst
+ *   Pointer to the destination of the data.
+ * @param src
+ *   Pointer to the source data.
+ * @param n
+ *   Number of bytes to copy.
+ * @return
+ *   Pointer to the destination data.
+ */
 static __rte_always_inline void *
 rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 {
@@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 	}
 
 	/* Implementation for size > 64 bytes depends on alignment with vector register size. */
-	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
+	if (!(((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK))
 		return rte_memcpy_aligned_more_than_64(dst, src, n);
 	else
 		return rte_memcpy_generic_more_than_64(dst, src, n);
 }
 
-#undef ALIGNMENT_MASK
+#undef RTE_MEMCPY_ALIGNMENT_MASK
 
 #ifdef __cplusplus
 }
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/1 eal/x86: fix memcpy alignment mask definition

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal purposes, but it is publicly exposed when including the header file, potentially colliding with existing definitions with the same name. Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the definition.

Furthermore, the superfluous function declaration at the top of the file was removed, and its description was moved to the function definition, to improve search results with source code browsers.

Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK coding style.

None of these changes should have any practical effect.

Fixes f5472703c0bd ("eal: optimize aligned memcpy on x86")

---
v2:
* Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)

---
 lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 20 deletions(-)
lib/eal/x86/include/rte_memcpy.h +17 -20
index 8ed8c55010..41fb08ab95 100644
@@ -32,21 +32,6 @@ extern "C" {
 #define RTE_MEMCPY_AVX
 #endif
 
-/**
- * Copy bytes from one location to another. The locations must not overlap.
- *
- * @param dst
- *   Pointer to the destination of the data.
- * @param src
- *   Pointer to the source data.
- * @param n
- *   Number of bytes to copy.
- * @return
- *   Pointer to the destination data.
- */
-static __rte_always_inline void *
-rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
-
 /**
  * Copy bytes from one location to another,
  * locations must not overlap.
@@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t *__rte_restrict src)
  * AVX512 implementation below
  */
 
-#define ALIGNMENT_MASK 0x3F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * AVX implementation below
  */
 
-#define ALIGNMENT_MASK 0x1F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * SSE implementation below
  */
 
-#define ALIGNMENT_MASK 0x0F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
 
 /**
  * Macro for copying unaligned block from one location to another with constant load offset,
@@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void *__rte_restrict dst, const void *__rte_rest
 	return ret;
 }
 
+/**
+ * Copy bytes from one location to another. The locations must not overlap.
+ *
+ * @param dst
+ *   Pointer to the destination of the data.
+ * @param src
+ *   Pointer to the source data.
+ * @param n
+ *   Number of bytes to copy.
+ * @return
+ *   Pointer to the destination data.
+ */
 static __rte_always_inline void *
 rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 {
@@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 	}
 
 	/* Implementation for size > 64 bytes depends on alignment with vector register size. */
-	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
+	if (!(((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK))
 		return rte_memcpy_aligned_more_than_64(dst, src, n);
 	else
 		return rte_memcpy_generic_more_than_64(dst, src, n);
 }
 
-#undef ALIGNMENT_MASK
+#undef RTE_MEMCPY_ALIGNMENT_MASK
 
 #ifdef __cplusplus
 }
Signature · 1 line
2.43.0
Acked-by on v2 1/1
#2 lore raw
Quoted 10 lines · Morten Brørup

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal purposes, but it is publicly exposed when including the header file, potentially colliding with existing definitions with the same name. Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the definition.

Furthermore, the superfluous function declaration at the top of the file was removed, and its description was moved to the function definition, to improve search results with source code browsers.

Quoted 8 lines

Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK coding style.

None of these changes should have any practical effect.

Fixes f5472703c0bd ("eal: optimize aligned memcpy on x86")
Quoted 3 lines

---
v2:
* Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)

Did you miss this change in v2? I still see the "!" below.

Quoted 95 lines
---
 lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 20 deletions(-)
lib/eal/x86/include/rte_memcpy.h +17 -20
index 8ed8c55010..41fb08ab95 100644
@@ -32,21 +32,6 @@ extern "C" {
 #define RTE_MEMCPY_AVX
 #endif
 
-/**
- * Copy bytes from one location to another. The locations must not overlap.
- *
- * @param dst
- *   Pointer to the destination of the data.
- * @param src
- *   Pointer to the source data.
- * @param n
- *   Number of bytes to copy.
- * @return
- *   Pointer to the destination data.
- */
-static __rte_always_inline void *
-rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
-
 /**
  * Copy bytes from one location to another,
  * locations must not overlap.
@@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t *__rte_restrict src)
  * AVX512 implementation below
  */
 
-#define ALIGNMENT_MASK 0x3F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * AVX implementation below
  */
 
-#define ALIGNMENT_MASK 0x1F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * SSE implementation below
  */
 
-#define ALIGNMENT_MASK 0x0F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
 
 /**
  * Macro for copying unaligned block from one location to another with constant load offset,
@@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void *__rte_restrict dst, const void *__rte_rest
 	return ret;
 }
 
+/**
+ * Copy bytes from one location to another. The locations must not overlap.
+ *
+ * @param dst
+ *   Pointer to the destination of the data.
+ * @param src
+ *   Pointer to the source data.
+ * @param n
+ *   Number of bytes to copy.
+ * @return
+ *   Pointer to the destination data.
+ */
 static __rte_always_inline void *
 rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 {
@@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 	}
 
 	/* Implementation for size > 64 bytes depends on alignment with vector register size. */
-	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
+	if (!(((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK))
 		return rte_memcpy_aligned_more_than_64(dst, src, n);
 	else
 		return rte_memcpy_generic_more_than_64(dst, src, n);
 }
 
-#undef ALIGNMENT_MASK
+#undef RTE_MEMCPY_ALIGNMENT_MASK
 
 #ifdef __cplusplus
 }
Signature · 1 line
2.43.0
#3 lore raw
Quoted 25 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Friday, 4 September 2026 13.25

Quoted 1 line · Morten Brørup

An alignment mask (ALIGNMENT_MASK) is temporarily defined for

internal

Quoted 6 lines

purposes, but it is publicly exposed when including the header file, potentially colliding with existing definitions with the same name. Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the definition.

Furthermore, the superfluous function declaration at the top of the

file

Quoted 1 line

was removed, and its description was moved to the function

definition,

Quoted 3 lines

to improve search results with source code browsers.

Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow

DPDK

Quoted 6 lines

coding style.

None of these changes should have any practical effect.

Fixes f5472703c0bd ("eal: optimize aligned memcpy on x86")
Quoted 7 lines
Quoted 1 line
Quoted 3 lines

---
v2:
* Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)

Did you miss this change in v2? I still see the "!" below.

Thank you, yes.
It's in my editor, but not on disk. :-\

Will send v3 shortly.

#4 lore raw

PATCH v3 1/1 eal/x86: fix memcpy alignment mask definition

In reply to Morten Brørup

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal purposes, but it is publicly exposed when including the header file, potentially colliding with existing definitions with the same name. Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the definition.

Furthermore, the superfluous function declaration at the top of the file was removed, and its description was moved to the function definition, to improve search results with source code browsers.

Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK coding style.

None of these changes should have any practical effect.

Fixes f5472703c0bd ("eal: optimize aligned memcpy on x86")

---
v3:
* Actually changed "!(addrs & MASK)" to "(addrs & MASK) == 0". In v2, it was changed in my editor, but not saved to disk.
v2:
* Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)

---
 lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 20 deletions(-)
lib/eal/x86/include/rte_memcpy.h +17 -20
index 8ed8c55010..41fb08ab95 100644
@@ -32,21 +32,6 @@ extern "C" {
 #define RTE_MEMCPY_AVX
 #endif
 
-/**
- * Copy bytes from one location to another. The locations must not overlap.
- *
- * @param dst
- *   Pointer to the destination of the data.
- * @param src
- *   Pointer to the source data.
- * @param n
- *   Number of bytes to copy.
- * @return
- *   Pointer to the destination data.
- */
-static __rte_always_inline void *
-rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
-
 /**
  * Copy bytes from one location to another,
  * locations must not overlap.
@@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t *__rte_restrict src)
  * AVX512 implementation below
  */
 
-#define ALIGNMENT_MASK 0x3F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * AVX implementation below
  */
 
-#define ALIGNMENT_MASK 0x1F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * SSE implementation below
  */
 
-#define ALIGNMENT_MASK 0x0F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
 
 /**
  * Macro for copying unaligned block from one location to another with constant load offset,
@@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void *__rte_restrict dst, const void *__rte_rest
 	return ret;
 }
 
+/**
+ * Copy bytes from one location to another. The locations must not overlap.
+ *
+ * @param dst
+ *   Pointer to the destination of the data.
+ * @param src
+ *   Pointer to the source data.
+ * @param n
+ *   Number of bytes to copy.
+ * @return
+ *   Pointer to the destination data.
+ */
 static __rte_always_inline void *
 rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 {
@@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 	}
 
 	/* Implementation for size > 64 bytes depends on alignment with vector register size. */
-	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
+	if (!(((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK))
 		return rte_memcpy_aligned_more_than_64(dst, src, n);
 	else
 		return rte_memcpy_generic_more_than_64(dst, src, n);
 }
 
-#undef ALIGNMENT_MASK
+#undef RTE_MEMCPY_ALIGNMENT_MASK
 
 #ifdef __cplusplus
 }
Signature · 1 line
2.43.0
#5 lore raw

PATCH v4 1/1 eal/x86: fix memcpy alignment mask definition

In reply to Morten Brørup

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal purposes, but it is publicly exposed when including the header file, potentially colliding with existing definitions with the same name. Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the definition.

Furthermore, the superfluous function declaration at the top of the file was removed, and its description was moved to the function definition, to improve search results with source code browsers.

Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK coding style.

None of these changes should have any practical effect.

Fixes f5472703c0bd ("eal: optimize aligned memcpy on x86")

---
v4:
* Really, really changed it this time.
When editing patch files, remember to edit the code too.
v3:
* Actually changed "!(addrs & MASK)" to "(addrs & MASK) == 0". In v2, it was changed in my editor, but not saved to disk.
v2:
* Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)

---
 lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 20 deletions(-)
lib/eal/x86/include/rte_memcpy.h +17 -20
index 8ed8c55010..41fb08ab95 100644
@@ -32,21 +32,6 @@ extern "C" {
 #define RTE_MEMCPY_AVX
 #endif
 
-/**
- * Copy bytes from one location to another. The locations must not overlap.
- *
- * @param dst
- *   Pointer to the destination of the data.
- * @param src
- *   Pointer to the source data.
- * @param n
- *   Number of bytes to copy.
- * @return
- *   Pointer to the destination data.
- */
-static __rte_always_inline void *
-rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
-
 /**
  * Copy bytes from one location to another,
  * locations must not overlap.
@@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t *__rte_restrict src)
  * AVX512 implementation below
  */
 
-#define ALIGNMENT_MASK 0x3F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * AVX implementation below
  */
 
-#define ALIGNMENT_MASK 0x1F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict dst, const void *__rte_rest
  * SSE implementation below
  */
 
-#define ALIGNMENT_MASK 0x0F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
 
 /**
  * Macro for copying unaligned block from one location to another with constant load offset,
@@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void *__rte_restrict dst, const void *__rte_rest
 	return ret;
 }
 
+/**
+ * Copy bytes from one location to another. The locations must not overlap.
+ *
+ * @param dst
+ *   Pointer to the destination of the data.
+ * @param src
+ *   Pointer to the source data.
+ * @param n
+ *   Number of bytes to copy.
+ * @return
+ *   Pointer to the destination data.
+ */
 static __rte_always_inline void *
 rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 {
@@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)
 	}
 
 	/* Implementation for size > 64 bytes depends on alignment with vector register size. */
-	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
+	if ((((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK) == 0)
 		return rte_memcpy_aligned_more_than_64(dst, src, n);
 	else
 		return rte_memcpy_generic_more_than_64(dst, src, n);
 }
 
-#undef ALIGNMENT_MASK
+#undef RTE_MEMCPY_ALIGNMENT_MASK
 
 #ifdef __cplusplus
 }
Signature · 1 line
2.43.0
Acked-by on v4 1/1
#6 lore raw
Quoted 122 lines

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal purposes, but it is publicly exposed when including the header file, potentially colliding with existing definitions with the same name. Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the definition.

Furthermore, the superfluous function declaration at the top of the file was removed, and its description was moved to the function definition, to improve search results with source code browsers.

Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK coding style.

None of these changes should have any practical effect.

Fixes f5472703c0bd ("eal: optimize aligned memcpy on x86")

---
v4:
* Really, really changed it this time.
When editing patch files, remember to edit the code too.
v3:
* Actually changed "!(addrs & MASK)" to "(addrs & MASK) == 0". In v2, it was changed in my editor, but not saved to disk.
v2:
* Changed "!(addrs & MASK)" to "(addrs & MASK) == 0". (AI)

---
 lib/eal/x86/include/rte_memcpy.h | 37 +++++++++++++++-----------------
 1 file changed, 17 insertions(+), 20 deletions(-)
lib/eal/x86/include/rte_memcpy.h +1 -16
index 8ed8c55010..41fb08ab95 100644
@@ -32,21 +32,6 @@ extern "C" {
 #define RTE_MEMCPY_AVX
 #endif
 
-/**
- * Copy bytes from one location to another. The locations must not overlap.
- *
- * @param dst
- *   Pointer to the destination of the data.
- * @param src
- *   Pointer to the source data.
- * @param n
- *   Number of bytes to copy.
- * @return
- *   Pointer to the destination data.
- */
-static __rte_always_inline void *
-rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n);
-
 /**
  * Copy bytes from one location to another,
  * locations must not overlap.
@@ -187,7 +172,7 @@ rte_mov256(uint8_t *__rte_restrict dst, const uint8_t
 *__rte_restrict src)
  * AVX512 implementation below
  */
 
-#define ALIGNMENT_MASK 0x3F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x3F
 
 /**

* Copy 128-byte blocks from one location to another,

lib/eal/x86/include/rte_memcpy.h +0 -0
@@ -333,7 +318,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict

dst, const void *__rte_rest
* AVX implementation below
*/

lib/eal/x86/include/rte_memcpy.h +1 -1
-#define ALIGNMENT_MASK 0x1F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x1F
 
 /**
  * Copy 128-byte blocks from one location to another,
@@ -444,7 +429,7 @@ rte_memcpy_generic_more_than_64(void *__rte_restrict

dst, const void *__rte_rest
* SSE implementation below
*/

lib/eal/x86/include/rte_memcpy.h +1 -1
-#define ALIGNMENT_MASK 0x0F
+#define RTE_MEMCPY_ALIGNMENT_MASK 0x0F
 
 /**
  * Macro for copying unaligned block from one location to another with constant

load offset,

lib/eal/x86/include/rte_memcpy.h +12 -0
@@ -673,6 +658,18 @@ rte_memcpy_aligned_more_than_64(void
 *__rte_restrict dst, const void *__rte_rest
 	return ret;
 }
 
+/**
+ * Copy bytes from one location to another. The locations must not overlap.
+ *
+ * @param dst
+ *   Pointer to the destination of the data.
+ * @param src
+ *   Pointer to the source data.
+ * @param n
+ *   Number of bytes to copy.
+ * @return
+ *   Pointer to the destination data.
+ */
 static __rte_always_inline void *
 rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)

{

lib/eal/x86/include/rte_memcpy.h +0 -0
@@ -709,13 +706,13 @@ rte_memcpy(void *__rte_restrict dst, const void
 *__rte_restrict src, size_t n)
 	}
 
 	/* Implementation for size > 64 bytes depends on alignment with vector

register size. */

lib/eal/x86/include/rte_memcpy.h +1 -1
-	if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK))
+	if ((((uintptr_t)dst | (uintptr_t)src) & RTE_MEMCPY_ALIGNMENT_MASK)

== 0)

lib/eal/x86/include/rte_memcpy.h +0 -0
 		return rte_memcpy_aligned_more_than_64(dst, src, n);

lib/eal/x86/include/rte_memcpy.h rte_memcpy(void *__rte_restrict dst, const void *__rte_restrict src, size_t n)

Quoted 10 lines
lib/eal/x86/include/rte_memcpy.h +1 -2
 	else
 		return rte_memcpy_generic_more_than_64(dst, src, n);
 }
 
-#undef ALIGNMENT_MASK
+#undef RTE_MEMCPY_ALIGNMENT_MASK
 
 #ifdef __cplusplus
 }
--
Quoted 1 line

2.43.0

#7 lore raw
Quoted 13 lines
Quoted 13 lines

An alignment mask (ALIGNMENT_MASK) is temporarily defined for internal purposes, but it is publicly exposed when including the header file, potentially colliding with existing definitions with the same name. Fixed this potential issue by adding the RTE_MEMCPY_ prefix to the definition.

Furthermore, the superfluous function declaration at the top of the file was removed, and its description was moved to the function definition, to improve search results with source code browsers.

Also, changed "!(addrs & MASK)" to "(addrs & MASK) == 0" to follow DPDK coding style.

Quoted 7 lines
Quoted 6 lines

None of these changes should have any practical effect.

Fixes f5472703c0bd ("eal: optimize aligned memcpy on x86")

Applied, thanks.