Exemple #1
0
static void init_buffers()
{
	unsigned int i;

	page_zeros = malloc(page_size);
	if (!page_zeros)
		exit(EXIT_FAILURE);
	memset(page_zeros, 0, page_size);

	page_0xff = malloc(page_size);
	if (!page_0xff)
		exit(EXIT_FAILURE);
	memset(page_0xff, 0xff, page_size);

	page_rand = malloc(page_size);
	if (!page_rand)
		exit(EXIT_FAILURE);
	memset(page_rand, 0x55, page_size);	/* overwritten below */

	page_allocs = malloc(page_size);
	if (!page_allocs)
		exit(EXIT_FAILURE);
	memset(page_allocs, 0xff, page_size);

	for (i = 0; i < (page_size / sizeof(unsigned long *)); i++)
		page_allocs[i] = (unsigned long) malloc(page_size);

	setup_maps();

	// regenerate_random_page may end up using maps, so has to be last.
	regenerate_random_page();
}
Exemple #2
0
void regenerate(void)
{
	if (no_files == TRUE)	/* We don't regenerate sockets */
		return;

	/* we're about to exit. */
	if (shm->spawn_no_more)
		return;

	shm->regenerating = TRUE;

	sleep(1);	/* give children time to finish with fds. */

	shm->regenerate = 0;

	output(0, "Regenerating random pages, fd's etc.\n");

	regenerate_fds();

	/* Do random setsockopts on all network sockets. */
	do_sso_sockets();

	destroy_maps();
	setup_maps();

	generate_random_page(page_rand);

	shm->regenerating = FALSE;
}
Exemple #3
0
static void regenerate()
{
	if (!shm->regenerate) {
		output("[%d] Regenerating random pages, fd's etc.\n", getpid());
		close_files();
		open_files();

		destroy_maps();
		setup_maps();

		shm->regenerate = REGENERATION_POINT - 1;

		regenerate_random_page();
	}
}
Exemple #4
0
static void regenerate(void)
{
	if (no_files == TRUE)	/* We don't regenerate sockets */
		return;

	shm->regenerating = TRUE;

	sleep(1);	/* give children time to finish with fds. */

	shm->regenerate = 0;

	output(0, "[%d] Regenerating random pages, fd's etc.\n", getpid());

	regenerate_fds();

	destroy_maps();
	setup_maps();

	generate_random_page(page_rand);

	shm->regenerating = FALSE;
}
Exemple #5
0
void init_buffers(void)
{
	unsigned int i;

	output(2, "shm is at %p\n", shm);

	page_zeros = memalign(page_size, page_size * 2);
	if (!page_zeros)
		exit(EXIT_FAILURE);
	memset(page_zeros, 0, page_size);
	output(2, "page_zeros @ %p\n", page_zeros);

	page_0xff = memalign(page_size, page_size * 2);
	if (!page_0xff)
		exit(EXIT_FAILURE);
	memset(page_0xff, 0xff, page_size);
	output(2, "page_0xff @ %p\n", page_0xff);

	page_rand = memalign(page_size, page_size * 2);
	if (!page_rand)
		exit(EXIT_FAILURE);
	memset(page_rand, 0x55, page_size);	/* overwritten below */
	output(2, "page_rand @ %p\n", page_rand);

	page_allocs = memalign(page_size, page_size * 2);
	if (!page_allocs)
		exit(EXIT_FAILURE);
	memset(page_allocs, 0xff, page_size);
	output(2, "page_allocs @ %p\n", page_allocs);

	for (i = 0; i < (page_size / sizeof(unsigned long *)); i++)
		page_allocs[i] = (unsigned long) malloc(page_size);

	setup_maps();

	// generate_random_page may end up using maps, so has to be last.
	generate_random_page(page_rand);
}
Exemple #6
0
void execute(expr_list * ee)
{
    int verbose = isatty(2);
    expr_list *l;
    int count, n;

    setup_region();

    exprs = ee;
    G_add_error_handler(error_handler, NULL);

    for (l = ee; l; l = l->next) {
	expression *e = l->exp;
	const char *var;

	if (e->type != expr_type_binding && e->type != expr_type_function)
	    G_fatal_error("internal error: execute: invalid type: %d",
			  e->type);

	if (e->type != expr_type_binding)
	    continue;

	var = e->data.bind.var;

	if (!overwrite_flag && check_output_map(var))
	    G_fatal_error(_("output map <%s> exists. To overwrite, use the --overwrite flag"), var);
    }

    for (l = ee; l; l = l->next) {
	expression *e = l->exp;
	const char *var;
	expression *val;

	initialize(e);

	if (e->type != expr_type_binding)
	    continue;

	var = e->data.bind.var;
	val = e->data.bind.val;

	e->data.bind.fd = open_output_map(var, val->res_type);
    }

    setup_maps();

    count = rows * depths;
    n = 0;

    G_init_workers();

    for (current_depth = 0; current_depth < depths; current_depth++)
	for (current_row = 0; current_row < rows; current_row++) {
	    if (verbose)
		G_percent(n, count, 2);

	    for (l = ee; l; l = l->next) {
		expression *e = l->exp;
		int fd;

		evaluate(e);

		if (e->type != expr_type_binding)
		    continue;

		fd = e->data.bind.fd;
		put_map_row(fd, e->buf, e->res_type);
	    }

	    n++;
	}

    G_finish_workers();

    if (verbose)
	G_percent(n, count, 2);

    for (l = ee; l; l = l->next) {
	expression *e = l->exp;
	const char *var;
	expression *val;
	int fd;

	if (e->type != expr_type_binding)
	    continue;

	var = e->data.bind.var;
	val = e->data.bind.val;
	fd = e->data.bind.fd;

	close_output_map(fd);
	e->data.bind.fd = -1;

	if (val->type == expr_type_map) {
	    if (val->data.map.mod == 'M') {
		copy_cats(var, val->data.map.idx);
		copy_colors(var, val->data.map.idx);
	    }

	    copy_history(var, val->data.map.idx);
	}
	else
	    create_history(var, val);
    }

    G_unset_error_routine();
}
Exemple #7
0
int main(int argc, char **argv)
{
    int i, j, result = 0;

    // process flags for -v verbose, -t terminate, -h help
    for (i = 1; i < argc; i++) {
        if (argv[i] && argv[i][0] == '-') {
            int len = strlen(argv[i]);
            for (j = 1; j < len; j++) {
                switch (argv[i][j]) {
                    case 'h':
                        printf("testexpression.c: possible arguments "
                               "-q quiet (suppress output), "
                               "-t terminate automatically, "
                               "-h help\n");
                        return 1;
                        break;
                    case 'q':
                        verbose = 0;
                        break;
                    case 't':
                        terminate = 1;
                        break;
                    default:
                        break;
                }
            }
        }
    }

    signal(SIGINT, ctrlc);

    if (setup_destination()) {
        eprintf("Error initializing destination.\n");
        result = 1;
        goto done;
    }

    if (setup_source()) {
        eprintf("Done initializing source.\n");
        result = 1;
        goto done;
    }

    wait_ready();

    if (autoconnect && setup_maps()) {
        eprintf("Error setting map.\n");
        result = 1;
        goto done;
    }

    loop();

    if (sent != received) {
        eprintf("Not all sent messages were received.\n");
        eprintf("Updated value %d time%s, but received %d of them.\n",
                sent, sent == 1 ? "" : "s", received);
        result = 1;
    }

  done:
    cleanup_destination();
    cleanup_source();
    printf("Test %s.\n", result ? "FAILED" : "PASSED");
    return result;
}
ebml_chapters_converter_c::ebml_chapters_converter_c()
{
  setup_maps();
}
ebml_segmentinfo_converter_c::ebml_segmentinfo_converter_c()
{
  setup_maps();
}