Skip to contentSkip to conversation

eal: add define guards to avoid multi-inclusion

PATCH In review Weiguo Li 4 participants 10 messages Feb 9, 2022 – Oct 15, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Weiguo Li

author
#1 lore raw

PATCH v3 1/4 kni: add define guards to avoid multi-inclusion

Supplement define guards to prevent multiple inclusion.

---
 lib/kni/rte_kni_fifo.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/kni/rte_kni_fifo.h +4 -1
index d2ec82fe87..2ff71554c0 100644
@@ -2,7 +2,8 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-
+#ifndef RTE_KNI_FIFO_H
+#define RTE_KNI_FIFO_H
 
 /**
  * @internal when c11 memory model enabled use c11 atomic memory barrier.
@@ -115,3 +116,5 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
 	uint32_t fifo_read = __KNI_LOAD_ACQUIRE(&fifo->read);
 	return (fifo_read - fifo_write - 1) & (fifo->len - 1);
 }
+
+#endif /* RTE_KNI_FIFO_H */
Signature · 1 line
2.25.1
Acked-by on v3 1/4
#2 lore raw

Re: [PATCH v3 1/4] kni: add define guards to avoid multi-inclusion

Quoted 2 lines · Weiguo Li

Supplement define guards to prevent multiple inclusion.

It is kind of private header and only 'rte_kni.c' includes it, that is why missing guards doesn't cause trouble but no harm/objection to have them.

Quoted 1 line
Quoted 9 lines
---
  lib/kni/rte_kni_fifo.h | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
lib/kni/rte_kni_fifo.h +0 -0
index d2ec82fe87..2ff71554c0 100644

lib/kni/rte_kni_fifo.h line 6

Quoted 6 lines
lib/kni/rte_kni_fifo.h +2 -1
@@ -2,7 +2,8 @@
   * Copyright(c) 2010-2014 Intel Corporation
   */
 
-
+#ifndef RTE_KNI_FIFO_H
+#define RTE_KNI_FIFO_H

It doesn't really differ much but other kni header guards wrapped with '_', I don't now why.
If there will be a new version can you please apply the same here to have consistency, like:
#ifndef _RTE_KNI_FIFO_H_

Quoted 9 lines
lib/kni/rte_kni_fifo.h +2 -0
  /**
   * @internal when c11 memory model enabled use c11 atomic memory barrier.
@@ -115,3 +116,5 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
  	uint32_t fifo_read = __KNI_LOAD_ACQUIRE(&fifo->read);
  	return (fifo_read - fifo_write - 1) & (fifo->len - 1);
  }
+
+#endif /* RTE_KNI_FIFO_H */
#3 lore raw

Re: [PATCH v3 1/4] kni: add define guards to avoid multi-inclusion

09/02/2022 14:52, Ferruh Yigit:

Quoted 6 lines · Weiguo Li

lib/kni/rte_kni_fifo.h line 6

Quoted 2 lines
lib/kni/rte_kni_fifo.h +2 -0
+#ifndef RTE_KNI_FIFO_H
+#define RTE_KNI_FIFO_H

It doesn't really differ much but other kni header guards wrapped with '_', I don't now why.

No good reason I think.

Quoted 3 lines

If there will be a new version can you please apply the same here to have consistency, like:
#ifndef _RTE_KNI_FIFO_H_

I think consistency is not important here.
We should not add underscores where not needed,
it gives a false impression of reserved keywords.

author
#4 lore raw

PATCH v3 2/4 eal: add define guards to avoid multi-inclusion

In reply to a message not in the archive

Supplement define guards to prevent multiple inclusion.

---
 lib/eal/include/rte_eal_paging.h        | 5 +++++
 lib/eal/windows/include/rte_virt2phys.h | 5 +++++
 2 files changed, 10 insertions(+)
lib/eal/include/rte_eal_paging.h +5 -0
index c60317d0f5..75c4291484 100644
@@ -2,6 +2,9 @@
  * Copyright(c) 2020 Dmitry Kozlyuk
  */
 
+#ifndef RTE_EAL_PAGING_H
+#define RTE_EAL_PAGING_H
+
 #include <stdint.h>
 
 #include <rte_compat.h>
@@ -96,3 +99,5 @@ rte_mem_page_size(void);
 __rte_internal
 int
 rte_mem_lock(const void *virt, size_t size);
