Re: [Xen-devel] [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS

2019-03-08 Thread Ian Jackson
Jan Beulich writes ("Re: [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS"): > >No. This is not fine. Signed integer subtraction sometimes has UB. ... > I've spent an hour trying to find the relevant parts of the spec, but I'm > afraid I've once again failed at finding all necessary pieces. The spe

Re: [Xen-devel] [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS

2019-03-08 Thread Jan Beulich
>>> Ian Jackson 03/07/19 3:16 PM >>> >Jan Beulich writes ("Re: [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS"): >> On 06.03.19 at 21:55, wrote: >> > On Wed, 6 Mar 2019, Jan Beulich wrote: >> > uintptr_t is the integer type corresponding to a pointer, so we should >> > use uintptr_t first. ptrdiff

Re: [Xen-devel] [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS

2019-03-07 Thread Ian Jackson
Jan Beulich writes ("Re: [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS"): > On 06.03.19 at 21:55, wrote: > > On Wed, 6 Mar 2019, Jan Beulich wrote: > > uintptr_t is the integer type corresponding to a pointer, so we should > > use uintptr_t first. ptrdiff_t is the difference type so we should cast

Re: [Xen-devel] [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS

2019-03-07 Thread Jan Beulich
>>> On 06.03.19 at 21:55, wrote: > On Wed, 6 Mar 2019, Jan Beulich wrote: >> > +static inline ptrdiff_t name ## _bytediff(const type s1[], >> > \ >> > + const struct abstract_ ## name >> > s2[])\ >> > +{

Re: [Xen-devel] [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS

2019-03-06 Thread Stefano Stabellini
On Wed, 6 Mar 2019, Jan Beulich wrote: > > +static inline ptrdiff_t name ## _diff(const type s1[], > >\ > > + const struct abstract_ ## name s2[]) > >\ > > +{

Re: [Xen-devel] [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS

2019-03-06 Thread Jan Beulich
>>> On 05.03.19 at 23:38, wrote: > --- a/xen/include/xen/lib.h > +++ b/xen/include/xen/lib.h > @@ -173,4 +173,92 @@ void init_constructors(void); > void *bsearch(const void *key, const void *base, size_t num, size_t size, >int (*cmp)(const void *key, const void *elt)); > > + /*

[Xen-devel] [PATCH v11 3/9] xen: introduce DECLARE_BOUNDS

2019-03-05 Thread Stefano Stabellini
Introduce a MACRO to be used to declare array variables corresponding to linker symbols, plus two static inline functions to be used for comparing and subtracting pointers with the linker symbols. Note that the start and end symbols are declared of different types to help avoid errors and misusing