Beispiel #1
0
xmltagnamehandle xmlcontext::insert_tagname( const xmlstring &tagname )
{
   if (!init)
      init_context();

   // bugfix: first search, if the tagname is already in the list
   // since usually there are not much different tagnames, the search
   // shouldn't slow down parsing too much
   xmltagnamemap::const_iterator iter,stop;
   iter = tagnames.begin();
   stop = tagnames.end();

   for(;iter!=stop;iter++)
   {
      if ((*iter).second == tagname )
      {
         return (*iter).first;
      }
   }

   // insert new tagname
   xmltagnamemap::value_type keyvaluepair(nexthandle,tagname);
   tagnames.insert(keyvaluepair);

   return nexthandle++;
}
Beispiel #2
0
/**
 * Setup state before each subtest begins.
 */
static enum piglit_result
test_setup(void)
{
	enum piglit_result result = PIGLIT_PASS;

	/* Just in case the previous test forgot to unset these pointers... */
	g_dpy = EGL_NO_DISPLAY;
	g_ctx = EGL_NO_CONTEXT;

	result = init_display(EGL_NONE, &g_dpy);
	if (result != PIGLIT_PASS) {
		goto cleanup;
	}


	result = init_context(g_dpy, &g_ctx);
	if (result != PIGLIT_PASS) {
		goto cleanup;
	}
	/* Ensure that a context is bound so that the test can create syncs. */
	eglMakeCurrent(g_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, g_ctx);

cleanup:
	if (result != PIGLIT_PASS) {
		test_cleanup(EGL_NO_SYNC_KHR, &result);
	}
	return result;
}
Beispiel #3
0
xmlstring xmlcontext::get_entity( const xmlstring &entname )
{
   if (!init) init_context();

   xmlentitymap::const_iterator iter = entities.find( entname );
   return ( iter == entities.end() ? entname : iter->second );
}
Beispiel #4
0
void GlfwWindow::set_active(bool active) {

  glfwMakeContextCurrent(glfw_window_);
  if (!ctx_.render_device) {
    init_context();
  }
}
Beispiel #5
0
void scanrestart(void) {
	cp_context_t *ctx;
	int errors;
	
	ctx = init_context(CP_LOG_ERROR, &errors);
	check(cp_register_pcollection(ctx, pcollectiondir("collection1")) == CP_OK);
	check(cp_register_pcollection(ctx, pcollectiondir("collection2")) == CP_OK);
	check(cp_scan_plugins(ctx, 0) == CP_OK);
	check(cp_start_plugin(ctx, "plugin2b") == CP_OK);
	check(cp_start_plugin(ctx, "plugin1") == CP_OK);
	check(cp_get_plugin_state(ctx, "plugin1") == CP_PLUGIN_ACTIVE);
	check(cp_get_plugin_state(ctx, "plugin2a") == CP_PLUGIN_INSTALLED);
	check(cp_get_plugin_state(ctx, "plugin2b") == CP_PLUGIN_ACTIVE);

	// Check that upgraded plug-in is correctly restarted after upgrade
	check(cp_register_pcollection(ctx, pcollectiondir("collection1v2")) == CP_OK);
	check(cp_scan_plugins(ctx, CP_SP_UPGRADE | CP_SP_RESTART_ACTIVE) == CP_OK);
	check(cp_get_plugin_state(ctx, "plugin1") == CP_PLUGIN_ACTIVE);
	check(cp_get_plugin_state(ctx, "plugin2a") == CP_PLUGIN_INSTALLED);
	check(cp_get_plugin_state(ctx, "plugin2b") == CP_PLUGIN_ACTIVE);

	// Check that other plug-ins are correctly restarted after upgrade
	check(cp_register_pcollection(ctx, pcollectiondir("collection1v3")) == CP_OK);
	check(cp_scan_plugins(ctx, CP_SP_UPGRADE | CP_SP_STOP_ALL_ON_UPGRADE | CP_SP_RESTART_ACTIVE) == CP_OK);
	check(cp_get_plugin_state(ctx, "plugin1") == CP_PLUGIN_ACTIVE);
	check(cp_get_plugin_state(ctx, "plugin2a") == CP_PLUGIN_INSTALLED);
	check(cp_get_plugin_state(ctx, "plugin2b") == CP_PLUGIN_ACTIVE);
	
	cp_destroy();
	check(errors == 0);
}
AmfParser::AmfParser() {
	// TODO Auto-generated constructor stub
	init_context(&mContext, AmfReadHandle, AmfWriteHandle);
	mpParseBuffer = NULL;
	miCurrentCapacity = 0;
	InitParseBuffer();
}
Beispiel #7
0
void loadonlymaximalfrommemory(void) {
	cp_context_t *ctx;
	cp_plugin_info_t *plugin;
	cp_status_t status;
	int errors, bytesloaded = 0, i;
	const char *pd;
	char *pdfilename, *membuffer;
	FILE *f;

	/* Load plugin descriptor to memory buffer */
	pd = plugindir("maximal");
	check((pdfilename = malloc((strlen(pd) + strlen(CP_FNAMESEP_STR) + strlen(PLUGINFILENAME) + 1) * sizeof(char))) != NULL);
	strcpy(pdfilename, pd);
	strcat(pdfilename, CP_FNAMESEP_STR PLUGINFILENAME);
	check((membuffer = malloc(MEMBUFFERSIZE * sizeof(unsigned char))) != NULL);
	check((f = fopen(pdfilename, "r")) != NULL);
	do {
		i = fread(membuffer + bytesloaded, sizeof(char), MEMBUFFERSIZE - bytesloaded, f);
		check(!ferror(f));
		bytesloaded += i;
	} while (i > 0);
	fclose(f);
	
	/* Load plugin descriptor from memory buffer */
	ctx = init_context(CP_LOG_ERROR, &errors);
	check((plugin = cp_load_plugin_descriptor_from_memory(ctx, membuffer, bytesloaded, &status)) != NULL && status == CP_OK);

	/* Clean up */
	free(membuffer);
	cp_release_info(ctx, plugin);
	cp_destroy();
	check(errors == 0);
}
Beispiel #8
0
void scanstoponupgrade(void) {
	cp_context_t *ctx;
	int errors;
	
	ctx = init_context(CP_LOG_ERROR, &errors);
	check(cp_register_pcollection(ctx, pcollectiondir("collection1")) == CP_OK);
	check(cp_register_pcollection(ctx, pcollectiondir("collection2")) == CP_OK);
	check(cp_scan_plugins(ctx, 0) == CP_OK);
	
	// First check upgrade without stopping other plug-ins
	check(cp_start_plugin(ctx, "plugin1") == CP_OK);
	check(cp_get_plugin_state(ctx, "plugin1") == CP_PLUGIN_ACTIVE);
	check(cp_start_plugin(ctx, "plugin2a") == CP_OK);
	check(cp_get_plugin_state(ctx, "plugin2a") == CP_PLUGIN_ACTIVE);
	check(cp_register_pcollection(ctx, pcollectiondir("collection1v2")) == CP_OK);
	check(cp_scan_plugins(ctx, CP_SP_UPGRADE) == CP_OK);
	check(cp_get_plugin_state(ctx, "plugin1") == CP_PLUGIN_INSTALLED);
	check(cp_get_plugin_state(ctx, "plugin2a") == CP_PLUGIN_ACTIVE);
	
	// Then check upgrade with stop flag
	check(cp_start_plugin(ctx, "plugin1") == CP_OK);
	check(cp_get_plugin_state(ctx, "plugin1") == CP_PLUGIN_ACTIVE);
	check(cp_register_pcollection(ctx, pcollectiondir("collection1v3")) == CP_OK);
	check(cp_scan_plugins(ctx, CP_SP_UPGRADE | CP_SP_STOP_ALL_ON_UPGRADE) == CP_OK);
	check(cp_get_plugin_state(ctx, "plugin1") == CP_PLUGIN_INSTALLED);
	check(cp_get_plugin_state(ctx, "plugin2a") == CP_PLUGIN_RESOLVED);

	cp_destroy();
	check(errors == 0);
}
Beispiel #9
0
int main(int argc,char ** argv)
{
	//set log level first
	setenv("LOG_LEVEL","2",1);
	char ** ppHead=argv;
	while(ppHead!=NULL && *ppHead!=NULL)
	{
		if(strcmp(*ppHead,"-h")==0)
		{
			printHelp();
			exit(0);
		}
		ppHead++;
	}
	int ret=init_context(argc,argv);
	logI("MAIN","================init context complete===============\n");
	if(ret==-1)
	{
		release();
		printHelp();
		exit(1);
			
	}
	
	init_plugin(argc,argv);
	logI("MAIN","================init plugins complete===============\n");

	startup();
	
	return 0;
}
Beispiel #10
0
  bool Video_DX9::begin_prerender() {
    assert(!m_render_target && !m_render_to_surface);

    if(g_video_dx9_reset) {
      const HRESULT result = m_d3d_device->TestCooperativeLevel();
      
      if(result == D3DERR_DEVICELOST)
        return false;
      else if(result == D3DERR_DRIVERINTERNALERROR)
        throw Video_Device_Failure();
      
      if(result == D3DERR_DEVICENOTRESET) {
        if(FAILED(m_d3d_device->Reset(m_d3d_parameters)))
          throw Video_Device_Failure();
      
        g_video_dx9_reset = false;

        init_context();
      }
    }

    get_Textures().unlose_resources();
    get_Fonts().unlose_resources();

    return true;
  }
