From nobody Mon May 13 22:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1644304035; cv=none; d=zohomail.com; s=zohoarc; b=Mi0IzFZclkzkKTQxtO+hcho84pNKeRFtvdNfTe0gmsEptbvrPZinFI444jPFfZRIhyVJbciD7pks3zFYAJLBKJSqYHwRbOKGrHvy/G28Qb6wtAEKQd22HiA/HNzDQ3lP3Al0ASXklEWp3ZHlW3PRaIocKmk0OuWDIa9ftLo+6Qk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644304035; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mCUb5g78LuJVrOtCJeFF2txQ1SfvngrUecaJfWrIMSg=; b=NHtSpoMCijXz8GUgKEV3Bz8fD9yR3BRVOFRyRW6mlo31sI1t+8AI6NIo0ReWfNjpd3gZoONKoJNfGPb4lEFBjTyus3dheCzSzWXpszuVgEP5UaVzLPbKAp/BA4+WR9XLRdrEtgQA4cPqxxSBS8HptbKHm3P4kSiu9i6IuLBf4go= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644304035884490.6889429178698; Mon, 7 Feb 2022 23:07:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.267542.461321 (Exim 4.92) (envelope-from ) id 1nHKaO-0000nV-PQ; Tue, 08 Feb 2022 07:06:48 +0000 Received: by outflank-mailman (output) from mailman id 267542.461321; Tue, 08 Feb 2022 07:06:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHKaO-0000nM-Lm; Tue, 08 Feb 2022 07:06:48 +0000 Received: by outflank-mailman (input) for mailman id 267542; Tue, 08 Feb 2022 07:06:46 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHKaM-0008SU-FU for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 07:06:46 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id aaa78e9e-88ad-11ec-8eb8-a37418f5ba1a; Tue, 08 Feb 2022 08:06:43 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7B27721100; Tue, 8 Feb 2022 07:06:41 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 518F213483; Tue, 8 Feb 2022 07:06:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MDOZEoEWAmKxHgAAMHmgww (envelope-from ); Tue, 08 Feb 2022 07:06:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: aaa78e9e-88ad-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1644304001; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mCUb5g78LuJVrOtCJeFF2txQ1SfvngrUecaJfWrIMSg=; b=pi/Zzj2yFuUYK3zI2wgKrrv6EjPrpmA5sZOzeuNymMF3PfC/PMaTYE0u+90TQYnELNimOM Kug1IfOJnrcHuXLg2MbaAneVTqVVvCV3pSlDVRFBbm1i3gs3emQ3gNdxPiBz1jPg9EMCTU 4HIvxh42ecZL8lfIh2gxX5iNq6uDmlo= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD Subject: [PATCH v3 1/5] tools/include: generate a _xen_list.h file Date: Tue, 8 Feb 2022 08:06:34 +0100 Message-Id: <20220208070638.5909-2-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220208070638.5909-1-jgross@suse.com> References: <20220208070638.5909-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1644304036893100003 Content-Type: text/plain; charset="utf-8" Today tools/include contains two basically identical header files generated from the same source. They just differ by the used name space and they are being generated from different Makefiles via a perl script. Prepare to have only one such header by using a more generic namespace "XEN" for _xen_list.h. As the original header hasn't been updated in the Xen tree since its introduction about 10 years ago, and the updates of FreeBSD side have mostly covered BSD internal debugging aids, just don't generate the new header during build, especially as using the current FreeBSD version of the file would require some updates of the perl script, which are potentially more work than just doing the needed editing by hand. Additionally this enables to remove the not needed debugging extensions of FreeBSD. Signed-off-by: Juergen Gross Acked-by: Anthony PERARD --- tools/include/Makefile | 2 + tools/include/_xen_list.h | 509 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 511 insertions(+) create mode 100644 tools/include/_xen_list.h diff --git a/tools/include/Makefile b/tools/include/Makefile index d7b51006e0..d965987f55 100644 --- a/tools/include/Makefile +++ b/tools/include/Makefile @@ -70,11 +70,13 @@ install: all $(INSTALL_DATA) xen/io/*.h $(DESTDIR)$(includedir)/xen/io $(INSTALL_DATA) xen/sys/*.h $(DESTDIR)$(includedir)/xen/sys $(INSTALL_DATA) xen/xsm/*.h $(DESTDIR)$(includedir)/xen/xsm + $(INSTALL_DATA) _xen_list.h $(DESTDIR)$(includedir) =20 .PHONY: uninstall uninstall: echo "[FIXME] uninstall headers" rm -rf $(DESTDIR)$(includedir)/xen + rm -f $(DESTDIR)$(includedir)/_xen_list.h =20 .PHONY: clean clean: diff --git a/tools/include/_xen_list.h b/tools/include/_xen_list.h new file mode 100644 index 0000000000..ce246f95c9 --- /dev/null +++ b/tools/include/_xen_list.h @@ -0,0 +1,509 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + * $FreeBSD$ + */ + +#ifndef XEN__SYS_QUEUE_H_ +#define XEN__SYS_QUEUE_H_ + +/* #include */ + +/* + * This file defines four types of data structures: singly-linked lists, + * singly-linked tail queues, lists and tail queues. + * + * A singly-linked list is headed by a single forward pointer. The elements + * are singly linked for minimum space and pointer manipulation overhead at + * the expense of O(n) removal for arbitrary elements. New elements can be + * added to the list after an existing element or at the head of the list. + * Elements being removed from the head of the list should use the explicit + * macro for this purpose for optimum efficiency. A singly-linked list may + * only be traversed in the forward direction. Singly-linked lists are id= eal + * for applications with large datasets and few or no removals or for + * implementing a LIFO queue. + * + * A singly-linked tail queue is headed by a pair of pointers, one to the + * head of the list and the other to the tail of the list. The elements are + * singly linked for minimum space and pointer manipulation overhead at the + * expense of O(n) removal for arbitrary elements. New elements can be add= ed + * to the list after an existing element, at the head of the list, or at t= he + * end of the list. Elements being removed from the head of the tail queue + * should use the explicit macro for this purpose for optimum efficiency. + * A singly-linked tail queue may only be traversed in the forward directi= on. + * Singly-linked tail queues are ideal for applications with large datasets + * and few or no removals or for implementing a FIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * For details on the use of these macros, see the queue(3) manual page. + * + * + * XEN_SLIST XEN_LIST XEN_STAILQ XEN_TAILQ + * _HEAD + + + + + * _HEAD_INITIALIZER + + + + + * _ENTRY + + + + + * _INIT + + + + + * _EMPTY + + + + + * _FIRST + + + + + * _NEXT + + + + + * _PREV - - - + + * _LAST - - + + + * _FOREACH + + + + + * _FOREACH_SAFE + + + + + * _FOREACH_REVERSE - - - + + * _FOREACH_REVERSE_SAFE - - - + + * _INSERT_HEAD + + + + + * _INSERT_BEFORE - + - + + * _INSERT_AFTER + + + + + * _INSERT_TAIL - - + + + * _CONCAT - - + + + * _REMOVE_AFTER + - + - + * _REMOVE_HEAD + - + - + * _REMOVE + + + + + * _SWAP + + + + + * + */ + +/* + * Singly-linked List declarations. + */ +#define XEN_SLIST_HEAD(name, type) \ +struct name { \ + type *slh_first; /* first element */ \ +} + +#define XEN_SLIST_HEAD_INITIALIZER(head) \ + { 0 } + +#define XEN_SLIST_ENTRY(type) \ +struct { \ + type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List functions. + */ +#define XEN_SLIST_EMPTY(head) ((head)->slh_first =3D=3D 0) + +#define XEN_SLIST_FIRST(head) ((head)->slh_first) + +#define XEN_SLIST_FOREACH(var, head, field) \ + for ((var) =3D XEN_SLIST_FIRST((head)); \ + (var); \ + (var) =3D XEN_SLIST_NEXT((var), field)) + +#define XEN_SLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) =3D XEN_SLIST_FIRST((head)); \ + (var) && ((tvar) =3D XEN_SLIST_NEXT((var), field), 1); \ + (var) =3D (tvar)) + +#define XEN_SLIST_FOREACH_PREVPTR(var, varp, head, field) \ + for ((varp) =3D &XEN_SLIST_FIRST((head)); \ + ((var) =3D *(varp)) !=3D 0; \ + (varp) =3D &XEN_SLIST_NEXT((var), field)) + +#define XEN_SLIST_INIT(head) do { \ + XEN_SLIST_FIRST((head)) =3D 0; \ +} while (0) + +#define XEN_SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + XEN_SLIST_NEXT((elm), field) =3D XEN_SLIST_NEXT((slistelm), field);\ + XEN_SLIST_NEXT((slistelm), field) =3D (elm); \ +} while (0) + +#define XEN_SLIST_INSERT_HEAD(head, elm, field) do { \ + XEN_SLIST_NEXT((elm), field) =3D XEN_SLIST_FIRST((head)); \ + XEN_SLIST_FIRST((head)) =3D (elm); \ +} while (0) + +#define XEN_SLIST_NEXT(elm, field) ((elm)->field.sle_next) + +#define XEN_SLIST_REMOVE(head, elm, type, field) do { \ + if (XEN_SLIST_FIRST((head)) =3D=3D (elm)) { \ + XEN_SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + type *curelm =3D XEN_SLIST_FIRST((head)); \ + while (XEN_SLIST_NEXT(curelm, field) !=3D (elm)) \ + curelm =3D XEN_SLIST_NEXT(curelm, field); \ + XEN_SLIST_REMOVE_AFTER(curelm, field); \ + } \ +} while (0) + +#define XEN_SLIST_REMOVE_AFTER(elm, field) do { \ + XEN_SLIST_NEXT(elm, field) =3D \ + XEN_SLIST_NEXT(XEN_SLIST_NEXT(elm, field), field); \ +} while (0) + +#define XEN_SLIST_REMOVE_HEAD(head, field) do { \ + XEN_SLIST_FIRST((head)) =3D XEN_SLIST_NEXT(XEN_SLIST_FIRST((head)), field= );\ +} while (0) + +#define XEN_SLIST_SWAP(head1, head2, type) do { \ + type *swap_first =3D XEN_SLIST_FIRST(head1); \ + XEN_SLIST_FIRST(head1) =3D XEN_SLIST_FIRST(head2); \ + XEN_SLIST_FIRST(head2) =3D swap_first; \ +} while (0) + +/* + * Singly-linked Tail queue declarations. + */ +#define XEN_STAILQ_HEAD(name, type) \ +struct name { \ + type *stqh_first;/* first element */ \ + type **stqh_last;/* addr of last next element */ \ +} + +#define XEN_STAILQ_HEAD_INITIALIZER(head) \ + { 0, &(head).stqh_first } + +#define XEN_STAILQ_ENTRY(type) \ +struct { \ + type *stqe_next; /* next element */ \ +} + +/* + * Singly-linked Tail queue functions. + */ +#define XEN_STAILQ_CONCAT(head1, head2) do { \ + if (!XEN_STAILQ_EMPTY((head2))) { \ + *(head1)->stqh_last =3D (head2)->stqh_first; \ + (head1)->stqh_last =3D (head2)->stqh_last; \ + XEN_STAILQ_INIT((head2)); \ + } \ +} while (0) + +#define XEN_STAILQ_EMPTY(head) ((head)->stqh_first =3D=3D 0) + +#define XEN_STAILQ_FIRST(head) ((head)->stqh_first) + +#define XEN_STAILQ_FOREACH(var, head, field) \ + for((var) =3D XEN_STAILQ_FIRST((head)); \ + (var); \ + (var) =3D XEN_STAILQ_NEXT((var), field)) + + +#define XEN_STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) =3D XEN_STAILQ_FIRST((head)); \ + (var) && ((tvar) =3D XEN_STAILQ_NEXT((var), field), 1); \ + (var) =3D (tvar)) + +#define XEN_STAILQ_INIT(head) do { \ + XEN_STAILQ_FIRST((head)) =3D 0; \ + (head)->stqh_last =3D &XEN_STAILQ_FIRST((head)); \ +} while (0) + +#define XEN_STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ + if ((XEN_STAILQ_NEXT((elm), field) =3D XEN_STAILQ_NEXT((tqelm), field)) = =3D=3D 0)\ + (head)->stqh_last =3D &XEN_STAILQ_NEXT((elm), field); \ + XEN_STAILQ_NEXT((tqelm), field) =3D (elm); \ +} while (0) + +#define XEN_STAILQ_INSERT_HEAD(head, elm, field) do { \ + if ((XEN_STAILQ_NEXT((elm), field) =3D XEN_STAILQ_FIRST((head))) =3D=3D 0= )\ + (head)->stqh_last =3D &XEN_STAILQ_NEXT((elm), field); \ + XEN_STAILQ_FIRST((head)) =3D (elm); \ +} while (0) + +#define XEN_STAILQ_INSERT_TAIL(head, elm, field) do { \ + XEN_STAILQ_NEXT((elm), field) =3D 0; \ + *(head)->stqh_last =3D (elm); \ + (head)->stqh_last =3D &XEN_STAILQ_NEXT((elm), field); \ +} while (0) + +#define XEN_STAILQ_LAST(head, type, field) \ + (XEN_STAILQ_EMPTY((head)) ? \ + 0 : \ + ((type *)(void *) \ + ((char *)((head)->stqh_last) - offsetof(type, field)))) + +#define XEN_STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) + +#define XEN_STAILQ_REMOVE(head, elm, type, field) do { \ + if (XEN_STAILQ_FIRST((head)) =3D=3D (elm)) { \ + XEN_STAILQ_REMOVE_HEAD((head), field); \ + } \ + else { \ + type *curelm =3D XEN_STAILQ_FIRST((head)); \ + while (XEN_STAILQ_NEXT(curelm, field) !=3D (elm)) \ + curelm =3D XEN_STAILQ_NEXT(curelm, field); \ + XEN_STAILQ_REMOVE_AFTER(head, curelm, field); \ + } \ +} while (0) + +#define XEN_STAILQ_REMOVE_AFTER(head, elm, field) do { \ + if ((XEN_STAILQ_NEXT(elm, field) =3D \ + XEN_STAILQ_NEXT(XEN_STAILQ_NEXT(elm, field), field)) =3D=3D 0) \ + (head)->stqh_last =3D &XEN_STAILQ_NEXT((elm), field); \ +} while (0) + +#define XEN_STAILQ_REMOVE_HEAD(head, field) do { \ + if ((XEN_STAILQ_FIRST((head)) =3D \ + XEN_STAILQ_NEXT(XEN_STAILQ_FIRST((head)), field)) =3D=3D 0) \ + (head)->stqh_last =3D &XEN_STAILQ_FIRST((head)); \ +} while (0) + +#define XEN_STAILQ_SWAP(head1, head2, type) do { \ + type *swap_first =3D XEN_STAILQ_FIRST(head1); \ + type **swap_last =3D (head1)->stqh_last; \ + XEN_STAILQ_FIRST(head1) =3D XEN_STAILQ_FIRST(head2); \ + (head1)->stqh_last =3D (head2)->stqh_last; \ + XEN_STAILQ_FIRST(head2) =3D swap_first; \ + (head2)->stqh_last =3D swap_last; \ + if (XEN_STAILQ_EMPTY(head1)) \ + (head1)->stqh_last =3D &XEN_STAILQ_FIRST(head1); \ + if (XEN_STAILQ_EMPTY(head2)) \ + (head2)->stqh_last =3D &XEN_STAILQ_FIRST(head2); \ +} while (0) + + +/* + * List declarations. + */ +#define XEN_LIST_HEAD(name, type) \ +struct name { \ + type *lh_first; /* first element */ \ +} + +#define XEN_LIST_HEAD_INITIALIZER(head) \ + { 0 } + +#define XEN_LIST_ENTRY(type) \ +struct { \ + type *le_next; /* next element */ \ + type **le_prev; /* address of previous next element */ \ +} + +/* + * List functions. + */ + +#define XEN_LIST_EMPTY(head) ((head)->lh_first =3D=3D 0) + +#define XEN_LIST_FIRST(head) ((head)->lh_first) + +#define XEN_LIST_FOREACH(var, head, field) \ + for ((var) =3D XEN_LIST_FIRST((head)); \ + (var); \ + (var) =3D XEN_LIST_NEXT((var), field)) + +#define XEN_LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) =3D XEN_LIST_FIRST((head)); \ + (var) && ((tvar) =3D XEN_LIST_NEXT((var), field), 1); \ + (var) =3D (tvar)) + +#define XEN_LIST_INIT(head) do { \ + XEN_LIST_FIRST((head)) =3D 0; \ +} while (0) + +#define XEN_LIST_INSERT_AFTER(listelm, elm, field) do { \ + if ((XEN_LIST_NEXT((elm), field) =3D XEN_LIST_NEXT((listelm), field)) != =3D 0)\ + XEN_LIST_NEXT((listelm), field)->field.le_prev =3D \ + &XEN_LIST_NEXT((elm), field); \ + XEN_LIST_NEXT((listelm), field) =3D (elm); \ + (elm)->field.le_prev =3D &XEN_LIST_NEXT((listelm), field); \ +} while (0) + +#define XEN_LIST_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.le_prev =3D (listelm)->field.le_prev; \ + XEN_LIST_NEXT((elm), field) =3D (listelm); \ + *(listelm)->field.le_prev =3D (elm); \ + (listelm)->field.le_prev =3D &XEN_LIST_NEXT((elm), field); \ +} while (0) + +#define XEN_LIST_INSERT_HEAD(head, elm, field) do { \ + if ((XEN_LIST_NEXT((elm), field) =3D XEN_LIST_FIRST((head))) !=3D 0)\ + XEN_LIST_FIRST((head))->field.le_prev =3D &XEN_LIST_NEXT((elm), field);\ + XEN_LIST_FIRST((head)) =3D (elm); \ + (elm)->field.le_prev =3D &XEN_LIST_FIRST((head)); \ +} while (0) + +#define XEN_LIST_NEXT(elm, field) ((elm)->field.le_next) + +#define XEN_LIST_REMOVE(elm, field) do { \ + if (XEN_LIST_NEXT((elm), field) !=3D 0) \ + XEN_LIST_NEXT((elm), field)->field.le_prev =3D \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev =3D XEN_LIST_NEXT((elm), field); \ +} while (0) + +#define XEN_LIST_SWAP(head1, head2, type, field) do { \ + type *swap_tmp =3D XEN_LIST_FIRST((head1)); \ + XEN_LIST_FIRST((head1)) =3D XEN_LIST_FIRST((head2)); \ + XEN_LIST_FIRST((head2)) =3D swap_tmp; \ + if ((swap_tmp =3D XEN_LIST_FIRST((head1))) !=3D 0) \ + swap_tmp->field.le_prev =3D &XEN_LIST_FIRST((head1)); \ + if ((swap_tmp =3D XEN_LIST_FIRST((head2))) !=3D 0) \ + swap_tmp->field.le_prev =3D &XEN_LIST_FIRST((head2)); \ +} while (0) + +/* + * Tail queue declarations. + */ +#define XEN_TAILQ_HEAD(name, type) \ +struct name { \ + type *tqh_first; /* first element */ \ + type **tqh_last; /* addr of last next element */ \ +} + +#define XEN_TAILQ_HEAD_INITIALIZER(head) \ + { 0, &(head).tqh_first } + +#define XEN_TAILQ_ENTRY(type) \ +struct { \ + type *tqe_next; /* next element */ \ + type **tqe_prev; /* address of previous next element */ \ +} + +/* + * Tail queue functions. + */ + +#define XEN_TAILQ_CONCAT(head1, head2, field) do { \ + if (!XEN_TAILQ_EMPTY(head2)) { \ + *(head1)->tqh_last =3D (head2)->tqh_first; \ + (head2)->tqh_first->field.tqe_prev =3D (head1)->tqh_last; \ + (head1)->tqh_last =3D (head2)->tqh_last; \ + XEN_TAILQ_INIT((head2)); \ + } \ +} while (0) + +#define XEN_TAILQ_EMPTY(head) ((head)->tqh_first =3D=3D 0) + +#define XEN_TAILQ_FIRST(head) ((head)->tqh_first) + +#define XEN_TAILQ_FOREACH(var, head, field) \ + for ((var) =3D XEN_TAILQ_FIRST((head)); \ + (var); \ + (var) =3D XEN_TAILQ_NEXT((var), field)) + +#define XEN_TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) =3D XEN_TAILQ_FIRST((head)); \ + (var) && ((tvar) =3D XEN_TAILQ_NEXT((var), field), 1); \ + (var) =3D (tvar)) + +#define XEN_TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) =3D XEN_TAILQ_LAST((head), headname); \ + (var); \ + (var) =3D XEN_TAILQ_PREV((var), headname, field)) + +#define XEN_TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ + for ((var) =3D XEN_TAILQ_LAST((head), headname); \ + (var) && ((tvar) =3D XEN_TAILQ_PREV((var), headname, field), 1);\ + (var) =3D (tvar)) + +#define XEN_TAILQ_INIT(head) do { \ + XEN_TAILQ_FIRST((head)) =3D 0; \ + (head)->tqh_last =3D &XEN_TAILQ_FIRST((head)); \ +} while (0) + +#define XEN_TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if ((XEN_TAILQ_NEXT((elm), field) =3D XEN_TAILQ_NEXT((listelm), field)) != =3D 0)\ + XEN_TAILQ_NEXT((elm), field)->field.tqe_prev =3D \ + &XEN_TAILQ_NEXT((elm), field); \ + else { \ + (head)->tqh_last =3D &XEN_TAILQ_NEXT((elm), field); \ + } \ + XEN_TAILQ_NEXT((listelm), field) =3D (elm); \ + (elm)->field.tqe_prev =3D &XEN_TAILQ_NEXT((listelm), field); \ +} while (0) + +#define XEN_TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev =3D (listelm)->field.tqe_prev; \ + XEN_TAILQ_NEXT((elm), field) =3D (listelm); \ + *(listelm)->field.tqe_prev =3D (elm); \ + (listelm)->field.tqe_prev =3D &XEN_TAILQ_NEXT((elm), field); \ +} while (0) + +#define XEN_TAILQ_INSERT_HEAD(head, elm, field) do { \ + if ((XEN_TAILQ_NEXT((elm), field) =3D XEN_TAILQ_FIRST((head))) !=3D 0)\ + XEN_TAILQ_FIRST((head))->field.tqe_prev =3D \ + &XEN_TAILQ_NEXT((elm), field); \ + else \ + (head)->tqh_last =3D &XEN_TAILQ_NEXT((elm), field); \ + XEN_TAILQ_FIRST((head)) =3D (elm); \ + (elm)->field.tqe_prev =3D &XEN_TAILQ_FIRST((head)); \ +} while (0) + +#define XEN_TAILQ_INSERT_TAIL(head, elm, field) do { \ + XEN_TAILQ_NEXT((elm), field) =3D 0; \ + (elm)->field.tqe_prev =3D (head)->tqh_last; \ + *(head)->tqh_last =3D (elm); \ + (head)->tqh_last =3D &XEN_TAILQ_NEXT((elm), field); \ +} while (0) + +#define XEN_TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) + +#define XEN_TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) + +#define XEN_TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + +#define XEN_TAILQ_REMOVE(head, elm, field) do { \ + if ((XEN_TAILQ_NEXT((elm), field)) !=3D 0) \ + XEN_TAILQ_NEXT((elm), field)->field.tqe_prev =3D \ + (elm)->field.tqe_prev; \ + else { \ + (head)->tqh_last =3D (elm)->field.tqe_prev; \ + } \ + *(elm)->field.tqe_prev =3D XEN_TAILQ_NEXT((elm), field); \ +} while (0) + +#define XEN_TAILQ_SWAP(head1, head2, type, field) do { \ + type *swap_first =3D (head1)->tqh_first; \ + type **swap_last =3D (head1)->tqh_last; \ + (head1)->tqh_first =3D (head2)->tqh_first; \ + (head1)->tqh_last =3D (head2)->tqh_last; \ + (head2)->tqh_first =3D swap_first; \ + (head2)->tqh_last =3D swap_last; \ + if ((swap_first =3D (head1)->tqh_first) !=3D 0) \ + swap_first->field.tqe_prev =3D &(head1)->tqh_first; \ + else \ + (head1)->tqh_last =3D &(head1)->tqh_first; \ + if ((swap_first =3D (head2)->tqh_first) !=3D 0) \ + swap_first->field.tqe_prev =3D &(head2)->tqh_first; \ + else \ + (head2)->tqh_last =3D &(head2)->tqh_first; \ +} while (0) + +#endif /* !XEN__SYS_QUEUE_H_ */ --=20 2.34.1 From nobody Mon May 13 22:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1644304036; cv=none; d=zohomail.com; s=zohoarc; b=VZnbVOgs0gdbXFhznELdEvSnM7siVk0UwSRWc1wMdOq0JtipRGIaFju1cbLfcFtDMD8+We6xOE/UOMDayVP6/uKw3KqrLFcosK0qISjvKDRIrJjl6ZoKea+Y6ZreBjqV2Ig1R4PlSqDOMrvYgsltDMiZdk2+XwX77GYiUF4rX30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644304036; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ioM7WbcIe/sYDvywckVh1bsSGpG8hSYfcSzh25quefQ=; b=OdpJWxqf/StiZb5p0CvpSeHofIXjtgsriC4EwbfzH0M4RHxIwDbvFsb1i5lDTaGtNRTTNmHkiYes27Rf7tkrzvU6qA4l0GX7b6jlD+HEjkcrVp+Ziu3KyiGI4nmhsJbUywFCODZf5Vdc/AVHm0VKaNtmAvGcCOlf96NFdmSHqSA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 164430403631572.2325379831683; Mon, 7 Feb 2022 23:07:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.267543.461327 (Exim 4.92) (envelope-from ) id 1nHKaP-0000rm-A1; Tue, 08 Feb 2022 07:06:49 +0000 Received: by outflank-mailman (output) from mailman id 267543.461327; Tue, 08 Feb 2022 07:06:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHKaP-0000rG-1T; Tue, 08 Feb 2022 07:06:49 +0000 Received: by outflank-mailman (input) for mailman id 267543; Tue, 08 Feb 2022 07:06:47 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHKaN-0008SU-4h for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 07:06:47 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id aad21d12-88ad-11ec-8eb8-a37418f5ba1a; Tue, 08 Feb 2022 08:06:43 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BB8D821102; Tue, 8 Feb 2022 07:06:41 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8570A13483; Tue, 8 Feb 2022 07:06:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +Eg7H4EWAmKxHgAAMHmgww (envelope-from ); Tue, 08 Feb 2022 07:06:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: aad21d12-88ad-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1644304001; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ioM7WbcIe/sYDvywckVh1bsSGpG8hSYfcSzh25quefQ=; b=EvZ1+6ZiUmyfWehVJQpMMJp8UQZRHNNWsmZuFwvk/6X83OMR4ODSnOHFUIObwJ+Bg4Rxm1 CXnAiYYFfYqBEAhtvs18ofPw+tkURQKbzkGhWiyjcCZrbgp0S56IPNAIiwAMK50q98h+Bu ihHuN+N+Mc5Vy6O6lwRe+DSiSPM5cPE= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD Subject: [PATCH v3 2/5] tools/libs/light: replace _libxl_list.h with _xen_list.h Date: Tue, 8 Feb 2022 08:06:35 +0100 Message-Id: <20220208070638.5909-3-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220208070638.5909-1-jgross@suse.com> References: <20220208070638.5909-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1644304037070100006 Content-Type: text/plain; charset="utf-8" Remove generating _libxl_list.h and use the common _xen_list.h instead. Signed-off-by: Juergen Gross Acked-by: Anthony PERARD --- tools/include/libxl.h | 4 +- tools/libs/light/Makefile | 10 +-- tools/libs/light/libxl.c | 40 ++++----- tools/libs/light/libxl_aoutils.c | 20 ++--- tools/libs/light/libxl_device.c | 27 +++--- tools/libs/light/libxl_disk.c | 4 +- tools/libs/light/libxl_domain.c | 18 ++-- tools/libs/light/libxl_event.c | 128 +++++++++++++-------------- tools/libs/light/libxl_fork.c | 44 ++++----- tools/libs/light/libxl_internal.h | 86 +++++++++--------- tools/libs/light/libxl_qmp.c | 19 ++-- tools/libs/light/libxl_stream_read.c | 20 ++--- 12 files changed, 206 insertions(+), 214 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 2bbbd21f0b..51a9b6cfac 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -747,7 +747,7 @@ typedef struct libxl__ctx libxl_ctx; =20 #include -#include <_libxl_list.h> +#include <_xen_list.h> =20 /* API compatibility. */ #ifdef LIBXL_API_VERSION @@ -1448,7 +1448,7 @@ typedef struct { } libxl_enum_string_table; =20 struct libxl_event; -typedef LIBXL_TAILQ_ENTRY(struct libxl_event) libxl_ev_link; +typedef XEN_TAILQ_ENTRY(struct libxl_event) libxl_ev_link; =20 /* * A boolean variable with an explicit default state. diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile index be32d95d39..5642955672 100644 --- a/tools/libs/light/Makefile +++ b/tools/libs/light/Makefile @@ -153,14 +153,14 @@ LIBXL_TEST_OBJS +=3D $(foreach t, $(LIBXL_TESTS_INSID= E),libxl_test_$t.opic) TEST_PROG_OBJS +=3D $(foreach t, $(LIBXL_TESTS_PROGS),test_$t.o) test_comm= on.o TEST_PROGS +=3D $(foreach t, $(LIBXL_TESTS_PROGS),test_$t) =20 -AUTOINCS =3D $(XEN_INCLUDE)/_libxl_list.h _libxl_save_msgs_callout.h _libx= l_save_msgs_helper.h +AUTOINCS =3D _libxl_save_msgs_callout.h _libxl_save_msgs_helper.h AUTOSRCS =3D _libxl_save_msgs_callout.c _libxl_save_msgs_helper.c =20 CLIENTS =3D testidl libxl-save-helper =20 SAVE_HELPER_OBJS =3D libxl_save_helper.o _libxl_save_msgs_helper.o =20 -LIBHEADER :=3D libxl.h libxl_event.h libxl_json.h _libxl_types.h _libxl_ty= pes_json.h _libxl_list.h libxl_utils.h libxl_uuid.h +LIBHEADER :=3D libxl.h libxl_event.h libxl_json.h _libxl_types.h _libxl_ty= pes_json.h libxl_utils.h libxl_uuid.h =20 NO_HEADERS_CHK :=3D y =20 @@ -201,17 +201,13 @@ _libxl.api-for-check: $(XEN_INCLUDE)/libxl.h $(AUTOIN= CS) >$@.new mv -f $@.new $@ =20 -$(XEN_INCLUDE)/_libxl_list.h: $(XEN_INCLUDE)/xen-external/bsd-sys-queue-h-= seddery $(XEN_INCLUDE)/xen-external/bsd-sys-queue.h - $(PERL) $^ --prefix=3Dlibxl >$(notdir $@).new - $(call move-if-changed,$(notdir $@).new,$@) - _libxl_save_msgs_helper.c _libxl_save_msgs_callout.c \ _libxl_save_msgs_helper.h _libxl_save_msgs_callout.h: \ libxl_save_msgs_gen.pl $(PERL) -w $< $@ >$@.new $(call move-if-changed,$@.new,$@) =20 -$(XEN_INCLUDE)/libxl.h: $(XEN_INCLUDE)/_libxl_types.h $(XEN_INCLUDE)/_libx= l_list.h +$(XEN_INCLUDE)/libxl.h: $(XEN_INCLUDE)/_libxl_types.h $(XEN_INCLUDE)/libxl_json.h: $(XEN_INCLUDE)/_libxl_types_json.h libxl_internal.h: _libxl_types_internal.h _libxl_types_private.h _libxl_ty= pes_internal_private.h libxl_internal_json.h: _libxl_types_internal_json.h diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c index 667ae6409b..a0bf7d186f 100644 --- a/tools/libs/light/libxl.c +++ b/tools/libs/light/libxl.c @@ -41,29 +41,29 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, ctx->nogc_gc.alloc_maxsize =3D -1; ctx->nogc_gc.owner =3D ctx; =20 - LIBXL_TAILQ_INIT(&ctx->occurred); + XEN_TAILQ_INIT(&ctx->occurred); =20 ctx->osevent_hooks =3D 0; =20 ctx->poller_app =3D 0; - LIBXL_LIST_INIT(&ctx->pollers_event); - LIBXL_LIST_INIT(&ctx->pollers_idle); - LIBXL_LIST_INIT(&ctx->pollers_active); + XEN_LIST_INIT(&ctx->pollers_event); + XEN_LIST_INIT(&ctx->pollers_idle); + XEN_LIST_INIT(&ctx->pollers_active); =20 - LIBXL_LIST_INIT(&ctx->efds); - LIBXL_TAILQ_INIT(&ctx->etimes); + XEN_LIST_INIT(&ctx->efds); + XEN_TAILQ_INIT(&ctx->etimes); =20 ctx->watch_slots =3D 0; - LIBXL_SLIST_INIT(&ctx->watch_freeslots); + XEN_SLIST_INIT(&ctx->watch_freeslots); libxl__ev_fd_init(&ctx->watch_efd); =20 ctx->xce =3D 0; - LIBXL_LIST_INIT(&ctx->evtchns_waiting); + XEN_LIST_INIT(&ctx->evtchns_waiting); libxl__ev_fd_init(&ctx->evtchn_efd); =20 - LIBXL_LIST_INIT(&ctx->aos_inprogress); + XEN_LIST_INIT(&ctx->aos_inprogress); =20 - LIBXL_TAILQ_INIT(&ctx->death_list); + XEN_TAILQ_INIT(&ctx->death_list); libxl__ev_xswatch_init(&ctx->death_watch); =20 ctx->childproc_hooks =3D &libxl__childproc_default_hooks; @@ -122,14 +122,14 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, static void free_disable_deaths(libxl__gc *gc, struct libxl__evgen_domain_death_list *l) { libxl_evgen_domain_death *death; - while ((death =3D LIBXL_TAILQ_FIRST(l))) + while ((death =3D XEN_TAILQ_FIRST(l))) libxl__evdisable_domain_death(gc, death); } =20 static void discard_events(struct libxl__event_list *l) { /* doesn't bother unlinking from the list, so l is corrupt on return */ libxl_event *ev, *next; - LIBXL_TAILQ_FOREACH_SAFE(ev, l, link, next) + XEN_TAILQ_FOREACH_SAFE(ev, l, link, next) libxl_event_free(0, ev); } =20 @@ -150,7 +150,7 @@ int libxl_ctx_free(libxl_ctx *ctx) free_disable_deaths(gc, &CTX->death_reported); =20 libxl_evgen_disk_eject *eject; - while ((eject =3D LIBXL_LIST_FIRST(&CTX->disk_eject_evgens))) + while ((eject =3D XEN_LIST_FIRST(&CTX->disk_eject_evgens))) libxl__evdisable_disk_eject(gc, eject); =20 libxl_childproc_setmode(CTX,0,0); @@ -162,10 +162,10 @@ int libxl_ctx_free(libxl_ctx *ctx) =20 /* Now there should be no more events requested from the application: = */ =20 - assert(LIBXL_LIST_EMPTY(&ctx->efds)); - assert(LIBXL_TAILQ_EMPTY(&ctx->etimes)); - assert(LIBXL_LIST_EMPTY(&ctx->evtchns_waiting)); - assert(LIBXL_LIST_EMPTY(&ctx->aos_inprogress)); + assert(XEN_LIST_EMPTY(&ctx->efds)); + assert(XEN_TAILQ_EMPTY(&ctx->etimes)); + assert(XEN_LIST_EMPTY(&ctx->evtchns_waiting)); + assert(XEN_LIST_EMPTY(&ctx->aos_inprogress)); =20 if (ctx->xch) xc_interface_close(ctx->xch); libxl_version_info_dispose(&ctx->version_info); @@ -174,10 +174,10 @@ int libxl_ctx_free(libxl_ctx *ctx) =20 libxl__poller_put(ctx, ctx->poller_app); ctx->poller_app =3D NULL; - assert(LIBXL_LIST_EMPTY(&ctx->pollers_event)); - assert(LIBXL_LIST_EMPTY(&ctx->pollers_active)); + assert(XEN_LIST_EMPTY(&ctx->pollers_event)); + assert(XEN_LIST_EMPTY(&ctx->pollers_active)); libxl__poller *poller, *poller_tmp; - LIBXL_LIST_FOREACH_SAFE(poller, &ctx->pollers_idle, entry, poller_tmp)= { + XEN_LIST_FOREACH_SAFE(poller, &ctx->pollers_idle, entry, poller_tmp) { libxl__poller_dispose(poller); free(poller); } diff --git a/tools/libs/light/libxl_aoutils.c b/tools/libs/light/libxl_aout= ils.c index c4c095a5ba..c2d42e7cac 100644 --- a/tools/libs/light/libxl_aoutils.c +++ b/tools/libs/light/libxl_aoutils.c @@ -106,7 +106,7 @@ void libxl__datacopier_init(libxl__datacopier_state *dc) libxl__ao_abortable_init(&dc->abrt); libxl__ev_fd_init(&dc->toread); libxl__ev_fd_init(&dc->towrite); - LIBXL_TAILQ_INIT(&dc->bufs); + XEN_TAILQ_INIT(&dc->bufs); } =20 void libxl__datacopier_kill(libxl__datacopier_state *dc) @@ -117,9 +117,9 @@ void libxl__datacopier_kill(libxl__datacopier_state *dc) libxl__ao_abortable_deregister(&dc->abrt); libxl__ev_fd_deregister(gc, &dc->toread); libxl__ev_fd_deregister(gc, &dc->towrite); - LIBXL_TAILQ_FOREACH_SAFE(buf, &dc->bufs, entry, tbuf) + XEN_TAILQ_FOREACH_SAFE(buf, &dc->bufs, entry, tbuf) free(buf); - LIBXL_TAILQ_INIT(&dc->bufs); + XEN_TAILQ_INIT(&dc->bufs); } =20 static void datacopier_callback(libxl__egc *egc, libxl__datacopier_state *= dc, @@ -182,7 +182,7 @@ void libxl__datacopier_prefixdata(libxl__egc *egc, libx= l__datacopier_state *dc, memcpy(buf->buf, ptr, buf->used); =20 dc->used +=3D buf->used; - LIBXL_TAILQ_INSERT_TAIL(&dc->bufs, buf, entry); + XEN_TAILQ_INSERT_TAIL(&dc->bufs, buf, entry); } } =20 @@ -235,18 +235,18 @@ static void datacopier_readable(libxl__egc *egc, libx= l__ev_fd *ev, r =3D read(ev->fd, dc->readbuf + dc->used, dc->bytes_to_read); } else { while (dc->used >=3D dc->maxsz) { - libxl__datacopier_buf *rm =3D LIBXL_TAILQ_FIRST(&dc->bufs); + libxl__datacopier_buf *rm =3D XEN_TAILQ_FIRST(&dc->bufs); dc->used -=3D rm->used; assert(dc->used >=3D 0); - LIBXL_TAILQ_REMOVE(&dc->bufs, rm, entry); + XEN_TAILQ_REMOVE(&dc->bufs, rm, entry); free(rm); } =20 - buf =3D LIBXL_TAILQ_LAST(&dc->bufs, libxl__datacopier_bufs); + buf =3D XEN_TAILQ_LAST(&dc->bufs, libxl__datacopier_bufs); if (!buf || buf->used >=3D sizeof(buf->buf)) { buf =3D libxl__malloc(NOGC, sizeof(*buf)); buf->used =3D 0; - LIBXL_TAILQ_INSERT_TAIL(&dc->bufs, buf, entry); + XEN_TAILQ_INSERT_TAIL(&dc->bufs, buf, entry); } r =3D read(ev->fd, buf->buf + buf->used, min_t(size_t, sizeof(buf->buf) - buf->used, @@ -331,11 +331,11 @@ static void datacopier_writable(libxl__egc *egc, libx= l__ev_fd *ev, } assert(revents & POLLOUT); for (;;) { - libxl__datacopier_buf *buf =3D LIBXL_TAILQ_FIRST(&dc->bufs); + libxl__datacopier_buf *buf =3D XEN_TAILQ_FIRST(&dc->bufs); if (!buf) break; if (!buf->used) { - LIBXL_TAILQ_REMOVE(&dc->bufs, buf, entry); + XEN_TAILQ_REMOVE(&dc->bufs, buf, entry); free(buf); continue; } diff --git a/tools/libs/light/libxl_device.c b/tools/libs/light/libxl_devic= e.c index 36c4e41e4d..e6025d135e 100644 --- a/tools/libs/light/libxl_device.c +++ b/tools/libs/light/libxl_device.c @@ -1476,7 +1476,7 @@ static void qdisk_spawn_outcome(libxl__egc *egc, libx= l__dm_spawn_state *dmss, */ typedef struct libxl__ddomain_device { libxl__device *dev; - LIBXL_SLIST_ENTRY(struct libxl__ddomain_device) next; + XEN_SLIST_ENTRY(struct libxl__ddomain_device) next; } libxl__ddomain_device; =20 /* @@ -1485,8 +1485,8 @@ typedef struct libxl__ddomain_device { typedef struct libxl__ddomain_guest { uint32_t domid; int num_qdisks; - LIBXL_SLIST_HEAD(, struct libxl__ddomain_device) devices; - LIBXL_SLIST_ENTRY(struct libxl__ddomain_guest) next; + XEN_SLIST_HEAD(, struct libxl__ddomain_device) devices; + XEN_SLIST_ENTRY(struct libxl__ddomain_guest) next; } libxl__ddomain_guest; =20 /* @@ -1496,7 +1496,7 @@ typedef struct libxl__ddomain_guest { typedef struct { libxl__ao *ao; libxl__ev_xswatch watch; - LIBXL_SLIST_HEAD(, struct libxl__ddomain_guest) guests; + XEN_SLIST_HEAD(, struct libxl__ddomain_guest) guests; } libxl__ddomain; =20 static libxl__ddomain_guest *search_for_guest(libxl__ddomain *ddomain, @@ -1504,7 +1504,7 @@ static libxl__ddomain_guest *search_for_guest(libxl__= ddomain *ddomain, { libxl__ddomain_guest *dguest; =20 - LIBXL_SLIST_FOREACH(dguest, &ddomain->guests, next) { + XEN_SLIST_FOREACH(dguest, &ddomain->guests, next) { if (dguest->domid =3D=3D domid) return dguest; } @@ -1516,7 +1516,7 @@ static libxl__ddomain_device *search_for_device(libxl= __ddomain_guest *dguest, { libxl__ddomain_device *ddev; =20 - LIBXL_SLIST_FOREACH(ddev, &dguest->devices, next) { + XEN_SLIST_FOREACH(ddev, &dguest->devices, next) { #define LIBXL_DEVICE_CMP(dev1, dev2, entry) (dev1->entry =3D=3D dev2->entr= y) if (LIBXL_DEVICE_CMP(ddev->dev, dev, backend_devid) && LIBXL_DEVICE_CMP(ddev->dev, dev, backend_domid) && @@ -1537,8 +1537,8 @@ static void check_and_maybe_remove_guest(libxl__gc *g= c, { assert(ddomain); =20 - if (dguest !=3D NULL && LIBXL_SLIST_FIRST(&dguest->devices) =3D=3D NUL= L) { - LIBXL_SLIST_REMOVE(&ddomain->guests, dguest, libxl__ddomain_guest, + if (dguest !=3D NULL && XEN_SLIST_FIRST(&dguest->devices) =3D=3D NULL)= { + XEN_SLIST_REMOVE(&ddomain->guests, dguest, libxl__ddomain_guest, next); LOGD(DEBUG, dguest->domid, "Removed domain from the list of active= guests"); /* Clear any leftovers in libxl/ */ @@ -1572,7 +1572,7 @@ static int add_device(libxl__egc *egc, libxl__ao *ao, ddev =3D libxl__zalloc(NOGC, sizeof(*ddev)); ddev->dev =3D libxl__zalloc(NOGC, sizeof(*ddev->dev)); *ddev->dev =3D *dev; - LIBXL_SLIST_INSERT_HEAD(&dguest->devices, ddev, next); + XEN_SLIST_INSERT_HEAD(&dguest->devices, ddev, next); LOGD(DEBUG, dev->domid, "Added device %s to the list of active devices= ", libxl__device_backend_path(gc, dev)); =20 @@ -1649,8 +1649,7 @@ static int remove_device(libxl__egc *egc, libxl__ao *= ao, * above or from add_device make a copy of the data they use, so * there's no risk of dereferencing. */ - LIBXL_SLIST_REMOVE(&dguest->devices, ddev, libxl__ddomain_device, - next); + XEN_SLIST_REMOVE(&dguest->devices, ddev, libxl__ddomain_device, next); LOGD(DEBUG, dev->domid, "Removed device %s from the list of active dev= ices", libxl__device_backend_path(gc, dev)); =20 @@ -1716,8 +1715,8 @@ static void backend_watch_callback(libxl__egc *egc, l= ibxl__ev_xswatch *watch, /* Create a new guest struct and initialize it */ dguest =3D libxl__zalloc(NOGC, sizeof(*dguest)); dguest->domid =3D dev->domid; - LIBXL_SLIST_INIT(&dguest->devices); - LIBXL_SLIST_INSERT_HEAD(&ddomain->guests, dguest, next); + XEN_SLIST_INIT(&dguest->devices); + XEN_SLIST_INSERT_HEAD(&ddomain->guests, dguest, next); LOGD(DEBUG, dguest->domid, "Added domain to the list of active gue= sts"); } ddev =3D search_for_device(dguest, dev); @@ -1766,7 +1765,7 @@ int libxl_device_events_handler(libxl_ctx *ctx, int i, j, k; =20 ddomain.ao =3D ao; - LIBXL_SLIST_INIT(&ddomain.guests); + XEN_SLIST_INIT(&ddomain.guests); =20 rc =3D libxl__get_domid(gc, &domid); if (rc) { diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c index 93936d0dd0..a5ca77850f 100644 --- a/tools/libs/light/libxl_disk.c +++ b/tools/libs/light/libxl_disk.c @@ -88,7 +88,7 @@ int libxl_evenable_disk_eject(libxl_ctx *ctx, uint32_t gu= est_domid, memset(evg, 0, sizeof(*evg)); evg->user =3D user; evg->domid =3D guest_domid; - LIBXL_LIST_INSERT_HEAD(&CTX->disk_eject_evgens, evg, entry); + XEN_LIST_INSERT_HEAD(&CTX->disk_eject_evgens, evg, entry); =20 uint32_t domid =3D libxl_get_stubdom_id(ctx, guest_domid); =20 @@ -133,7 +133,7 @@ int libxl_evenable_disk_eject(libxl_ctx *ctx, uint32_t = guest_domid, void libxl__evdisable_disk_eject(libxl__gc *gc, libxl_evgen_disk_eject *ev= g) { CTX_LOCK; =20 - LIBXL_LIST_REMOVE(evg, entry); + XEN_LIST_REMOVE(evg, entry); =20 if (libxl__ev_xswatch_isregistered(&evg->watch)) libxl__ev_xswatch_deregister(gc, &evg->watch); diff --git a/tools/libs/light/libxl_domain.c b/tools/libs/light/libxl_domai= n.c index 544a9bf59d..d544a60777 100644 --- a/tools/libs/light/libxl_domain.c +++ b/tools/libs/light/libxl_domain.c @@ -867,7 +867,7 @@ static void domain_death_occurred(libxl__egc *egc, =20 LOGD(DEBUG, evg->domid, "%s", why); =20 - libxl_evgen_domain_death *evg_next =3D LIBXL_TAILQ_NEXT(evg, entry); + libxl_evgen_domain_death *evg_next =3D XEN_TAILQ_NEXT(evg, entry); *evg_upd =3D evg_next; =20 libxl_event *ev =3D NEW_EVENT(egc, DOMAIN_DEATH, evg->domid, evg->user= ); @@ -875,8 +875,8 @@ static void domain_death_occurred(libxl__egc *egc, libxl__event_occurred(egc, ev); =20 evg->death_reported =3D 1; - LIBXL_TAILQ_REMOVE(&CTX->death_list, evg, entry); - LIBXL_TAILQ_INSERT_HEAD(&CTX->death_reported, evg, entry); + XEN_TAILQ_REMOVE(&CTX->death_list, evg, entry); + XEN_TAILQ_INSERT_HEAD(&CTX->death_reported, evg, entry); } =20 static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswat= ch *w, @@ -887,12 +887,12 @@ static void domain_death_xswatch_callback(libxl__egc = *egc, libxl__ev_xswatch *w, =20 CTX_LOCK; =20 - evg =3D LIBXL_TAILQ_FIRST(&CTX->death_list); + evg =3D XEN_TAILQ_FIRST(&CTX->death_list); =20 for (;;) { if (!evg) goto out; =20 - int nentries =3D LIBXL_TAILQ_NEXT(evg, entry) ? 200 : 1; + int nentries =3D XEN_TAILQ_NEXT(evg, entry) ? 200 : 1; xc_domaininfo_t domaininfos[nentries]; const xc_domaininfo_t *got =3D domaininfos, *gotend; =20 @@ -966,7 +966,7 @@ static void domain_death_xswatch_callback(libxl__egc *e= gc, libxl__ev_xswatch *w, =20 evg->shutdown_reported =3D 1; } - evg =3D LIBXL_TAILQ_NEXT(evg, entry); + evg =3D XEN_TAILQ_NEXT(evg, entry); } =20 assert(rc); /* rc=3D=3D0 results in us eating all evgs and quittin= g */ @@ -1015,13 +1015,13 @@ void libxl__evdisable_domain_death(libxl__gc *gc, CTX_LOCK; =20 if (!evg->death_reported) - LIBXL_TAILQ_REMOVE(&CTX->death_list, evg, entry); + XEN_TAILQ_REMOVE(&CTX->death_list, evg, entry); else - LIBXL_TAILQ_REMOVE(&CTX->death_reported, evg, entry); + XEN_TAILQ_REMOVE(&CTX->death_reported, evg, entry); =20 free(evg); =20 - if (!LIBXL_TAILQ_FIRST(&CTX->death_list) && + if (!XEN_TAILQ_FIRST(&CTX->death_list) && libxl__ev_xswatch_isregistered(&CTX->death_watch)) libxl__ev_xswatch_deregister(gc, &CTX->death_watch); =20 diff --git a/tools/libs/light/libxl_event.c b/tools/libs/light/libxl_event.c index 7c5387e94f..c8bcd13960 100644 --- a/tools/libs/light/libxl_event.c +++ b/tools/libs/light/libxl_event.c @@ -165,7 +165,7 @@ static void ao__check_destroy(libxl_ctx *ctx, libxl__ao= *ao); */ static void pollers_note_osevent_added(libxl_ctx *ctx) { libxl__poller *poller; - LIBXL_LIST_FOREACH(poller, &ctx->pollers_active, active_entry) + XEN_LIST_FOREACH(poller, &ctx->pollers_active, active_entry) poller->osevents_added =3D 1; } =20 @@ -189,7 +189,7 @@ void libxl__egc_ao_cleanup_1_baton(libxl__gc *gc) if (CTX->poller_app->osevents_added) baton_wake(gc, CTX->poller_app); =20 - LIBXL_LIST_FOREACH(search, &CTX->pollers_active, active_entry) { + XEN_LIST_FOREACH(search, &CTX->pollers_active, active_entry) { if (search =3D=3D CTX->poller_app) /* This one is special. We can't give it the baton. */ continue; @@ -279,7 +279,7 @@ void libxl__egc_ao_cleanup_1_baton(libxl__gc *gc) struct libxl__osevent_hook_nexus { void *ev; void *for_app_reg; - LIBXL_SLIST_ENTRY(libxl__osevent_hook_nexus) next; + XEN_SLIST_ENTRY(libxl__osevent_hook_nexus) next; }; =20 static void *osevent_ev_from_hook_nexus(libxl_ctx *ctx, @@ -293,7 +293,7 @@ static void osevent_release_nexus(libxl__gc *gc, libxl__osevent_hook_nexus *nexus) { nexus->ev =3D 0; - LIBXL_SLIST_INSERT_HEAD(nexi_idle, nexus, next); + XEN_SLIST_INSERT_HEAD(nexi_idle, nexus, next); } =20 /*----- OSEVENT* hook functions for nexusop "alloc" -----*/ @@ -301,9 +301,9 @@ static void osevent_hook_pre_alloc(libxl__gc *gc, void = *ev, libxl__osevent_hook_nexi *nexi_idle, libxl__osevent_hook_nexus **nexus_r) { - libxl__osevent_hook_nexus *nexus =3D LIBXL_SLIST_FIRST(nexi_idle); + libxl__osevent_hook_nexus *nexus =3D XEN_SLIST_FIRST(nexi_idle); if (nexus) { - LIBXL_SLIST_REMOVE_HEAD(nexi_idle, next); + XEN_SLIST_REMOVE_HEAD(nexi_idle, next); } else { nexus =3D libxl__zalloc(NOGC, sizeof(*nexus)); } @@ -364,7 +364,7 @@ int libxl__ev_fd_register(libxl__gc *gc, libxl__ev_fd *= ev, ev->events =3D events; ev->func =3D func; =20 - LIBXL_LIST_INSERT_HEAD(&CTX->efds, ev, entry); + XEN_LIST_INSERT_HEAD(&CTX->efds, ev, entry); pollers_note_osevent_added(CTX); =20 rc =3D 0; @@ -409,10 +409,10 @@ void libxl__ev_fd_deregister(libxl__gc *gc, libxl__ev= _fd *ev) DBG("ev_fd=3D%p deregister fd=3D%d", ev, ev->fd); =20 OSEVENT_HOOK_VOID(fd,deregister, release, ev->fd, ev->nexus->for_app_r= eg); - LIBXL_LIST_REMOVE(ev, entry); + XEN_LIST_REMOVE(ev, entry); ev->fd =3D -1; =20 - LIBXL_LIST_FOREACH(poller, &CTX->pollers_active, active_entry) + XEN_LIST_FOREACH(poller, &CTX->pollers_active, active_entry) poller->fds_deregistered =3D 1; =20 out: @@ -504,7 +504,7 @@ static void time_deregister(libxl__gc *gc, libxl__ev_ti= me *ev) OSEVENT_HOOK_VOID(timeout,modify, noop /* release nexus in _occurred_ */, &ev->nexus->for_app_reg, right_away); - LIBXL_TAILQ_REMOVE(&CTX->etimes, ev, entry); + XEN_TAILQ_REMOVE(&CTX->etimes, ev, entry); } } =20 @@ -640,7 +640,7 @@ static void time_occurs(libxl__egc *egc, libxl__ev_time= *etime, int rc) libxl__ev_xswatch *libxl__watch_slot_contents(libxl__gc *gc, int slotnum) { libxl__ev_watch_slot *slot =3D &CTX->watch_slots[slotnum]; - libxl__ev_watch_slot *slotcontents =3D LIBXL_SLIST_NEXT(slot, empty); + libxl__ev_watch_slot *slotcontents =3D XEN_SLIST_NEXT(slot, empty); =20 if (slotcontents =3D=3D NULL || ((uintptr_t)slotcontents >=3D (uintptr_t)CTX->watch_slots && @@ -672,7 +672,7 @@ libxl__ev_xswatch *libxl__watch_slot_contents(libxl__gc= *gc, int slotnum) static void libxl__set_watch_slot_contents(libxl__ev_watch_slot *slot, libxl__ev_xswatch *w) { - /* we look a bit behind the curtain of LIBXL_SLIST, to explicitly + /* we look a bit behind the curtain of XEN_SLIST, to explicitly * assign to the pointer that's the next link. See the comment * by the definition of libxl__ev_watch_slot */ slot->empty.sle_next =3D (void*)w; @@ -784,7 +784,7 @@ int libxl__ev_xswatch_register(libxl__gc *gc, libxl__ev= _xswatch *w, if (rc) goto out_rc; } =20 - if (LIBXL_SLIST_EMPTY(&CTX->watch_freeslots)) { + if (XEN_SLIST_EMPTY(&CTX->watch_freeslots)) { /* Free list is empty so there is not in fact a linked * free list in the array and we can safely realloc it */ int newarraysize =3D (CTX->watch_nslots + 1) << 2; @@ -794,14 +794,13 @@ int libxl__ev_xswatch_register(libxl__gc *gc, libxl__= ev_xswatch *w, CTX->watch_slots, sizeof(*newarray) * newarrays= ize); if (!newarray) goto out_nomem; for (i =3D CTX->watch_nslots; i < newarraysize; i++) - LIBXL_SLIST_INSERT_HEAD(&CTX->watch_freeslots, - &newarray[i], empty); + XEN_SLIST_INSERT_HEAD(&CTX->watch_freeslots, &newarray[i], emp= ty); CTX->watch_slots =3D newarray; CTX->watch_nslots =3D newarraysize; } - use =3D LIBXL_SLIST_FIRST(&CTX->watch_freeslots); + use =3D XEN_SLIST_FIRST(&CTX->watch_freeslots); assert(use); - LIBXL_SLIST_REMOVE_HEAD(&CTX->watch_freeslots, empty); + XEN_SLIST_REMOVE_HEAD(&CTX->watch_freeslots, empty); =20 path_copy =3D strdup(path); if (!path_copy) goto out_nomem; @@ -832,7 +831,7 @@ int libxl__ev_xswatch_register(libxl__gc *gc, libxl__ev= _xswatch *w, rc =3D ERROR_NOMEM; out_rc: if (use) - LIBXL_SLIST_INSERT_HEAD(&CTX->watch_freeslots, use, empty); + XEN_SLIST_INSERT_HEAD(&CTX->watch_freeslots, use, empty); free(path_copy); watches_check_fd_deregister(gc); CTX_UNLOCK; @@ -856,7 +855,7 @@ void libxl__ev_xswatch_deregister(libxl__gc *gc, libxl_= _ev_xswatch *w) LOGEV(ERROR, errno, "remove watch for path %s", w->path); =20 libxl__ev_watch_slot *slot =3D &CTX->watch_slots[w->slotnum]; - LIBXL_SLIST_INSERT_HEAD(&CTX->watch_freeslots, slot, empty); + XEN_SLIST_INSERT_HEAD(&CTX->watch_freeslots, slot, empty); w->slotnum =3D -1; CTX->nwatches--; watches_check_fd_deregister(gc); @@ -927,7 +926,7 @@ static void evtchn_fd_callback(libxl__egc *egc, libxl__= ev_fd *ev, return; } =20 - LIBXL_LIST_FOREACH(evev, &CTX->evtchns_waiting, entry) + XEN_LIST_FOREACH(evev, &CTX->evtchns_waiting, entry) if (port =3D=3D evev->port) goto found; /* not found */ @@ -937,7 +936,7 @@ static void evtchn_fd_callback(libxl__egc *egc, libxl__= ev_fd *ev, found: DBG("ev_evtchn=3D%p port=3D%d signaled", evev, port); evev->waiting =3D 0; - LIBXL_LIST_REMOVE(evev, entry); + XEN_LIST_REMOVE(evev, entry); evev->callback(egc, evev); } } @@ -972,7 +971,7 @@ int libxl__ctx_evtchn_init(libxl__gc *gc) { =20 static void evtchn_check_fd_deregister(libxl__gc *gc) { - if (CTX->xce && LIBXL_LIST_EMPTY(&CTX->evtchns_waiting)) + if (CTX->xce && XEN_LIST_EMPTY(&CTX->evtchns_waiting)) libxl__ev_fd_deregister(gc, &CTX->evtchn_efd); } =20 @@ -1003,7 +1002,7 @@ int libxl__ev_evtchn_wait(libxl__gc *gc, libxl__ev_ev= tchn *evev) } =20 evev->waiting =3D 1; - LIBXL_LIST_INSERT_HEAD(&CTX->evtchns_waiting, evev, entry); + XEN_LIST_INSERT_HEAD(&CTX->evtchns_waiting, evev, entry); return 0; =20 out: @@ -1020,7 +1019,7 @@ void libxl__ev_evtchn_cancel(libxl__gc *gc, libxl__ev= _evtchn *evev) return; =20 evev->waiting =3D 0; - LIBXL_LIST_REMOVE(evev, entry); + XEN_LIST_REMOVE(evev, entry); evtchn_check_fd_deregister(gc); } =20 @@ -1095,7 +1094,7 @@ int libxl__ev_devstate_wait(libxl__ao *ao, libxl__ev_= devstate *ds, =20 void libxl__ev_immediate_register(libxl__egc *egc, libxl__ev_immediate *ei) { - LIBXL_STAILQ_INSERT_TAIL(&egc->ev_immediates, ei, entry); + XEN_STAILQ_INSERT_TAIL(&egc->ev_immediates, ei, entry); } =20 /* @@ -1221,7 +1220,7 @@ static int beforepoll_internal(libxl__gc *gc, libxl__= poller *poller, =20 #define REQUIRE_FDS(BODY) do{ \ \ - LIBXL_LIST_FOREACH(efd, &CTX->efds, entry) \ + XEN_LIST_FOREACH(efd, &CTX->efds, entry) \ REQUIRE_FD(efd->fd, efd->events, BODY); \ \ REQUIRE_FD(poller->wakeup_pipe[0], POLLIN, BODY); \ @@ -1298,7 +1297,7 @@ static int beforepoll_internal(libxl__gc *gc, libxl__= poller *poller, poller->fds_deregistered =3D 0; poller->osevents_added =3D 0; =20 - libxl__ev_time *etime =3D LIBXL_TAILQ_FIRST(&CTX->etimes); + libxl__ev_time *etime =3D XEN_TAILQ_FIRST(&CTX->etimes); if (etime) { int our_timeout; struct timeval rel; @@ -1436,7 +1435,7 @@ static void afterpoll_internal(libxl__egc *egc, libxl= __poller *poller, * so that we don't call the same function again. */ int revents; =20 - LIBXL_LIST_FOREACH(efd, &CTX->efds, entry) { + XEN_LIST_FOREACH(efd, &CTX->efds, entry) { =20 if (!efd->events) continue; @@ -1454,7 +1453,7 @@ static void afterpoll_internal(libxl__egc *egc, libxl= __poller *poller, } =20 for (;;) { - libxl__ev_time *etime =3D LIBXL_TAILQ_FIRST(&CTX->etimes); + libxl__ev_time *etime =3D XEN_TAILQ_FIRST(&CTX->etimes); if (!etime) break; =20 @@ -1494,8 +1493,8 @@ void libxl_osevent_register_hooks(libxl_ctx *ctx, { GC_INIT(ctx); CTX_LOCK; - assert(LIBXL_LIST_EMPTY(&ctx->efds)); - assert(LIBXL_TAILQ_EMPTY(&ctx->etimes)); + assert(XEN_LIST_EMPTY(&ctx->efds)); + assert(XEN_TAILQ_EMPTY(&ctx->etimes)); ctx->osevent_hooks =3D hooks; ctx->osevent_user =3D user; CTX_UNLOCK; @@ -1534,7 +1533,7 @@ void libxl_osevent_occurred_timeout(libxl_ctx *ctx, v= oid *for_libxl) if (!ev) goto out; assert(!ev->infinite); =20 - LIBXL_TAILQ_REMOVE(&CTX->etimes, ev, entry); + XEN_TAILQ_REMOVE(&CTX->etimes, ev, entry); =20 time_occurs(egc, ev, ERROR_TIMEDOUT); =20 @@ -1577,9 +1576,9 @@ static void egc_run_callbacks(libxl__egc *egc) libxl__aop_occurred *aop, *aop_tmp; libxl__ev_immediate *ei; =20 - while (!LIBXL_STAILQ_EMPTY(&egc->ev_immediates)) { - ei =3D LIBXL_STAILQ_FIRST(&egc->ev_immediates); - LIBXL_STAILQ_REMOVE_HEAD(&egc->ev_immediates, entry); + while (!XEN_STAILQ_EMPTY(&egc->ev_immediates)) { + ei =3D XEN_STAILQ_FIRST(&egc->ev_immediates); + XEN_STAILQ_REMOVE_HEAD(&egc->ev_immediates, entry); CTX_LOCK; /* This callback is internal to libxl and expects CTX to be * locked. */ @@ -1587,15 +1586,15 @@ static void egc_run_callbacks(libxl__egc *egc) CTX_UNLOCK; } =20 - LIBXL_TAILQ_FOREACH_SAFE(ev, &egc->occurred_for_callback, link, ev_tmp= ) { - LIBXL_TAILQ_REMOVE(&egc->occurred_for_callback, ev, link); + XEN_TAILQ_FOREACH_SAFE(ev, &egc->occurred_for_callback, link, ev_tmp) { + XEN_TAILQ_REMOVE(&egc->occurred_for_callback, ev, link); LOG(DEBUG,"event %p callback type=3D%s", ev, libxl_event_type_to_string(ev->type)); CTX->event_hooks->event_occurs(CTX->event_hooks_user, ev); } =20 - LIBXL_TAILQ_FOREACH_SAFE(aop, &egc->aops_for_callback, entry, aop_tmp)= { - LIBXL_TAILQ_REMOVE(&egc->aops_for_callback, aop, entry); + XEN_TAILQ_FOREACH_SAFE(aop, &egc->aops_for_callback, entry, aop_tmp) { + XEN_TAILQ_REMOVE(&egc->aops_for_callback, aop, entry); LOG(DEBUG,"ao %p: progress report: callback aop=3D%p", aop->ao, ao= p); aop->how->callback(CTX, aop->ev, aop->how->for_callback); =20 @@ -1607,9 +1606,9 @@ static void egc_run_callbacks(libxl__egc *egc) } =20 libxl__ao *ao, *ao_tmp; - LIBXL_TAILQ_FOREACH_SAFE(ao, &egc->aos_for_callback, - entry_for_callback, ao_tmp) { - LIBXL_TAILQ_REMOVE(&egc->aos_for_callback, ao, entry_for_callback); + XEN_TAILQ_FOREACH_SAFE(ao, &egc->aos_for_callback, + entry_for_callback, ao_tmp) { + XEN_TAILQ_REMOVE(&egc->aos_for_callback, ao, entry_for_callback); LOG(DEBUG,"ao %p: completion callback", ao); ao->how.callback(CTX, ao->rc, ao->how.u.for_callback); CTX_LOCK; @@ -1648,12 +1647,12 @@ void libxl__event_occurred(libxl__egc *egc, libxl_e= vent *event) * from libxl. This helps avoid reentrancy bugs: parts of * libxl that call libxl__event_occurred do not have to worry * that libxl might be reentered at that point. */ - LIBXL_TAILQ_INSERT_TAIL(&egc->occurred_for_callback, event, link); + XEN_TAILQ_INSERT_TAIL(&egc->occurred_for_callback, event, link); return; } else { libxl__poller *poller; - LIBXL_TAILQ_INSERT_TAIL(&CTX->occurred, event, link); - LIBXL_LIST_FOREACH(poller, &CTX->pollers_event, entry) + XEN_TAILQ_INSERT_TAIL(&CTX->occurred, event, link); + XEN_LIST_FOREACH(poller, &CTX->pollers_event, entry) libxl__poller_wakeup(gc, poller); } } @@ -1691,7 +1690,7 @@ static int event_check_internal(libxl__egc *egc, libx= l_event **event_r, libxl_event *ev; int rc; =20 - LIBXL_TAILQ_FOREACH(ev, &CTX->occurred, link) { + XEN_TAILQ_FOREACH(ev, &CTX->occurred, link) { if (!(typemask & ((uint64_t)1 << ev->type))) continue; =20 @@ -1699,7 +1698,7 @@ static int event_check_internal(libxl__egc *egc, libx= l_event **event_r, continue; =20 /* got one! */ - LIBXL_TAILQ_REMOVE(&CTX->occurred, ev, link); + XEN_TAILQ_REMOVE(&CTX->occurred, ev, link); *event_r =3D ev; rc =3D 0; goto out; @@ -1820,9 +1819,9 @@ libxl__poller *libxl__poller_get(libxl__gc *gc) /* must be called with ctx locked */ int rc; =20 - libxl__poller *p =3D LIBXL_LIST_FIRST(&CTX->pollers_idle); + libxl__poller *p =3D XEN_LIST_FIRST(&CTX->pollers_idle); if (p) { - LIBXL_LIST_REMOVE(p, entry); + XEN_LIST_REMOVE(p, entry); } else { p =3D libxl__zalloc(NOGC, sizeof(*p)); =20 @@ -1833,16 +1832,15 @@ libxl__poller *libxl__poller_get(libxl__gc *gc) } } =20 - LIBXL_LIST_INSERT_HEAD(&CTX->pollers_active, p, - active_entry); + XEN_LIST_INSERT_HEAD(&CTX->pollers_active, p, active_entry); return p; } =20 void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p) { if (!p) return; - LIBXL_LIST_REMOVE(p, active_entry); - LIBXL_LIST_INSERT_HEAD(&ctx->pollers_idle, p, entry); + XEN_LIST_REMOVE(p, active_entry); + XEN_LIST_INSERT_HEAD(&ctx->pollers_idle, p, entry); } =20 void libxl__poller_wakeup(libxl__gc *gc, libxl__poller *p) @@ -2048,7 +2046,7 @@ void libxl__ao_create_fail(libxl__ao *ao) assert(!ao->complete); assert(!ao->progress_reports_outstanding); assert(!ao->aborting); - LIBXL_LIST_REMOVE(ao, inprogress_entry); + XEN_LIST_REMOVE(ao, inprogress_entry); libxl__ao__destroy(CTX, ao); } =20 @@ -2070,7 +2068,7 @@ void libxl__ao_complete(libxl__egc *egc, libxl__ao *a= o, int rc) assert(!ao->nested_progeny); ao->complete =3D 1; ao->rc =3D rc; - LIBXL_LIST_REMOVE(ao, inprogress_entry); + XEN_LIST_REMOVE(ao, inprogress_entry); if (ao->outstanding_killed_child) LOG(DEBUG, "ao %p: .. but waiting for %d fork to exit", ao, ao->outstanding_killed_child); @@ -2107,7 +2105,7 @@ void libxl__ao_complete_check_progress_reports(libxl_= _egc *egc, libxl__ao *ao) libxl__poller_wakeup(gc, ao->poller); } else if (ao->how.callback) { LOG(DEBUG, "ao %p: complete for callback", ao); - LIBXL_TAILQ_INSERT_TAIL(&egc->aos_for_callback, ao, entry_for_call= back); + XEN_TAILQ_INSERT_TAIL(&egc->aos_for_callback, ao, entry_for_callba= ck); } else { libxl_event *ev; ev =3D NEW_EVENT(egc, OPERATION_COMPLETE, ao->domid, ao->how.u.for= _event); @@ -2148,7 +2146,7 @@ libxl__ao *libxl__ao_create(libxl_ctx *ctx, uint32_t = domid, "ao %p: create: how=3D%p callback=3D%p poller=3D%p", ao, how, ao->how.callback, ao->poller); =20 - LIBXL_LIST_INSERT_HEAD(&ctx->aos_inprogress, ao, inprogress_entry); + XEN_LIST_INSERT_HEAD(&ctx->aos_inprogress, ao, inprogress_entry); =20 return ao; =20 @@ -2255,7 +2253,7 @@ static int ao__abort(libxl_ctx *ctx, libxl__ao *paren= t) =20 parent->aborting =3D 1; =20 - if (LIBXL_LIST_EMPTY(&parent->abortables)) { + if (XEN_LIST_EMPTY(&parent->abortables)) { LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "ao %p: abort requested and noted, but no-one intereste= d", parent); @@ -2264,13 +2262,13 @@ static int ao__abort(libxl_ctx *ctx, libxl__ao *par= ent) } =20 /* We keep calling abort hooks until there are none left */ - while (!LIBXL_LIST_EMPTY(&parent->abortables)) { + while (!XEN_LIST_EMPTY(&parent->abortables)) { assert(!parent->complete); =20 - libxl__ao_abortable *abrt =3D LIBXL_LIST_FIRST(&parent->abortables= ); + libxl__ao_abortable *abrt =3D XEN_LIST_FIRST(&parent->abortables); assert(parent =3D=3D ao_nested_root(abrt->ao)); =20 - LIBXL_LIST_REMOVE(abrt, entry); + XEN_LIST_REMOVE(abrt, entry); abrt->registered =3D 0; =20 LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, @@ -2300,7 +2298,7 @@ int libxl_ao_abort(libxl_ctx *ctx, const libxl_asynco= p_how *how) libxl__ctx_lock(ctx); int rc; =20 - LIBXL_LIST_FOREACH(search, &ctx->aos_inprogress, inprogress_entry) { + XEN_LIST_FOREACH(search, &ctx->aos_inprogress, inprogress_entry) { if (how) { /* looking for ao to be reported by callback or event */ if (search->poller) @@ -2356,7 +2354,7 @@ int libxl__ao_abortable_register(libxl__ao_abortable = *abrt) } =20 DBG("ao=3D%p, abrt=3D%p: registering (root=3D%p)", ao, abrt, root); - LIBXL_LIST_INSERT_HEAD(&root->abortables, abrt, entry); + XEN_LIST_INSERT_HEAD(&root->abortables, abrt, entry); abrt->registered =3D 1; =20 return 0; @@ -2372,7 +2370,7 @@ _hidden void libxl__ao_abortable_deregister(libxl__ao= _abortable *abrt) AO_GC; =20 DBG("ao=3D%p, abrt=3D%p: deregistering (root=3D%p)", ao, abrt, root); - LIBXL_LIST_REMOVE(abrt, entry); + XEN_LIST_REMOVE(abrt, entry); abrt->registered =3D 0; } =20 @@ -2408,7 +2406,7 @@ void libxl__ao_progress_report(libxl__egc *egc, libxl= __ao *ao, aop->ao =3D ao; aop->ev =3D ev; aop->how =3D how; - LIBXL_TAILQ_INSERT_TAIL(&egc->aops_for_callback, aop, entry); + XEN_TAILQ_INSERT_TAIL(&egc->aops_for_callback, aop, entry); LOG(DEBUG,"ao %p: progress report: callback queued aop=3D%p",ao,ao= p); } else { LOG(DEBUG,"ao %p: progress report: event queued ev=3D%p type=3D%s", diff --git a/tools/libs/light/libxl_fork.c b/tools/libs/light/libxl_fork.c index 5d47dceb8a..676a14bb28 100644 --- a/tools/libs/light/libxl_fork.c +++ b/tools/libs/light/libxl_fork.c @@ -37,14 +37,14 @@ */ =20 struct libxl__carefd { - LIBXL_LIST_ENTRY(libxl__carefd) entry; + XEN_LIST_ENTRY(libxl__carefd) entry; int fd; }; =20 static pthread_mutex_t no_forking =3D PTHREAD_MUTEX_INITIALIZER; static int atfork_registered; -static LIBXL_LIST_HEAD(, libxl__carefd) carefds =3D - LIBXL_LIST_HEAD_INITIALIZER(carefds); +static XEN_LIST_HEAD(, libxl__carefd) carefds =3D + XEN_LIST_HEAD_INITIALIZER(carefds); =20 /* Protected against concurrency by no_forking. sigchld_users is * protected against being interrupted by SIGCHLD (and thus read @@ -52,8 +52,8 @@ static LIBXL_LIST_HEAD(, libxl__carefd) carefds =3D * below). */ static bool sigchld_installed; /* 0 means not */ static pthread_mutex_t sigchld_defer_mutex =3D PTHREAD_MUTEX_INITIALIZER; -static LIBXL_LIST_HEAD(, libxl_ctx) sigchld_users =3D - LIBXL_LIST_HEAD_INITIALIZER(sigchld_users); +static XEN_LIST_HEAD(, libxl_ctx) sigchld_users =3D + XEN_LIST_HEAD_INITIALIZER(sigchld_users); static struct sigaction sigchld_saved_action; =20 static void sigchld_removehandler_core(void); /* idempotent */ @@ -105,7 +105,7 @@ libxl__carefd *libxl__carefd_record(libxl_ctx *ctx, int= fd) libxl_fd_set_cloexec(ctx, fd, 1); cf =3D libxl__zalloc(&ctx->nogc_gc, sizeof(*cf)); cf->fd =3D fd; - LIBXL_LIST_INSERT_HEAD(&carefds, cf, entry); + XEN_LIST_INSERT_HEAD(&carefds, cf, entry); return cf; } =20 @@ -141,7 +141,7 @@ void libxl_postfork_child_noexec(libxl_ctx *ctx) =20 atfork_lock(); =20 - LIBXL_LIST_FOREACH_SAFE(cf, &carefds, entry, cf_tmp) { + XEN_LIST_FOREACH_SAFE(cf, &carefds, entry, cf_tmp) { if (cf->fd >=3D 0) { r =3D close(cf->fd); if (r) @@ -151,7 +151,7 @@ void libxl_postfork_child_noexec(libxl_ctx *ctx) } free(cf); } - LIBXL_LIST_INIT(&carefds); + XEN_LIST_INIT(&carefds); =20 if (sigchld_installed) { /* We are in theory not at risk of concurrent execution of the @@ -172,7 +172,7 @@ void libxl_postfork_child_noexec(libxl_ctx *ctx) * use SIGCHLD, but instead just waits for the child(ren). */ defer_sigchld(); =20 - LIBXL_LIST_INIT(&sigchld_users); + XEN_LIST_INIT(&sigchld_users); /* After this the ->sigchld_user_registered entries in the * now-obsolete contexts may be lies. But that's OK because * no-one will look at them. */ @@ -190,7 +190,7 @@ int libxl__carefd_close(libxl__carefd *cf) atfork_lock(); int r =3D cf->fd < 0 ? 0 : close(cf->fd); int esave =3D errno; - LIBXL_LIST_REMOVE(cf, entry); + XEN_LIST_REMOVE(cf, entry); atfork_unlock(); free(cf); errno =3D esave; @@ -238,7 +238,7 @@ static void sigchld_handler(int signo) int r =3D pthread_mutex_lock(&sigchld_defer_mutex); assert(!r); =20 - LIBXL_LIST_FOREACH(notify, &sigchld_users, sigchld_users_entry) { + XEN_LIST_FOREACH(notify, &sigchld_users, sigchld_users_entry) { int e =3D libxl__self_pipe_wakeup(notify->sigchld_selfpipe[1]); if (e) abort(); /* errors are probably EBADF, very bad */ } @@ -362,11 +362,11 @@ static void sigchld_user_remove(libxl_ctx *ctx) /* id= empotent */ atfork_lock(); defer_sigchld(); =20 - LIBXL_LIST_REMOVE(ctx, sigchld_users_entry); + XEN_LIST_REMOVE(ctx, sigchld_users_entry); =20 release_sigchld(); =20 - if (LIBXL_LIST_EMPTY(&sigchld_users)) + if (XEN_LIST_EMPTY(&sigchld_users)) sigchld_removehandler_core(); =20 atfork_unlock(); @@ -404,7 +404,7 @@ int libxl__sigchld_needed(libxl__gc *gc) /* non-reentra= nt, idempotent */ =20 defer_sigchld(); =20 - LIBXL_LIST_INSERT_HEAD(&sigchld_users, CTX, sigchld_users_entry); + XEN_LIST_INSERT_HEAD(&sigchld_users, CTX, sigchld_users_entry); =20 release_sigchld(); atfork_unlock(); @@ -421,7 +421,7 @@ static bool chldmode_ours(libxl_ctx *ctx, bool creating) { switch (ctx->childproc_hooks->chldowner) { case libxl_sigchld_owner_libxl: - return creating || !LIBXL_LIST_EMPTY(&ctx->children); + return creating || !XEN_LIST_EMPTY(&ctx->children); case libxl_sigchld_owner_mainloop: return 0; case libxl_sigchld_owner_libxl_always: @@ -452,7 +452,7 @@ static void childproc_reaped_ours(libxl__egc *egc, libx= l__ev_child *ch, int status) { pid_t pid =3D ch->pid; - LIBXL_LIST_REMOVE(ch, entry); + XEN_LIST_REMOVE(ch, entry); ch->pid =3D -1; ch->callback(egc, ch, pid, status); } @@ -462,7 +462,7 @@ static int childproc_reaped(libxl__egc *egc, pid_t pid,= int status) EGC_GC; libxl__ev_child *ch; =20 - LIBXL_LIST_FOREACH(ch, &CTX->children, entry) + XEN_LIST_FOREACH(ch, &CTX->children, entry) if (ch->pid =3D=3D pid) goto found; =20 @@ -497,7 +497,7 @@ static void childproc_checkall(libxl__egc *egc) int status; pid_t got; =20 - LIBXL_LIST_FOREACH(ch, &CTX->children, entry) { + XEN_LIST_FOREACH(ch, &CTX->children, entry) { got =3D checked_waitpid(egc, ch->pid, &status); if (got) goto found; @@ -625,7 +625,7 @@ pid_t libxl__ev_child_fork(libxl__gc *gc, libxl__ev_chi= ld *ch, =20 ch->pid =3D pid; ch->callback =3D death; - LIBXL_LIST_INSERT_HEAD(&CTX->children, ch, entry); + XEN_LIST_INSERT_HEAD(&CTX->children, ch, entry); rc =3D pid; =20 out: @@ -640,7 +640,7 @@ void libxl_childproc_setmode(libxl_ctx *ctx, const libx= l_childproc_hooks *hooks, GC_INIT(ctx); CTX_LOCK; =20 - assert(LIBXL_LIST_EMPTY(&CTX->children)); + assert(XEN_LIST_EMPTY(&CTX->children)); =20 if (!hooks) hooks =3D &libxl__childproc_default_hooks; @@ -698,10 +698,10 @@ void libxl__ev_child_kill_deregister(libxl__ao *ao, l= ibxl__ev_child *ch, new_ch->ao =3D ao; new_ch->ch.pid =3D pid; new_ch->ch.callback =3D deregistered_child_callback; - LIBXL_LIST_INSERT_HEAD(&CTX->children, &new_ch->ch, entry); + XEN_LIST_INSERT_HEAD(&CTX->children, &new_ch->ch, entry); ao->outstanding_killed_child++; =20 - LIBXL_LIST_REMOVE(ch, entry); + XEN_LIST_REMOVE(ch, entry); ch->pid =3D -1; int r =3D kill(pid, sig); if (r) diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index 37d5c27756..c0e7779d97 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -245,7 +245,7 @@ struct libxl__ev_fd { short events; libxl__ev_fd_callback *func; /* remainder is private for libxl__ev_fd... */ - LIBXL_LIST_ENTRY(libxl__ev_fd) entry; + XEN_LIST_ENTRY(libxl__ev_fd) entry; libxl__osevent_hook_nexus *nexus; }; =20 @@ -260,7 +260,7 @@ struct libxl__ao_abortable { libxl__ao_abortable_callback *callback; /* remainder is private for abort machinery */ bool registered; - LIBXL_LIST_ENTRY(libxl__ao_abortable) entry; + XEN_LIST_ENTRY(libxl__ao_abortable) entry; /* * For nested aos: * Semantically, abort affects the whole tree of aos, @@ -296,7 +296,7 @@ struct libxl__ev_time { libxl__ev_time_callback *func; /* remainder is private for libxl__ev_time... */ int infinite; /* not registered in list or with app if infinite */ - LIBXL_TAILQ_ENTRY(libxl__ev_time) entry; + XEN_TAILQ_ENTRY(libxl__ev_time) entry; struct timeval abs; libxl__osevent_hook_nexus *nexus; libxl__ao_abortable abrt; @@ -323,7 +323,7 @@ struct libxl__ev_evtchn { int port; /* remainder is private for libxl__ev_evtchn_... */ bool waiting; - LIBXL_LIST_ENTRY(libxl__ev_evtchn) entry; + XEN_LIST_ENTRY(libxl__ev_evtchn) entry; }; =20 /* @@ -341,7 +341,7 @@ struct libxl__ev_evtchn { * xswatch pointers when we store and retrieve them. */ typedef struct libxl__ev_watch_slot { - LIBXL_SLIST_ENTRY(struct libxl__ev_watch_slot) empty; + XEN_SLIST_ENTRY(struct libxl__ev_watch_slot) empty; } libxl__ev_watch_slot; =20 _hidden libxl__ev_xswatch *libxl__watch_slot_contents(libxl__gc *gc, @@ -357,7 +357,7 @@ struct libxl__ev_child { pid_t pid; /* -1 means unused ("unregistered", ie Idle) */ libxl__ev_child_callback *callback; /* remainder is private for libxl__ev_... */ - LIBXL_LIST_ENTRY(struct libxl__ev_child) entry; + XEN_LIST_ENTRY(struct libxl__ev_child) entry; }; =20 /* libxl__ev_immediate @@ -370,7 +370,7 @@ struct libxl__ev_immediate { /* filled by user */ void (*callback)(libxl__egc *, libxl__ev_immediate *); /* private to libxl__ev_immediate */ - LIBXL_STAILQ_ENTRY(libxl__ev_immediate) entry; + XEN_STAILQ_ENTRY(libxl__ev_immediate) entry; }; void libxl__ev_immediate_register(libxl__egc *, libxl__ev_immediate *); =20 @@ -582,7 +582,7 @@ _hidden void libxl__qmp_param_add_integer(libxl__gc *gc, struct libxl__evgen_domain_death { uint32_t domid; unsigned shutdown_reported:1, death_reported:1; - LIBXL_TAILQ_ENTRY(libxl_evgen_domain_death) entry; + XEN_TAILQ_ENTRY(libxl_evgen_domain_death) entry; /* on list .death_reported ? CTX->death_list : CTX->death_reported= */ libxl_ev_user user; }; @@ -592,7 +592,7 @@ libxl__evdisable_domain_death(libxl__gc*, libxl_evgen_d= omain_death*); struct libxl__evgen_disk_eject { libxl__ev_xswatch watch; uint32_t domid; - LIBXL_LIST_ENTRY(libxl_evgen_disk_eject) entry; + XEN_LIST_ENTRY(libxl_evgen_disk_eject) entry; libxl_ev_user user; char *vdev, *be_ptr_path; }; @@ -620,7 +620,7 @@ struct libxl__poller { * The "poller_app" is never idle, but is sometimes on * pollers_event. */ - LIBXL_LIST_ENTRY(libxl__poller) entry; + XEN_LIST_ENTRY(libxl__poller) entry; =20 struct pollfd *fd_polls; int fd_polls_allocd; @@ -653,7 +653,7 @@ struct libxl__poller { * a promise to also make this check, so the baton will never be * dropped. */ - LIBXL_LIST_ENTRY(libxl__poller) active_entry; + XEN_LIST_ENTRY(libxl__poller) active_entry; bool fds_deregistered; bool osevents_added; }; @@ -687,7 +687,7 @@ struct libxl__ctx { * documented in the libxl public interface. */ =20 - LIBXL_TAILQ_HEAD(libxl__event_list, libxl_event) occurred; + XEN_TAILQ_HEAD(libxl__event_list, libxl_event) occurred; =20 int osevent_in_hook; const libxl_osevent_hooks *osevent_hooks; @@ -696,40 +696,40 @@ struct libxl__ctx { * for restrictions on the use of the osevent fields. */ =20 libxl__poller *poller_app; /* libxl_osevent_beforepoll and _afterpoll = */ - LIBXL_LIST_HEAD(, libxl__poller) pollers_event, pollers_idle; - LIBXL_LIST_HEAD(, libxl__poller) pollers_active; + XEN_LIST_HEAD(, libxl__poller) pollers_event, pollers_idle; + XEN_LIST_HEAD(, libxl__poller) pollers_active; =20 - LIBXL_SLIST_HEAD(libxl__osevent_hook_nexi, libxl__osevent_hook_nexus) + XEN_SLIST_HEAD(libxl__osevent_hook_nexi, libxl__osevent_hook_nexus) hook_fd_nexi_idle, hook_timeout_nexi_idle; - LIBXL_LIST_HEAD(, libxl__ev_fd) efds; - LIBXL_TAILQ_HEAD(, libxl__ev_time) etimes; + XEN_LIST_HEAD(, libxl__ev_fd) efds; + XEN_TAILQ_HEAD(, libxl__ev_time) etimes; =20 libxl__ev_watch_slot *watch_slots; int watch_nslots, nwatches; - LIBXL_SLIST_HEAD(, libxl__ev_watch_slot) watch_freeslots; + XEN_SLIST_HEAD(, libxl__ev_watch_slot) watch_freeslots; uint32_t watch_counter; /* helps disambiguate slot reuse */ libxl__ev_fd watch_efd; =20 xenevtchn_handle *xce; /* waiting must be done only with libxl__ev_evt= chn* */ - LIBXL_LIST_HEAD(, libxl__ev_evtchn) evtchns_waiting; + XEN_LIST_HEAD(, libxl__ev_evtchn) evtchns_waiting; libxl__ev_fd evtchn_efd; =20 - LIBXL_LIST_HEAD(, libxl__ao) aos_inprogress; + XEN_LIST_HEAD(, libxl__ao) aos_inprogress; =20 - LIBXL_TAILQ_HEAD(libxl__evgen_domain_death_list, libxl_evgen_domain_de= ath) + XEN_TAILQ_HEAD(libxl__evgen_domain_death_list, libxl_evgen_domain_deat= h) death_list /* sorted by domid */, death_reported; libxl__ev_xswatch death_watch; =20 - LIBXL_LIST_HEAD(, libxl_evgen_disk_eject) disk_eject_evgens; + XEN_LIST_HEAD(, libxl_evgen_disk_eject) disk_eject_evgens; =20 const libxl_childproc_hooks *childproc_hooks; void *childproc_user; int sigchld_selfpipe[2]; /* [0]=3D=3D-1 means handler not installed */ libxl__ev_fd sigchld_selfpipe_efd; - LIBXL_LIST_HEAD(, libxl__ev_child) children; + XEN_LIST_HEAD(, libxl__ev_child) children; bool sigchld_user_registered; - LIBXL_LIST_ENTRY(libxl_ctx) sigchld_users_entry; + XEN_LIST_ENTRY(libxl_ctx) sigchld_users_entry; =20 libxl_version_info version_info; =20 @@ -774,9 +774,9 @@ struct libxl__egc { * The egc and its gc may be accessed only on the creating thread. */ struct libxl__gc gc; struct libxl__event_list occurred_for_callback; - LIBXL_TAILQ_HEAD(, libxl__ao) aos_for_callback; - LIBXL_TAILQ_HEAD(, libxl__aop_occurred) aops_for_callback; - LIBXL_STAILQ_HEAD(, libxl__ev_immediate) ev_immediates; + XEN_TAILQ_HEAD(, libxl__ao) aos_for_callback; + XEN_TAILQ_HEAD(, libxl__aop_occurred) aops_for_callback; + XEN_STAILQ_HEAD(, libxl__ev_immediate) ev_immediates; }; =20 struct libxl__aop_occurred { @@ -787,7 +787,7 @@ struct libxl__aop_occurred { * While an aop exists, it corresponds to one refcount in * ao->progress_reports_outstanding, preventing ao destruction. */ - LIBXL_TAILQ_ENTRY(libxl__aop_occurred) entry; + XEN_TAILQ_ENTRY(libxl__aop_occurred) entry; libxl__ao *ao; libxl_event *ev; const libxl_asyncprogress_how *how; @@ -819,13 +819,13 @@ struct libxl__ao { int nested_progeny; int progress_reports_outstanding; int rc; - LIBXL_LIST_HEAD(, libxl__ao_abortable) abortables; - LIBXL_LIST_ENTRY(libxl__ao) inprogress_entry; + XEN_LIST_HEAD(, libxl__ao_abortable) abortables; + XEN_LIST_ENTRY(libxl__ao) inprogress_entry; libxl__gc gc; libxl_asyncop_how how; libxl__poller *poller; uint32_t domid; - LIBXL_TAILQ_ENTRY(libxl__ao) entry_for_callback; + XEN_TAILQ_ENTRY(libxl__ao) entry_for_callback; int outstanding_killed_child; }; =20 @@ -2379,10 +2379,10 @@ bool libxl__stubdomain_is_linux(libxl_domain_build_= info *b_info) =20 #define LIBXL_INIT_EGC(egc,ctx) do{ \ LIBXL_INIT_GC((egc).gc,ctx); \ - LIBXL_TAILQ_INIT(&(egc).occurred_for_callback); \ - LIBXL_TAILQ_INIT(&(egc).aos_for_callback); \ - LIBXL_TAILQ_INIT(&(egc).aops_for_callback); \ - LIBXL_STAILQ_INIT(&(egc).ev_immediates); \ + XEN_TAILQ_INIT(&(egc).occurred_for_callback); \ + XEN_TAILQ_INIT(&(egc).aos_for_callback); \ + XEN_TAILQ_INIT(&(egc).aops_for_callback); \ + XEN_STAILQ_INIT(&(egc).ev_immediates); \ } while(0) =20 _hidden void libxl__egc_ao_cleanup_1_baton(libxl__gc *gc); @@ -3141,7 +3141,7 @@ typedef void libxl__datacopier_callback(libxl__egc *e= gc, =20 struct libxl__datacopier_buf { /* private to datacopier */ - LIBXL_TAILQ_ENTRY(libxl__datacopier_buf) entry; + XEN_TAILQ_ENTRY(libxl__datacopier_buf) entry; int used; char buf[1000]; }; @@ -3163,7 +3163,7 @@ struct libxl__datacopier_state { libxl__ao_abortable abrt; libxl__ev_fd toread, towrite; ssize_t used; - LIBXL_TAILQ_HEAD(libxl__datacopier_bufs, libxl__datacopier_buf) bufs; + XEN_TAILQ_HEAD(libxl__datacopier_bufs, libxl__datacopier_buf) bufs; }; =20 _hidden void libxl__datacopier_init(libxl__datacopier_state *dc); @@ -3443,7 +3443,7 @@ typedef struct libxl__stream_read_state libxl__stream= _read_state; =20 typedef struct libxl__sr_record_buf { /* private to stream read helper */ - LIBXL_STAILQ_ENTRY(struct libxl__sr_record_buf) entry; + XEN_STAILQ_ENTRY(struct libxl__sr_record_buf) entry; libxl__sr_rec_hdr hdr; void *body; /* iff hdr.length !=3D 0 */ } libxl__sr_record_buf; @@ -3473,7 +3473,7 @@ struct libxl__stream_read_state { /* Main stream-reading data. */ libxl__datacopier_state dc; /* Only used when reading a record */ libxl__sr_hdr hdr; - LIBXL_STAILQ_HEAD(, libxl__sr_record_buf) record_queue; /* NOGC */ + XEN_STAILQ_HEAD(, libxl__sr_record_buf) record_queue; /* NOGC */ enum { SRS_PHASE_NORMAL, SRS_PHASE_BUFFERING, @@ -4599,9 +4599,9 @@ static inline int libxl__defbool_is_default(libxl_def= bool *db) #define LIBXL_TAILQ_INSERT_SORTED(head, entry, elm_new, elm_search, \ search_body, new_after_search_p) \ do { \ - for ((elm_search) =3D LIBXL_TAILQ_FIRST((head)); \ + for ((elm_search) =3D XEN_TAILQ_FIRST((head)); \ (elm_search); \ - (elm_search) =3D LIBXL_TAILQ_NEXT((elm_search), entry)) { \ + (elm_search) =3D XEN_TAILQ_NEXT((elm_search), entry)) { \ search_body; \ if (!(new_after_search_p)) \ break; \ @@ -4610,9 +4610,9 @@ static inline int libxl__defbool_is_default(libxl_def= bool *db) * to place elm_new, or NULL meaning we want to put elm_new at \ * the end */ \ if ((elm_search)) \ - LIBXL_TAILQ_INSERT_BEFORE((elm_search), (elm_new), entry); \ + XEN_TAILQ_INSERT_BEFORE((elm_search), (elm_new), entry); \ else \ - LIBXL_TAILQ_INSERT_TAIL((head), (elm_new), entry); \ + XEN_TAILQ_INSERT_TAIL((head), (elm_new), entry); \ } while(0) =20 =20 diff --git a/tools/libs/light/libxl_qmp.c b/tools/libs/light/libxl_qmp.c index fb146a54cb..8faa102e4d 100644 --- a/tools/libs/light/libxl_qmp.c +++ b/tools/libs/light/libxl_qmp.c @@ -63,7 +63,7 @@ =20 #include =20 -#include "_libxl_list.h" +#include "_xen_list.h" #include "libxl_internal.h" =20 /* #define DEBUG_RECEIVED */ @@ -107,7 +107,7 @@ typedef struct callback_id_pair { qmp_callback_t callback; void *opaque; qmp_request_context *context; - LIBXL_STAILQ_ENTRY(struct callback_id_pair) next; + XEN_STAILQ_ENTRY(struct callback_id_pair) next; } callback_id_pair; =20 struct libxl__qmp_handler { @@ -123,7 +123,7 @@ struct libxl__qmp_handler { uint32_t domid; =20 int last_id_used; - LIBXL_STAILQ_HEAD(callback_list, callback_id_pair) callback_list; + XEN_STAILQ_HEAD(callback_list, callback_id_pair) callback_list; struct { int major; int minor; @@ -189,7 +189,7 @@ static callback_id_pair *qmp_get_callback_from_id(libxl= __qmp_handler *qmp, if (id_object) { id =3D libxl__json_object_get_integer(id_object); =20 - LIBXL_STAILQ_FOREACH(pp, &qmp->callback_list, next) { + XEN_STAILQ_FOREACH(pp, &qmp->callback_list, next) { if (pp->id =3D=3D id) { return pp; } @@ -217,7 +217,7 @@ static void qmp_handle_error_response(libxl__gc *gc, li= bxl__qmp_handler *qmp, /* tell that the id have been processed */ qmp->wait_for_id =3D 0; } - LIBXL_STAILQ_REMOVE(&qmp->callback_list, pp, callback_id_pair, nex= t); + XEN_STAILQ_REMOVE(&qmp->callback_list, pp, callback_id_pair, next); free(pp); } =20 @@ -266,8 +266,7 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qm= p_handler *qmp, /* tell that the id have been processed */ qmp->wait_for_id =3D 0; } - LIBXL_STAILQ_REMOVE(&qmp->callback_list, pp, callback_id_pair, - next); + XEN_STAILQ_REMOVE(&qmp->callback_list, pp, callback_id_pair, n= ext); free(pp); } return 0; @@ -325,7 +324,7 @@ static libxl__qmp_handler *qmp_init_handler(libxl__gc *= gc, uint32_t domid) qmp->domid =3D domid; qmp->timeout =3D 5; =20 - LIBXL_STAILQ_INIT(&qmp->callback_list); + XEN_STAILQ_INIT(&qmp->callback_list); =20 return qmp; } @@ -383,7 +382,7 @@ static void qmp_close(libxl__qmp_handler *qmp) callback_id_pair *tmp =3D NULL; =20 close(qmp->qmp_fd); - LIBXL_STAILQ_FOREACH(pp, &qmp->callback_list, next) { + XEN_STAILQ_FOREACH(pp, &qmp->callback_list, next) { free(tmp); tmp =3D pp; } @@ -547,7 +546,7 @@ static char *qmp_send_prepare(libxl__gc *gc, libxl__qmp= _handler *qmp, elm->callback =3D callback; elm->opaque =3D opaque; elm->context =3D context; - LIBXL_STAILQ_INSERT_TAIL(&qmp->callback_list, elm, next); + XEN_STAILQ_INSERT_TAIL(&qmp->callback_list, elm, next); =20 LOGD(DEBUG, qmp->domid, "next qmp command: '%s'", buf); =20 diff --git a/tools/libs/light/libxl_stream_read.c b/tools/libs/light/libxl_= stream_read.c index 99a6714e76..e64e8f0ead 100644 --- a/tools/libs/light/libxl_stream_read.c +++ b/tools/libs/light/libxl_stream_read.c @@ -214,7 +214,7 @@ void libxl__stream_read_init(libxl__stream_read_state *= stream) stream->sync_teardown =3D false; FILLZERO(stream->dc); FILLZERO(stream->hdr); - LIBXL_STAILQ_INIT(&stream->record_queue); + XEN_STAILQ_INIT(&stream->record_queue); stream->phase =3D SRS_PHASE_NORMAL; stream->recursion_guard =3D false; stream->incoming_record =3D NULL; @@ -402,7 +402,7 @@ static void stream_continue(libxl__egc *egc, * processing the record. There should never be two records * in the queue. */ - if (LIBXL_STAILQ_EMPTY(&stream->record_queue)) + if (XEN_STAILQ_EMPTY(&stream->record_queue)) setup_read_record(egc, stream); else { if (process_record(egc, stream)) @@ -412,7 +412,7 @@ static void stream_continue(libxl__egc *egc, * process_record() had better have consumed the one and * only record in the queue. */ - assert(LIBXL_STAILQ_EMPTY(&stream->record_queue)); + assert(XEN_STAILQ_EMPTY(&stream->record_queue)); } break; =20 @@ -428,7 +428,7 @@ static void stream_continue(libxl__egc *egc, * the tail to spot the CHECKPOINT_END record, and switch to * the unbuffering phase. */ - libxl__sr_record_buf *rec =3D LIBXL_STAILQ_LAST( + libxl__sr_record_buf *rec =3D XEN_STAILQ_LAST( &stream->record_queue, libxl__sr_record_buf, entry); =20 assert(stream->in_checkpoint); @@ -537,7 +537,7 @@ static void record_body_done(libxl__egc *egc, if (rc) goto err; =20 - LIBXL_STAILQ_INSERT_TAIL(&stream->record_queue, rec, entry); + XEN_STAILQ_INSERT_TAIL(&stream->record_queue, rec, entry); stream->incoming_record =3D NULL; =20 stream_continue(egc, stream); @@ -567,9 +567,9 @@ static bool process_record(libxl__egc *egc, int rc =3D 0; =20 /* Pop a record from the head of the queue. */ - assert(!LIBXL_STAILQ_EMPTY(&stream->record_queue)); - rec =3D LIBXL_STAILQ_FIRST(&stream->record_queue); - LIBXL_STAILQ_REMOVE_HEAD(&stream->record_queue, entry); + assert(!XEN_STAILQ_EMPTY(&stream->record_queue)); + rec =3D XEN_STAILQ_FIRST(&stream->record_queue); + XEN_STAILQ_REMOVE_HEAD(&stream->record_queue, entry); =20 LOG(DEBUG, "Record: %u, length %u", rec->hdr.type, rec->hdr.length); =20 @@ -813,9 +813,9 @@ static void stream_done(libxl__egc *egc, =20 /* The record queue had better be empty if the stream believes * itself to have been successful. */ - assert(LIBXL_STAILQ_EMPTY(&stream->record_queue) || stream->rc); + assert(XEN_STAILQ_EMPTY(&stream->record_queue) || stream->rc); =20 - LIBXL_STAILQ_FOREACH_SAFE(rec, &stream->record_queue, entry, trec) + XEN_STAILQ_FOREACH_SAFE(rec, &stream->record_queue, entry, trec) free_record(rec); =20 if (!stream->back_channel) { --=20 2.34.1 From nobody Mon May 13 22:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1644304034; cv=none; d=zohomail.com; s=zohoarc; b=GtF8qMNJj+hOe4SYE54BpUwD3McBkz9sLu4Bl9s2TlInCmA6ALCwIVi4lovWC+V5ez2oH1nIcvvckc9zLSw/SQLCjb8qNCE0tEmxgHHH0ZHZd4h9gPiZrDjo4hAX3L31OzqOVltxvPlaR2xGNC4COwOQFc2jEMX9/6ugHTtTC+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644304034; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y3JYUku98qeZg6VOnInB3O+12NYpmiH94/YoTHJL2nY=; b=HUeOo6dbPT0kUrIpLOTrPqhy86S1zcXgLu2S5ma1qaiaNZYDmMD4SK7RG94ldMQOPcNdLcGIMRat0gVIxjE/+5qcjuRv8uvcX0EyCxDUeCH0OKhuJglewx1oUe1vePO1ZPWmiY8NGOFNgriv/R00bmyat706X79suDwM1M6gh9s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644304034720205.85274277501094; Mon, 7 Feb 2022 23:07:14 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.267539.461288 (Exim 4.92) (envelope-from ) id 1nHKaL-0008Qb-Hn; Tue, 08 Feb 2022 07:06:45 +0000 Received: by outflank-mailman (output) from mailman id 267539.461288; Tue, 08 Feb 2022 07:06:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHKaL-0008QU-E9; Tue, 08 Feb 2022 07:06:45 +0000 Received: by outflank-mailman (input) for mailman id 267539; Tue, 08 Feb 2022 07:06:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHKaJ-0008AS-KA for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 07:06:43 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ab0a14c1-88ad-11ec-8f75-fffcc8bd4f1a; Tue, 08 Feb 2022 08:06:42 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0DE5C21106; Tue, 8 Feb 2022 07:06:42 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C09B613B7F; Tue, 8 Feb 2022 07:06:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id APeoLYEWAmKxHgAAMHmgww (envelope-from ); Tue, 08 Feb 2022 07:06:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ab0a14c1-88ad-11ec-8f75-fffcc8bd4f1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1644304002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y3JYUku98qeZg6VOnInB3O+12NYpmiH94/YoTHJL2nY=; b=e3dxfCJaE87YJujX3F8bFRkPyXU/qA/bzF08wB6YXTUTKBRgV1aoYKGfA+O+4W+fbD9DDV pBwIbabSpdcJoe2SHv4MiEBy+4+FeYOqr/UlYSAlwVzJPn8hM2WGplgESwOgiO3NtGX8mf 4Q/rGZ7Wl4dslBsX3wl4jxbBahcZWGs= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Anthony PERARD Subject: [PATCH v3 3/5] tools/libs/toolcore: replace _xentoolcore_list.h with _xen_list.h Date: Tue, 8 Feb 2022 08:06:36 +0100 Message-Id: <20220208070638.5909-4-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220208070638.5909-1-jgross@suse.com> References: <20220208070638.5909-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1644304036627100001 Content-Type: text/plain; charset="utf-8" Remove generating _xentoolcore_list.h and use the common _xen_list.h instead. Signed-off-by: Juergen Gross Acked-by: Anthony PERARD --- v3: - fix build (Anthony PERARD) --- .gitignore | 1 - tools/include/xentoolcore_internal.h | 4 ++-- tools/libs/toolcore/Makefile | 8 -------- tools/libs/toolcore/handlereg.c | 8 ++++---- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 3f9d55ba87..afe78c787c 100644 --- a/.gitignore +++ b/.gitignore @@ -227,7 +227,6 @@ tools/hotplug/NetBSD/rc.d/xencommons tools/hotplug/NetBSD/rc.d/xendriverdomain tools/include/acpi tools/include/_libxl*.h -tools/include/_xentoolcore_list.h tools/include/xen/* tools/include/xen-xsm/* tools/include/xen-foreign/*.(c|h|size) diff --git a/tools/include/xentoolcore_internal.h b/tools/include/xentoolco= re_internal.h index 04f5848f09..deccefd612 100644 --- a/tools/include/xentoolcore_internal.h +++ b/tools/include/xentoolcore_internal.h @@ -27,7 +27,7 @@ #include =20 #include "xentoolcore.h" -#include "_xentoolcore_list.h" +#include "_xen_list.h" =20 /*---------- active handle registration ----------*/ =20 @@ -87,7 +87,7 @@ typedef int Xentoolcore__Restrict_Callback(Xentoolcore__A= ctive_Handle*, =20 struct Xentoolcore__Active_Handle { Xentoolcore__Restrict_Callback *restrict_callback; - XENTOOLCORE_LIST_ENTRY(Xentoolcore__Active_Handle) entry; + XEN_LIST_ENTRY(Xentoolcore__Active_Handle) entry; }; =20 void xentoolcore__register_active_handle(Xentoolcore__Active_Handle*); diff --git a/tools/libs/toolcore/Makefile b/tools/libs/toolcore/Makefile index ed4ae00694..9c013b2879 100644 --- a/tools/libs/toolcore/Makefile +++ b/tools/libs/toolcore/Makefile @@ -3,7 +3,6 @@ include $(XEN_ROOT)/tools/Rules.mk =20 MAJOR =3D 1 MINOR =3D 0 -AUTOINCS :=3D $(XEN_INCLUDE)/_xentoolcore_list.h =20 LIBHEADER :=3D xentoolcore.h =20 @@ -12,10 +11,3 @@ SRCS-y +=3D handlereg.c include $(XEN_ROOT)/tools/libs/libs.mk =20 PKG_CONFIG_DESC :=3D Central support for Xen Hypervisor userland libraries - -$(LIB_OBJS): $(AUTOINCS) -$(PIC_OBJS): $(AUTOINCS) - -$(XEN_INCLUDE)/_xentoolcore_list.h: $(XEN_INCLUDE)/xen-external/bsd-sys-qu= eue-h-seddery $(XEN_INCLUDE)/xen-external/bsd-sys-queue.h - $(PERL) $^ --prefix=3Dxentoolcore >$(notdir $@).new - $(call move-if-changed,$(notdir $@).new,$@) diff --git a/tools/libs/toolcore/handlereg.c b/tools/libs/toolcore/handlere= g.c index baec55e2a4..b43cb0e8ac 100644 --- a/tools/libs/toolcore/handlereg.c +++ b/tools/libs/toolcore/handlereg.c @@ -31,7 +31,7 @@ #include =20 static pthread_mutex_t handles_lock =3D PTHREAD_MUTEX_INITIALIZER; -static XENTOOLCORE_LIST_HEAD(, Xentoolcore__Active_Handle) handles; +static XEN_LIST_HEAD(, Xentoolcore__Active_Handle) handles; =20 static void lock(void) { int e =3D pthread_mutex_lock(&handles_lock); @@ -45,13 +45,13 @@ static void unlock(void) { =20 void xentoolcore__register_active_handle(Xentoolcore__Active_Handle *ah) { lock(); - XENTOOLCORE_LIST_INSERT_HEAD(&handles, ah, entry); + XEN_LIST_INSERT_HEAD(&handles, ah, entry); unlock(); } =20 void xentoolcore__deregister_active_handle(Xentoolcore__Active_Handle *ah)= { lock(); - XENTOOLCORE_LIST_REMOVE(ah, entry); + XEN_LIST_REMOVE(ah, entry); unlock(); } =20 @@ -60,7 +60,7 @@ int xentoolcore_restrict_all(domid_t domid) { Xentoolcore__Active_Handle *ah; =20 lock(); - XENTOOLCORE_LIST_FOREACH(ah, &handles, entry) { + XEN_LIST_FOREACH(ah, &handles, entry) { r =3D ah->restrict_callback(ah, domid); if (r) goto out; } --=20 2.34.1 From nobody Mon May 13 22:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1644304033; cv=none; d=zohomail.com; s=zohoarc; b=OeYI0/sf7zJuPk1lzyBKeatF6reSLOsCrCH0eMqdNigVYFRrOvAPMj10pdOUdGKR2NH42c/zjsNnoy/fC2jRN3ahO8CWgQRBq7IaRJzAAXKyURfnOhhAVJawW5wXeBjTc+ltfd8Vau2Si5xB5yuYNJCudt/5lxT7zkgQIUNruV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644304033; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=O9L5VCHqoZDN85JbspHZhwKfGz0YeeeAr6knmmOSjvM=; b=bBMBop5d6VGUj6T9SGKWT+Zkv5CN5SFX9349lXrtVC2eYRCP0bH4LVmDbJGT5lapbqeirC0TRoGL2gWDxgj682qNeOKPwdxNfzin4JCWZjKp0vFRCLNJ98Gk/jpmzQItB6viqrWrtJElEtEJ7/cHfQonOHqbwhKdlCVDMnMbI/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644304033659790.6295058808255; Mon, 7 Feb 2022 23:07:13 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.267540.461293 (Exim 4.92) (envelope-from ) id 1nHKaL-000068-W7; Tue, 08 Feb 2022 07:06:45 +0000 Received: by outflank-mailman (output) from mailman id 267540.461293; Tue, 08 Feb 2022 07:06:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHKaL-0008Vx-Rq; Tue, 08 Feb 2022 07:06:45 +0000 Received: by outflank-mailman (input) for mailman id 267540; Tue, 08 Feb 2022 07:06:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHKaK-0008AS-Jw for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 07:06:44 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ab265d4d-88ad-11ec-8f75-fffcc8bd4f1a; Tue, 08 Feb 2022 08:06:42 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3D4EB21107; Tue, 8 Feb 2022 07:06:42 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 153E113483; Tue, 8 Feb 2022 07:06:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2JryA4IWAmKxHgAAMHmgww (envelope-from ); Tue, 08 Feb 2022 07:06:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ab265d4d-88ad-11ec-8f75-fffcc8bd4f1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1644304002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O9L5VCHqoZDN85JbspHZhwKfGz0YeeeAr6knmmOSjvM=; b=pFucpYKdrfeC2ykt7q9s1nWnrqV9sAt2QBSB7t8ntYAIrAVTwHTjybqR5qsz4S4axFwM0c I3lTx8sVoDDqvpJrj+v2WwBEYcCNynb/JSFyNGONSn9qt+eJkoHzm8058dHyjHkkwSLTOQ uVQaVMTC5a+vK4a39m9Btnset4Z+ZJY= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD Subject: [PATCH v3 4/5] tools/libs/evtchn: use _xen_list.h Date: Tue, 8 Feb 2022 08:06:37 +0100 Message-Id: <20220208070638.5909-5-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220208070638.5909-1-jgross@suse.com> References: <20220208070638.5909-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1644304034577100001 Content-Type: text/plain; charset="utf-8" Instead of including xen-external/bsd-sys-queue.h use the header _xen_list.h in minios.c. Signed-off-by: Juergen Gross Acked-by: Anthony PERARD --- tools/libs/evtchn/minios.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/libs/evtchn/minios.c b/tools/libs/evtchn/minios.c index 30f98bc7e4..65cfccfd09 100644 --- a/tools/libs/evtchn/minios.c +++ b/tools/libs/evtchn/minios.c @@ -20,7 +20,7 @@ * Split off from xc_minios.c */ =20 -#include "xen-external/bsd-sys-queue.h" +#include "_xen_list.h" #include #include #include @@ -38,10 +38,10 @@ =20 #include "private.h" =20 -LIST_HEAD(port_list, port_info); +XEN_LIST_HEAD(port_list, struct port_info); =20 struct port_info { - LIST_ENTRY(port_info) list; + XEN_LIST_ENTRY(struct port_info) list; evtchn_port_t port; bool pending; bool bound; @@ -62,7 +62,7 @@ static struct port_info *port_alloc(xenevtchn_handle *xce) port_info->port =3D -1; port_info->bound =3D false; =20 - LIST_INSERT_HEAD(port_list, port_info, list); + XEN_LIST_INSERT_HEAD(port_list, port_info, list); =20 return port_info; } @@ -72,7 +72,7 @@ static void port_dealloc(struct port_info *port_info) if ( port_info->bound ) unbind_evtchn(port_info->port); =20 - LIST_REMOVE(port_info, list); + XEN_LIST_REMOVE(port_info, list); free(port_info); } =20 @@ -81,7 +81,7 @@ static int evtchn_close_fd(struct file *file) struct port_info *port_info, *tmp; struct port_list *port_list =3D file->dev; =20 - LIST_FOREACH_SAFE(port_info, port_list, list, tmp) + XEN_LIST_FOREACH_SAFE(port_info, port_list, list, tmp) port_dealloc(port_info); free(port_list); =20 @@ -126,7 +126,7 @@ int osdep_evtchn_open(xenevtchn_handle *xce, unsigned i= nt flags) } =20 file->dev =3D list; - LIST_INIT(list); + XEN_LIST_INIT(list); xce->fd =3D fd; printf("evtchn_open() -> %d\n", fd); =20 @@ -173,7 +173,7 @@ static void evtchn_handler(evtchn_port_t port, struct p= t_regs *regs, void *data) assert(file); port_list =3D file->dev; mask_evtchn(port); - LIST_FOREACH(port_info, port_list, list) + XEN_LIST_FOREACH(port_info, port_list, list) { if ( port_info->port =3D=3D port ) goto found; @@ -257,7 +257,7 @@ int xenevtchn_unbind(xenevtchn_handle *xce, evtchn_port= _t port) struct port_info *port_info; struct port_list *port_list =3D file->dev; =20 - LIST_FOREACH(port_info, port_list, list) + XEN_LIST_FOREACH(port_info, port_list, list) { if ( port_info->port =3D=3D port ) { @@ -314,7 +314,7 @@ xenevtchn_port_or_error_t xenevtchn_pending(xenevtchn_h= andle *xce) =20 file->read =3D false; =20 - LIST_FOREACH(port_info, port_list, list) + XEN_LIST_FOREACH(port_info, port_list, list) { if ( port_info->port !=3D -1 && port_info->pending ) { --=20 2.34.1 From nobody Mon May 13 22:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1644304036; cv=none; d=zohomail.com; s=zohoarc; b=fpXDPjgvqcr0JLfnAY/hRVP/4Ynba7AUnO/qApEqwB/LQMqnmIJQEVQE6oO9xbwYRT40QYAOFC5OGcm0uAWg8r+7yyf6Lgx48cjm56I902PbAWxkPDUPFxD8f/kFEO5OEiyJ8JGBxr8B39NZQEiDbrIoMnVL7dKuJ4HqhqOCq08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644304036; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9PIRJvROq4WGxqvOvdeBhrJLUoEN4dl0PDZArfMcTVw=; b=l/mmyR5j9EVhnLb5CPOhEwr0uM8adzY219YpNvXJSK4mYOW2mFOvxWX4LJbA20e7ZS1xgVj/3V4/LEVdn0uGqyzwnwEONEYYGrEJSIj0/y0sosiW0bWWjdzgGoJd+z6iP+O+YEDPzJKGIf6isYAj2AE9JmFGmjXsCqgG8AA9WK8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1644304036291425.7917365954688; Mon, 7 Feb 2022 23:07:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.267541.461309 (Exim 4.92) (envelope-from ) id 1nHKaN-0000Vm-8Q; Tue, 08 Feb 2022 07:06:47 +0000 Received: by outflank-mailman (output) from mailman id 267541.461309; Tue, 08 Feb 2022 07:06:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHKaN-0000Uv-4m; Tue, 08 Feb 2022 07:06:47 +0000 Received: by outflank-mailman (input) for mailman id 267541; Tue, 08 Feb 2022 07:06:46 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nHKaL-0008AS-K6 for xen-devel@lists.xenproject.org; Tue, 08 Feb 2022 07:06:46 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ab49eb61-88ad-11ec-8f75-fffcc8bd4f1a; Tue, 08 Feb 2022 08:06:42 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7B33B2110A; Tue, 8 Feb 2022 07:06:42 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 48DB813483; Tue, 8 Feb 2022 07:06:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oIhxEIIWAmKxHgAAMHmgww (envelope-from ); Tue, 08 Feb 2022 07:06:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ab49eb61-88ad-11ec-8f75-fffcc8bd4f1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1644304002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9PIRJvROq4WGxqvOvdeBhrJLUoEN4dl0PDZArfMcTVw=; b=mfy5fXqJzm0eOg/72w/B4AlvdDkCI4fbugLKDzk6YCl7Rn3o1j6Ej7lvKtgvuhDxuV5R9J LcRgd8sGHtCmypH5nN6skg/tL9zb1uAx9aTy52jJNFgGvRvhQYLZzpvrsxRQJr9HY0vF1F tnldAcD+iSwhFPgPdE07PWOg2+JvQxU= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD Subject: [PATCH v3 5/5] tools/include: remove xen-external directory Date: Tue, 8 Feb 2022 08:06:38 +0100 Message-Id: <20220208070638.5909-6-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220208070638.5909-1-jgross@suse.com> References: <20220208070638.5909-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1644304037038100005 Content-Type: text/plain; charset="utf-8" There is no user of tools/include/xen-external/* left. Remove it. Signed-off-by: Juergen Gross Acked-by: Anthony PERARD --- tools/include/xen-external/README | 24 - tools/include/xen-external/bsd-COPYRIGHT | 126 -- tools/include/xen-external/bsd-queue.3 | 1044 ----------------- .../xen-external/bsd-sys-queue-h-seddery | 74 -- tools/include/xen-external/bsd-sys-queue.h | 637 ---------- 5 files changed, 1905 deletions(-) delete mode 100644 tools/include/xen-external/README delete mode 100644 tools/include/xen-external/bsd-COPYRIGHT delete mode 100644 tools/include/xen-external/bsd-queue.3 delete mode 100755 tools/include/xen-external/bsd-sys-queue-h-seddery delete mode 100644 tools/include/xen-external/bsd-sys-queue.h diff --git a/tools/include/xen-external/README b/tools/include/xen-external= /README deleted file mode 100644 index 93c2bc9cd8..0000000000 --- a/tools/include/xen-external/README +++ /dev/null @@ -1,24 +0,0 @@ -WARNING - DO NOT EDIT THINGS IN THIS DIRECTORY ----------------------------------------------- - -These files were obtained elsewhere and should only be updated by -copying new versions from the source location, as documented below: - -bsd-COPYRIGHT -bsd-sys-queue.h -bsd-queue.3 - - Obtained from the FreeBSD SVN using the following commands: - svn co -r 221843 svn://svn.freebsd.org/base/head/sys/sys/ - svn co -r 221843 svn://svn.freebsd.org/base/head/share/man/man3 - svn cat -r 221843 http://svn.freebsd.org/base/head/COPYRIGHT >tools/li= bxl/external/bsd-COPYRIGHT - -Exceptions: - -README - - This file - -bsd-sys-queue-h-seddery - - Script to transform the above into a new namespace. diff --git a/tools/include/xen-external/bsd-COPYRIGHT b/tools/include/xen-e= xternal/bsd-COPYRIGHT deleted file mode 100644 index 6dc5d16b46..0000000000 --- a/tools/include/xen-external/bsd-COPYRIGHT +++ /dev/null @@ -1,126 +0,0 @@ -# $FreeBSD$ -# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94 - -The compilation of software known as FreeBSD is distributed under the -following terms: - -Copyright (c) 1992-2011 The FreeBSD Project. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - -The 4.4BSD and 4.4BSD-Lite software is distributed under the following -terms: - -All of the documentation and software included in the 4.4BSD and 4.4BSD-Li= te -Releases is copyrighted by The Regents of the University of California. - -Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 - The Regents of the University of California. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. All advertising materials mentioning features or use of this software - must display the following acknowledgement: -This product includes software developed by the University of -California, Berkeley and its contributors. -4. Neither the name of the University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - -The Institute of Electrical and Electronics Engineers and the American -National Standards Committee X3, on Information Processing Systems have -given us permission to reprint portions of their documentation. - -In the following statement, the phrase ``this text'' refers to portions -of the system documentation. - -Portions of this text are reprinted and reproduced in electronic form in -the second BSD Networking Software Release, from IEEE Std 1003.1-1988, IEEE -Standard Portable Operating System Interface for Computer Environments -(POSIX), copyright C 1988 by the Institute of Electrical and Electronics -Engineers, Inc. In the event of any discrepancy between these versions -and the original IEEE Standard, the original IEEE Standard is the referee -document. - -In the following statement, the phrase ``This material'' refers to portions -of the system documentation. - -This material is reproduced with permission from American National -Standards Committee X3, on Information Processing Systems. Computer and -Business Equipment Manufacturers Association (CBEMA), 311 First St., NW, -Suite 500, Washington, DC 20001-2178. The developmental work of -Programming Language C was completed by the X3J11 Technical Committee. - -The views and conclusions contained in the software and documentation are -those of the authors and should not be interpreted as representing official -policies, either expressed or implied, of the Regents of the University -of California. - - -NOTE: The copyright of UC Berkeley's Berkeley Software Distribution ("BSD") -source has been updated. The copyright addendum may be found at -ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change and is -included below. - -July 22, 1999 - -To All Licensees, Distributors of Any Version of BSD: - -As you know, certain of the Berkeley Software Distribution ("BSD") source -code files require that further distributions of products containing all or -portions of the software, acknowledge within their advertising materials -that such products contain software developed by UC Berkeley and its -contributors. - -Specifically, the provision reads: - -" * 3. All advertising materials mentioning features or use of this so= ftware - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors." - -Effective immediately, licensees and distributors are no longer required to -include the acknowledgement within advertising materials. Accordingly, the -foregoing paragraph of those BSD Unix files containing it is hereby deleted -in its entirety. - -William Hoskins -Director, Office of Technology Licensing -University of California, Berkeley diff --git a/tools/include/xen-external/bsd-queue.3 b/tools/include/xen-ext= ernal/bsd-queue.3 deleted file mode 100644 index 007ca5c629..0000000000 --- a/tools/include/xen-external/bsd-queue.3 +++ /dev/null @@ -1,1044 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this softwa= re -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this softwa= re -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PUR= POSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIAB= LE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUEN= TIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ST= RICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY = WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)queue.3 8.2 (Berkeley) 1/24/94 -.\" $FreeBSD$ -.\" -.Dd May 13, 2011 -.Dt QUEUE 3 -.Os -.Sh NAME -.Nm SLIST_EMPTY , -.Nm SLIST_ENTRY , -.Nm SLIST_FIRST , -.Nm SLIST_FOREACH , -.Nm SLIST_FOREACH_SAFE , -.Nm SLIST_HEAD , -.Nm SLIST_HEAD_INITIALIZER , -.Nm SLIST_INIT , -.Nm SLIST_INSERT_AFTER , -.Nm SLIST_INSERT_HEAD , -.Nm SLIST_NEXT , -.Nm SLIST_REMOVE_AFTER , -.Nm SLIST_REMOVE_HEAD , -.Nm SLIST_REMOVE , -.Nm SLIST_SWAP , -.Nm STAILQ_CONCAT , -.Nm STAILQ_EMPTY , -.Nm STAILQ_ENTRY , -.Nm STAILQ_FIRST , -.Nm STAILQ_FOREACH , -.Nm STAILQ_FOREACH_SAFE , -.Nm STAILQ_HEAD , -.Nm STAILQ_HEAD_INITIALIZER , -.Nm STAILQ_INIT , -.Nm STAILQ_INSERT_AFTER , -.Nm STAILQ_INSERT_HEAD , -.Nm STAILQ_INSERT_TAIL , -.Nm STAILQ_LAST , -.Nm STAILQ_NEXT , -.Nm STAILQ_REMOVE_AFTER , -.Nm STAILQ_REMOVE_HEAD , -.Nm STAILQ_REMOVE , -.Nm STAILQ_SWAP , -.Nm LIST_EMPTY , -.Nm LIST_ENTRY , -.Nm LIST_FIRST , -.Nm LIST_FOREACH , -.Nm LIST_FOREACH_SAFE , -.Nm LIST_HEAD , -.Nm LIST_HEAD_INITIALIZER , -.Nm LIST_INIT , -.Nm LIST_INSERT_AFTER , -.Nm LIST_INSERT_BEFORE , -.Nm LIST_INSERT_HEAD , -.Nm LIST_NEXT , -.Nm LIST_REMOVE , -.Nm LIST_SWAP , -.Nm TAILQ_CONCAT , -.Nm TAILQ_EMPTY , -.Nm TAILQ_ENTRY , -.Nm TAILQ_FIRST , -.Nm TAILQ_FOREACH , -.Nm TAILQ_FOREACH_SAFE , -.Nm TAILQ_FOREACH_REVERSE , -.Nm TAILQ_FOREACH_REVERSE_SAFE , -.Nm TAILQ_HEAD , -.Nm TAILQ_HEAD_INITIALIZER , -.Nm TAILQ_INIT , -.Nm TAILQ_INSERT_AFTER , -.Nm TAILQ_INSERT_BEFORE , -.Nm TAILQ_INSERT_HEAD , -.Nm TAILQ_INSERT_TAIL , -.Nm TAILQ_LAST , -.Nm TAILQ_NEXT , -.Nm TAILQ_PREV , -.Nm TAILQ_REMOVE , -.Nm TAILQ_SWAP -.Nd implementations of singly-linked lists, singly-linked tail queues, -lists and tail queues -.Sh SYNOPSIS -.In sys/queue.h -.\" -.Fn SLIST_EMPTY "SLIST_HEAD *head" -.Fn SLIST_ENTRY "TYPE" -.Fn SLIST_FIRST "SLIST_HEAD *head" -.Fn SLIST_FOREACH "TYPE *var" "SLIST_HEAD *head" "SLIST_ENTRY NAME" -.Fn SLIST_FOREACH_SAFE "TYPE *var" "SLIST_HEAD *head" "SLIST_ENTRY NAME" "= TYPE *temp_var" -.Fn SLIST_HEAD "HEADNAME" "TYPE" -.Fn SLIST_HEAD_INITIALIZER "SLIST_HEAD head" -.Fn SLIST_INIT "SLIST_HEAD *head" -.Fn SLIST_INSERT_AFTER "TYPE *listelm" "TYPE *elm" "SLIST_ENTRY NAME" -.Fn SLIST_INSERT_HEAD "SLIST_HEAD *head" "TYPE *elm" "SLIST_ENTRY NAME" -.Fn SLIST_NEXT "TYPE *elm" "SLIST_ENTRY NAME" -.Fn SLIST_REMOVE_AFTER "TYPE *elm" "SLIST_ENTRY NAME" -.Fn SLIST_REMOVE_HEAD "SLIST_HEAD *head" "SLIST_ENTRY NAME" -.Fn SLIST_REMOVE "SLIST_HEAD *head" "TYPE *elm" "TYPE" "SLIST_ENTRY NAME" -.Fn SLIST_SWAP "SLIST_HEAD *head1" "SLIST_HEAD *head2" "SLIST_ENTRY NAME" -.\" -.Fn STAILQ_CONCAT "STAILQ_HEAD *head1" "STAILQ_HEAD *head2" -.Fn STAILQ_EMPTY "STAILQ_HEAD *head" -.Fn STAILQ_ENTRY "TYPE" -.Fn STAILQ_FIRST "STAILQ_HEAD *head" -.Fn STAILQ_FOREACH "TYPE *var" "STAILQ_HEAD *head" "STAILQ_ENTRY NAME" -.Fn STAILQ_FOREACH_SAFE "TYPE *var" "STAILQ_HEAD *head" "STAILQ_ENTRY NAME= " "TYPE *temp_var" -.Fn STAILQ_HEAD "HEADNAME" "TYPE" -.Fn STAILQ_HEAD_INITIALIZER "STAILQ_HEAD head" -.Fn STAILQ_INIT "STAILQ_HEAD *head" -.Fn STAILQ_INSERT_AFTER "STAILQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "S= TAILQ_ENTRY NAME" -.Fn STAILQ_INSERT_HEAD "STAILQ_HEAD *head" "TYPE *elm" "STAILQ_ENTRY NAME" -.Fn STAILQ_INSERT_TAIL "STAILQ_HEAD *head" "TYPE *elm" "STAILQ_ENTRY NAME" -.Fn STAILQ_LAST "STAILQ_HEAD *head" "TYPE" "STAILQ_ENTRY NAME" -.Fn STAILQ_NEXT "TYPE *elm" "STAILQ_ENTRY NAME" -.Fn STAILQ_REMOVE_AFTER "STAILQ_HEAD *head" "TYPE *elm" "STAILQ_ENTRY NAME" -.Fn STAILQ_REMOVE_HEAD "STAILQ_HEAD *head" "STAILQ_ENTRY NAME" -.Fn STAILQ_REMOVE "STAILQ_HEAD *head" "TYPE *elm" "TYPE" "STAILQ_ENTRY NAM= E" -.Fn STAILQ_SWAP "STAILQ_HEAD *head1" "STAILQ_HEAD *head2" "STAILQ_ENTRY NA= ME" -.\" -.Fn LIST_EMPTY "LIST_HEAD *head" -.Fn LIST_ENTRY "TYPE" -.Fn LIST_FIRST "LIST_HEAD *head" -.Fn LIST_FOREACH "TYPE *var" "LIST_HEAD *head" "LIST_ENTRY NAME" -.Fn LIST_FOREACH_SAFE "TYPE *var" "LIST_HEAD *head" "LIST_ENTRY NAME" "TYP= E *temp_var" -.Fn LIST_HEAD "HEADNAME" "TYPE" -.Fn LIST_HEAD_INITIALIZER "LIST_HEAD head" -.Fn LIST_INIT "LIST_HEAD *head" -.Fn LIST_INSERT_AFTER "TYPE *listelm" "TYPE *elm" "LIST_ENTRY NAME" -.Fn LIST_INSERT_BEFORE "TYPE *listelm" "TYPE *elm" "LIST_ENTRY NAME" -.Fn LIST_INSERT_HEAD "LIST_HEAD *head" "TYPE *elm" "LIST_ENTRY NAME" -.Fn LIST_NEXT "TYPE *elm" "LIST_ENTRY NAME" -.Fn LIST_REMOVE "TYPE *elm" "LIST_ENTRY NAME" -.Fn LIST_SWAP "LIST_HEAD *head1" "LIST_HEAD *head2" "TYPE" "LIST_ENTRY NAM= E" -.\" -.Fn TAILQ_CONCAT "TAILQ_HEAD *head1" "TAILQ_HEAD *head2" "TAILQ_ENTRY NAME" -.Fn TAILQ_EMPTY "TAILQ_HEAD *head" -.Fn TAILQ_ENTRY "TYPE" -.Fn TAILQ_FIRST "TAILQ_HEAD *head" -.Fn TAILQ_FOREACH "TYPE *var" "TAILQ_HEAD *head" "TAILQ_ENTRY NAME" -.Fn TAILQ_FOREACH_SAFE "TYPE *var" "TAILQ_HEAD *head" "TAILQ_ENTRY NAME" "= TYPE *temp_var" -.Fn TAILQ_FOREACH_REVERSE "TYPE *var" "TAILQ_HEAD *head" "HEADNAME" "TAILQ= _ENTRY NAME" -.Fn TAILQ_FOREACH_REVERSE_SAFE "TYPE *var" "TAILQ_HEAD *head" "HEADNAME" "= TAILQ_ENTRY NAME" "TYPE *temp_var" -.Fn TAILQ_HEAD "HEADNAME" "TYPE" -.Fn TAILQ_HEAD_INITIALIZER "TAILQ_HEAD head" -.Fn TAILQ_INIT "TAILQ_HEAD *head" -.Fn TAILQ_INSERT_AFTER "TAILQ_HEAD *head" "TYPE *listelm" "TYPE *elm" "TAI= LQ_ENTRY NAME" -.Fn TAILQ_INSERT_BEFORE "TYPE *listelm" "TYPE *elm" "TAILQ_ENTRY NAME" -.Fn TAILQ_INSERT_HEAD "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME" -.Fn TAILQ_INSERT_TAIL "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME" -.Fn TAILQ_LAST "TAILQ_HEAD *head" "HEADNAME" -.Fn TAILQ_NEXT "TYPE *elm" "TAILQ_ENTRY NAME" -.Fn TAILQ_PREV "TYPE *elm" "HEADNAME" "TAILQ_ENTRY NAME" -.Fn TAILQ_REMOVE "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME" -.Fn TAILQ_SWAP "TAILQ_HEAD *head1" "TAILQ_HEAD *head2" "TYPE" "TAILQ_ENTRY= NAME" -.\" -.Sh DESCRIPTION -These macros define and operate on four types of data structures: -singly-linked lists, singly-linked tail queues, lists, and tail queues. -All four structures support the following functionality: -.Bl -enum -compact -offset indent -.It -Insertion of a new entry at the head of the list. -.It -Insertion of a new entry after any element in the list. -.It -O(1) removal of an entry from the head of the list. -.It -Forward traversal through the list. -.It -Swawpping the contents of two lists. -.El -.Pp -Singly-linked lists are the simplest of the four data structures -and support only the above functionality. -Singly-linked lists are ideal for applications with large datasets -and few or no removals, -or for implementing a LIFO queue. -Singly-linked lists add the following functionality: -.Bl -enum -compact -offset indent -.It -O(n) removal of any entry in the list. -.El -.Pp -Singly-linked tail queues add the following functionality: -.Bl -enum -compact -offset indent -.It -Entries can be added at the end of a list. -.It -O(n) removal of any entry in the list. -.It -They may be concatenated. -.El -However: -.Bl -enum -compact -offset indent -.It -All list insertions must specify the head of the list. -.It -Each head entry requires two pointers rather than one. -.It -Code size is about 15% greater and operations run about 20% slower -than singly-linked lists. -.El -.Pp -Singly-linked tailqs are ideal for applications with large datasets and -few or no removals, -or for implementing a FIFO queue. -.Pp -All doubly linked types of data structures (lists and tail queues) -additionally allow: -.Bl -enum -compact -offset indent -.It -Insertion of a new entry before any element in the list. -.It -O(1) removal of any entry in the list. -.El -However: -.Bl -enum -compact -offset indent -.It -Each element requires two pointers rather than one. -.It -Code size and execution time of operations (except for removal) is about -twice that of the singly-linked data-structures. -.El -.Pp -Linked lists are the simplest of the doubly linked data structures and sup= port -only the above functionality over singly-linked lists. -.Pp -Tail queues add the following functionality: -.Bl -enum -compact -offset indent -.It -Entries can be added at the end of a list. -.It -They may be traversed backwards, from tail to head. -.It -They may be concatenated. -.El -However: -.Bl -enum -compact -offset indent -.It -All list insertions and removals must specify the head of the list. -.It -Each head entry requires two pointers rather than one. -.It -Code size is about 15% greater and operations run about 20% slower -than singly-linked lists. -.El -.Pp -In the macro definitions, -.Fa TYPE -is the name of a user defined structure, -that must contain a field of type -.Li SLIST_ENTRY , -.Li STAILQ_ENTRY , -.Li LIST_ENTRY , -or -.Li TAILQ_ENTRY , -named -.Fa NAME . -The argument -.Fa HEADNAME -is the name of a user defined structure that must be declared -using the macros -.Li SLIST_HEAD , -.Li STAILQ_HEAD , -.Li LIST_HEAD , -or -.Li TAILQ_HEAD . -See the examples below for further explanation of how these -macros are used. -.Sh SINGLY-LINKED LISTS -A singly-linked list is headed by a structure defined by the -.Nm SLIST_HEAD -macro. -This structure contains a single pointer to the first element -on the list. -The elements are singly linked for minimum space and pointer manipulation -overhead at the expense of O(n) removal for arbitrary elements. -New elements can be added to the list after an existing element or -at the head of the list. -An -.Fa SLIST_HEAD -structure is declared as follows: -.Bd -literal -offset indent -SLIST_HEAD(HEADNAME, TYPE) head; -.Ed -.Pp -where -.Fa HEADNAME -is the name of the structure to be defined, and -.Fa TYPE -is the type of the elements to be linked into the list. -A pointer to the head of the list can later be declared as: -.Bd -literal -offset indent -struct HEADNAME *headp; -.Ed -.Pp -(The names -.Li head -and -.Li headp -are user selectable.) -.Pp -The macro -.Nm SLIST_HEAD_INITIALIZER -evaluates to an initializer for the list -.Fa head . -.Pp -The macro -.Nm SLIST_EMPTY -evaluates to true if there are no elements in the list. -.Pp -The macro -.Nm SLIST_ENTRY -declares a structure that connects the elements in -the list. -.Pp -The macro -.Nm SLIST_FIRST -returns the first element in the list or NULL if the list is empty. -.Pp -The macro -.Nm SLIST_FOREACH -traverses the list referenced by -.Fa head -in the forward direction, assigning each element in -turn to -.Fa var . -.Pp -The macro -.Nm SLIST_FOREACH_SAFE -traverses the list referenced by -.Fa head -in the forward direction, assigning each element in -turn to -.Fa var . -However, unlike -.Fn SLIST_FOREACH -here it is permitted to both remove -.Fa var -as well as free it from within the loop safely without interfering with the -traversal. -.Pp -The macro -.Nm SLIST_INIT -initializes the list referenced by -.Fa head . -.Pp -The macro -.Nm SLIST_INSERT_HEAD -inserts the new element -.Fa elm -at the head of the list. -.Pp -The macro -.Nm SLIST_INSERT_AFTER -inserts the new element -.Fa elm -after the element -.Fa listelm . -.Pp -The macro -.Nm SLIST_NEXT -returns the next element in the list. -.Pp -The macro -.Nm SLIST_REMOVE_AFTER -removes the element after -.Fa elm -from the list. Unlike -.Fa SLIST_REMOVE , -this macro does not traverse the entire list. -.Pp -The macro -.Nm SLIST_REMOVE_HEAD -removes the element -.Fa elm -from the head of the list. -For optimum efficiency, -elements being removed from the head of the list should explicitly use -this macro instead of the generic -.Fa SLIST_REMOVE -macro. -.Pp -The macro -.Nm SLIST_REMOVE -removes the element -.Fa elm -from the list. -.Pp -The macro -.Nm SLIST_SWAP -swaps the contents of -.Fa head1 -and -.Fa head2 . -.Sh SINGLY-LINKED LIST EXAMPLE -.Bd -literal -SLIST_HEAD(slisthead, entry) head =3D - SLIST_HEAD_INITIALIZER(head); -struct slisthead *headp; /* Singly-linked List head. */ -struct entry { - ... - SLIST_ENTRY(entry) entries; /* Singly-linked List. */ - ... -} *n1, *n2, *n3, *np; - -SLIST_INIT(&head); /* Initialize the list. */ - -n1 =3D malloc(sizeof(struct entry)); /* Insert at the head. */ -SLIST_INSERT_HEAD(&head, n1, entries); - -n2 =3D malloc(sizeof(struct entry)); /* Insert after. */ -SLIST_INSERT_AFTER(n1, n2, entries); - -SLIST_REMOVE(&head, n2, entry, entries);/* Deletion. */ -free(n2); - -n3 =3D SLIST_FIRST(&head); -SLIST_REMOVE_HEAD(&head, entries); /* Deletion from the head. */ -free(n3); - /* Forward traversal. */ -SLIST_FOREACH(np, &head, entries) - np-> ... - /* Safe forward traversal. */ -SLIST_FOREACH_SAFE(np, &head, entries, np_temp) { - np->do_stuff(); - ... - SLIST_REMOVE(&head, np, entry, entries); - free(np); -} - -while (!SLIST_EMPTY(&head)) { /* List Deletion. */ - n1 =3D SLIST_FIRST(&head); - SLIST_REMOVE_HEAD(&head, entries); - free(n1); -} -.Ed -.Sh SINGLY-LINKED TAIL QUEUES -A singly-linked tail queue is headed by a structure defined by the -.Nm STAILQ_HEAD -macro. -This structure contains a pair of pointers, -one to the first element in the tail queue and the other to -the last element in the tail queue. -The elements are singly linked for minimum space and pointer -manipulation overhead at the expense of O(n) removal for arbitrary -elements. -New elements can be added to the tail queue after an existing element, -at the head of the tail queue, or at the end of the tail queue. -A -.Fa STAILQ_HEAD -structure is declared as follows: -.Bd -literal -offset indent -STAILQ_HEAD(HEADNAME, TYPE) head; -.Ed -.Pp -where -.Li HEADNAME -is the name of the structure to be defined, and -.Li TYPE -is the type of the elements to be linked into the tail queue. -A pointer to the head of the tail queue can later be declared as: -.Bd -literal -offset indent -struct HEADNAME *headp; -.Ed -.Pp -(The names -.Li head -and -.Li headp -are user selectable.) -.Pp -The macro -.Nm STAILQ_HEAD_INITIALIZER -evaluates to an initializer for the tail queue -.Fa head . -.Pp -The macro -.Nm STAILQ_CONCAT -concatenates the tail queue headed by -.Fa head2 -onto the end of the one headed by -.Fa head1 -removing all entries from the former. -.Pp -The macro -.Nm STAILQ_EMPTY -evaluates to true if there are no items on the tail queue. -.Pp -The macro -.Nm STAILQ_ENTRY -declares a structure that connects the elements in -the tail queue. -.Pp -The macro -.Nm STAILQ_FIRST -returns the first item on the tail queue or NULL if the tail queue -is empty. -.Pp -The macro -.Nm STAILQ_FOREACH -traverses the tail queue referenced by -.Fa head -in the forward direction, assigning each element -in turn to -.Fa var . -.Pp -The macro -.Nm STAILQ_FOREACH_SAFE -traverses the tail queue referenced by -.Fa head -in the forward direction, assigning each element -in turn to -.Fa var . -However, unlike -.Fn STAILQ_FOREACH -here it is permitted to both remove -.Fa var -as well as free it from within the loop safely without interfering with the -traversal. -.Pp -The macro -.Nm STAILQ_INIT -initializes the tail queue referenced by -.Fa head . -.Pp -The macro -.Nm STAILQ_INSERT_HEAD -inserts the new element -.Fa elm -at the head of the tail queue. -.Pp -The macro -.Nm STAILQ_INSERT_TAIL -inserts the new element -.Fa elm -at the end of the tail queue. -.Pp -The macro -.Nm STAILQ_INSERT_AFTER -inserts the new element -.Fa elm -after the element -.Fa listelm . -.Pp -The macro -.Nm STAILQ_LAST -returns the last item on the tail queue. -If the tail queue is empty the return value is -.Dv NULL . -.Pp -The macro -.Nm STAILQ_NEXT -returns the next item on the tail queue, or NULL this item is the last. -.Pp -The macro -.Nm STAILQ_REMOVE_AFTER -removes the element after -.Fa elm -from the tail queue. Unlike -.Fa STAILQ_REMOVE , -this macro does not traverse the entire tail queue. -.Pp -The macro -.Nm STAILQ_REMOVE_HEAD -removes the element at the head of the tail queue. -For optimum efficiency, -elements being removed from the head of the tail queue should -use this macro explicitly rather than the generic -.Fa STAILQ_REMOVE -macro. -.Pp -The macro -.Nm STAILQ_REMOVE -removes the element -.Fa elm -from the tail queue. -.Pp -The macro -.Nm STAILQ_SWAP -swaps the contents of -.Fa head1 -and -.Fa head2 . -.Sh SINGLY-LINKED TAIL QUEUE EXAMPLE -.Bd -literal -STAILQ_HEAD(stailhead, entry) head =3D - STAILQ_HEAD_INITIALIZER(head); -struct stailhead *headp; /* Singly-linked tail queue head. */ -struct entry { - ... - STAILQ_ENTRY(entry) entries; /* Tail queue. */ - ... -} *n1, *n2, *n3, *np; - -STAILQ_INIT(&head); /* Initialize the queue. */ - -n1 =3D malloc(sizeof(struct entry)); /* Insert at the head. */ -STAILQ_INSERT_HEAD(&head, n1, entries); - -n1 =3D malloc(sizeof(struct entry)); /* Insert at the tail. */ -STAILQ_INSERT_TAIL(&head, n1, entries); - -n2 =3D malloc(sizeof(struct entry)); /* Insert after. */ -STAILQ_INSERT_AFTER(&head, n1, n2, entries); - /* Deletion. */ -STAILQ_REMOVE(&head, n2, entry, entries); -free(n2); - /* Deletion from the head. */ -n3 =3D STAILQ_FIRST(&head); -STAILQ_REMOVE_HEAD(&head, entries); -free(n3); - /* Forward traversal. */ -STAILQ_FOREACH(np, &head, entries) - np-> ... - /* Safe forward traversal. */ -STAILQ_FOREACH_SAFE(np, &head, entries, np_temp) { - np->do_stuff(); - ... - STAILQ_REMOVE(&head, np, entry, entries); - free(np); -} - /* TailQ Deletion. */ -while (!STAILQ_EMPTY(&head)) { - n1 =3D STAILQ_FIRST(&head); - STAILQ_REMOVE_HEAD(&head, entries); - free(n1); -} - /* Faster TailQ Deletion. */ -n1 =3D STAILQ_FIRST(&head); -while (n1 !=3D NULL) { - n2 =3D STAILQ_NEXT(n1, entries); - free(n1); - n1 =3D n2; -} -STAILQ_INIT(&head); -.Ed -.Sh LISTS -A list is headed by a structure defined by the -.Nm LIST_HEAD -macro. -This structure contains a single pointer to the first element -on the list. -The elements are doubly linked so that an arbitrary element can be -removed without traversing the list. -New elements can be added to the list after an existing element, -before an existing element, or at the head of the list. -A -.Fa LIST_HEAD -structure is declared as follows: -.Bd -literal -offset indent -LIST_HEAD(HEADNAME, TYPE) head; -.Ed -.Pp -where -.Fa HEADNAME -is the name of the structure to be defined, and -.Fa TYPE -is the type of the elements to be linked into the list. -A pointer to the head of the list can later be declared as: -.Bd -literal -offset indent -struct HEADNAME *headp; -.Ed -.Pp -(The names -.Li head -and -.Li headp -are user selectable.) -.Pp -The macro -.Nm LIST_HEAD_INITIALIZER -evaluates to an initializer for the list -.Fa head . -.Pp -The macro -.Nm LIST_EMPTY -evaluates to true if there are no elements in the list. -.Pp -The macro -.Nm LIST_ENTRY -declares a structure that connects the elements in -the list. -.Pp -The macro -.Nm LIST_FIRST -returns the first element in the list or NULL if the list -is empty. -.Pp -The macro -.Nm LIST_FOREACH -traverses the list referenced by -.Fa head -in the forward direction, assigning each element in turn to -.Fa var . -.Pp -The macro -.Nm LIST_FOREACH_SAFE -traverses the list referenced by -.Fa head -in the forward direction, assigning each element in turn to -.Fa var . -However, unlike -.Fn LIST_FOREACH -here it is permitted to both remove -.Fa var -as well as free it from within the loop safely without interfering with the -traversal. -.Pp -The macro -.Nm LIST_INIT -initializes the list referenced by -.Fa head . -.Pp -The macro -.Nm LIST_INSERT_HEAD -inserts the new element -.Fa elm -at the head of the list. -.Pp -The macro -.Nm LIST_INSERT_AFTER -inserts the new element -.Fa elm -after the element -.Fa listelm . -.Pp -The macro -.Nm LIST_INSERT_BEFORE -inserts the new element -.Fa elm -before the element -.Fa listelm . -.Pp -The macro -.Nm LIST_NEXT -returns the next element in the list, or NULL if this is the last. -.Pp -The macro -.Nm LIST_REMOVE -removes the element -.Fa elm -from the list. -.Pp -The macro -.Nm LIST_SWAP -swaps the contents of -.Fa head1 -and -.Fa head2 . -.Sh LIST EXAMPLE -.Bd -literal -LIST_HEAD(listhead, entry) head =3D - LIST_HEAD_INITIALIZER(head); -struct listhead *headp; /* List head. */ -struct entry { - ... - LIST_ENTRY(entry) entries; /* List. */ - ... -} *n1, *n2, *n3, *np, *np_temp; - -LIST_INIT(&head); /* Initialize the list. */ - -n1 =3D malloc(sizeof(struct entry)); /* Insert at the head. */ -LIST_INSERT_HEAD(&head, n1, entries); - -n2 =3D malloc(sizeof(struct entry)); /* Insert after. */ -LIST_INSERT_AFTER(n1, n2, entries); - -n3 =3D malloc(sizeof(struct entry)); /* Insert before. */ -LIST_INSERT_BEFORE(n2, n3, entries); - -LIST_REMOVE(n2, entries); /* Deletion. */ -free(n2); - /* Forward traversal. */ -LIST_FOREACH(np, &head, entries) - np-> ... - - /* Safe forward traversal. */ -LIST_FOREACH_SAFE(np, &head, entries, np_temp) { - np->do_stuff(); - ... - LIST_REMOVE(np, entries); - free(np); -} - -while (!LIST_EMPTY(&head)) { /* List Deletion. */ - n1 =3D LIST_FIRST(&head); - LIST_REMOVE(n1, entries); - free(n1); -} - -n1 =3D LIST_FIRST(&head); /* Faster List Deletion. */ -while (n1 !=3D NULL) { - n2 =3D LIST_NEXT(n1, entries); - free(n1); - n1 =3D n2; -} -LIST_INIT(&head); -.Ed -.Sh TAIL QUEUES -A tail queue is headed by a structure defined by the -.Nm TAILQ_HEAD -macro. -This structure contains a pair of pointers, -one to the first element in the tail queue and the other to -the last element in the tail queue. -The elements are doubly linked so that an arbitrary element can be -removed without traversing the tail queue. -New elements can be added to the tail queue after an existing element, -before an existing element, at the head of the tail queue, -or at the end of the tail queue. -A -.Fa TAILQ_HEAD -structure is declared as follows: -.Bd -literal -offset indent -TAILQ_HEAD(HEADNAME, TYPE) head; -.Ed -.Pp -where -.Li HEADNAME -is the name of the structure to be defined, and -.Li TYPE -is the type of the elements to be linked into the tail queue. -A pointer to the head of the tail queue can later be declared as: -.Bd -literal -offset indent -struct HEADNAME *headp; -.Ed -.Pp -(The names -.Li head -and -.Li headp -are user selectable.) -.Pp -The macro -.Nm TAILQ_HEAD_INITIALIZER -evaluates to an initializer for the tail queue -.Fa head . -.Pp -The macro -.Nm TAILQ_CONCAT -concatenates the tail queue headed by -.Fa head2 -onto the end of the one headed by -.Fa head1 -removing all entries from the former. -.Pp -The macro -.Nm TAILQ_EMPTY -evaluates to true if there are no items on the tail queue. -.Pp -The macro -.Nm TAILQ_ENTRY -declares a structure that connects the elements in -the tail queue. -.Pp -The macro -.Nm TAILQ_FIRST -returns the first item on the tail queue or NULL if the tail queue -is empty. -.Pp -The macro -.Nm TAILQ_FOREACH -traverses the tail queue referenced by -.Fa head -in the forward direction, assigning each element in turn to -.Fa var . -.Fa var -is set to -.Dv NULL -if the loop completes normally, or if there were no elements. -.Pp -The macro -.Nm TAILQ_FOREACH_REVERSE -traverses the tail queue referenced by -.Fa head -in the reverse direction, assigning each element in turn to -.Fa var . -.Pp -The macros -.Nm TAILQ_FOREACH_SAFE -and -.Nm TAILQ_FOREACH_REVERSE_SAFE -traverse the list referenced by -.Fa head -in the forward or reverse direction respectively, -assigning each element in turn to -.Fa var . -However, unlike their unsafe counterparts, -.Nm TAILQ_FOREACH -and -.Nm TAILQ_FOREACH_REVERSE -permit to both remove -.Fa var -as well as free it from within the loop safely without interfering with the -traversal. -.Pp -The macro -.Nm TAILQ_INIT -initializes the tail queue referenced by -.Fa head . -.Pp -The macro -.Nm TAILQ_INSERT_HEAD -inserts the new element -.Fa elm -at the head of the tail queue. -.Pp -The macro -.Nm TAILQ_INSERT_TAIL -inserts the new element -.Fa elm -at the end of the tail queue. -.Pp -The macro -.Nm TAILQ_INSERT_AFTER -inserts the new element -.Fa elm -after the element -.Fa listelm . -.Pp -The macro -.Nm TAILQ_INSERT_BEFORE -inserts the new element -.Fa elm -before the element -.Fa listelm . -.Pp -The macro -.Nm TAILQ_LAST -returns the last item on the tail queue. -If the tail queue is empty the return value is -.Dv NULL . -.Pp -The macro -.Nm TAILQ_NEXT -returns the next item on the tail queue, or NULL if this item is the last. -.Pp -The macro -.Nm TAILQ_PREV -returns the previous item on the tail queue, or NULL if this item -is the first. -.Pp -The macro -.Nm TAILQ_REMOVE -removes the element -.Fa elm -from the tail queue. -.Pp -The macro -.Nm TAILQ_SWAP -swaps the contents of -.Fa head1 -and -.Fa head2 . -.Sh TAIL QUEUE EXAMPLE -.Bd -literal -TAILQ_HEAD(tailhead, entry) head =3D - TAILQ_HEAD_INITIALIZER(head); -struct tailhead *headp; /* Tail queue head. */ -struct entry { - ... - TAILQ_ENTRY(entry) entries; /* Tail queue. */ - ... -} *n1, *n2, *n3, *np; - -TAILQ_INIT(&head); /* Initialize the queue. */ - -n1 =3D malloc(sizeof(struct entry)); /* Insert at the head. */ -TAILQ_INSERT_HEAD(&head, n1, entries); - -n1 =3D malloc(sizeof(struct entry)); /* Insert at the tail. */ -TAILQ_INSERT_TAIL(&head, n1, entries); - -n2 =3D malloc(sizeof(struct entry)); /* Insert after. */ -TAILQ_INSERT_AFTER(&head, n1, n2, entries); - -n3 =3D malloc(sizeof(struct entry)); /* Insert before. */ -TAILQ_INSERT_BEFORE(n2, n3, entries); - -TAILQ_REMOVE(&head, n2, entries); /* Deletion. */ -free(n2); - /* Forward traversal. */ -TAILQ_FOREACH(np, &head, entries) - np-> ... - /* Safe forward traversal. */ -TAILQ_FOREACH_SAFE(np, &head, entries, np_temp) { - np->do_stuff(); - ... - TAILQ_REMOVE(&head, np, entries); - free(np); -} - /* Reverse traversal. */ -TAILQ_FOREACH_REVERSE(np, &head, tailhead, entries) - np-> ... - /* TailQ Deletion. */ -while (!TAILQ_EMPTY(&head)) { - n1 =3D TAILQ_FIRST(&head); - TAILQ_REMOVE(&head, n1, entries); - free(n1); -} - /* Faster TailQ Deletion. */ -n1 =3D TAILQ_FIRST(&head); -while (n1 !=3D NULL) { - n2 =3D TAILQ_NEXT(n1, entries); - free(n1); - n1 =3D n2; -} -TAILQ_INIT(&head); -.Ed -.Sh SEE ALSO -.Xr tree 3 -.Sh HISTORY -The -.Nm queue -functions first appeared in -.Bx 4.4 . diff --git a/tools/include/xen-external/bsd-sys-queue-h-seddery b/tools/inc= lude/xen-external/bsd-sys-queue-h-seddery deleted file mode 100755 index 3f8716d9ff..0000000000 --- a/tools/include/xen-external/bsd-sys-queue-h-seddery +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/perl -p -# -# This script is part of the Xen build system. It has a very -# permissive licence to avoid complicating the licence of the -# generated header file and to allow this seddery to be reused by -# other projects. -# -# Permission is hereby granted, free of charge, to any person -# obtaining a copy of this individual file (the "Software"), to deal -# in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, -# sublicense, and/or sell copies of the Software, and to permit -# persons to whom the Software is furnished to do so, subject to the -# following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Copyright (C) 2011 Citrix Ltd - -our $namespace, $ucnamespace; - -BEGIN { - die unless @ARGV; - $namespace =3D pop @ARGV; - $namespace =3D~ s/^--prefix=3D// or die; - $ucnamespace =3D uc $namespace; - - print < - -/* - * This file defines four types of data structures: singly-linked lists, - * singly-linked tail queues, lists and tail queues. - * - * A singly-linked list is headed by a single forward pointer. The elements - * are singly linked for minimum space and pointer manipulation overhead at - * the expense of O(n) removal for arbitrary elements. New elements can be - * added to the list after an existing element or at the head of the list. - * Elements being removed from the head of the list should use the explicit - * macro for this purpose for optimum efficiency. A singly-linked list may - * only be traversed in the forward direction. Singly-linked lists are id= eal - * for applications with large datasets and few or no removals or for - * implementing a LIFO queue. - * - * A singly-linked tail queue is headed by a pair of pointers, one to the - * head of the list and the other to the tail of the list. The elements are - * singly linked for minimum space and pointer manipulation overhead at the - * expense of O(n) removal for arbitrary elements. New elements can be add= ed - * to the list after an existing element, at the head of the list, or at t= he - * end of the list. Elements being removed from the head of the tail queue - * should use the explicit macro for this purpose for optimum efficiency. - * A singly-linked tail queue may only be traversed in the forward directi= on. - * Singly-linked tail queues are ideal for applications with large datasets - * and few or no removals or for implementing a FIFO queue. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before - * or after an existing element or at the head of the list. A list - * may only be traversed in the forward direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or - * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may be traversed in either direction. - * - * For details on the use of these macros, see the queue(3) manual page. - * - * - * SLIST LIST STAILQ TAILQ - * _HEAD + + + + - * _HEAD_INITIALIZER + + + + - * _ENTRY + + + + - * _INIT + + + + - * _EMPTY + + + + - * _FIRST + + + + - * _NEXT + + + + - * _PREV - - - + - * _LAST - - + + - * _FOREACH + + + + - * _FOREACH_SAFE + + + + - * _FOREACH_REVERSE - - - + - * _FOREACH_REVERSE_SAFE - - - + - * _INSERT_HEAD + + + + - * _INSERT_BEFORE - + - + - * _INSERT_AFTER + + + + - * _INSERT_TAIL - - + + - * _CONCAT - - + + - * _REMOVE_AFTER + - + - - * _REMOVE_HEAD + - + - - * _REMOVE + + + + - * _SWAP + + + + - * - */ -#ifdef QUEUE_MACRO_DEBUG -/* Store the last 2 places the queue element or head was altered */ -struct qm_trace { - char * lastfile; - int lastline; - char * prevfile; - int prevline; -}; - -#define TRACEBUF struct qm_trace trace; -#define TRASHIT(x) do {(x) =3D (void *)-1;} while (0) -#define QMD_SAVELINK(name, link) void **name =3D (void *)&(link) - -#define QMD_TRACE_HEAD(head) do { \ - (head)->trace.prevline =3D (head)->trace.lastline; \ - (head)->trace.prevfile =3D (head)->trace.lastfile; \ - (head)->trace.lastline =3D __LINE__; \ - (head)->trace.lastfile =3D __FILE__; \ -} while (0) - -#define QMD_TRACE_ELEM(elem) do { \ - (elem)->trace.prevline =3D (elem)->trace.lastline; \ - (elem)->trace.prevfile =3D (elem)->trace.lastfile; \ - (elem)->trace.lastline =3D __LINE__; \ - (elem)->trace.lastfile =3D __FILE__; \ -} while (0) - -#else -#define QMD_TRACE_ELEM(elem) -#define QMD_TRACE_HEAD(head) -#define QMD_SAVELINK(name, link) -#define TRACEBUF -#define TRASHIT(x) -#endif /* QUEUE_MACRO_DEBUG */ - -/* - * Singly-linked List declarations. - */ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define SLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -/* - * Singly-linked List functions. - */ -#define SLIST_EMPTY(head) ((head)->slh_first =3D=3D NULL) - -#define SLIST_FIRST(head) ((head)->slh_first) - -#define SLIST_FOREACH(var, head, field) \ - for ((var) =3D SLIST_FIRST((head)); \ - (var); \ - (var) =3D SLIST_NEXT((var), field)) - -#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) =3D SLIST_FIRST((head)); \ - (var) && ((tvar) =3D SLIST_NEXT((var), field), 1); \ - (var) =3D (tvar)) - -#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ - for ((varp) =3D &SLIST_FIRST((head)); \ - ((var) =3D *(varp)) !=3D NULL; \ - (varp) =3D &SLIST_NEXT((var), field)) - -#define SLIST_INIT(head) do { \ - SLIST_FIRST((head)) =3D NULL; \ -} while (0) - -#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ - SLIST_NEXT((elm), field) =3D SLIST_NEXT((slistelm), field); \ - SLIST_NEXT((slistelm), field) =3D (elm); \ -} while (0) - -#define SLIST_INSERT_HEAD(head, elm, field) do { \ - SLIST_NEXT((elm), field) =3D SLIST_FIRST((head)); \ - SLIST_FIRST((head)) =3D (elm); \ -} while (0) - -#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) - -#define SLIST_REMOVE(head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.sle_next); \ - if (SLIST_FIRST((head)) =3D=3D (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm =3D SLIST_FIRST((head)); \ - while (SLIST_NEXT(curelm, field) !=3D (elm)) \ - curelm =3D SLIST_NEXT(curelm, field); \ - SLIST_REMOVE_AFTER(curelm, field); \ - } \ - TRASHIT(*oldnext); \ -} while (0) - -#define SLIST_REMOVE_AFTER(elm, field) do { \ - SLIST_NEXT(elm, field) =3D \ - SLIST_NEXT(SLIST_NEXT(elm, field), field); \ -} while (0) - -#define SLIST_REMOVE_HEAD(head, field) do { \ - SLIST_FIRST((head)) =3D SLIST_NEXT(SLIST_FIRST((head)), field); \ -} while (0) - -#define SLIST_SWAP(head1, head2, type) do { \ - struct type *swap_first =3D SLIST_FIRST(head1); \ - SLIST_FIRST(head1) =3D SLIST_FIRST(head2); \ - SLIST_FIRST(head2) =3D swap_first; \ -} while (0) - -/* - * Singly-linked Tail queue declarations. - */ -#define STAILQ_HEAD(name, type) \ -struct name { \ - struct type *stqh_first;/* first element */ \ - struct type **stqh_last;/* addr of last next element */ \ -} - -#define STAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).stqh_first } - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} - -/* - * Singly-linked Tail queue functions. - */ -#define STAILQ_CONCAT(head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last =3D (head2)->stqh_first; \ - (head1)->stqh_last =3D (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ -} while (0) - -#define STAILQ_EMPTY(head) ((head)->stqh_first =3D=3D NULL) - -#define STAILQ_FIRST(head) ((head)->stqh_first) - -#define STAILQ_FOREACH(var, head, field) \ - for((var) =3D STAILQ_FIRST((head)); \ - (var); \ - (var) =3D STAILQ_NEXT((var), field)) - - -#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) =3D STAILQ_FIRST((head)); \ - (var) && ((tvar) =3D STAILQ_NEXT((var), field), 1); \ - (var) =3D (tvar)) - -#define STAILQ_INIT(head) do { \ - STAILQ_FIRST((head)) =3D NULL; \ - (head)->stqh_last =3D &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) =3D STAILQ_NEXT((tqelm), field)) =3D=3D NU= LL)\ - (head)->stqh_last =3D &STAILQ_NEXT((elm), field); \ - STAILQ_NEXT((tqelm), field) =3D (elm); \ -} while (0) - -#define STAILQ_INSERT_HEAD(head, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) =3D STAILQ_FIRST((head))) =3D=3D NULL) \ - (head)->stqh_last =3D &STAILQ_NEXT((elm), field); \ - STAILQ_FIRST((head)) =3D (elm); \ -} while (0) - -#define STAILQ_INSERT_TAIL(head, elm, field) do { \ - STAILQ_NEXT((elm), field) =3D NULL; \ - *(head)->stqh_last =3D (elm); \ - (head)->stqh_last =3D &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_LAST(head, type, field) \ - (STAILQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *)(void *) \ - ((char *)((head)->stqh_last) - __offsetof(struct type, field)))) - -#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) - -#define STAILQ_REMOVE(head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ - if (STAILQ_FIRST((head)) =3D=3D (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm =3D STAILQ_FIRST((head)); \ - while (STAILQ_NEXT(curelm, field) !=3D (elm)) \ - curelm =3D STAILQ_NEXT(curelm, field); \ - STAILQ_REMOVE_AFTER(head, curelm, field); \ - } \ - TRASHIT(*oldnext); \ -} while (0) - -#define STAILQ_REMOVE_AFTER(head, elm, field) do { \ - if ((STAILQ_NEXT(elm, field) =3D \ - STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) =3D=3D NULL) \ - (head)->stqh_last =3D &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_REMOVE_HEAD(head, field) do { \ - if ((STAILQ_FIRST((head)) =3D \ - STAILQ_NEXT(STAILQ_FIRST((head)), field)) =3D=3D NULL) \ - (head)->stqh_last =3D &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_SWAP(head1, head2, type) do { \ - struct type *swap_first =3D STAILQ_FIRST(head1); \ - struct type **swap_last =3D (head1)->stqh_last; \ - STAILQ_FIRST(head1) =3D STAILQ_FIRST(head2); \ - (head1)->stqh_last =3D (head2)->stqh_last; \ - STAILQ_FIRST(head2) =3D swap_first; \ - (head2)->stqh_last =3D swap_last; \ - if (STAILQ_EMPTY(head1)) \ - (head1)->stqh_last =3D &STAILQ_FIRST(head1); \ - if (STAILQ_EMPTY(head2)) \ - (head2)->stqh_last =3D &STAILQ_FIRST(head2); \ -} while (0) - - -/* - * List declarations. - */ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define LIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List functions. - */ - -#if (defined(_KERNEL) && defined(INVARIANTS)) -#define QMD_LIST_CHECK_HEAD(head, field) do { \ - if (LIST_FIRST((head)) !=3D NULL && \ - LIST_FIRST((head))->field.le_prev !=3D \ - &LIST_FIRST((head))) \ - panic("Bad list head %p first->prev !=3D head", (head)); \ -} while (0) - -#define QMD_LIST_CHECK_NEXT(elm, field) do { \ - if (LIST_NEXT((elm), field) !=3D NULL && \ - LIST_NEXT((elm), field)->field.le_prev !=3D \ - &((elm)->field.le_next)) \ - panic("Bad link elm %p next->prev !=3D elm", (elm)); \ -} while (0) - -#define QMD_LIST_CHECK_PREV(elm, field) do { \ - if (*(elm)->field.le_prev !=3D (elm)) \ - panic("Bad link elm %p prev->next !=3D elm", (elm)); \ -} while (0) -#else -#define QMD_LIST_CHECK_HEAD(head, field) -#define QMD_LIST_CHECK_NEXT(elm, field) -#define QMD_LIST_CHECK_PREV(elm, field) -#endif /* (_KERNEL && INVARIANTS) */ - -#define LIST_EMPTY(head) ((head)->lh_first =3D=3D NULL) - -#define LIST_FIRST(head) ((head)->lh_first) - -#define LIST_FOREACH(var, head, field) \ - for ((var) =3D LIST_FIRST((head)); \ - (var); \ - (var) =3D LIST_NEXT((var), field)) - -#define LIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) =3D LIST_FIRST((head)); \ - (var) && ((tvar) =3D LIST_NEXT((var), field), 1); \ - (var) =3D (tvar)) - -#define LIST_INIT(head) do { \ - LIST_FIRST((head)) =3D NULL; \ -} while (0) - -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ - QMD_LIST_CHECK_NEXT(listelm, field); \ - if ((LIST_NEXT((elm), field) =3D LIST_NEXT((listelm), field)) !=3D NULL)\ - LIST_NEXT((listelm), field)->field.le_prev =3D \ - &LIST_NEXT((elm), field); \ - LIST_NEXT((listelm), field) =3D (elm); \ - (elm)->field.le_prev =3D &LIST_NEXT((listelm), field); \ -} while (0) - -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ - QMD_LIST_CHECK_PREV(listelm, field); \ - (elm)->field.le_prev =3D (listelm)->field.le_prev; \ - LIST_NEXT((elm), field) =3D (listelm); \ - *(listelm)->field.le_prev =3D (elm); \ - (listelm)->field.le_prev =3D &LIST_NEXT((elm), field); \ -} while (0) - -#define LIST_INSERT_HEAD(head, elm, field) do { \ - QMD_LIST_CHECK_HEAD((head), field); \ - if ((LIST_NEXT((elm), field) =3D LIST_FIRST((head))) !=3D NULL) \ - LIST_FIRST((head))->field.le_prev =3D &LIST_NEXT((elm), field);\ - LIST_FIRST((head)) =3D (elm); \ - (elm)->field.le_prev =3D &LIST_FIRST((head)); \ -} while (0) - -#define LIST_NEXT(elm, field) ((elm)->field.le_next) - -#define LIST_REMOVE(elm, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.le_next); \ - QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ - QMD_LIST_CHECK_NEXT(elm, field); \ - QMD_LIST_CHECK_PREV(elm, field); \ - if (LIST_NEXT((elm), field) !=3D NULL) \ - LIST_NEXT((elm), field)->field.le_prev =3D \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev =3D LIST_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ -} while (0) - -#define LIST_SWAP(head1, head2, type, field) do { \ - struct type *swap_tmp =3D LIST_FIRST((head1)); \ - LIST_FIRST((head1)) =3D LIST_FIRST((head2)); \ - LIST_FIRST((head2)) =3D swap_tmp; \ - if ((swap_tmp =3D LIST_FIRST((head1))) !=3D NULL) \ - swap_tmp->field.le_prev =3D &LIST_FIRST((head1)); \ - if ((swap_tmp =3D LIST_FIRST((head2))) !=3D NULL) \ - swap_tmp->field.le_prev =3D &LIST_FIRST((head2)); \ -} while (0) - -/* - * Tail queue declarations. - */ -#define TAILQ_HEAD(name, type) \ -struct name { \ - struct type *tqh_first; /* first element */ \ - struct type **tqh_last; /* addr of last next element */ \ - TRACEBUF \ -} - -#define TAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } - -#define TAILQ_ENTRY(type) \ -struct { \ - struct type *tqe_next; /* next element */ \ - struct type **tqe_prev; /* address of previous next element */ \ - TRACEBUF \ -} - -/* - * Tail queue functions. - */ -#if (defined(_KERNEL) && defined(INVARIANTS)) -#define QMD_TAILQ_CHECK_HEAD(head, field) do { \ - if (!TAILQ_EMPTY(head) && \ - TAILQ_FIRST((head))->field.tqe_prev !=3D \ - &TAILQ_FIRST((head))) \ - panic("Bad tailq head %p first->prev !=3D head", (head)); \ -} while (0) - -#define QMD_TAILQ_CHECK_TAIL(head, field) do { \ - if (*(head)->tqh_last !=3D NULL) \ - panic("Bad tailq NEXT(%p->tqh_last) !=3D NULL", (head)); \ -} while (0) - -#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \ - if (TAILQ_NEXT((elm), field) !=3D NULL && \ - TAILQ_NEXT((elm), field)->field.tqe_prev !=3D \ - &((elm)->field.tqe_next)) \ - panic("Bad link elm %p next->prev !=3D elm", (elm)); \ -} while (0) - -#define QMD_TAILQ_CHECK_PREV(elm, field) do { \ - if (*(elm)->field.tqe_prev !=3D (elm)) \ - panic("Bad link elm %p prev->next !=3D elm", (elm)); \ -} while (0) -#else -#define QMD_TAILQ_CHECK_HEAD(head, field) -#define QMD_TAILQ_CHECK_TAIL(head, headname) -#define QMD_TAILQ_CHECK_NEXT(elm, field) -#define QMD_TAILQ_CHECK_PREV(elm, field) -#endif /* (_KERNEL && INVARIANTS) */ - -#define TAILQ_CONCAT(head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last =3D (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev =3D (head1)->tqh_last; \ - (head1)->tqh_last =3D (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - QMD_TRACE_HEAD(head1); \ - QMD_TRACE_HEAD(head2); \ - } \ -} while (0) - -#define TAILQ_EMPTY(head) ((head)->tqh_first =3D=3D NULL) - -#define TAILQ_FIRST(head) ((head)->tqh_first) - -#define TAILQ_FOREACH(var, head, field) \ - for ((var) =3D TAILQ_FIRST((head)); \ - (var); \ - (var) =3D TAILQ_NEXT((var), field)) - -#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) =3D TAILQ_FIRST((head)); \ - (var) && ((tvar) =3D TAILQ_NEXT((var), field), 1); \ - (var) =3D (tvar)) - -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) =3D TAILQ_LAST((head), headname); \ - (var); \ - (var) =3D TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ - for ((var) =3D TAILQ_LAST((head), headname); \ - (var) && ((tvar) =3D TAILQ_PREV((var), headname, field), 1); \ - (var) =3D (tvar)) - -#define TAILQ_INIT(head) do { \ - TAILQ_FIRST((head)) =3D NULL; \ - (head)->tqh_last =3D &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ -} while (0) - -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - QMD_TAILQ_CHECK_NEXT(listelm, field); \ - if ((TAILQ_NEXT((elm), field) =3D TAILQ_NEXT((listelm), field)) !=3D NULL= )\ - TAILQ_NEXT((elm), field)->field.tqe_prev =3D \ - &TAILQ_NEXT((elm), field); \ - else { \ - (head)->tqh_last =3D &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - } \ - TAILQ_NEXT((listelm), field) =3D (elm); \ - (elm)->field.tqe_prev =3D &TAILQ_NEXT((listelm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&listelm->field); \ -} while (0) - -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - QMD_TAILQ_CHECK_PREV(listelm, field); \ - (elm)->field.tqe_prev =3D (listelm)->field.tqe_prev; \ - TAILQ_NEXT((elm), field) =3D (listelm); \ - *(listelm)->field.tqe_prev =3D (elm); \ - (listelm)->field.tqe_prev =3D &TAILQ_NEXT((elm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&listelm->field); \ -} while (0) - -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ - QMD_TAILQ_CHECK_HEAD(head, field); \ - if ((TAILQ_NEXT((elm), field) =3D TAILQ_FIRST((head))) !=3D NULL) \ - TAILQ_FIRST((head))->field.tqe_prev =3D \ - &TAILQ_NEXT((elm), field); \ - else \ - (head)->tqh_last =3D &TAILQ_NEXT((elm), field); \ - TAILQ_FIRST((head)) =3D (elm); \ - (elm)->field.tqe_prev =3D &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ - QMD_TAILQ_CHECK_TAIL(head, field); \ - TAILQ_NEXT((elm), field) =3D NULL; \ - (elm)->field.tqe_prev =3D (head)->tqh_last; \ - *(head)->tqh_last =3D (elm); \ - (head)->tqh_last =3D &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) - -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) - -#define TAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - -#define TAILQ_REMOVE(head, elm, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ - QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ - QMD_TAILQ_CHECK_NEXT(elm, field); \ - QMD_TAILQ_CHECK_PREV(elm, field); \ - if ((TAILQ_NEXT((elm), field)) !=3D NULL) \ - TAILQ_NEXT((elm), field)->field.tqe_prev =3D \ - (elm)->field.tqe_prev; \ - else { \ - (head)->tqh_last =3D (elm)->field.tqe_prev; \ - QMD_TRACE_HEAD(head); \ - } \ - *(elm)->field.tqe_prev =3D TAILQ_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_SWAP(head1, head2, type, field) do { \ - struct type *swap_first =3D (head1)->tqh_first; \ - struct type **swap_last =3D (head1)->tqh_last; \ - (head1)->tqh_first =3D (head2)->tqh_first; \ - (head1)->tqh_last =3D (head2)->tqh_last; \ - (head2)->tqh_first =3D swap_first; \ - (head2)->tqh_last =3D swap_last; \ - if ((swap_first =3D (head1)->tqh_first) !=3D NULL) \ - swap_first->field.tqe_prev =3D &(head1)->tqh_first; \ - else \ - (head1)->tqh_last =3D &(head1)->tqh_first; \ - if ((swap_first =3D (head2)->tqh_first) !=3D NULL) \ - swap_first->field.tqe_prev =3D &(head2)->tqh_first; \ - else \ - (head2)->tqh_last =3D &(head2)->tqh_first; \ -} while (0) - -#endif /* !_SYS_QUEUE_H_ */ --=20 2.34.1