Beispiel #1
0
static int usb_eth_driver_register(void)
{
	list_insert_after(&usb_eth_driver.list_node,
			  &generic_usb_drivers);

	list_insert_after(&net_poller.list_node, &net_pollers);

	return 0;
}
Beispiel #2
0
static int board_setup(void)
{
	sysinfo_install_flags();

	Exynos5420Gpio *lid_switch = new_exynos5420_gpio_input(GPIO_X, 3, 4);
	Exynos5420Gpio *ec_in_rw = new_exynos5420_gpio_input(GPIO_X, 2, 3);

	flag_replace(FLAG_LIDSW, &lid_switch->ops);
	flag_install(FLAG_ECINRW, &ec_in_rw->ops);

	// The power switch is active low and needs to be inverted.
	Exynos5420Gpio *power_switch_l =
		new_exynos5420_gpio_input(GPIO_X, 1, 2);
	flag_replace(FLAG_PWRSW, new_gpio_not(&power_switch_l->ops));

	Exynos5UsiI2c *i2c9 = new_exynos5_usi_i2c(0x12e10000, 400000);

	tpm_set_ops(&new_slb9635_i2c(&i2c9->ops, 0x20)->base.ops);

	Exynos5Spi *spi1 = new_exynos5_spi(0x12d30000);
	Exynos5Spi *spi2 = new_exynos5_spi(0x12d40000);

	CrosEcSpiBus *cros_ec_spi_bus = new_cros_ec_spi_bus(&spi2->ops);
	cros_ec_set_bus(&cros_ec_spi_bus->ops);

	flash_set_ops(&new_spi_flash(&spi1->ops, 0x400000)->ops);

	Exynos5I2s *i2s0 = new_exynos5_i2s_multi(0x03830000, 16, 2, 256);
	I2sSource *i2s_source = new_i2s_source(&i2s0->ops, 48000, 2, 16000);
	sound_set_ops(&new_sound_route(&i2s_source->ops)->ops);

	DwmciHost *emmc = new_dwmci_host(0x12200000, 100000000, 8, 0,
					 DWMCI_SET_SAMPLE_CLK(1) |
					 DWMCI_SET_DRV_CLK(3) |
					 DWMCI_SET_DIV_RATIO(3));
	DwmciHost *sd_card = new_dwmci_host(0x12220000, 100000000, 4, 1,
					    DWMCI_SET_SAMPLE_CLK(1) |
					    DWMCI_SET_DRV_CLK(2) |
					    DWMCI_SET_DIV_RATIO(3));
	list_insert_after(&emmc->mmc.ctrlr.list_node,
			  &fixed_block_dev_controllers);
	list_insert_after(&sd_card->mmc.ctrlr.list_node,
			  &removable_block_dev_controllers);

	power_set_ops(&exynos_power_ops);

	UsbHostController *usb_drd0 = new_usb_hc(XHCI, 0x12000000);
	UsbHostController *usb_drd1 = new_usb_hc(XHCI, 0x12400000);

	set_usb_init_callback(usb_drd0, exynos5420_usbss_phy_tune);
	/* DRD1 port has no SuperSpeed lines anyway */

	list_insert_after(&usb_drd0->list_node, &usb_host_controllers);
	list_insert_after(&usb_drd1->list_node, &usb_host_controllers);

	return 0;
}
int main()
{
    struct list_t *root;
    size_t s;
    int a=43,b=63,c=99,d=70,e=25,f=17,g=57,h=69,i=111,j=120,k=70,l=73,m=75;
    /* char z[100]="test"; */
    /* z = "test"; */

    root = list_init();

	root = list_remove_rear(root);
    root = list_remove_any(root,&k);
    root = list_remove_front(root);

    list_insert_rear(root, &a);
    list_insert_rear(root, &b);
    
    root = list_insert_after(root,&c,3);
    list_insert_rear(root, &d);
    
    root = list_insert_front(root, &e);
    root = list_insert_front(root, &f);
    
    list_insert_rear(root, &g);
    root = list_remove_front(root);
    
    list_insert_rear(root, &h);
    
    root = list_insert_after(root,&i,5);
    root = list_insert_after(root,&j,120);
    
    root = list_remove_any(root,&k);

    root = list_remove_front(root);
    list_insert_rear(root, &l);
    root = list_remove_any(root,&l);

    list_insert_rear(root, &m);
    
    
    root = list_remove_rear(root);
    root = list_remove_rear(root);
    root = list_remove_rear(root);
    root = list_remove_rear(root);
    root = list_remove_rear(root);
    root = list_remove_rear(root);
    root = list_remove_rear(root);
    
    s = list_size(root);
    printf( "%d\n", (int)s);
    printf( "%d\n", search(root, &g) );

    list_destroy(root);

    return 0;
}
Beispiel #4
0
static int board_setup(void)
{
	sysinfo_install_flags(NULL);

	fill_board_descriptor();

	fit_set_compat(bdescriptor.compat_string);

	install_phys_presence_flag();

	console_add_input_driver(&dakota_input_driver);

	power_set_ops(new_ipq40xx_power_ops());

	SpiController *spi = new_spi(0, 0);
	flash_set_ops(&new_spi_flash(&spi->ops)->ops);

	QcomMmcHost *mmc = new_qcom_mmc_host(1, MSM_SDC1_BASE, 8);

	if (!mmc)
		return -1;

	list_insert_after(&mmc->mmc.ctrlr.list_node,
				  &fixed_block_dev_controllers);

	UsbHostController *usb_host1 = new_usb_hc(XHCI, 0x8A00000);

	list_insert_after(&usb_host1->list_node, &usb_host_controllers);

#if (!CONFIG_MOCK_TPM)
	Ipq40xxI2c *i2c = new_ipq40xx_i2c(BLSP_QUP_ID_2);
	tpm_set_ops(&new_slb9635_i2c(&i2c->ops, 0x20)->base.ops);
#endif

	DisplayOps *ww_ring_ops = new_ww_ring_display
		(&new_ipq40xx_i2c (BLSP_QUP_ID_3)->ops, 0x32);

	display_set_ops(ww_ring_ops);

	display_init();

	write32(ADSS_AUDIO_TXB_CBCR_REG, 0); /* Disable ADSS clock branch */

	ipq_snoc_pnoc_init();

	list_insert_after(&ipq_enet_fixup.list_node, &device_tree_fixups);

	return 0;
}
Beispiel #5
0
void list_append(List* self, ADT p_data)
{
	RealList* l_reallist = (RealList*)self;
	l_reallist->current = l_reallist->tail;

	list_insert_after(self, p_data);
}
Beispiel #6
0
/**
 * Sort a linked list in an order defined by the sort handler
 *
 * @param list  Linked list
 * @param sh    Sort handler
 * @param arg   Handler argument
 */
void list_sort(struct list *list, list_sort_h *sh, void *arg)
{
	struct le *le;
	bool sort;

	if (!list || !sh)
		return;

 retry:
	le = list->head;
	sort = false;

	while (le && le->next) {

		if (sh(le, le->next, arg)) {

			le = le->next;
		}
		else {
			struct le *tle = le->next;

			list_unlink(le);
			list_insert_after(list, tle, le, le->data);
			sort = true;
		}
	}

	if (sort) {
		goto retry;
	}
}
// Must be called with monitor held
static void schedule_next_instance(alarm_t *alarm, bool force_reschedule) {
  // If the alarm is currently set and it's at the start of the list,
  // we'll need to re-schedule since we've adjusted the earliest deadline.
  bool needs_reschedule = (!list_is_empty(alarms) && list_front(alarms) == alarm);
  if (alarm->callback)
    list_remove(alarms, alarm);

  // Calculate the next deadline for this alarm
  period_ms_t just_now = now();
  period_ms_t ms_into_period = alarm->is_periodic ? ((just_now - alarm->created) % alarm->period) : 0;
  alarm->deadline = just_now + (alarm->period - ms_into_period);

  // Add it into the timer list sorted by deadline (earliest deadline first).
  if (list_is_empty(alarms) || ((alarm_t *)list_front(alarms))->deadline >= alarm->deadline)
    list_prepend(alarms, alarm);
  else
    for (list_node_t *node = list_begin(alarms); node != list_end(alarms); node = list_next(node)) {
      list_node_t *next = list_next(node);
      if (next == list_end(alarms) || ((alarm_t *)list_node(next))->deadline >= alarm->deadline) {
        list_insert_after(alarms, node, alarm);
        break;
      }
    }

  // If the new alarm has the earliest deadline, we need to re-evaluate our schedule.
  if (force_reschedule || needs_reschedule || (!list_is_empty(alarms) && list_front(alarms) == alarm))
    reschedule_root_alarm();
}
// Runs in exclusion with alarm_cancel and timer_callback.
void alarm_set(alarm_t *alarm, period_ms_t deadline, alarm_callback_t cb, void *data) {
  assert(alarms != NULL);
  assert(alarm != NULL);
  assert(cb != NULL);

  pthread_mutex_lock(&monitor);

  // If the alarm is currently set and it's at the start of the list,
  // we'll need to re-schedule since we've adjusted the earliest deadline.
  bool needs_reschedule = (!list_is_empty(alarms) && list_front(alarms) == alarm);
  if (alarm->callback)
    list_remove(alarms, alarm);

  alarm->deadline = now() + deadline;
  alarm->callback = cb;
  alarm->data = data;

  // Add it into the timer list sorted by deadline (earliest deadline first).
  if (list_is_empty(alarms))
    list_prepend(alarms, alarm);
  else
    for (list_node_t *node = list_begin(alarms); node != list_end(alarms); node = list_next(node)) {
      list_node_t *next = list_next(node);
      if (next == list_end(alarms) || ((alarm_t *)list_node(next))->deadline >= alarm->deadline) {
        list_insert_after(alarms, node, alarm);
        break;
      }
    }

  // If the new alarm has the earliest deadline, we need to re-evaluate our schedule.
  if (needs_reschedule || (!list_is_empty(alarms) && list_front(alarms) == alarm))
    reschedule();

  pthread_mutex_unlock(&monitor);
}
Beispiel #9
0
err_t list_insert_sorted(list_t* list, list_item_t* item, int (*compare)(const void*, const void*))
{
    if(item == NULL) return E_NULL_POINTER;
    if(compare == NULL) return E_NULL_POINTER;
    
    if(list->head == NULL){
        list->head = item;
        list->tail = item;
        return E_NO_ERROR;
    }
    
    list_item_t* cur = list->head;
    int cmp = 0;
    
    while(cur){
        cmp = compare(item->data, cur->data);
        if(cmp > 0){
            if(cur->next){
                cur = cur->next;
            }else{
                list_insert_after(list, cur, item);
                break;
            }
        }else{
            list_insert_before(list, cur, item);
            break;
        }
    }
    
    return E_NO_ERROR;
}
Beispiel #10
0
int check_list()
{
  LIST *list, *listreturn;

  char *dataptr;

  size_t counter;

  int travreturn;
  
  list = list_init();
  if(!list)
    return 1;

  /* test if list is functional without anything in it (expect NULL return) */
  listreturn = list_mvprev(list);
  if(listreturn)
    return 2;

  /* play with some data */
  for(counter = 0; datas[counter]; counter ++)
    {
      dataptr = list_insert_after(list, datas[counter], strlen(datas[counter]) + 1);
      if(strcmp(dataptr, datas[counter]))
	{
	  fprintf(stderr, "got %s, expecting %s\n", dataptr, datas[counter]);
	  return 3;
	}
      
    }

  for(counter = 0; datas[counter]; counter ++)
    {
      dataptr = list_insert_before(list, datas[counter], strlen(datas[counter]) + 1);
      if(strcmp(dataptr, datas[counter]))
	{
	  fprintf(stderr, "got %s, expecting %s\n", dataptr, datas[counter]);
	  return 4;
	}
    }

  /* test traversal */
  travreturn = list_traverse(list, (void *)NULL, &list_traverse_print, 0);
  if(travreturn != LIST_EXTENT)
    return 5;

  /* The defaults for list traversal are to not change the current
     element of the list. Thus, list_curr should return the last
     inserted piece of data which is at datas[counter - 1] */
  dataptr = (char *)list_curr(list);
  if(strcmp(dataptr, datas[counter - 1]))
    {
      fprintf(stderr, "get %s, expecting %s\n", dataptr, datas[counter - 1]);
      return 6;
    }

  list_free(list, LIST_DEALLOC);

  return 0;
}
Beispiel #11
0
/**
 * list_insert()
 *  Insert data into a list at the head (if *prev is NULL) or after *prev
 *  @list -- Pointer to list to operate on
 *  @prev -- Pointer to node to insert after
 *  @data -- Data to insert in the new node
 *  @len  -- Length of the data to insert
 *  @return -- pointer to the newly created node
 */
list_node *list_insert(linked_list *list, list_node *prev, void *data, size_t len)
{
    if(prev == NULL)
        return list_insert_head(list, data, len);
    else
        return list_insert_after(prev, data, len);
}
Beispiel #12
0
static void
trim_map_segment_remove(trim_map_t *tm, trim_seg_t *ts, uint64_t start,
    uint64_t end)
{
	trim_seg_t *nts;
	boolean_t left_over, right_over;

	ASSERT(MUTEX_HELD(&tm->tm_lock));

	left_over = (ts->ts_start < start);
	right_over = (ts->ts_end > end);

	TRIM_MAP_SDEC(tm, end - start);
	if (left_over && right_over) {
		nts = kmem_alloc(sizeof (*nts), KM_SLEEP);
		nts->ts_start = end;
		nts->ts_end = ts->ts_end;
		nts->ts_txg = ts->ts_txg;
		nts->ts_time = ts->ts_time;
		ts->ts_end = start;
		avl_insert_here(&tm->tm_queued_frees, nts, ts, AVL_AFTER);
		list_insert_after(&tm->tm_head, ts, nts);
		TRIM_MAP_QINC(tm);
	} else if (left_over) {
		ts->ts_end = start;
	} else if (right_over) {
		ts->ts_start = end;
	} else {
		avl_remove(&tm->tm_queued_frees, ts);
		list_remove(&tm->tm_head, ts);
		TRIM_MAP_QDEC(tm);
		kmem_free(ts, sizeof (*ts));
	}
}
Beispiel #13
0
void pool_add_block(pool_t* pool, block_t* block, int block_size)
{
    LOG("add block->index = %d , size = %d\n", block->debug_index, block_size);
    block->mem_size = block_size;
    block->cur_pos = ((char*)block) + sizeof(block_t);
    list_insert_after((list_t*)&(pool->blocks), (list_t*)block);
}
Beispiel #14
0
Ipq806xSound *new_ipq806x_sound(GpioOps *gpio, unsigned int frame_rate,
                                unsigned int channels, unsigned int bitwidth, uint16_t volume)
{
    Ipq806xSound *sound = xzalloc(sizeof(*sound));
    CleanupFunc *cleanup = xzalloc(sizeof(*cleanup));

    assert(gpio != NULL);

    sound->ops.start = &ipq806x_sound_start;
    sound->ops.stop = &ipq806x_sound_stop;
    sound->ops.play = &ipq806x_sound_play;
    sound->ops.set_volume = &ipq806x_set_volume;

    sound->gpio = gpio;

    sound->ctrl_regs = (void *)(IPQ806X_LPAIF_BASE +
                                LPAIF_MI2S_CTL_OFFSET(LPAIF_I2S_PORT_MI2S));
    sound->dma_regs = (void *)(IPQ806X_LPAIF_BASE +
                               LPAIF_DMA_ADDR(LPAIF_DMA_RD_CH_MI2S, 0x00));
    sound->lcc_mi2s_regs = (void *)(IPQ806X_LCC_BASE + LCC_MI2S_NS_REG);
    sound->buffer = (void *)(IPQ806X_LPM_BASE);

    sound->buffer_length = LPM_SIZE;
    sound->frame_rate = frame_rate;
    sound->channels = channels;
    sound->bitwidth = bitwidth;
    sound->volume = volume;

    cleanup->cleanup = &ipq806x_sound_shutdown;
    cleanup->types = CleanupOnHandoff | CleanupOnLegacy;
    cleanup->data = sound;
    list_insert_after(&cleanup->list_node, &cleanup_funcs);

    return sound;
}
Beispiel #15
0
int main()
{
    List *list = list_create();

    if (!list)
        std::cout << "List creation error\n";

    list_insert(list, 1);
    list_insert(list, 2);
    list_insert(list, 3);

    if (list_item_data(list_first(list)) != 3)
        std::cout << "list_insert error\n";

    list_insert_after(list, list_first(list), 4);

    if (list_item_data(list_item_next(list_first(list))) != 4)
        std::cout << "list_insert_after error\n";

    list_erase(list, list_first(list));

    if (list_item_data(list_first(list)) != 4)
        std::cout << "list_erase error\n";

    std::cout << "List: ";
    for (ListItem *item = list_first(list) ; item ; item = list_item_next(item))
    {
        std::cout << list_item_data(item) << " ";
    }
    std::cout << "\n";
    
    list_delete(list);
}
Beispiel #16
0
void list_move_after(list_node * list, list_node * node)
{
	MESSAGE_DEBUG("list:%p node:%p\n", list, node);
//	list_delete (node);
	list_insert_after (list, node);
//	list_dump(list);
}
Beispiel #17
0
static void list_sorted_insert(struct tcb_list *list, struct tcb_node *node)
{
    struct tcb_node *find;
    if(node->tcb->prio > 0)
    {
        for(find = list->head; find != NULL; find = find->next)
        {
            if(find->tcb->prio < node->tcb->prio)
            {
                break;
            }
        }
        list_insert_before(list, find, node);
    }
    else
    {
        for(find = list->tail; find != NULL; find = find->prev)
        {
            if(find->tcb->prio >= node->tcb->prio)
            {
                break;
            }
        }
        list_insert_after(list, find, node);
    }
}
Beispiel #18
0
list_item_t* list_insert_after_new(list_t* list, list_item_t* ref, void* data)
{
    list_item_t* item = list_alloc_item(data);
    
    list_insert_after(list, ref, item);
    
    return item;
}
Beispiel #19
0
void display_set_ops(DisplayOps *ops)
{
	die_if(display_ops, "%s: Display ops already set.\n", __func__);
	display_ops = ops;

	/* Call stop() when exiting depthcharge. */
	list_insert_after(&display_cleanup_func.list_node, &cleanup_funcs);
}
Beispiel #20
0
/**
 * Inserts a node to a sorted list
 */
void sorted_list_insert(sorted_list_t* list, list_node_t* node)
{
	if (list_empty(&list->list)) {
		list_push_front(&list->list, node);
		return;
	}

	list_node_t* other_node = list_front(&list->list);	
	while (other_node != NULL) {
		int cmp_result = list->compare_func(node, other_node);
		if (cmp_result == 0) {
			list_insert_after(&list->list, other_node, node);
			return;
		}
	
		if (cmp_result < 0) {
			if (other_node->prev == NULL) {
				list_insert_before(&list->list, other_node, node);
				return;
			}
			cmp_result = list->compare_func(node, other_node->prev);
			if (cmp_result > 0) {
				list_insert_before(&list->list, other_node, node);
				return;
			}
			other_node = other_node->prev;
			continue;
		}
	
		if (cmp_result > 0) {
			if (other_node->next == NULL) {
				list_insert_after(&list->list, other_node, node);
				return;
			}
			cmp_result = list->compare_func(node, other_node->next);
			if (cmp_result < 0) {
				list_insert_after(&list->list, other_node, node);
				return;
			}
			other_node = other_node->next;
			continue;
		}
	}
}
Beispiel #21
0
static int i2ctpm_init(I2cTpm *tpm)
{
	if (tpm->chip_ops.init(&tpm->chip_ops))
		return -1;

	list_insert_after(&tpm->cleanup.list_node, &cleanup_funcs);

	tpm->initialized = 1;

	return 0;
}
Beispiel #22
0
void insert(char *args, List *list, Node *node, int direction)
{
	int n;
	if (get_one_arg(args, &n))
	{
		if (direction == id_after)
			list_insert_after(list, node, n);
		else 
			list_insert_before(list, node, n);
	}		
}
Beispiel #23
0
static int board_setup(void)
{
	sysinfo_install_flags(NULL);

	flash_set_ops(&new_mem_mapped_flash(0xffe00000, 0x200000)->ops);

	AhciCtrlr *ahci = new_ahci_ctrlr(PCI_DEV(0, 17, 0));
	list_insert_after(&ahci->ctrlr.list_node, &fixed_block_dev_controllers);

	return 0;
}
Beispiel #24
0
static int dc_usb_install_on_demand_input(void)
{
	static OnDemandInput dev =
	{
		&usb_input_init,
		1
	};

	list_insert_after(&dev.list_node, &on_demand_input_devices);
	return 0;
}
Beispiel #25
0
static int board_setup(void)
{
	ImgSpi *spfi;
	MtdDevCtrlr *mtd;
	SpiGptCtrlr *virtual_dev;
	UsbHostController *usb_host;
	ImgGpio *img_gpio;
	ImgI2c *img_i2c;
	struct board_conf *conf = pick_board_config();

	flag_install(FLAG_DEVSW, new_gpio_low());
	flag_install(FLAG_LIDSW, new_gpio_high());
	flag_install(FLAG_PHYS_PRESENCE, new_gpio_high());
	flag_install(FLAG_RECSW, new_gpio_high());
	flag_install(FLAG_PWRSW, new_gpio_low());
	flag_install(FLAG_WPSW, new_gpio_low());

	usb_host = new_usb_hc(DWC2, 0xB8120000);
	list_insert_after(&usb_host->list_node, &usb_host_controllers);

	img_gpio = new_imgtec_gpio_output(NOR_CS_GPIO);
	spfi = new_imgtec_spi(SPIM_INTERFACE, NOR_CS, &(img_gpio->ops));
	flash_set_ops(&new_spi_flash(&spfi->ops)->ops);

	img_gpio = new_imgtec_gpio_output(conf->nand_cs_gpio);
	spfi = new_imgtec_spi(SPIM_INTERFACE, NAND_CS, &(img_gpio->ops));

	mtd = new_spi_nand(&spfi->ops);
	virtual_dev = new_spi_gpt("RW_GPT", new_mtd_stream(mtd),
				  "spi@18101000/flash@1");
	list_insert_after(&virtual_dev->block_ctrlr.list_node,
				&fixed_block_dev_controllers);
	img_i2c = new_imgtec_i2c(conf->i2c_interface, 100000, 33333333);
	tpm_set_ops(&new_slb9635_i2c(&(img_i2c->ops), 0x20)->base.ops);

	fit_set_compat(conf->compatible);

	list_insert_after(&urara_dt_fixup.list_node, &device_tree_fixups);

	return 0;
}
Beispiel #26
0
static int board_setup(void)
{
	bcm_qspi *qspi = new_bcm_qspi(BCM_QSPI_BASE, SPI_MODE_3, 50000000);
	flash_set_ops(&new_spi_flash(&qspi->ops)->ops);

	MtdDevCtrlr *mtd = new_bcm_nand((void *)BCM_NAND_BASE,
					(void *)BCM_NAND_IDM_BASE,
					4 /* ONFI timing mode */);
	SpiGptCtrlr *virtual_dev = new_spi_gpt("RW_GPT",
					       new_mtd_stream(mtd),
					       "nand");
	list_insert_after(&virtual_dev->block_ctrlr.list_node,
			  &fixed_block_dev_controllers);

	UsbHostController *usb_host20 = new_usb_hc(EHCI, 0x18048000);
	UsbHostController *usb_host11 = new_usb_hc(OHCI, 0x18048800);
	list_insert_after(&usb_host20->list_node, &usb_host_controllers);
	list_insert_after(&usb_host11->list_node, &usb_host_controllers);

	return 0;
}
Beispiel #27
0
void list_insert(List* self, int p_index, ADT p_src)
{
	RealList* l_reallist = (RealList*)self;

	if ( p_index<=0 || p_index>l_reallist->length )
	{
		list_append(self, p_src);
		return ;
	}

	if ( list_locate(self, p_index) ) list_insert_after(self, p_src);
	else list_append(self, p_src);
}
Beispiel #28
0
/**
 * Start a timer
 *
 * @param tmr   Timer to start
 * @param delay Timer delay in [ms]
 * @param th    Timeout handler
 * @param arg   Handler argument
 */
void tmr_start(struct tmr *tmr, uint64_t delay, tmr_h *th, void *arg)
{
	struct list *tmrl = tmrl_get();
	struct le *le;

	if (!tmr)
		return;

	if (tmr->th) {
		list_unlink(&tmr->le);
	}

	tmr->th  = th;
	tmr->arg = arg;

	if (!th)
		return;

	tmr->jfs = delay + tmr_jiffies();

	if (delay == 0) {
		le = list_apply(tmrl, true, inspos_handler_0, &tmr->jfs);
		if (le) {
			list_insert_before(tmrl, le, &tmr->le, tmr);
		}
		else {
			list_append(tmrl, &tmr->le, tmr);
		}
	}
	else {
		le = list_apply(tmrl, false, inspos_handler, &tmr->jfs);
		if (le) {
			list_insert_after(tmrl, le, &tmr->le, tmr);
		}
		else {
			list_prepend(tmrl, &tmr->le, tmr);
		}
	}

#ifdef HAVE_ACTSCHED
	/* TODO: this is a hack. when a new timer is started we must reset
	   the main sleeping timer in actsched.cpp */
	{
		extern void actsched_restart_timer(void);
		actsched_restart_timer();
	}
#endif
}
Beispiel #29
0
/**
 * Add candidate pair to list, sorted by pair priority (highest is first)
 */
static void list_add_sorted(struct list *list, struct candpair *cp)
{
	struct le *le;

	/* find our slot */
	for (le = list_tail(list); le; le = le->prev) {
		struct candpair *cp0 = le->data;

		if (cp->pprio < cp0->pprio) {
			list_insert_after(list, le, &cp->le, cp);
			return;
		}
	}

	list_prepend(list, &cp->le, cp);
}
Beispiel #30
0
// Inicializacao com buffer pre-alocado
void rst_init_ptr(rst_buffer_t *ptr, u_int64_t id1, u_int64_t id2)
{
    int fd;
    char fname[30];
    char hostname[MAXHOSTNAMELEN+1];
       
    if ( ptr == NULL ) {
        fprintf(stderr, "[rastro] error inicializing - invalid pointer\n");
        return;
    }
    
#ifdef THREADED
    if (!rst_key_initialized) {
        pthread_key_create(&rst_key, rst_destroy_buffer);
        rst_key_initialized = 1;
    }
#endif
    
    if(!list_init){
    	list_initialize(&list, list_copy, list_cmp, list_destroy);
	list_init=true;
    }
    
    RST_SET_PTR(ptr);
    ptr->rst_buffer_size = 100000;
    ptr->rst_buffer = malloc(ptr->rst_buffer_size);
    RST_RESET(ptr);
    
    sprintf(fname, "rastro-%"PRIu64"-%"PRIu64".rst",/* dirname,*/ id1, id2);
    fd = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0666);
    if (fd == -1) {
        fprintf(stderr, "[rastro] cannot open file %s: %s\n", 
                        fname, strerror(errno));
        return;
    }
    
    list_insert_after(&list, NULL, (void *)ptr );
    
    RST_SET_FD(ptr, fd);
    
    // this will force first event to register sync time
    RST_SET_T0(ptr, 0);

    gethostname(hostname, sizeof(hostname));
    
    XCAT(rst_event_,LETRA_UINT64,LETRA_STRING,_ptr)(ptr, RST_EVENT_INIT, id1, id2, hostname);
}