Beispiel #11
0
//==============================================================================
bool USB_Device::open_by_vid_pid(uint16_t vendor_id, uint16_t product_id)
{
	init_context();
	close();

	libusb_device_vector devices;
	USB_Enumerator enumerator(context_, devices);
	libusb_device_descriptor descriptor;

	foreach (libusb_device *item, devices)
	{
		if (!libusb_get_device_descriptor(item, &descriptor) &&
				descriptor.idVendor == vendor_id &&
				descriptor.idProduct == product_id)
		{
			int result = libusb_open(item, &handle_);
			if (result < 0)
				on_error("libusb_open", result);
			device_ = libusb_get_device(handle_);

			log_info("usb, open device, VID: %04Xh, PID: %04Xh", vendor_id, product_id);

			return true;
		}
	}
	return false;
}
Beispiel #12
0
static ErlDrvData
exmpp_xml_start(ErlDrvPort port, char *command)
{
	struct exmpp_xml_data *edd;

	/* Set binary mode. */
	set_port_control_flags(port, PORT_CONTROL_FLAG_BINARY);

	/* Allocate driver data structure. */
	edd = driver_alloc(sizeof(*edd));
	if (edd == NULL)
		return (ERL_DRV_ERROR_GENERAL);

	/* Initialize generic context. */
	if (init_context(&edd->ctx) != 0) {
		driver_free(edd);
		return (ERL_DRV_ERROR_GENERAL);
	}
	edd->ctx.make_attributes = exmpp_xml_cb_make_attributes;

	/* Initialize driver instance's context. */
	edd->parser = NULL;

	/* Initialize the declared_nss list. */
	edd->declared_nss = driver_alloc(sizeof(*(edd->declared_nss)));
	if (edd->declared_nss == NULL) {
		free_context(&edd->ctx);
		driver_free(edd);
		return (ERL_DRV_ERROR_GENERAL);
	}
	ei_x_new(edd->declared_nss);

	return ((ErlDrvData)edd);
}
Beispiel #13
0
int main(int argc , char* argv[])
{
	kbthreads_live = NUMCONTEXTS;
	
	int i;
    for( i =  0; i < NUMCONTEXTS/2; i++)
	{
       	kbthread_create(&contexts[i].context, kbthread_low);
		contexts[i].isTerminated = 0;
		contexts[i].priority = 1;
		contexts[i].goodMorning = time(NULL);
		contexts[i].time_to_sleep = 4; 
	}
	
	for (i = NUMCONTEXTS/2 ; i< NUMCONTEXTS ; i++)
	{
		kbthread_create(&contexts[i].context,kbthread_high);
		contexts[i].isTerminated = 0;
		contexts[i].priority = 2;
		contexts[i].goodMorning = time(NULL);
		contexts[i].time_to_sleep = 5;
	}
	setup_signals();
	init_context(&scheduler_context);
	current_context = &scheduler_context;
	setcontext(current_context);
	return 0;
}
Beispiel #14
0
/*
 * Tests memory allocation on the GPU by reading raster data in and,
 * after transfering it to the device, read it back and creating an
 * output raster that should be identical to the input one.
 *
 * int nrows .............. the number of rows in the DEM.
 * int ncols .............. the number of columns in the DEM.
 * int infd ............... file descriptor to read from the DEM.
 * int outfd .............. file descriptor to write to an output raster.
 * RASTER_MAP_TYPE rtype .. DEM element data type.
 *
 */
void test_cl (const int nrows, const int ncols,
              const int infd, const int outfd,
              RASTER_MAP_TYPE rtype)
{
    int row, col;

    CONTEXT * ctx = init_context ( );

    /* load raster DEM data */
    FCELL *dem_device = load_raster (ctx, nrows, ncols, infd, rtype);

    G_message ("Transfering raster data to the device ...");

    clmsync (ctx, 0, dem_device, CL_MEM_DEVICE|CL_EVENT_WAIT);

    G_message ("Transfering data from the device to the host ...");

    clmsync (ctx, 0, dem_device, CL_MEM_HOST|CL_EVENT_WAIT);

    /* save raster data */
    save_raster (dem_device, nrows, ncols, outfd);

    /* free allocated resources */
    clfree (dem_device);
}
Beispiel #15
0
/*
 * Allocate and initialize it (prior to sampling)
 */
static void init_forall_context(ef_solver_t *solver) {
  context_t *ctx;

  assert(solver->forall_context == NULL);
  ctx = (context_t *) safe_malloc(sizeof(context_t));
  init_context(ctx, solver->prob->terms, solver->logic, CTX_MODE_MULTICHECKS, solver->arch, false);
  solver->forall_context = ctx;
}
int main(int argc, char **argv)
{
    int c1 = init_context(&ctx1);
    int c2 = init_context(&ctx2);

    makecontext(&ctx1, (void (*)()) hello, 1, &ctx2);
    makecontext(&ctx2, (void (*)()) hello, 1, &ctx1);

    swapcontext(&oldc, &ctx1);

    VALGRIND_STACK_DEREGISTER(c1);
    
    VALGRIND_STACK_DEREGISTER(c2);
    

    return 0;
}
Beispiel #17
0
static void*
thread2_create_sync_with_display_bound_in_other_thread(void *arg)
{
	enum piglit_result *result;
	EGLDisplay t2_dpy = 0;
	EGLContext t2_ctx = 0;
	EGLSyncKHR t2_sync = 0;

	result = malloc(sizeof(*result));
	*result = PIGLIT_FAIL;

	piglit_logi("create second EGLDisplay");
	*result = init_other_display(&t2_dpy, g_dpy);
	if (*result != PIGLIT_PASS) {
		piglit_loge("failed to initialize a second EGLDisplay");
		goto cleanup;
	}

	if (!piglit_is_egl_extension_supported(t2_dpy, "EGL_KHR_fence_sync")) {
		piglit_loge("EGL_KHR_fence_sync unsupported on second display");
		*result = PIGLIT_SKIP;
		goto cleanup;
	}

	piglit_logi("create and make context current on second display");
	*result = init_context(t2_dpy, &t2_ctx);
	if (*result != PIGLIT_PASS) {
		goto cleanup;
	}

	*result = check_sync_in_current_context();
	if (*result != PIGLIT_PASS) {
		goto cleanup;
	}

	piglit_logi("try to create sync on first display, which is "
		 "bound on thread1");
	t2_sync = peglCreateSyncKHR(t2_dpy, EGL_SYNC_FENCE_KHR, NULL);
	if (t2_sync) {
		piglit_loge("eglCreateSyncKHR incorrectly succeeded");
		*result = PIGLIT_FAIL;
		goto cleanup;
	}
	if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
		piglit_loge("eglCreateSyncKHR emitted wrong error");
		*result = PIGLIT_FAIL;
		goto cleanup;
	}
	piglit_logi("eglCreateSyncKHR correctly failed with "
		 "EGL_BAD_MATCH");

cleanup:
	if (t2_dpy) {
		eglMakeCurrent(t2_dpy, 0, 0, 0);
		eglTerminate(t2_dpy);
	}
	return result;
}
Beispiel #18
0
xmlstring xmlcontext::get_tagname( xmltagnamehandle handle )
{
   if (!init)
      init_context();
   xmltagnamemap::const_iterator iter = tagnames.find( handle );

   xmlstring empty("");
   return ( iter == tagnames.end() ? empty : iter->second );
}
std::auto_ptr<SocketStream> open_conn(const char *hostname,
	TLSContext& rContext)
{
	init_context(rContext);
	std::auto_ptr<SocketStreamTLS> conn(new SocketStreamTLS);
	conn->Open(rContext, Socket::TypeINET, hostname,
		BOX_PORT_BBSTORED_TEST);
	return static_cast<std::auto_ptr<SocketStream> >(conn);
}
Beispiel #20
0
static void clean_up (void) {

   if( INVALID_WEBSVC_HANDLE != s_websvc){
      wst_term( s_websvc);
      s_websvc = INVALID_WEBSVC_HANDLE;
   }

   init_context ();
}
Beispiel #21
0
    /// Handle RDMA_CM_EVENT_ADDR_RESOLVED event.
    virtual void on_addr_resolved(struct rdma_cm_id* id)
    {
        if (!pd_)
            init_context(id->verbs);

        CONNECTION* conn = static_cast<CONNECTION*>(id->context);

        conn->on_addr_resolved(pd_, cq_);
    }
Beispiel #22
0
void debuglogger(void) {
	cp_context_t *ctx;
	struct log_count_t lc = { CP_LOG_DEBUG, 0, 0 };

	ctx = init_context(CP_LOG_INFO, NULL);
	check(cp_register_logger(ctx, counting_logger, &lc, CP_LOG_DEBUG) == CP_OK);
	cp_destroy();
	check(lc.count_max > 0 && lc.count_above_max == 0);
}
Beispiel #23
0
void islogged(void) {
	cp_context_t *ctx;

	ctx = init_context(CP_LOG_ERROR + 1, NULL);
	islogged_sev(ctx, CP_LOG_DEBUG);
	islogged_sev(ctx, CP_LOG_INFO);
	islogged_sev(ctx, CP_LOG_WARNING);
	islogged_sev(ctx, CP_LOG_ERROR);
	cp_destroy();
}
Beispiel #24
0
CLContext::CLContext (SmartPtr<CLDevice> &device)
    : _context_id (NULL)
    , _device (device)
{
    if (!init_context ()) {
        XCAM_LOG_DEBUG ("CL init context failed");
    }

    XCAM_LOG_DEBUG ("CLContext constructed");
}
/* -------------------------------------------- */
int64_t handle_them(file_container_t *fnames, int threadNum, int type, int bitsToLoss)
{
    int i;
    ctx_t total;
    margs_t *args;
    pthread_t *threads;
    args = malloc(sizeof(margs_t) * threadNum);
    memset(args, 0, sizeof(margs_t) * threadNum);
    threads = malloc(sizeof(pthread_t) * threadNum);
    memset(threads, 0, sizeof(pthread_t) * threadNum);

    for (i = 0; i < threadNum; i++)
    {
        args[i].idx = i;
        args[i].fnames = fnames;
        init_context(&(args[i].nums));
        args[i].bitsToLoss = bitsToLoss;

        if (type == 0)
        {
            pthread_create(&(threads[i]), NULL, worker_compress, &args[i]);
        }

        else if (type == 1)
        {
            pthread_create(&(threads[i]), NULL, worker_uncompress, &args[i]);
        }
    }

    init_context(&total);

    for (i = 0; i < threadNum; i++)
    {
        pthread_join(threads[i], NULL);
        update_context(&total, &(args[i].nums));
    }

    //ctx_print_more(&total, "Overall");
    print_context_info(&total, "[Overall] Context Info In handle_them()");
    free(threads);
    free(args);
    return total.allFileSize;
}
Beispiel #26
0
void logmsg(void) {
	cp_context_t *ctx;

	ctx = init_context(CP_LOG_ERROR + 1, NULL);
	logmsg_sev(ctx, CP_LOG_DEBUG, "debug");
	logmsg_sev(ctx, CP_LOG_INFO, "info");
	logmsg_sev(ctx, CP_LOG_WARNING, "warning");
	logmsg_sev(ctx, CP_LOG_ERROR, "error");
	cp_destroy();
}
Beispiel #27
0
void errorlogger(void) {
	cp_context_t *ctx;
	cp_status_t status;
	int errors;

	ctx = init_context(CP_LOG_ERROR + 1, &errors);
	check(cp_load_plugin_descriptor(ctx, "nonexisting", &status) == NULL && status != CP_OK);
	cp_destroy();
	check(errors > 0);
}
Beispiel #28
0
void warninglogger(void) {
	cp_context_t *ctx;
	struct log_count_t lc = { CP_LOG_WARNING, 0, 0 };

	ctx = init_context(CP_LOG_ERROR, NULL);
	check(cp_register_logger(ctx, counting_logger, &lc, CP_LOG_WARNING) == CP_OK);
	check(cp_start_plugin(ctx, "nonexisting") == CP_ERR_UNKNOWN);
	cp_destroy();
	check(lc.count_max > 0 && lc.count_above_max == 0);
}
Beispiel #29
0
/* Allocates memory */
cell factor_vm::begin_callback(cell quot_) {
  data_root<object> quot(quot_, this);

  ctx->reset();
  spare_ctx = new_context();
  callback_ids.push_back(callback_id++);

  init_context(ctx);

  return quot.value();
}
Beispiel #30
0
void onecollection(void) {
	cp_context_t *ctx;
	int errors;
	
	ctx = init_context(CP_LOG_ERROR, &errors);
	check(cp_register_pcollection(ctx, pcollectiondir("collection1")) == CP_OK);
	check(cp_scan_plugins(ctx, 0) == CP_OK);
	check(cp_get_plugin_state(ctx, "plugin1") == CP_PLUGIN_INSTALLED);
	cp_destroy();
	check(errors == 0);
}