From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Frysinger Date: Fri, 20 Jul 2012 17:47:45 -0400 Subject: [U-Boot] [PATCH 1/2] common.h: Introduce DEFINE_CACHE_ALIGN_BUFFER In-Reply-To: <201207201331.48086.marex@denx.de> References: <1341716895-31089-1-git-send-email-marex@denx.de> <201207200001.19869.vapier@gentoo.org> <201207201331.48086.marex@denx.de> Message-ID: <201207201747.47423.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Friday 20 July 2012 07:31:47 Marek Vasut wrote: > Dear Mike Frysinger, > > On Saturday 07 July 2012 23:08:14 Marek Vasut wrote: > > > +/* > > > DEFINE_CACHE_ALIGN_BUFFER() is similar to ALLOC_CACHE_ALIGN_BUFFER, > > > but it's purpose is to allow allocating aligned buffers outside of > > > function scope. Usage of this macro shall be avoided or used with > > > extreme care! */ > > > +#define DEFINE_CACHE_ALIGN_BUFFER(type, name, size) > > > + static char __##name[roundup(size * sizeof(type), ARCH_DMA_MINALIGN)] > > > + __aligned(ARCH_DMA_MINALIGN); > > > + static type *name = (type *)__##name; > > > > how is this any different from doing: > > static __u8 foo[1234] __aligned(ARCH_DMA_MINALIGN); > > Does __aligned() align both start of the buffer downwards and end of it > upwards ? it guarantees the start is aligned. i don't believe it does any tail padding. that said, you've added just 1 consumer, but it uses in function scope, so i don't see why you had to define a new helper in the first place. the existing one would work fine shouldn't it ? you should probably add a const to the 2nd part so gcc is more likely to optimize away the storage: static type * const name = (type *)__##name; otherwise older gcc versions will create a pointer to go through rather than having things directly access the buffer. w/out const: $ readelf -s a.out | grep foo 11: 00000000004005d0 8 OBJECT LOCAL DEFAULT 13 foo.1592 12: 0000000000402080 96 OBJECT LOCAL DEFAULT 25 __foo.1591 w/const: $ readelf -s a.out | grep foo 11: 0000000000402080 96 OBJECT LOCAL DEFAULT 25 __foo.1591 -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. URL: