diff options
author | Junyan He <junyan.he@intel.com> | 2016-07-19 19:25:54 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2016-09-02 17:35:03 +0800 |
commit | a3867177fde9e7e5bd01fe0f94914e8cb37783cd (patch) | |
tree | ad0f7699b94283613918606937811bba87900d66 /src/cl_context.c | |
parent | ce4439635c2eb365124f1c772842fe068bac3847 (diff) |
Runtime: Apply base object to cl_context
Signed-off-by: Junyan He <junyan.he@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'src/cl_context.c')
-rw-r--r-- | src/cl_context.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/cl_context.c b/src/cl_context.c index a6bde7d2..c6137a36 100644 --- a/src/cl_context.c +++ b/src/cl_context.c @@ -167,11 +167,9 @@ cl_context_new(struct _cl_context_prop *props) cl_context ctx = NULL; TRY_ALLOC_NO_ERR (ctx, CALLOC(struct _cl_context)); + CL_OBJECT_INIT_BASE(ctx, CL_OBJECT_CONTEXT_MAGIC); TRY_ALLOC_NO_ERR (ctx->drv, cl_driver_new(props)); - SET_ICD(ctx->dispatch) ctx->props = *props; - ctx->magic = CL_MAGIC_CONTEXT_HEADER; - ctx->ref_n = 1; ctx->ver = cl_driver_get_ver(ctx->drv); pthread_mutex_init(&ctx->program_lock, NULL); pthread_mutex_init(&ctx->queue_lock, NULL); @@ -195,7 +193,7 @@ cl_context_delete(cl_context ctx) return; /* We are not done yet */ - if (atomic_dec(&ctx->ref_n) > 1) + if (CL_OBJECT_DEC_REF(ctx) > 1) return; /* delete the internal programs. */ @@ -227,7 +225,7 @@ cl_context_delete(cl_context ctx) assert(ctx->drv); cl_free(ctx->prop_user); cl_driver_delete(ctx->drv); - ctx->magic = CL_MAGIC_DEAD_HEADER; /* For safety */ + CL_OBJECT_DESTROY_BASE(ctx); cl_free(ctx); } @@ -235,7 +233,7 @@ LOCAL void cl_context_add_ref(cl_context ctx) { assert(ctx); - atomic_inc(&ctx->ref_n); + CL_OBJECT_INC_REF(ctx); } LOCAL cl_command_queue |