patch-2.2.16 linux/include/asm-s390/queue.h

Next file: linux/include/asm-s390/s390-regs-common.h
Previous file: linux/include/asm-s390/ptrace.h
Back to the patch index
Back to the overall index

diff -urN v2.2.15/linux/include/asm-s390/queue.h linux/include/asm-s390/queue.h
@@ -2,18 +2,21 @@
  *  include/asm-s390/queue.h
  *
  *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ *    Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
  *    Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
  *
  *  A little set of queue utilies.
  */
 #include <linux/stddef.h>
+#include <asm/types.h>
 
 typedef struct queue
 {
 	struct queue *next;	
 } queue;
 
+typedef queue list;
+
 typedef struct
 {
 	queue *head;
@@ -56,9 +59,103 @@
 	return(head);
 }
 
+static __inline__ void init_list(list **lhead)
+{
+	*lhead=NULL;
+}
+
+static __inline__ void add_to_list(list **lhead,list *member)
+{
+	member->next=*lhead;
+	*lhead=member;
+}
+
+static __inline__ void add_to_list_tail(list **lhead,list *member)
+{
+	list *curr,*prev;
+	if(*lhead==NULL)
+		*lhead=member;
+	else
+	{
+		prev=*lhead;
+		for(curr=(*lhead)->next;curr!=NULL;curr=curr->next)
+			prev=curr;
+		prev->next=member;
+	}
+}
+static __inline__ void add_to_list_tail_null(list **lhead,list *member)
+{
+	member->next=NULL;
+	add_to_list_tail_null(lhead,member);
+}
+
+
+static __inline__ int is_in_list(list *lhead,list *member)
+{
+	list *curr;
+
+	for(curr=lhead;curr!=NULL;curr=curr->next)
+		if(curr==member)
+			return(TRUE);
+	return(FALSE);
+}
+
+static __inline__ int get_prev(list *lhead,list *member,list **prev)
+{
+	list *curr;
+
+	*prev=NULL;
+	for(curr=lhead;curr!=NULL;curr=curr->next)
+	{
+		if(curr==member)
+			return(TRUE);
+		*prev=curr;
+	}
+	*prev=NULL;
+	return(FALSE);
+}
+
+
+
+static __inline__ int remove_from_list(list **lhead,list *member)
+{
+	list *prev;
+
+	if(get_prev(*lhead,member,&prev))
+	{
+
+		if(prev)
+			prev->next=member->next;
+		else
+			*lhead=member->next;
+		return(TRUE);
+	}
+	return(FALSE);
+}
 
+static __inline__ int remove_from_queue(qheader *qhead,queue *member)
+{
+	queue *prev;
 
+	if(get_prev(qhead->head,(list *)member,(list **)&prev))
+	{
 
+		if(prev)
+		{
+			prev->next=member->next;
+			if(prev->next==NULL)
+				qhead->tail=prev;
+		}
+		else
+		{
+			if(qhead->head==qhead->tail)
+				qhead->tail=NULL;
+			qhead->head=member->next;
+		}
+		return(TRUE);
+	}
+	return(FALSE);
+}
 
 
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)