Env: VC++6.00

I wonder how to define a char[ ] with alignment restrictions?
For example, I hope the start address of a char[100] is with alignment
restrictions 256 bytes.


TIA
ou

Re: define a char[ ] with alignment restrictions by M

M
Thu Jul 17 01:39:35 CDT 2008

Check the reference for the Microsoft Specific "align" keyword to have
control on the data alignment - that might serve your purpose.
http://msdn.microsoft.com/en-us/library/83ythb65(VS.80).aspx

Regards,
Shoaib.

"ou" <ou07@ab.auone-net.jp> wrote in message
news:eY9%23%23b85IHA.1428@TK2MSFTNGP06.phx.gbl...
> Env: VC++6.00
>
> I wonder how to define a char[ ] with alignment restrictions?
> For example, I hope the start address of a char[100] is with alignment
> restrictions 256 bytes.
>
>
> TIA
> ou
>



Re: define a char[ ] with alignment restrictions by ou

ou
Thu Jul 17 01:40:39 CDT 2008

Thanks Shoaib.

I just try as follows,

#define CACHE_LINE 256
#define CACHE_ALIGN __declspec(align(CACHE_LINE))
CACHE_ALIGN int array[128];

But, IDE compiler reports a fatal error: C1600.

Does it supports with VC++6.00?

ou

> Check the reference for the Microsoft Specific "align" keyword to have
> control on the data alignment - that might serve your purpose.
> http://msdn.microsoft.com/en-us/library/83ythb65(VS.80).aspx


Re: define a char[ ] with alignment restrictions by Liviu

Liviu
Thu Jul 17 01:56:13 CDT 2008

OP said VC++ 6, and I don't think declspec(align) worked there.

P.S. Does anyone remember what /bzalign was for in the old ages?

"M. Shoaib Surya" <shoaibsurya@hotmail.com> wrote in message
news:Ocq8hC95IHA.1196@TK2MSFTNGP05.phx.gbl...
> Check the reference for the Microsoft Specific "align" keyword to have
> control on the data alignment - that might serve your purpose.
> http://msdn.microsoft.com/en-us/library/83ythb65(VS.80).aspx
>
> Regards,
> Shoaib.
>
> "ou" <ou07@ab.auone-net.jp> wrote in message
> news:eY9%23%23b85IHA.1428@TK2MSFTNGP06.phx.gbl...
>> Env: VC++6.00
>>
>> I wonder how to define a char[ ] with alignment restrictions?
>> For example, I hope the start address of a char[100] is with
>> alignment restrictions 256 bytes.
>>
>>
>> TIA
>> ou





Re: define a char[ ] with alignment restrictions by Tim

Tim
Fri Jul 18 00:52:35 CDT 2008

"ou" <ou07@ab.auone-net.jp> wrote:

>Thanks Shoaib.
>
>I just try as follows,
>
>#define CACHE_LINE 256

Cache lines are not 256 bytes.

>#define CACHE_ALIGN __declspec(align(CACHE_LINE))
>CACHE_ALIGN int array[128];
>
>But, IDE compiler reports a fatal error: C1600.
>
>Does it supports with VC++6.00?

No. To create a 100-byte character array with 256-byte alignment, you can
do it by hand:

char unaligned[100+256];
char * pAligned = (char *)((unsigned long)(unaligned + 255) & 255);
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Re: define a char[ ] with alignment restrictions by Ben

Ben
Sat Jul 26 22:20:57 CDT 2008



"Tim Roberts" <timr@probo.com> wrote in message
news:hob0845coj9pvmti3pavsdbm6a655teh22@4ax.com...
> "ou" <ou07@ab.auone-net.jp> wrote:
>
>>Thanks Shoaib.
>>
>>I just try as follows,
>>
>>#define CACHE_LINE 256
>
> Cache lines are not 256 bytes.
>
>>#define CACHE_ALIGN __declspec(align(CACHE_LINE))
>>CACHE_ALIGN int array[128];
>>
>>But, IDE compiler reports a fatal error: C1600.
>>
>>Does it supports with VC++6.00?
>
> No. To create a 100-byte character array with 256-byte alignment, you can
> do it by hand:
>
> char unaligned[100+256];
> char * pAligned = (char *)((unsigned long)(unaligned + 255) & 255);
should be "& ~255UL", else you get a pointer into the first 256 bytes of
virtual address space.
> --
> Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc.