From 2c7a1617079024d4844a8872c845c9b109a76025 Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 26 Oct 2016 18:53:23 -0400 Subject: driver: internals: added the static inlined amgc_get_driver_ictx() helper. --- src/internal/apimagic_driver_impl.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/internal/apimagic_driver_impl.h b/src/internal/apimagic_driver_impl.h index 2e42ce4..6d5ce02 100644 --- a/src/internal/apimagic_driver_impl.h +++ b/src/internal/apimagic_driver_impl.h @@ -50,4 +50,18 @@ struct amgc_unit_ctx_impl { struct compilation_unit_t ccunit; }; + +static inline struct amgc_driver_ctx_impl * amgc_get_driver_ictx( + const struct amgc_driver_ctx * dctx) +{ + uintptr_t addr; + + if (dctx) { + addr = (uintptr_t)dctx - offsetof(struct amgc_driver_ctx_impl,ctx); + return (struct amgc_driver_ctx_impl *)addr; + } + + return 0; +} + #endif -- cgit v1.2.3