From 3a8090030fad79d143daa3df00ee367d86ada75a Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 2 Sep 2016 14:33:57 -0400 Subject: driver: internals: added the static inlined slbt_get_driver_ictx() helper. --- src/internal/slibtool_driver_impl.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/internal/slibtool_driver_impl.h') diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index f79f9e3..19549ad 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -84,4 +84,16 @@ struct slbt_unit_ctx_impl { struct slbt_unit_ctx uctx; }; +static inline struct slbt_driver_ctx_impl * slbt_get_driver_ictx(const struct slbt_driver_ctx * dctx) +{ + uintptr_t addr; + + if (dctx) { + addr = (uintptr_t)dctx - offsetof(struct slbt_driver_ctx_impl,ctx); + return (struct slbt_driver_ctx_impl *)addr; + } + + return 0; +} + #endif -- cgit v1.2.3