Re: [RFC v2] Documentation about unaligned memory access

2007-12-05 Thread Jan Kara
A minor typo: ... > Avoiding unaligned accesses > === > > The easiest way to avoid unaligned access is to use the get_unaligned() and > put_unaligned() macros provided by the header file. > > Going back to an earlier example of code that potentially causes unaligned

Re: [RFC v2] Documentation about unaligned memory access

2007-12-05 Thread Jan Kara
A minor typo: ... Avoiding unaligned accesses === The easiest way to avoid unaligned access is to use the get_unaligned() and put_unaligned() macros provided by the asm/unaligned.h header file. Going back to an earlier example of code that potentially causes

Re: [RFC v2] Documentation about unaligned memory access

2007-12-03 Thread Johannes Berg
> void myfunc(u8 *data, u32 value) > { > [...] > value = cpu_to_le32(value); > put_unaligned(value, data); > u32 value = get_unaligned(data); Actually, this is wrong. put_unaligned and get_unaligned use the type of the "data" pointer,

Re: [RFC v2] Documentation about unaligned memory access

2007-12-03 Thread Johannes Berg
void myfunc(u8 *data, u32 value) { [...] value = cpu_to_le32(value); put_unaligned(value, data); u32 value = get_unaligned(data); Actually, this is wrong. put_unaligned and get_unaligned use the type of the data pointer, e.g. on

Re: [RFC v2] Documentation about unaligned memory access

2007-11-29 Thread DM
On Nov 29, 2007 5:15 PM, Daniel Drake <[EMAIL PROTECTED]> wrote: [...] > To avoid the unaligned memory access, you would rewrite it as follows: > >void myfunc(u8 *data, u32 value) >{ >[...] >value = cpu_to_le32(value); >

Re: [RFC v2] Documentation about unaligned memory access

2007-11-29 Thread Jan Engelhardt
On Nov 29 2007 12:04, Kyle McMartin wrote: > >For example, if you had 4GB of virtual memory, picture it as an >array of bytes, > u8 memory[4096 * (1024 * 1024)];/* 4G bytes */ uint8_t memory[4096UL * 1024 * 1024]; >Aligned accesses would be accessing this array in this manner, >

Re: [RFC v2] Documentation about unaligned memory access

2007-11-29 Thread Randy Dunlap
On Thu, 29 Nov 2007 16:15:23 + (GMT) Daniel Drake wrote: > Assuming there aren't too many comments/suggestions on this revision, the > next version will be submitted for inclusion as > Documentation/unaligned_memory_access.txt I just have a few typo/punctuation/grammar fixes. Otherwise it

Re: [RFC v2] Documentation about unaligned memory access

2007-11-29 Thread Kyle McMartin
Hi Daniel, On Thu, Nov 29, 2007 at 04:15:23PM +, Daniel Drake wrote: > Unaligned memory accesses occur when you try to read N bytes of data starting > from an address that is not evenly divisible by N (i.e. addr % N != 0). > For example, reading 4 bytes of data from address 0x10004 is fine,

[RFC v2] Documentation about unaligned memory access

2007-11-29 Thread Daniel Drake
New version of the unaligned access document I posted recently. Thanks for all the feedback, I've learned a lot! Changes: - 'in between' spelling fix - shortened example addresses for readability - better summarised the common architectural differences in handling unaligned access under "Why

[RFC v2] Documentation about unaligned memory access

2007-11-29 Thread Daniel Drake
New version of the unaligned access document I posted recently. Thanks for all the feedback, I've learned a lot! Changes: - 'in between' spelling fix - shortened example addresses for readability - better summarised the common architectural differences in handling unaligned access under Why

Re: [RFC v2] Documentation about unaligned memory access

2007-11-29 Thread Kyle McMartin
Hi Daniel, On Thu, Nov 29, 2007 at 04:15:23PM +, Daniel Drake wrote: Unaligned memory accesses occur when you try to read N bytes of data starting from an address that is not evenly divisible by N (i.e. addr % N != 0). For example, reading 4 bytes of data from address 0x10004 is fine, but

Re: [RFC v2] Documentation about unaligned memory access

2007-11-29 Thread Randy Dunlap
On Thu, 29 Nov 2007 16:15:23 + (GMT) Daniel Drake wrote: Assuming there aren't too many comments/suggestions on this revision, the next version will be submitted for inclusion as Documentation/unaligned_memory_access.txt I just have a few typo/punctuation/grammar fixes. Otherwise it

Re: [RFC v2] Documentation about unaligned memory access

2007-11-29 Thread Jan Engelhardt
On Nov 29 2007 12:04, Kyle McMartin wrote: For example, if you had 4GB of virtual memory, picture it as an array of bytes, u8 memory[4096 * (1024 * 1024)];/* 4G bytes */ uint8_t memory[4096UL * 1024 * 1024]; Aligned accesses would be accessing this array in this manner,

Re: [RFC v2] Documentation about unaligned memory access

2007-11-29 Thread DM
On Nov 29, 2007 5:15 PM, Daniel Drake [EMAIL PROTECTED] wrote: [...] To avoid the unaligned memory access, you would rewrite it as follows: void myfunc(u8 *data, u32 value) { [...] value = cpu_to_le32(value); put_unaligned(value,