+
+#endif /* RTE_EAL_PAGING_H */
lib/eal/windows/include/rte_virt2phys.h +5 -0
index 4bb2b4aafe..d0eae33141 100644
@@ -2,6 +2,9 @@
  * Copyright (c) 2020 Dmitry Kozlyuk
  */
 
+#ifndef RTE_VIRT2PHYS_H
+#define RTE_VIRT2PHYS_H
+
 /**
  * @file virt2phys driver interface
  */
@@ -32,3 +35,5 @@ DEFINE_GUID(GUID_DEVINTERFACE_VIRT2PHYS,
  */
 #define IOCTL_VIRT2PHYS_TRANSLATE CTL_CODE( \
 	VIRT2PHYS_DEVTYPE, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
+#endif /* RTE_VIRT2PHYS_H */
Signature · 1 line
2.25.1
author
#6 lore raw

PATCH v3 3/4 efd: add define guards to avoid multi-inclusion

In reply to a message not in the archive

Supplement define guards to prevent multiple inclusion.

---
 lib/efd/rte_efd_x86.h | 5 +++++
 1 file changed, 5 insertions(+)
lib/efd/rte_efd_x86.h +5 -0
index e2f9dcca88..6e377765f9 100644
@@ -2,6 +2,9 @@
  * Copyright(c) 2016-2017 Intel Corporation
  */
 
+#ifndef RTE_EFD_X86_H
+#define RTE_EFD_X86_H
+
 /* rte_efd_x86.h
  * This file holds all x86 specific EFD functions
  */
@@ -55,3 +58,5 @@ efd_lookup_internal_avx2(const efd_hashfunc_t *group_hash_idx,
 #endif
 
 }
+
+#endif /* RTE_EFD_X86_H */
Signature · 1 line
2.25.1
author
#8 lore raw

PATCH v3 4/4 hash: add define guards to avoid multi-inclusion

In reply to a message not in the archive

Supplement define guards to prevent multiple inclusion.

---
 lib/hash/rte_cmp_arm64.h | 5 +++++
 lib/hash/rte_cmp_x86.h   | 5 +++++
 2 files changed, 10 insertions(+)
lib/hash/rte_cmp_arm64.h +5 -0
index e9e26f9abd..ecf0ea3e6f 100644
@@ -2,6 +2,9 @@
  * Copyright(c) 2015 Cavium, Inc
  */
 
+#ifndef RTE_CMP_ARM64_H
+#define RTE_CMP_ARM64_H
+
 /* Functions to compare multiple of 16 byte keys (up to 128 bytes) */
 static int
 rte_hash_k16_cmp_eq(const void *key1, const void *key2,
@@ -83,3 +86,5 @@ rte_hash_k128_cmp_eq(const void *key1, const void *key2, size_t key_len)
 		rte_hash_k64_cmp_eq((const char *) key1 + 64,
 				(const char *) key2 + 64, key_len);
 }
+
+#endif /* RTE_CMP_ARM64_H */
lib/hash/rte_cmp_x86.h +5 -0
index 13a5836351..3b3b3860b1 100644
@@ -2,6 +2,9 @@
  * Copyright(c) 2015 Intel Corporation
  */
 
+#ifndef RTE_CMP_X86_H
+#define RTE_CMP_X86_H
+
 #include <rte_vect.h>
 
 /* Functions to compare multiple of 16 byte keys (up to 128 bytes) */
@@ -74,3 +77,5 @@ rte_hash_k128_cmp_eq(const void *key1, const void *key2, size_t key_len)
 		rte_hash_k64_cmp_eq((const char *) key1 + 64,
 				(const char *) key2 + 64, key_len);
 }
+
+#endif /* RTE_CMP_X86_H */
Signature · 1 line
2.25.1
#10 lore raw

Re: [PATCH v3 4/4] hash: add define guards to avoid multi-inclusion

In reply to Weiguo Li
Quoted 7 lines · On Wed, 9 Feb 2022 15:24:08 +0800 Weiguo Li <[email protected]> wrote:

Supplement define guards to prevent multiple inclusion.

---
 lib/hash/rte_cmp_arm64.h | 5 +++++
 lib/hash/rte_cmp_x86.h   | 5 +++++
 2 files changed, 10 insertions(+)

These are internal files not exported by install so not necessary.