~ubuntu-branches/ubuntu/trusty/systemd/trusty

« back to all changes in this revision

Viewing changes to src/shared/list.h

  • Committer: Package Import Robot
  • Author(s): Michael Biebl, Michael Biebl, Michael Stapelberg, Daniel Schaal, Ondrej Balaz
  • Date: 2013-09-12 00:13:11 UTC
  • mfrom: (1.1.11) (9.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: package-import@ubuntu.com-20130912001311-dz35it34wr2lbday
Tags: 204-3
[ Michael Biebl ]
* Upload to unstable.
* Use /bin/bash in debug-shell.service as Debian doesn't have /sbin/sushell.
* Only import net.ifaces cmdline property for network devices.
* Generate strict dependencies between the binary packages using a
  shlibs.local file and add an explicit versioned dependency on
  libsystemd-login0 to systemd to ensure packages are upgraded in sync.
  Closes: #719444
* Drop obsolete Replaces: libudev0 from udev package.
* Use correct paths for various binaries, like /sbin/quotaon, which are
  installed in / and not /usr in Debian.  Closes: #721347
* Don't install kernel-install(8) man page since we don't install the
  corresponding binary either.  Closes: #722180
* Cherry-pick upstream fixes to make switching runlevels and starting
  reboot via ctrl-alt-del more robust.
* Cherry-pick upstream fix to properly apply ACLs to Journal files.

[ Michael Stapelberg ]
* Make systemctl enable|disable call update-rc.d for SysV init scripts.
  Closes: #709780
* Don't mount /tmp as tmpfs by default and make it possible to enable this
  feature via "systemctl enable tmp.mount".

[ Daniel Schaal ]
* Add bug-script to systemd and udev.  Closes: #711245

[ Ondrej Balaz ]
* Recognize discard option in /etc/crypttab.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
2
 
 
3
#pragma once
 
4
 
 
5
/***
 
6
  This file is part of systemd.
 
7
 
 
8
  Copyright 2010 Lennart Poettering
 
9
 
 
10
  systemd is free software; you can redistribute it and/or modify it
 
11
  under the terms of the GNU Lesser General Public License as published by
 
12
  the Free Software Foundation; either version 2.1 of the License, or
 
13
  (at your option) any later version.
 
14
 
 
15
  systemd is distributed in the hope that it will be useful, but
 
16
  WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
18
  Lesser General Public License for more details.
 
19
 
 
20
  You should have received a copy of the GNU Lesser General Public License
 
21
  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 
22
***/
 
23
 
 
24
/* The head of the linked list. Use this in the structure that shall
 
25
 * contain the head of the linked list */
 
26
#define LIST_HEAD(t,name)                                               \
 
27
        t *name
 
28
 
 
29
/* The pointers in the linked list's items. Use this in the item structure */
 
30
#define LIST_FIELDS(t,name)                                             \
 
31
        t *name##_next, *name##_prev
 
32
 
 
33
/* Initialize the list's head */
 
34
#define LIST_HEAD_INIT(t,head)                                          \
 
35
        do {                                                            \
 
36
                (head) = NULL; }                                        \
 
37
        while(false)
 
38
 
 
39
/* Initialize a list item */
 
40
#define LIST_INIT(t,name,item)                                          \
 
41
        do {                                                            \
 
42
                t *_item = (item);                                      \
 
43
                assert(_item);                                          \
 
44
                _item->name##_prev = _item->name##_next = NULL;         \
 
45
        } while(false)
 
46
 
 
47
/* Prepend an item to the list */
 
48
#define LIST_PREPEND(t,name,head,item)                                  \
 
49
        do {                                                            \
 
50
                t **_head = &(head), *_item = (item);                   \
 
51
                assert(_item);                                          \
 
52
                if ((_item->name##_next = *_head))                      \
 
53
                        _item->name##_next->name##_prev = _item;        \
 
54
                _item->name##_prev = NULL;                              \
 
55
                *_head = _item;                                         \
 
56
        } while(false)
 
57
 
 
58
/* Remove an item from the list */
 
59
#define LIST_REMOVE(t,name,head,item)                                   \
 
60
        do {                                                            \
 
61
                t **_head = &(head), *_item = (item);                   \
 
62
                assert(_item);                                          \
 
63
                if (_item->name##_next)                                 \
 
64
                        _item->name##_next->name##_prev = _item->name##_prev; \
 
65
                if (_item->name##_prev)                                 \
 
66
                        _item->name##_prev->name##_next = _item->name##_next; \
 
67
                else {                                                  \
 
68
                        assert(*_head == _item);                        \
 
69
                        *_head = _item->name##_next;                    \
 
70
                }                                                       \
 
71
                _item->name##_next = _item->name##_prev = NULL;         \
 
72
        } while(false)
 
73
 
 
74
/* Find the head of the list */
 
75
#define LIST_FIND_HEAD(t,name,item,head)                                \
 
76
        do {                                                            \
 
77
                t *_item = (item);                                      \
 
78
                assert(_item);                                          \
 
79
                while (_item->name##_prev)                              \
 
80
                       _item = _item->name##_prev;                      \
 
81
                (head) = _item;                                         \
 
82
        } while (false)
 
83
 
 
84
/* Find the head of the list */
 
85
#define LIST_FIND_TAIL(t,name,item,tail)                                \
 
86
        do {                                                            \
 
87
                t *_item = (item);                                      \
 
88
                assert(_item);                                          \
 
89
                while (_item->name##_next)                              \
 
90
                        _item = _item->name##_next;                     \
 
91
                (tail) = _item;                                         \
 
92
        } while (false)
 
93
 
 
94
/* Insert an item after another one (a = where, b = what) */
 
95
#define LIST_INSERT_AFTER(t,name,head,a,b)                              \
 
96
        do {                                                            \
 
97
                t **_head = &(head), *_a = (a), *_b = (b);              \
 
98
                assert(_b);                                             \
 
99
                if (!_a) {                                              \
 
100
                        if ((_b->name##_next = *_head))                 \
 
101
                                _b->name##_next->name##_prev = _b;      \
 
102
                        _b->name##_prev = NULL;                         \
 
103
                        *_head = _b;                                    \
 
104
                } else {                                                \
 
105
                        if ((_b->name##_next = _a->name##_next))        \
 
106
                                _b->name##_next->name##_prev = _b;      \
 
107
                        _b->name##_prev = _a;                           \
 
108
                        _a->name##_next = _b;                           \
 
109
                }                                                       \
 
110
        } while(false)
 
111
 
 
112
#define LIST_JUST_US(name,item)                                         \
 
113
        (!(item)->name##_prev && !(item)->name##_next)                  \
 
114
 
 
115
#define LIST_FOREACH(name,i,head)                                       \
 
116
        for ((i) = (head); (i); (i) = (i)->name##_next)
 
117
 
 
118
#define LIST_FOREACH_SAFE(name,i,n,head)                                \
 
119
        for ((i) = (head); (i) && (((n) = (i)->name##_next), 1); (i) = (n))
 
120
 
 
121
#define LIST_FOREACH_BEFORE(name,i,p)                                   \
 
122
        for ((i) = (p)->name##_prev; (i); (i) = (i)->name##_prev)
 
123
 
 
124
#define LIST_FOREACH_AFTER(name,i,p)                                    \
 
125
        for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next)