Пример #1
0
struct bt_ctf_clock *bt_ctf_clock_create(const char *name)
{
	int ret;
	struct bt_ctf_clock *clock = NULL;

	clock = _bt_ctf_clock_create();
	if (!clock) {
		goto error;
	}

	ret = bt_ctf_clock_set_name(clock, name);
	if (ret) {
		goto error;
	}

	ret = bt_uuid_generate(clock->uuid);
	if (ret) {
		goto error;
	}

	clock->uuid_set = 1;
	return clock;
error:
	BT_PUT(clock);
	return clock;
}
Пример #2
0
struct bt_ctf_clock *bt_ctf_clock_create(const char *name)
{
    int ret;
    struct bt_ctf_clock *clock = NULL;

    clock = _bt_ctf_clock_create();
    if (!clock) {
        goto error;
    }

    ret = bt_ctf_clock_set_name(clock, name);
    if (ret) {
        goto error;
    }

    ret = bt_uuid_generate(clock->uuid);
    if (ret) {
        goto error;
    }

    /*
     * For backward compatibility reasons, a fresh clock can have
     * a value because it could be added to a trace created by a
     * CTF writer. As soon as this clock is added to a non-writer
     * trace, then its value/time functions will be disabled.
     */
    clock->has_value = 1;
    clock->uuid_set = 1;
    return clock;
error:
    BT_PUT(clock);
    return clock;
}
Пример #3
0
struct bt_ctf_clock *bt_ctf_clock_create(const char *name)
{
	int ret;
	struct bt_ctf_clock *clock = NULL;
	unsigned char cc_uuid[BABELTRACE_UUID_LEN];

	BT_ASSERT_PRE_NON_NULL(name, "Name");
	clock = g_new0(struct bt_ctf_clock, 1);
	if (!clock) {
		goto error;
	}

	bt_ctf_object_init_shared(&clock->base, bt_ctf_clock_destroy);
	clock->value = 0;

	/* Pre-2.0.0 backward compatibility: default frequency is 1 GHz */
	clock->clock_class = (void *) bt_ctf_clock_class_create(name, 1000000000);
	if (!clock->clock_class) {
		goto error;
	}

	/* Automatically set clock class's UUID. */
	ret = bt_uuid_generate(cc_uuid);
	if (ret) {
		goto error;
	}

	ret = bt_ctf_clock_class_set_uuid(clock->clock_class, cc_uuid);
	BT_ASSERT(ret == 0);
	return clock;

error:
	BT_CTF_OBJECT_PUT_REF_AND_RESET(clock);
	return clock;
}
Пример #4
0
int main(int argc, char **argv)
{
	int fd, metadata_fd, ret;
	DIR *dir;
	int dir_fd;
	FILE *metadata_fp;

	ret = parse_args(argc, argv);
	if (ret) {
		fprintf(stderr, "Error: invalid argument.\n");
		usage(stderr);
		goto error;
	}

	if (s_help) {
		usage(stdout);
		exit(EXIT_SUCCESS);
	}

	ret = g_mkdir(s_outputname, S_IRWXU|S_IRWXG);
	if (ret) {
		perror("g_mkdir");
		goto error;
	}

	dir = opendir(s_outputname);
	if (!dir) {
		perror("opendir");
		goto error_rmdir;
	}
	dir_fd = bt_dirfd(dir);
	if (dir_fd < 0) {
		perror("dirfd");
		goto error_closedir;
	}

	fd = openat(dir_fd, "datastream", O_RDWR|O_CREAT,
		    S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
	if (fd < 0) {
		perror("openat");
		goto error_closedirfd;
	}

	metadata_fd = openat(dir_fd, "metadata", O_RDWR|O_CREAT,
			     S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
	if (metadata_fd < 0) {
		perror("openat");
		goto error_closedatastream;
	}
	metadata_fp = fdopen(metadata_fd, "w");
	if (!metadata_fp) {
		perror("fdopen");
		goto error_closemetadatafd;
	}

	bt_uuid_generate(s_uuid);
	print_metadata(metadata_fp);
	trace_text(stdin, fd);

	ret = close(fd);
	if (ret)
		perror("close");
	exit(EXIT_SUCCESS);

	/* error handling */
error_closemetadatafd:
	ret = close(metadata_fd);
	if (ret)
		perror("close");
error_closedatastream:
	ret = close(fd);
	if (ret)
		perror("close");
error_closedirfd:
	ret = close(dir_fd);
	if (ret)
		perror("close");
error_closedir:
	ret = closedir(dir);
	if (ret)
		perror("closedir");
error_rmdir:
	ret = rmdir(s_outputname);
	if (ret)
		perror("rmdir");
error:
	exit(EXIT_FAILURE);
}