Hey folks.
I'm working on a module that wants to know whether it's being run
interactively, so I'm checking JPI$_MODE in a call to sys$getjpiw().
Here's a test file: I think it's short enough to post:
==============(beginning of jpitest.xs)=====================
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <starlet.h>
#include <jpidef.h>
#pragma __member_alignment __save
typedef struct _ile3
{
#pragma __nomember_alignment
unsigned short int
ile3$w_length,
ile3$w_code;
void
*ile3$ps_bufaddr;
unsigned short int
*ile3$ps_retlen_addr;
} ile3;
typedef struct _quadword { int lo, hi; } quadword;
#pragma __member_alignment __restore
MODULE = jpitest PACKAGE = jpitest
void
test1()
PREINIT:
quadword iosb;
ile3 itmlst[2];
long mode;
int status;
CODE:
itmlst[0].ile3$w_code = JPI$_MODE;
itmlst[0].ile3$w_length = sizeof(mode);
itmlst[0].ile3$ps_bufaddr = &mode;
itmlst[0].ile3$ps_retlen_addr = 0;
memset(&itmlst[1], 0, sizeof(ile3));
status = sys$getjpiw(0, 0, 0, itmlst, &iosb, 0, 0);
printf ("status = %%X%08X mode = %d\n", status, mode);
==================(end of jpitest.xs)==========================
With a test.pl that just calls jpitest::test1(), I get this output:
status = %X00000001 mode = 0
But 0 is JPI$K_OTHER, what I should really be getting is 3, which is
JPI$K_INTERACTIVE. Changing this XS code into plain C, where test1()
becomes main() and running it gives me the results I expect:
status = %X00000001 mode = 3
This is with Perl 5.6.0 on OpenVMS Alpha V7.3.
What the heck's going on here?
| Forrest Cahoon | [EMAIL PROTECTED] |------------------------------|
| 850 21st Ave SE |----------------------| Only unbalanced people |
| Mpls MN 55414-2514 | | can tip the scales... |