Пример #1
0
/* worker thread */
void
rdsv3_worker_thread(void *arg)
{
	rdsv3_workqueue_struct_t *wq = arg;
	rdsv3_work_t *work;

	RDSV3_DPRINTF4("rdsv3_worker_thread", "Enter(wq: 0x%p)", wq);

	mutex_enter(&wq->wq_lock);
	work = list_remove_head(&wq->wq_queue);
	while (work) {
		mutex_exit(&wq->wq_lock);

		/* process work */
		work->func(work);

		mutex_enter(&wq->wq_lock);
		work = list_remove_head(&wq->wq_queue);
	}

	/* No more work, go home, until called again */
	if (wq->wq_state != RDSV3_WQ_THREAD_EXITING) {
		wq->wq_state = RDSV3_WQ_THREAD_IDLE;
	}
	mutex_exit(&wq->wq_lock);

	RDSV3_DPRINTF4("rdsv3_worker_thread", "Return(wq: 0x%p)", wq);
}
Пример #2
0
/*
 * Finalization routine for nfsauth. It is important to call this routine
 * before destroying the exported_lock.
 */
void
nfsauth_fini(void)
{
	refreshq_exi_node_t	*ren;

	/*
	 * Prevent the nfsauth_refresh_thread from getting new
	 * work.
	 */
	mutex_enter(&refreshq_lock);
	if (refreshq_thread_state != REFRESHQ_THREAD_HALTED) {
		refreshq_thread_state = REFRESHQ_THREAD_FINI_REQ;
		cv_broadcast(&refreshq_cv);

		/*
		 * Also, wait for nfsauth_refresh_thread() to exit.
		 */
		while (refreshq_thread_state != REFRESHQ_THREAD_HALTED) {
			cv_wait(&refreshq_cv, &refreshq_lock);
		}
	}
	mutex_exit(&refreshq_lock);

	/*
	 * Walk the exi_list and in turn, walk the auth_lists and free all
	 * lists.  In addition, free INVALID auth_cache entries.
	 */
	while ((ren = list_remove_head(&refreshq_queue))) {
		refreshq_auth_node_t *ran;

		while ((ran = list_remove_head(&ren->ren_authlist)) != NULL) {
			struct auth_cache *p = ran->ran_auth;
			if (p->auth_state == NFS_AUTH_INVALID)
				nfsauth_free_node(p);
			strfree(ran->ran_netid);
			kmem_free(ran, sizeof (refreshq_auth_node_t));
		}

		list_destroy(&ren->ren_authlist);
		exi_rele(ren->ren_exi);
		kmem_free(ren, sizeof (refreshq_exi_node_t));
	}
	list_destroy(&refreshq_queue);

	cv_destroy(&refreshq_cv);
	mutex_destroy(&refreshq_lock);

	mutex_destroy(&mountd_lock);

	/*
	 * Deallocate nfsauth cache handle
	 */
	kmem_cache_destroy(exi_cache_handle);
}
Пример #3
0
void vmm_page_table_free(list_t *page_table){

    struct page_table_entry_t* entry;

    entry = (page_table_entry_t*)list_remove_head(page_table);
    while(entry){
	/* Do not add pages from the memory image to the page pool */
	if((unsigned int)entry->paddr_base >= PHYSMEM_START){
	    list_add_tail(page_pool, entry->paddr_base);
	}
	free(entry);
	entry = (page_table_entry_t*)list_remove_head(page_table);
    }
}
Пример #4
0
void HCI_recv_packet(unsigned char* packet_buffer, unsigned int packet_length) {
  tHciDataPacket * hciReadPacket = NULL;

  if (!list_is_empty ((tListNode*)&hciReadPktPool)){
      
    if(packet_length > 0) {
      /* enqueueing a packet for read */
      list_remove_head ((tListNode*)&hciReadPktPool, (tListNode **)&hciReadPacket);
      
      Osal_MemCpy(hciReadPacket->dataBuff, packet_buffer, MIN(HCI_READ_PACKET_SIZE, packet_length));
    
      hciReadPacket->data_len = packet_length;
      switch(HCI_verify(hciReadPacket)) {
        case 0:
          list_insert_tail((tListNode*)&hciReadPktRxQueue, (tListNode *)hciReadPacket);
          break;

        default:
        case 1:
        case 2:
          list_insert_head((tListNode*)&hciReadPktPool, (tListNode *)hciReadPacket);
          break;
      }
    }
  }
  else{
    // HCI Read Packet Pool is empty, wait for a free packet.
    readPacketListFull = TRUE;
    return;
  }

  // process incoming packet

  // don't process when hci_send_req is undergoing
  if (hciAwaitReply) {
    return;
  }

  /* process any pending events read */
  while(!list_is_empty((tListNode*)&hciReadPktRxQueue))
  {
    list_remove_head ((tListNode*)&hciReadPktRxQueue, (tListNode **)&hciReadPacket);
    //Enable_SPI_IRQ();
    HCI_Event_CB(hciReadPacket->dataBuff);
    //Disable_SPI_IRQ();
    list_insert_tail((tListNode*)&hciReadPktPool, (tListNode *)hciReadPacket);
  }
}
Пример #5
0
void HCI_Isr(void)
{
  tHciDataPacket * hciReadPacket = NULL;
  uint8_t data_len;
    
  Clear_SPI_EXTI_Flag();
  while(BlueNRG_DataPresent()){        
    if (list_is_empty (&hciReadPktPool) == FALSE){
            
      /* enqueueing a packet for read */
      list_remove_head (&hciReadPktPool, (tListNode **)&hciReadPacket);
            
      data_len = BlueNRG_SPI_Read_All(&SpiHandle, hciReadPacket->dataBuff, HCI_PACKET_SIZE);
      if(data_len > 0){                    
	HCI_Input(hciReadPacket);
	// Packet will be inserted to te correct queue by 
      }
      else {
	// Insert the packet back into the pool.
	list_insert_head(&hciReadPktPool, (tListNode *)hciReadPacket);
      }
            
    }
    else{
      // HCI Read Packet Pool is empty, wait for a free packet.
      readPacketListFull = TRUE;
      Clear_SPI_EXTI_Flag();
      return;
    }
        
    Clear_SPI_EXTI_Flag();
  }
}
Пример #6
0
//-----------------------------------------------------------------------------
tbs_size_t mac_rlc_serialize_tb (char* buffer_pP, list_t transport_blocksP)
{
  //-----------------------------------------------------------------------------
  mem_block_t *tb_p;
  tbs_size_t   tbs_size;
  tbs_size_t   tb_size;

  tbs_size = 0;

  while (transport_blocksP.nb_elements > 0) {
    tb_p = list_remove_head (&transport_blocksP);

    if (tb_p != NULL) {
      tb_size = ((struct mac_tb_req *) (tb_p->data))->tb_size;
#ifdef DEBUG_MAC_INTERFACE
#if defined(TRACE_RLC_PAYLOAD)
      LOG_T(RLC, "[MAC-RLC] DUMP TX PDU(%d bytes):\n", tb_size);
      rlc_util_print_hex_octets(RLC, ((struct mac_tb_req *) (tb_p->data))->data_ptr, tb_size);
#endif
#endif
      memcpy(&buffer_pP[tbs_size], &((struct mac_tb_req *) (tb_p->data))->data_ptr[0], tb_size);
      tbs_size = tbs_size + tb_size;
      free_mem_block(tb_p);
    }
  }

  return tbs_size;
}
Пример #7
0
//-----------------------------------------------------------------------------
struct mac_data_req
rlc_am_mac_data_request (void *rlcP)
{
//-----------------------------------------------------------------------------
  struct mac_data_req data_req;
  mem_block_t      *pdu;
  signed int nb_pdu_to_transmit = ((struct rlc_am_entity *) rlcP)->nb_pdu_requested_by_mac_on_ch1 ;
  //rlc_am_get_pdus (rlcP, RLC_AM_TRAFFIC_ALLOWED_FOR_STATUS | RLC_AM_TRAFFIC_ALLOWED_FOR_DATA);
  rlc_am_get_pdus (rlcP, RLC_AM_TRAFFIC_ALLOWED_FOR_DATA);

  list_init (&data_req.data, NULL);

  //list_add_list (&((struct rlc_am_entity *) rlcP)->pdus_to_mac_layer_ch1, &data_req.data);
   while (nb_pdu_to_transmit > 0 ) {
      pdu = list_remove_head (&((struct rlc_am_entity *) rlcP)->pdus_to_mac_layer_ch1);
        if (pdu != null) {
         list_add_tail_eurecom (pdu, &data_req.data);
        } else {
          //msg ("[RLC_AM][RB %d] WARNING  MAC_DATA_REQUEST CANNOT GIVE A PDU REQUESTED BY MAC\n", ((struct rlc_am_entity *) rlcP)->rb_id);
        }
      nb_pdu_to_transmit = nb_pdu_to_transmit - 1;
  }
  //list_add_list (&((struct rlc_am_entity *) rlcP)->pdus_to_mac_layer_ch2, &data_req.data);

#ifdef DEBUG_RLC_AM_TX
  msg ("[RLC_AM][RB %d] MAC_DATA_REQUEST %d TBs (REQUESTED %d) Frame %d\n", ((struct rlc_am_entity *) rlcP)->rb_id, data_req.data.nb_elements,  ((struct rlc_am_entity *) rlcP)->nb_pdu_requested_by_mac_on_ch1 , Mac_rlc_xface->frame);
#endif
  data_req.buffer_occupancy_in_pdus = rlc_am_get_buffer_occupancy_in_pdus_ch1 ((struct rlc_am_entity *) rlcP);
  data_req.buffer_occupancy_in_pdus += rlc_am_get_buffer_occupancy_in_pdus_ch2 ((struct rlc_am_entity *) rlcP);
  data_req.buffer_occupancy_in_bytes = data_req.buffer_occupancy_in_pdus * ((struct rlc_am_entity *) rlcP)->pdu_size;
  data_req.rlc_info.rlc_protocol_state = ((struct rlc_am_entity *) rlcP)->protocol_state;
  return data_req;
}
Пример #8
0
void test_list_remove_data (void)
{
  list *l = list_empty();
  assert(list_remove_head(l) == NULL);
  element *tmp = NULL;
  
  element* e1 = element_init("plop");
  element* e2 = element_init("plap");
  element* e3 = element_init("plup");
  
  list_add_head(l,e1);
  list_add_head(l,e2);
  assert(list_remove_data(l,"plup") == NULL);
  list_add_head(l,e3);
  
  tmp = list_remove_data(l,"plup");
  assert( tmp == e3);
  assert(l->head == e2);
  free(tmp);

  tmp = list_remove_data(l,"plop");
  assert( tmp == e1);
  assert(l->head == e2);
  assert(e2->next == NULL);
  
  free(tmp);
  list_free(l);
  
  printf("Les tests de list_remove_data sont réussis!\n");
}
Пример #9
0
void HCI_Process(void)
{
  uint8_t data_len;
  uint8_t buffer[HCI_READ_PACKET_SIZE];
  tHciDataPacket * hciReadPacket = NULL;
  
  Disable_SPI_IRQ();
  uint8_t list_empty = list_is_empty(&hciReadPktRxQueue);        
  /* process any pending events read */
  while(list_empty == FALSE)
  {
    list_remove_head (&hciReadPktRxQueue, (tListNode **)&hciReadPacket);
    Enable_SPI_IRQ();
    HCI_Event_CB(hciReadPacket->dataBuff);
    Disable_SPI_IRQ();
    list_insert_tail(&hciReadPktPool, (tListNode *)hciReadPacket);
    list_empty = list_is_empty(&hciReadPktRxQueue);
  }
  if (readPacketListFull) {
    while(BlueNRG_DataPresent()) {
      data_len = BlueNRG_SPI_Read_All(&SpiHandle, buffer, HCI_READ_PACKET_SIZE);
      if(data_len > 0)
        HCI_Event_CB(buffer);
    }
    readPacketListFull = FALSE;
  }
  
  Enable_SPI_IRQ();    
}
Пример #10
0
static zx_status_t usb_midi_sink_write(void* ctx, const void* data, size_t length,
                                       zx_off_t offset, size_t* actual) {
    usb_midi_sink_t* sink = ctx;

    if (sink->dead) {
        return ZX_ERR_IO_NOT_PRESENT;
    }

    zx_status_t status = ZX_OK;
    size_t out_actual = length;

    const uint8_t* src = (uint8_t *)data;

    while (length > 0) {
        sync_completion_wait(&sink->free_write_completion, ZX_TIME_INFINITE);
        if (sink->dead) {
            return ZX_ERR_IO_NOT_PRESENT;
        }
        mtx_lock(&sink->mutex);
        list_node_t* node = list_remove_head(&sink->free_write_reqs);
        if (list_is_empty(&sink->free_write_reqs)) {
            sync_completion_reset(&sink->free_write_completion);
        }
        mtx_unlock(&sink->mutex);
        if (!node) {
            // shouldn't happen!
            status = ZX_ERR_INTERNAL;
            goto out;
        }
        usb_req_internal_t* req_int = containerof(node, usb_req_internal_t, node);
        usb_request_t* req = REQ_INTERNAL_TO_USB_REQ(req_int, sink->parent_req_size);

        size_t message_length = get_midi_message_length(*src);
        if (message_length < 1 || message_length > length) return ZX_ERR_INVALID_ARGS;

        uint8_t buffer[4];
        buffer[0] = (src[0] & 0xF0) >> 4;
        buffer[1] = src[0];
        buffer[2] = (message_length > 1 ? src[1] : 0);
        buffer[3] = (message_length > 2 ? src[2] : 0);

        usb_request_copy_to(req, buffer, 4, 0);
        req->header.length = 4;
        usb_request_complete_t complete = {
            .callback = usb_midi_sink_write_complete,
            .ctx = sink,
        };
        usb_request_queue(&sink->usb, req, &complete);

        src += message_length;
        length -= message_length;
    }

out:
    update_signals(sink);
    if (status == ZX_OK) {
        *actual = out_actual;
    }
    return status;
}
Пример #11
0
static void
trim_map_vdev_commit_done(spa_t *spa, vdev_t *vd)
{
	trim_map_t *tm = vd->vdev_trimmap;
	trim_seg_t *ts;
	list_t pending_writes;
	zio_t *zio;
	uint64_t start, size;
	void *cookie;

	ASSERT(vd->vdev_ops->vdev_op_leaf);

	if (tm == NULL)
		return;

	mutex_enter(&tm->tm_lock);
	if (!avl_is_empty(&tm->tm_inflight_frees)) {
		cookie = NULL;
		while ((ts = avl_destroy_nodes(&tm->tm_inflight_frees,
		    &cookie)) != NULL) {
			kmem_free(ts, sizeof (*ts));
		}
	}
	list_create(&pending_writes, sizeof (zio_t), offsetof(zio_t,
	    io_trim_link));
	list_move_tail(&pending_writes, &tm->tm_pending_writes);
	mutex_exit(&tm->tm_lock);

	while ((zio = list_remove_head(&pending_writes)) != NULL) {
		zio_vdev_io_reissue(zio);
		zio_execute(zio);
	}
	list_destroy(&pending_writes);
}
//-----------------------------------------------------------------------------
void
rlc_um_receive (
  const protocol_ctxt_t* const ctxt_pP,
  rlc_um_entity_t * const rlc_pP,
  struct mac_data_ind data_indP)
{
  //-----------------------------------------------------------------------------

  mem_block_t        *tb_p             = NULL;
  uint8_t               *first_byte_p     = NULL;
  uint16_t               tb_size_in_bytes = 0;

  while ((tb_p = list_remove_head (&data_indP.data))) {

    first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr;
    tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size;

    rlc_pP->stat_rx_data_bytes += tb_size_in_bytes;
    rlc_pP->stat_rx_data_pdu   += 1;

    if (tb_size_in_bytes > 0) {
      rlc_um_receive_process_dar (ctxt_pP, rlc_pP, tb_p, (rlc_um_pdu_sn_10_t*)first_byte_p, tb_size_in_bytes);
#if defined(TRACE_RLC_UM_RX)
      LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n",
            PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP),
            rlc_pP->vr_ur,
            rlc_pP->vr_ux,
            rlc_pP->vr_uh);
      //rlc_um_display_rx_window(rlc_pP); commented because bad display
#endif
    }
  }
}
Пример #13
0
void pipeline_destroy(struct pipeline *line)
{
	while (!list_is_empty(&line->pipe))
		umem_cache_free(pipestage_cache, list_remove_head(&line->pipe));

	umem_cache_free(pipeline_cache, line);
}
Пример #14
0
/*
 * Print these messages by running:
 * echo ::zfs_dbgmsg | mdb -k
 *
 * Monitor these messages by running:
 * 	dtrace -q -n 'zfs-dbgmsg{printf("%s\n", stringof(arg0))}'
 */
void
zfs_dbgmsg(const char *fmt, ...)
{
	int size;
	va_list adx;
	zfs_dbgmsg_t *zdm;

	va_start(adx, fmt);
	size = vsnprintf(NULL, 0, fmt, adx);
	va_end(adx);

	/*
	 * There is one byte of string in sizeof (zfs_dbgmsg_t), used
	 * for the terminating null.
	 */
	zdm = kmem_alloc(sizeof (zfs_dbgmsg_t) + size, KM_SLEEP);
	zdm->zdm_timestamp = gethrestime_sec();

	va_start(adx, fmt);
	(void) vsnprintf(zdm->zdm_msg, size + 1, fmt, adx);
	va_end(adx);

	DTRACE_PROBE1(zfs__dbgmsg, char *, zdm->zdm_msg);

	mutex_enter(&zfs_dbgmsgs_lock);
	list_insert_tail(&zfs_dbgmsgs, zdm);
	zfs_dbgmsg_size += sizeof (zfs_dbgmsg_t) + size;
	while (zfs_dbgmsg_size > zfs_dbgmsg_maxsize) {
		zdm = list_remove_head(&zfs_dbgmsgs);
		size = sizeof (zfs_dbgmsg_t) + strlen(zdm->zdm_msg);
		kmem_free(zdm, size);
		zfs_dbgmsg_size -= size;
	}
	mutex_exit(&zfs_dbgmsgs_lock);
}
Пример #15
0
static cbuf_t *
cbufq_deq_common(cbufq_t *cbufq, int remove)
{
	cbuf_t *head;

	if (list_is_empty(&cbufq->cbufq_bufs)) {
		VERIFY(cbufq->cbufq_count == 0);
		return (NULL);
	}

	VERIFY(cbufq->cbufq_count >= 1);
	cbufq->cbufq_count--;

	if (remove) {
		head = list_remove_head(&cbufq->cbufq_bufs);
	} else {
		head = list_head(&cbufq->cbufq_bufs);
	}

	/*
	 * Ensure the useful data in the buffer starts at index 0.
	 */
	cbuf_compact(head);

	return (head);
}
Пример #16
0
static int
splat_list_test7(struct file *file, void *arg)
{
	list_t list;
	list_item_t *li;
	int rc = 0;

	splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Creating list\n%s", "");
	list_create(&list, sizeof(list_item_t), offsetof(list_item_t, li_node));

	li = kmem_alloc(sizeof(list_item_t), KM_SLEEP);
	if (li == NULL) {
		rc = -ENOMEM;
		goto out;
	}

	/* Validate newly initialized node is inactive */
	splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Init list node\n%s", "");
	list_link_init(&li->li_node);
	if (list_link_active(&li->li_node)) {
		splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Newly initialized "
			    "list node should inactive %p/%p\n",
			    li->li_node.prev, li->li_node.next);
		rc = -EINVAL;
		goto out_li;
	}

	/* Validate node is active when linked in to a list */
	splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Insert list node\n%s", "");
	list_insert_head(&list, li);
	if (!list_link_active(&li->li_node)) {
		splat_vprint(file, SPLAT_LIST_TEST7_NAME, "List node "
			    "inserted in list should be active %p/%p\n",
			    li->li_node.prev, li->li_node.next);
		rc = -EINVAL;
		goto out;
	}

	/* Validate node is inactive when removed from list */
	splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Remove list node\n%s", "");
	list_remove(&list, li);
	if (list_link_active(&li->li_node)) {
		splat_vprint(file, SPLAT_LIST_TEST7_NAME, "List node "
			    "removed from list should be inactive %p/%p\n",
			    li->li_node.prev, li->li_node.next);
		rc = -EINVAL;
	}
out_li:
	kmem_free(li, sizeof(list_item_t));
out:
	/* Remove all items */
	while ((li = list_remove_head(&list)))
		kmem_free(li, sizeof(list_item_t));

	splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Destroying list\n%s", "");
	list_destroy(&list);

        return rc;
}
Пример #17
0
void HCI_Isr(void)
{
  tHciDataPacket * hciReadPacket = NULL;
  uint8_t data_len,i=0;
  uint8_t retries = 0;
  
  while(BlueNRG_DataPresent())
  {        
    if (list_is_empty (&hciReadPktPool) == FALSE){//check if we have free hci read packets
      
      /* enqueueing a packet for read */
      list_remove_head (&hciReadPktPool, (tListNode **)&hciReadPacket);
      
      data_len = BlueNRG_SPI_Read_All(hciReadPacket->dataBuff,HCI_READ_PACKET_SIZE);
      
      if(data_len > 0){   
        
        retries = 0;
        
        hciReadPacket->data_len = data_len;
        
        if(HCI_verify(hciReadPacket) == 0)
          list_insert_tail(&hciReadPktRxQueue, (tListNode *)hciReadPacket);
        else
          list_insert_head(&hciReadPktPool, (tListNode *)hciReadPacket);

        i++;
        if( i > HCI_READ_PACKET_NUM_MAX)
        {
            goto error;
        }
      }
      else 
      {
        // Insert the packet back into the pool.
        list_insert_head(&hciReadPktPool, (tListNode *)hciReadPacket);
        
        retries++; //Device was busy or did not respond correctly
        
        if(retries > 10)
        {    
            goto error;
        }
      }
    }
    else{
      // HCI Read Packet Pool is empty, wait for a free packet.
      readPacketListFull = TRUE;
      return;
    }

  }
  return;
  error:
  ISRDevice_busy = TRUE;
  return;
  
  
}
Пример #18
0
void *vmm_alloc_page() {
    void *page = list_remove_head(page_pool);
    assert(page != NULL);

    printf("Page pool has %d pages left\n", list_length(page_pool));

    return page;
}
Пример #19
0
static void move_list(tListNode * dest_list, tListNode * src_list)
{
  pListNode tmp_node;
  
  while(!list_is_empty(src_list)){
    list_remove_head(src_list, &tmp_node);
    list_insert_tail(dest_list, tmp_node);
  }
}
Пример #20
0
void list_free(list *l){
	element * el;
	el = l->head;
	while(!list_is_end_mark(l->head)){
		el = list_remove_head(l);
		free(el);
	}
	free(l);
}
Пример #21
0
int HCI_Process(void)
{
  uint8_t data_len;
  
  tHciDataPacket * hciReadPacket = NULL;
  uint8_t retries = 0;
  
  uint8_t list_empty = list_is_empty(&hciReadPktRxQueue);        
  /* process any pending events read */
  //events are added to tail in ISR
  while(list_empty == FALSE)
  {
    list_remove_head (&hciReadPktRxQueue, (tListNode **)&hciReadPacket);
 
    HCI_Event_CB(hciReadPacket->dataBuff);
    
    list_insert_tail(&hciReadPktPool, (tListNode *)hciReadPacket);
    
    list_empty = list_is_empty(&hciReadPktRxQueue); 
  }
  

    if (readPacketListFull)  //readPacketListFull is set in interrupt context
    {
        while(BlueNRG_DataPresent()) 
        {
            __debug_hci("Data too fast"); 
            
            data_len = BlueNRG_SPI_Read_All(HCI_Process_buffer, HCI_READ_PACKET_SIZE);
      
            if(data_len > 0)
            {
                HCI_Event_CB(hciReadPacket->dataBuff);
    
                retries = 0;
            }
            else
            {
                retries++;
                if(retries > 1)
                {
                    return -1;
                    break;
                }
                
            }
        }
        readPacketListFull = FALSE; //check if we ever get here
    }
    if(ISRDevice_busy == TRUE)
    {
        ISRDevice_busy = FALSE;
        return -2;
    }
    return 1;
}
Пример #22
0
static void
i_ilbadm_free_sgroup(ilbadm_sgroup_t *sg)
{
	ilbadm_servnode_t	*s;

	while ((s = list_remove_head(&sg->sg_serv_list)) != NULL)
		free(s);

	list_destroy(&sg->sg_serv_list);
}
Пример #23
0
//-----------------------------------------------------------------------------
void
list_free (list_t * listP)
{
//-----------------------------------------------------------------------------
  mem_block_t      *le;

  while ((le = list_remove_head (listP))) {
    free_mem_block (le);
  }
}
Пример #24
0
void queue_clear(queue_type *queue)
{
	int rc;

	if(!queue)
		return;

	do {
		rc = list_remove_head(queue->qlist);
	} while(!rc);
}
Пример #25
0
void
dsl_prop_fini(dsl_dir_t *dd)
{
	dsl_prop_record_t *pr;

	while ((pr = list_remove_head(&dd->dd_props)) != NULL) {
		list_destroy(&pr->pr_cbs);
		strfree((char *)pr->pr_propname);
		kmem_free(pr, sizeof (dsl_prop_record_t));
	}
	list_destroy(&dd->dd_props);
}
Пример #26
0
int queue_dequeue(queue_type *queue, void * value)
{
	int rc;

	if(!queue || !value)
		return EINVAL;

	rc = list_get_head(queue->qlist, value);
	if(rc)
		return rc;

	return list_remove_head(queue->qlist);
}
Пример #27
0
void
zfs_dbgmsg_fini(void)
{
	zfs_dbgmsg_t *zdm;

	while ((zdm = list_remove_head(&zfs_dbgmsgs)) != NULL) {
		int size = sizeof (zfs_dbgmsg_t) + strlen(zdm->zdm_msg);
		kmem_free(zdm, size);
		zfs_dbgmsg_size -= size;
	}
	mutex_destroy(&zfs_dbgmsgs_lock);
	ASSERT0(zfs_dbgmsg_size);
}
Пример #28
0
int main(int argc, char **argv)
{
	struct person *p;
	int tmp_age;
	char tmp_name[32];
	int i, n;

	list_t *l = list_init();
	node_t *tmp_node;

	printf("Number of people: ");
	scanf("%d", &n);

	for (i = 0; i < n; ++i) {
		p = (struct person*)malloc(sizeof(struct person));
		assert(p != NULL);
		printf("age: ");
		scanf("%d", &p->age);
		while(getchar()!='\n');
		printf("name: ");
		fgets(p->name, 32, stdin);
		p->name[strlen(p->name) - 1] = '\0';

		tmp_node = node_init(p);
		list_insert(l, tmp_node);
	}
	printf("List length: %d\n", l->length);

	printf("Traverse list forward\n");
	list_traverse(l, LIST_FORWARD, dump_data);
	printf("Traverse list backward\n");
	list_traverse(l, LIST_BACKWARD, dump_data);		

	tmp_node = list_remove_head(l);
	printf("Removed node: \n");
	dump_data(tmp_node);
	free(tmp_node);
	printf("New list. List length = %d\n", l->length);
	list_traverse(l, LIST_FORWARD, dump_data);

	tmp_node = list_remove_tail(l);
	printf("Removed node: \n");	
	dump_data(tmp_node);
	free(tmp_node);
	printf("New list. List length = %d\n", l->length);
	list_traverse(l, LIST_FORWARD, dump_data);

	list_free(l);
	
	return 0;
}
Пример #29
0
LPFC_MBOXQ_t *
lpfc_mbox_get(struct lpfc_hba * phba)
{
	LPFC_MBOXQ_t *mbq = NULL;
	struct lpfc_sli *psli = &phba->sli;

	list_remove_head((&psli->mboxq), mbq, LPFC_MBOXQ_t,
			 list);
	if (mbq) {
		psli->mboxq_cnt--;
	}

	return mbq;
}
Пример #30
0
void
zfs_dbgmsg_fini(void)
{
#if !defined(_KERNEL) || !defined(__linux__)
	zfs_dbgmsg_t *zdm;

	while ((zdm = list_remove_head(&zfs_dbgmsgs)) != NULL) {
		int size = sizeof (zfs_dbgmsg_t) + strlen(zdm->zdm_msg);
		kmem_free(zdm, size);
		zfs_dbgmsg_size -= size;
	}
	mutex_destroy(&zfs_dbgmsgs_lock);
	ASSERT0(zfs_dbgmsg_size);
#endif
}