From patchwork Tue Mar 1 18:57:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 8469011 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A185BC0553 for ; Tue, 1 Mar 2016 19:00:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A8DAA20304 for ; Tue, 1 Mar 2016 19:00:08 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B142B202EC for ; Tue, 1 Mar 2016 19:00:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aapUA-00011k-40; Tue, 01 Mar 2016 18:57:30 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aapU8-00011Q-Nr for xen-devel@lists.xen.org; Tue, 01 Mar 2016 18:57:28 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id AC/38-03883-716E5D65; Tue, 01 Mar 2016 18:57:27 +0000 X-Env-Sender: prvs=861a7224f=Andrew.Cooper3@citrix.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1456858645!10013900!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24192 invoked from network); 1 Mar 2016 18:57:27 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-2.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 1 Mar 2016 18:57:27 -0000 X-IronPort-AV: E=Sophos;i="5.22,524,1449532800"; d="scan'208";a="342292383" From: Andrew Cooper To: Xen-devel Date: Tue, 1 Mar 2016 18:57:20 +0000 Message-ID: <1456858641-20776-3-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456858641-20776-1-git-send-email-andrew.cooper3@citrix.com> References: <1456858641-20776-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper , Tim Deegan , Jan Beulich , Doug Goldstein Subject: [Xen-devel] [PATCH 3/4] xen/errno: Reduce complexity of inclusion X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The inclusion rules conditions for errno.h were unnecesserily complicated, and required the includer to jump through hoops if they wished to avoid getting multiple namespaces worth of constants. Vastly simply the logic, and document what is going on. Signed-off-by: Andrew Cooper Reviewed-by: Doug Goldstein --- CC: Jan Beulich CC: Tim Deegan CC: Doug Goldstein --- xen/include/public/errno.h | 55 ++++++++++++++++++++++++++++++---------------- xen/include/xen/errno.h | 6 ++--- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/xen/include/public/errno.h b/xen/include/public/errno.h index dbac396..fa375be 100644 --- a/xen/include/public/errno.h +++ b/xen/include/public/errno.h @@ -1,20 +1,36 @@ -#ifndef __XEN_PUBLIC_ERRNO_H__ - -#ifndef __ASSEMBLY__ - -#define XEN_ERRNO(name, value) XEN_##name = value, -enum xen_errno { +/* + * There are two expected ways of including this header. + * + * 1) The "default" case (expected from tools etc). + * + * Simply #include + * + * In this circumstance, normal header guards apply and the includer shall get + * an enumeration in the XEN_xxx namespace. + * + * 2) The special case where the includer provides a XEN_ERRNO() in scope. + * + * In this case, no inclusion guards apply and the caller is responsible for + * their XEN_ERRNO() being appropriate in the included context. + */ -#else /* !__ASSEMBLY__ */ +#ifndef XEN_ERRNO -#define XEN_ERRNO(name, value) .equ XEN_##name, value +/* + * Includer has not provided a custom XEN_ERRNO(). Arrange an automatic enum + * and constants in the XEN_xxx namespace. + */ +#define XEN_ERRNO_DEFAULT_INCLUDE -#endif /* __ASSEMBLY__ */ +#ifndef __XEN_PUBLIC_ERRNO_H__ +#define __XEN_PUBLIC_ERRNO_H__ -/* ` enum neg_errnoval { [ -Efoo for each Efoo in the list below ] } */ -/* ` enum errnoval { */ +#define XEN_ERRNO(name, value) XEN_##name = value, +enum { #endif /* __XEN_PUBLIC_ERRNO_H__ */ +#endif /* !XEN_ERRNO */ + #ifdef XEN_ERRNO @@ -82,16 +98,17 @@ XEN_ERRNO(EISCONN, 106) /* Transport endpoint is already connected */ XEN_ERRNO(ENOTCONN, 107) /* Transport endpoint is not connected */ XEN_ERRNO(ETIMEDOUT, 110) /* Connection timed out */ -#undef XEN_ERRNO #endif /* XEN_ERRNO */ -#ifndef __XEN_PUBLIC_ERRNO_H__ -#define __XEN_PUBLIC_ERRNO_H__ -/* ` } */ +#ifdef XEN_ERRNO_DEFAULT_INCLUDE -#ifndef __ASSEMBLY__ -}; -#endif +/* + * Clean up from a default include. Close the enum and remove the default + * XEN_ERRNO from scope. + */ +#undef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO +} ; -#endif /* __XEN_PUBLIC_ERRNO_H__ */ +#endif /* XEN_ERRNO_DEFAULT_INCLUDE */ diff --git a/xen/include/xen/errno.h b/xen/include/xen/errno.h index 3178466..69b28dd 100644 --- a/xen/include/xen/errno.h +++ b/xen/include/xen/errno.h @@ -1,18 +1,16 @@ #ifndef __XEN_ERRNO_H__ #define __XEN_ERRNO_H__ -#include - #ifndef __ASSEMBLY__ -#define XEN_ERRNO(name, value) name = XEN_##name, +#define XEN_ERRNO(name, value) name = value, enum { #include }; #else /* !__ASSEMBLY__ */ -#define XEN_ERRNO(name, value) .equ name, XEN_##name +#define XEN_ERRNO(name, value) .equ name, value #include #endif /* __ASSEMBLY__ */