xen/errno: Introduce EISDIR/EROFS/ENOTEMPTY to the ABI
PATCH 1/4 xen/errno: Introduce EISDIR/EROFS/ENOTEMPTY to the ABI
These POSIX errnos are expected by other areas of the Xen public interface, specifically public/io/xs_wire.h
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Doug Goldstein <[email protected]>
--- xen/include/public/errno.h | 3 +++ 1 file changed, 3 insertions(+)
xen/include/public/errno.h +3 -0
@@ -49,16 +49,19 @@ XEN_ERRNO(EBUSY, 16) /* Device or resource busy */ XEN_ERRNO(EEXIST, 17) /* File exists */ XEN_ERRNO(EXDEV, 18) /* Cross-device link */ XEN_ERRNO(ENODEV, 19) /* No such device */ +XEN_ERRNO(EISDIR, 21) /* Is a directory */ XEN_ERRNO(EINVAL, 22) /* Invalid argument */ XEN_ERRNO(ENFILE, 23) /* File table overflow */ XEN_ERRNO(EMFILE, 24) /* Too many open files */ XEN_ERRNO(ENOSPC, 28) /* No space left on device */ +XEN_ERRNO(EROFS, 30) /* Read-only file system */ XEN_ERRNO(EMLINK, 31) /* Too many links */ XEN_ERRNO(EDOM, 33) /* Math argument out of domain of func */ XEN_ERRNO(ERANGE, 34) /* Math result not representable */ XEN_ERRNO(EDEADLK, 35) /* Resource deadlock would occur */ XEN_ERRNO(ENAMETOOLONG, 36) /* File name too long */ XEN_ERRNO(ENOLCK, 37) /* No record locks available */ +XEN_ERRNO(ENOTEMPTY, 39) /* Directory not empty */ XEN_ERRNO(ENOSYS, 38) /* Function not implemented */ XEN_ERRNO(ENODATA, 61) /* No data available */XEN_ERRNO (ETIME ,62 )/* Timer expired */
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH 2/4 xen/errno: Declare aliases using XEN_ERRNO()
Otherwise a custom XEN_ERRNO definition will not end up creating appropriately namespaced constants for the aliases.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Doug Goldstein <[email protected]>
--- xen/include/public/errno.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
xen/include/public/errno.h +2 -3
@@ -42,6 +42,7 @@ XEN_ERRNO(ENOEXEC, 8) /* Exec format error */ XEN_ERRNO(EBADF, 9) /* Bad file number */ XEN_ERRNO(ECHILD, 10) /* No child processes */ XEN_ERRNO(EAGAIN, 11) /* Try again */ +XEN_ERRNO(EWOULDBLOCK, 11) /* Operation would block. Aliases EAGAIN */ XEN_ERRNO(ENOMEM, 12) /* Out of memory */ XEN_ERRNO(EACCES, 13) /* Permission denied */XEN_ERRNO (EFAULT ,14 )/* Bad address */
@@ -59,6 +60,7 @@ XEN_ERRNO(EMLINK, 31) /* Too many links */ XEN_ERRNO(EDOM, 33) /* Math argument out of domain of func */ XEN_ERRNO(ERANGE, 34) /* Math result not representable */ XEN_ERRNO(EDEADLK, 35) /* Resource deadlock would occur */ +XEN_ERRNO(EDEADLOCK, 35) /* Resource deadlock would occur. Aliases EDEADLK */ XEN_ERRNO(ENAMETOOLONG, 36) /* File name too long */ XEN_ERRNO(ENOLCK, 37) /* No record locks available */XEN_ERRNO (ENOTEMPTY ,39 )/* Directory not empty */
@@ -92,7 +94,4 @@ XEN_ERRNO(ETIMEDOUT, 110) /* Connection timed out */ };#endif -#define XEN_EWOULDBLOCK XEN_EAGAIN/* Operation would block */ -#define XEN_EDEADLOCK XEN_EDEADLK/* Resource deadlock would occur */ -#endif /* __XEN_PUBLIC_ERRNO_H__ */
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH 3/4 xen/errno: Reduce complexity of inclusion
In reply to Andrew CooperThe 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.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Doug Goldstein <[email protected]>
--- xen/include/public/errno.h | 55 ++++++++++++++++++++++++++++++---------------- xen/include/xen/errno.h | 6 ++--- 2 files changed, 38 insertions(+), 23 deletions(-)
xen/include/public/errno.h +36 -19
@@ -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 <public/errno.h> +* +* 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 */
xen/include/xen/errno.h +2 -4
@@ -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__ */
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH 4/4 hvmloader: Use xen/errno.h rather than the host systems errno.h
In reply to Andrew Cooperhvmloader is unhosted, and shouldn't use the system errno.h. It already has to use Xen's errno.h for other hypercalls. The use of public/io/xs_wire.h requires the use of un-prefixed errno values.
This fixes the build on stricter toolchains where requesting -fno-builtin does reduce the include path as much as it can.
---
CC: Jan Beulich <[email protected]>
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Doug Goldstein <[email protected]>
v3:
* Split single patch multiple fixes
v2:
* Fix compilation. I am not sure how v1 compiled, but I did definitely check it before posting.
--- tools/firmware/hvmloader/util.h | 9 +++++++++ tools/firmware/hvmloader/vnuma.c | 3 +-- tools/firmware/hvmloader/xenbus.c | 1 - 3 files changed, 10 insertions(+), 3 deletions(-)
tools/firmware/hvmloader/util.h +9 -0
@@ -9,6 +9,15 @@#include <xen/hvm/hvm_info_table.h> #include "e820.h" +/* Request un-prefixed values from errno.h. */ +#define XEN_ERRNO (name, value) name = value, +enum { +#include <xen/errno.h> +}; + +/* Cause xs_wire.h to give us xsd_errors[]. */ +#define EINVAL EINVAL +#define __STR (...) #__VA_ARGS__#define STR (...) __STR(__VA_ARGS__)
tools/firmware/hvmloader/vnuma.c +1 -2
@@ -28,7 +28,6 @@#include "util.h" #include "hypercall.h" #include "vnuma.h" -#include <xen/errno.h> unsigned int nr_vnodes, nr_vmemranges;unsigned int *vcpu_to_vnode, *vdistance;
@@ -40,7 +39,7 @@ void init_vnuma_info(void)struct xen_vnuma_topology_info vnuma_topo = { .domid =DOMID_SELF }; rc =hypercall_memory_op (XENMEM_get_vnumainfo, &vnuma_topo); -if ( rc != -XEN_ENOBUFS ) +if ( rc != -ENOBUFS )return ;ASSERT (vnuma_topo.nr_vcpus == hvm_info->nr_vcpus);
tools/firmware/hvmloader/xenbus.c +0 -1
@@ -27,7 +27,6 @@#include "util.h" #include "hypercall.h" -#include <errno.h> #include <xen/sched.h> #include <xen/event_channel.h> #include <xen/hvm/params.h>
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 4 lines · Andrew Cooper
These POSIX errnos are expected by other areas of the Xen public interface, specifically
public/io/xs_wire.hSigned-off-by Andrew Cooper <[email protected]>
Quoted 33 lines
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Doug Goldstein <[email protected]>--- xen/include/public/errno.h | 3 +++ 1 file changed, 3 insertions(+)xen/include/public/errno.h +3
-0@@ -49,16 +49,19 @@ XEN_ERRNO(EBUSY, 16) /* Device or resource busy */ XEN_ERRNO(EEXIST, 17) /* File exists */ XEN_ERRNO(EXDEV, 18) /* Cross-device link */ XEN_ERRNO(ENODEV, 19) /* No such device */ +XEN_ERRNO(EISDIR, 21) /* Is a directory */ XEN_ERRNO(EINVAL, 22) /* Invalid argument */ XEN_ERRNO(ENFILE, 23) /* File table overflow */ XEN_ERRNO(EMFILE, 24) /* Too many open files */ XEN_ERRNO(ENOSPC, 28) /* No space left on device */ +XEN_ERRNO(EROFS, 30) /* Read-only file system */ XEN_ERRNO(EMLINK, 31) /* Too many links */ XEN_ERRNO(EDOM, 33) /* Math argument out of domain of func */ XEN_ERRNO(ERANGE, 34) /* Math result not representable */ XEN_ERRNO(EDEADLK, 35) /* Resource deadlock would occur */ XEN_ERRNO(ENAMETOOLONG, 36) /* File name too long */ XEN_ERRNO(ENOLCK, 37) /* No record locks available */ +XEN_ERRNO(ENOTEMPTY, 39) /* Directory not empty */ XEN_ERRNO(ENOSYS, 38) /* Function not implemented */ XEN_ERRNO(ENODATA, 61) /* No data available */XEN_ERRNO (ETIME ,62 )/* Timer expired */
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/4] xen/errno: Declare aliases using XEN_ERRNO()
In reply to Andrew CooperQuoted 4 lines · Andrew Cooper
Otherwise a custom
XEN_ERRNOdefinition will not end up creating appropriately namespaced constants for the aliases.Signed-off-by Andrew Cooper <[email protected]>
Quoted 37 lines
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Doug Goldstein <[email protected]>--- xen/include/public/errno.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)xen/include/public/errno.h +2
-3@@ -42,6 +42,7 @@ XEN_ERRNO(ENOEXEC, 8) /* Exec format error */ XEN_ERRNO(EBADF, 9) /* Bad file number */ XEN_ERRNO(ECHILD, 10) /* No child processes */ XEN_ERRNO(EAGAIN, 11) /* Try again */ +XEN_ERRNO(EWOULDBLOCK, 11) /* Operation would block. Aliases EAGAIN */ XEN_ERRNO(ENOMEM, 12) /* Out of memory */ XEN_ERRNO(EACCES, 13) /* Permission denied */XEN_ERRNO (EFAULT ,14 )/* Bad address */ @@ -59,6 +60,7 @@ XEN_ERRNO(EMLINK, 31) /* Too many links */ XEN_ERRNO(EDOM, 33) /* Math argument out of domain of func */ XEN_ERRNO(ERANGE, 34) /* Math result not representable */ XEN_ERRNO(EDEADLK, 35) /* Resource deadlock would occur */ +XEN_ERRNO(EDEADLOCK, 35) /* Resource deadlock would occur. Aliases EDEADLK */ XEN_ERRNO(ENAMETOOLONG, 36) /* File name too long */ XEN_ERRNO(ENOLCK, 37) /* No record locks available */XEN_ERRNO (ENOTEMPTY ,39 )/* Directory not empty */ @@ -92,7 +94,4 @@ XEN_ERRNO(ETIMEDOUT, 110) /* Connection timed out */ };#endif -#define XEN_EWOULDBLOCK XEN_EAGAIN/* Operation would block */ -#define XEN_EDEADLOCK XEN_EDEADLK/* Resource deadlock would occur */ -#endif /* __XEN_PUBLIC_ERRNO_H__ */
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/4] xen/errno: Reduce complexity of inclusion
In reply to Andrew CooperQuoted 7 lines · Andrew Cooper
The inclusion rules conditions for
errno.hwere 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 <[email protected]>
Quoted 113 lines
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Doug Goldstein <[email protected]>--- xen/include/public/errno.h | 55 ++++++++++++++++++++++++++++++---------------- xen/include/xen/errno.h | 6 ++--- 2 files changed, 38 insertions(+), 23 deletions(-)xen/include/public/errno.h +36
-19@@ -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 <public/errno.h> +* +* 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 */ xen/include/xen/errno.h +2
-4@@ -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__ */
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 4/4] hvmloader: Use xen/errno.h rather than the host systems errno.h
In reply to Andrew CooperQuoted 9 lines · Andrew Cooper
hvmloader is unhosted, and shouldn't use the system
errno.h. It already has to use Xen'serrno.hfor other hypercalls. The use ofpublic/io/xs_wire.hrequires the use of un-prefixed errno values.This fixes the build on stricter toolchains where requesting -fno-builtin does reduce the include path as much as it can.
Reported-by Doug Goldstein <[email protected]>Signed-off-by Andrew Cooper <[email protected]>
Quoted 72 lines
---
CC: Jan Beulich <[email protected]>
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Doug Goldstein <[email protected]>v3:
* Split single patch multiple fixes
v2:
* Fix compilation. I am not sure how v1 compiled, but I did definitely check it before posting.--- tools/firmware/hvmloader/util.h | 9 +++++++++ tools/firmware/hvmloader/vnuma.c | 3 +-- tools/firmware/hvmloader/xenbus.c | 1 - 3 files changed, 10 insertions(+), 3 deletions(-)tools/firmware/hvmloader/util.h +9
-0@@ -9,6 +9,15 @@#include <xen/hvm/hvm_info_table.h> #include "e820.h" +/* Request un-prefixed values from errno.h. */ +#define XEN_ERRNO (name, value) name = value, +enum { +#include <xen/errno.h> +}; + +/* Cause xs_wire.h to give us xsd_errors[]. */ +#define EINVAL EINVAL +#define __STR (...) #__VA_ARGS__#define STR (...) __STR(__VA_ARGS__)tools/firmware/hvmloader/vnuma.c +1
-2@@ -28,7 +28,6 @@#include "util.h" #include "hypercall.h" #include "vnuma.h" -#include <xen/errno.h> unsigned int nr_vnodes, nr_vmemranges;unsigned int *vcpu_to_vnode, *vdistance;@@ -40,7 +39,7 @@ void init_vnuma_info(void)struct xen_vnuma_topology_info vnuma_topo = { .domid =DOMID_SELF }; rc =hypercall_memory_op (XENMEM_get_vnumainfo, &vnuma_topo); -if ( rc != -XEN_ENOBUFS ) +if ( rc != -ENOBUFS )return ;ASSERT (vnuma_topo.nr_vcpus == hvm_info->nr_vcpus);tools/firmware/hvmloader/xenbus.c +0
-1@@ -27,7 +27,6 @@#include "util.h" #include "hypercall.h" -#include <errno.h> #include <xen/sched.h> #include <xen/event_channel.h> #include <xen/hvm/params.h>
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/4] xen/errno: Reduce complexity of inclusion
In reply to Andrew CooperQuoted 6 lines
Quoted 1 line
Quoted 1 line · On 01.03.16 at 19:57, <[email protected]> wrote:
The inclusion rules conditions for
errno.hwere 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.
Nice. While the enforcement of the creation of the XEN_* variants was intentional, you're right that it's not really necessary.
Quoted 39 lines
xen/include/public/errno.h +23
-9@@ -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 <public/errno.h> +* +* 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__
xen/include/public/errno.h line 35
Quoted 10 lines
xen/include/public/errno.h +4
-2-/* ` 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
This eliminates the default creation of equates in the assembly case, which - with the header being part of 4.6.x - we can't do.
Quoted 14 lines
xen/include/public/errno.h +0
-0@@ -82,16 +98,17 @@ XEN_ERRNO(EISCONN, 106) /* Transport endpoint is alreadyconnected */
XEN_ERRNO(ENOTCONN, 107)/* Transport endpoint is not connected */
XEN_ERRNO(ETIMEDOUT, 110)/* Connection timed out */xen/include/public/errno.h +1
-4-#undef XEN_ERRNO#endif /* XEN_ERRNO */ -#ifndef __XEN_PUBLIC_ERRNO_H__ -#define __XEN_PUBLIC_ERRNO_H__ -/* ` } */ +#ifdef XEN_ERRNO_DEFAULT_INCLUDE
xen/include/public/errno.h XEN_ERRNO(EISCONN, 106) /* Transport endpoint is already connected */ · line 112
Quoted 10 lines
xen/include/public/errno.h +7
-3-#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 +} ;
Stray blank.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 4/4] hvmloader: Use xen/errno.h rather than the host systems errno.h
In reply to Andrew CooperQuoted 9 lines · Andrew Cooper
hvmloader is unhosted, and shouldn't use the system
errno.h. It already has to use Xen'serrno.hfor other hypercalls. The use ofpublic/io/xs_wire.hrequires the use of un-prefixed errno values.This fixes the build on stricter toolchains where requesting -fno-builtin does reduce the include path as much as it can.
Reported-by Doug Goldstein <[email protected]>Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 1/1 xen/errno: Reduce complexity of inclusion
In reply to Jan BeulichThe 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.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Doug Goldstein <[email protected]>
v3:
* Reinstate magic documentation comments
* Provide assembly-suitable defaults if appropriate
--- xen/include/public/errno.h | 46 ++++++++++++++++++++++++++++++++++++++-------- xen/include/xen/errno.h | 6 ++---- 2 files changed, 40 insertions(+), 12 deletions(-)
xen/include/public/errno.h +38 -8
@@ -1,4 +1,30 @@ +/* +* 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. +*/ + +#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 +37,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 /*
@@ -82,16 +109,19 @@ 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__ -/* ` } */ + +/* +* Clean up from a default include. Close the enum (for C) and remove the +* default XEN_ERRNO from scope. +*/ +#ifdef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO#ifndef __ASSEMBLY__ };#endif -#endif /* __XEN_PUBLIC_ERRNO_H__ */ +#endif /* XEN_ERRNO_DEFAULT_INCLUDE */
xen/include/xen/errno.h +2 -4
@@ -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__ */
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v3] xen/errno: Reduce complexity of inclusion
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 03.03.16 at 15:14, <[email protected]> wrote:
xen/include/public/errno.h +4
-5@@ -82,16 +109,19 @@ 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__ -/* ` } */ + +/* +* Clean up from a default include. Close the enum (for C) and remove the +* default XEN_ERRNO from scope.
xen/include/public/errno.h XEN_ERRNO(EISCONN, 106) /* Transport endpoint is already connected */ · line 127
Quoted 10 lines
xen/include/public/errno.h +5
-1+*/ +#ifdef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO#ifndef __ASSEMBLY__ };#endif -#endif /* __XEN_PUBLIC_ERRNO_H__ */ +#endif /* XEN_ERRNO_DEFAULT_INCLUDE */
So far, upon reaching the end oft the file XEN_ERRNO is undefined, no matter whether it got defined here or prior to inclusion. I think this property should be retained, but moving the #undef to the very end. Please indicate if that's okay with you, as this doesn't really require another version to be sent.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3] xen/errno: Reduce complexity of inclusion
Quoted 27 lines
Review XEN_ERRNO(EISCONN, 106) /* Transport endpoint is already
Quoted 3 lines
Quoted 2 lines · On 04.03.16 at 13:24, <[email protected]> wrote:
Quoted 1 line · On 03.03.16 at 15:14, <[email protected]> wrote:
(quoted diff) +0
-0@@ -82,16 +109,19 @@ XEN_ERRNO(EISCONN, 106) /* Transport endpoint is alreadyconnected */
Quoted 23 lines
xen/include/public/errno.h +8
-5XEN_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__ -/* ` } */ + +/* +* Clean up from a default include. Close the enum (for C) and remove the +* default XEN_ERRNO from scope. +*/ +#ifdef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO#ifndef __ASSEMBLY__ };#endif
Quoted 7 lines
xen/include/public/errno.h XEN_ERRNO(EISCONN, 106) /* Transport endpoint is already connected */ · line 127
Quoted 2 lines
xen/include/public/errno.h +1
-1-#endif /* __XEN_PUBLIC_ERRNO_H__ */ +#endif /* XEN_ERRNO_DEFAULT_INCLUDE */ So far, upon reaching the end oft the file
XEN_ERRNOis undefined, no matter whether it got defined here or prior to inclusion. I think this property should be retained, but moving the #undef to the very end.
Or rather not removing it from where it's now.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3] xen/errno: Reduce complexity of inclusion
Quoted 27 lines · Jan Beulich
Quoted 27 lines
Review XEN_ERRNO(EISCONN, 106) /* Transport endpoint is already
Quoted 3 lines
Quoted 2 lines · On 04.03.16 at 13:24, <[email protected]> wrote:
Quoted 1 line · On 03.03.16 at 15:14, <[email protected]> wrote:
(quoted diff) +0
-0@@ -82,16 +109,19 @@ XEN_ERRNO(EISCONN, 106) /* Transport endpoint is alreadyconnected */
Quoted 23 lines
xen/include/public/errno.h +8
-5XEN_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__ -/* ` } */ + +/* +* Clean up from a default include. Close the enum (for C) and remove the +* default XEN_ERRNO from scope. +*/ +#ifdef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO#ifndef __ASSEMBLY__ };#endif
Quoted 7 lines
Quoted 6 lines
xen/include/public/errno.h XEN_ERRNO(EISCONN, 106) /* Transport endpoint is already connected */ · line 127
Quoted 2 lines
xen/include/public/errno.h +1
-1-#endif /* __XEN_PUBLIC_ERRNO_H__ */ +#endif /* XEN_ERRNO_DEFAULT_INCLUDE */ So far, upon reaching the end oft the file
XEN_ERRNOis undefined, no matter whether it got defined here or prior to inclusion. I think this property should be retained, but moving the #undef to the very end.Or rather not removing it from where it's now.
IMO, it is wrong to undef XEN_ERRNO if it was provided from external scope.
The only users of this "custom" include in Xen itself, and shortly, hvmloader.
I think it is fine as-is.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3] xen/errno: Reduce complexity of inclusion
Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 04.03.16 at 13:50, <[email protected]> wrote:
Quoted 33 lines · Jan Beulich
Quoted 33 lines
Review XEN_ERRNO(EISCONN, 106) /* Transport endpoint is already
Quoted 3 lines
Quoted 2 lines · On 04.03.16 at 13:24, <[email protected]> wrote:
Quoted 1 line · On 03.03.16 at 15:14, <[email protected]> wrote:
(quoted diff) +0
-0@@ -82,16 +109,19 @@ XEN_ERRNO(EISCONN, 106) /* Transport endpoint is alreadyconnected */
Quoted 15 lines
xen/include/public/errno.h +4
-5XEN_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__ -/* ` } */ + +/* +* Clean up from a default include. Close the enum (for C) and remove the +* default XEN_ERRNO from scope. xen/include/public/errno.h XEN_ERRNO(EISCONN, 106) /* Transport endpoint is already connected */ · line 127
Quoted 10 lines
xen/include/public/errno.h +5
-1+*/ +#ifdef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO_DEFAULT_INCLUDE +#undef XEN_ERRNO#ifndef __ASSEMBLY__ };#endif -#endif /* __XEN_PUBLIC_ERRNO_H__ */ +#endif /* XEN_ERRNO_DEFAULT_INCLUDE */ So far, upon reaching the end oft the file
XEN_ERRNOis undefined, no matter whether it got defined here or prior to inclusion. I think this property should be retained, but moving the #undef to the very end.
Quoted 3 lines
Quoted 1 line
Or rather not removing it from where it's now.
IMO, it is wrong to undef
XEN_ERRNOif it was provided from external scope.
Well, even if not written down, that's the intended behavior: The use case for the including file to further need that definition is rather hard to see, whereas use cases for the including file wanting to do multiple inclusion are quite easy to construct, and in that case the including file would needlessly be forced to repeatedly #undef the symbol.
Quoted 2 lines
The only users of this "custom" include in Xen itself, and shortly, hvmloader.
The only users you know of. I'm definitely having plans to make Linux use it too, to have a build time check that the errno values continue to be in sync.
Quoted 1 line
I think it is fine as-is.
I could use the same words, just for the unpatched file: I don't really agree with this part of your change.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3] xen/errno: Reduce complexity of inclusion
Jan Beulich writes ("Re: [Xen-devel] [PATCH v3] xen/errno: Reduce complexity of inclusion"):
Quoted 9 lines · On 04.03.16 at 13:50, <[email protected]> wrote:
Quoted 1 line
IMO, it is wrong to undef
XEN_ERRNOif it was provided from external scope.Well, even if not written down, that's the intended behavior: The use case for the including file to further need that definition is rather hard to see, whereas use cases for the including file wanting to do multiple inclusion are quite easy to construct, and in that case the including file would needlessly be forced to repeatedly #undef the symbol.
This is really a very bikeshed issue, but: I slightly prefer Jan's argument here to Andrew's.
I think that this overall patch from Andrew is very helpful and I would like to see this minor issue resolved.
Andrew, would you be able to revise the header to #undef XEN_ERRNO in this case ? Naturally this would want to be documented, in your admirable new doc comment.
Thanks,
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v4 1/1 xen/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.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Doug Goldstein <[email protected]>
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(-)
xen/include/public/errno.h +34 -7
@@ -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 */
xen/include/xen/errno.h +2 -4
@@ -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__ */
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel