📄 dll.c
字号:
/* Restore the previous interrupt lockout level. */
NU_Control_Interrupts(old_level);
//Tao_LoadOldSR();
/* Return a pointer to the removed node */
return(ent);
} /* end dll_dequeue */
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* dll_remove */
/* */
/* DESCRIPTION */
/* */
/* Remove a node and return a pointer to the succeeding node. */
/* */
/* CALLED BY */
/* */
/* CALLS */
/* */
/* none */
/* */
/*************************************************************************/
tqe_t *dll_remove(tqe_t *hdr, tqe_t *item)
{
tqe_t *ent,
*retval;
/* Search the linked list until item is found or the end of the list
* is reached.
*/
for (ent = hdr->flink;( (ent) && (ent != item) ); ent = ent->flink)
;
/* If item was not before reaching the end of the list, return a
* pointer to 0.
*/
if (!ent) {
return( (tqe_t *)0 );
}
/* Keep a pointer to the node to be returned */
retval = item->flink;
/* If we're deleting the list head, this is just a dequeue operation */
if (hdr->flink == item)
dll_dequeue(hdr);
else
/* If we are deleting the list tail, we need to reset the tail pointer
* and make the new tail point forward to 0.
*/
if (hdr->blink == item) {
hdr->blink = item->blink;
hdr->blink->flink = (tqe_t *)0;
}
else /* We're removing this entry from the middle of the list */
{
item->blink->flink = item->flink;
item->flink->blink = item->blink;
}
/* return a pointer to the removed node */
return(retval);
}
/****************************************************************************/
/* FUNCTION */
/* */
/* dll_update_lists */
/* */
/* DESCRIPTION */
/* */
/* This function removes the first node from the source list and places */
/* it at the tail of the destination list. */
/* */
/* AUTHOR */
/* */
/* Craig L. Meredith, Accelerated Technology Inc. */
/* */
/* CALLED BY */
/* */
/* demux */
/* */
/* CALLS */
/* */
/* NU_Control_Interrupts */
/* dll_enqueue */
/* dll_dequeue */
/* */
/* INPUTS */
/* */
/* No inputs to the function */
/* */
/* OUTPUTS */
/* */
/* No outputs from this function */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Craig L. Meredith 02/07/94 Initial version. */
/* Glen Johnson 10/27/94 Update for release 1.0.G1.E */
/* */
/****************************************************************************/
BUFFER *dll_update_lists (struct pqueue_hdr HUGE *source,
struct pqueue_hdr HUGE *dest)
{
BUFFER *tmp_ptr;
#ifdef PLUS
INT old_level;
#else
int old_level;
#endif
/* Temporarily lockout interrupts to protect the global buffer variables. */
// old_level = NU_Control_Interrupts(NU_DISABLE_INTERRUPTS);
//modified by Tao
// Tao_SaveOldSR();
tmp_ptr = (BUFFER *)dll_dequeue((tqe_t *)source);
if (tmp_ptr != NU_NULL)
{
dll_enqueue((tqe_t *)dest, (tqe_t *)tmp_ptr);
}
/* Restore the previous interrupt lockout level. */
// NU_Control_Interrupts(old_level);
// Tao_LoadOldSR();
return(tmp_ptr);
} /* end dll_update_lists routine */
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* dll_transq_alloc */
/* */
/* DESCRIPTION */
/* */
/* Get an entry of off the trans_freelist. If none are available */
/* then allocate it. */
/* */
/* CALLED BY */
/* */
/* tcpsend */
/* tcp_sendack */
/* */
/* CALLS */
/* */
/* dll_dequeue */
/* NU_Allocate_Memory */
/* */
/*************************************************************************/
struct transq *dll_transq_alloc(VOID)
{
struct transq *item;
STATUS status;
VOID *return_ptr;
item = (struct transq *) dll_dequeue ((tqe_t *) &trans_freelist);
/* If the free list is empty allocate memory for a new entry. */
if (!item)
{
count_trans++;
/* Get some memory for the new entry. */
#ifdef PLUS
status = NU_Allocate_Memory(&System_Memory, (VOID *) &return_ptr,
(UNSIGNED)sizeof(struct transq),
(UNSIGNED)NU_NO_SUSPEND);
#else
status = NU_Alloc_Memory (sizeof(struct transq),
(unsigned int **)&return_ptr,
NU_WAIT_FOREVER);
#endif
/* check status of memory allocation */
if (status == NU_SUCCESS)
{
return_ptr = normalize_ptr(return_ptr);
item = (struct transq *)return_ptr;
return (item);
}
else
{
NU_Tcp_Log_Error (TCP_SESS_MEM, TCP_RECOVERABLE,
__FILE__, __LINE__);
return (struct transq *)NU_NULL;
}
}
else
return (item);
}
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* dll_cleanup */
/* */
/* DESCRIPTION */
/* */
/* This function takes a list header and moves all of the buffers of */
/* off the list and onto the buffer_freelist. Mainly used to */
/* deallocate any unprocessed buffers when ever a TCP connection is */
/* closed. */
/* */
/* CALLED BY */
/* tcpdo */
/* */
/* CALLS */
/* */
/* dll_update_lists */
/* */
/* INPUTS */
/* hdr pointer to the head of a linked list. */
/* */
/* OUTPUTS */
/* */
/* none */
/* */
/* HISTORY */
/* NAME DATE REMARKS */
/* */
/* G. Johnson 04/25/95 Created initial version. */
/* */
/*************************************************************************/
VOID dll_cleanup(struct pqueue_hdr HUGE *hdr)
{
while(dll_update_lists(hdr, &buffer_freelist) != NU_NULL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -