Hi Nick,
thanx for your help. This code is really more clear than the one I was about to
used.
But I've a compiling error from the autogenerate procsinfo.c
Would be great if you could give me a hand with it
thanx :)
"procsinfo.c", line 32.28: 1506-117 (S) Operand must be a scalar type.
### ==> cat procsinfo.xs
#include <procinfo.h>
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#define my_pi_pid(proc) ((IV)proc.pi_pid)
MODULE = AIX::Procinfo::procsinfo PACKAGE = AIX::Procinfo::procsinfo PREFIX =
my_
IV pi_pid(struct procsinfo proc)
### ==> cat procsinfo.c
/*
* This file was generated automatically by xsubpp version 1.9508 from the
* contents of procsinfo.xs. Do not edit this file, edit procsinfo.xs instead.
*
* ANY CHANGES MADE HERE WILL BE LOST!
*
*/
#line 1 "procsinfo.xs"
#include <procinfo.h>
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#define my_pi_pid(proc) ((IV)proc.pi_pid)
#line 19 "procsinfo.c"
XS(XS_AIX__Procinfo__procsinfo_pi_pid); /* prototype to pass
-Wmissing-prototypes */
XS(XS_AIX__Procinfo__procsinfo_pi_pid)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: AIX::Procinfo::procsinfo::pi_pid(proc)");
{
IV RETVAL;
dXSTARG;
struct procsinfo proc;
if (sv_derived_from(ST(0), "struct procsinfo")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
proc = INT2PTR(struct procsinfo,tmp);
}
else
Perl_croak(aTHX_ "proc is not of type struct procsinfo");
RETVAL = pi_pid(proc);
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
#ifdef __cplusplus
extern "C"
#endif
XS(boot_AIX__Procinfo__procsinfo); /* prototype to pass -Wmissing-prototypes */
XS(boot_AIX__Procinfo__procsinfo)
{
dXSARGS;
char* file = __FILE__;
XS_VERSION_BOOTCHECK ;
newXS("AIX::Procinfo::procsinfo::pi_pid",
XS_AIX__Procinfo__procsinfo_pi_pid, file);
XSRETURN_YES;
}
Post by Yannick BergeronPost by Yannick BergeronI'm trying to write a module for an AIX structure named procinfo. This
structure
Post by Yannick Bergeronis different if we run AIX with a 32bit kernel or with a 64bit kernel
the xs parser doesn't seem to like ifdef. How can I declarer the same
subroutine
Post by Yannick Bergeronfor 32 bits and 64 bits?
I suspect it isn't only the #if that is the problem but the blank line(s).
xsubpp processes things in "paragraphs".
#ifdef is ok in the C part (before the MODULE line)
-------------------------------
static IV my_pi_pid(struct procsinfo proc)
{
#ifdef __64BIT__
return (IV) proc.pi_pid;
#else
return (IV) proc.pi_pid;
#endif
}
MODULE AIX::Procinfo::procsinfo PACKAGE = AIX::Procinfo::procsinfo PREFIX = my_
IV pi_pid(struct procsinfo proc)
-------------------------------
That said as the only difference is the return type, and both are
presumably going to end up as an IV anyway
-------------------------------
#define my_pi_pid(proc) ((IV)proc.pi_pid)
MODULE AIX::Procinfo::procsinfo PACKAGE = AIX::Procinfo::procsinfo PREFIX = my_
IV pi_pid(struct procsinfo proc)
-------------------------------
Should suffice.
Post by Yannick Bergeron#include <procinfo.h>
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
MODULE = AIX::Procinfo::procsinfo PACKAGE = AIX::Procinfo::procsinfo
#ifdef __64BIT__
pid_t
pi_pid(struct procsinfo proc)
/* process ID */
RETVAL = proc.pi_pid;
RETVAL
#else /* __64BIT__ */
unsigned long
pi_pid(struct procsinfo proc)
/* process ID */
RETVAL = proc.pi_pid;
RETVAL
#endif /* __64BIT__ */