public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] Alignment issue
@ 2004-08-10 18:38 Daryl Van Vorst
  2004-08-10 23:12 ` Marcel Holtmann
  2004-08-11  7:13 ` Marcel Holtmann
  0 siblings, 2 replies; 43+ messages in thread
From: Daryl Van Vorst @ 2004-08-10 18:38 UTC (permalink / raw)
  To: 'BlueZ Mailing List'

Marcel,

I ran into an alignment problem on our ARM platform. It showed up as =
corrupt
SDP responses. I traced it back to bt_put_unaligned() in bluetooth.h

The attached patch should fix the problem (it does as far as I can =
tell).
The compiler probably thinks both arguments to memcpy() are aligned and =
so
makes an optimization which breaks the copy (because the destination is =
not
actually aligned). Perhaps this is a compiler bug... I'm using gcc =
3.3.3.
After googling and reading some discussion on the topic it seems that =
it's
probably not a compiler bug. I'll leave that for someone else to decide. =
:)

I know I'm behind on the libs version, but I just had a look in CVS and =
the
code in question is the same.

Look reasonable to you?

Regards,

-Daryl.

--- bluez-libs-2.8/include/bluetooth.h	2004-07-07 21:54:33.000000000 =
-0700
+++ bluez-libs-2.8_mod/include/bluetooth.h	2004-08-09
11:27:04.000000000 -0700
@@ -93,10 +93,14 @@
 #define bt_put_unaligned(val, ptr) ((void)( *(ptr) =3D (val) ))
 #else
 #define bt_get_unaligned(ptr) \
-	({ __typeof__(*(ptr)) __tmp; memcpy(&__tmp, (ptr), sizeof(*(ptr)));
__tmp; })
+	({ __typeof__(*(ptr)) __tmp; \
+	char *__tmp1 =3D (char *)(ptr); \
+	memcpy(&__tmp, __tmp1, sizeof(*(ptr))); \
+	__tmp; })
 #define bt_put_unaligned(val, ptr) \
 	({ __typeof__(*(ptr)) __tmp =3D (val); \
-	memcpy((ptr), &__tmp, sizeof(*(ptr))); \
+	char *__tmp1 =3D (char *)(ptr); \
+	memcpy(__tmp1, &__tmp, sizeof(*(ptr))); \
 	(void)0; })
 #endif
=20



-------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 43+ messages in thread
* Re: [Bluez-devel] Alignment issue
@ 2004-08-16  9:48 john smith
  2004-08-16 10:15 ` Marcel Holtmann
  0 siblings, 1 reply; 43+ messages in thread
From: john smith @ 2004-08-16  9:48 UTC (permalink / raw)
  To: bluez-devel

> > > Why are these macros even here? ISTR Max having some reason not to use
> > > <asm/unaligned.h> but surely that's what it's there for...
> >
> > No, asm/unaligned.h is there for kernel code only.
>
>the rule is to not include headers from the kernel source code in any
>user space program or library. Even if some people try to bend this rule
>I will follow as much as I can.

Hi, I'm new to Linux prog. and I'm a bit confused. Does this mean there's a 
problem with bluez/utils/tools/l2ping.c which contains:

   #include <asm/types.h>
   #include <asm/byteorder.h>


Or are the above includes System kernel headers ( which as far as I 
understand are OK for user-space apps. to link to) rather than Kernel source 
headers.

Bye for now,

John

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo



-------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2005-01-23 23:16 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-10 18:38 [Bluez-devel] Alignment issue Daryl Van Vorst
2004-08-10 23:12 ` Marcel Holtmann
2004-08-11  9:20   ` Stephen Crane
2004-08-11 11:08     ` David Woodhouse
2004-08-11 19:33       ` Marcel Holtmann
2004-08-11  7:13 ` Marcel Holtmann
2004-08-11 16:44   ` Daryl Van Vorst
2004-08-11 19:31     ` Marcel Holtmann
2004-08-12  8:34       ` David Woodhouse
2004-08-12  9:27         ` Marcel Holtmann
2004-08-12 10:01           ` David Woodhouse
2004-08-12 10:22             ` Marcel Holtmann
2004-08-12 10:35               ` David Woodhouse
2004-08-12 11:00                 ` Marcel Holtmann
2004-08-12 11:33                   ` David Woodhouse
2004-08-12 11:49                     ` Marcel Holtmann
2004-08-12 12:02                       ` David Woodhouse
2004-08-12 12:29                         ` Marcel Holtmann
2004-08-12 13:36                         ` Marcel Holtmann
2004-08-13  8:07                           ` David Woodhouse
2004-08-13  9:05                             ` Marcel Holtmann
2004-08-13  9:14                               ` David Woodhouse
2004-08-13 11:52                               ` David Woodhouse
2004-08-13 12:40                                 ` Marcel Holtmann
2004-08-12 12:53               ` David Woodhouse
2004-08-13  9:58                 ` Marcel Holtmann
2004-08-13 10:56                   ` David Woodhouse
2004-08-12 10:10           ` Stephen Crane
2004-08-12 10:25             ` Marcel Holtmann
2005-01-20 14:30   ` David Woodhouse
2005-01-20 14:45     ` Marcel Holtmann
2005-01-20 14:59       ` David Woodhouse
2005-01-20 18:14         ` Marcel Holtmann
2005-01-21  8:26           ` David Woodhouse
2005-01-23  8:12             ` Marcel Holtmann
2005-01-23 11:39         ` Marcel Holtmann
2005-01-23 12:29           ` David Woodhouse
2005-01-23 14:40             ` Marcel Holtmann
2005-01-23 15:11               ` David Woodhouse
2005-01-23 15:22                 ` Marcel Holtmann
2005-01-23 23:16                   ` David Woodhouse
  -- strict thread matches above, loose matches on Subject: below --
2004-08-16  9:48 john smith
2004-08-16 10:15 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox