File: llist.h

package info (click to toggle)
dmx4linux 2.5%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,660 kB
  • ctags: 2,835
  • sloc: ansic: 23,341; yacc: 918; asm: 846; makefile: 614; sh: 439
file content (74 lines) | stat: -rw-r--r-- 1,905 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * llist.h
 *
 * Copyright (C) Michael Stickel <michael@cubic.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
/*
 * These are templates for Linked-List operations in C.
 * The List elements needs to have a next-pointer.
 * If unsure add a Line like LIST_HEAD(MyType) to the struct
 * with the type-name MyType.
 * examples are at the end of this file.
 */
#ifndef __DMX4L_LLIST_H__
#define __DMX4L_LLIST_H__

#define LLIST_HEAD(Type)  Type *next

#define LLIST_INSERT(root,elem) \
      ((elem)->next = (root), (root) = (elem))


#define LLIST_REMOVE(root,elem) \
  { \
    typeof(root) ii = root; \
    if ((elem) == ii) \
      root = (elem)->next; \
    else \
      { \
        while (ii->next) \
          { \
            if (ii->next == (elem)) \
              { \
                ii->next = (elem)->next; \
                (elem)->next = NULL; \
              } \
            else \
              ii = ii->next; \
          } \
      } \
  }



/* Example:
  struct MyElem
  {
    MyElem *next;   or   LIST_HEAD(MyElem);
    ....
  };


  static int dmx_remove_interface (DMXInterface *i)
  {
    if (i && i->driver && i->driver->interfaces)
        LIST_REMOVE(i->driver->interface, i);
    return 0;
  }
*/

#endif