It's always best to get storage on the stack and avoid the heap if you
can. z/OS C/C++ supports the GCC extensions that allow you to align
storage using
variable attributes.
char buffer[1408] __attribute__((__aligned__(16))) ; // only works in
64-bit
On 18/07/2018 2:44 AM, Steve Smith 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. :)
----------------------------------------------------------------------
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