[dpdk-dev] [PATCH v1 1/4] net/mlx4: move rdma-core calls to separate file
Adrien Mazarguil
adrien.mazarguil at 6wind.com
Thu Jan 25 12:31:41 CET 2018
On Wed, Jan 24, 2018 at 03:58:57PM -0800, Stephen Hemminger wrote:
> On Thu, 25 Jan 2018 00:25:00 +0100
> Adrien Mazarguil <adrien.mazarguil at 6wind.com> wrote:
>
> > +const struct mlx4_glue *mlx4_glue = &(const struct mlx4_glue){
> > + .fork_init = mlx4_glue_fork_init,
> > + .get_async_event = mlx4_glue_get_async_event,
>
> The cast should not be necessary here.
It's not a mere cast but a compound literal. The mlx4_glue symbol represents
a pointer to this structure, not the structure itself. This syntax is
equivalent to:
static const struct mlx4_glue mlx4_glue_internal = {
...
};
const struct mlx4_glue *mlx4_glue = &mlx4_glue_internal;
The reason I chose to expose a pointer instead of that structure directly is
seamless transition to dlsym() in the next patch, otherwise all
mlx4_glue->foo() need to be first written mlx4_glue.foo() and then modified
as mlx4_glue->foo().
--
Adrien Mazarguil
6WIND
More information about the dev
mailing list