Пример #1
0
/** Initialize a wait queue
    @param[in] wq  wait queue
 */
void 
wque_init_wait_queue(wait_queue *wq) {
	psw_t psw;

	psw_disable_and_save_interrupt(&psw);
	init_list_head(&wq->head);
	wq->reason = WQUE_REASON_WAKEUP;
	psw_restore_interrupt(&psw);
}
Пример #2
0
/** レディーキューを初期化する
    @param[in] que レディーキュー管理情報
 */
void
rdq_init_ready_queue(void) {
	int                                 i;
	thread_ready_queue_t *rdq = &rd_queue;

	rdq->bitmap = 0;  /*< 動作可能なスレッドがない状態なので0に設定する  */
	for(i = 0; i < RDQ_PRIORITY_MAX; ++i)
		init_list_head(&rdq->head[i]);  /*< 各優先度のキューを初期化する  */
}
Пример #3
0
void append_data(struct result *result_ptr, char *data, int size)
{
	if (result_ptr == NULL || data == NULL) {
		return;
	}
	if (result_ptr->lines == NULL) {
		result_ptr->lines = (struct line *) malloc(sizeof(struct line));
		if (result_ptr->lines == NULL) {
			fprintf(stderr, "malloc struct line list head failed!\n");
			exit(1);
		}
		init_list_head(&result_ptr->lines->list_node);
	}
	int i;
	int line_begin = 0;
	int line_len;
	for (i=0; i<size; i++) {
		if (data[i] == '\n') {
			line_len = i - line_begin + 1;
			if (result_ptr->last_line_completed) {
				char *content = (char *) malloc(line_len+1);
				if (content == NULL) {
					fprintf(stderr, "malloc line content failed!\n");
					exit(1);
				}
				strncpy(content, &data[line_begin], line_len);
				content[line_len] = '\0';
				struct line *line_ptr = (struct line *) malloc(sizeof(struct line *));
				if (line_ptr == NULL) {
					fprintf(stderr, "malloc struct line failed!\n");
					exit(1);
				}
				line_ptr->content = content;
				list_add_tail(&line_ptr->list_node, &result_ptr->lines->list_node);
			} else {
				struct list_head *head = &result_ptr->lines->list_node;
				struct list_head *last_node_ptr = head->prev;
				struct line *last_line_ptr = list_entry(last_node_ptr, struct line, list_node);
				int length = strlen(last_line_ptr->content) + line_len;
				char *content = (char *) malloc(length+1);
				if (content == NULL) {
					fprintf(stderr, "malloc line content failed!\n");
					exit(1);
				}
				strcpy(content, last_line_ptr->content);
				strncat(content, &data[line_begin], line_len);
				free(last_line_ptr->content);
				last_line_ptr->content = content;
			}
			result_ptr->last_line_completed = TRUE;
			line_begin = i + 1;
		}
	}
Пример #4
0
BOOL CCardFieldDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	init_list_head();
	if(load_card_right_json())
	{
		EndDialog(IDCANCEL);
		return FALSE;
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Пример #5
0
static struct nurs_plugin *
producer_create(struct nurs_plugin_def *defbase, const char *id)
{
	struct nurs_producer_def *def
		= (struct nurs_producer_def *)defbase;
	struct nurs_producer *pl;
	pthread_mutexattr_t attr; /* = {{0}}; */
	memset(&attr, 0, sizeof(pthread_mutexattr_t));

	pl = calloc(1, sizeof(struct nurs_producer) + def->context_size);
	if (pl == NULL) {
		nurs_log(NURS_ERROR, "failed to calloc: %s\n", strerror(errno));
		return NULL;
	}

	init_list_head(&pl->iosets);
	pthread_mutexattr_init(&attr);
	pthread_mutexattr_settype(&attr, NURS_MUTEX_ATTR);
	pthread_mutex_init(&pl->iosets_mutex, &attr);
	pthread_cond_init(&pl->iosets_condv, NULL);
	init_list_head(&pl->stacks);

	return (struct nurs_plugin *)pl;
}
Пример #6
0
Файл: conf.c Проект: noushi/bmon
tv_t * parse_tv(char *data)
{
	char *value;
	tv_t *tv = xcalloc(1, sizeof(tv_t));

	init_list_head(&tv->tv_list);

	value = strchr(data, '=');

	if (value) {
		*value = '\0';
		++value;
		tv->tv_value = strdup(value);
	}

	tv->tv_type = strdup(data);
	return tv;
}
Пример #7
0
static
struct p7_coro *p7_coro_new_(void (*entry)(void *), void *arg, size_t stack_size, unsigned carrier_id, struct p7_limbo *limbo) {
    struct p7_coro *coro = NULL;
    struct p7_coro_cntx *cntx = p7_coro_cntx_new_(entry, arg, stack_size, limbo);
    if (cntx != NULL) {
        __auto_type allocator = p7_root_alloc_get_proxy();
        coro = scraft_allocate(allocator, (sizeof(struct p7_coro)));
        if (coro != NULL) {
            (coro->carrier_id = carrier_id), (coro->cntx = cntx), (coro->following = NULL);
            (coro->func_info.entry = entry), (coro->func_info.arg = arg);
            coro->timedout = coro->resched = 0;
            coro->status = P7_CORO_STATUS_ALIVE;
            coro->decay = 0;
            coro->trapper = NULL;
            coro->fd_waiting = -1;
            coro->cleanup_info.arg = NULL;
            coro->cleanup_info.cleanup = NULL;
            (coro->mailbox_cleanup = NULL), (coro->mailbox_cleanup_arg = NULL);
            init_list_head(&(coro->mailbox));
        }
    }
    return coro;
}
Пример #8
0
Файл: conf.c Проект: noushi/bmon
module_conf_t * parse_module(char *data)
{
	char *name = data, *opts = data, *next;
	module_conf_t *m;

	if (!*name)
		quit("No module name given");

	m = xcalloc(1, sizeof(module_conf_t));

	init_list_head(&m->m_attrs);

	opts = strchr(data, ':');

	if (opts) {
		*opts = '\0';
		opts++;

		do {
			tv_t *tv;
			next = strchr(opts, ';');

			if (next) {
				*next = '\0';
				++next;
			}

			tv = parse_tv(opts);
			list_add_tail(&tv->tv_list, &m->m_attrs);

			opts = next;
		} while(next);
	}

	m->m_name = strdup(name);
	return m;
}
Пример #9
0
int main(int argc, char *argv[])
{
    char config_path[MAX_PATH];
    memset(config_path,0,MAX_PATH);

    /* Setup all the initial function pointers */
    my_ops.getattr = do_getattr;
    my_ops.read = do_read;
    my_ops.write = do_write;
    my_ops.readdir = do_readdir;
    my_ops.truncate = do_truncate;
    my_ops.mknod = do_mknod;
    my_ops.unlink = do_unlink;
    my_ops.rename = do_rename;
    my_ops.symlink = do_symlink;
    my_ops.readlink = do_readlink;
    my_ops.mkdir = do_mkdir;
    my_ops.rmdir = do_rmdir;
    my_ops.open = do_open;
    my_ops.release = do_release;
    my_ops.utime = do_utime;
    my_ops.chmod = do_chmod;
    my_ops.link = do_link;
    my_ops.flush = do_flush;
    my_ops.access = do_access;
    my_ops.destroy = do_destroy;
#ifdef HAVE_SETXATTR
    my_ops.setxattr = do_setxattr;
    my_ops.getxattr = do_getxattr;
    my_ops.listxattr = do_listxattr;
    my_ops.removexattr = do_removexattr;
#endif

    /* Check with corefs_op_init if we need to replace any of the pointers */
    client_op_init(&my_ops);

    /* Call the upper layer's init function */
    if(up_client_init(&my_ops) != PROCEED){
        fprintf(stderr, "ERROR: up_client_init failed, proceeding to load corefs...\n");
    }
    
    /* set the local path to $HOME/.corefs */
    local_path = calloc(LOCALSIZE,1);
    sprintf(local_path, "%s/.corefs",getenv("HOME"));
    
    /* See if the local path exists and if there is a mnt directory in it.
       Create, if there isn't  */
    struct stat st;
    char dir_path[MAXPATH+LOCALSIZE];
    int stret = stat(local_path, &st);
    if (stret < 0) {
        if (mkdir(local_path, 0700)) {
            perror("Failed to create local .corefs directory");
            exit(1);
        }
    }
    memset(dir_path, 0, MAXPATH+LOCALSIZE);
    sprintf(dir_path, "%s/mnt", local_path);
    stret = stat(dir_path, &st);
    if (stret < 0) {
        if (mkdir(dir_path, 0700)) {
            perror("Failed to create local .corefs/mnt directory");
            exit(1);
        }
    }

    init_list_head(&head);
    
    /* Parse the command line args */
    parse_arguments(argc, argv, config_path);
    init_sizes();
    if(corefs_main(fuse_argc, fuse_argv, &my_ops) != 0){
        usage(argv[0]);
        return -1;
    }
    return 0;
  
}
Пример #10
0
struct list_head* new_list_head()
{
	struct list_head* list = (struct list_head*) malloc( sizeof( struct list_head ) );
	init_list_head( list );
	return list;
}
Пример #11
0
void init_line(struct line *line_ptr)
{
	line_ptr->content = NULL;
	init_list_head(&line_ptr->list_node);
}