On Jan 18, 2011, at 2:42 PM, M D wrote:
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?
This has certainly been encountered before, on different platforms, including arm. I suspect this is a toolchain issue more than anything in this case as we have worked on arm for quite some time.
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.
the trick is to fix it in the way that fixes it for the most things all at once.
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.
Is there a gcc arg that will make this work? If so we can test for that being available and use it when it is.
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.
I would much rather not litter the code with a ton of garbage like this, there should be a way to tell the compiler how we want alignment to work either with a single ifdef in a header, or with a compiler arg.
-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?