The lines beginning with * aren't C either <g>. You want void *realp ...

Also, your second and third lines combine pretty well into one.

Cpool *p = (Cpool *)((long)realp & -16));

No one ever said system programming in C was pretty.

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Steve Smith
Sent: Tuesday, July 17, 2018 11:44 AM
To: [email protected]
Subject: Re: S0C6 in CSRC4RG1

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. :)

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

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

Reply via email to