use GCC/MSVC compatible __VA_ARGS__
cover use GCC/MSVC compatible __VA_ARGS__
MSVC does not support GCC args... forwarding of args replace with ... and __VA_ARGS__ when forwarding. Both forms of forwarding are a compiler extension but the latter is supported by both MSVC and GCC.
I have not been able to exhaustively test all versions of GCC so please provide feedback as appropriate.
Tyler Retzlaff (15):
eal: use GCC and MSVC common VA ARGS extension
bpf: use GCC and MSVC common VA ARGS extension
cfgfile: use GCC and MSVC common VA ARGS extension
cmdline: use GCC and MSVC common VA ARGS extension
ip_frag: use GCC and MSVC common VA ARGS extension
compressdev: use GCC and MSVC common VA ARGS extension
metrics: use GCC and MSVC common VA ARGS extension
mldev: use GCC and MSVC common VA ARGS extension
net: use GCC and MSVC common VA ARGS extension
pdump: use GCC and MSVC common VA ARGS extension
power: use GCC and MSVC common VA ARGS extension
rawdev: use GCC and MSVC common VA ARGS extension
rcu: use GCC and MSVC common VA ARGS extension
stack: use GCC and MSVC common VA ARGS extension
vhost: use GCC and MSVC common VA ARGS extension
lib/bpf/bpf_impl.h | 4 ++-- lib/cfgfile/rte_cfgfile.c | 4 ++-- lib/cmdline/cmdline_parse.c | 2 +- lib/cmdline/cmdline_parse_num.c | 4 ++-- lib/compressdev/rte_compressdev_internal.h | 4 ++-- lib/eal/common/eal_trace.h | 8 ++++---- lib/ip_frag/ip_frag_common.h | 4 ++-- lib/metrics/rte_metrics_telemetry.c | 12 ++++++------ lib/mldev/rte_mldev.h | 4 ++-- lib/net/rte_net_crc.c | 4 ++-- lib/pdump/rte_pdump.c | 4 ++-- lib/power/power_common.h | 6 +++--- lib/rawdev/rte_rawdev_pmd.h | 18 +++++++++--------- lib/rcu/rte_rcu_qsbr.c | 4 ++-- lib/rcu/rte_rcu_qsbr.h | 12 ++++++------ lib/stack/stack_pvt.h | 16 ++++++++-------- lib/vhost/vhost.h | 8 ++++---- lib/vhost/vhost_crypto.c | 14 +++++++------- 18 files changed, 66 insertions(+), 66 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 2/15 bpf: use GCC and MSVC common VA ARGS extension
Use ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bpf/bpf_impl.h +2 -2
@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (lvl, fmt, ...) \ + RTE_LOG_LINE(lvl, BPF, fmt, ## __VA_ARGS__)static inline size_t bpf_size (uint32_t bpf_op_sz)
Signature · 1 line
1.8.3.1
PATCH 1/15 eal: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/eal/common/eal_trace.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/eal/common/eal_trace.h +4 -4
@@ -16,11 +16,11 @@#include "eal_private.h" #include "eal_thread.h" -#define trace_err(fmt, args...) \ - EAL_LOG(ERR, "%s():%u " fmt, __func__, __LINE__, ## args) +#define trace_err (fmt, ...) \ + EAL_LOG(ERR, "%s():%u " fmt, __func__, __LINE__, ## __VA_ARGS__) -#define trace_crit(fmt, args...) \ - EAL_LOG(CRIT, "%s():%u " fmt, __func__, __LINE__, ## args) +#define trace_crit (fmt, ...) \ + EAL_LOG(CRIT, "%s():%u " fmt, __func__, __LINE__, ## __VA_ARGS__)#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32
Signature · 1 line
1.8.3.1
PATCH 4/15 cmdline: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
Fix checkpatches warning about style while(0) -> while (0)
--- lib/cmdline/cmdline_parse.c | 2 +- lib/cmdline/cmdline_parse_num.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/cmdline/cmdline_parse.c +1 -1
@@ -16,7 +16,7 @@#ifdef RTE_LIBRTE_CMDLINE_DEBUG #define debug_printf printf#else -#define debug_printf(args...) do {} while(0) +#define debug_printf (...) do {} while (0)#endif #define CMDLINE_BUFFER_SIZE 64
lib/cmdline/cmdline_parse_num.c +2 -2
@@ -14,9 +14,9 @@#include "cmdline_parse_num.h" #ifdef RTE_LIBRTE_CMDLINE_DEBUG -#define debug_printf(args...) printf(args) +#define debug_printf (...) printf(__VA_ARGS__)#else -#define debug_printf(args...) do {} while(0) +#define debug_printf (...) do {} while (0)#endif struct cmdline_token_ops cmdline_token_num_ops = {
Signature · 1 line
1.8.3.1
PATCH 3/15 cfgfile: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/cfgfile/rte_cfgfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/cfgfile/rte_cfgfile.c +2 -2
@@ -31,8 +31,8 @@ struct rte_cfgfile {RTE_LOG_REGISTER_DEFAULT (cfgfile_logtype,INFO );#define RTE_LOGTYPE_CFGFILE cfgfile_logtype -#define CFG_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## args) +#define CFG_LOG (level, fmt, ...) \ + RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## __VA_ARGS__)/* >8 End of setting up dynamic logging */ /** when we resize a file structure, how many extra entries
Signature · 1 line
1.8.3.1
PATCH 5/15 ip_frag: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
Fix checkpatches warning about style while(0) -> while (0)
--- lib/ip_frag/ip_frag_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/ip_frag/ip_frag_common.h +2 -2
@@ -26,9 +26,9 @@ RTE_LOG_LINE(level, IPFRAG, "" __VA_ARGS__)#ifdef RTE_LIBRTE_IP_FRAG_DEBUG -#define IP_FRAG_LOG(lvl, fmt, args...) RTE_LOG(lvl, IPFRAG, fmt, ##args) +#define IP_FRAG_LOG (lvl, fmt, ...) RTE_LOG(lvl, IPFRAG, fmt, ## __VA_ARGS__)#else -#define IP_FRAG_LOG(lvl, fmt, args...) do {} while(0) +#define IP_FRAG_LOG (lvl, fmt, ...) do {} while (0)#endif /* IP_FRAG_DEBUG */ #define IPV4_KEYLEN 1
Signature · 1 line
1.8.3.1
PATCH 7/15 metrics: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/metrics/rte_metrics_telemetry.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/metrics/rte_metrics_telemetry.c +6 -6
@@ -19,14 +19,14 @@#define RTE_LOGTYPE_METRICS metrics_log_level/* Logging Macros */ -#define METRICS_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, METRICS, "%s(): "fmt, __func__, ## args) +#define METRICS_LOG (level, fmt, ...) \ + RTE_LOG_LINE(level, METRICS, "%s(): "fmt, __func__, ## __VA_ARGS__) -#define METRICS_LOG_ERR(fmt, args...) \ - METRICS_LOG(ERR, fmt, ## args) +#define METRICS_LOG_ERR (fmt, ...) \ + METRICS_LOG(ERR, fmt, ## __VA_ARGS__) -#define METRICS_LOG_WARN(fmt, args...) \ - METRICS_LOG(WARNING, fmt, ## args) +#define METRICS_LOG_WARN (fmt, ...) \ + METRICS_LOG(WARNING, fmt, ## __VA_ARGS__)static int32_t rte_metrics_tel_reg_port_ethdev_to_metrics (uint16_t port_id)
Signature · 1 line
1.8.3.1
PATCH 6/15 compressdev: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/compressdev/rte_compressdev_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/compressdev/rte_compressdev_internal.h +2 -2
@@ -23,8 +23,8 @@extern int compressdev_logtype;#define RTE_LOGTYPE_COMPRESSDEV compressdev_logtype -#define COMPRESSDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, COMPRESSDEV, "%s(): " fmt, __func__, ## args) +#define COMPRESSDEV_LOG (level, fmt, ...) \ + RTE_LOG_LINE(level, COMPRESSDEV, "%s(): " fmt, __func__, ## __VA_ARGS__)/** * Dequeue processed packets from queue pair of a device.
Signature · 1 line
1.8.3.1
PATCH 11/15 power: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/power/power_common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/power/power_common.h +3 -3
@@ -16,10 +16,10 @@ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)#ifdef RTE_LIBRTE_POWER_DEBUG -#define POWER_DEBUG_LOG(fmt, args...) \ - RTE_LOG_LINE(ERR, POWER, "%s: " fmt, __func__, ## args) +#define POWER_DEBUG_LOG (fmt, ...) \ + RTE_LOG_LINE(ERR, POWER, "%s: " fmt, __func__, ## __VA_ARGS__)#else -#define POWER_DEBUG_LOG(fmt, args...) +#define POWER_DEBUG_LOG (fmt, ...)#endif /* check if scaling driver matches one we want */
Signature · 1 line
1.8.3.1
PATCH 10/15 pdump: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/pdump/rte_pdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/pdump/rte_pdump.c +2 -2
@@ -18,8 +18,8 @@RTE_LOG_REGISTER_DEFAULT (pdump_logtype,NOTICE );#define RTE_LOGTYPE_PDUMP pdump_logtype -#define PDUMP_LOG_LINE(level, fmt, args...) \ - RTE_LOG_LINE(level, PDUMP, "%s(): " fmt, __func__, ## args) +#define PDUMP_LOG_LINE (level, fmt, ...) \ + RTE_LOG_LINE(level, PDUMP, "%s(): " fmt, __func__, ## __VA_ARGS__)/* Used for the multi-process communication */ #define PDUMP_MP "mp_pdump"
Signature · 1 line
1.8.3.1
PATCH 9/15 net: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/net/rte_net_crc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/net/rte_net_crc.c +2 -2
@@ -73,8 +73,8 @@RTE_LOG_REGISTER_DEFAULT (libnet_logtype,INFO );#define RTE_LOGTYPE_NET libnet_logtype -#define NET_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, NET, "%s(): " fmt, __func__, ## args) +#define NET_LOG (level, fmt, ...) \ + RTE_LOG_LINE(level, NET, "%s(): " fmt, __func__, ## __VA_ARGS__)/* Scalar handling */
Signature · 1 line
1.8.3.1
PATCH 13/15 rcu: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/rcu/rte_rcu_qsbr.c | 4 ++-- lib/rcu/rte_rcu_qsbr.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
lib/rcu/rte_rcu_qsbr.c +2 -2
@@ -19,8 +19,8 @@#include "rte_rcu_qsbr.h" #include "rcu_qsbr_pvt.h" -#define RCU_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) +#define RCU_LOG (level, fmt, ...) \ + RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## __VA_ARGS__)/* Get the memory size of QSBR variable */ size_t
lib/rcu/rte_rcu_qsbr.h +6 -6
@@ -39,19 +39,19 @@#define RTE_LOGTYPE_RCU rte_rcu_log_type#if RTE_LOG_DP_LEVEL >=RTE_LOG_DEBUG -#define __RTE_RCU_DP_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) +#define __RTE_RCU_DP_LOG (level, fmt, ...) \ + RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## __VA_ARGS__)#else -#define __RTE_RCU_DP_LOG(level, fmt, args...) +#define __RTE_RCU_DP_LOG (level, fmt, ...)#endif #if defined(RTE_LIBRTE_RCU_DEBUG ) -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) do { \ +#define __RTE_RCU_IS_LOCK_CNT_ZERO (v, thread_id, level, fmt, ...) do { \ if (v->qsbr_cnt[thread_id].lock_cnt) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args); \ + RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## __VA_ARGS__); \ } while (0)#else -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) +#define __RTE_RCU_IS_LOCK_CNT_ZERO (v, thread_id, level, fmt, ...)#endif /* Registered thread IDs are stored as a bitmap of 64b element array.
Signature · 1 line
1.8.3.1
PATCH 12/15 rawdev: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/rawdev/rte_rawdev_pmd.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
lib/rawdev/rte_rawdev_pmd.h +9 -9
@@ -30,15 +30,15 @@#define RTE_LOGTYPE_RAWDEV librawdev_logtype/* Logging Macros */ -#define RTE_RDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RAWDEV, "%s(): " fmt, __func__, ##args) - -#define RTE_RDEV_ERR(fmt, args...) \ - RTE_RDEV_LOG(ERR, fmt, ## args) -#define RTE_RDEV_DEBUG(fmt, args...) \ - RTE_RDEV_LOG(DEBUG, fmt, ## args) -#define RTE_RDEV_INFO(fmt, args...) \ - RTE_RDEV_LOG(INFO, fmt, ## args) +#define RTE_RDEV_LOG (level, fmt, ...) \ + RTE_LOG_LINE(level, RAWDEV, "%s(): " fmt, __func__, ## __VA_ARGS__) + +#define RTE_RDEV_ERR (fmt, ...) \ + RTE_RDEV_LOG(ERR, fmt, ## __VA_ARGS__) +#define RTE_RDEV_DEBUG (fmt, ...) \ + RTE_RDEV_LOG(DEBUG, fmt, ## __VA_ARGS__) +#define RTE_RDEV_INFO (fmt, ...) \ + RTE_RDEV_LOG(INFO, fmt, ## __VA_ARGS__)/* Macros to check for valid device */
Signature · 1 line
1.8.3.1
PATCH 8/15 mldev: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/mldev/rte_mldev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/mldev/rte_mldev.h +2 -2
@@ -146,8 +146,8 @@extern int rte_ml_dev_logtype;#define RTE_LOGTYPE_MLDEV rte_ml_dev_logtype -#define RTE_MLDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, MLDEV, "%s(): " fmt, __func__, ##args) +#define RTE_MLDEV_LOG (level, fmt, ...) \ + RTE_LOG_LINE(level, MLDEV, "%s(): " fmt, __func__, ## __VA_ARGS__)#define RTE_ML_STR_MAX 128/**< Maximum length of name string */
Signature · 1 line
1.8.3.1
PATCH 14/15 stack: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/stack/stack_pvt.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
lib/stack/stack_pvt.h +8 -8
@@ -10,16 +10,16 @@extern int stack_logtype;#define RTE_LOGTYPE_STACK stack_logtype -#define STACK_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, STACK, "%s(): "fmt, __func__, ##args) +#define STACK_LOG (level, fmt, ...) \ + RTE_LOG_LINE(level, STACK, "%s(): "fmt, __func__, ## __VA_ARGS__) -#define STACK_LOG_ERR(fmt, args...) \ - STACK_LOG(ERR, fmt, ## args) +#define STACK_LOG_ERR (fmt, ...) \ + STACK_LOG(ERR, fmt, ## __VA_ARGS__) -#define STACK_LOG_WARN(fmt, args...) \ - STACK_LOG(WARNING, fmt, ## args) +#define STACK_LOG_WARN (fmt, ...) \ + STACK_LOG(WARNING, fmt, ## __VA_ARGS__) -#define STACK_LOG_INFO(fmt, args...) \ - STACK_LOG(INFO, fmt, ## args) +#define STACK_LOG_INFO (fmt, ...) \ + STACK_LOG(INFO, fmt, ## __VA_ARGS__)#endif /* _STACK_PVT_H_ */
Signature · 1 line
1.8.3.1
PATCH 15/15 vhost: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffUse ... and forward with __VA_ARGS__ instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.
--- lib/vhost/vhost.h | 8 ++++---- lib/vhost/vhost_crypto.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-)
lib/vhost/vhost.h +4 -4
@@ -677,11 +677,11 @@ void __vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,extern int vhost_data_log_level;#define RTE_LOGTYPE_VHOST_DATA vhost_data_log_level -#define VHOST_CONFIG_LOG(prefix, level, fmt, args...) \ - RTE_LOG_LINE(level, VHOST_CONFIG, "(%s) " fmt, prefix, ##args) +#define VHOST_CONFIG_LOG (prefix, level, fmt, ...) \ + RTE_LOG_LINE(level, VHOST_CONFIG, "(%s) " fmt, prefix, ## __VA_ARGS__) -#define VHOST_DATA_LOG(prefix, level, fmt, args...) \ - RTE_LOG_DP_LINE(level, VHOST_DATA, "(%s) " fmt, prefix, ##args) +#define VHOST_DATA_LOG (prefix, level, fmt, ...) \ + RTE_LOG_DP_LINE(level, VHOST_DATA, "(%s) " fmt, prefix, ## __VA_ARGS__)#ifdef RTE_LIBRTE_VHOST_DEBUG #define VHOST_MAX_PRINT_BUFF 6072
lib/vhost/vhost_crypto.c +7 -7
@@ -20,19 +20,19 @@RTE_LOG_REGISTER_SUFFIX (vhost_crypto_logtype, crypto,INFO );#define RTE_LOGTYPE_VHOST_CRYPTO vhost_crypto_logtype -#define VC_LOG_ERR(fmt, args...) \ +#define VC_LOG_ERR (fmt, ...) \ RTE_LOG_LINE(ERR, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) -#define VC_LOG_INFO(fmt, args...) \ + __func__, __LINE__, ## __VA_ARGS__) +#define VC_LOG_INFO (fmt, ...) \ RTE_LOG_LINE(INFO, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) + __func__, __LINE__, ## __VA_ARGS__)#ifdef RTE_LIBRTE_VHOST_DEBUG -#define VC_LOG_DBG(fmt, args...) \ +#define VC_LOG_DBG (fmt, ...) \ RTE_LOG_LINE(DEBUG, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) + __func__, __LINE__, ## __VA_ARGS__)#else -#define VC_LOG_DBG(fmt, args...) +#define VC_LOG_DBG (fmt, ...)#endif #define VIRTIO_CRYPTO_FEATURES ((1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
Signature · 1 line
1.8.3.1
Quoted 8 lines · Tyler Retzlaff
MSVC does not support GCC args... forwarding of args replace with ... and
__VA_ARGS__when forwarding. Both forms of forwarding are a compiler extension but the latter is supported by both MSVC and GCC.I have not been able to exhaustively test all versions of GCC so please provide feedback as appropriate.
Quoted 17 lines
Tyler Retzlaff (15):
eal: use GCC and MSVC common VA ARGS extension
bpf: use GCC and MSVC common VA ARGS extension
cfgfile: use GCC and MSVC common VA ARGS extension
cmdline: use GCC and MSVC common VA ARGS extension
ip_frag: use GCC and MSVC common VA ARGS extension
compressdev: use GCC and MSVC common VA ARGS extension
metrics: use GCC and MSVC common VA ARGS extension
mldev: use GCC and MSVC common VA ARGS extension
net: use GCC and MSVC common VA ARGS extension
pdump: use GCC and MSVC common VA ARGS extension
power: use GCC and MSVC common VA ARGS extension
rawdev: use GCC and MSVC common VA ARGS extension
rcu: use GCC and MSVC common VA ARGS extension
stack: use GCC and MSVC common VA ARGS extension
vhost: use GCC and MSVC common VA ARGS extension
Re: [PATCH 03/15] cfgfile: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffQuoted 14 lines · Tyler Retzlaff
Use ... and forward with
__VA_ARGS__instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.Signed-off-by Tyler Retzlaff <[email protected]>--- lib/cfgfile/rte_cfgfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/cfgfile/rte_cfgfile.c +0
-0
lib/cfgfile/rte_cfgfile.c struct rte_cfgfile { · line 37
Quoted 9 lines
lib/cfgfile/rte_cfgfile.c +2
-2@@ -31,8 +31,8 @@ struct rte_cfgfile {RTE_LOG_REGISTER_DEFAULT (cfgfile_logtype,INFO );#define RTE_LOGTYPE_CFGFILE cfgfile_logtype -#define CFG_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## args) +#define CFG_LOG (level, fmt, ...) \ + RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## __VA_ARGS__)/* >8 End of setting up dynamic logging */
Re: [PATCH 04/15] cmdline: use GCC and MSVC common VA ARGS extension
In reply to Tyler RetzlaffQuoted 8 lines · Tyler Retzlaff
Use ... and forward with
__VA_ARGS__instead of args... and args. Neither mechanism is conformant with the standard but the former works with both GCC and MSVC.Fix checkpatches warning about style while(0) -> while (0)
Signed-off-by Tyler Retzlaff <[email protected]>---
Quoted 7 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Monday, 12 February 2024 22.49MSVC does not support GCC args... forwarding of args replace with ... and
__VA_ARGS__when forwarding. Both forms of forwarding are a compiler extension but the latter is supported by both MSVC and GCC.
RE: [PATCH 12/15] rawdev: use GCC and MSVC common VA ARGS extension
In reply to Tyler Retzlaff12/02/2024 22:49, Tyler Retzlaff:
Quoted 4 lines
MSVC does not support GCC args... forwarding of args replace with ... and
__VA_ARGS__when forwarding. Both forms of forwarding are a compiler extension but the latter is supported by both MSVC and GCC.
You use the non-standard ", ## __VA_ARGS__"
which would not compile in pedantic modes,
and possibly with other compilers.
I remember a private chat where I recommended you to use this:
lib/eal/include/rte_common.h
/**
* ISO C helpers to modify format strings using variadic macros.
* This is a replacement for the ", ## __VA_ARGS__" GNU extension.
* An empty %s argument is appended to avoid a dangling comma. */
#define RTE_FMT(fmt, ...) fmt "%.0s", __VA_ARGS__ "" #define RTE_FMT_HEAD(fmt, ...) fmt
#define RTE_FMT_TAIL(fmt, ...) __VA_ARGS__
Why not using it?
v2 cover stop using variadic argument pack extension
In reply to Tyler RetzlaffRTE_LOG_LINE cannot be augmented with a prefix format and arguments without the user of RTE_LOG_LINE using the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.
Provide a new/similar macro RTE_LOG_LINE_PREFIX that accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside of RTE_FMT() allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with __VA_ARGS__ avoiding the need for conditional comma removal.
I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
note: due to drastic change in series i have not carried any series acks
forward.
v2:
* revamp entire series to be ISO C99 compliant, stop using variadic argument pack extension.
Tyler Retzlaff (17):
log: add a per line log helper with parameterized prefix
bpf: stop using variadic argument pack extension
cfgfile: stop using variadic argument pack extension
cmdline: stop using variadic argument pack extension
compressdev: stop using variadic argument pack extension
metrics: stop using variadic argument pack extension
mldev: stop using variadic argument pack extension
net: stop using variadic argument pack extension
pdump: stop using variadic argument pack extension
power: stop using variadic argument pack extension
rawdev: stop using variadic argument pack extension
rcu: stop using variadic argument pack extension
stack: stop using variadic argument pack extension
eal: stop using variadic argument pack extension
vhost: stop using variadic argument pack extension
vhost: stop using variadic argument pack extension
ip_frag: stop using variadic argument pack extension
lib/bpf/bpf_impl.h | 4 ++-- lib/cfgfile/rte_cfgfile.c | 5 +++-- lib/cmdline/cmdline_parse.c | 2 +- lib/cmdline/cmdline_parse_num.c | 4 ++-- lib/compressdev/rte_compressdev_internal.h | 4 ++-- lib/eal/common/eal_trace.h | 8 ++++---- lib/ip_frag/ip_frag_common.h | 4 ++-- lib/log/rte_log.h | 14 ++++++++++++++ lib/metrics/rte_metrics_telemetry.c | 12 ++++++------ lib/mldev/rte_mldev.h | 4 ++-- lib/net/rte_net_crc.c | 4 ++-- lib/pdump/rte_pdump.c | 4 ++-- lib/power/power_common.h | 6 +++--- lib/rawdev/rte_rawdev_pmd.h | 17 +++++++++-------- lib/rcu/rte_rcu_qsbr.c | 4 ++-- lib/rcu/rte_rcu_qsbr.h | 12 ++++++------ lib/stack/stack_pvt.h | 16 ++++++++-------- lib/vhost/vhost.h | 8 ++++---- lib/vhost/vhost_crypto.c | 21 +++++++++++---------- 19 files changed, 85 insertions(+), 68 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/17 log: add a per line log helper with parameterized prefix
Providing a custom prefix when logging is common for components. Lift ISO C99 compliant helper macros from mlx5_common.h and provide RTE_LOG_LINE_PREFIX macro that can expand similar to RTE_LOG_LINE with a custom prefix and argument list.
--- lib/log/rte_log.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
lib/log/rte_log.h +14 -0
@@ -379,6 +379,20 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) RTE_FMT_TAIL(__VA_ARGS__ ,))); \ } while (0) +#define _RTE_LOG_COMMA , + +#define RTE_LOG_LINE_PREFIX (l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args _RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) + +#define RTE_LOG_DP_LINE_PREFIX (l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG_DP(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args _RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) +#define RTE_LOG_REGISTER_IMPL (type, name, level) \ int type; \ RTE_INIT(__##type) \
Signature · 1 line
1.8.3.1
PATCH v2 2/17 bpf: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bpf/bpf_impl.h +2 -2
@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, BPF, "%s(): ", __func__, __VA_ARGS__)static inline size_t bpf_size (uint32_t bpf_op_sz)
Signature · 1 line
1.8.3.1
PATCH v2 4/17 cmdline: stop using variadic argument pack extension
In reply to Tyler RetzlaffRemove use of args... and just use __VA_ARGS__. The macros expanding the argument pack do not require args extension to remove trailing comma.
--- lib/cmdline/cmdline_parse.c | 2 +- lib/cmdline/cmdline_parse_num.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/cmdline/cmdline_parse.c +1 -1
@@ -16,7 +16,7 @@#ifdef RTE_LIBRTE_CMDLINE_DEBUG #define debug_printf printf#else -#define debug_printf(args...) do {} while(0) +#define debug_printf (...) do {} while (0)#endif #define CMDLINE_BUFFER_SIZE 64
lib/cmdline/cmdline_parse_num.c +2 -2
@@ -14,9 +14,9 @@#include "cmdline_parse_num.h" #ifdef RTE_LIBRTE_CMDLINE_DEBUG -#define debug_printf(args...) printf(args) +#define debug_printf (...) printf(__VA_ARGS__)#else -#define debug_printf(args...) do {} while(0) +#define debug_printf (...) do {} while (0)#endif struct cmdline_token_ops cmdline_token_num_ops = {
Signature · 1 line
1.8.3.1
PATCH v2 3/17 cfgfile: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/cfgfile/rte_cfgfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/cfgfile/rte_cfgfile.c +3 -2
@@ -31,8 +31,9 @@ struct rte_cfgfile {RTE_LOG_REGISTER_DEFAULT (cfgfile_logtype,INFO );#define RTE_LOGTYPE_CFGFILE cfgfile_logtype -#define CFG_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## args) +#define CFG_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, CFGFILE, "%s(): ", __func__, __VA_ARGS__) +/* >8 End of setting up dynamic logging */ /** when we resize a file structure, how many extra entries
Signature · 1 line
1.8.3.1
PATCH v2 5/17 compressdev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/compressdev/rte_compressdev_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/compressdev/rte_compressdev_internal.h +2 -2
@@ -23,8 +23,8 @@extern int compressdev_logtype;#define RTE_LOGTYPE_COMPRESSDEV compressdev_logtype -#define COMPRESSDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, COMPRESSDEV, "%s(): " fmt, __func__, ## args) +#define COMPRESSDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, COMPRESSDEV, "%s(): ", __func__, __VA_ARGS__)/** * Dequeue processed packets from queue pair of a device.
Signature · 1 line
1.8.3.1
PATCH v2 8/17 net: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/net/rte_net_crc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/net/rte_net_crc.c +2 -2
@@ -73,8 +73,8 @@RTE_LOG_REGISTER_DEFAULT (libnet_logtype,INFO );#define RTE_LOGTYPE_NET libnet_logtype -#define NET_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, NET, "%s(): " fmt, __func__, ## args) +#define NET_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, NET, "%s(): ", __func__, __VA_ARGS__)/* Scalar handling */
Signature · 1 line
1.8.3.1
PATCH v2 6/17 metrics: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/metrics/rte_metrics_telemetry.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/metrics/rte_metrics_telemetry.c +6 -6
@@ -19,14 +19,14 @@#define RTE_LOGTYPE_METRICS metrics_log_level/* Logging Macros */ -#define METRICS_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, METRICS, "%s(): "fmt, __func__, ## args) +#define METRICS_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, METRICS, "%s(): ", __func__, __VA_ARGS__) -#define METRICS_LOG_ERR(fmt, args...) \ - METRICS_LOG(ERR, fmt, ## args) +#define METRICS_LOG_ERR (...) \ + METRICS_LOG(ERR, __VA_ARGS__) -#define METRICS_LOG_WARN(fmt, args...) \ - METRICS_LOG(WARNING, fmt, ## args) +#define METRICS_LOG_WARN (...) \ + METRICS_LOG(WARNING, __VA_ARGS__)static int32_t rte_metrics_tel_reg_port_ethdev_to_metrics (uint16_t port_id)
Signature · 1 line
1.8.3.1
PATCH v2 10/17 power: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/power/power_common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/power/power_common.h +3 -3
@@ -16,10 +16,10 @@ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)#ifdef RTE_LIBRTE_POWER_DEBUG -#define POWER_DEBUG_LOG(fmt, args...) \ - RTE_LOG_LINE(ERR, POWER, "%s: " fmt, __func__, ## args) +#define POWER_DEBUG_LOG (...) \ + RTE_LOG_LINE_PREFIX(ERR, POWER, "%s(): ", __func__, __VA_ARGS__)#else -#define POWER_DEBUG_LOG(fmt, args...) +#define POWER_DEBUG_LOG (fmt, ...)#endif /* check if scaling driver matches one we want */
Signature · 1 line
1.8.3.1
PATCH v2 11/17 rawdev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/rawdev/rte_rawdev_pmd.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
lib/rawdev/rte_rawdev_pmd.h +9 -8
@@ -30,16 +30,17 @@#define RTE_LOGTYPE_RAWDEV librawdev_logtype/* Logging Macros */ -#define RTE_RDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RAWDEV, "%s(): " fmt, __func__, ##args) +#define RTE_RDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, RAWDEV, "%s(): ", __func__, __VA_ARGS__) -#define RTE_RDEV_ERR(fmt, args...) \ - RTE_RDEV_LOG(ERR, fmt, ## args) -#define RTE_RDEV_DEBUG(fmt, args...) \ - RTE_RDEV_LOG(DEBUG, fmt, ## args) -#define RTE_RDEV_INFO(fmt, args...) \ - RTE_RDEV_LOG(INFO, fmt, ## args) +#define RTE_RDEV_ERR (...) \ + RTE_RDEV_LOG(ERR, __VA_ARGS__) +#define RTE_RDEV_DEBUG (...) \ + RTE_RDEV_LOG(DEBUG, __VA_ARGS__) + +#define RTE_RDEV_INFO (...) \ + RTE_RDEV_LOG(INFO, __VA_ARGS__)/* Macros to check for valid device */ #define RTE_RAWDEV_VALID_DEVID_OR_ERR_RET (dev_id, retval) do { \
Signature · 1 line
1.8.3.1
PATCH v2 9/17 pdump: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/pdump/rte_pdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/pdump/rte_pdump.c +2 -2
@@ -18,8 +18,8 @@RTE_LOG_REGISTER_DEFAULT (pdump_logtype,NOTICE );#define RTE_LOGTYPE_PDUMP pdump_logtype -#define PDUMP_LOG_LINE(level, fmt, args...) \ - RTE_LOG_LINE(level, PDUMP, "%s(): " fmt, __func__, ## args) +#define PDUMP_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, PDUMP, "%s(): ", __func__, __VA_ARGS__)/* Used for the multi-process communication */ #define PDUMP_MP "mp_pdump"
Signature · 1 line
1.8.3.1
PATCH v2 7/17 mldev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/mldev/rte_mldev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/mldev/rte_mldev.h +2 -2
@@ -146,8 +146,8 @@extern int rte_ml_dev_logtype;#define RTE_LOGTYPE_MLDEV rte_ml_dev_logtype -#define RTE_MLDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, MLDEV, "%s(): " fmt, __func__, ##args) +#define RTE_MLDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, MLDEV, "%s(): ", __func__, __VA_ARGS__)#define RTE_ML_STR_MAX 128/**< Maximum length of name string */
Signature · 1 line
1.8.3.1
PATCH v2 13/17 stack: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/stack/stack_pvt.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
lib/stack/stack_pvt.h +8 -8
@@ -10,16 +10,16 @@extern int stack_logtype;#define RTE_LOGTYPE_STACK stack_logtype -#define STACK_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, STACK, "%s(): "fmt, __func__, ##args) +#define STACK_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, STACK, "%s(): ", __func__, __VA_ARGS__) -#define STACK_LOG_ERR(fmt, args...) \ - STACK_LOG(ERR, fmt, ## args) +#define STACK_LOG_ERR (...) \ + STACK_LOG(ERR, __VA_ARGS__) -#define STACK_LOG_WARN(fmt, args...) \ - STACK_LOG(WARNING, fmt, ## args) +#define STACK_LOG_WARN (...) \ + STACK_LOG(WARNING, __VA_ARGS__) -#define STACK_LOG_INFO(fmt, args...) \ - STACK_LOG(INFO, fmt, ## args) +#define STACK_LOG_INFO (fmt, ...) \ + STACK_LOG(INFO, __VA_ARGS__)#endif /* _STACK_PVT_H_ */
Signature · 1 line
1.8.3.1
PATCH v2 15/17 vhost: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/vhost/vhost.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/vhost/vhost.h +4 -4
@@ -679,11 +679,11 @@ void __vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,extern int vhost_data_log_level;#define RTE_LOGTYPE_VHOST_DATA vhost_data_log_level -#define VHOST_CONFIG_LOG(prefix, level, fmt, args...) \ - RTE_LOG_LINE(level, VHOST_CONFIG, "(%s) " fmt, prefix, ##args) +#define VHOST_CONFIG_LOG (prefix, level, ...) \ + RTE_LOG_LINE_PREFIX(level, VHOST_CONFIG, "(%s) ", prefix, __VA_ARGS__) -#define VHOST_DATA_LOG(prefix, level, fmt, args...) \ - RTE_LOG_DP_LINE(level, VHOST_DATA, "(%s) " fmt, prefix, ##args) +#define VHOST_DATA_LOG (prefix, level, ...) \ + RTE_LOG_DP_LINE_PREFIX(level, VHOST_DATA, "(%s) ", prefix, __VA_ARGS__)#ifdef RTE_LIBRTE_VHOST_DEBUG #define VHOST_MAX_PRINT_BUFF 6072
Signature · 1 line
1.8.3.1
PATCH v2 12/17 rcu: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/rcu/rte_rcu_qsbr.c | 4 ++-- lib/rcu/rte_rcu_qsbr.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
lib/rcu/rte_rcu_qsbr.c +2 -2
@@ -19,8 +19,8 @@#include "rte_rcu_qsbr.h" #include "rcu_qsbr_pvt.h" -#define RCU_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) +#define RCU_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__)/* Get the memory size of QSBR variable */ size_t
lib/rcu/rte_rcu_qsbr.h +6 -6
@@ -39,19 +39,19 @@#define RTE_LOGTYPE_RCU rte_rcu_log_type#if RTE_LOG_DP_LEVEL >=RTE_LOG_DEBUG -#define __RTE_RCU_DP_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) +#define __RTE_RCU_DP_LOG (level, ...) \ + RTE_LOG_DP_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__)#else -#define __RTE_RCU_DP_LOG(level, fmt, args...) +#define __RTE_RCU_DP_LOG (level, ...)#endif #if defined(RTE_LIBRTE_RCU_DEBUG ) -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) do { \ +#define __RTE_RCU_IS_LOCK_CNT_ZERO (v, thread_id, level, ...) do { \ if (v->qsbr_cnt[thread_id].lock_cnt) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args); \ + RTE_LOG_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__); \ } while (0)#else -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) +#define __RTE_RCU_IS_LOCK_CNT_ZERO (v, thread_id, level, fmt, ...)#endif /* Registered thread IDs are stored as a bitmap of 64b element array.
Signature · 1 line
1.8.3.1
PATCH v2 17/17 ip_frag: stop using variadic argument pack extension
In reply to Tyler RetzlaffRemove use of args... and just use __VA_ARGS__. The macros expanding the argument pack do not require args extension to remove trailing comma.
--- lib/ip_frag/ip_frag_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/ip_frag/ip_frag_common.h +2 -2
@@ -26,9 +26,9 @@ RTE_LOG_LINE(level, IPFRAG, "" __VA_ARGS__)#ifdef RTE_LIBRTE_IP_FRAG_DEBUG -#define IP_FRAG_LOG(lvl, fmt, args...) RTE_LOG(lvl, IPFRAG, fmt, ##args) +#define IP_FRAG_LOG (lvl, ...) RTE_LOG(lvl, IPFRAG, __VA_ARGS__)#else -#define IP_FRAG_LOG(lvl, fmt, args...) do {} while(0) +#define IP_FRAG_LOG (lvl, fmt, ...) do {} while (0)#endif /* IP_FRAG_DEBUG */ #define IPV4_KEYLEN 1
Signature · 1 line
1.8.3.1
PATCH v2 16/17 vhost: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/vhost/vhost_crypto.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
lib/vhost/vhost_crypto.c +11 -10
@@ -20,19 +20,20 @@RTE_LOG_REGISTER_SUFFIX (vhost_crypto_logtype, crypto,INFO );#define RTE_LOGTYPE_VHOST_CRYPTO vhost_crypto_logtype -#define VC_LOG_ERR(fmt, args...) \ - RTE_LOG_LINE(ERR, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) -#define VC_LOG_INFO(fmt, args...) \ - RTE_LOG_LINE(INFO, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) +#define VC_LOG_ERR (...) \ + RTE_LOG_LINE_PREFIX(ERR, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ _RTE_LOG_COMMA __LINE__, __VA_ARGS__) + +#define VC_LOG_INFO (...) \ + RTE_LOG_LINE_PREFIX(INFO, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ _RTE_LOG_COMMA __LINE__, __VA_ARGS__)#ifdef RTE_LIBRTE_VHOST_DEBUG -#define VC_LOG_DBG(fmt, args...) \ - RTE_LOG_LINE(DEBUG, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) +#define VC_LOG_DBG (...) \ + RTE_LOG_LINE_PREFIX(DEBUG, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ _RTE_LOG_COMMA __LINE__, __VA_ARGS__)#else -#define VC_LOG_DBG(fmt, args...) +#define VC_LOG_DBG (fmt, ...)#endif #define VIRTIO_CRYPTO_FEATURES ((1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
Signature · 1 line
1.8.3.1
PATCH v2 14/17 eal: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of EAL_LOG in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/eal/common/eal_trace.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/eal/common/eal_trace.h +4 -4
@@ -16,11 +16,11 @@#include "eal_private.h" #include "eal_thread.h" -#define trace_err(fmt, args...) \ - EAL_LOG(ERR, "%s():%u " fmt, __func__, __LINE__, ## args) +#define trace_err (...) \ + RTE_LOG_LINE_PREFIX(ERR, EAL, "%s():%u ", __func__ _RTE_LOG_COMMA __LINE__, __VA_ARGS__) -#define trace_crit(fmt, args...) \ - EAL_LOG(CRIT, "%s():%u " fmt, __func__, __LINE__, ## args) +#define trace_crit (...) \ + RTE_LOG_LINE_PREFIX(CRIT, EAL, "%s():%u ", __func__ _RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32
Signature · 1 line
1.8.3.1
RE: [PATCH v2 00/17] stop using variadic argument pack extension
In reply to Tyler RetzlaffQuoted 15 lines
From: Tyler Retzlaff [mailto:[email protected]]
Sent: Friday, 23 February 2024 00.46
RTE_LOG_LINEcannot be augmented with a prefix format and arguments without the user ofRTE_LOG_LINEusing the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.Provide a new/similar macro
RTE_LOG_LINE_PREFIXthat accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside ofRTE_FMT()allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with__VA_ARGS__avoiding the need for conditional comma removal.
Quoted 5 lines
I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
note: due to drastic change in series i have not carried any series acks
forward.
Re: [PATCH v2 01/17] log: add a per line log helper with parameterized prefix
In reply to Tyler Retzlaff23/02/2024 00:46, Tyler Retzlaff:
Quoted 4 lines
Providing a custom prefix when logging is common for components. Lift ISO C99 compliant helper macros from
mlx5_common.hand provideRTE_LOG_LINE_PREFIXmacro that can expand similar toRTE_LOG_LINEwith a custom prefix and argument list.
[...]
Quoted 1 line
Quoted 1 line
+#define
_RTE_LOG_COMMA,
I'm not sure about the underscore at the beginning. Anyway it is exported in the API.
By the way it should have a Doxygen comment.
lib/log/rte_log.h int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) · line 394
Quoted 12 lines
lib/log/rte_log.h +12
-0+ +#define RTE_LOG_LINE_PREFIX (l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args _RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) + +#define RTE_LOG_DP_LINE_PREFIX (l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG_DP(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args _RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0)
Please could you add a Doxygen comment for each RTE_LOG_LINE variations, including previous ones?
Would be nice to have an idea of the output what DP is doing.
v3 cover stop using variadic argument pack extension
In reply to Tyler RetzlaffRTE_LOG_LINE cannot be augmented with a prefix format and arguments without the user of RTE_LOG_LINE using the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.
Provide a new/similar macro RTE_LOG_LINE_PREFIX that accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside of RTE_FMT() allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with __VA_ARGS__ avoiding the need for conditional comma removal.
I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
note: due to drastic change in series i have not carried any series acks
forward.
v3:
* remove leading _ from RTE_LOG_COMMA the macro is not internal
* add doxygen comment for existing RTE_LOG{,DP}_LINE function-like macros, based on RTE_LOG{,DP} comments.
* add doxygen comment for new RTE_LOG{,DP}_LINE_PREFIX function-like macros, based on RTE_LOG{,DP} comments.
* merge 2 vhost patches into a single patch (mistake in previous submission)
v2:
* revamp entire series to be ISO C99 compliant, stop using variadic argument pack extension.
Tyler Retzlaff (16):
log: add a per line log helper with parameterized prefix
bpf: stop using variadic argument pack extension
cfgfile: stop using variadic argument pack extension
cmdline: stop using variadic argument pack extension
compressdev: stop using variadic argument pack extension
metrics: stop using variadic argument pack extension
mldev: stop using variadic argument pack extension
net: stop using variadic argument pack extension
pdump: stop using variadic argument pack extension
power: stop using variadic argument pack extension
rawdev: stop using variadic argument pack extension
rcu: stop using variadic argument pack extension
stack: stop using variadic argument pack extension
eal: stop using variadic argument pack extension
vhost: stop using variadic argument pack extension
ip_frag: stop using variadic argument pack extension
lib/bpf/bpf_impl.h | 4 +- lib/cfgfile/rte_cfgfile.c | 5 +- lib/cmdline/cmdline_parse.c | 2 +- lib/cmdline/cmdline_parse_num.c | 4 +- lib/compressdev/rte_compressdev_internal.h | 4 +- lib/eal/common/eal_trace.h | 8 +-- lib/ip_frag/ip_frag_common.h | 4 +- lib/log/rte_log.h | 97 ++++++++++++++++++++++++++++++ lib/metrics/rte_metrics_telemetry.c | 12 ++-- lib/mldev/rte_mldev.h | 4 +- lib/net/rte_net_crc.c | 4 +- lib/pdump/rte_pdump.c | 4 +- lib/power/power_common.h | 6 +- lib/rawdev/rte_rawdev_pmd.h | 17 +++--- lib/rcu/rte_rcu_qsbr.c | 4 +- lib/rcu/rte_rcu_qsbr.h | 12 ++-- lib/stack/stack_pvt.h | 16 ++--- lib/vhost/vhost.h | 8 +-- lib/vhost/vhost_crypto.c | 21 ++++--- 19 files changed, 168 insertions(+), 68 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v3 1/16 log: add a per line log helper with parameterized prefix
Providing a custom prefix when logging is common for components. Lift ISO C99 compliant helper macros from mlx5_common.h and provide RTE_LOG_LINE_PREFIX macro that can expand similar to RTE_LOG_LINE with a custom prefix and argument list.
--- lib/log/rte_log.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)
lib/log/rte_log.h +97 -0
@@ -367,18 +367,115 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)#define RTE_LOG_CHECK_NO_NEWLINE (...)#endif +/** +* Generates a log message with a single trailing newline. +* +* The RTE_LOG_LINE() is a helper that expands logging of a message +* with RTE_LOG() appending a single newline to the formatted message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ #define RTE_LOG_LINE (l, t, ...) do { \ RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(__VA_ARGS__ ,)); \ RTE_LOG(l, t, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ RTE_FMT_TAIL(__VA_ARGS__ ,))); \ } while (0) +/** +* Generates a log message for data path with a single trailing newline. +* +* Similar to RTE_LOG_LINE(), except that it is removed at compilation +* time if the RTE_LOG_DP_LEVEL configuration option is lower than the +* log level argument. +* +* The RTE_LOG_LINE() is a helper that expands logging of a message +* with RTE_LOG_DP() appending a single newline to the formatted +* message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ #define RTE_LOG_DP_LINE (l, t, ...) do { \ RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(__VA_ARGS__ ,)); \ RTE_LOG_DP(l, t, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ RTE_FMT_TAIL(__VA_ARGS__ ,))); \ } while (0) +#define RTE_LOG_COMMA , + +/* +* Generates a log message with a supplied prefix and arguments with a +* single trailing newline. +* +* The RTE_LOG_LINE_PREFIX() is a helper that expands logging of a +* message with RTE_LOG() prepending the supplied prefix and arguments +* appending a single newline to the formatted message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param prefix +* The prefix format string. +* @param args +* The arguments for the prefix format string. If args contains +* multiple arguments use RTE_LOG_COMMA to defer expansion. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ +#define RTE_LOG_LINE_PREFIX (l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) + +/* +* Generates a log message for the data path with a supplied prefix and +* arguments with a single trailing newline. +* +* The RTE_LOG_DP_LINE_PREFIX() is a helper that expands logging of a +* message with RTE_LOG_DP() prepending the supplied prefix and +* arguments appending a single newline to the formatted message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param prefix +* The prefix format string. +* @param args +* The arguments for the prefix format string. If args contains +* multiple arguments use RTE_LOG_COMMA to defer expansion. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ +#define RTE_LOG_DP_LINE_PREFIX (l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG_DP(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) +#define RTE_LOG_REGISTER_IMPL (type, name, level) \ int type; \ RTE_INIT(__##type) \
Signature · 1 line
1.8.3.1
PATCH v3 3/16 cfgfile: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/cfgfile/rte_cfgfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/cfgfile/rte_cfgfile.c +3 -2
@@ -31,8 +31,9 @@ struct rte_cfgfile {RTE_LOG_REGISTER_DEFAULT (cfgfile_logtype,INFO );#define RTE_LOGTYPE_CFGFILE cfgfile_logtype -#define CFG_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## args) +#define CFG_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, CFGFILE, "%s(): ", __func__, __VA_ARGS__) +/* >8 End of setting up dynamic logging */ /** when we resize a file structure, how many extra entries
Signature · 1 line
1.8.3.1
PATCH v3 2/16 bpf: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bpf/bpf_impl.h +2 -2
@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, BPF, "%s(): ", __func__, __VA_ARGS__)static inline size_t bpf_size (uint32_t bpf_op_sz)
Signature · 1 line
1.8.3.1
PATCH v3 4/16 cmdline: stop using variadic argument pack extension
In reply to Tyler RetzlaffRemove use of args... and just use __VA_ARGS__. The macros expanding the argument pack do not require args extension to remove trailing comma.
--- lib/cmdline/cmdline_parse.c | 2 +- lib/cmdline/cmdline_parse_num.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/cmdline/cmdline_parse.c +1 -1
@@ -16,7 +16,7 @@#ifdef RTE_LIBRTE_CMDLINE_DEBUG #define debug_printf printf#else -#define debug_printf(args...) do {} while(0) +#define debug_printf (...) do {} while (0)#endif #define CMDLINE_BUFFER_SIZE 64
lib/cmdline/cmdline_parse_num.c +2 -2
@@ -14,9 +14,9 @@#include "cmdline_parse_num.h" #ifdef RTE_LIBRTE_CMDLINE_DEBUG -#define debug_printf(args...) printf(args) +#define debug_printf (...) printf(__VA_ARGS__)#else -#define debug_printf(args...) do {} while(0) +#define debug_printf (...) do {} while (0)#endif struct cmdline_token_ops cmdline_token_num_ops = {
Signature · 1 line
1.8.3.1
PATCH v3 5/16 compressdev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/compressdev/rte_compressdev_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/compressdev/rte_compressdev_internal.h +2 -2
@@ -23,8 +23,8 @@extern int compressdev_logtype;#define RTE_LOGTYPE_COMPRESSDEV compressdev_logtype -#define COMPRESSDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, COMPRESSDEV, "%s(): " fmt, __func__, ## args) +#define COMPRESSDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, COMPRESSDEV, "%s(): ", __func__, __VA_ARGS__)/** * Dequeue processed packets from queue pair of a device.
Signature · 1 line
1.8.3.1
PATCH v3 9/16 pdump: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/pdump/rte_pdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/pdump/rte_pdump.c +2 -2
@@ -18,8 +18,8 @@RTE_LOG_REGISTER_DEFAULT (pdump_logtype,NOTICE );#define RTE_LOGTYPE_PDUMP pdump_logtype -#define PDUMP_LOG_LINE(level, fmt, args...) \ - RTE_LOG_LINE(level, PDUMP, "%s(): " fmt, __func__, ## args) +#define PDUMP_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, PDUMP, "%s(): ", __func__, __VA_ARGS__)/* Used for the multi-process communication */ #define PDUMP_MP "mp_pdump"
Signature · 1 line
1.8.3.1
PATCH v3 6/16 metrics: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/metrics/rte_metrics_telemetry.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/metrics/rte_metrics_telemetry.c +6 -6
@@ -19,14 +19,14 @@#define RTE_LOGTYPE_METRICS metrics_log_level/* Logging Macros */ -#define METRICS_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, METRICS, "%s(): "fmt, __func__, ## args) +#define METRICS_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, METRICS, "%s(): ", __func__, __VA_ARGS__) -#define METRICS_LOG_ERR(fmt, args...) \ - METRICS_LOG(ERR, fmt, ## args) +#define METRICS_LOG_ERR (...) \ + METRICS_LOG(ERR, __VA_ARGS__) -#define METRICS_LOG_WARN(fmt, args...) \ - METRICS_LOG(WARNING, fmt, ## args) +#define METRICS_LOG_WARN (...) \ + METRICS_LOG(WARNING, __VA_ARGS__)static int32_t rte_metrics_tel_reg_port_ethdev_to_metrics (uint16_t port_id)
Signature · 1 line
1.8.3.1
PATCH v3 7/16 mldev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/mldev/rte_mldev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/mldev/rte_mldev.h +2 -2
@@ -146,8 +146,8 @@extern int rte_ml_dev_logtype;#define RTE_LOGTYPE_MLDEV rte_ml_dev_logtype -#define RTE_MLDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, MLDEV, "%s(): " fmt, __func__, ##args) +#define RTE_MLDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, MLDEV, "%s(): ", __func__, __VA_ARGS__)#define RTE_ML_STR_MAX 128/**< Maximum length of name string */
Signature · 1 line
1.8.3.1
PATCH v3 14/16 eal: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of EAL_LOG in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/eal/common/eal_trace.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/eal/common/eal_trace.h +4 -4
@@ -16,11 +16,11 @@#include "eal_private.h" #include "eal_thread.h" -#define trace_err(fmt, args...) \ - EAL_LOG(ERR, "%s():%u " fmt, __func__, __LINE__, ## args) +#define trace_err (...) \ + RTE_LOG_LINE_PREFIX(ERR, EAL, "%s():%u ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__) -#define trace_crit(fmt, args...) \ - EAL_LOG(CRIT, "%s():%u " fmt, __func__, __LINE__, ## args) +#define trace_crit (...) \ + RTE_LOG_LINE_PREFIX(CRIT, EAL, "%s():%u ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32
Signature · 1 line
1.8.3.1
PATCH v3 8/16 net: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/net/rte_net_crc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/net/rte_net_crc.c +2 -2
@@ -73,8 +73,8 @@RTE_LOG_REGISTER_DEFAULT (libnet_logtype,INFO );#define RTE_LOGTYPE_NET libnet_logtype -#define NET_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, NET, "%s(): " fmt, __func__, ## args) +#define NET_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, NET, "%s(): ", __func__, __VA_ARGS__)/* Scalar handling */
Signature · 1 line
1.8.3.1
PATCH v3 12/16 rcu: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/rcu/rte_rcu_qsbr.c | 4 ++-- lib/rcu/rte_rcu_qsbr.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
lib/rcu/rte_rcu_qsbr.c +2 -2
@@ -19,8 +19,8 @@#include "rte_rcu_qsbr.h" #include "rcu_qsbr_pvt.h" -#define RCU_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) +#define RCU_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__)/* Get the memory size of QSBR variable */ size_t
lib/rcu/rte_rcu_qsbr.h +6 -6
@@ -39,19 +39,19 @@#define RTE_LOGTYPE_RCU rte_rcu_log_type#if RTE_LOG_DP_LEVEL >=RTE_LOG_DEBUG -#define __RTE_RCU_DP_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) +#define __RTE_RCU_DP_LOG (level, ...) \ + RTE_LOG_DP_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__)#else -#define __RTE_RCU_DP_LOG(level, fmt, args...) +#define __RTE_RCU_DP_LOG (level, ...)#endif #if defined(RTE_LIBRTE_RCU_DEBUG ) -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) do { \ +#define __RTE_RCU_IS_LOCK_CNT_ZERO (v, thread_id, level, ...) do { \ if (v->qsbr_cnt[thread_id].lock_cnt) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args); \ + RTE_LOG_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__); \ } while (0)#else -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) +#define __RTE_RCU_IS_LOCK_CNT_ZERO (v, thread_id, level, fmt, ...)#endif /* Registered thread IDs are stored as a bitmap of 64b element array.
Signature · 1 line
1.8.3.1
PATCH v3 15/16 vhost: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/vhost/vhost.h | 8 ++++---- lib/vhost/vhost_crypto.c | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-)
lib/vhost/vhost.h +4 -4
@@ -679,11 +679,11 @@ void __vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,extern int vhost_data_log_level;#define RTE_LOGTYPE_VHOST_DATA vhost_data_log_level -#define VHOST_CONFIG_LOG(prefix, level, fmt, args...) \ - RTE_LOG_LINE(level, VHOST_CONFIG, "(%s) " fmt, prefix, ##args) +#define VHOST_CONFIG_LOG (prefix, level, ...) \ + RTE_LOG_LINE_PREFIX(level, VHOST_CONFIG, "(%s) ", prefix, __VA_ARGS__) -#define VHOST_DATA_LOG(prefix, level, fmt, args...) \ - RTE_LOG_DP_LINE(level, VHOST_DATA, "(%s) " fmt, prefix, ##args) +#define VHOST_DATA_LOG (prefix, level, ...) \ + RTE_LOG_DP_LINE_PREFIX(level, VHOST_DATA, "(%s) ", prefix, __VA_ARGS__)#ifdef RTE_LIBRTE_VHOST_DEBUG #define VHOST_MAX_PRINT_BUFF 6072
lib/vhost/vhost_crypto.c +11 -10
@@ -20,19 +20,20 @@RTE_LOG_REGISTER_SUFFIX (vhost_crypto_logtype, crypto,INFO );#define RTE_LOGTYPE_VHOST_CRYPTO vhost_crypto_logtype -#define VC_LOG_ERR(fmt, args...) \ - RTE_LOG_LINE(ERR, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) -#define VC_LOG_INFO(fmt, args...) \ - RTE_LOG_LINE(INFO, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) +#define VC_LOG_ERR (...) \ + RTE_LOG_LINE_PREFIX(ERR, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__) + +#define VC_LOG_INFO (...) \ + RTE_LOG_LINE_PREFIX(INFO, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#ifdef RTE_LIBRTE_VHOST_DEBUG -#define VC_LOG_DBG(fmt, args...) \ - RTE_LOG_LINE(DEBUG, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) +#define VC_LOG_DBG (...) \ + RTE_LOG_LINE_PREFIX(DEBUG, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#else -#define VC_LOG_DBG(fmt, args...) +#define VC_LOG_DBG (fmt, ...)#endif #define VIRTIO_CRYPTO_FEATURES ((1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
Signature · 1 line
1.8.3.1
PATCH v3 13/16 stack: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/stack/stack_pvt.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
lib/stack/stack_pvt.h +8 -8
@@ -10,16 +10,16 @@extern int stack_logtype;#define RTE_LOGTYPE_STACK stack_logtype -#define STACK_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, STACK, "%s(): "fmt, __func__, ##args) +#define STACK_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, STACK, "%s(): ", __func__, __VA_ARGS__) -#define STACK_LOG_ERR(fmt, args...) \ - STACK_LOG(ERR, fmt, ## args) +#define STACK_LOG_ERR (...) \ + STACK_LOG(ERR, __VA_ARGS__) -#define STACK_LOG_WARN(fmt, args...) \ - STACK_LOG(WARNING, fmt, ## args) +#define STACK_LOG_WARN (...) \ + STACK_LOG(WARNING, __VA_ARGS__) -#define STACK_LOG_INFO(fmt, args...) \ - STACK_LOG(INFO, fmt, ## args) +#define STACK_LOG_INFO (fmt, ...) \ + STACK_LOG(INFO, __VA_ARGS__)#endif /* _STACK_PVT_H_ */
Signature · 1 line
1.8.3.1
PATCH v3 10/16 power: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/power/power_common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/power/power_common.h +3 -3
@@ -16,10 +16,10 @@ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)#ifdef RTE_LIBRTE_POWER_DEBUG -#define POWER_DEBUG_LOG(fmt, args...) \ - RTE_LOG_LINE(ERR, POWER, "%s: " fmt, __func__, ## args) +#define POWER_DEBUG_LOG (...) \ + RTE_LOG_LINE_PREFIX(ERR, POWER, "%s(): ", __func__, __VA_ARGS__)#else -#define POWER_DEBUG_LOG(fmt, args...) +#define POWER_DEBUG_LOG (fmt, ...)#endif /* check if scaling driver matches one we want */
Signature · 1 line
1.8.3.1
PATCH v3 11/16 rawdev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/rawdev/rte_rawdev_pmd.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
lib/rawdev/rte_rawdev_pmd.h +9 -8
@@ -30,16 +30,17 @@#define RTE_LOGTYPE_RAWDEV librawdev_logtype/* Logging Macros */ -#define RTE_RDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RAWDEV, "%s(): " fmt, __func__, ##args) +#define RTE_RDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, RAWDEV, "%s(): ", __func__, __VA_ARGS__) -#define RTE_RDEV_ERR(fmt, args...) \ - RTE_RDEV_LOG(ERR, fmt, ## args) -#define RTE_RDEV_DEBUG(fmt, args...) \ - RTE_RDEV_LOG(DEBUG, fmt, ## args) -#define RTE_RDEV_INFO(fmt, args...) \ - RTE_RDEV_LOG(INFO, fmt, ## args) +#define RTE_RDEV_ERR (...) \ + RTE_RDEV_LOG(ERR, __VA_ARGS__) +#define RTE_RDEV_DEBUG (...) \ + RTE_RDEV_LOG(DEBUG, __VA_ARGS__) + +#define RTE_RDEV_INFO (...) \ + RTE_RDEV_LOG(INFO, __VA_ARGS__)/* Macros to check for valid device */ #define RTE_RAWDEV_VALID_DEVID_OR_ERR_RET (dev_id, retval) do { \
Signature · 1 line
1.8.3.1
PATCH v3 16/16 ip_frag: stop using variadic argument pack extension
In reply to Tyler RetzlaffRemove use of args... and just use __VA_ARGS__. The macros expanding the argument pack do not require args extension to remove trailing comma.
--- lib/ip_frag/ip_frag_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/ip_frag/ip_frag_common.h +2 -2
@@ -26,9 +26,9 @@ RTE_LOG_LINE(level, IPFRAG, "" __VA_ARGS__)#ifdef RTE_LIBRTE_IP_FRAG_DEBUG -#define IP_FRAG_LOG(lvl, fmt, args...) RTE_LOG(lvl, IPFRAG, fmt, ##args) +#define IP_FRAG_LOG (lvl, ...) RTE_LOG(lvl, IPFRAG, __VA_ARGS__)#else -#define IP_FRAG_LOG(lvl, fmt, args...) do {} while(0) +#define IP_FRAG_LOG (lvl, fmt, ...) do {} while (0)#endif /* IP_FRAG_DEBUG */ #define IPV4_KEYLEN 1
Signature · 1 line
1.8.3.1
Re: [PATCH v3 00/16] stop using variadic argument pack extension
In reply to Tyler RetzlaffQuoted 12 lines · On Mon, 26 Feb 2024 12:19:30 -0800 Tyler Retzlaff…
RTE_LOG_LINEcannot be augmented with a prefix format and arguments without the user ofRTE_LOG_LINEusing the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.Provide a new/similar macro
RTE_LOG_LINE_PREFIXthat accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside ofRTE_FMT()allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with__VA_ARGS__avoiding the need for conditional comma removal.
Quoted 5 lines
I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
note: due to drastic change in series i have not carried any series acks
forward.
The changes look good, you might want to add release note, update coding style doc, and/or update checkpatch to discourage re-introduction.
RE: [PATCH v3 02/16] bpf: stop using variadic argument pack extension
In reply to Tyler RetzlaffQuoted 18 lines
Subject: [PATCH v3 02/16] bpf: stop using variadic argument pack extension
Use
RTE_LOG_LINE_PREFIXinstead ofRTE_LOG_LINEin macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.Signed-off-by Tyler Retzlaff <[email protected]>--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/bpf/bpf_impl.h +0
-0@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;
lib/bpf/bpf_impl.h struct rte_bpf {
Quoted 10 lines
lib/bpf/bpf_impl.h +2
-3#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, BPF, "%s(): ", __func__, __VA_ARGS__)static inline size_t bpf_size (uint32_t bpf_op_sz) --
Quoted 1 line
1.8.3.1
RE: [PATCH v3 16/16] ip_frag: stop using variadic argument pack extension
In reply to Tyler RetzlaffQuoted 19 lines
Subject: [PATCH v3 16/16]
ip_frag: stop using variadic argument pack extensionRemove use of args... and just use
__VA_ARGS__. The macros expanding the argument pack do not require args extension to remove trailing comma.Signed-off-by Tyler Retzlaff <[email protected]>--- lib/ip_frag/ip_frag_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/ip_frag/ip_frag_common.h +0
-0@@ -26,9 +26,9 @@RTE_LOG_LINE (level,IPFRAG ,"" __VA_ARGS__)
lib/ip_frag/ip_frag_common.h
Quoted 10 lines
lib/ip_frag/ip_frag_common.h +2
-3#ifdef RTE_LIBRTE_IP_FRAG_DEBUG -#define IP_FRAG_LOG(lvl, fmt, args...) RTE_LOG(lvl, IPFRAG, fmt, ##args) +#define IP_FRAG_LOG (lvl, ...) RTE_LOG(lvl, IPFRAG, __VA_ARGS__)#else -#define IP_FRAG_LOG(lvl, fmt, args...) do {} while(0) +#define IP_FRAG_LOG (lvl, fmt, ...) do {} while (0)#endif /* IP_FRAG_DEBUG */ #define IPV4_KEYLEN 1 --
Quoted 1 line
1.8.3.1
Re: [PATCH v3 00/16] stop using variadic argument pack extension
In reply to Stephen HemmingerQuoted 15 lines · Stephen Hemminger
Quoted 12 lines · On Mon, 26 Feb 2024 12:19:30 -0800 Tyler Retzlaff…
RTE_LOG_LINEcannot be augmented with a prefix format and arguments without the user ofRTE_LOG_LINEusing the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.Provide a new/similar macro
RTE_LOG_LINE_PREFIXthat accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside ofRTE_FMT()allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with__VA_ARGS__avoiding the need for conditional comma removal.
Quoted 8 lines
Quoted 5 lines
I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
note: due to drastic change in series i have not carried any series acks
forward.The changes look good, you might want to add release note, update coding style doc, and/or update checkpatch to discourage re-introduction.
re-introduction should be protected by the CI. i know checkpatch would be better but i couldn't think of a good way to match an arbitrarily named pack ... reliably where it could potentially cause noise.
i'll look into style doc in a separate series since i think there are a couple of things i'd like to propose there now that we are using C11.
thanks for the review!
Quoted 2 lines
Series-acked-by Stephen Hemminger <[email protected]>
Re: [PATCH v3 00/16] stop using variadic argument pack extension
Quoted 23 lines · Tyler Retzlaff
Quoted 21 lines · Stephen Hemminger
Quoted 17 lines · On Mon, 26 Feb 2024 12:19:30 -0800 Tyler Retzlaff…
RTE_LOG_LINEcannot be augmented with a prefix format and arguments without the user ofRTE_LOG_LINEusing the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.Provide a new/similar macro
RTE_LOG_LINE_PREFIXthat accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside ofRTE_FMT()allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with__VA_ARGS__avoiding the need for conditional comma removal.I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
note: due to drastic change in series i have not carried any series acks
forward.
Quoted 6 lines
Quoted 2 lines
The changes look good, you might want to add release note, update coding style doc, and/or update checkpatch to discourage re-introduction.
re-introduction should be protected by the CI. i know checkpatch would be better but i couldn't think of a good way to match an arbitrarily named pack ... reliably where it could potentially cause noise.
What about a simple:
+ # forbid use of variadic argument pack extension in macros
+ awk -v FOLDERS="lib drivers app examples" \
+ -v
EXPRESSIONS='#[[:space:]]*define.*[^(,[:space:]]\\.\\.\\.[[:space:]]*)' \
+ -v RET_ON_FAIL=1 \ + -v MESSAGE='Do not use variadic argument pack in macros' \ + -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ + "$1" || res=1
+
Signature · 1 line
David Marchand
Re: [PATCH v3 02/16] bpf: stop using variadic argument pack extension
In reply to Tyler RetzlaffQuoted 15 lines · Tyler Retzlaff
Use
RTE_LOG_LINE_PREFIXinstead ofRTE_LOG_LINEin macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.Signed-off-by Tyler Retzlaff <[email protected]>--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/bpf/bpf_impl.h +0
-0
lib/bpf/bpf_impl.h struct rte_bpf { · line 33
Quoted 7 lines
lib/bpf/bpf_impl.h +2
-2@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, BPF, "%s(): ", __func__, __VA_ARGS__)
The patch $topic seems to be removal of variadic argument extension. So, I would expect a simple:
+#define RTE_BPF_LOG_LINE(level, ...) \
+ RTE_LOG_LINE(level, BPF, __VA_ARGS__)
Konstantin, just to be sure, are you ok with this (debug from my pov) prefix addition?
Signature · 1 line
David Marchand
RE: [PATCH v3 02/16] bpf: stop using variadic argument pack extension
Quoted 32 lines
Quoted 15 lines · Tyler Retzlaff
Use
RTE_LOG_LINE_PREFIXinstead ofRTE_LOG_LINEin macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.Signed-off-by Tyler Retzlaff <[email protected]>--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/bpf/bpf_impl.h +0
-0lib/bpf/bpf_impl.h struct rte_bpf { · line 33
Quoted 7 lines
lib/bpf/bpf_impl.h +2
-2@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, BPF, "%s(): ", __func__, __VA_ARGS__)The patch $topic seems to be removal of variadic argument extension. So, I would expect a simple:
(quoted diff) +2
-0+#define RTE_BPF_LOG_LINE(level, ...) \ + RTE_LOG_LINE(level, BPF, __VA_ARGS__)
Quoted 3 lines
Konstantin, just to be sure, are you ok with this (debug from my pov) prefix addition?
Thanks David for spotting it, yes somehow I missed that. Actually yes, yours variant looks correct to me. Konstantin.
Re: [PATCH v3 02/16] bpf: stop using variadic argument pack extension
Quoted 32 lines · Konstantin Ananyev
Quoted 32 lines
Quoted 15 lines · Tyler Retzlaff
Use
RTE_LOG_LINE_PREFIXinstead ofRTE_LOG_LINEin macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.Signed-off-by Tyler Retzlaff <[email protected]>--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/bpf/bpf_impl.h +0
-0lib/bpf/bpf_impl.h struct rte_bpf { · line 33
Quoted 7 lines
lib/bpf/bpf_impl.h +2
-2@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, BPF, "%s(): ", __func__, __VA_ARGS__)The patch $topic seems to be removal of variadic argument extension. So, I would expect a simple:
(quoted diff) +2
-0+#define RTE_BPF_LOG_LINE(level, ...) \ + RTE_LOG_LINE(level, BPF, __VA_ARGS__)
Quoted 7 lines
Quoted 3 lines
Konstantin, just to be sure, are you ok with this (debug from my pov) prefix addition?
Thanks David for spotting it, yes somehow I missed that. Actually yes, yours variant looks correct to me. Konstantin.
oh, sorry about this. i did not intend to add prefixes where there were none. would you like me to restore this with David's suggestion or would you like to keep the prefix with __func__?
let me know i'll make an adjustment to the series if necessary.
Quoted 1 line
Re: [PATCH v3 00/16] stop using variadic argument pack extension
In reply to David MarchandQuoted 39 lines · David Marchand
Quoted 23 lines · Tyler Retzlaff
Quoted 21 lines · Stephen Hemminger
Quoted 17 lines · On Mon, 26 Feb 2024 12:19:30 -0800 Tyler Retzlaff…
RTE_LOG_LINEcannot be augmented with a prefix format and arguments without the user ofRTE_LOG_LINEusing the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.Provide a new/similar macro
RTE_LOG_LINE_PREFIXthat accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside ofRTE_FMT()allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with__VA_ARGS__avoiding the need for conditional comma removal.I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
note: due to drastic change in series i have not carried any series acks
forward.Quoted 6 lines
Quoted 2 lines
The changes look good, you might want to add release note, update coding style doc, and/or update checkpatch to discourage re-introduction.
re-introduction should be protected by the CI. i know checkpatch would be better but i couldn't think of a good way to match an arbitrarily named pack ... reliably where it could potentially cause noise.
What about a simple:
(quoted diff) +3
-0+ # forbid use of variadic argument pack extension in macros + awk -v FOLDERS="lib drivers app examples" \ + -vEXPRESSIONS='#[[:space:]]*define.*[^(,[:space:]]\\.\\.\\.[[:space:]]*)' \
Review
Quoted 5 lines
(quoted diff) +5
-0+ -v RET_ON_FAIL=1 \ + -v MESSAGE='Do not use variadic argument pack in macros' \ + -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ + "$1" || res=1 +
I have no objection, I suppose worst case scenario if it turns out to catch things we don't want it to catch we can always ignore or remove it.
I will add the check and submit a new rev.
Quoted 4 lines
Signature · 2 lines
-- David Marchand
RE: [PATCH v3 02/16] bpf: stop using variadic argument pack extension
In reply to Tyler RetzlaffQuoted 39 lines · Konstantin Ananyev
Quoted 36 lines
Quoted 35 lines
Quoted 15 lines · Tyler Retzlaff
Use
RTE_LOG_LINE_PREFIXinstead ofRTE_LOG_LINEin macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.Signed-off-by Tyler Retzlaff <[email protected]>--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/bpf/bpf_impl.h +0
-0lib/bpf/bpf_impl.h struct rte_bpf { · line 33
Quoted 7 lines
lib/bpf/bpf_impl.h +2
-2@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, BPF, "%s(): ", __func__, __VA_ARGS__)The patch $topic seems to be removal of variadic argument extension. So, I would expect a simple:
(quoted diff) +2
-0+#define RTE_BPF_LOG_LINE(level, ...) \ + RTE_LOG_LINE(level, BPF, __VA_ARGS__)Konstantin, just to be sure, are you ok with this (debug from my pov) prefix addition?
Quoted 7 lines
Quoted 3 lines
Thanks David for spotting it, yes somehow I missed that. Actually yes, yours variant looks correct to me. Konstantin.
oh, sorry about this. i did not intend to add prefixes where there were none. would you like me to restore this with David's suggestion or would you like to keep the prefix with
__func__?
Please restore as David suggested.
No worries, after all I didn't spot it myself, all kudos goes to David :)
Re: [PATCH v3 02/16] bpf: stop using variadic argument pack extension
Quoted 43 lines · Konstantin Ananyev
Quoted 43 lines · Konstantin Ananyev
Quoted 39 lines
Quoted 32 lines
Quoted 15 lines · Tyler Retzlaff
Use
RTE_LOG_LINE_PREFIXinstead ofRTE_LOG_LINEin macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.Signed-off-by Tyler Retzlaff <[email protected]>--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/bpf/bpf_impl.h +0
-0lib/bpf/bpf_impl.h struct rte_bpf { · line 33
Quoted 7 lines
lib/bpf/bpf_impl.h +2
-2@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, BPF, "%s(): ", __func__, __VA_ARGS__)The patch $topic seems to be removal of variadic argument extension. So, I would expect a simple:
(quoted diff) +2
-0+#define RTE_BPF_LOG_LINE(level, ...) \ + RTE_LOG_LINE(level, BPF, __VA_ARGS__)Quoted 3 lines
Konstantin, just to be sure, are you ok with this (debug from my pov) prefix addition?
Thanks David for spotting it, yes somehow I missed that. Actually yes, yours variant looks correct to me. Konstantin.
Quoted 6 lines
Quoted 3 lines
oh, sorry about this. i did not intend to add prefixes where there were none. would you like me to restore this with David's suggestion or would you like to keep the prefix with
__func__?Please restore as David suggested.
No worries, after all I didn't spot it myself, all kudos goes to David :)
thanks, i'll submit a new rev!
Quoted 1 line
Re: [PATCH v3 00/16] stop using variadic argument pack extension
In reply to Tyler RetzlaffQuoted 19 lines · Tyler Retzlaff
RTE_LOG_LINEcannot be augmented with a prefix format and arguments without the user ofRTE_LOG_LINEusing the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.Provide a new/similar macro
RTE_LOG_LINE_PREFIXthat accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside ofRTE_FMT()allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with__VA_ARGS__avoiding the need for conditional comma removal.I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
note: due to drastic change in series i have not carried any series acks
forward.
Quoted 8 lines
v3:
* remove leading _ fromRTE_LOG_COMMAthe macro is not internal
* add doxygen comment for existing RTE_LOG{,DP}_LINE function-like macros, based on RTE_LOG{,DP} comments.
* add doxygen comment for new RTE_LOG{,DP}_LINE_PREFIX function-like macros, based on RTE_LOG{,DP} comments.
* merge 2 vhost patches into a single patch (mistake in previous submission)
I find this new helper less tricky to use and easier to read than the RTE_FMT_* stuff that gets copy/pasted everywhere.
The changes are quite mechanical, so even though we are past -rc1, +1 for me on the series.
Can we finish the job and convert remaining macros that prefix messages in lib/?
Signature · 1 line
David Marchand
Re: [PATCH v3 00/16] stop using variadic argument pack extension
Quoted 30 lines · David Marchand
Quoted 19 lines · Tyler Retzlaff
RTE_LOG_LINEcannot be augmented with a prefix format and arguments without the user ofRTE_LOG_LINEusing the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.Provide a new/similar macro
RTE_LOG_LINE_PREFIXthat accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside ofRTE_FMT()allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with__VA_ARGS__avoiding the need for conditional comma removal.I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
note: due to drastic change in series i have not carried any series acks
forward.Quoted 8 lines
v3:
* remove leading _ fromRTE_LOG_COMMAthe macro is not internal
* add doxygen comment for existing RTE_LOG{,DP}_LINE function-like macros, based on RTE_LOG{,DP} comments.
* add doxygen comment for new RTE_LOG{,DP}_LINE_PREFIX function-like macros, based on RTE_LOG{,DP} comments.
* merge 2 vhost patches into a single patch (mistake in previous submission)
Quoted 6 lines
I find this new helper less tricky to use and easier to read than the RTE_FMT_* stuff that gets copy/pasted everywhere.
The changes are quite mechanical, so even though we are past -rc1, +1 for me on the series.Can we finish the job and convert remaining macros that prefix messages in
lib/?
I didn't realize I missed any. do you have a list or a regex that points me at them. I was just searching for use of args...
Happy to make the conversion of the others in the next rev.
ty
Quoted 4 lines
Signature · 2 lines
-- David Marchand
Re: [PATCH v3 00/16] stop using variadic argument pack extension
Quoted 11 lines · Tyler Retzlaff
Quoted 6 lines
I find this new helper less tricky to use and easier to read than the RTE_FMT_* stuff that gets copy/pasted everywhere.
The changes are quite mechanical, so even though we are past -rc1, +1 for me on the series.Can we finish the job and convert remaining macros that prefix messages in
lib/?I didn't realize I missed any. do you have a list or a regex that points me at them. I was just searching for use of args...
Happy to make the conversion of the others in the next rev.
Basically, this new macro/approach makes direct use of RTE_FMT_HEAD unneeded.
So I grepped like this:
$ git grep RTE_FMT_HEAD -- lib/ :^lib/log/ :^lib/eal/include/rte_common.h
b55361f252:lib/cryptodev/rte_cryptodev.h: RTE_FMT("%s()
line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \
b55361f252:lib/cryptodev/rte_cryptodev.h: RTE_FMT("%s()
line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \
b55361f252:lib/cryptodev/rte_cryptodev.h: RTE_FMT("[%s]
%s: " RTE_FMT_HEAD(__VA_ARGS__ ,), \
b55361f252:lib/eal/windows/include/rte_windows.h:
RTE_FMT_HEAD(__VA_ARGS__ ,), GetLastError(), \
b55361f252:lib/eventdev/eventdev_pmd.h: RTE_FMT("%s() line %u:
" RTE_FMT_HEAD(__VA_ARGS__ ,), \
b55361f252:lib/eventdev/eventdev_pmd.h: RTE_FMT("%s() line %u:
" RTE_FMT_HEAD(__VA_ARGS__ ,), \
b55361f252:lib/eventdev/rte_event_timer_adapter.c:
RTE_FMT("EVTIMER: %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \
b55361f252:lib/graph/graph_private.h: RTE_FMT("%s():%u "
RTE_FMT_HEAD(__VA_ARGS__ ,), \
b55361f252:lib/member/member.h: RTE_FMT("%s(): "
RTE_FMT_HEAD(__VA_ARGS__ ,), \
b55361f252:lib/node/node_private.h: RTE_FMT("%s: %s():%u "
RTE_FMT_HEAD(__VA_ARGS__ ,), \Signature · 1 line
David Marchand
PATCH v4 2/22 cfgfile: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/cfgfile/rte_cfgfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/cfgfile/rte_cfgfile.c +3 -2
@@ -31,8 +31,9 @@ struct rte_cfgfile {RTE_LOG_REGISTER_DEFAULT (cfgfile_logtype,INFO );#define RTE_LOGTYPE_CFGFILE cfgfile_logtype -#define CFG_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## args) +#define CFG_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, CFGFILE, "%s(): ", __func__, __VA_ARGS__) +/* >8 End of setting up dynamic logging */ /** when we resize a file structure, how many extra entries
Signature · 1 line
1.8.3.1
v4 cover stop using variadic argument pack extension
In reply to Tyler RetzlaffRTE_LOG_LINE cannot be augmented with a prefix format and arguments without the user of RTE_LOG_LINE using the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.
Provide a new/similar macro RTE_LOG_LINE_PREFIX that accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside of RTE_FMT() allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with __VA_ARGS__ avoiding the need for conditional comma removal.
I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
v4:
* remove unintended addition of prefix to bpf log helper.
* use RTE_LOG_LINE_PREFIX in other places using RTE_FMT_HEAD and RTE_FMT_TAIL.
* add a checkpatch check to prevent reintroduction of ##args.
v3:
* remove leading _ from RTE_LOG_COMMA the macro is not internal
* add doxygen comment for existing RTE_LOG{,DP}_LINE function-like macros, based on RTE_LOG{,DP} comments.
* add doxygen comment for new RTE_LOG{,DP}_LINE_PREFIX function-like macros, based on RTE_LOG{,DP} comments.
* merge 2 vhost patches into a single patch (mistake in previous submission)
v2:
* revamp entire series to be ISO C99 compliant, stop using variadic argument pack extension.
Tyler Retzlaff (22):
log: add a per line log helper with parameterized prefix
cfgfile: stop using variadic argument pack extension
cmdline: stop using variadic argument pack extension
compressdev: stop using variadic argument pack extension
metrics: stop using variadic argument pack extension
mldev: stop using variadic argument pack extension
net: stop using variadic argument pack extension
pdump: stop using variadic argument pack extension
power: stop using variadic argument pack extension
rawdev: stop using variadic argument pack extension
rcu: stop using variadic argument pack extension
stack: stop using variadic argument pack extension
eal: stop using variadic argument pack extension
vhost: stop using variadic argument pack extension
ip_frag: stop using variadic argument pack extension
bpf: stop using variadic argument pack extension
cryptodev: stop using variadic argument pack extension
eventdev: stop using variadic argument pack extension
graph: stop using variadic argument pack extension
member: stop using variadic argument pack extension
node: stop using variadic argument pack extension
devtools: forbid use argument variadic pack extension
devtools/checkpatches.sh | 8 +++ lib/bpf/bpf_impl.h | 4 +- lib/cfgfile/rte_cfgfile.c | 5 +- lib/cmdline/cmdline_parse.c | 2 +- lib/cmdline/cmdline_parse_num.c | 4 +- lib/compressdev/rte_compressdev_internal.h | 4 +- lib/cryptodev/rte_cryptodev.h | 15 ++--- lib/eal/common/eal_trace.h | 8 +-- lib/eal/windows/include/rte_windows.h | 5 +- lib/eventdev/eventdev_pmd.h | 10 ++- lib/eventdev/rte_event_timer_adapter.c | 5 +- lib/graph/graph_private.h | 5 +- lib/ip_frag/ip_frag_common.h | 4 +- lib/log/rte_log.h | 97 ++++++++++++++++++++++++++++++ lib/member/member.h | 5 +- lib/metrics/rte_metrics_telemetry.c | 12 ++-- lib/mldev/rte_mldev.h | 4 +- lib/net/rte_net_crc.c | 4 +- lib/node/node_private.h | 6 +- lib/pdump/rte_pdump.c | 4 +- lib/power/power_common.h | 6 +- lib/rawdev/rte_rawdev_pmd.h | 17 +++--- lib/rcu/rte_rcu_qsbr.c | 4 +- lib/rcu/rte_rcu_qsbr.h | 12 ++-- lib/stack/stack_pvt.h | 16 ++--- lib/vhost/vhost.h | 8 +-- lib/vhost/vhost_crypto.c | 21 ++++--- 27 files changed, 196 insertions(+), 99 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v4 1/22 log: add a per line log helper with parameterized prefix
Providing a custom prefix when logging is common for components. Lift ISO C99 compliant helper macros from mlx5_common.h and provide RTE_LOG_LINE_PREFIX macro that can expand similar to RTE_LOG_LINE with a custom prefix and argument list.
--- lib/log/rte_log.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)
lib/log/rte_log.h +97 -0
@@ -367,18 +367,115 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)#define RTE_LOG_CHECK_NO_NEWLINE (...)#endif +/** +* Generates a log message with a single trailing newline. +* +* The RTE_LOG_LINE() is a helper that expands logging of a message +* with RTE_LOG() appending a single newline to the formatted message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ #define RTE_LOG_LINE (l, t, ...) do { \ RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(__VA_ARGS__ ,)); \ RTE_LOG(l, t, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ RTE_FMT_TAIL(__VA_ARGS__ ,))); \ } while (0) +/** +* Generates a log message for data path with a single trailing newline. +* +* Similar to RTE_LOG_LINE(), except that it is removed at compilation +* time if the RTE_LOG_DP_LEVEL configuration option is lower than the +* log level argument. +* +* The RTE_LOG_LINE() is a helper that expands logging of a message +* with RTE_LOG_DP() appending a single newline to the formatted +* message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ #define RTE_LOG_DP_LINE (l, t, ...) do { \ RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(__VA_ARGS__ ,)); \ RTE_LOG_DP(l, t, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ RTE_FMT_TAIL(__VA_ARGS__ ,))); \ } while (0) +#define RTE_LOG_COMMA , + +/* +* Generates a log message with a supplied prefix and arguments with a +* single trailing newline. +* +* The RTE_LOG_LINE_PREFIX() is a helper that expands logging of a +* message with RTE_LOG() prepending the supplied prefix and arguments +* appending a single newline to the formatted message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param prefix +* The prefix format string. +* @param args +* The arguments for the prefix format string. If args contains +* multiple arguments use RTE_LOG_COMMA to defer expansion. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ +#define RTE_LOG_LINE_PREFIX (l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) + +/* +* Generates a log message for the data path with a supplied prefix and +* arguments with a single trailing newline. +* +* The RTE_LOG_DP_LINE_PREFIX() is a helper that expands logging of a +* message with RTE_LOG_DP() prepending the supplied prefix and +* arguments appending a single newline to the formatted message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param prefix +* The prefix format string. +* @param args +* The arguments for the prefix format string. If args contains +* multiple arguments use RTE_LOG_COMMA to defer expansion. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ +#define RTE_LOG_DP_LINE_PREFIX (l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG_DP(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) +#define RTE_LOG_REGISTER_IMPL (type, name, level) \ int type; \ RTE_INIT(__##type) \
Signature · 1 line
1.8.3.1
PATCH v4 4/22 compressdev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/compressdev/rte_compressdev_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/compressdev/rte_compressdev_internal.h +2 -2
@@ -23,8 +23,8 @@extern int compressdev_logtype;#define RTE_LOGTYPE_COMPRESSDEV compressdev_logtype -#define COMPRESSDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, COMPRESSDEV, "%s(): " fmt, __func__, ## args) +#define COMPRESSDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, COMPRESSDEV, "%s(): ", __func__, __VA_ARGS__)/** * Dequeue processed packets from queue pair of a device.
Signature · 1 line
1.8.3.1
PATCH v4 3/22 cmdline: stop using variadic argument pack extension
In reply to Tyler RetzlaffRemove use of args... and just use __VA_ARGS__. The macros expanding the argument pack do not require args extension to remove trailing comma.
--- lib/cmdline/cmdline_parse.c | 2 +- lib/cmdline/cmdline_parse_num.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/cmdline/cmdline_parse.c +1 -1
@@ -16,7 +16,7 @@#ifdef RTE_LIBRTE_CMDLINE_DEBUG #define debug_printf printf#else -#define debug_printf(args...) do {} while(0) +#define debug_printf (...) do {} while (0)#endif #define CMDLINE_BUFFER_SIZE 64
lib/cmdline/cmdline_parse_num.c +2 -2
@@ -14,9 +14,9 @@#include "cmdline_parse_num.h" #ifdef RTE_LIBRTE_CMDLINE_DEBUG -#define debug_printf(args...) printf(args) +#define debug_printf (...) printf(__VA_ARGS__)#else -#define debug_printf(args...) do {} while(0) +#define debug_printf (...) do {} while (0)#endif struct cmdline_token_ops cmdline_token_num_ops = {
Signature · 1 line
1.8.3.1
PATCH v4 6/22 mldev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/mldev/rte_mldev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/mldev/rte_mldev.h +2 -2
@@ -146,8 +146,8 @@extern int rte_ml_dev_logtype;#define RTE_LOGTYPE_MLDEV rte_ml_dev_logtype -#define RTE_MLDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, MLDEV, "%s(): " fmt, __func__, ##args) +#define RTE_MLDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, MLDEV, "%s(): ", __func__, __VA_ARGS__)#define RTE_ML_STR_MAX 128/**< Maximum length of name string */
Signature · 1 line
1.8.3.1
PATCH v4 9/22 power: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/power/power_common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/power/power_common.h +3 -3
@@ -16,10 +16,10 @@ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)#ifdef RTE_LIBRTE_POWER_DEBUG -#define POWER_DEBUG_LOG(fmt, args...) \ - RTE_LOG_LINE(ERR, POWER, "%s: " fmt, __func__, ## args) +#define POWER_DEBUG_LOG (...) \ + RTE_LOG_LINE_PREFIX(ERR, POWER, "%s(): ", __func__, __VA_ARGS__)#else -#define POWER_DEBUG_LOG(fmt, args...) +#define POWER_DEBUG_LOG (fmt, ...)#endif /* check if scaling driver matches one we want */
Signature · 1 line
1.8.3.1
PATCH v4 8/22 pdump: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/pdump/rte_pdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/pdump/rte_pdump.c +2 -2
@@ -18,8 +18,8 @@RTE_LOG_REGISTER_DEFAULT (pdump_logtype,NOTICE );#define RTE_LOGTYPE_PDUMP pdump_logtype -#define PDUMP_LOG_LINE(level, fmt, args...) \ - RTE_LOG_LINE(level, PDUMP, "%s(): " fmt, __func__, ## args) +#define PDUMP_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, PDUMP, "%s(): ", __func__, __VA_ARGS__)/* Used for the multi-process communication */ #define PDUMP_MP "mp_pdump"
Signature · 1 line
1.8.3.1
PATCH v4 10/22 rawdev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/rawdev/rte_rawdev_pmd.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
lib/rawdev/rte_rawdev_pmd.h +9 -8
@@ -30,16 +30,17 @@#define RTE_LOGTYPE_RAWDEV librawdev_logtype/* Logging Macros */ -#define RTE_RDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RAWDEV, "%s(): " fmt, __func__, ##args) +#define RTE_RDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, RAWDEV, "%s(): ", __func__, __VA_ARGS__) -#define RTE_RDEV_ERR(fmt, args...) \ - RTE_RDEV_LOG(ERR, fmt, ## args) -#define RTE_RDEV_DEBUG(fmt, args...) \ - RTE_RDEV_LOG(DEBUG, fmt, ## args) -#define RTE_RDEV_INFO(fmt, args...) \ - RTE_RDEV_LOG(INFO, fmt, ## args) +#define RTE_RDEV_ERR (...) \ + RTE_RDEV_LOG(ERR, __VA_ARGS__) +#define RTE_RDEV_DEBUG (...) \ + RTE_RDEV_LOG(DEBUG, __VA_ARGS__) + +#define RTE_RDEV_INFO (...) \ + RTE_RDEV_LOG(INFO, __VA_ARGS__)/* Macros to check for valid device */ #define RTE_RAWDEV_VALID_DEVID_OR_ERR_RET (dev_id, retval) do { \
Signature · 1 line
1.8.3.1
PATCH v4 12/22 stack: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/stack/stack_pvt.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
lib/stack/stack_pvt.h +8 -8
@@ -10,16 +10,16 @@extern int stack_logtype;#define RTE_LOGTYPE_STACK stack_logtype -#define STACK_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, STACK, "%s(): "fmt, __func__, ##args) +#define STACK_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, STACK, "%s(): ", __func__, __VA_ARGS__) -#define STACK_LOG_ERR(fmt, args...) \ - STACK_LOG(ERR, fmt, ## args) +#define STACK_LOG_ERR (...) \ + STACK_LOG(ERR, __VA_ARGS__) -#define STACK_LOG_WARN(fmt, args...) \ - STACK_LOG(WARNING, fmt, ## args) +#define STACK_LOG_WARN (...) \ + STACK_LOG(WARNING, __VA_ARGS__) -#define STACK_LOG_INFO(fmt, args...) \ - STACK_LOG(INFO, fmt, ## args) +#define STACK_LOG_INFO (fmt, ...) \ + STACK_LOG(INFO, __VA_ARGS__)#endif /* _STACK_PVT_H_ */
Signature · 1 line
1.8.3.1
PATCH v4 7/22 net: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/net/rte_net_crc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/net/rte_net_crc.c +2 -2
@@ -73,8 +73,8 @@RTE_LOG_REGISTER_DEFAULT (libnet_logtype,INFO );#define RTE_LOGTYPE_NET libnet_logtype -#define NET_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, NET, "%s(): " fmt, __func__, ## args) +#define NET_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, NET, "%s(): ", __func__, __VA_ARGS__)/* Scalar handling */
Signature · 1 line
1.8.3.1
PATCH v4 11/22 rcu: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/rcu/rte_rcu_qsbr.c | 4 ++-- lib/rcu/rte_rcu_qsbr.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
lib/rcu/rte_rcu_qsbr.c +2 -2
@@ -19,8 +19,8 @@#include "rte_rcu_qsbr.h" #include "rcu_qsbr_pvt.h" -#define RCU_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) +#define RCU_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__)/* Get the memory size of QSBR variable */ size_t
lib/rcu/rte_rcu_qsbr.h +6 -6
@@ -39,19 +39,19 @@#define RTE_LOGTYPE_RCU rte_rcu_log_type#if RTE_LOG_DP_LEVEL >=RTE_LOG_DEBUG -#define __RTE_RCU_DP_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) +#define __RTE_RCU_DP_LOG (level, ...) \ + RTE_LOG_DP_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__)#else -#define __RTE_RCU_DP_LOG(level, fmt, args...) +#define __RTE_RCU_DP_LOG (level, ...)#endif #if defined(RTE_LIBRTE_RCU_DEBUG ) -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) do { \ +#define __RTE_RCU_IS_LOCK_CNT_ZERO (v, thread_id, level, ...) do { \ if (v->qsbr_cnt[thread_id].lock_cnt) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args); \ + RTE_LOG_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__); \ } while (0)#else -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) +#define __RTE_RCU_IS_LOCK_CNT_ZERO (v, thread_id, level, fmt, ...)#endif /* Registered thread IDs are stored as a bitmap of 64b element array.
Signature · 1 line
1.8.3.1
PATCH v4 13/22 eal: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of EAL_LOG in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/eal/common/eal_trace.h | 8 ++++---- lib/eal/windows/include/rte_windows.h | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-)
lib/eal/common/eal_trace.h +4 -4
@@ -16,11 +16,11 @@#include "eal_private.h" #include "eal_thread.h" -#define trace_err(fmt, args...) \ - EAL_LOG(ERR, "%s():%u " fmt, __func__, __LINE__, ## args) +#define trace_err (...) \ + RTE_LOG_LINE_PREFIX(ERR, EAL, "%s():%u ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__) -#define trace_crit(fmt, args...) \ - EAL_LOG(CRIT, "%s():%u " fmt, __func__, __LINE__, ## args) +#define trace_crit (...) \ + RTE_LOG_LINE_PREFIX(CRIT, EAL, "%s():%u ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32
lib/eal/windows/include/rte_windows.h +2 -3
@@ -48,9 +48,8 @@* Log GetLastError() with context, usually a Win32 API function and arguments. */ #define RTE_LOG_WIN32_ERR (...) \ - RTE_LOG_LINE(DEBUG, EAL, RTE_FMT("GetLastError()=%lu: " \ - RTE_FMT_HEAD(__VA_ARGS__ ,), GetLastError(), \ - RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(DEBUG, EAL, + "GetLastError()=%lu: " GetLastError(), __VA_ARGS__) #ifdef __cplusplus }
Signature · 1 line
1.8.3.1
PATCH v4 21/22 node: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/node/node_private.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/node/node_private.h +2 -4
@@ -16,10 +16,8 @@#define RTE_LOGTYPE_NODE rte_node_logtype#define NODE_LOG (level, node_name, ...) \ - RTE_LOG_LINE(level, NODE, \ - RTE_FMT("%s: %s():%u " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - node_name, __func__, __LINE__, \ - RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(level, NODE, "%s: %s():%u ", \ + node_name RTE_LOG_COMMA __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define node_err (node_name, ...) NODE_LOG(ERR, node_name, __VA_ARGS__)#define node_info (node_name, ...) NODE_LOG(INFO, node_name, __VA_ARGS__)
Signature · 1 line
1.8.3.1
PATCH v4 19/22 graph: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/graph/graph_private.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/graph/graph_private.h +2 -3
@@ -21,9 +21,8 @@#define RTE_LOGTYPE_GRAPH rte_graph_logtype#define GRAPH_LOG (level, ...) \ - RTE_LOG_LINE(level, GRAPH, \ - RTE_FMT("%s():%u " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(level, GRAPH, \ + "%s():%u ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define graph_err (...) GRAPH_LOG(ERR, __VA_ARGS__)#define graph_warn (...) GRAPH_LOG(WARNING, __VA_ARGS__)
Signature · 1 line
1.8.3.1
PATCH v4 14/22 vhost: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/vhost/vhost.h | 8 ++++---- lib/vhost/vhost_crypto.c | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-)
lib/vhost/vhost.h +4 -4
@@ -679,11 +679,11 @@ void __vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,extern int vhost_data_log_level;#define RTE_LOGTYPE_VHOST_DATA vhost_data_log_level -#define VHOST_CONFIG_LOG(prefix, level, fmt, args...) \ - RTE_LOG_LINE(level, VHOST_CONFIG, "(%s) " fmt, prefix, ##args) +#define VHOST_CONFIG_LOG (prefix, level, ...) \ + RTE_LOG_LINE_PREFIX(level, VHOST_CONFIG, "(%s) ", prefix, __VA_ARGS__) -#define VHOST_DATA_LOG(prefix, level, fmt, args...) \ - RTE_LOG_DP_LINE(level, VHOST_DATA, "(%s) " fmt, prefix, ##args) +#define VHOST_DATA_LOG (prefix, level, ...) \ + RTE_LOG_DP_LINE_PREFIX(level, VHOST_DATA, "(%s) ", prefix, __VA_ARGS__)#ifdef RTE_LIBRTE_VHOST_DEBUG #define VHOST_MAX_PRINT_BUFF 6072
lib/vhost/vhost_crypto.c +11 -10
@@ -20,19 +20,20 @@RTE_LOG_REGISTER_SUFFIX (vhost_crypto_logtype, crypto,INFO );#define RTE_LOGTYPE_VHOST_CRYPTO vhost_crypto_logtype -#define VC_LOG_ERR(fmt, args...) \ - RTE_LOG_LINE(ERR, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) -#define VC_LOG_INFO(fmt, args...) \ - RTE_LOG_LINE(INFO, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) +#define VC_LOG_ERR (...) \ + RTE_LOG_LINE_PREFIX(ERR, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__) + +#define VC_LOG_INFO (...) \ + RTE_LOG_LINE_PREFIX(INFO, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#ifdef RTE_LIBRTE_VHOST_DEBUG -#define VC_LOG_DBG(fmt, args...) \ - RTE_LOG_LINE(DEBUG, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) +#define VC_LOG_DBG (...) \ + RTE_LOG_LINE_PREFIX(DEBUG, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#else -#define VC_LOG_DBG(fmt, args...) +#define VC_LOG_DBG (fmt, ...)#endif #define VIRTIO_CRYPTO_FEATURES ((1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
Signature · 1 line
1.8.3.1
PATCH v4 15/22 ip_frag: stop using variadic argument pack extension
In reply to Tyler RetzlaffRemove use of args... and just use __VA_ARGS__. The macros expanding the argument pack do not require args extension to remove trailing comma.
--- lib/ip_frag/ip_frag_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/ip_frag/ip_frag_common.h +2 -2
@@ -26,9 +26,9 @@ RTE_LOG_LINE(level, IPFRAG, "" __VA_ARGS__)#ifdef RTE_LIBRTE_IP_FRAG_DEBUG -#define IP_FRAG_LOG(lvl, fmt, args...) RTE_LOG(lvl, IPFRAG, fmt, ##args) +#define IP_FRAG_LOG (lvl, ...) RTE_LOG(lvl, IPFRAG, __VA_ARGS__)#else -#define IP_FRAG_LOG(lvl, fmt, args...) do {} while(0) +#define IP_FRAG_LOG (lvl, fmt, ...) do {} while (0)#endif /* IP_FRAG_DEBUG */ #define IPV4_KEYLEN 1
Signature · 1 line
1.8.3.1
PATCH v4 18/22 eventdev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/eventdev/eventdev_pmd.h | 10 ++++------ lib/eventdev/rte_event_timer_adapter.c | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-)
lib/eventdev/eventdev_pmd.h +4 -6
@@ -36,15 +36,13 @@/* Logging Macros */ #define RTE_EDEV_LOG_ERR (...) \ - RTE_LOG_LINE(ERR, EVENTDEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(ERR, EVENTDEV, \ + "%s() line %u: ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#ifdef RTE_LIBRTE_EVENTDEV_DEBUG #define RTE_EDEV_LOG_DEBUG (...) \ - RTE_LOG_LINE(DEBUG, EVENTDEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(DEBUG, EVENTDEV, \ + "%s() line %u: ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#else #define RTE_EDEV_LOG_DEBUG (...) (void)0#endif
lib/eventdev/rte_event_timer_adapter.c +2 -3
@@ -41,9 +41,8 @@static const struct event_timer_adapter_ops swtim_ops;#define EVTIM_LOG (level, logtype, ...) \ - RTE_LOG_LINE(level, logtype, \ - RTE_FMT("EVTIMER: %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(level, logtype, \ + "EVTIMER: %s() line %u: ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define EVTIM_LOG_ERR (...) EVTIM_LOG(ERR, EVTIM, __VA_ARGS__)
Signature · 1 line
1.8.3.1
PATCH v4 22/22 devtools: forbid use argument variadic pack extension
In reply to Tyler RetzlaffPrevent introduction of new use of args... and ##args compiler extension.
--- devtools/checkpatches.sh | 8 ++++++++ 1 file changed, 8 insertions(+)
devtools/checkpatches.sh +8 -0
@@ -61,6 +61,14 @@ check_forbidden_additions() { # <patch> -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ "$1" || res=1 + # forbid use of variadic argument pack extension in macros + awk -v FOLDERS="lib drivers app examples" \ + -v EXPRESSIONS='#[[:space:]]*define.*[^(,[:space:]]\\.\\.\\.[[:space:]]*)' \ + -v RET_ON_FAIL=1 \ + -v MESSAGE='Do not use variadic argument pack in macros' \ + -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ + "$1" || res=1 + # no output on stdout or stderr awk -v FOLDERS="lib drivers" \ -v EXPRESSIONS="\\\<printf\\\> \\\<fprintf\\\(stdout, \\\<fprintf\\\(stderr," \
Signature · 1 line
1.8.3.1
PATCH v4 17/22 cryptodev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/cryptodev/rte_cryptodev.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
lib/cryptodev/rte_cryptodev.h +6 -9
@@ -34,22 +34,19 @@/* Logging Macros */ #define CDEV_LOG_ERR (...) \ - RTE_LOG_LINE(ERR, CRYPTODEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(ERR, CRYPTODEV, \ + "%s() line %u: ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define CDEV_LOG_INFO (...) \ RTE_LOG_LINE(INFO, CRYPTODEV, "" __VA_ARGS__)#define CDEV_LOG_DEBUG (...) \ - RTE_LOG_LINE(DEBUG, CRYPTODEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(DEBUG, CRYPTODEV, \ + "%s() line %u: ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define CDEV_PMD_TRACE (...) \ - RTE_LOG_LINE(DEBUG, CRYPTODEV, \ - RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - dev, __func__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(DEBUG, CRYPTODEV, \ + "[%s] %s: ", dev RTE_LOG_COMMA __func__, __VA_ARGS__)/** * A macro that points to an offset from the start
Signature · 1 line
1.8.3.1
PATCH v4 16/22 bpf: stop using variadic argument pack extension
In reply to Tyler RetzlaffRemove fmt, args... and forward with __VA_ARGS__.
--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bpf/bpf_impl.h +2 -2
@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (lvl, ...) \ + RTE_LOG_LINE(lvl, BPF, __VA_ARGS__)static inline size_t bpf_size (uint32_t bpf_op_sz)
Signature · 1 line
1.8.3.1
PATCH v4 5/22 metrics: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/metrics/rte_metrics_telemetry.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/metrics/rte_metrics_telemetry.c +6 -6
@@ -19,14 +19,14 @@#define RTE_LOGTYPE_METRICS metrics_log_level/* Logging Macros */ -#define METRICS_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, METRICS, "%s(): "fmt, __func__, ## args) +#define METRICS_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, METRICS, "%s(): ", __func__, __VA_ARGS__) -#define METRICS_LOG_ERR(fmt, args...) \ - METRICS_LOG(ERR, fmt, ## args) +#define METRICS_LOG_ERR (...) \ + METRICS_LOG(ERR, __VA_ARGS__) -#define METRICS_LOG_WARN(fmt, args...) \ - METRICS_LOG(WARNING, fmt, ## args) +#define METRICS_LOG_WARN (...) \ + METRICS_LOG(WARNING, __VA_ARGS__)static int32_t rte_metrics_tel_reg_port_ethdev_to_metrics (uint16_t port_id)
Signature · 1 line
1.8.3.1
PATCH v4 20/22 member: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/member/member.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/member/member.h +2 -3
@@ -8,7 +8,6 @@#define RTE_LOGTYPE_MEMBER librte_member_logtype#define MEMBER_LOG (level, ...) \ - RTE_LOG_LINE(level, MEMBER, \ - RTE_FMT("%s(): " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(level, MEMBER, \ + "%s(): ", __func__, __VA_ARGS__)
Signature · 1 line
1.8.3.1
PATCH v5 2/22 cfgfile: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/cfgfile/rte_cfgfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/cfgfile/rte_cfgfile.c +3 -2
@@ -31,8 +31,9 @@ struct rte_cfgfile {RTE_LOG_REGISTER_DEFAULT (cfgfile_logtype,INFO );#define RTE_LOGTYPE_CFGFILE cfgfile_logtype -#define CFG_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## args) +#define CFG_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, CFGFILE, "%s(): ", __func__, __VA_ARGS__) +/* >8 End of setting up dynamic logging */ /** when we resize a file structure, how many extra entries
Signature · 1 line
1.8.3.1
PATCH v5 3/22 cmdline: stop using variadic argument pack extension
In reply to Tyler RetzlaffRemove use of args... and just use __VA_ARGS__. The macros expanding the argument pack do not require args extension to remove trailing comma.
--- lib/cmdline/cmdline_parse.c | 2 +- lib/cmdline/cmdline_parse_num.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/cmdline/cmdline_parse.c +1 -1
@@ -16,7 +16,7 @@#ifdef RTE_LIBRTE_CMDLINE_DEBUG #define debug_printf printf#else -#define debug_printf(args...) do {} while(0) +#define debug_printf (...) do {} while (0)#endif #define CMDLINE_BUFFER_SIZE 64
lib/cmdline/cmdline_parse_num.c +2 -2
@@ -14,9 +14,9 @@#include "cmdline_parse_num.h" #ifdef RTE_LIBRTE_CMDLINE_DEBUG -#define debug_printf(args...) printf(args) +#define debug_printf (...) printf(__VA_ARGS__)#else -#define debug_printf(args...) do {} while(0) +#define debug_printf (...) do {} while (0)#endif struct cmdline_token_ops cmdline_token_num_ops = {
Signature · 1 line
1.8.3.1
PATCH v5 1/22 log: add a per line log helper with parameterized prefix
In reply to Tyler RetzlaffProviding a custom prefix when logging is common for components. Lift ISO C99 compliant helper macros from mlx5_common.h and provide RTE_LOG_LINE_PREFIX macro that can expand similar to RTE_LOG_LINE with a custom prefix and argument list.
--- lib/log/rte_log.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)
lib/log/rte_log.h +97 -0
@@ -367,18 +367,115 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)#define RTE_LOG_CHECK_NO_NEWLINE (...)#endif +/** +* Generates a log message with a single trailing newline. +* +* The RTE_LOG_LINE() is a helper that expands logging of a message +* with RTE_LOG() appending a single newline to the formatted message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ #define RTE_LOG_LINE (l, t, ...) do { \ RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(__VA_ARGS__ ,)); \ RTE_LOG(l, t, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ RTE_FMT_TAIL(__VA_ARGS__ ,))); \ } while (0) +/** +* Generates a log message for data path with a single trailing newline. +* +* Similar to RTE_LOG_LINE(), except that it is removed at compilation +* time if the RTE_LOG_DP_LEVEL configuration option is lower than the +* log level argument. +* +* The RTE_LOG_LINE() is a helper that expands logging of a message +* with RTE_LOG_DP() appending a single newline to the formatted +* message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ #define RTE_LOG_DP_LINE (l, t, ...) do { \ RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(__VA_ARGS__ ,)); \ RTE_LOG_DP(l, t, RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ RTE_FMT_TAIL(__VA_ARGS__ ,))); \ } while (0) +#define RTE_LOG_COMMA , + +/* +* Generates a log message with a supplied prefix and arguments with a +* single trailing newline. +* +* The RTE_LOG_LINE_PREFIX() is a helper that expands logging of a +* message with RTE_LOG() prepending the supplied prefix and arguments +* appending a single newline to the formatted message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param prefix +* The prefix format string. +* @param args +* The arguments for the prefix format string. If args contains +* multiple arguments use RTE_LOG_COMMA to defer expansion. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ +#define RTE_LOG_LINE_PREFIX (l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) + +/* +* Generates a log message for the data path with a supplied prefix and +* arguments with a single trailing newline. +* +* The RTE_LOG_DP_LINE_PREFIX() is a helper that expands logging of a +* message with RTE_LOG_DP() prepending the supplied prefix and +* arguments appending a single newline to the formatted message. +* +* @param l +* Log level. A value between EMERG (1) and DEBUG (8). The short name +* is expanded by the macro, so it cannot be an integer value. +* @param t +* The log type, for example, EAL. The short name is expanded by the +* macro, so it cannot be an integer value. +* @param prefix +* The prefix format string. +* @param args +* The arguments for the prefix format string. If args contains +* multiple arguments use RTE_LOG_COMMA to defer expansion. +* @param ... +* The fmt string, as in printf(3), followed by the variable arguments +* required by the format. +*/ +#define RTE_LOG_DP_LINE_PREFIX (l, t, prefix, args, ...) do { \ + RTE_LOG_CHECK_NO_NEWLINE(RTE_FMT_HEAD(prefix __VA_ARGS__ ,)); \ + RTE_LOG_DP(l, t, RTE_FMT(prefix RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \ + args RTE_LOG_COMMA RTE_FMT_TAIL(__VA_ARGS__ ,))); \ +} while (0) +#define RTE_LOG_REGISTER_IMPL (type, name, level) \ int type; \ RTE_INIT(__##type) \
Signature · 1 line
1.8.3.1
v5 cover stop using variadic argument pack extension
In reply to Tyler RetzlaffRTE_LOG_LINE cannot be augmented with a prefix format and arguments without the user of RTE_LOG_LINE using the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.
Provide a new/similar macro RTE_LOG_LINE_PREFIX that accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside of RTE_FMT() allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with __VA_ARGS__ avoiding the need for conditional comma removal.
I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
v5:
* add missing newline escape and comma in rte_windows.h macro.
v4:
* remove unintended addition of prefix to bpf log helper.
* use RTE_LOG_LINE_PREFIX in other places using RTE_FMT_HEAD and RTE_FMT_TAIL.
* add a checkpatch check to prevent reintroduction of ##args.
v3:
* remove leading _ from RTE_LOG_COMMA the macro is not internal
* add doxygen comment for existing RTE_LOG{,DP}_LINE function-like macros, based on RTE_LOG{,DP} comments.
* add doxygen comment for new RTE_LOG{,DP}_LINE_PREFIX function-like macros, based on RTE_LOG{,DP} comments.
* merge 2 vhost patches into a single patch (mistake in previous submission)
v2:
* revamp entire series to be ISO C99 compliant, stop using variadic argument pack extension.
Tyler Retzlaff (22):
log: add a per line log helper with parameterized prefix
cfgfile: stop using variadic argument pack extension
cmdline: stop using variadic argument pack extension
compressdev: stop using variadic argument pack extension
metrics: stop using variadic argument pack extension
mldev: stop using variadic argument pack extension
net: stop using variadic argument pack extension
pdump: stop using variadic argument pack extension
power: stop using variadic argument pack extension
rawdev: stop using variadic argument pack extension
rcu: stop using variadic argument pack extension
stack: stop using variadic argument pack extension
eal: stop using variadic argument pack extension
vhost: stop using variadic argument pack extension
ip_frag: stop using variadic argument pack extension
bpf: stop using variadic argument pack extension
cryptodev: stop using variadic argument pack extension
eventdev: stop using variadic argument pack extension
graph: stop using variadic argument pack extension
member: stop using variadic argument pack extension
node: stop using variadic argument pack extension
devtools: forbid use argument variadic pack extension
devtools/checkpatches.sh | 8 +++ lib/bpf/bpf_impl.h | 4 +- lib/cfgfile/rte_cfgfile.c | 5 +- lib/cmdline/cmdline_parse.c | 2 +- lib/cmdline/cmdline_parse_num.c | 4 +- lib/compressdev/rte_compressdev_internal.h | 4 +- lib/cryptodev/rte_cryptodev.h | 15 ++--- lib/eal/common/eal_trace.h | 8 +-- lib/eal/windows/include/rte_windows.h | 5 +- lib/eventdev/eventdev_pmd.h | 10 ++- lib/eventdev/rte_event_timer_adapter.c | 5 +- lib/graph/graph_private.h | 5 +- lib/ip_frag/ip_frag_common.h | 4 +- lib/log/rte_log.h | 97 ++++++++++++++++++++++++++++++ lib/member/member.h | 5 +- lib/metrics/rte_metrics_telemetry.c | 12 ++-- lib/mldev/rte_mldev.h | 4 +- lib/net/rte_net_crc.c | 4 +- lib/node/node_private.h | 6 +- lib/pdump/rte_pdump.c | 4 +- lib/power/power_common.h | 6 +- lib/rawdev/rte_rawdev_pmd.h | 17 +++--- lib/rcu/rte_rcu_qsbr.c | 4 +- lib/rcu/rte_rcu_qsbr.h | 12 ++-- lib/stack/stack_pvt.h | 16 ++--- lib/vhost/vhost.h | 8 +-- lib/vhost/vhost_crypto.c | 21 ++++--- 27 files changed, 196 insertions(+), 99 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v5 4/22 compressdev: stop using variadic argument pack extension
Use RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/compressdev/rte_compressdev_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/compressdev/rte_compressdev_internal.h +2 -2
@@ -23,8 +23,8 @@extern int compressdev_logtype;#define RTE_LOGTYPE_COMPRESSDEV compressdev_logtype -#define COMPRESSDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, COMPRESSDEV, "%s(): " fmt, __func__, ## args) +#define COMPRESSDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, COMPRESSDEV, "%s(): ", __func__, __VA_ARGS__)/** * Dequeue processed packets from queue pair of a device.
Signature · 1 line
1.8.3.1
PATCH v5 6/22 mldev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/mldev/rte_mldev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/mldev/rte_mldev.h +2 -2
@@ -146,8 +146,8 @@extern int rte_ml_dev_logtype;#define RTE_LOGTYPE_MLDEV rte_ml_dev_logtype -#define RTE_MLDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, MLDEV, "%s(): " fmt, __func__, ##args) +#define RTE_MLDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, MLDEV, "%s(): ", __func__, __VA_ARGS__)#define RTE_ML_STR_MAX 128/**< Maximum length of name string */
Signature · 1 line
1.8.3.1
PATCH v5 7/22 net: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/net/rte_net_crc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/net/rte_net_crc.c +2 -2
@@ -73,8 +73,8 @@RTE_LOG_REGISTER_DEFAULT (libnet_logtype,INFO );#define RTE_LOGTYPE_NET libnet_logtype -#define NET_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, NET, "%s(): " fmt, __func__, ## args) +#define NET_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, NET, "%s(): ", __func__, __VA_ARGS__)/* Scalar handling */
Signature · 1 line
1.8.3.1
PATCH v5 8/22 pdump: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/pdump/rte_pdump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/pdump/rte_pdump.c +2 -2
@@ -18,8 +18,8 @@RTE_LOG_REGISTER_DEFAULT (pdump_logtype,NOTICE );#define RTE_LOGTYPE_PDUMP pdump_logtype -#define PDUMP_LOG_LINE(level, fmt, args...) \ - RTE_LOG_LINE(level, PDUMP, "%s(): " fmt, __func__, ## args) +#define PDUMP_LOG_LINE (level, ...) \ + RTE_LOG_LINE_PREFIX(level, PDUMP, "%s(): ", __func__, __VA_ARGS__)/* Used for the multi-process communication */ #define PDUMP_MP "mp_pdump"
Signature · 1 line
1.8.3.1
PATCH v5 5/22 metrics: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/metrics/rte_metrics_telemetry.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/metrics/rte_metrics_telemetry.c +6 -6
@@ -19,14 +19,14 @@#define RTE_LOGTYPE_METRICS metrics_log_level/* Logging Macros */ -#define METRICS_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, METRICS, "%s(): "fmt, __func__, ## args) +#define METRICS_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, METRICS, "%s(): ", __func__, __VA_ARGS__) -#define METRICS_LOG_ERR(fmt, args...) \ - METRICS_LOG(ERR, fmt, ## args) +#define METRICS_LOG_ERR (...) \ + METRICS_LOG(ERR, __VA_ARGS__) -#define METRICS_LOG_WARN(fmt, args...) \ - METRICS_LOG(WARNING, fmt, ## args) +#define METRICS_LOG_WARN (...) \ + METRICS_LOG(WARNING, __VA_ARGS__)static int32_t rte_metrics_tel_reg_port_ethdev_to_metrics (uint16_t port_id)
Signature · 1 line
1.8.3.1
PATCH v5 12/22 stack: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/stack/stack_pvt.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
lib/stack/stack_pvt.h +8 -8
@@ -10,16 +10,16 @@extern int stack_logtype;#define RTE_LOGTYPE_STACK stack_logtype -#define STACK_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, STACK, "%s(): "fmt, __func__, ##args) +#define STACK_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, STACK, "%s(): ", __func__, __VA_ARGS__) -#define STACK_LOG_ERR(fmt, args...) \ - STACK_LOG(ERR, fmt, ## args) +#define STACK_LOG_ERR (...) \ + STACK_LOG(ERR, __VA_ARGS__) -#define STACK_LOG_WARN(fmt, args...) \ - STACK_LOG(WARNING, fmt, ## args) +#define STACK_LOG_WARN (...) \ + STACK_LOG(WARNING, __VA_ARGS__) -#define STACK_LOG_INFO(fmt, args...) \ - STACK_LOG(INFO, fmt, ## args) +#define STACK_LOG_INFO (fmt, ...) \ + STACK_LOG(INFO, __VA_ARGS__)#endif /* _STACK_PVT_H_ */
Signature · 1 line
1.8.3.1
PATCH v5 13/22 eal: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of EAL_LOG in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/eal/common/eal_trace.h | 8 ++++---- lib/eal/windows/include/rte_windows.h | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-)
lib/eal/common/eal_trace.h +4 -4
@@ -16,11 +16,11 @@#include "eal_private.h" #include "eal_thread.h" -#define trace_err(fmt, args...) \ - EAL_LOG(ERR, "%s():%u " fmt, __func__, __LINE__, ## args) +#define trace_err (...) \ + RTE_LOG_LINE_PREFIX(ERR, EAL, "%s():%u ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__) -#define trace_crit(fmt, args...) \ - EAL_LOG(CRIT, "%s():%u " fmt, __func__, __LINE__, ## args) +#define trace_crit (...) \ + RTE_LOG_LINE_PREFIX(CRIT, EAL, "%s():%u ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32
lib/eal/windows/include/rte_windows.h +2 -3
@@ -48,9 +48,8 @@* Log GetLastError() with context, usually a Win32 API function and arguments. */ #define RTE_LOG_WIN32_ERR (...) \ - RTE_LOG_LINE(DEBUG, EAL, RTE_FMT("GetLastError()=%lu: " \ - RTE_FMT_HEAD(__VA_ARGS__ ,), GetLastError(), \ - RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(DEBUG, EAL, \ + "GetLastError()=%lu: ", GetLastError(), __VA_ARGS__) #ifdef __cplusplus }
Signature · 1 line
1.8.3.1
PATCH v5 11/22 rcu: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/rcu/rte_rcu_qsbr.c | 4 ++-- lib/rcu/rte_rcu_qsbr.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
lib/rcu/rte_rcu_qsbr.c +2 -2
@@ -19,8 +19,8 @@#include "rte_rcu_qsbr.h" #include "rcu_qsbr_pvt.h" -#define RCU_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) +#define RCU_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__)/* Get the memory size of QSBR variable */ size_t
lib/rcu/rte_rcu_qsbr.h +6 -6
@@ -39,19 +39,19 @@#define RTE_LOGTYPE_RCU rte_rcu_log_type#if RTE_LOG_DP_LEVEL >=RTE_LOG_DEBUG -#define __RTE_RCU_DP_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args) +#define __RTE_RCU_DP_LOG (level, ...) \ + RTE_LOG_DP_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__)#else -#define __RTE_RCU_DP_LOG(level, fmt, args...) +#define __RTE_RCU_DP_LOG (level, ...)#endif #if defined(RTE_LIBRTE_RCU_DEBUG ) -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) do { \ +#define __RTE_RCU_IS_LOCK_CNT_ZERO (v, thread_id, level, ...) do { \ if (v->qsbr_cnt[thread_id].lock_cnt) \ - RTE_LOG_LINE(level, RCU, "%s(): " fmt, __func__, ## args); \ + RTE_LOG_LINE_PREFIX(level, RCU, "%s(): ", __func__, __VA_ARGS__); \ } while (0)#else -#define __RTE_RCU_IS_LOCK_CNT_ZERO(v, thread_id, level, fmt, args...) +#define __RTE_RCU_IS_LOCK_CNT_ZERO (v, thread_id, level, fmt, ...)#endif /* Registered thread IDs are stored as a bitmap of 64b element array.
Signature · 1 line
1.8.3.1
PATCH v5 17/22 cryptodev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/cryptodev/rte_cryptodev.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
lib/cryptodev/rte_cryptodev.h +6 -9
@@ -34,22 +34,19 @@/* Logging Macros */ #define CDEV_LOG_ERR (...) \ - RTE_LOG_LINE(ERR, CRYPTODEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(ERR, CRYPTODEV, \ + "%s() line %u: ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define CDEV_LOG_INFO (...) \ RTE_LOG_LINE(INFO, CRYPTODEV, "" __VA_ARGS__)#define CDEV_LOG_DEBUG (...) \ - RTE_LOG_LINE(DEBUG, CRYPTODEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(DEBUG, CRYPTODEV, \ + "%s() line %u: ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define CDEV_PMD_TRACE (...) \ - RTE_LOG_LINE(DEBUG, CRYPTODEV, \ - RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - dev, __func__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(DEBUG, CRYPTODEV, \ + "[%s] %s: ", dev RTE_LOG_COMMA __func__, __VA_ARGS__)/** * A macro that points to an offset from the start
Signature · 1 line
1.8.3.1
PATCH v5 9/22 power: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/power/power_common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/power/power_common.h +3 -3
@@ -16,10 +16,10 @@ RTE_LOG_LINE(level, POWER, "" __VA_ARGS__)#ifdef RTE_LIBRTE_POWER_DEBUG -#define POWER_DEBUG_LOG(fmt, args...) \ - RTE_LOG_LINE(ERR, POWER, "%s: " fmt, __func__, ## args) +#define POWER_DEBUG_LOG (...) \ + RTE_LOG_LINE_PREFIX(ERR, POWER, "%s(): ", __func__, __VA_ARGS__)#else -#define POWER_DEBUG_LOG(fmt, args...) +#define POWER_DEBUG_LOG (fmt, ...)#endif /* check if scaling driver matches one we want */
Signature · 1 line
1.8.3.1
PATCH v5 14/22 vhost: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/vhost/vhost.h | 8 ++++---- lib/vhost/vhost_crypto.c | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-)
lib/vhost/vhost.h +4 -4
@@ -679,11 +679,11 @@ void __vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,extern int vhost_data_log_level;#define RTE_LOGTYPE_VHOST_DATA vhost_data_log_level -#define VHOST_CONFIG_LOG(prefix, level, fmt, args...) \ - RTE_LOG_LINE(level, VHOST_CONFIG, "(%s) " fmt, prefix, ##args) +#define VHOST_CONFIG_LOG (prefix, level, ...) \ + RTE_LOG_LINE_PREFIX(level, VHOST_CONFIG, "(%s) ", prefix, __VA_ARGS__) -#define VHOST_DATA_LOG(prefix, level, fmt, args...) \ - RTE_LOG_DP_LINE(level, VHOST_DATA, "(%s) " fmt, prefix, ##args) +#define VHOST_DATA_LOG (prefix, level, ...) \ + RTE_LOG_DP_LINE_PREFIX(level, VHOST_DATA, "(%s) ", prefix, __VA_ARGS__)#ifdef RTE_LIBRTE_VHOST_DEBUG #define VHOST_MAX_PRINT_BUFF 6072
lib/vhost/vhost_crypto.c +11 -10
@@ -20,19 +20,20 @@RTE_LOG_REGISTER_SUFFIX (vhost_crypto_logtype, crypto,INFO );#define RTE_LOGTYPE_VHOST_CRYPTO vhost_crypto_logtype -#define VC_LOG_ERR(fmt, args...) \ - RTE_LOG_LINE(ERR, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) -#define VC_LOG_INFO(fmt, args...) \ - RTE_LOG_LINE(INFO, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) +#define VC_LOG_ERR (...) \ + RTE_LOG_LINE_PREFIX(ERR, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__) + +#define VC_LOG_INFO (...) \ + RTE_LOG_LINE_PREFIX(INFO, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#ifdef RTE_LIBRTE_VHOST_DEBUG -#define VC_LOG_DBG(fmt, args...) \ - RTE_LOG_LINE(DEBUG, VHOST_CRYPTO, "%s() line %u: " fmt, \ - __func__, __LINE__, ## args) +#define VC_LOG_DBG (...) \ + RTE_LOG_LINE_PREFIX(DEBUG, VHOST_CRYPTO, "%s() line %u: ", \ + __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#else -#define VC_LOG_DBG(fmt, args...) +#define VC_LOG_DBG (fmt, ...)#endif #define VIRTIO_CRYPTO_FEATURES ((1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
Signature · 1 line
1.8.3.1
PATCH v5 10/22 rawdev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/rawdev/rte_rawdev_pmd.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
lib/rawdev/rte_rawdev_pmd.h +9 -8
@@ -30,16 +30,17 @@#define RTE_LOGTYPE_RAWDEV librawdev_logtype/* Logging Macros */ -#define RTE_RDEV_LOG(level, fmt, args...) \ - RTE_LOG_LINE(level, RAWDEV, "%s(): " fmt, __func__, ##args) +#define RTE_RDEV_LOG (level, ...) \ + RTE_LOG_LINE_PREFIX(level, RAWDEV, "%s(): ", __func__, __VA_ARGS__) -#define RTE_RDEV_ERR(fmt, args...) \ - RTE_RDEV_LOG(ERR, fmt, ## args) -#define RTE_RDEV_DEBUG(fmt, args...) \ - RTE_RDEV_LOG(DEBUG, fmt, ## args) -#define RTE_RDEV_INFO(fmt, args...) \ - RTE_RDEV_LOG(INFO, fmt, ## args) +#define RTE_RDEV_ERR (...) \ + RTE_RDEV_LOG(ERR, __VA_ARGS__) +#define RTE_RDEV_DEBUG (...) \ + RTE_RDEV_LOG(DEBUG, __VA_ARGS__) + +#define RTE_RDEV_INFO (...) \ + RTE_RDEV_LOG(INFO, __VA_ARGS__)/* Macros to check for valid device */ #define RTE_RAWDEV_VALID_DEVID_OR_ERR_RET (dev_id, retval) do { \
Signature · 1 line
1.8.3.1
PATCH v5 19/22 graph: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/graph/graph_private.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/graph/graph_private.h +2 -3
@@ -21,9 +21,8 @@#define RTE_LOGTYPE_GRAPH rte_graph_logtype#define GRAPH_LOG (level, ...) \ - RTE_LOG_LINE(level, GRAPH, \ - RTE_FMT("%s():%u " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(level, GRAPH, \ + "%s():%u ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define graph_err (...) GRAPH_LOG(ERR, __VA_ARGS__)#define graph_warn (...) GRAPH_LOG(WARNING, __VA_ARGS__)
Signature · 1 line
1.8.3.1
PATCH v5 15/22 ip_frag: stop using variadic argument pack extension
In reply to Tyler RetzlaffRemove use of args... and just use __VA_ARGS__. The macros expanding the argument pack do not require args extension to remove trailing comma.
--- lib/ip_frag/ip_frag_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/ip_frag/ip_frag_common.h +2 -2
@@ -26,9 +26,9 @@ RTE_LOG_LINE(level, IPFRAG, "" __VA_ARGS__)#ifdef RTE_LIBRTE_IP_FRAG_DEBUG -#define IP_FRAG_LOG(lvl, fmt, args...) RTE_LOG(lvl, IPFRAG, fmt, ##args) +#define IP_FRAG_LOG (lvl, ...) RTE_LOG(lvl, IPFRAG, __VA_ARGS__)#else -#define IP_FRAG_LOG(lvl, fmt, args...) do {} while(0) +#define IP_FRAG_LOG (lvl, fmt, ...) do {} while (0)#endif /* IP_FRAG_DEBUG */ #define IPV4_KEYLEN 1
Signature · 1 line
1.8.3.1
PATCH v5 22/22 devtools: forbid use argument variadic pack extension
In reply to Tyler RetzlaffPrevent introduction of new use of args... and ##args compiler extension.
--- devtools/checkpatches.sh | 8 ++++++++ 1 file changed, 8 insertions(+)
devtools/checkpatches.sh +8 -0
@@ -61,6 +61,14 @@ check_forbidden_additions() { # <patch> -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ "$1" || res=1 + # forbid use of variadic argument pack extension in macros + awk -v FOLDERS="lib drivers app examples" \ + -v EXPRESSIONS='#[[:space:]]*define.*[^(,[:space:]]\\.\\.\\.[[:space:]]*)' \ + -v RET_ON_FAIL=1 \ + -v MESSAGE='Do not use variadic argument pack in macros' \ + -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \ + "$1" || res=1 + # no output on stdout or stderr awk -v FOLDERS="lib drivers" \ -v EXPRESSIONS="\\\<printf\\\> \\\<fprintf\\\(stdout, \\\<fprintf\\\(stderr," \
Signature · 1 line
1.8.3.1
PATCH v5 20/22 member: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/member/member.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/member/member.h +2 -3
@@ -8,7 +8,6 @@#define RTE_LOGTYPE_MEMBER librte_member_logtype#define MEMBER_LOG (level, ...) \ - RTE_LOG_LINE(level, MEMBER, \ - RTE_FMT("%s(): " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(level, MEMBER, \ + "%s(): ", __func__, __VA_ARGS__)
Signature · 1 line
1.8.3.1
PATCH v5 21/22 node: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/node/node_private.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/node/node_private.h +2 -4
@@ -16,10 +16,8 @@#define RTE_LOGTYPE_NODE rte_node_logtype#define NODE_LOG (level, node_name, ...) \ - RTE_LOG_LINE(level, NODE, \ - RTE_FMT("%s: %s():%u " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - node_name, __func__, __LINE__, \ - RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(level, NODE, "%s: %s():%u ", \ + node_name RTE_LOG_COMMA __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define node_err (node_name, ...) NODE_LOG(ERR, node_name, __VA_ARGS__)#define node_info (node_name, ...) NODE_LOG(INFO, node_name, __VA_ARGS__)
Signature · 1 line
1.8.3.1
PATCH v5 16/22 bpf: stop using variadic argument pack extension
In reply to Tyler RetzlaffRemove fmt, args... and forward with __VA_ARGS__.
--- lib/bpf/bpf_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bpf/bpf_impl.h +2 -2
@@ -29,8 +29,8 @@ struct rte_bpf {extern int rte_bpf_logtype;#define RTE_LOGTYPE_BPF rte_bpf_logtype -#define RTE_BPF_LOG_LINE(lvl, fmt, args...) \ - RTE_LOG_LINE(lvl, BPF, fmt, ##args) +#define RTE_BPF_LOG_LINE (lvl, ...) \ + RTE_LOG_LINE(lvl, BPF, __VA_ARGS__)static inline size_t bpf_size (uint32_t bpf_op_sz)
Signature · 1 line
1.8.3.1
PATCH v5 18/22 eventdev: stop using variadic argument pack extension
In reply to Tyler RetzlaffUse RTE_LOG_LINE_PREFIX instead of RTE_LOG_LINE in macro expansions which allow a prefix and arguments to be inserted into the log line without the need to use the ## args variadic argument pack extension.
--- lib/eventdev/eventdev_pmd.h | 10 ++++------ lib/eventdev/rte_event_timer_adapter.c | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-)
lib/eventdev/eventdev_pmd.h +4 -6
@@ -36,15 +36,13 @@/* Logging Macros */ #define RTE_EDEV_LOG_ERR (...) \ - RTE_LOG_LINE(ERR, EVENTDEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(ERR, EVENTDEV, \ + "%s() line %u: ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#ifdef RTE_LIBRTE_EVENTDEV_DEBUG #define RTE_EDEV_LOG_DEBUG (...) \ - RTE_LOG_LINE(DEBUG, EVENTDEV, \ - RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(DEBUG, EVENTDEV, \ + "%s() line %u: ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#else #define RTE_EDEV_LOG_DEBUG (...) (void)0#endif
lib/eventdev/rte_event_timer_adapter.c +2 -3
@@ -41,9 +41,8 @@static const struct event_timer_adapter_ops swtim_ops;#define EVTIM_LOG (level, logtype, ...) \ - RTE_LOG_LINE(level, logtype, \ - RTE_FMT("EVTIMER: %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__ ,), \ - __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__ ,))) + RTE_LOG_LINE_PREFIX(level, logtype, \ + "EVTIMER: %s() line %u: ", __func__ RTE_LOG_COMMA __LINE__, __VA_ARGS__)#define EVTIM_LOG_ERR (...) EVTIM_LOG(ERR, EVTIM, __VA_ARGS__)
Signature · 1 line
1.8.3.1
Re: [PATCH v5 00/22] stop using variadic argument pack extension
In reply to Tyler RetzlaffQuoted 13 lines · Tyler Retzlaff
RTE_LOG_LINEcannot be augmented with a prefix format and arguments without the user ofRTE_LOG_LINEusing the args... and ## args compiler extension to conditionally remove trailing comma when the macro receives only a single argument.Provide a new/similar macro
RTE_LOG_LINE_PREFIXthat accepts the prefix format and arguments as separate parameters allowing them to be expanded at the correct locations inside ofRTE_FMT()allowing the rest of the non-prefix format string and arguments to be collapsed to the argument pack which can be directly forwarded with__VA_ARGS__avoiding the need for conditional comma removal.
Quoted 6 lines
I've done my best to manually check expansions (preprocessed) and compiled printf of the logs to validate correct output.
v5:
* add missing newline escape and comma inrte_windows.hmacro.
LGTM.
Series applied, thanks.
Signature · 1 line
David Marchand