[ofw] [PATCH 9/?] Don't reinvent the wheel
Fab Tillier
ftillier at microsoft.com
Mon Jun 18 19:32:45 PDT 2012
The to_mxxx macro basically reinvents the CONTAINING_RECORD macro. Just use CONTAINING_RECORD.
Signed-off-by: Fab Tillier <ftillier at microsoft.com>
Index: hw/mlx4/user/hca/mlx4.h
===================================================================
--- hw/mlx4/user/hca/mlx4.h (revision 3414)
+++ hw/mlx4/user/hca/mlx4.h (working copy)
@@ -276,44 +276,40 @@
return (val + align - 1) & ~(align - 1);
}
-#define to_mxxx(xxx, type) \
- ((struct mlx4_##type *) \
- ((uint8_t *) ib##xxx - offsetof(struct mlx4_##type, ibv_##xxx)))
-
static inline struct mlx4_context *to_mctx(struct ibv_context *ibctx)
{
- return to_mxxx(ctx, context);
+ return CONTAINING_RECORD(ibctx, struct mlx4_context, ibv_ctx);
}
static inline struct mlx4_pd *to_mpd(struct ibv_pd *ibpd)
{
- return to_mxxx(pd, pd);
+ return CONTAINING_RECORD(ibpd, struct mlx4_pd, ibv_pd);
}
static inline struct mlx4_cq *to_mcq(struct ibv_cq *ibcq)
{
- return to_mxxx(cq, cq);
+ return CONTAINING_RECORD(ibcq, struct mlx4_cq, ibv_cq);
}
static inline struct mlx4_srq *to_msrq(struct ibv_srq *ibsrq)
{
- return to_mxxx(srq, srq);
+ return CONTAINING_RECORD(ibsrq, struct mlx4_srq, ibv_srq);
}
static inline struct mlx4_qp *to_mqp(struct ibv_qp *ibqp)
{
- return to_mxxx(qp, qp);
+ return CONTAINING_RECORD(ibqp, struct mlx4_qp, ibv_qp);
}
static inline struct mlx4_ah *to_mah(struct ibv_ah *ibah)
{
- return to_mxxx(ah, ah);
+ return CONTAINING_RECORD(ibah, struct mlx4_ah, ibv_ah);
}
#ifdef XRC_SUPPORT
static inline struct mlx4_xrc_domain *to_mxrcd(struct ibv_xrc_domain *ibxrcd)
{
- return to_mxxx(xrcd, xrc_domain);
+ return CONTAINING_RECORD(ibxrcd, struct mlx4_xrcd, ibv_xrcd);
}
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 9.to_mxxx.patch
Type: application/octet-stream
Size: 1604 bytes
Desc: 9.to_mxxx.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20120619/80a8f2a6/attachment.obj>
More information about the ofw
mailing list