typedef unsigned int PLI_PTR;
#define PLI_PTR_TO_C_PTR(p) (void *) ((p) == 0xFF000000 ? 0 : (p) &
0x7FFFFFFF)
usage example:
int func (PLI_PTR a, PLI_PTR b)
{
some_type *parm1 = PLI_PTR_TO_C_PTR (a);
another_type *parm2 = PLI_PTR_TO_C_PTR (b);
if (parm1 == NULL)
...
}
func in this example is an external function called from PL/1 that gets
two pointers BYVALUE that could be NULL() - or scalar types by reference -
and may have the high order bit set. The macro PLI_PTR_TO_C_PTR
translates the PL/1 NULL() pattern to the C constant NULL
and - otherwise - switches the high order bit off.
Should work; I didn't test it.
If the expression is not allowed as an initializer (I'm not sure at the
moment),
definition and initialization have to be separated.
Kind regards
Bernd
Am 01.04.2014 16:24, schrieb John Gilmore:
Implementation dependencies are in general undesirable, but
inter-language linkages of the kind being talked about here are always
and ineluctably doubly implementation-dependent.
Consider now the PL/I statements
declare pbs32_sysnull_image
static aligned bit(32) initial('00000000'b4) ;
declare p pointer,
pbs32 aligned bit(32) based(addr(p)),
addr builtin ;
pbs32 = pbs32_sysnull_image ;
This kind of brutal data-type punning, common in assembly language, is
anathema to little old ladies of both sexes in statement-level
languages. It nevertheless has its uses; it is direct and efficient,
and, whether written in C or PL/I, it will not be optimized away.
John Gilmore, Ashland, MA 01721 - USA
----------------------------------------------------------------------
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