xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Tim Deegan <tim@xen.org>, Jan Beulich <JBeulich@suse.com>,
	Doug Goldstein <cardoe@cardoe.com>
Subject: [PATCH v4] xen/errno: Reduce complexity of inclusion
Date: Mon, 7 Mar 2016 15:13:42 +0000	[thread overview]
Message-ID: <1457363622-29534-1-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <22233.45757.915716.14337@mariner.uk.xensource.com>

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.

Simply the logic, and document what is going on.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
CC: Doug Goldstein <cardoe@cardoe.com>

v3:
 * Reinstate magic documentation comments
 * Provide assembly-suitable defaults if appropriate

v4:
 * Reintroduce broken #undef logic to be bug-compatible with the previous
   version.
---
 xen/include/public/errno.h | 41 ++++++++++++++++++++++++++++++++++-------
 xen/include/xen/errno.h    |  6 ++----
 2 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/xen/include/public/errno.h b/xen/include/public/errno.h
index dbac396..a0dd0cf 100644
--- a/xen/include/public/errno.h
+++ b/xen/include/public/errno.h
@@ -1,4 +1,31 @@
+/*
+ * There are two expected ways of including this header.
+ *
+ * 1) The "default" case (expected from tools etc).
+ *
+ * Simply #include <public/errno.h>
+ *
+ * In this circumstance, normal header guards apply and the includer shall get
+ * an enumeration in the XEN_xxx namespace, appropriate for C or assembly.
+ *
+ * 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.  The header
+ * will unilaterally #undef XEN_ERRNO().
+ */
+
+#ifndef XEN_ERRNO
+
+/*
+ * Includer has not provided a custom XEN_ERRNO().  Arrange for normal header
+ * guards, an automatic enum (for C code) and constants in the XEN_xxx
+ * namespace.
+ */
 #ifndef __XEN_PUBLIC_ERRNO_H__
+#define __XEN_PUBLIC_ERRNO_H__
+
+#define XEN_ERRNO_DEFAULT_INCLUDE
 
 #ifndef __ASSEMBLY__
 
@@ -11,11 +38,12 @@ enum xen_errno {
 
 #endif /* __ASSEMBLY__ */
 
+#endif /* __XEN_PUBLIC_ERRNO_H__ */
+#endif /* !XEN_ERRNO */
+
 /* ` enum neg_errnoval {  [ -Efoo for each Efoo in the list below ]  } */
 /* ` enum errnoval { */
 
-#endif /* __XEN_PUBLIC_ERRNO_H__ */
-
 #ifdef XEN_ERRNO
 
 /*
@@ -84,14 +112,13 @@ XEN_ERRNO(ETIMEDOUT,	110)	/* Connection timed out */
 
 #undef XEN_ERRNO
 #endif /* XEN_ERRNO */
-
-#ifndef __XEN_PUBLIC_ERRNO_H__
-#define __XEN_PUBLIC_ERRNO_H__
-
 /* ` } */
 
+/* Clean up from a default include.  Close the enum (for C). */
+#ifdef XEN_ERRNO_DEFAULT_INCLUDE
+#undef XEN_ERRNO_DEFAULT_INCLUDE
 #ifndef __ASSEMBLY__
 };
 #endif
 
-#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 <public/errno.h>
-
 #ifndef __ASSEMBLY__
 
-#define XEN_ERRNO(name, value) name = XEN_##name,
+#define XEN_ERRNO(name, value) name = value,
 enum {
 #include <public/errno.h>
 };
 
 #else /* !__ASSEMBLY__ */
 
-#define XEN_ERRNO(name, value) .equ name, XEN_##name
+#define XEN_ERRNO(name, value) .equ name, value
 #include <public/errno.h>
 
 #endif /* __ASSEMBLY__ */
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-03-07 15:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-01 18:57 [PATCH 1/4] xen/errno: Introduce EISDIR/EROFS/ENOTEMPTY to the ABI Andrew Cooper
2016-03-01 18:57 ` [PATCH 2/4] xen/errno: Declare aliases using XEN_ERRNO() Andrew Cooper
2016-03-02  2:38   ` Doug Goldstein
2016-03-01 18:57 ` [PATCH 3/4] xen/errno: Reduce complexity of inclusion Andrew Cooper
2016-03-02  2:39   ` Doug Goldstein
2016-03-03  8:30   ` Jan Beulich
2016-03-03 14:14     ` [PATCH v3] " Andrew Cooper
2016-03-04 12:24       ` Jan Beulich
2016-03-04 12:28         ` Jan Beulich
2016-03-04 12:50           ` Andrew Cooper
2016-03-04 13:05             ` Jan Beulich
2016-03-04 16:07               ` Ian Jackson
2016-03-07 15:13                 ` Andrew Cooper [this message]
2016-03-01 18:57 ` [PATCH 4/4] hvmloader: Use xen/errno.h rather than the host systems errno.h Andrew Cooper
2016-03-02 12:53   ` Doug Goldstein
2016-03-03 11:35   ` Wei Liu
2016-03-02  2:37 ` [PATCH 1/4] xen/errno: Introduce EISDIR/EROFS/ENOTEMPTY to the ABI Doug Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457363622-29534-1-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=cardoe@cardoe.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).