Re: __attribute__((packed)) ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 14 July 2004 12:48, amith wrote:
> Muli Ben-Yehuda wrote:
> >On Wed, Jul 14, 2004 at 03:50:06PM +0530, amith wrote:
> >>mine.c :3: warning:'packed' attribute ignored.
> >
> >It's a single pointer. What exactly is there for the compiler to pack?
> >
> >Cheers,
> >Muli
>
> hi there,
> u r observations are right .
> i was reading this FAQ on porting Linux applications to ARM. follows
> from http://www.arm.com/support/faqdev/1228.html
> ---------------------------------------------------------------------------
>--------------------------------------------------------------------- Thus
> if you wish to define a pointer to a word that can be at any
> address (i.e. that can be at a non-natural alignment) then you must
> specify this using the __packed qualifier when defining the pointer:
>
>    __packed int *pi; // pointer to unaligned int
> ---------------------------------------------------------------------------
>---------------------------------------------------------------------
>
> later i learnt that __packed is recognised by armcc compiler , i tried
> using arm-linux-gcc , with __attribute__(packed)), assuming both do the
> same.
> Could someone point out the gcc equivalent of __pack , i feel it doesnt
> make sense using __attribute__((packed)) on void **ptr.

Hi there,

I don't know if i'm correct but packed means that the variable whose attribute 
is being set to packed should be "packed" :) as close as possible ("should 
have the smallest possible alignment" - from Using GCC) to a preceding 
variable. Here's the example from the docs that might bring more clarity to 
the situation:

struct foo {
	char a;
	int x[2] __attribute__ ((packed));
};

so the field x immediately follows a.

Regards,
Boris.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA9RQdiBySr3Fn37QRAuxDAJ9kT0C/Ry0iS7TtXEaPA07UwlQkqwCcCMyd
kRK3qrD3L4GmbnJTQ/sp+g4=
=887u
-----END PGP SIGNATURE-----

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux