Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* $NetBSD: list.h,v 1.2 2004/05/20 19:51:55 christos Exp $ */ |
michael@0 | 2 | |
michael@0 | 3 | /* |
michael@0 | 4 | * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") |
michael@0 | 5 | * Copyright (c) 1997,1999 by Internet Software Consortium. |
michael@0 | 6 | * |
michael@0 | 7 | * Permission to use, copy, modify, and distribute this software for any |
michael@0 | 8 | * purpose with or without fee is hereby granted, provided that the above |
michael@0 | 9 | * copyright notice and this permission notice appear in all copies. |
michael@0 | 10 | * |
michael@0 | 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES |
michael@0 | 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
michael@0 | 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR |
michael@0 | 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
michael@0 | 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
michael@0 | 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
michael@0 | 17 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
michael@0 | 18 | */ |
michael@0 | 19 | |
michael@0 | 20 | /* |
michael@0 | 21 | * This version of this file is derived from Android 2.3 "Gingerbread", |
michael@0 | 22 | * which contains uncredited changes by Android/Google developers. It has |
michael@0 | 23 | * been modified in 2011 for use in the Android build of Mozilla Firefox by |
michael@0 | 24 | * Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>, |
michael@0 | 25 | * and Steve Workman <sjhworkman@gmail.com>). |
michael@0 | 26 | * These changes are offered under the same license as the original NetBSD |
michael@0 | 27 | * file, whose copyright and license are unchanged above. |
michael@0 | 28 | */ |
michael@0 | 29 | |
michael@0 | 30 | #ifndef LIST_H |
michael@0 | 31 | #define LIST_H 1 |
michael@0 | 32 | #include "assertions.h" |
michael@0 | 33 | |
michael@0 | 34 | #define LIST(type) struct { type *head, *tail; } |
michael@0 | 35 | #define INIT_LIST(list) \ |
michael@0 | 36 | do { (list).head = NULL; (list).tail = NULL; } while (/*CONSTCOND*/0) |
michael@0 | 37 | |
michael@0 | 38 | #define LINK(type) struct { type *prev, *next; } |
michael@0 | 39 | #define INIT_LINK_TYPE(elt, link, type) \ |
michael@0 | 40 | do { \ |
michael@0 | 41 | (elt)->link.prev = (type *)(-1); \ |
michael@0 | 42 | (elt)->link.next = (type *)(-1); \ |
michael@0 | 43 | } while (/*CONSTCOND*/0) |
michael@0 | 44 | #define INIT_LINK(elt, link) \ |
michael@0 | 45 | INIT_LINK_TYPE(elt, link, void) |
michael@0 | 46 | #define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1)) |
michael@0 | 47 | |
michael@0 | 48 | #define HEAD(list) ((list).head) |
michael@0 | 49 | #define TAIL(list) ((list).tail) |
michael@0 | 50 | #define EMPTY(list) ((list).head == NULL) |
michael@0 | 51 | |
michael@0 | 52 | #define PREPEND(list, elt, link) \ |
michael@0 | 53 | do { \ |
michael@0 | 54 | INSIST(!LINKED(elt, link));\ |
michael@0 | 55 | if ((list).head != NULL) \ |
michael@0 | 56 | (list).head->link.prev = (elt); \ |
michael@0 | 57 | else \ |
michael@0 | 58 | (list).tail = (elt); \ |
michael@0 | 59 | (elt)->link.prev = NULL; \ |
michael@0 | 60 | (elt)->link.next = (list).head; \ |
michael@0 | 61 | (list).head = (elt); \ |
michael@0 | 62 | } while (/*CONSTCOND*/0) |
michael@0 | 63 | |
michael@0 | 64 | #define APPEND(list, elt, link) \ |
michael@0 | 65 | do { \ |
michael@0 | 66 | INSIST(!LINKED(elt, link));\ |
michael@0 | 67 | if ((list).tail != NULL) \ |
michael@0 | 68 | (list).tail->link.next = (elt); \ |
michael@0 | 69 | else \ |
michael@0 | 70 | (list).head = (elt); \ |
michael@0 | 71 | (elt)->link.prev = (list).tail; \ |
michael@0 | 72 | (elt)->link.next = NULL; \ |
michael@0 | 73 | (list).tail = (elt); \ |
michael@0 | 74 | } while (/*CONSTCOND*/0) |
michael@0 | 75 | |
michael@0 | 76 | #define UNLINK_TYPE(list, elt, link, type) \ |
michael@0 | 77 | do { \ |
michael@0 | 78 | INSIST(LINKED(elt, link));\ |
michael@0 | 79 | if ((elt)->link.next != NULL) \ |
michael@0 | 80 | (elt)->link.next->link.prev = (elt)->link.prev; \ |
michael@0 | 81 | else \ |
michael@0 | 82 | (list).tail = (elt)->link.prev; \ |
michael@0 | 83 | if ((elt)->link.prev != NULL) \ |
michael@0 | 84 | (elt)->link.prev->link.next = (elt)->link.next; \ |
michael@0 | 85 | else \ |
michael@0 | 86 | (list).head = (elt)->link.next; \ |
michael@0 | 87 | INIT_LINK_TYPE(elt, link, type); \ |
michael@0 | 88 | } while (/*CONSTCOND*/0) |
michael@0 | 89 | #define UNLINK(list, elt, link) \ |
michael@0 | 90 | UNLINK_TYPE(list, elt, link, void) |
michael@0 | 91 | |
michael@0 | 92 | #define PREV(elt, link) ((elt)->link.prev) |
michael@0 | 93 | #define NEXT(elt, link) ((elt)->link.next) |
michael@0 | 94 | |
michael@0 | 95 | #define INSERT_BEFORE(list, before, elt, link) \ |
michael@0 | 96 | do { \ |
michael@0 | 97 | INSIST(!LINKED(elt, link));\ |
michael@0 | 98 | if ((before)->link.prev == NULL) \ |
michael@0 | 99 | PREPEND(list, elt, link); \ |
michael@0 | 100 | else { \ |
michael@0 | 101 | (elt)->link.prev = (before)->link.prev; \ |
michael@0 | 102 | (before)->link.prev = (elt); \ |
michael@0 | 103 | (elt)->link.prev->link.next = (elt); \ |
michael@0 | 104 | (elt)->link.next = (before); \ |
michael@0 | 105 | } \ |
michael@0 | 106 | } while (/*CONSTCOND*/0) |
michael@0 | 107 | |
michael@0 | 108 | #define INSERT_AFTER(list, after, elt, link) \ |
michael@0 | 109 | do { \ |
michael@0 | 110 | INSIST(!LINKED(elt, link));\ |
michael@0 | 111 | if ((after)->link.next == NULL) \ |
michael@0 | 112 | APPEND(list, elt, link); \ |
michael@0 | 113 | else { \ |
michael@0 | 114 | (elt)->link.next = (after)->link.next; \ |
michael@0 | 115 | (after)->link.next = (elt); \ |
michael@0 | 116 | (elt)->link.next->link.prev = (elt); \ |
michael@0 | 117 | (elt)->link.prev = (after); \ |
michael@0 | 118 | } \ |
michael@0 | 119 | } while (/*CONSTCOND*/0) |
michael@0 | 120 | |
michael@0 | 121 | #define ENQUEUE(list, elt, link) APPEND(list, elt, link) |
michael@0 | 122 | #define DEQUEUE(list, elt, link) UNLINK(list, elt, link) |
michael@0 | 123 | |
michael@0 | 124 | #endif /* LIST_H */ |