OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-s390x/] [queue.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *  include/asm-s390/queue.h
3
 *
4
 *  S390 version
5
 *    Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6
 *    Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
7
 *
8
 *  A little set of queue utilies.
9
 */
10
#ifndef __ASM_QUEUE_H
11
#define __ASM_QUEUE_H
12
#include <linux/stddef.h>
13
 
14
typedef struct queue
15
{
16
        struct queue *next;
17
} queue;
18
 
19
typedef queue list;
20
 
21
typedef struct
22
{
23
        queue *head;
24
        queue *tail;
25
} qheader;
26
 
27
static __inline__ void init_queue(qheader *qhead)
28
{
29
        memset(qhead,0,sizeof(*qhead));
30
}
31
 
32
static __inline__ void enqueue_tail(qheader *qhead,queue *member)
33
{
34
        if(member)
35
        {
36
                queue *tail=qhead->tail;
37
 
38
                if(tail)
39
                        tail->next=member;
40
                else
41
 
42
                        qhead->head=member;
43
                qhead->tail=member;
44
                member->next=NULL;
45
        }
46
}
47
 
48
static __inline__ queue *dequeue_head(qheader *qhead)
49
{
50
        queue *head=qhead->head,*next_head;
51
 
52
        if(head)
53
        {
54
                next_head=head->next;
55
                qhead->head=next_head;
56
                if(!next_head)
57
                        qhead->tail=NULL;
58
        }
59
        return(head);
60
}
61
 
62
static __inline__ void init_list(list **lhead)
63
{
64
        *lhead=NULL;
65
}
66
 
67
static __inline__ void add_to_list(list **lhead,list *member)
68
{
69
        member->next=*lhead;
70
        *lhead=member;
71
}
72
 
73
static __inline__ list *remove_listhead(list **lhead)
74
{
75
        list *oldhead=*lhead;
76
 
77
        if(oldhead)
78
                *lhead=(*lhead)->next;
79
        return(oldhead);
80
}
81
 
82
static __inline__ void add_to_list_tail(list **lhead,list *member)
83
{
84
        list *curr,*prev;
85
        if(*lhead==NULL)
86
                *lhead=member;
87
        else
88
        {
89
                prev=*lhead;
90
                for(curr=(*lhead)->next;curr!=NULL;curr=curr->next)
91
                        prev=curr;
92
                prev->next=member;
93
        }
94
}
95
static __inline__ void add_to_list_tail_null(list **lhead,list *member)
96
{
97
        member->next=NULL;
98
        add_to_list_tail_null(lhead,member);
99
}
100
 
101
 
102
static __inline__ int is_in_list(list *lhead,list *member)
103
{
104
        list *curr;
105
 
106
        for(curr=lhead;curr!=NULL;curr=curr->next)
107
                if(curr==member)
108
                        return(1);
109
        return(0);
110
}
111
 
112
static __inline__ int get_prev(list *lhead,list *member,list **prev)
113
{
114
        list *curr;
115
 
116
        *prev=NULL;
117
        for(curr=lhead;curr!=NULL;curr=curr->next)
118
        {
119
                if(curr==member)
120
                        return(1);
121
                *prev=curr;
122
        }
123
        *prev=NULL;
124
        return(0);
125
}
126
 
127
 
128
 
129
static __inline__ int remove_from_list(list **lhead,list *member)
130
{
131
        list *prev;
132
 
133
        if(get_prev(*lhead,member,&prev))
134
        {
135
 
136
                if(prev)
137
                        prev->next=member->next;
138
                else
139
                        *lhead=member->next;
140
                return(1);
141
        }
142
        return(0);
143
}
144
 
145
static __inline__ int remove_from_queue(qheader *qhead,queue *member)
146
{
147
        queue *prev;
148
 
149
        if(get_prev(qhead->head,(list *)member,(list **)&prev))
150
        {
151
 
152
                if(prev)
153
                {
154
                        prev->next=member->next;
155
                        if(prev->next==NULL)
156
                                qhead->tail=prev;
157
                }
158
                else
159
                {
160
                        if(qhead->head==qhead->tail)
161
                                qhead->tail=NULL;
162
                        qhead->head=member->next;
163
                }
164
                return(1);
165
        }
166
        return(0);
167
}
168
 
169
#endif /* __ASM_QUEUE_H */
170
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.