Ugh indeed.  Me C is getting rusty.

void* realp = malloc(1408 + 15);
long ip = (long)realp & -16;
Cpool* p = (CPool*)ip;

sas

On Tue, Jul 17, 2018 at 2:44 PM, Steve Smith <[email protected]> wrote:

> In assembler, STORAGE provides a BNDRY= keyword, which would be fine, but
> this is a Metal C program.  malloc provides no such thing.  Don's
> suggestion is doable, but it's fugly C code, and amounts to doing vascular
> surgery wearing oven mitts:
>
> *void realp = malloc(1408 + 15);
> long ip = (long)realp & -16;
> *Cpool p = (*CPool)ip;
>
> Yeah, that's clear to anyone.  Although I'm sure it could be obfuscated.
> Note: If you think the 1st & 3rd lines are commented out, this thread is
> not for you :-)
>
> Problems:
> 1. Undocumented requirement to quad-word align CPOOL anchor and/or extent
> in 64-bit mode (and actually undocumented alignment requirements for all).
> 2. Unable to guarantee quad-word alignment with malloc.
>
> Ugh.
> sas
>
>
> On Tue, Jul 17, 2018 at 1:41 PM, Don Poitras <[email protected]> wrote:
>
>> Add 15 bytes to whatever length you are asking for and copy the
>> pointer. 'And' the last nibble to 0. Voila! quad-aligned pointer. :)
>
>
>


-- 
sas

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to