From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v2 24/30] tools/libxc: Modify bitmap operations to take void pointers Date: Thu, 18 Feb 2016 13:37:22 +0000 Message-ID: <56C5C912.9000401@citrix.com> References: <1454679743-18133-1-git-send-email-andrew.cooper3@citrix.com> <1454679743-18133-25-git-send-email-andrew.cooper3@citrix.com> <20160208162304.GA99992@deinos.phlegethon.org> <1454949407.17191.17.camel@citrix.com> <56BB0BD0.6020009@citrix.com> <1455099530.19857.145.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1455099530.19857.145.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell , Tim Deegan Cc: Wei Liu , Ian Jackson , Xen-devel List-Id: xen-devel@lists.xenproject.org On 10/02/16 10:18, Ian Campbell wrote: > On Wed, 2016-02-10 at 10:07 +0000, Andrew Cooper wrote: >> On 08/02/16 16:36, Ian Campbell wrote: >>> On Mon, 2016-02-08 at 16:23 +0000, Tim Deegan wrote: >>>> At 13:42 +0000 on 05 Feb (1454679737), Andrew Cooper wrote: >>>>> The type of the pointer to a bitmap is not interesting; it does not >>>>> affect the >>>>> representation of the block of bits being pointed to. >>>> It does affect the alignment, though. Is this safe on ARM? >>> Good point. These constructs in the patch: >>> >>> + const unsigned long *addr = _addr; >>> >>> Would be broken if _addr were not suitably aligned for an unsigned >>> long. >>> >>> That probably rules out this approach unfortunately. >> What about reworking libxc bitops in terms of unsigned char? That >> should cover all alignment issues. > Assuming any asm or calls to __builtin_foo backends were adjusted to suite, > that would be ok, would that be compatible with the Xen side though? It is all plain C. What I mean is -static inline int test_bit(int nr, unsigned long *addr) +static inline int test_bit(int nr, const void *_addr) { + const char *addr = _addr; return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1; } and changing BITMAP_{ENTRY,SHIFT}() to use char rather than unsigned long. The prototypes still have void *, but char* is used internally which will match the minimum alignment of any object passed. ~Andrew