コード例 #1
0
ファイル: stdext_test.c プロジェクト: rgmabs19357/fzsvn
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	switch (_g_type) {

	case TEST_STRING:
		_test_string();
		break;

	case TEST_DIR:
		_test_dir();

	default:
		break;

	}

	_release();

	return 0;
}
コード例 #2
0
ファイル: filedes_limit.c プロジェクト: rgmabs19357/fzsvn
int main(int argc, char **argv)
{
	int fd;
	int i = 0;

	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	_init();

	while (1) {
		fd = open(TMPFILE, O_RDONLY);
		if (fd < 0) {
			printf("open error: %s\n", strerror(errno));
			break;
		}
		else {
			printf("the fd is %d\n", fd);
		}
		i++;
	}

	printf("open %d file descriptor in one process, fd is %d\n", i, fd);

	return 0;
}
コード例 #3
0
ファイル: saxtest.c プロジェクト: rgmabs19357/fzsvn
int main(int argc, char **argv)
{
	xmlSAXHandler handler;
	int fd;
	int mid;

	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_init())
		return -1;

	memset(&handler, 0, sizeof(xmlSAXHandler));

	handler.startElement = _element_start;
	handler.endElement = _element_end;
	handler.error = _element_error;

	if (xmlSAXUserParseMemory(&handler, NULL, g_buffer, g_buflen) < 0) {
		printf("SAX parser error 1\n");
	}

	xmlCleanupParser();

	_release();

	return 0;
}
コード例 #4
0
ファイル: main.c プロジェクト: rgmabs19357/fzsvn
/**
 *	main function of program.
 *
 *	Return 0 if success, -1 on error. 
 */
int 
main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate())
		return -1;

	if (cfg_load_file(_s_proxy, _s_cfgfile)) {
		_release();
		ERR_RET(-1, "parse config file %s failed\n", _s_cfgfile);
	}

	if (_s_vrycfg)	
		proxy_print(_s_proxy);		
	else 
		proxy_main(_s_proxy);

	_release();

	return 0;
}
コード例 #5
0
ファイル: static_o2_test.c プロジェクト: rgmabs19357/fzsvn
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	int i = 0;
	int j = 0;

	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	alarm(1);
	while(1) {
		if (_g_count > 2)
			break;
		i++;
	}
	
	j = i;
	printf("j is %d\n", j);

	_release();

	return 0;
}
コード例 #6
0
ファイル: sem_mutex_test.c プロジェクト: rgmabs19357/fzsvn
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	printf("current pid is %d\n", getpid());

	if (_g_perf) {
		_sem_mutex_perf();
		return 0;
	}

	if (_g_op & SEM_OP_CREATE) {
		if (sem_mutex_create(_g_key))
			return -1;
		if (_g_verbose)
			sem_mutex_print(_g_key);
	}

	if (_g_op & SEM_OP_LOCK) {
		if (sem_mutex_lock(_g_key))
			return -1;

		if (_g_verbose)
			sem_mutex_print(_g_key);

	}
	
	if (_g_op & SEM_OP_UNLOCK) {
		if (sem_mutex_unlock(_g_key))
			return -1;

		if (_g_verbose)
			sem_mutex_print(_g_key);

//		_crash();
	}

	if (_g_op & SEM_OP_DESTROY) {
		if (sem_mutex_destroy(_g_key))
			return -1;
	}

	if (_g_verbose)
		if (sem_mutex_print(_g_key))
			return -1;

	_release();

	return 0;
}
コード例 #7
0
ファイル: main.c プロジェクト: rgmabs19357/fzsvn
int main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	proxy_main(&_g_arg);

	return 0;
}
コード例 #8
0
ファイル: sqlite_perf.c プロジェクト: rgmabs19357/fzsvn
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	_release();

	return 0;
}
コード例 #9
0
ファイル: client.c プロジェクト: HPCNow/slurm
extern client_req_t *
client_req_init(uint32_t len, char *buf)
{
	client_req_t *req = NULL;

	/* buf always '\0' terminated */
	req = xmalloc(sizeof(client_req_t));
	req->buf = buf;
	req->buf_len = len;
	req->parse_idx = 0;

	if (_parse_cmd(req) != SLURM_SUCCESS) {
		xfree(req);
	}

	return req;
}
コード例 #10
0
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	int i;
	struct timeval tv1, tv2;
	unsigned long sec, usec;


	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	gettimeofday(&tv1, NULL);

	for (i = 0; i < _g_count; i++) {
		_g_pid = getpid();
	}

	gettimeofday(&tv2, NULL);

	if (tv2.tv_usec >= tv1.tv_usec) {
		usec = tv2.tv_usec - tv1.tv_usec;
	}
	else {
		usec = 1000000 + tv2.tv_usec - tv1.tv_usec;
		tv2.tv_sec--;
	}
	
	sec = tv2.tv_sec - tv1.tv_sec;

	printf("glibc syscall %d times spend %lu sec %lu usec\n",
	       _g_count, sec, usec);
	
	

	_release();

	return 0;
}
コード例 #11
0
ファイル: signal_util.c プロジェクト: rgmabs19357/fzsvn
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	int i;
	sigval_t sv;

	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	for (i = 34; i < 64; i++) {
		sv.sival_int = i - 34;
		sigqueue(getpid(), i, sv);		
	}

	_release();

	return 0;
}
コード例 #12
0
ファイル: tree_test.c プロジェクト: rgmabs19357/fzsvn
int main(int argc, char **argv)
{
	tree_t *tree = NULL;
	treenode_t *node = NULL;
	person_t *person = NULL;

	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_init())
		return -1;

	tree = tree_alloc(NULL, person_find, person_print, 
			person_free, 0x1234);

	person = malloc(sizeof(person_t));
	if (!person)
		goto out_free;
	
	strncpy(person->name, "fz", NAMELEN - 1);
	person->age = 33;
	tree_add_end(tree, NULL, person);

	node = tree_find(tree, person);
	if (node) {
		printf("find (%s:%d) in tree\n", person->name, person->age);
		person = malloc(sizeof(person_t));
		if (!person)
			goto out_free;
		strncpy(person->name, "forrest", NAMELEN -1);
		person->age = 11;

		tree_add_first(tree, node, person);
	
		person = malloc(sizeof(person_t));
		if (!person)
			goto out_free;
		strncpy(person->name, "bug", NAMELEN -1);
		person->age = 13;

		tree_add_end(tree, node, person);
	}

	tree_print(tree);

	person = malloc(sizeof(person_t));
	if (!person)
		goto out_free;
	strncpy(person->name, "fz", NAMELEN -1);
	person->age = 33;
	node = tree_find(tree, person);
	if (node) {
		printf("find (%s:%d) in tree\n", person->name, person->age);
	}
	tree_del(tree, person);
	free(person);

	tree_print(tree);

out_free:
	tree_free(tree);

	_release();
	
	return 0;
}
コード例 #13
0
ファイル: cmd.c プロジェクト: open-cpu/pslse
// See if a command was sent by AFU and process if so
void handle_cmd(struct cmd *cmd, uint32_t parity_enabled, uint32_t latency)
{
	struct cmd_event *event;
	uint64_t address, address_parity;
	uint32_t command, command_parity, tag, tag_parity, size, abort, handle;
	uint8_t parity, fail;
	int rc;

	if (cmd == NULL)
		return;

	// Check for command from AFU
	rc = psl_get_command(cmd->afu_event, &command, &command_parity, &tag,
			     &tag_parity, &address, &address_parity, &size,
			     &abort, &handle);

	// No command ready
	if (rc != PSL_SUCCESS)
		return;

	debug_msg
	    ("%s:COMMAND tag=0x%02x code=0x%04x size=0x%02x abt=%d cch=0x%04x",
	     cmd->afu_name, tag, command, size, abort, handle);
	debug_msg("%s:COMMAND tag=0x%02x addr=0x%016" PRIx64, cmd->afu_name,
		  tag, address);

	// Is AFU running?
	if (*(cmd->psl_state) != PSLSE_RUNNING) {
		warn_msg("Command without jrunning, tag=0x%02x", tag);
		return;
	}
	// Check parity
	fail = 0;
	if (parity_enabled) {
		parity = generate_parity(address, ODD_PARITY);
		if (parity != address_parity) {
			_cmd_parity_error("address", (uint64_t) address,
					  address_parity);
			fail = 1;
		}
		parity = generate_parity(tag, ODD_PARITY);
		if (parity != tag_parity) {
			_cmd_parity_error("tag", (uint64_t) tag, tag_parity);
			fail = 1;
		}
		parity = generate_parity(command, ODD_PARITY);
		if (parity != command_parity) {
			_cmd_parity_error("code", (uint64_t) command,
					  command_parity);
			fail = 1;
		}
	}
	// Add failed command
	if (fail) {
		_add_other(cmd, handle, tag, command, abort,
			   PSL_RESPONSE_FAILED);
		return;
	}
	// Check credits and parse
	if (!cmd->credits) {
		warn_msg("AFU issued command without any credits");
		_add_other(cmd, handle, tag, command, abort,
			   PSL_RESPONSE_FAILED);
		return;
	}

	cmd->credits--;

	// Client not connected
	if ((cmd == NULL) || (cmd->client == NULL) ||
	    (handle >= cmd->max_clients) || ((cmd->client[handle]) == NULL)) {
		_add_other(cmd, handle, tag, command, abort,
			   PSL_RESPONSE_FAILED);
		return;
	}
	// Client is flushing new commands
	if ((cmd->client[handle]->flushing == FLUSH_FLUSHING) &&
	    (command != PSL_COMMAND_RESTART)) {
		_add_other(cmd, handle, tag, command, abort,
			   PSL_RESPONSE_FLUSHED);
		return;
	}
	// Check for duplicate tag
	event = cmd->list;
	while (event != NULL) {
		if (event->tag == tag) {
			error_msg("Duplicate tag 0x%02x", tag);
			return;
		}
		event = event->_next;
	}

	// Parse command
	_parse_cmd(cmd, command, tag, address, size, abort, handle, latency);
}