source: trunk/libs/newlib/src/libgloss/sparc_leon/asm-leon/leonbare_kernel_queue.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 6.5 KB
Line 
1//####BSDCOPYRIGHTBEGIN####
2//
3// -------------------------------------------
4//
5// Portions of this software may have been derived from OpenBSD,
6// FreeBSD or other sources, and are covered by the appropriate
7// copyright disclaimers included herein.
8//
9// Portions created by Red Hat are
10// Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
11//
12// -------------------------------------------
13//
14//####BSDCOPYRIGHTEND####
15//==========================================================================
16
17/*
18 * Copyright (c) 1991, 1993
19 *      The Regents of the University of California.  All rights reserved.
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
23 * are met:
24 * 1. Redistributions of source code must retain the above copyright
25 *    notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 *    notice, this list of conditions and the following disclaimer in the
28 *    documentation and/or other materials provided with the distribution.
29 * 3. All advertising materials mentioning features or use of this software
30 *    must display the following acknowledgement:
31 *      This product includes software developed by the University of
32 *      California, Berkeley and its contributors.
33 * 4. Neither the name of the University nor the names of its contributors
34 *    may be used to endorse or promote products derived from this software
35 *    without specific prior written permission.
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
38 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
41 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
43 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 *
49 *      @(#)queue.h     8.5 (Berkeley) 8/20/94
50 * $FreeBSD: src/sys/sys/queue.h,v 1.32.2.4 2001/03/31 03:33:39 hsu Exp $
51 */
52
53#ifndef _SYS_LEONBARE_QUEUE_H_
54#define _SYS_LEONBARE_QUEUE_H_
55
56
57/*
58 * Tail queue definitions.
59 */
60#define LBTAILQ_HEAD(name, type)                                                \
61struct name {                                                           \
62        struct type *tqh_first; /* first element */                     \
63        struct type **tqh_last; /* addr of last next element */         \
64        char *tqh_name;                                                 \
65}
66
67#define LBTAILQ_HEAD_INITIALIZER(head)                                  \
68        { NULL, &(head).tqh_first, 0 }
69
70#define LBTAILQ_ENTRY(type)                                             \
71struct {                                                                \
72        struct type *tqe_next;  /* next element */                      \
73        struct type **tqe_prev; /* address of previous next element */  \
74}
75
76/*
77 * Tail queue functions.
78 */
79#define LBTAILQ_EMPTY(head) (LEONBARE_KERNEL_GETU32P((head)->tqh_first) == NULL)
80
81#define LBTAILQ_HASTWO(head, field) ((!LBTAILQ_EMPTY(head)) && LBTAILQ_NEXT(LBTAILQ_FIRST(head),field))
82
83#define LBTAILQ_FOREACH(var, head, field)                                       \
84        for (var = LBTAILQ_FIRST(head); var; var = LBTAILQ_NEXT(var, field))
85
86#define LBTAILQ_FIRST(head) LEONBARE_KERNEL_GETU32P_CAST((head)->tqh_first,__typeof((head)->tqh_first))
87
88#define LBTAILQ_LAST(head, headname) \
89        LEONBARE_KERNEL_GETU32P_BARE(LEONBARE_KERNEL_GETU32P(((struct headname *)(LEONBARE_KERNEL_GETU32P((head)->tqh_last)))->tqh_last))
90
91#define LBTAILQ_NEXT(elm, field) LEONBARE_KERNEL_GETU32P_CAST((elm)->field.tqe_next,__typeof((elm)->field.tqe_next))
92
93#define LBTAILQ_PREV(elm, headname, field) \
94        LEONBARE_KERNEL_GETU32P_BARE(LEONBARE_KERNEL_GETU32P(((struct headname *)(LEONBARE_KERNEL_GETU32P((elm)->field.tqe_prev)))->tqh_last))
95
96/* #define      LBTAILQ_INIT(head) do {                                         \ */
97/*      (head)->tqh_first = NULL;                                       \ */
98/*      (head)->tqh_last = &(head)->tqh_first;                          \ */
99/*         (head)->tqh_name = 0;                                           \ */
100/* } while (0) */
101
102#define LBTAILQ_INIT(head) do {                                         \
103        LEONBARE_KERNEL_SETU32P((head)->tqh_first,NULL);                \
104        LEONBARE_KERNEL_SETU32P((head)->tqh_last,&(head)->tqh_first);   \
105        LEONBARE_KERNEL_SETU32P((head)->tqh_name,0);                    \
106} while (0)
107
108/* #define LBTAILQ_INSERT_HEAD(head, elm, field) do {                   \ */
109/*      if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)        \ */
110/*              (head)->tqh_first->field.tqe_prev =                     \ */
111/*                  &(elm)->field.tqe_next;                             \ */
112/*      else                                                            \ */
113/*              (head)->tqh_last = &(elm)->field.tqe_next;              \ */
114/*      (head)->tqh_first = (elm);                                      \ */
115/*      (elm)->field.tqe_prev = &(head)->tqh_first;                     \ */
116/* } while (0) */
117
118#define LBTAILQ_INSERT_HEAD(head, elm, field) do {                      \
119        if ((LEONBARE_KERNEL_SETU32P((elm)->field.tqe_next,LEONBARE_KERNEL_GETU32P((head)->tqh_first))) != NULL) \
120            LEONBARE_KERNEL_SETU32P(LEONBARE_KERNEL_GETU32P_CAST((head)->tqh_first,__typeof ((head)->tqh_first))->field.tqe_prev,&(elm)->field.tqe_next); \
121        else                                                            \
122            LEONBARE_KERNEL_SETU32P((head)->tqh_last,&(elm)->field.tqe_next); \
123        LEONBARE_KERNEL_SETU32P((head)->tqh_first,(elm));               \
124        LEONBARE_KERNEL_SETU32P((elm)->field.tqe_prev,&(head)->tqh_first); \
125} while (0)
126
127#define LBTAILQ_INSERT_TAIL(head, elm, field) do {                      \
128        LEONBARE_KERNEL_SETU32P((elm)->field.tqe_next,NULL);            \
129        LEONBARE_KERNEL_SETU32P((elm)->field.tqe_prev,LEONBARE_KERNEL_GETU32P((head)->tqh_last)); \
130        LEONBARE_KERNEL_SETU32P_BARE(LEONBARE_KERNEL_GETU32P((head)->tqh_last),(elm)); \
131        LEONBARE_KERNEL_SETU32P((head)->tqh_last,&(elm)->field.tqe_next); \
132} while (0)
133
134#define LBTAILQ_REMOVE(head, elm, field) do {                           \
135        if (LEONBARE_KERNEL_GETU32P((elm)->field.tqe_next) != NULL)     \
136            LEONBARE_KERNEL_SETU32P(LEONBARE_KERNEL_GETU32P_CAST((elm)->field.tqe_next, __typeof((elm)->field.tqe_next))->field.tqe_prev, LEONBARE_KERNEL_GETU32P((elm)->field.tqe_prev)); \
137        else                                                            \
138            LEONBARE_KERNEL_SETU32P((head)->tqh_last, LEONBARE_KERNEL_GETU32P((elm)->field.tqe_prev)); \
139        LEONBARE_KERNEL_SETU32P_BARE(LEONBARE_KERNEL_GETU32P((elm)->field.tqe_prev),LEONBARE_KERNEL_GETU32P((elm)->field.tqe_next)); \
140        LEONBARE_KERNEL_SETU32P((elm)->field.tqe_next, 0);              \
141        LEONBARE_KERNEL_SETU32P((elm)->field.tqe_prev, 0);     /* mark removed */ \
142} while (0)
143
144#define LBTAILQ_REMOVED(elm, field) (LEONBARE_KERNEL_GETU32P((elm)->field.tqe_next) == NULL && LEONBARE_KERNEL_GETU32P((elm)->field.tqe_prev) == NULL)
145
146
147
148#endif /* !_SYS_QUEUE_H_ */
Note: See TracBrowser for help on using the repository browser.