Re: "new byte[132]" alignment on 16 bytes
From: Willy Denoyette [MVP] (willy.denoyette_at_pandora.be)
Date: 11/08/04
- Next message: Zach: "Re: How to add a string to a big file in csharp !"
- Previous message: Shiva: "Re: How to use WebDAV to create an appointment in Exchange/outlook"
- In reply to: Olaf Baeyens: ""new byte[132]" alignment on 16 bytes"
- Next in thread: Olaf Baeyens: "Re: "new byte[132]" alignment on 16 bytes"
- Reply: Olaf Baeyens: "Re: "new byte[132]" alignment on 16 bytes"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 8 Nov 2004 13:32:46 +0100
What exactly do you mean with "C# to always align a....". C# doesn't align
anything. Byte arrays are allocated on the managed heap and this allocation
is done by the CLR, the application code cannot control the alignment nor
the location.
However, as your functions are unmanaged code and as such, you have to copy
the byte arrays to unmanaged memory anyway, no-one stops you from
implementing some form of custom marshalling.
Willy.
"Olaf Baeyens" <olaf.baeyens@skyscan.be> wrote in message
news:418f4198$0$32258$ba620e4c@news.skynet.be...
>I am porting some of my buffer class code for C++ to C#.
> This C++ class allocates a block of memory using
> m_pBuffer=new BYTE[...];
>
> But since the class is also used for pointers for funtions that uses raw
> MMX
> and SSE power, the starting pointer MUST be starting at a 16 byte memory
> boundary.
> In C++ I allocate more memory than needed, and in a second phase I search
> for the address that starts on a 16 byte boundary. And I then use that new
> memory address pointer.
>
> Is there a way to make C# to always align a "byte[] Buffer=new byte[132];"
> dynamically to a 16 byte memory address?
> [StructLayout(LayoutKind.???)] ???
>
> I am not talking about the location of &Buffer but about the location of
> &(new byte[132]).
> It would be nice if I could decide to make parts of my code aligned on 16
> bytes and the rest on normal 8 bytes or 32 byte depending on the need and
> not force all uses of Buffer to be alignend on 16 bytes..
>
> --
> http://www.skyscan.be
>
>
- Next message: Zach: "Re: How to add a string to a big file in csharp !"
- Previous message: Shiva: "Re: How to use WebDAV to create an appointment in Exchange/outlook"
- In reply to: Olaf Baeyens: ""new byte[132]" alignment on 16 bytes"
- Next in thread: Olaf Baeyens: "Re: "new byte[132]" alignment on 16 bytes"
- Reply: Olaf Baeyens: "Re: "new byte[132]" alignment on 16 bytes"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|