int main(int argc, char *argv[])
{
	struct list_head list1, list2;
	struct list_node n1, n2, n3;
	pid_t child;
	int status;

	plan_tests(1);
	list_head_init(&list1);
	list_head_init(&list2);
	list_add(&list1, &n1);
	list_add(&list2, &n2);
	list_add_tail(&list2, &n3);

	child = fork();
	if (child) {
		wait(&status);
	} else {
		/* This should abort. */
		list_del_from(&list1, &n3);
		exit(0);
	}

	ok1(WIFSIGNALED(status) && WTERMSIG(status) == SIGABRT);
	list_del_from(&list2, &n3);
	return exit_status();
}
示例#2
0
/**
 * do initialization
 */
void
name_constructor(void) 
{
	int i;
	
#ifdef WIN32
	int len;

	GetWindowsDirectory(my_hosts_file, MAX_FILE - 12);
	GetWindowsDirectory(my_services_file, MAX_FILE - 12);
	GetWindowsDirectory(my_resolv_file, MAX_FILE - 12);

	len = strlen(my_hosts_file);
	if (my_hosts_file[len - 1] != '\\')
		strscat(my_hosts_file, "\\", sizeof(my_host_file));
	strscat(my_hosts_file, "hosts_olsr", sizeof(my_host_file));
	
	len = strlen(my_services_file);
	if (my_services_file[len - 1] != '\\')
		strscat(my_services_file, "\\", sizeof(my_services_file));
	strscat(my_services_file, "services_olsr", sizeof(my_services_file));

	len = strlen(my_resolv_file);
	if (my_resolv_file[len - 1] != '\\')
		strscat(my_resolv_file, "\\", sizeof(my_resolv_file));
	strscat(my_resolv_file, "resolvconf_olsr", sizeof(my_resolv_file));
#else
	strscpy(my_hosts_file, "/var/run/hosts_olsr", sizeof(my_hosts_file));
	strscpy(my_services_file, "/var/run/services_olsr", sizeof(my_services_file));
	strscpy(my_resolv_file, "/var/run/resolvconf_olsr", sizeof(my_resolv_file));
	*my_sighup_pid_file = 0;
#endif

	my_suffix[0] = '\0';
	my_add_hosts[0] = '\0';
	my_latlon_file[0] = '\0';
	latlon_in_file[0] = '\0';
	my_name_change_script[0] = '\0';
	my_services_change_script[0] = '\0';
	
	/* init the lists heads */
	for(i = 0; i < HASHSIZE; i++) {
		list_head_init(&name_list[i]);
		list_head_init(&forwarder_list[i]);
		list_head_init(&service_list[i]);
		list_head_init(&latlon_list[i]);
	}
	

}
示例#3
0
/*
 * Allocate a cookie for the next available cookie id.
 */
struct olsr_cookie_info *
olsr_alloc_cookie(const char *cookie_name, olsr_cookie_type cookie_type)
{
  struct olsr_cookie_info *ci;
  int ci_index;

  /*
   * Look for an unused index.
   * For ease of troubleshooting (non-zero patterns) we start at index 1.
   */
  for (ci_index = 1; ci_index < COOKIE_ID_MAX; ci_index++) {
    if (!cookies[ci_index]) {
      break;
    }
  }

  assert(ci_index < COOKIE_ID_MAX);     /* increase COOKIE_ID_MAX */

  ci = calloc(1, sizeof(struct olsr_cookie_info));
  cookies[ci_index] = ci;

  /* Now populate the cookie info */
  ci->ci_id = ci_index;
  ci->ci_type = cookie_type;
  if (cookie_name) {
    ci->ci_name = strdup(cookie_name);
  }

  /* Init the free list */
  if (cookie_type == OLSR_COOKIE_TYPE_MEMORY) {
    list_head_init(&ci->ci_free_list);
  }

  return ci;
}
示例#4
0
/* This allocates the block but doesn't sew it into data structures. */
static struct block *new_block(const tal_t *ctx,
			       BIGNUM *prev_work,
			       const struct protocol_block_id *sha,
			       const struct block_info *bi)
{
	struct block *block = tal(ctx, struct block);
	unsigned int i;

	total_work_done(le32_to_cpu(bi->tailer->difficulty),
			prev_work, &block->total_work);

	block->bi = *bi;
	block->all_known = false;
	list_head_init(&block->children);
	block->sha = *sha;
	block->shard = tal_arr(block, struct block_shard *,
			       num_shards(bi->hdr));
	for (i = 0; i < num_shards(bi->hdr); i++)
		block->shard[i] = new_block_shard(block->shard, i,
						  bi->num_txs[i]);

	/* In case we destroy before block_add(), eg. testing. */
	block->prev = NULL;

	tal_add_destructor(block, destroy_block);
	return block;
}
示例#5
0
/*
 * Allocate a new hash node (updating atomic counter in the process),
 * unless doing so will push us over the maximum cache size.
 */
static struct cache_node *
cache_node_allocate(
	struct cache *		cache,
	cache_key_t		key)
{
	unsigned int		nodesfree;
	struct cache_node *	node;

	pthread_mutex_lock(&cache->c_mutex);
	nodesfree = (cache->c_count < cache->c_maxcount);
	if (nodesfree) {
		cache->c_count++;
		if (cache->c_count > cache->c_max)
			cache->c_max = cache->c_count;
	}
	cache->c_misses++;
	pthread_mutex_unlock(&cache->c_mutex);
	if (!nodesfree)
		return NULL;
	node = cache->alloc(key);
	if (node == NULL) {	/* uh-oh */
		pthread_mutex_lock(&cache->c_mutex);
		cache->c_count--;
		pthread_mutex_unlock(&cache->c_mutex);
		return NULL;
	}
	pthread_mutex_init(&node->cn_mutex, NULL);
	list_head_init(&node->cn_mru);
	node->cn_count = 1;
	node->cn_priority = 0;
	return node;
}
示例#6
0
/**
 * Init datastructures for maintaining timers.
 */
void
olsr_init_timers(void)
{
  int idx;

  OLSR_PRINTF(3, "Initializing scheduler.\n");

  /* Grab initial timestamp */
  if (gettimeofday(&first_tv, NULL)) {
    olsr_exit("OS clock is not working, have to shut down OLSR", 1);
  }
  last_tv = first_tv;
  now_times = olsr_times();

  for (idx = 0; idx < TIMER_WHEEL_SLOTS; idx++) {
    list_head_init(&timer_wheel[idx]);
  }

  /*
   * Reset the last timer run.
   */
  timer_last_run = now_times;

  /* Allocate a cookie for the block based memeory manager. */
  timer_mem_cookie = olsr_alloc_cookie("timer_entry", OLSR_COOKIE_TYPE_MEMORY);
  olsr_cookie_set_memory_size(timer_mem_cookie, sizeof(struct timer_entry));
}
示例#7
0
int main(int argc, char *argv[])
{
	struct parent parent;
	struct child c1, c2, c3;

	plan_tests(12);
	parent.num_children = 0;
	list_head_init(&parent.children);

	c1.name = "c1";
	list_add(&parent.children, &c1.list);

	ok1(list_next(&parent.children, &c1, list) == NULL);
	ok1(list_prev(&parent.children, &c1, list) == NULL);

	c2.name = "c2";
	list_add_tail(&parent.children, &c2.list);

	ok1(list_next(&parent.children, &c1, list) == &c2);
	ok1(list_prev(&parent.children, &c1, list) == NULL);
	ok1(list_next(&parent.children, &c2, list) == NULL);
	ok1(list_prev(&parent.children, &c2, list) == &c1);

	c3.name = "c3";
	list_add_tail(&parent.children, &c3.list);

	ok1(list_next(&parent.children, &c1, list) == &c2);
	ok1(list_prev(&parent.children, &c1, list) == NULL);
	ok1(list_next(&parent.children, &c2, list) == &c3);
	ok1(list_prev(&parent.children, &c2, list) == &c1);
	ok1(list_next(&parent.children, &c3, list) == NULL);
	ok1(list_prev(&parent.children, &c3, list) == &c2);
	return exit_status();
}
示例#8
0
static struct dt_node *new_node(const char *name)
{
	struct dt_node *node = malloc(sizeof *node);
	if (!node) {
		prerror("Failed to allocate node\n");
		abort();
	}

	node->name = take_name(name);
	node->parent = NULL;
	list_head_init(&node->properties);
	list_head_init(&node->children);
	/* FIXME: locking? */
	node->phandle = new_phandle();
	return node;
}
示例#9
0
int __init tasklets_initialise(void) { 
  int i;
  for(i = 0; i < TASKLET_MAXTYPES;++i)
    list_head_init(&list_head[i]);
  setup_tasklets();
  return 0;
}
示例#10
0
int main(int argc, char *argv[])
{
    struct timespec start, curr;
    struct timers timers;
    struct list_head expired;
    struct timer t[PER_CONN_TIME];
    unsigned int i, num;
    bool check = false;

    opt_register_noarg("-c|--check", opt_set_bool, &check,
                       "Check timer structure during progress");

    opt_parse(&argc, argv, opt_log_stderr_exit);

    num = argv[1] ? atoi(argv[1]) : (check ? 100000 : 100000000);

    list_head_init(&expired);
    curr = start = time_now();
    timers_init(&timers, start);

    for (i = 0; i < num; i++) {
        curr = time_add(curr, time_from_msec(1));
        if (check)
            timers_check(&timers, NULL);
        timers_expire(&timers, curr, &expired);
        if (check)
            timers_check(&timers, NULL);
        assert(list_empty(&expired));

        if (i >= PER_CONN_TIME) {
            timer_del(&timers, &t[i%PER_CONN_TIME]);
            if (check)
                timers_check(&timers, NULL);
        }
        timer_add(&timers, &t[i%PER_CONN_TIME],
                  time_add(curr, time_from_msec(CONN_TIMEOUT_MS)));
        if (check)
            timers_check(&timers, NULL);
    }
    if (num > PER_CONN_TIME) {
        for (i = 0; i < PER_CONN_TIME; i++)
            timer_del(&timers, &t[i]);
    }

    curr = time_sub(time_now(), start);
    if (check)
        timers_check(&timers, NULL);
    timers_cleanup(&timers);
    opt_free_table();

    for (i = 0; i < ARRAY_SIZE(timers.level); i++)
        if (!timers.level[i])
            break;

    printf("%u in %lu.%09lu (%u levels / %zu)\n",
           num, (long)curr.tv_sec, curr.tv_nsec,
           i, ARRAY_SIZE(timers.level));
    return 0;
}
示例#11
0
struct cache *
cache_init(
	unsigned int		hashsize,
	struct cache_operations	*cache_operations)
{
	struct cache *		cache;
	unsigned int		i, maxcount;

	maxcount = hashsize * HASH_CACHE_RATIO;

	if (!(cache = malloc(sizeof(struct cache))))
		return NULL;
	if (!(cache->c_hash = calloc(hashsize, sizeof(struct cache_hash)))) {
		free(cache);
		return NULL;
	}

	cache->c_count = 0;
	cache->c_max = 0;
	cache->c_hits = 0;
	cache->c_misses = 0;
	cache->c_maxcount = maxcount;
	cache->c_hashsize = hashsize;
	cache->hash = cache_operations->hash;
	cache->alloc = cache_operations->alloc;
	cache->flush = cache_operations->flush;
	cache->relse = cache_operations->relse;
	cache->compare = cache_operations->compare;
	cache->bulkrelse = cache_operations->bulkrelse ?
		cache_operations->bulkrelse : cache_generic_bulkrelse;
	pthread_mutex_init(&cache->c_mutex, NULL);

	for (i = 0; i < hashsize; i++) {
		list_head_init(&cache->c_hash[i].ch_list);
		cache->c_hash[i].ch_count = 0;
		pthread_mutex_init(&cache->c_hash[i].ch_mutex, NULL);
	}

	for (i = 0; i <= CACHE_MAX_PRIORITY; i++) {
		list_head_init(&cache->c_mrus[i].cm_list);
		cache->c_mrus[i].cm_count = 0;
		pthread_mutex_init(&cache->c_mrus[i].cm_mutex, NULL);
	}
	return cache;
}
示例#12
0
文件: list.c 项目: vaesoo/nfq
/* move an entire list */
void
list_move_list(struct list_head *from, struct list_head *to)
{
	assert(list_empty(to));
	*to = *from;
	to->prev->next = to;
	to->next->prev = to;
	list_head_init(from);
}
示例#13
0
/**
 * MAKE SURE to initialize process module before any operation with processes.
 */
