Return-Path: Subject: RE: [Bluez-devel] Alignment issue From: Marcel Holtmann To: David Woodhouse Cc: Daryl Van Vorst , "'BlueZ Mailing List'" In-Reply-To: <1092299689.4622.8.camel@imladris.demon.co.uk> References: <001201c47fc2$7093e4a0$1301010a@baked> <1092252699.4564.238.camel@pegasus> <1092299689.4622.8.camel@imladris.demon.co.uk> Content-Type: text/plain Message-Id: <1092302834.28711.72.camel@pegasus> Mime-Version: 1.0 Sender: bluez-devel-admin@lists.sourceforge.net Errors-To: bluez-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Id: List-Post: List-Help: List-Subscribe: , List-Archive: Date: Thu, 12 Aug 2004 11:27:14 +0200 Hi David, > > this is what the Linux kernel is using and we will notice it if some > > compiler version will optimize it in future. I committed that change to > > CVS. > > The Linux kernel isn't the best example to follow when it comes to > relying on undocumented and unguaranteed compiler behaviour. Don't be so > sure the kernel would notice -- we have to fix up alignment trap in the > kernel _anyway_ so the use of get_unaligned() is only an optimisation > there. > > I'd be more inclined to play with using char * pointers in the memcpy, > and/or __attribute__((packed)). I am not an expert when it comes to specific compiler stuff and I can't make the best decision with my limited information. What I realized is that we need our own unaligned access implementation, because we can't rely on the asm/unaligned.h. So I started to put our own in bluetooth.h for general access. If this was wrong, please correct me. Some platforms can do unaligned access by themself and some are not. At the moment only the i386 is listed, but we should list others like AMD64 and PowerPC. Patches and hints are welcome. For the rest the generic way is to use memcpy, but actually every architecture uses memmove, because of the GCC __builtin_memcpy problem. Some of them like Alpha and ARM are using specific implementations, but using the macro with memmove seems also to work fine there. I like to keep the unaligned macros as short as possible. Do anyone wrote an autoconf macro for checking if memmove works like expected or if it gets optimized by the compiler? Regards Marcel ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel