Exemple #1
0
// }
void my_test() {

	char heap[100];

	//printf("%s\n", heap);
	
	hl_init(heap, 100 * sizeof(char));
	
	char* ptr = (char *) hl_alloc(heap, 13 * sizeof(char));
	
	ptr[0] = 'h';
	ptr[1] = 'e';
	ptr[2] = 'l';
	ptr[3] = 'l';
	ptr[4] = 'o';
	ptr[5] = ' ';
	ptr[6] = 'w';
	ptr[7] = 'o';
	ptr[8] = 'r';
	ptr[9] = 'l';
	ptr[10] = 'd';
	ptr[11] = '!';
	ptr[12] = '\0';
	
	printf("%s\n", ptr);
	//printf("%s\n", ptr->);

	char* ptr2 = (char *) hl_resize(heap, ptr, 13 * sizeof(char));
	printf("%s\n", ptr2);


	char* ptr3 = (char *) hl_resize(heap, ptr,  16 * sizeof(char));
	printf("%s\n", ptr3);

}
Exemple #2
0
void exec_init() {
	// initialize all sub-systems
	hl_init();
	schd_init();
	lcd_init();
	cam_init();	
	adc_init();
	serv_init();
	cont_init();
	ui_init();
	mot_init();
	//comms_init();	
	
	// disable interrupt
	disable_irq(EXEC_PIT_IRQ_NUM);
	
	// enable the clock to the PIT module (pg. 299)
	SIM_SCGC6 |= SIM_SCGC6_PIT_MASK;

	// enable clock for PIT timers and allow timers to continue to
	// run in debug mode (pg. 1038)
	PIT_MCR = 0x0; 
	
	exec_disablePit();
	
	exec_sysMode = EXEC_MODE_IDLE;
	lcd_update();
	exec_update();		
}
Exemple #3
0
int main( int argc, char** argv ) {
  if( argc > 1 ){
    unsigned char* p = readfile(argv[1]);
    hlState_t s;
    hl_init(&s);
    s.prog = p;
    hl_pstart(&s);
    hl_vrun(&s);
  }
  return 0;
}
Exemple #4
0
void initMain(int argc, char** argv) {
  installLayerStackTracer();
  std::string line;
  for (int i = 0; i < argc; ++i) {
    line += argv[i];
    line += ' ';
  }

#ifndef GFLAGS_GFLAGS_H_
  namespace gflags = google;
#endif

  gflags::ParseCommandLineFlags(&argc, &argv, true);
  initializeLogging(argc, argv);
  LOG(INFO) << "commandline: " << line;
  CHECK_EQ(argc, 1) << "Unknown commandline argument: " << argv[1];

  installProfilerSwitch();

#ifdef __SSE__
  _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
#endif
#ifdef __SSE3__
  _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
#endif

  if (FLAGS_seed == 0) {
    unsigned int t = time(NULL);
    srand(t);
    ThreadLocalRand::initSeed(t);
    LOG(INFO) << "random number seed=" << t;
  } else {
    srand(FLAGS_seed);
    ThreadLocalRand::initSeed(FLAGS_seed);
  }

  if (FLAGS_use_gpu) {
    // This is the initialization of the CUDA environment,
    // need before runInitFunctions.
    // TODO(hedaoyuan) Can be considered in the runInitFunctions,
    // but to ensure that it is the first to initialize.
    hl_start();
    hl_init(FLAGS_gpu_id);
  }

  version::printVersion();
  checkCPUFeature().check();
  runInitFunctions();
}
Exemple #5
0
int main(int argc, char *argv[])
{
	gboolean root_override=FALSE, open_in_new_window = FALSE;
	GList *filenames = NULL, *projectfiles=NULL;
	gint linenumber = -1;

	Tbfwin *firstbfwin;
#ifndef NOSPLASH
	GtkWidget *splash_window;
#endif /* #ifndef NOSPLASH */

#ifdef ENABLE_NLS
	setlocale(LC_ALL,"");
	bindtextdomain(PACKAGE,LOCALEDIR);
	DEBUG_MSG("set bindtextdomain for %s to %s\n",PACKAGE,LOCALEDIR);
	bind_textdomain_codeset(PACKAGE, "UTF-8");
	textdomain(PACKAGE);
#endif
#ifdef HAVE_ATLEAST_GNOMEUI_2_6
	gnome_init(PACKAGE, VERSION, argc, argv);
#else
	gtk_init(&argc, &argv);
#endif /* HAVE_ATLEAST_GNOMEUI_2_6
 */
	main_v = g_new0(Tmain, 1);
	main_v->session = g_new0(Tsessionvars,1);
	DEBUG_MSG("main, main_v is at %p\n", main_v);

	rcfile_check_directory();
	rcfile_parse_main();

	parse_commandline(argc, argv, &root_override, &filenames, &projectfiles, &open_in_new_window, &linenumber);
#ifdef WITH_MSG_QUEUE
	if (((filenames || projectfiles) && (main_v->props.view_bars & MODE_REUSE_WINDOW)) || open_in_new_window) {
		msg_queue_start(filenames, projectfiles, linenumber, open_in_new_window);
	}
#endif /* WITH_MSG_QUEUE */
#ifndef NOSPLASH
	/* start splash screen somewhere here */
	splash_window = start_splash_screen();
	splash_screen_set_label(_("parsing highlighting file..."));
#endif /* #ifndef NOSPLASH */

	{
		gchar *filename = g_strconcat(g_get_home_dir(), "/.winefish/dir_history", NULL);
		main_v->recent_directories = get_stringlist(filename, NULL);
		g_free(filename);
	}
	rcfile_parse_global_session();
	rcfile_parse_highlighting();
#ifndef NOSPLASH
	splash_screen_set_label(_("compiling highlighting patterns..."));
#endif /* #ifndef NOSPLASH */
	hl_init();
#ifndef NOSPLASH
	splash_screen_set_label(_("initialize some other things..."));
#endif /* #ifndef NOSPLASH */
	filebrowserconfig_init();
	filebrowser_filters_rebuild();
	autoclosing_init();
#ifndef NOSPLASH
	splash_screen_set_label(_("parsing autotext and words file..."));
#endif /* #ifndef NOSPLASH */
	autotext_init();
	completion_init();
#ifndef NOSPLASH
	splash_screen_set_label(_("parsing custom menu file..."));
#endif /* #ifndef NOSPLASH */
	rcfile_parse_custom_menu(FALSE,FALSE);

#ifdef SNOOPER2
#ifndef NOSPLASH
	splash_screen_set_label(_("parsing keymap and initializing function list..."));
#endif /* #ifndef NOSPLASH */
	funclist_init();
	keymap_init();
#endif /* SNOOPER2 */
	
	main_v->tooltips = gtk_tooltips_new();
	/* initialize the completion window */
	/* main_v->completion.window = NULL; */
	fref_init();
	bmark_init();
#ifdef WITH_MSG_QUEUE
	if (!filenames && !projectfiles && (main_v->props.view_bars & MODE_REUSE_WINDOW)) {
		msg_queue_start(NULL, NULL, -1, open_in_new_window);
	}
#endif /* WITH_MSG_QUEUE */
#ifndef NOSPLASH
	splash_screen_set_label(_("creating main gui..."));
#endif /* #ifndef NOSPLASH */

	/* create the first window */
	firstbfwin = g_new0(Tbfwin,1);
	firstbfwin->session = main_v->session;
	firstbfwin->bookmarkstore = main_v->bookmarkstore;
	main_v->bfwinlist = g_list_append(NULL, firstbfwin);
	gui_create_main(firstbfwin, filenames, linenumber);
	bmark_reload(firstbfwin);
#ifndef NOSPLASH
	splash_screen_set_label(_("showing main gui..."));
#endif /* #ifndef NOSPLASH */

	/* set GTK settings, must be AFTER the menu is created */
	{
		gchar *shortcutfilename;
		GtkSettings* gtksettings = gtk_settings_get_default();
		g_object_set(G_OBJECT(gtksettings), "gtk-can-change-accels", TRUE, NULL); 
		shortcutfilename = g_strconcat(g_get_home_dir(), "/.winefish/menudump_2", NULL);
		gtk_accel_map_load(shortcutfilename);
		g_free(shortcutfilename);
	}

	gui_show_main(firstbfwin);
	/*
	if (main_v->props.view_html_toolbar && main_v->globses.quickbar_items == NULL) {
		info_dialog(firstbfwin->main_window, _("Winefish tip:"), _("This message is shown since you DONOT have any items in the QuickBar.\n\nIf you right-click a button in the Standard toolbars you can add buttons to the Quickbar."));
	}
	*/
	if (projectfiles) {
		GList *tmplist = g_list_first(projectfiles);
		while (tmplist) {
			project_open_from_file(firstbfwin, tmplist->data, linenumber);
			tmplist = g_list_next(tmplist);
		}
	}

#ifndef NOSPLASH
	DEBUG_MSG("destroy splash\n");
	flush_queue();
	{
		static struct timespec const req = { 0, 10000000};
		nanosleep(&req, NULL);
	}
	gtk_widget_destroy(splash_window);
#endif /* #ifndef NOSPLASH */

	/* snooper must be installed after the main gui has shown;
	otherwise the program may be aborted */
#ifndef SNOOPER2
	snooper_install();
#endif /* SNOOPER2 */

	DEBUG_MSG("main, before gtk_main()\n");
	gtk_main();
	DEBUG_MSG("main, after gtk_main()\n");
#ifdef WITH_MSG_QUEUE	
	/* do the cleanup */
	msg_queue_cleanup();
#endif /* WITH_MSG_QUEUE */
	DEBUG_MSG("Winefish: exiting cleanly\n");
	return 0;
}
/* This is just an example task. Replace it with your code.
 * NOTE: your code will test others' library code. If YOUR test segfaults,
 * that will be bad for YOU. So program defensively.
 * 
 * Provide a short description of your task here:
 * 
 */
void standalone_speedtask(void *heap) {
  int i;
  void *ptrs[ITERS_LARGE];
  void *ptrs_two[ITERS_LARGE];
  void *ptrs_three[ITERS_LARGE];
  
  if (!hl_init(heap, HEAP_SIZE))
	  return;

  for (i = 0; i < ITERS_LARGE; i++) {
	  ptrs[i] = hl_alloc(heap, REQ_SIZE1);
  }
  
  for (i = 0; i < ITERS_LARGE; i++) {
	  if (ptrs[i])
		  ptrs[i] = hl_resize(heap, ptrs[i], REQ_SIZE2);
  }
  
  for (i = 1; i < ITERS_LARGE; i+=2) {
	  if (ptrs[i])
		  hl_release(heap, ptrs[i]);
  }

  //Create another heap right after this first one and run the same tests
  
  if (!hl_init((char*)heap + HEAP_SIZE, HEAP_SIZE))
    return;

  for (i = 0; i < ITERS_SMALL; i++) {
    ptrs_two[i] = hl_alloc(heap, REQ_SIZE1);
  }

  for (i = 0; i < ITERS_SMALL; i++) {
    if (ptrs_two[i])
      ptrs_two[i] = hl_resize(heap, ptrs_two[i], REQ_SIZE2);
  }
  
  for (i = 1; i < ITERS_SMALL; i+=2) {
    if (ptrs_two[i])
      hl_release(heap, ptrs_two[i]);
  }
  //Once again, but with medium size
  if (!hl_init((char*)heap + HEAP_SIZE, HEAP_SIZE))
    return;

  for (i = 0; i < ITERS_MEDIUM; i++) {
    ptrs_three[i] = hl_alloc(heap, REQ_SIZE1);
  }

  for (i = 0; i < ITERS_MEDIUM; i++) {
    if (ptrs_three[i])
      ptrs_three[i] = hl_resize(heap, ptrs_three[i], REQ_SIZE2);
  }
  
  for (i = 1; i < ITERS_MEDIUM; i+=2) {
    if (ptrs_three[i])
      hl_release(heap, ptrs_three[i]);
  }
  
  
}