void haddock_process_module_init(void)
{
    for (os_size_t i=0; i < HDK_CFG_PROC_PRIORITY_NUM; i++) {
        list_head_init(& process_list_table[i].list);
        process_list_table[i].ready = 0x0;
    }
    
    haddock_memset(&__process_pool, 0, sizeof(__process_pool));
}
示例#14
0
void
olsr_init_export_route(void)
{
  /* the add/chg/del kernel queues */
  //list_head_init(&add_kernel_list);
  list_head_init(&chg_kernel_list);

  olsr_addroute_function = olsr_ioctl_add_route;
  olsr_addroute6_function = olsr_ioctl_add_route6;
  olsr_delroute_function = olsr_ioctl_del_route;
  olsr_delroute6_function = olsr_ioctl_del_route6;
}
示例#15
0
文件: dev.c 项目: open-sw/vzctl
int add_dev_param(dev_param *dev, dev_res *res)
{
	dev_res *tmp;

	if (list_is_init(&dev->dev))
		list_head_init(&dev->dev);
	tmp = malloc(sizeof(*tmp));
	if (tmp == NULL)
		return -1;
	memcpy(tmp, res, sizeof(*tmp));
	list_add_tail(&tmp->list, &dev->dev);

	return 0;
}
示例#16
0
struct pending_block *new_pending_block(struct state *state)
{
	struct pending_block *b = tal(state, struct pending_block);
	unsigned int i;

	for (i = 0; i < ARRAY_SIZE(b->pend); i++)
		b->pend[i] = tal_arr(b, struct pending_tx *, 0);

	/* FIXME: time out or limit unknown txs. */
	list_head_init(&b->unknown_tx);
	b->num_unknown = 0;
	b->needs_recheck = false;
	return b;
}
示例#17
0
文件: rfc822.c 项目: chr15m/ccan
struct rfc822_msg *rfc822_start(const void *ctx, const char *p, size_t len)
{
	struct rfc822_msg *msg;
	int i;

	msg = tal(ctx, struct rfc822_msg);
	ALLOC_CHECK(msg, NULL);

	msg->data = p;
	msg->end = p + len;

	msg->remainder = msg->data;
	msg->body = NULL;

	list_head_init(&msg->headers);

	for (i = 0; i < INDEX_HASH_SIZE; i++)
		list_head_init(&msg->header_index[i]);

	CHECK(msg, "<rfc22_start");

	return msg;
}
示例#18
0
int main(void)
{
    struct parent parent;
    struct child c1, c2, c3;
    const struct parent *p;
    const struct child *c;

    plan_tests(20);
    parent.num_children = 0;
    list_head_init(&parent.children);

    c1.name = "c1";
    list_add(&parent.children, &c1.list);

    ok1(list_next(&parent.children, &c1, list) == NULL);
    ok1(list_prev(&parent.children, &c1, list) == NULL);

    c2.name = "c2";
    list_add_tail(&parent.children, &c2.list);

    ok1(list_next(&parent.children, &c1, list) == &c2);
    ok1(list_prev(&parent.children, &c1, list) == NULL);
    ok1(list_next(&parent.children, &c2, list) == NULL);
    ok1(list_prev(&parent.children, &c2, list) == &c1);

    c3.name = "c3";
    list_add_tail(&parent.children, &c3.list);

    ok1(list_next(&parent.children, &c1, list) == &c2);
    ok1(list_prev(&parent.children, &c1, list) == NULL);
    ok1(list_next(&parent.children, &c2, list) == &c3);
    ok1(list_prev(&parent.children, &c2, list) == &c1);
    ok1(list_next(&parent.children, &c3, list) == NULL);
    ok1(list_prev(&parent.children, &c3, list) == &c2);

    /* Const variants */
    p = &parent;
    c = &c2;
    ok1(list_next(&p->children, &c1, list) == &c2);
    ok1(list_prev(&p->children, &c1, list) == NULL);
    ok1(list_next(&p->children, c, list) == &c3);
    ok1(list_prev(&p->children, c, list) == &c1);
    ok1(list_next(&parent.children, c, list) == &c3);
    ok1(list_prev(&parent.children, c, list) == &c1);
    ok1(list_next(&p->children, &c3, list) == NULL);
    ok1(list_prev(&p->children, &c3, list) == &c2);

    return exit_status();
}
示例#19
0
int setup_io_work_queue(struct tcmu_device *dev)
{
	struct tcmur_handler *r_handler = tcmu_get_runner_handler(dev);
	struct tcmur_device *rdev = tcmu_dev_get_private(dev);
	struct tcmu_io_queue *io_wq = &rdev->work_queue;
	int ret, i, nr_threads = r_handler->nr_threads;

	if (!nr_threads)
		return 0;

	list_head_init(&io_wq->io_queue);

	ret = pthread_mutex_init(&io_wq->io_lock, NULL);
	if (ret != 0) {
		goto out;
	}
	ret = pthread_cond_init(&io_wq->io_cond, NULL);
	if (ret != 0) {
		goto cleanup_lock;
	}

	/* TODO: Allow user to override device defaults */
	io_wq->io_wq_threads = calloc(nr_threads, sizeof(pthread_t));
	if (!io_wq->io_wq_threads) {
		ret = ENOMEM;
		goto cleanup_cond;
	}

	for (i = 0; i < nr_threads; i++) {
		ret = pthread_create(&io_wq->io_wq_threads[i], NULL,
				      io_work_queue, dev);
		if (ret != 0) {
			goto cleanup_threads;
		}
	}

	return 0;

cleanup_threads:
	cleanup_io_work_queue_threads(dev);
	free(io_wq->io_wq_threads);
cleanup_cond:
	pthread_cond_destroy(&io_wq->io_cond);
cleanup_lock:
	pthread_mutex_destroy(&io_wq->io_lock);
out:
	return -ret;
}
示例#20
0
文件: target.c 项目: open-power/pdbg
void target_init(struct target *target, const char *name, uint64_t base,
                 target_read read, target_write write,
                 target_destroy destroy, struct target *next)
{
    target->name = name;
    target->index = -1;
    target->base = base;
    target->read = read;
    target->write = write;
    target->destroy = destroy;
    target->next = next;

    list_head_init(&target->children);

    if (next)
        list_add_tail(&next->children, &target->link);
}
示例#21
0
void init_irq_8259A(void) { 
  int i;
  for( i = 0 ; i < IDT_ENTRIES; ++i ) { 
    struct irq_descriptor *irq  = irq_descriptor + i;
    irq->irq = i;
    irq->flags = IRQ_DISABLED; 
    list_head_init(&irq->action_head); /*initialise action list*/
    if(i < NR_IRQS) {
      irq->controller = &controller_8259A;
#if 1
      if(i != FDC_IRQ) 
#endif
       setidt(i+BASE_IRQ,(unsigned long)interrupt_handlers[i],INTR_TYPE,INTR_DPL);
    } else 
      irq->controller = &default_controller;
    irq->depth = 1; /*default for SHARED_IRQ*/
  }
}
示例#22
0
int wire_channel_recv_nonblock(wire_channel_t *c, void **msg)
{
	struct list_head *list = list_head(&c->pending_send);
	if (list == NULL)
		return -1;

	list_del(list);

	struct wire_msg *xmsg = list_entry(list, struct wire_msg, list);
	list_head_init(&xmsg->list); // Tell the caller we have taken the data

	// It is assumed that the message will be consumed before the next time the sender gets cpu time
	xmsg->received = 1;
	wire_resume(xmsg->caller);

	*msg = xmsg->msg;
	return 0;
}
示例#23
0
int trace_hash_init(struct trace_hash *hash, int buckets)
{
	struct list_head *bucket;

	memset(hash, 0, sizeof(*hash));

	hash->buckets = calloc(sizeof(*hash->buckets), buckets);
	if (!hash->buckets)
		return -ENOMEM;
	hash->nr_buckets = buckets;

	/* If a power of two then we can shortcut */
	if (!(buckets & (buckets - 1)))
		hash->power = buckets - 1;

	trace_hash_for_each_bucket(bucket, hash)
		list_head_init(bucket);
	return 0;
}
示例#24
0
文件: stats.c 项目: carriercomm/stats
static void add_line(struct file *info, const char *str)
{
	struct line *line;
	struct pattern *p;
	struct values *vals;

	p = get_pattern(str, &vals);

	line = linehash_get(&info->patterns, p);
	if (line) {
		add_stats(line, p, vals);
	} else {
		/* We need to keep a copy of this! */
		p->text = strdup(p->text); 
		line = malloc(sizeof(*line));
		line->pattern = p;
		list_head_init(&line->vals);
		list_add(&line->vals, &vals->list);
		linehash_add(&info->patterns, line);
		list_add_tail(&info->lines, &line->list);
	}
}
示例#25
0
struct block *block_add(struct state *state,
			struct block *prev,
			const struct protocol_block_id *sha,
			const struct block_info *bi)
{
	u32 height = le32_to_cpu(bi->hdr->height);
	struct block *block;

	log_debug(state->log, "Adding block %u ", height);
	log_add_struct(state->log, struct protocol_block_id, sha);

	block = new_block(state, &prev->total_work, sha, bi);
	block->prev = prev;

	/* Add to list for that generation. */
	if (height >= tal_count(state->block_height)) {
		/* We can only increment block heights. */
		assert(height == tal_count(state->block_height));
		tal_arr_append(&state->block_height,
			       tal(state->block_height, struct list_head));
		list_head_init(state->block_height[height]);
	}
示例#26
0
static struct io_plan *jcon_connected(struct io_conn *conn,
				      struct lightningd_state *dstate)
{
	struct json_connection *jcon;

	jcon = tal(dstate, struct json_connection);
	jcon->dstate = dstate;
	jcon->used = 0;
	jcon->buffer = tal_arr(jcon, char, 64);
	jcon->stop = false;
	jcon->current = NULL;
	jcon->log = new_log(jcon, dstate->log_record, "%sjcon fd %i:",
			    log_prefix(dstate->base_log), io_conn_fd(conn));
	list_head_init(&jcon->output);

	io_set_finish(conn, finish_jcon, jcon);

	return io_duplex(conn,
			 io_read_partial(conn, jcon->buffer,
					 tal_count(jcon->buffer),
					 &jcon->len_read, read_json, jcon),
			 write_json(conn, jcon));
}
示例#27
0
void wire_channel_init(wire_channel_t *c)
{
	list_head_init(&c->pending_send);
	list_head_init(&c->pending_recv);
}
示例#28
0
/**
 * Walk through the timer list and check if any timer is ready to fire.
 * Callback the provided function with the context pointer.
 */
static void
walk_timers(uint32_t * last_run)
{
  unsigned int total_timers_walked = 0, total_timers_fired = 0;
  unsigned int wheel_slot_walks = 0;

  /*
   * Check the required wheel slots since the last time a timer walk was invoked,
   * or check *all* the wheel slots, whatever is less work.
   * The latter is meant as a safety belt if the scheduler falls behind.
   */
  while ((*last_run <= now_times) && (wheel_slot_walks < TIMER_WHEEL_SLOTS)) {
    struct list_node tmp_head_node;
    /* keep some statistics */
    unsigned int timers_walked = 0, timers_fired = 0;

    /* Get the hash slot for this clocktick */
    struct list_node *const timer_head_node = &timer_wheel[*last_run & TIMER_WHEEL_MASK];

    /* Walk all entries hanging off this hash bucket. We treat this basically as a stack
     * so that we always know if and where the next element is.
     */
    list_head_init(&tmp_head_node);
    while (!list_is_empty(timer_head_node)) {
      /* the top element */
      struct list_node *const timer_node = timer_head_node->next;
      struct timer_entry *const timer = list2timer(timer_node);

      /*
       * Dequeue and insert to a temporary list.
       * We do this to avoid loosing our walking context when
       * multiple timers fire.
       */
      list_remove(timer_node);
      list_add_after(&tmp_head_node, timer_node);
      timers_walked++;

      /* Ready to fire ? */
      if (TIMED_OUT(timer->timer_clock)) {

        OLSR_PRINTF(7, "TIMER: fire %s timer %p, ctx %p, "
                   "at clocktick %u (%s)\n",
                   timer->timer_cookie->ci_name,
                   timer, timer->timer_cb_context, (unsigned int)*last_run, olsr_wallclock_string());

        /* This timer is expired, call into the provided callback function */
        timer->timer_cb(timer->timer_cb_context);

        /* Only act on actually running timers */
        if (timer->timer_flags & OLSR_TIMER_RUNNING) {
          /*
           * Don't restart the periodic timer if the callback function has
           * stopped the timer.
           */
          if (timer->timer_period) {
            /* For periodical timers, rehash the random number and restart */
            timer->timer_random = random();
            olsr_change_timer(timer, timer->timer_period, timer->timer_jitter_pct, OLSR_TIMER_PERIODIC);
          } else {
            /* Singleshot timers are stopped */
            olsr_stop_timer(timer);
          }
        }

        timers_fired++;
      }
    }

    /*
     * Now merge the temporary list back to the old bucket.
     */
    list_merge(timer_head_node, &tmp_head_node);

    /* keep some statistics */
    total_timers_walked += timers_walked;
    total_timers_fired += timers_fired;

    /* Increment the time slot and wheel slot walk iteration */
    (*last_run)++;
    wheel_slot_walks++;
  }

  OLSR_PRINTF(7, "TIMER: processed %4u/%d clockwheel slots, "
             "timers walked %4u/%u, timers fired %u\n",
             wheel_slot_walks, TIMER_WHEEL_SLOTS, total_timers_walked, timer_mem_cookie->ci_usage, total_timers_fired);

  /*
   * If the scheduler has slipped and we have walked all wheel slots,
   * reset the last timer run.
   */
  *last_run = now_times;
}
示例#29
0
文件: name_buf.c 项目: b409/b409
void init_name_buf(void)
{
	list_head_init(&name_buf_list);
}
示例#30
0
static int __INIT__ mw61_init(void)
{
	__u32 val;
	struct spi_slave  *spi_slave;
	struct spi_master *spi_master;

	val = readl(VA(SROM_BASE + SROM_BW));
	val &= ~0xF0;
	val |= 0xD0;
	writel(VA(SROM_BASE + SROM_BW), val);

	val = readl(VA(0x7f0080a0));
	val &= ~(3 << 28);
	val |= 2 << 28;
	writel(VA(0x7f0080a0), val);

	val = readl(VA(0x7f008080));
	val &= ~0xFF;
	val |= 0x11;
	writel(VA(0x7f008080), val);

	val = readl(VA(0x7f008084));
	val |= 0x3;
	writel(VA(0x7f008084), val);

#ifdef CONFIG_IRQ_SUPPORT
	s3c6410_interrupt_init();

#ifdef CONFIG_TIMER_SUPPORT
	s3c6410_timer_init();
#endif
#endif
	// MMC0 GPIO setting
	writel(VA(GPG_BASE + GPCON), 0x2222222);

	//gpio setting, EINT0,1 and EINT7
	val = readl(VA(GPN_CON));
	val &= ~0xffff;
	val |= 2 << 14 | 0xa;
	writel(VA(GPN_CON), val);

	//gpio trigger setting, EINT0,1 and EINT7
	val = readl(VA(EINT0_CON));
	val &= ~0x7;
	val |= 3;
	//set dm9000's interrupt,high level active
	val &= ~(0x7 << 12);
	val |= 0x001 << 12;
	writel(VA(EINT0_CON), val);

	//clean external interrupt
	val = readl(VA(EINT0PEND));
	writel(VA(EINT0PEND), val);

#ifdef CONFIG_SPI
	// master 0
	val = readl(VA(GPC_BASE + GPCCON));
	val &= ~0xFFFF;
	val |= 0x2222;
	writel(VA(GPC_BASE + GPCCON), val);

	set_master_tab(mw61_spi_master, ARRAY_ELEM_NUM(mw61_spi_master));

	set_slave_tab(mw61_spi_slave, ARRAY_ELEM_NUM(mw61_spi_slave));

	spi_slave  = get_spi_slave("w25x_nor_flash");
	spi_master = get_spi_master("s3c6410_spi0");
	list_head_init(&spi_master->slave_list);
	spi_slave_attach(spi_master, spi_slave);
#endif

	return 0;
}