static intel_driver_t* intel_driver_new(void) { intel_driver_t *driver = NULL; TRY_ALLOC_NO_ERR (driver, CALLOC(intel_driver_t)); driver->fd = -1; exit: return driver; error: intel_driver_delete(driver); driver = NULL; goto exit; }
LOCAL dri_state_t* dri_state_new(void) { dri_state_t *state = NULL; TRY_ALLOC_NO_ERR (state, CALLOC(dri_state_t)); state->fd = -1; state->driConnectedFlag = NONE; dri_state_init_drawable_hash_table(state); exit: return state; error: dri_state_delete(state); state = NULL; goto exit; }
static intel_driver_t* cl_intel_driver_new(cl_context_prop props) { intel_driver_t *driver = NULL; TRY_ALLOC_NO_ERR (driver, intel_driver_new()); intel_driver_open(driver, props); /* We use the first 2 slots(0,1) for all the bufs. * Notify the gbe this base index, thus gbe can avoid conflicts * when it allocates slots for images*/ gbe_set_image_base_index(3); exit: return driver; error: cl_intel_driver_delete(driver); driver = NULL; goto exit; }
LOCAL cl_context cl_context_new(struct _cl_context_prop *props) { cl_context ctx = NULL; TRY_ALLOC_NO_ERR (ctx, CALLOC(struct _cl_context)); 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); pthread_mutex_init(&ctx->buffer_lock, NULL); pthread_mutex_init(&ctx->sampler_lock, NULL); exit: return ctx; error: cl_context_delete(ctx); ctx = NULL; goto exit; }