Пример #1
0
static
int max_mem_node(void)
{
	DIR *ndir;
	struct dirent *dent;
	int maxmemnode = 0;

	ndir = opendir("/sys/devices/system/node");
	if (!ndir)
		return 0;

	while ((dent = readdir(ndir))) {
		if (str_cmpn(dent->d_name, "node", 4))
			continue;

		int node;
		sscanf(dent->d_name+4, "%d", &node);

		if (maxmemnode < node)
			maxmemnode = node;
	}

	closedir(ndir);

	return maxmemnode;
}
Пример #2
0
void rtti_pointer_decode(const rtti_t *type, const char **buf, void *data)
{
	const rtti_t *ptype = type->args[0].v;
	void *pdata;

	CHECK_TYPE(POINTER);

	if (str_cmpn(*buf, "null", 4) == 0) {
		pdata = NULL;
		*buf += 4;
	}

	else {
		pdata = malloc(ptype->size);
		ptype->decode(ptype, buf, pdata);
		error_do return;
	}

	CAST(void *, data) = pdata;
}
Пример #3
0
void rtti_flist64_decode(const rtti_t *type, const char **buf, void *data)
{
	const flist64_t *list = type->args[0].v;
	flag64_t *flag64 = data;
	const char *delim = type->args[1].s;
	char clmod = (char)type->args[2].i;

	SKIP_SPACE(buf);

	flag64->flag = flag64->mask = 0;

	if (str_cmpn(*buf, "null", 4) == 0) {
		*buf += 4;
		return;
	}

	char *sbuf = rtti_string_parse(buf);
	error_do return;

	if (flist64_decode(sbuf, list, flag64, clmod, delim) == -1) {
		error_set(errno, "failed to decode flist64");
		return;
	}
}