/** * The default context needs to exist per ring that uses contexts. It stores the * context state of the GPU for applications that don't utilize HW contexts, as * well as an idle case. */ static int create_default_context(struct drm_i915_private *dev_priv) { struct i915_hw_context *ctx; int ret; BUG_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex)); ctx = create_hw_context(dev_priv->dev, NULL); if (IS_ERR(ctx)) return PTR_ERR(ctx); /* We may need to do things with the shrinker which require us to * immediately switch back to the default context. This can cause a * problem as pinning the default context also requires GTT space which * may not be available. To avoid this we always pin the * default context. */ dev_priv->ring[RCS].default_context = ctx; ret = i915_gem_object_pin(ctx->obj, CONTEXT_ALIGN, false); if (ret) { do_destroy(ctx); return ret; } ret = do_switch(NULL, ctx, 0); if (ret) { i915_gem_object_unpin(ctx->obj); do_destroy(ctx); } else { DRM_DEBUG_DRIVER("Default HW context loaded\n"); } return ret; }
void do_destroy( node_type *& r) { if(r == NULL) return; do_destroy(r->left()); do_destroy(r->right()); delete r; r = NULL; --m_size; }
int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file) { struct drm_i915_gem_context_destroy *args = data; struct drm_i915_file_private *file_priv = file->driver_priv; struct i915_hw_context *ctx; int ret; if (!(dev->driver->driver_features & DRIVER_GEM)) return -ENODEV; ret = i915_mutex_lock_interruptible(dev); if (ret) return ret; ctx = i915_gem_context_get(file_priv, args->ctx_id); if (!ctx) { mutex_unlock(&dev->struct_mutex); return -ENOENT; } do_destroy(ctx); mutex_unlock(&dev->struct_mutex); DRM_DEBUG_DRIVER("HW context %d destroyed\n", args->ctx_id); return 0; }
/** * The default context needs to exist per ring that uses contexts. It stores the * context state of the GPU for applications that don't utilize HW contexts, as * well as an idle case. */ static int create_default_context(struct drm_i915_private *dev_priv) { struct i915_hw_context *ctx; int ret; DRM_LOCK_ASSERT(dev_priv->dev); ret = create_hw_context(dev_priv->dev, NULL, &ctx); if (ret != 0) return (ret); /* We may need to do things with the shrinker which require us to * immediately switch back to the default context. This can cause a * problem as pinning the default context also requires GTT space which * may not be available. To avoid this we always pin the * default context. */ dev_priv->rings[RCS].default_context = ctx; ret = i915_gem_object_pin(ctx->obj, CONTEXT_ALIGN, false); if (ret) goto err_destroy; ret = do_switch(ctx); if (ret) goto err_unpin; DRM_DEBUG_DRIVER("Default HW context loaded\n"); return 0; err_unpin: i915_gem_object_unpin(ctx->obj); err_destroy: do_destroy(ctx); return ret; }
RIOTRtnE RServerCSLtr_Init(RServerCSLtr ** rtn_csLtr) { RC_ASSERT(*rtn_csLtr == NULL); RIOTRtnE ret; RServerCSLtr * csLtr = NULL; // Alloc memory and setting default value if ((csLtr = malloc(sizeof(RServerCSLtr))) == NULL) { RC_LOG_E("memory allocate failed!"); ret = RC_ERR_NOMEM; goto fail_and_exit; } memset(csLtr, 0, sizeof(RServerCSLtr)); csLtr->status = RC_STATUS_INITIAL; csLtr->sfd = 0; if (evhr_create(&csLtr->evhr) != EVHR_RTN_SUCCESS) { RC_LOG_E("evhr_create failed!"); ret = RC_ERR_NOMEM; goto fail_and_exit; } // RServerCSLtr initial success RC_LOG_D("RServerCSLtr initial success."); *rtn_csLtr = csLtr; return RC_SUCCESS; fail_and_exit: do_destroy(csLtr); return ret; }
static void do_destroy_all(void) { ip_pool_t i, highest = high_nr(); for (i=0; i<=highest; i++) do_destroy(i); }
RIOTRtnE RServer_Init() { RIOTRtnE ret; RC_LOG_I("Start initial server's configure and resource."); if (gRServerCtx != NULL) { RC_LOG_E("Initial RServerCtx failed! RServerCtx can not duplicate initial."); return RC_ERR_PERM; } // Initial RServerCtx if ((ret = do_init(&gRServerCtx)) != RC_SUCCESS) { RC_LOG_E("Initial RServerCtx failed! ret[%d]", ret); goto error_return; } RC_LOG_I("Server was initial complete, ready to start."); //do_status_change(gRServerCtx, RC_STATUS_READY); return RC_SUCCESS; error_return: do_destroy(gRServerCtx); gRServerCtx = NULL; return ret; }
static int create_hw_context(struct drm_device *dev, struct drm_i915_file_private *file_priv, struct i915_hw_context **ret_ctx) { struct drm_i915_private *dev_priv = dev->dev_private; struct i915_hw_context *ctx; int ret, id; ctx = malloc(sizeof(*ctx), DRM_I915_GEM, M_NOWAIT | M_ZERO); if (ctx == NULL) return (-ENOMEM); ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size); if (ctx->obj == NULL) { free(ctx, DRM_I915_GEM); DRM_DEBUG_DRIVER("Context object allocated failed\n"); return (-ENOMEM); } if (INTEL_INFO(dev)->gen >= 7) { ret = i915_gem_object_set_cache_level(ctx->obj, I915_CACHE_LLC_MLC); if (ret) goto err_out; } /* The ring associated with the context object is handled by the normal * object tracking code. We give an initial ring value simple to pass an * assertion in the context switch code. */ ctx->ring = &dev_priv->rings[RCS]; /* Default context will never have a file_priv */ if (file_priv == NULL) { *ret_ctx = ctx; return (0); } ctx->file_priv = file_priv; again: id = 0; ret = drm_gem_name_create(&file_priv->context_idr, ctx, &id); if (ret == 0) ctx->id = id; if (ret == -EAGAIN) goto again; else if (ret) goto err_out; *ret_ctx = ctx; return (0); err_out: do_destroy(ctx); return (ret); }
int auto_check() { object me = this_object(); object ob, dest, room, victim; if( !living(me) ) return 1; if( !(ob = query("owner")) ) return do_destroy(me); if( !(dest = environment(ob)) ) return do_destroy(me); room = environment(); if( room != dest ) { message("vision", me->name() + "急急忙忙地离开了。\n", room, ({me}));
RIOTRtnE RServer_Destroy() { do_destroy(gRServerCtx); gRServerCtx = NULL; RC_LOG_I("RServer was destroy."); return RC_SUCCESS; }
RIOTRtnE RServerCSLtr_Destroy(RServerCSLtr * csLtr) { RC_ASSERT(csLtr); RC_LOG_D("RServerCSLtr destroy now."); do_destroy(csLtr); RC_LOG_D("RServerCSLtr was destroy."); return RC_SUCCESS; }
static int context_idr_cleanup(uint32_t id, void *p, void *data) { struct i915_hw_context *ctx = p; KASSERT(id != DEFAULT_CONTEXT_ID, ("i915_gem_context: id == DEFAULT_CONTEXT_ID in cleanup")); do_destroy(ctx); return 0; }
static int context_idr_cleanup(int id, void *p, void *data) { struct i915_hw_context *ctx = p; BUG_ON(id == DEFAULT_CONTEXT_ID); do_destroy(ctx); return 0; }
static RIOTRtnE do_init(RServerCtx ** rtn_ctx) { RC_ASSERT(*rtn_ctx == NULL); RIOTRtnE ret; RServerCtx * ctx = NULL; if ((ctx = malloc(sizeof(RServerCtx))) == NULL) return RC_ERR_NOMEM; memset(ctx, 0, sizeof(RServerCtx)); ctx->status = RC_STATUS_INITIAL; ctx->cfg.port = RSERVER_CFG_DEFAULT_PORT; // Initial Evhr RC_LOG_D(" ==> [Evhr]"); if (evhr_create(&ctx->evhr) != EVHR_RTN_SUCCESS) { RC_LOG_E("Initial Evhr failed!"); ret = RC_ERR_NOMEM; goto error_return; } // Initial CusEv RC_LOG_D(" ==> [CusEv]"); if ((ctx->cusEv = evhr_cus_event_add( ctx->evhr, EVHR_PTR_TO_DATA(ctx), gRServerCusEvDispatch)) == NULL) { RC_LOG_E("Initial CusEv failed!"); ret = RC_ERR_NOMEM; goto error_return; } // Initial taskPool RC_LOG_D(" ==> [TaskPool]"); if (tpool_create(&ctx->taskPool, 5) != TPOOL_SUCCESS) { RC_LOG_E("Initial TaskPool failed!"); ret = RC_ERR_NOMEM; goto error_return; } // Initial RSUnit Socket RC_LOG_D(" ==> [RServerCSListener]"); if ((ret = RServerCSLtr_Init(&ctx->csLtr)) != RC_SUCCESS) { RC_LOG_E("Initial RServerCSListener failed! ret[%d]", ret); goto error_return; } *rtn_ctx = ctx; return RC_SUCCESS; error_return : do_destroy(ctx); return ret; }
static struct i915_hw_context * create_hw_context(struct drm_device *dev, struct drm_i915_file_private *file_priv) { struct drm_i915_private *dev_priv = dev->dev_private; struct i915_hw_context *ctx; int ret, id; ctx = kzalloc(sizeof(struct drm_i915_file_private), GFP_KERNEL); if (ctx == NULL) return ERR_PTR(-ENOMEM); ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size); if (ctx->obj == NULL) { kfree(ctx); DRM_DEBUG_DRIVER("Context object allocated failed\n"); return ERR_PTR(-ENOMEM); } /* The ring associated with the context object is handled by the normal * object tracking code. We give an initial ring value simple to pass an * assertion in the context switch code. */ ctx->ring = &dev_priv->ring[RCS]; /* Default context will never have a file_priv */ if (file_priv == NULL) return ctx; ctx->file_priv = file_priv; again: if (idr_pre_get(&file_priv->context_idr, GFP_KERNEL) == 0) { ret = -ENOMEM; DRM_DEBUG_DRIVER("idr allocation failed\n"); goto err_out; } ret = idr_get_new_above(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID + 1, &id); if (ret == 0) ctx->id = id; if (ret == -EAGAIN) goto again; else if (ret) goto err_out; return ctx; err_out: do_destroy(ctx); return ERR_PTR(ret); }
void Object::_on_destruction() { // this can cause problems with the libs being unloaded in the wrong order #if IMP_HAS_LOG != IMP_SILENT && !IMP_BASE_HAS_LOG4CXX LogLevel old = IMP::base::get_log_level(); if (log_level_ != DEFAULT) { IMP::base::set_log_level(log_level_); } log_level_ = old; #endif do_destroy(); }
static struct i915_hw_context * create_hw_context(struct drm_device *dev, struct drm_i915_file_private *file_priv) { struct drm_i915_private *dev_priv = dev->dev_private; struct i915_hw_context *ctx; int ret; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (ctx == NULL) return ERR_PTR(-ENOMEM); ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size); if (ctx->obj == NULL) { kfree(ctx); DRM_DEBUG_DRIVER("Context object allocated failed\n"); return ERR_PTR(-ENOMEM); } if (INTEL_INFO(dev)->gen >= 7) { ret = i915_gem_object_set_cache_level(ctx->obj, I915_CACHE_LLC_MLC); if (ret) goto err_out; } /* The ring associated with the context object is handled by the normal * object tracking code. We give an initial ring value simple to pass an * assertion in the context switch code. */ ctx->ring = &dev_priv->ring[RCS]; /* Default context will never have a file_priv */ if (file_priv == NULL) return ctx; ctx->file_priv = file_priv; ret = idr_alloc(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID + 1, 0, GFP_KERNEL); if (ret < 0) goto err_out; ctx->id = ret; return ctx; err_out: do_destroy(ctx); return ERR_PTR(ret); }
void i915_gem_context_fini(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; if (dev_priv->hw_contexts_disabled) return; /* The only known way to stop the gpu from accessing the hw context is * to reset it. Do this as the very last operation to avoid confusing * other code, leading to spurious errors. */ intel_gpu_reset(dev); i915_gem_object_unpin(dev_priv->ring[RCS].default_context->obj); do_destroy(dev_priv->ring[RCS].default_context); }
static void process_cmds(void) { char line[VCHANNEL_MAX_LINE]; int size; char *p, *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7, *tok8; while ((size = g_vchannel_read_fn(line, sizeof(line))) >= 0) { p = unescape(line); tok1 = get_token(&p); tok2 = get_token(&p); tok3 = get_token(&p); tok4 = get_token(&p); tok5 = get_token(&p); tok6 = get_token(&p); tok7 = get_token(&p); tok8 = get_token(&p); if (strcmp(tok1, "SYNC") == 0) do_sync(); else if (strcmp(tok1, "STATE") == 0) do_state(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0)), strtol(tok4, NULL, 0)); else if (strcmp(tok1, "POSITION") == 0) do_position(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0)), strtol(tok4, NULL, 0), strtol(tok5, NULL, 0), strtol(tok6, NULL, 0), strtol(tok7, NULL, 0)); else if (strcmp(tok1, "ZCHANGE") == 0) do_zchange(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0)), long_to_hwnd(strtoul(tok4, NULL, 0))); else if (strcmp(tok1, "FOCUS") == 0) do_focus(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL, 0))); else if (strcmp(tok1, "DESTROY") == 0) do_destroy(long_to_hwnd(strtoul(tok3, NULL, 0))); else if (strcmp(tok1, "SPAWN") == 0) do_spawn(strtoul(tok2, NULL, 0), tok3); else if (strcmp(tok1, "PERSISTENT") == 0) do_persistent(strtoul(tok2, NULL, 0), strtol(tok3, NULL, 0)); free(p); } }
/* * Timer event. */ static void on_timer_event(pj_timer_heap_t *th, pj_timer_entry *e) { pj_tcp_session *sess = (pj_tcp_session*)e->user_data; enum timer_id_t eid; PJ_UNUSED_ARG(th); pj_lock_acquire(sess->lock); eid = (enum timer_id_t) e->id; e->id = TIMER_NONE; if (eid == TIMER_KEEP_ALIVE) { pj_time_val now; pj_bool_t resched = PJ_TRUE; pj_gettimeofday(&now); /* Reshcedule timer */ if (resched) { pj_time_val delay; delay.sec = sess->ka_interval; delay.msec = 0; sess->timer.id = TIMER_KEEP_ALIVE; pj_timer_heap_schedule(sess->timer_heap, &sess->timer, &delay); } pj_lock_release(sess->lock); } else if (eid == TIMER_DESTROY) { /* Time to destroy */ pj_lock_release(sess->lock); do_destroy(sess); } else { pj_assert(!"Unknown timer event"); pj_lock_release(sess->lock); } }
/* Set session state */ PJ_DECL(void) pj_tcp_session_set_state(pj_tcp_session *sess, enum pj_tcp_state_t state) { pj_tcp_state_t old_state = sess->state; if (state==sess->state) return; PJ_LOG(4,(sess->obj_name, "State changed %s --> %s", state_names[old_state], state_names[state])); sess->state = state; #if 0 if (sess->partial_destroy) { do_destroy(sess); } else { #endif if (sess->cb.on_state) { (*sess->cb.on_state)(sess, old_state, state); } #if 0 } #endif }
void VectorImpl::_do_destroy(void* storage, size_t num) const { if (!(mFlags & HAS_TRIVIAL_DTOR)) { do_destroy(storage, num); } }
__seqof1 & __seqof1::operator = (const __seqof1 & that) { do_destroy(&__seqof1_destroy); do_copy(that, &__seqof1_copy); return *this; }
/* * Create TCP client session. */ PJ_DEF(pj_status_t) pj_tcp_session_create( const pj_stun_config *cfg, const char *name, int af, const pj_tcp_session_cb *cb, unsigned options, void *user_data, pj_stun_session *default_stun, pj_tcp_session **p_sess, int sess_idx, int check_idx) { pj_pool_t *pool; pj_tcp_session *sess; pj_stun_session_cb stun_cb; pj_lock_t *null_lock; pj_status_t status; PJ_ASSERT_RETURN(cfg && cfg->pf && cb && p_sess, PJ_EINVAL); PJ_ASSERT_RETURN(cb->on_send_pkt, PJ_EINVAL); PJ_UNUSED_ARG(options); if (name == NULL) name = "tcp%p"; /* Allocate and create TCP session */ pool = pj_pool_create(cfg->pf, name, PJNATH_POOL_LEN_TCP_SESS, PJNATH_POOL_INC_TCP_SESS, NULL); sess = PJ_POOL_ZALLOC_T(pool, pj_tcp_session); sess->pool = pool; sess->obj_name = pool->obj_name; sess->timer_heap = cfg->timer_heap; sess->af = (pj_uint16_t)af; sess->ka_interval = PJ_TCP_KEEP_ALIVE_SEC; sess->user_data = user_data; sess->sess_idx = sess_idx; sess->check_idx = check_idx; /* Copy STUN session */ pj_memcpy(&sess->stun_cfg, cfg, sizeof(pj_stun_config)); /* Copy callback */ pj_memcpy(&sess->cb, cb, sizeof(*cb)); /* Session lock */ status = pj_lock_create_recursive_mutex(pool, sess->obj_name, &sess->lock); if (status != PJ_SUCCESS) { do_destroy(sess); return status; } /* Timer */ pj_timer_entry_init(&sess->timer, TIMER_NONE, sess, &on_timer_event); //DEAN if (default_stun) { sess->stun = default_stun; } else { /* Create STUN session */ pj_bzero(&stun_cb, sizeof(stun_cb)); stun_cb.on_send_msg = &stun_on_send_msg; #if 0 stun_cb.on_request_complete = &stun_on_request_complete; #else stun_cb.on_request_complete = &on_stun_request_complete; #endif stun_cb.on_rx_request = &on_stun_rx_request; stun_cb.on_rx_indication = &on_stun_rx_indication; status = pj_stun_session_create2(&sess->stun_cfg, sess->obj_name, &stun_cb, PJ_FALSE, NULL, &sess->stun, PJ_TRUE, sess); if (status != PJ_SUCCESS) { do_destroy(sess); return status; } } /* Attach ourself to STUN session */ pj_stun_session_set_user_data(sess->stun, pj_tcp_sock_get_tsd(user_data)); /* Replace mutex in STUN session with a NULL mutex, since access to * STUN session is serialized. */ status = pj_lock_create_null_mutex(pool, name, &null_lock); if (status != PJ_SUCCESS) { do_destroy(sess); return status; } pj_stun_session_set_lock(sess->stun, null_lock, PJ_TRUE); /* Done */ PJ_LOG(4,(sess->obj_name, "TCP client session created")); *p_sess = sess; return PJ_SUCCESS; }
~BST() { do_destroy(m_root); }
int main(int argc, char **argv) { int opt; int op; #define OP_NONE 0 #define OP_LIST 1 #define OP_LIST_ALL 2 #define OP_FLUSH 3 #define OP_FLUSH_ALL 4 #define OP_DESTROY 5 #define OP_DESTROY_ALL 6 #define OP_ADD 7 #define OP_DEL 8 #define OP_CHECK 9 #define OP_NEW 10 #define OP_NEW_ALL 11 #define OP_HIGHEST 12 char *op_pool; fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { fprintf(stderr, "cannot get DGRAM socket: %s\n", strerror(errno)); exit(1); } op_pool = 0; op = OP_NONE; /* GRRR. I thought getopt() would allow an "L*" specifier, for an -L * taking an optional argument. Does not work. Bad. * Adding -l for -L without argument, also -f/-F and -x/-X. */ while (EOF != (opt=getopt( argc, argv, "HhnvuqA:D:C:N:t:L:F:X:lfxB"))) switch(opt) { case 'l': if (op != OP_NONE) usage("conflicting operations"); op = OP_LIST_ALL; break; case 'L': if (op != OP_NONE) usage("conflicting operations"); op = OP_LIST; op_pool = optarg; break; case 'f': if (op != OP_NONE) usage("conflicting operations"); op = OP_FLUSH_ALL; break; case 'F': if (op != OP_NONE) usage("conflicting operations"); op = OP_FLUSH; op_pool = optarg; break; case 'x': if (op != OP_NONE) usage("conflicting operations"); op = OP_DESTROY_ALL; break; case 'X': if (op != OP_NONE) usage("conflicting operations"); op = OP_DESTROY; op_pool = optarg; break; case 'A': if (op != OP_NONE) usage("conflicting operations"); op = OP_ADD; op_pool = optarg; break; case 'D': if (op != OP_NONE) usage("conflicting operations"); op = OP_DEL; op_pool = optarg; break; case 'C': if (op != OP_NONE) usage("conflicting operations"); op = OP_CHECK; op_pool = optarg; break; case 'B': if (op != OP_NONE) usage("conflicting operations"); op = OP_NEW_ALL; break; case 'N': if (op != OP_NONE) usage("conflicting operations"); op = OP_NEW; op_pool = optarg; break; case 'H': if (op != OP_NONE) usage("conflicting operations"); op = OP_HIGHEST; break; case 't': flag_t = optarg; break; case 'n': flag_n = 1; break; case 'v': flag_v = 1; break; case 'u': flag_u = 1; break; case 'q': flag_q = 1; break; case 'h': usage(0); default: usage("bad option"); } if (op == OP_NONE) usage("no operation specified"); if (op == OP_LIST_ALL) { do_list_all(); return 0; } if (op == OP_LIST) { do_list(get_index(op_pool)); return 0; } if (op == OP_FLUSH_ALL) { do_flush_all(); return 0; } if (op == OP_FLUSH) { do_flush(get_index(op_pool)); return 0; } if (op == OP_DESTROY_ALL) { do_destroy_all(); return 0; } if (op == OP_DESTROY) { do_destroy(get_index(op_pool)); return 0; } if (op == OP_CHECK) { if (optind >= argc) usage("missing address to check"); return do_check(get_index(op_pool), argv[optind]); } if (op == OP_NEW_ALL) { do_new_all(); return 0; } if (op == OP_NEW) { do_new(get_index(op_pool), argc-optind, argv+optind); return 0; } if (op == OP_ADD) { if (optind >= argc) usage("missing address to add"); return do_adddel(get_index(op_pool), argv[optind], IP_POOL_ADD_ADDR); } if (op == OP_DEL) { if (optind >= argc) usage("missing address to delete"); return do_adddel(get_index(op_pool), argv[optind], IP_POOL_DEL_ADDR); } if (op == OP_HIGHEST) { printf("%d\n", high_nr()); return 0; } usage("no operation specified"); return 0; }
void clear() { do_destroy(m_root); }
__seqof1::~__seqof1() { do_destroy(&__seqof1_destroy); }
int main(int argc, char* argv[]){ char* action; Window window; int arg[5]={0}; // Connexion à un serveur X display = XOpenDisplay(NULL); if(!display){ printf("Can not open display.\n"); exit(EXIT_FAILURE); } // Récupère la valeur par default des différentes variables. screen = DefaultScreen(display); gc = DefaultGC (display, screen); root = RootWindow (display, screen); // Détermine l'action à effectuer : // On vérifie que le 2er argument (autre que nom fichier) est un id de fenetre : if(argc>2 && ((!strncmp(argv[2],"0x",2) && strtoll(argv[2],NULL,16)) || strtoll(argv[2],NULL,10)) ){ action = argv[1]; window = get_window(argv); // Si 5 arguments, c'est soit un move, soit un resize: if (argc==3){ // 1 seul argument (ex: 0x32422 ) if(!strcmp(action,"mapRaise")) do_map_and_raise(window); else if(!strcmp(action,"map")) do_map(window); else if(!strcmp(action,"raise")) do_raise(window); else if(!strcmp(action,"destroy")) do_destroy(window); else if(!strcmp(action,"focus")) do_focus(window); else if(!strcmp(action,"minimize")) do_minimize(window); else if(!strcmp(action,"set_desktop")) set_desktop((int)strtoll(argv[2],NULL,10)); else fail(); } else if(argc==4){ // 2 arguments (ex : 0x4242535 1 ) if(!strcmp(action,"set_desktop_for_window")){ set_desktop(strtoll(argv[3],NULL,10)); set_desktop_for_window(window,strtoll(argv[3],NULL,10)); } else if(!strcmp(action,"set_viewport")) set_viewport((int)strtoll(argv[2],NULL,10),(int)strtoll(argv[3],NULL,10)); else fail(); } else if(argc==5){ arg[0]=(int)strtoll(argv[3],NULL,10); arg[1]=(int)strtoll(argv[4],NULL,10); if(!strcmp(action,"move")) do_move(window, arg[0], arg[1]); else if(!strcmp(action,"resize")) do_resize(window,arg[0],arg[1]); else fail(); } else if(argc==7){ arg[0]=(int)strtoll(argv[3],NULL,10); arg[1]=(int)strtoll(argv[4],NULL,10); arg[2]=(int)strtoll(argv[5],NULL,10); arg[3]=(int)strtoll(argv[6],NULL,10); if(!strcmp(action,"moveResize")) do_move_and_resize(window, arg[0], arg[1], arg[2], arg[3]); else fail(); } else fail(); } else fail(); XCloseDisplay(display); return EXIT_SUCCESS; }
static struct i915_hw_context * create_hw_context(struct drm_device *dev, struct drm_i915_file_private *file_priv) { struct drm_i915_private *dev_priv = dev->dev_private; struct i915_hw_context *ctx; struct i915_ctx_handle *han; int ret; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (ctx == NULL) return ERR_PTR(-ENOMEM); ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size); if (ctx->obj == NULL) { kfree(ctx); DRM_DEBUG_DRIVER("Context object allocated failed\n"); return ERR_PTR(-ENOMEM); } if (INTEL_INFO(dev)->gen >= 7) { ret = i915_gem_object_set_cache_level(ctx->obj, I915_CACHE_LLC_MLC); if (ret) goto err_out; } /* The ring associated with the context object is handled by the normal * object tracking code. We give an initial ring value simple to pass an * assertion in the context switch code. */ ctx->ring = &dev_priv->ring[RCS]; /* Default context will never have a file_priv */ if (file_priv == NULL) return ctx; ctx->file_priv = file_priv; han = malloc(sizeof(*han), M_DRM, M_WAITOK | M_CANFAIL | M_ZERO); if (han == NULL) { ret = -ENOMEM; DRM_DEBUG_DRIVER("idr allocation failed\n"); goto err_out; } han->ctx = ctx; again: han->handle = ++file_priv->ctx_id; if (han->handle <= DEFAULT_CONTEXT_ID + 1 || SPLAY_INSERT(i915_ctx_tree, &file_priv->ctx_tree, han)) goto again; ctx->id = han->handle; return ctx; err_out: do_destroy(ctx); return ERR_PTR(ret); }