* Re: Can the empty struct rte_eth_txmode be enhanced? @ 2013-06-12 12:23 lxu [not found] ` <tencent_32A472FE12E181E41F4C6C1C-9uewiaClKEY@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: lxu @ 2013-06-12 12:23 UTC (permalink / raw) To: Olivier MATZ, dev [-- Attachment #1: Type: text/plain, Size: 1421 bytes --] Great! Thanks for the quick feedback. ------------------ Original ------------------ From: "Olivier MATZ"<olivier.matz@6wind.com>; Date: Wed, Jun 12, 2013 05:17 PM To: "dev"<dev@dpdk.org>; Cc: "lxu"<lxu4net@qq.com>; Subject: Re: [dpdk-dev] Can the empty struct rte_eth_txmode be enhanced? Hello, > Can we change the struct rte_eth_txmode ? > > Such as : > > struct rte_eth_txmode { int reserve[]; }; /* sizeof(struct rte_eth_txmode) == 0 in gcc and g++ */ I agree with your solution. Do you approve the following patch ? From: lxu <lxu4net@qq.com> Date: Wed, 12 Jun 2013 09:32:30 +0200 Subject: [PATCH] ethdev: force the size of struct rte_eth_txmode to be 0 The size of an empty structure is 0 when compiling with gcc, and 1 when compiling with g++. Adding an empty table forces the size fo be 0, in C or C++. Acked-by: Olivier Matz <olivier.matz@6wind.com> Signed-off-by: lxu <lxu4net@qq.com> --- lib/librte_ether/rte_ethdev.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 5985496..e0a1ccf 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -320,6 +320,7 @@ struct rte_eth_vmdq_dcb_conf { * For future extensions. */ struct rte_eth_txmode { + int reserved[]; /* force the size of struct to be 0 */ }; /** -- 1.7.10.4 [-- Attachment #2: Type: text/html, Size: 1977 bytes --] ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <tencent_32A472FE12E181E41F4C6C1C-9uewiaClKEY@public.gmane.org>]
* Re: Can the empty struct rte_eth_txmode be enhanced? [not found] ` <tencent_32A472FE12E181E41F4C6C1C-9uewiaClKEY@public.gmane.org> @ 2013-06-12 13:39 ` Thomas Monjalon [not found] ` <201306121539.49552.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Thomas Monjalon @ 2013-06-12 13:39 UTC (permalink / raw) To: dev-VfR2kkLFssw 12/06/2013 14:23, lxu : > Great! Thanks for the quick feedback. > > ------------------ Original ------------------ > From: "Olivier MATZ"<olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>; > > I agree with your solution. Do you approve the following patch ? > > From: lxu <lxu4net-9uewiaClKEY@public.gmane.org> > Date: Wed, 12 Jun 2013 09:32:30 +0200 > Subject: [PATCH] ethdev: force the size of struct rte_eth_txmode to be 0 applied, thanks -- Thomas ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <201306121539.49552.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>]
* [PATCH] ethdev: fix empty struct rte_eth_txmode [not found] ` <201306121539.49552.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> @ 2013-06-12 14:30 ` Thomas Monjalon [not found] ` <1371047405-29432-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Thomas Monjalon @ 2013-06-12 14:30 UTC (permalink / raw) To: dev-VfR2kkLFssw The previous fix was for g++ but is broken with gcc: error: flexible array member in otherwise empty struct See http://gcc.gnu.org/onlinedocs/gcc-4.2.2/gcc/Zero-Length.html Let's fix it with #ifdef __cplusplus. Signed-off-by: Thomas Monjalon <thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> --- lib/librte_ether/rte_ethdev.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index a253b3f..2280772 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -320,7 +320,9 @@ struct rte_eth_vmdq_dcb_conf { * For future extensions. */ struct rte_eth_txmode { +#ifdef __cplusplus int reserved[]; /* force size of struct to be 0 */ +#endif }; /** -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <1371047405-29432-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] ethdev: fix empty struct rte_eth_txmode [not found] ` <1371047405-29432-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> @ 2013-06-12 14:46 ` Olivier MATZ [not found] ` <51B889B2.9050105-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Olivier MATZ @ 2013-06-12 14:46 UTC (permalink / raw) To: Thomas Monjalon; +Cc: dev-VfR2kkLFssw On 06/12/2013 04:30 PM, Thomas Monjalon wrote: > The previous fix was for g++ but is broken with gcc: > error: flexible array member in otherwise empty struct > See http://gcc.gnu.org/onlinedocs/gcc-4.2.2/gcc/Zero-Length.html > > Let's fix it with #ifdef __cplusplus. Sorry Thomas for the previous one, I should have tested it. This one looks good, I checked compilation and it works with gcc-4.6.3 and g++-4.6.3 ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <51B889B2.9050105-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] ethdev: fix empty struct rte_eth_txmode [not found] ` <51B889B2.9050105-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> @ 2013-06-12 15:14 ` Thomas Monjalon 0 siblings, 0 replies; 7+ messages in thread From: Thomas Monjalon @ 2013-06-12 15:14 UTC (permalink / raw) To: Olivier MATZ; +Cc: dev-VfR2kkLFssw 12/06/2013 16:46, Olivier MATZ : > On 06/12/2013 04:30 PM, Thomas Monjalon wrote: > > The previous fix was for g++ but is broken with gcc: > > error: flexible array member in otherwise empty struct > > Sorry Thomas for the previous one, I should have tested it. No problem, I should also better test before pushing :) > This one looks good, I checked compilation and it works with > gcc-4.6.3 and g++-4.6.3 pushed -- Thomas ^ permalink raw reply [flat|nested] 7+ messages in thread
* Can the empty struct rte_eth_txmode be enhanced? @ 2013-06-12 4:54 lxu [not found] ` <tencent_30A6C31C56B0DBD36771F80E-9uewiaClKEY@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: lxu @ 2013-06-12 4:54 UTC (permalink / raw) To: dev [-- Attachment #1: Type: text/plain, Size: 617 bytes --] Hello all,I'm trying to write a C++ DPDK example. Everything is fine until I tried to enable RSS feature. It wasn't work.After hardy works, I found it's because empty structure rte_eth_txmode. In gcc the size of rte_eth_txmode is 0. But in g++ it's 1. I known the empty structure is a gcc extension. But it isn't be permitted by C99 (6.7.2.1/7 "Structure and union specifiers": "If the struct-declaration-list contains no named members, the behavior is undefined"). Can we change the struct rte_eth_txmode ? Such as : struct rte_eth_txmode { int reserve[]; }; /* sizeof(struct rte_eth_txmode) == 0 in gcc and g++ */ [-- Attachment #2: Type: text/html, Size: 1087 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <tencent_30A6C31C56B0DBD36771F80E-9uewiaClKEY@public.gmane.org>]
* Re: Can the empty struct rte_eth_txmode be enhanced? [not found] ` <tencent_30A6C31C56B0DBD36771F80E-9uewiaClKEY@public.gmane.org> @ 2013-06-12 9:17 ` Olivier MATZ 0 siblings, 0 replies; 7+ messages in thread From: Olivier MATZ @ 2013-06-12 9:17 UTC (permalink / raw) To: dev-VfR2kkLFssw Hello, > Can we change the struct rte_eth_txmode ? > > Such as : > > struct rte_eth_txmode { int reserve[]; }; /* sizeof(struct rte_eth_txmode) == 0 in gcc and g++ */ I agree with your solution. Do you approve the following patch ? From: lxu <lxu4net-9uewiaClKEY@public.gmane.org> Date: Wed, 12 Jun 2013 09:32:30 +0200 Subject: [PATCH] ethdev: force the size of struct rte_eth_txmode to be 0 The size of an empty structure is 0 when compiling with gcc, and 1 when compiling with g++. Adding an empty table forces the size fo be 0, in C or C++. Acked-by: Olivier Matz <olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> Signed-off-by: lxu <lxu4net-9uewiaClKEY@public.gmane.org> --- lib/librte_ether/rte_ethdev.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 5985496..e0a1ccf 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -320,6 +320,7 @@ struct rte_eth_vmdq_dcb_conf { * For future extensions. */ struct rte_eth_txmode { + int reserved[]; /* force the size of struct to be 0 */ }; /** -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-06-12 15:14 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-06-12 12:23 Can the empty struct rte_eth_txmode be enhanced? lxu [not found] ` <tencent_32A472FE12E181E41F4C6C1C-9uewiaClKEY@public.gmane.org> 2013-06-12 13:39 ` Thomas Monjalon [not found] ` <201306121539.49552.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 2013-06-12 14:30 ` [PATCH] ethdev: fix empty struct rte_eth_txmode Thomas Monjalon [not found] ` <1371047405-29432-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 2013-06-12 14:46 ` Olivier MATZ [not found] ` <51B889B2.9050105-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 2013-06-12 15:14 ` Thomas Monjalon -- strict thread matches above, loose matches on Subject: below -- 2013-06-12 4:54 Can the empty struct rte_eth_txmode be enhanced? lxu [not found] ` <tencent_30A6C31C56B0DBD36771F80E-9uewiaClKEY@public.gmane.org> 2013-06-12 9:17 ` Olivier MATZ
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).