memory-alignment

Why does this EXC_BAD_ACCESS happen with long long and not with int?

I've run into a EXC_BAD_ACCESS with a piece of code that deals with data serialization. The code only fails on device (iPhone) and not on simulator. It also fails only on certain data types. Here is a test code that reproduces the problem: template <typename T> void test_alignment() { // allocate memory and record the original addr...

Does VC++ support _mm_malloc ?

Does Visual Studio C++ 2008/2010 support _mm_malloc officially? It is defined in malloc.h but I can't find its description in the MSDN library. ...

Memory alignment

Hi, I have understood why memory should be aligned to 4 byte and 8 byte based on data width of the bus. But following statement confuses me "IoDrive requires that all I/O performed on a device using O_DIRECT must be 512-byte alligned and a multiple of 512 bytes in size." What is the need for aligning address to 512 bytes. ...

MIPS memcpy issue (i think)

I have some software that I have working on a redhat system with icc and it is working fine. When I ported the code to an IRIX system running with MIPS then I get some calculations that come out as "nan" when there should definitely be values there. I dont have any good debuggers on the non-redhat system, but I have tracked down that so...

How to make tr1::array allocate aligned memory?

You can allocate a std::vector which allocates aligned heap memory by defining your own allocator. You can allocate a c-style array on the stack using declspec align. But can you declare a tr1::array which guarantees that the element at index zero will be aligned? ...

__attribute__((aligned)) - gcc

Hello How will gcc set the alignment for variable/field with __attribute__((aligned)) What about different gcc versions/ different platforms? Testing code: int main() { printf("%d\n", (__alignof__(char __attribute__ ((aligned)) )) ); } For x86, gcc 3.4, 4.1, 4.3 I got 16. ...

Why does a struct consisting of a char, short, and char (in that order), when compiled in C++ with 4-byte packing enabled, come to a 6-byte struct?

I thought I understood how C/C++ handled struct member alignment. But I'm getting strange results for a particular arrangement in Visual Studio 2008 and 2010. Specifically, I'm finding that a struct consisting of a char, short, and char is compiled into a 6-byte struct, even with 4- or 8-byte packing enabled. I am at a loss as to why th...

How to determine if address is word aligned

Can you tell by looking at them which of these addresses is word aligned? 0x000AE430 0X00014432 0X000B0737 0X0E0D8844 ...

Array size optimization

Is there any advantage defining an array's size to be a multiple of 8, if using 64 bit UNIX OS? I am intended to use this array for loading data from shared memory. So dependencies may exist on the operating system and the page size. ...