On Tue, 18 Jan 2011 12:54:53 -0500 Michael Jerris <mike@jerris.com> wrote: In general, should I conclude that this issue has not been encountered before?
take a look at swith_types.h 645-710. This is what you would need to do cross platform to align stuff. If I understood you correctly, you mean to point out a general cross platform issue and how it is dealt with withing freeswitch code. Right? Just to complete the info, the ARM processor is running Little-Endian. The code/settings/dialplan worked fine on a x86 linux machine, also little endian. Probably nothing new, but I thought I should fill in the details.
I am surprised the first way isn't aligned already, the first proposed change wont be cross platform, the second, if that works, should be fine (as long as you free it later of course) but I am unsure if that will actually work cross platform. The trick here is to figure out how to fix it once for all platforms.
Mike
I expected that the original code would be aligned too. It just wasn't, atleast with gcc 4.3.3 + Code Sourcery enhancements. In gcc 4.4.5 ( I think, I don't have access to my development machine at the moment.) using the switch -falign-functions did align the buffer buf at a 32-bit boundary. Of course align-functions does not ensure that all uint8_t buffers would be aligned. Perhaps a conditional define would be more suitable fix, considering all platforms. As far as I can tell, the memory alignment requirement is ARM specific, which restricts this issue to gcc/linux. So in pseudo code #define ALIGN_ON_ARM ifdef GCC ifdef arm #undef ALIGN_ON_ARM #define ALIGN_ON_ARM __attribute__ (aligned(4)) #endif #endif and then in the source code uint8_t buf[260] ALIGN_ON_ARM = {0}; Would something along these lines work? The only issue is that it would touch a lot of the code. The use of structures with a uint8 buffer is likely widely used within freeswitch. -m
On Jan 18, 2011, at 12:35 PM, M D wrote:
Summary: Has anyone looked at/actively looking at the 32-bit boundary memory alignment requirement for the ARM architecture?