Exemple #1
0
/*
 * Optimize the filter code in its dag representation.
 */
void
bpf_optimize(struct block **rootp)
{
	struct block *root;

	root = *rootp;

	opt_init(root);
	opt_loop(root, 0);
	opt_loop(root, 1);
	intern_blocks(root);
#ifdef BDEBUG
	if (dflag > 1) {
		printf("after intern_blocks()\n");
		opt_dump(root);
	}
#endif
	opt_root(rootp);
#ifdef BDEBUG
	if (dflag > 1) {
		printf("after opt_root()\n");
		opt_dump(root);
	}
#endif
	opt_cleanup();
}
Exemple #2
0
static void
opt_loop(struct block *root, int do_stmts)
{

#ifdef BDEBUG
	if (dflag > 1) {
		printf("opt_loop(root, %d) begin\n", do_stmts);
		opt_dump(root);
	}
#endif
	do {
		done = 1;
		find_levels(root);
		find_dom(root);
		find_closure(root);
		find_ud(root);
		find_edom(root);
		opt_blks(root, do_stmts);
#ifdef BDEBUG
		if (dflag > 1) {
			printf("opt_loop(root, %d) bottom, done=%d\n", do_stmts, done);
			opt_dump(root);
		}
#endif
	} while (!done);
}
Exemple #3
0
void	core(t_machine *vm, t_exec *begin, T_TEAM lampions, void *mem)
{
  int		cont;
  t_graph	*g;
  t_instruct	*ops;
  int		dec;

  cont = 1;
  dec = 1;
  ops = init_call();
  vm->cycle_to_die = CYCLE_TO_DIE;
  g = init(begin, lampions);
  g->lampions = lampions;
  while (begin && (vm->n_cycles < vm->dump || vm->dump == NO_DUMP) && cont)
    {
      g->vm = vm;
      gere_event(g, &cont, 0, dec);
      check_for_near(begin, &begin, vm->cycle_to_die);
      dec = call(begin, lampions, mem, ops);
      vm->last_live = last(lampions, vm->last_live);
      count_and_live(vm, begin);
      vm->n_cycles++;
    }
  if (cont)
    gere_event(g, &cont, 1, 0);
  if (vm->dump != NO_DUMP || !cont)
    opt_dump(mem);
}
Exemple #4
0
int main(int argc, char *argv[])
{
	const char client_name[] = "SteelSeries Sound Illuminator";
	const char *client_name_real;
	jack_status_t status;
	J2STL j2stl;
	int ret;

	/* Memory initialization */
	memset(&j2stl, 0, sizeof(j2stl));
	pthread_mutex_init(&j2stl.memsync.mutex, NULL);
	pthread_cond_init(&j2stl.memsync.cond, NULL);
	j2stl.status.progname = basename(argv[0]);

	/* Options parsing */
	opt_parse(argc, argv, &j2stl.status);
	if (j2stl.status.verbose)
		opt_dump(&j2stl.status);


	/* Stlseries init */
	if (stlseries_open(&j2stl.kbd.stlseries)) {
		fprintf(stderr, "Unable to open steelseries keyboard.\n");
		exit(EXIT_FAILURE);
	}

	/* Jack init */
	j2stl.jack.client = jack_client_open(client_name, JackNoStartServer,
					   &status, NULL);
	if (j2stl.jack.client == NULL) {
		fprintf(stderr, "Unable to create jack client, status = "
				"0x%2.0x<\n", status);
		if (status & JackServerFailed)
			fprintf(stderr, "Unable to establish a connection to "
					"the server\n");
		exit(EXIT_FAILURE);
	}
	if (status & JackNameNotUnique) {
		client_name_real = jack_get_client_name(j2stl.jack.client);
		fprintf(stderr, "Name assigned to the client: %s\n",
			client_name_real);
	} else {
		client_name_real = client_name;
		if (j2stl.status.verbose)
			fprintf(stderr, "Jack client name: %s\n",
				client_name_real);
	}

	/* Set jack callbacks */
	jack_set_process_callback(j2stl.jack.client, jack_process, &j2stl);
	jack_on_shutdown(j2stl.jack.client, jack_shutdown, NULL);

	/* Retrieve audio format from jack */
	j2stl.audio.sample_rate = jack_get_sample_rate(j2stl.jack.client);
	j2stl.audio.size = lrint((j2stl.status.sampling / 1000.0) *
				 j2stl.audio.sample_rate);
	j2stl.audio.data = malloc(sizeof(jack_default_audio_sample_t) *
				  j2stl.audio.size);
	if (j2stl.audio.data == NULL) {
		fprintf(stderr, "Unable to allocate memory for sound buffers: "
				"%s\n", strerror(errno));
		exit(EXIT_FAILURE);
	}
	if (j2stl.status.verbose)
		fprintf(stderr, "Jack sample rate: %u\n",
			j2stl.audio.sample_rate);

	/* jack: port creation */
	j2stl.jack.input_port = jack_port_register(j2stl.jack.client, "input",
					     JACK_DEFAULT_AUDIO_TYPE,
					     JackPortIsInput, 0);
	if (j2stl.jack.input_port == NULL) {
		fprintf(stderr, "No port available.\n");
		exit(EXIT_FAILURE);
	}

	/* Threads launch */
	if ((ret = pthread_create(&j2stl.status.fftw_thread, NULL,
				  fftw_thread, &j2stl))) {
		fprintf(stderr, "Unable to spawn fftw thread: %s\n",
			strerror(ret));
		exit(EXIT_FAILURE);
	}

	if (jack_activate(j2stl.jack.client) != 0) {
		fprintf(stderr, "Unable to activate client\n");
		exit(EXIT_FAILURE);
	}
	if (j2stl.status.verbose)
		fprintf(stderr, "Jack client thread launched\n");

	if (j2stl.status.timeout)
		sleep(j2stl.status.timeout);
	else
		for(;;);

	process_cleanup(&j2stl);

	return EXIT_SUCCESS;
}