[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.6] public/errno: Reduce complexity of inclusion



commit 83e463edaab3dfb6fc36cf1db6bf6607aefb630f
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Mar 7 17:45:13 2016 +0100
Commit:     Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
CommitDate: Wed May 29 12:08:25 2019 +0100

    public/errno: Reduce complexity of inclusion
    
    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@xxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
    (cherry picked from commit 67790205df26e7c3dfeef8b8e64194ebc279220d)
---
 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 dbac396798..a0dd0cfd5b 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 31784663fe..69b28dd3c6 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__ */
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.6

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.