Thread (31 messages) 31 messages, 6 authors, 2018-01-31

Re: [PATCH v1 1/4] net/mlx4: move rdma-core calls to separate file

From: Adrien Mazarguil <hidden>
Date: 2018-01-25 11:31:55

On Wed, Jan 24, 2018 at 03:58:57PM -0800, Stephen Hemminger wrote:
On Thu, 25 Jan 2018 00:25:00 +0100
Adrien Mazarguil [off-list ref] wrote:
quoted
+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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help