From mboxrd@z Thu Jan 1 00:00:00 1970 From: Doug Goldstein Subject: Re: [PATCH 3/4] xen/errno: Reduce complexity of inclusion Date: Tue, 1 Mar 2016 20:39:16 -0600 Message-ID: <56D65254.5080807@cardoe.com> References: <1456858641-20776-1-git-send-email-andrew.cooper3@citrix.com> <1456858641-20776-3-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2217912645384207671==" Return-path: In-Reply-To: <1456858641-20776-3-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Andrew Cooper , Xen-devel Cc: Tim Deegan , Jan Beulich List-Id: xen-devel@lists.xenproject.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============2217912645384207671== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="6hrCN078MpA2sSxgg2FgmKxCIuo4Qb0Rw" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6hrCN078MpA2sSxgg2FgmKxCIuo4Qb0Rw Content-Type: multipart/mixed; boundary="iaAU7wRv8REKc03wWF5MixcKkPJTA9LKB" From: Doug Goldstein To: Andrew Cooper , Xen-devel Cc: Jan Beulich , Tim Deegan Message-ID: <56D65254.5080807@cardoe.com> Subject: Re: [PATCH 3/4] xen/errno: Reduce complexity of inclusion References: <1456858641-20776-1-git-send-email-andrew.cooper3@citrix.com> <1456858641-20776-3-git-send-email-andrew.cooper3@citrix.com> In-Reply-To: <1456858641-20776-3-git-send-email-andrew.cooper3@citrix.com> --iaAU7wRv8REKc03wWF5MixcKkPJTA9LKB Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 3/1/16 12:57 PM, Andrew Cooper wrote: > The inclusion rules conditions for errno.h were unnecesserily complicat= ed, and > required the includer to jump through hoops if they wished to avoid get= ting > multiple namespaces worth of constants. >=20 > Vastly simply the logic, and document what is going on. >=20 > 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(-) >=20 > 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 =3D 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 s= hall get > + * an enumeration in the XEN_xxx namespace. > + * > + * 2) The special case where the includer provides a XEN_ERRNO() in sc= ope. > + * > + * In this case, no inclusion guards apply and the caller is responsib= le for > + * their XEN_ERRNO() being appropriate in the included context. > + */ > =20 > -#else /* !__ASSEMBLY__ */ > +#ifndef XEN_ERRNO > =20 > -#define XEN_ERRNO(name, value) .equ XEN_##name, value > +/* > + * Includer has not provided a custom XEN_ERRNO(). Arrange an automat= ic enum > + * and constants in the XEN_xxx namespace. > + */ > +#define XEN_ERRNO_DEFAULT_INCLUDE > =20 > -#endif /* __ASSEMBLY__ */ > +#ifndef __XEN_PUBLIC_ERRNO_H__ > +#define __XEN_PUBLIC_ERRNO_H__ > =20 > -/* ` enum neg_errnoval { [ -Efoo for each Efoo in the list below ] }= */ > -/* ` enum errnoval { */ > +#define XEN_ERRNO(name, value) XEN_##name =3D value, > +enum { > =20 > #endif /* __XEN_PUBLIC_ERRNO_H__ */ > +#endif /* !XEN_ERRNO */ > + > =20 > #ifdef XEN_ERRNO > =20 > @@ -82,16 +98,17 @@ XEN_ERRNO(EISCONN, 106) /* Transport endpoint is al= ready connected */ > XEN_ERRNO(ENOTCONN, 107) /* Transport endpoint is not connected */ > XEN_ERRNO(ETIMEDOUT, 110) /* Connection timed out */ > =20 > -#undef XEN_ERRNO > #endif /* XEN_ERRNO */ > =20 > -#ifndef __XEN_PUBLIC_ERRNO_H__ > -#define __XEN_PUBLIC_ERRNO_H__ > =20 > -/* ` } */ > +#ifdef XEN_ERRNO_DEFAULT_INCLUDE > =20 > -#ifndef __ASSEMBLY__ > -}; > -#endif > +/* > + * Clean up from a default include. Close the enum and remove the def= ault > + * XEN_ERRNO from scope. > + */ > +#undef XEN_ERRNO_DEFAULT_INCLUDE > +#undef XEN_ERRNO > +} ; > =20 > -#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__ > =20 > -#include > - > #ifndef __ASSEMBLY__ > =20 > -#define XEN_ERRNO(name, value) name =3D XEN_##name, > +#define XEN_ERRNO(name, value) name =3D value, > enum { > #include > }; > =20 > #else /* !__ASSEMBLY__ */ > =20 > -#define XEN_ERRNO(name, value) .equ name, XEN_##name > +#define XEN_ERRNO(name, value) .equ name, value > #include > =20 > #endif /* __ASSEMBLY__ */ >=20 --=20 Doug Goldstein --iaAU7wRv8REKc03wWF5MixcKkPJTA9LKB-- --6hrCN078MpA2sSxgg2FgmKxCIuo4Qb0Rw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0 iQJ8BAEBCgBmBQJW1lJVXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRBNTM5MEQ2RTNFMTkyNzlCNzVDMzIwOTVB MkJDMDNEQzg3RUQxQkQ0AAoJEKK8A9yH7RvUPxQP/iyJeYyq8+eqShFD257itTe7 sf7Kq+OdDv+ETMbcmtbBq6HzYtkdZSdR0S7pdt1Rw1CUJhSRv9MuWyAYT0vIy40k JFlFdEwMa/Bu7TRvP+eEFDNV/YZAgVe+AB+DLjtyRlEaiMkHJcFu3tnTVqpCLDfg 3ZuQ1GEVKDsav3Qb1XvwduWd04jrFsUhUBQbnyNh90lCZ7cX3tg+hh6Irz3HH+0H VSSe6+wc0NYr2WXO0Y7NiVr252qZZ9H2I9G173tnL8KtIANWLiMRfOXJLpVrYDJb WOPELHV00DoHe1WXTcqnSZudPu3gNaivRb8zORthT34YCCAksT7uBZGnaMwIMq// IgxW2obS0T21RX8rpNRndSe7jFEQbI6mJDUnOcV5vAFwzbzcO+1Sv2FuCpLZ89TG 5ykkQgyOOIPCnik4AJQNuSgKb75bwCnR1aEsiE2FFOipC0MRW965bRToqs/Vwb0s DcG0ybO4GBC+UTAGeV7hv9CIYWdG7Uy/f03WmTXZFMrEsYJHSa+AZBpP6wyWji+L nmDvy2q/KaUQ71R+ELVX5Nx4/9n2ETeQuvj1kLKeZy+Z2lzZCNs2SJC7HpqHsN3t PYuN1VxAHrZLYJw9Wde5W0e5wlc4FKFdMbjdi66SJmakyB5xcKv2WAhYDNWnFzzW GtOlDYsH8NTvUDLmXX/v =xSHn -----END PGP SIGNATURE----- --6hrCN078MpA2sSxgg2FgmKxCIuo4Qb0Rw-- --===============2217912645384207671== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --===============2217912645384207671==--