Exemplo n.º 1
0
static bool gl_write_type_n(struct gl_shader_parser *glsp,
		const char *type, size_t len)
{
	if (cmp_type(type, len, "float2", 6) == 0)
		dstr_cat(&glsp->gl_string, "vec2");
	else if (cmp_type(type, len, "float3", 6) == 0)
		dstr_cat(&glsp->gl_string, "vec3");
	else if (cmp_type(type, len, "float4", 6) == 0)
		dstr_cat(&glsp->gl_string, "vec4");
	else if (cmp_type(type, len, "float3x3", 8) == 0)
		dstr_cat(&glsp->gl_string, "mat3x3");
	else if (cmp_type(type, len, "float3x4", 8) == 0)
		dstr_cat(&glsp->gl_string, "mat3x4");
	else if (cmp_type(type, len, "float4x4", 8) == 0)
		dstr_cat(&glsp->gl_string, "mat4x4");
	else if (cmp_type(type, len, "texture2d", 9) == 0)
		dstr_cat(&glsp->gl_string, "sampler2D");
	else if (cmp_type(type, len, "texture3d", 9) == 0)
		dstr_cat(&glsp->gl_string, "sampler3D");
	else if (cmp_type(type, len, "texture_cube", 12) == 0)
		dstr_cat(&glsp->gl_string, "samplerCube");
	else
		return false;

	return true;
}
Exemplo n.º 2
0
int main()
{
    unsigned num_cols = 1000;
    unsigned num_rows = 500;

    // buffers for streamify and materialize,
    // block size matches the block size of the input/output vector
    size_t numbuffers = 2 * foxxll::config::get_instance()->disks_number();

    // RAM to be used for sorting (in bytes)
    size_t memory_for_sorting = 1 << 28;

    ///////////////////////////////////////////////////////////////////////

    using array_type = stxxl::vector<unsigned>;

    array_type input(num_rows* num_cols);
    array_type output(num_cols* num_rows);

    // fill the input array with some values
    for (unsigned i = 0; i < num_rows * num_cols; ++i)
        input[i] = i;

    std::cout << "Before transpose:" << std::endl;
    dump_upper_left(input, num_rows, num_cols, 10, 10);

    foxxll::stats_data stats_before(*foxxll::stats::get_instance());

    // HERE streaming part begins (streamifying)
    // create input stream
    using input_stream_type = stxxl::stream::streamify_traits<array_type::iterator>::stream_type;
    input_stream_type input_stream = stxxl::stream::streamify(input.begin(), input.end(), numbuffers);

    // create stream of destination indices
    using destination_index_stream_type = streamop_matrix_transpose;
    destination_index_stream_type destination_index_stream(num_cols, num_rows);

    // create tuple stream: (key, value)
    using tuple_stream_type = stxxl::stream::make_tuplestream<destination_index_stream_type, input_stream_type>;
    tuple_stream_type tuple_stream(destination_index_stream, input_stream);

    // sort tuples by first entry (key)
    using cmp_type = cmp_tuple_first<tuple_stream_type::value_type>;
    using sorted_tuple_stream_type = stxxl::stream::sort<tuple_stream_type, cmp_type>;
    sorted_tuple_stream_type sorted_tuple_stream(tuple_stream, cmp_type(), memory_for_sorting);

    // discard the key we used for sorting, keep second entry of the tuple only (value)
    using sorted_element_stream_type = stxxl::stream::choose<sorted_tuple_stream_type, 1>;
    sorted_element_stream_type sorted_element_stream(sorted_tuple_stream);

    // HERE streaming part ends (materializing)
    array_type::iterator o = stxxl::stream::materialize(sorted_element_stream, output.begin(), output.end(), numbuffers);
    die_unless(o == output.end());
    die_unless(sorted_element_stream.empty());

    foxxll::stats_data stats_after(*foxxll::stats::get_instance());

    std::cout << "After transpose:" << std::endl;
    dump_upper_left(output, num_cols, num_rows, 10, 10);

    std::cout << "I/O stats (streaming part only!)" << std::endl << (stats_after - stats_before);

    return 0;
}
Exemplo n.º 3
0
/* check filesystem against extra mtree data if available,
 * NOT guaranteed to catch db/filesystem discrepencies */
static int check_file_properties(alpm_pkg_t *pkg)
{
	char path[PATH_MAX], *rel;
	int ret = 0;
	size_t space;
	struct archive *mtree = alpm_pkg_mtree_open(pkg);
	struct archive_entry *entry;

	if(!mtree) {
		pu_ui_warn("%s: mtree data not available (%s)",
				alpm_pkg_get_name(pkg), strerror(errno));
		return require_mtree;
	}

	strncpy(path, alpm_option_get_root(handle), PATH_MAX);
	rel = path + strlen(path);
	space = PATH_MAX - (rel - path);

	while(alpm_pkg_mtree_next(pkg, mtree, &entry) == ARCHIVE_OK) {
		const char *ppath = archive_entry_pathname(entry);
		const char *fpath;
		struct stat buf;

		if(strncmp("./", ppath, 2) == 0) { ppath += 2; }

		if(strcmp(ppath, ".INSTALL") == 0) {
			if((fpath = get_db_path(pkg, "install")) == NULL) {
				continue;
			}
		} else if(strcmp(ppath, ".CHANGELOG") == 0) {
			if((fpath = get_db_path(pkg, "changelog")) == NULL) {
				continue;
			}
		} else if(ppath[0] == '.') {
			continue;
		} else if(skip_noextract && match_noextract(handle, ppath)) {
			continue;
		} else {
			strncpy(rel, ppath, space);
			fpath = path;
		}

		if(lstat(fpath, &buf) != 0) {
			if(errno == ENOENT) {
				eprintf("%s: '%s' missing file\n", alpm_pkg_get_name(pkg), fpath);
			} else {
				pu_ui_warn("%s: '%s' read error (%s)",
						alpm_pkg_get_name(pkg), fpath, strerror(errno));
			}
			ret = 1;
			continue;
		}

		if(cmp_type(pkg, fpath, entry, &buf) != 0) { ret = 1; }

		if(skip_noupgrade && match_noupgrade(handle, ppath)) { continue; }

		if(cmp_mode(pkg, fpath, entry, &buf) != 0) { ret = 1; }
		if(cmp_uid(pkg, fpath, entry, &buf) != 0) { ret = 1; }
		if(cmp_gid(pkg, fpath, entry, &buf) != 0) { ret = 1; }

		if(skip_backups && match_backup(pkg, ppath)) {
			continue;
		}

		if(S_ISLNK(buf.st_mode) && S_ISLNK(archive_entry_mode(entry))) {
			if(cmp_target(pkg, fpath, entry) != 0) { ret = 1; }
		}
		if(!S_ISDIR(buf.st_mode)) {
			if(cmp_mtime(pkg, fpath, entry, &buf) != 0) { ret = 1; }
			if(!S_ISLNK(buf.st_mode)) {
				/* always fails for directories and symlinks */
				if(cmp_size(pkg, fpath, entry, &buf) != 0) { ret = 1; }
			}
		}
	}
	alpm_pkg_mtree_close(pkg, mtree);

	if(!quiet && !ret) {
		eprintf("%s: all files match mtree\n", alpm_pkg_get_name(pkg));
	}

	return ret;
}