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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [compat/] [linux/] [v2_0/] [include/] [linux/] [list.h] - Blame information for rev 27

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

Line No. Rev Author Line
1 27 unneback
/*
2
 * JFFS2 -- Journalling Flash File System, Version 2.
3
 *
4
 * Copyright (C) 2002 Red Hat, Inc.
5
 *
6
 * Created by Jonathan Larmour <jlarmour@redhat.com>
7
 *
8
 *===========================================================================
9
 *####ECOSGPLCOPYRIGHTBEGIN####
10
 * -------------------------------------------
11
 * This file is part of eCos, the Embedded Configurable Operating System.
12
 * Copyright (C) 2003 Red Hat.
13
 *
14
 * eCos is free software; you can redistribute it and/or modify it under
15
 * the terms of the GNU General Public License as published by the Free
16
 * Software Foundation; either version 2 or (at your option) any later version.
17
 *
18
 * eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
 * for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License along
24
 * with eCos; if not, write to the Free Software Foundation, Inc.,
25
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26
 *
27
 * As a special exception, if other files instantiate templates or use macros
28
 * or inline functions from this file, or you compile this file and link it
29
 * with other works to produce a work based on this file, this file does not
30
 * by itself cause the resulting work to be covered by the GNU General Public
31
 * License. However the source code for this file must still be made available
32
 * in accordance with section (3) of the GNU General Public License.
33
 *
34
 * This exception does not invalidate any other reasons why a work based on
35
 * this file might be covered by the GNU General Public License.
36
 *
37
 * Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38
 * at http://sources.redhat.com/ecos/ecos-license/
39
 * -------------------------------------------
40
 *####ECOSGPLCOPYRIGHTEND####
41
 *===========================================================================
42
 *
43
 */
44
 
45
#ifndef CYGONCE_FS_JFFS2_LIST_H
46
#define CYGONCE_FS_JFFS2_LIST_H
47
 
48
 
49
/* -----------------------------------------------------------------------*/
50
 
51
/* Doubly linked list implementation to replace the GPL'd one used in
52
   the Linux kernel. */
53
 
54
#include <stddef.h>
55
#include <cyg/infra/cyg_type.h>
56
 
57
/* TYPES */
58
 
59
struct list_head {
60
    struct list_head *next;
61
    struct list_head *prev;
62
};
63
 
64
/* MACROS */
65
 
66
#define INIT_LIST_HEAD( _list_ )              \
67
CYG_MACRO_START                               \
68
(_list_)->next = (_list_)->prev = (_list_);   \
69
CYG_MACRO_END
70
 
71
/* FUNCTIONS */
72
 
73
/* Insert an entry _after_ the specified entry */
74
static __inline__ void
75
list_add( struct list_head *newent, struct list_head *afterthisent )
76
{
77
    struct list_head *next = afterthisent->next;
78
    newent->next = next;
79
    newent->prev = afterthisent;
80
    afterthisent->next = newent;
81
    next->prev = newent;
82
} /* list_add() */
83
 
84
/* Insert an entry _before_ the specified entry */
85
static __inline__ void
86
list_add_tail( struct list_head *newent, struct list_head *beforethisent )
87
{
88
    struct list_head *prev = beforethisent->prev;
89
    newent->prev = prev;
90
    newent->next = beforethisent;
91
    beforethisent->prev = newent;
92
    prev->next = newent;
93
} /* list_add_tail() */
94
 
95
/* Delete the specified entry */
96
static __inline__ void
97
list_del( struct list_head *ent )
98
{
99
    ent->prev->next = ent->next;
100
    ent->next->prev = ent->prev;
101
} /* list_del() */
102
 
103
/* Is this list empty? */
104
static __inline__ int
105
list_empty( struct list_head *list )
106
{
107
    return ( list->next == list );
108
} /* list_empty() */
109
 
110
/* list_entry - Assuming you have a struct of type _type_ that contains a
111
   list which has the name _member_ in that struct type, then given the
112
   address of that list in the struct, _list_, this returns the address
113
   of the container structure */
114
 
115
#define list_entry( _list_, _type_, _member_ ) \
116
    ((_type_ *)((char *)(_list_)-(char *)(offsetof(_type_,_member_))))
117
 
118
/* list_for_each - using _ent_, iterate through list _list_ */
119
 
120
#define list_for_each( _ent_, _list_ )   \
121
    for ( (_ent_) = (_list_)->next;      \
122
    (_ent_) != (_list_);                 \
123
    (_ent_) = (_ent_)->next )
124
 
125
/* -----------------------------------------------------------------------*/
126
#endif /* #ifndef CYGONCE_FS_JFFS2_LIST_H */
127
/* EOF list.h */

powered by: WebSVN 2.1.0

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