Skip to content
This repository has been archived by the owner on Aug 6, 2019. It is now read-only.

Commit

Permalink
rework perl extensions to correctly use OUTPUT/RETVAL
Browse files Browse the repository at this point in the history
  • Loading branch information
postwait committed Jan 24, 2013
1 parent 4af465b commit 1fbd874
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
34 changes: 18 additions & 16 deletions usr/src/cmd/perl/contrib/Sun/Solaris/Privilege/Privilege.xs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
#define IVCONST(s, c) newCONSTSUB(s, #c, newSViv((int)(intptr_t)c));
#define POFF (sizeof ("PRIV_") - 1)

#define RETPRIVSET(set) \
ST(0) = sv_newmortal(); \
sv_setref_pv(ST(0), "Sun::Solaris::Privilege::PrivsetPtr", \
(void*)(set)); \
SvREADONLY_on(SvRV(ST(0)))

typedef int sysret;

typedef priv_set_t Sun__Solaris__Privilege__Privset;
Expand Down Expand Up @@ -125,11 +119,11 @@ CODE:
if (getppriv(which, RETVAL) != 0) {
priv_freeset(RETVAL);
XSRETURN_UNDEF;
} else {
RETPRIVSET(RETVAL);
}
OUTPUT:
RETVAL
CLEANUP:
SvREADONLY_on(SvRV(ST(0)));

sysret
setppriv(op, which, set)
Expand All @@ -145,9 +139,10 @@ CODE:
XSRETURN_UNDEF;
}
priv_emptyset(RETVAL);
RETPRIVSET(RETVAL);
OUTPUT:
RETVAL
CLEANUP:
SvREADONLY_on(SvRV(ST(0)));

Sun::Solaris::Privilege::Privset *
priv_fillset()
Expand All @@ -157,9 +152,10 @@ CODE:
XSRETURN_UNDEF;
}
priv_fillset(RETVAL);
RETPRIVSET(RETVAL);
OUTPUT:
RETVAL
CLEANUP:
SvREADONLY_on(SvRV(ST(0)));

boolean_t
priv_isemptyset(set)
Expand Down Expand Up @@ -198,9 +194,10 @@ CODE:
XSRETURN_UNDEF;
}
priv_intersect(set1, RETVAL);
RETPRIVSET(RETVAL);
OUTPUT:
RETVAL
CLEANUP:
SvREADONLY_on(SvRV(ST(0)));

Sun::Solaris::Privilege::Privset *
priv_union(set1, set2)
Expand All @@ -212,9 +209,10 @@ CODE:
XSRETURN_UNDEF;
}
priv_union(set1, RETVAL);
RETPRIVSET(RETVAL);
OUTPUT:
RETVAL
CLEANUP:
SvREADONLY_on(SvRV(ST(0)));

Sun::Solaris::Privilege::Privset *
priv_inverse(set1)
Expand All @@ -225,9 +223,10 @@ CODE:
XSRETURN_UNDEF;
}
priv_inverse(RETVAL);
RETPRIVSET(RETVAL);
OUTPUT:
RETVAL
CLEANUP:
SvREADONLY_on(SvRV(ST(0)));


sysret
Expand All @@ -243,9 +242,10 @@ CODE:
if (RETVAL == NULL) {
XSRETURN_UNDEF;
}
RETPRIVSET(RETVAL);
OUTPUT:
RETVAL
CLEANUP:
SvREADONLY_on(SvRV(ST(0)));


sysret
Expand Down Expand Up @@ -278,9 +278,10 @@ CODE:
if (RETVAL == NULL) {
XSRETURN_UNDEF;
}
RETPRIVSET(RETVAL);
OUTPUT:
RETVAL
CLEANUP:
SvREADONLY_on(SvRV(ST(0)));

char *
priv_gettext(priv)
Expand All @@ -303,5 +304,6 @@ void
Privilege_DESTROY(ps)
Sun::Solaris::Privilege::Privset *ps;
CODE:
priv_freeset(ps);
if (ps != NULL)
priv_freeset(ps);

17 changes: 4 additions & 13 deletions usr/src/cmd/perl/contrib/Sun/Solaris/Ucred/Ucred.xs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ dupset(const priv_set_t *s)
return (new);
}

#define RETPRIVSET(set) \
ST(0) = sv_newmortal(); \
sv_setref_pv(ST(0), "Sun::Solaris::Privilege::PrivsetPtr", \
(void*)(set)); \
SvREADONLY_on(SvRV(ST(0)))

#define RETUCRED(uc) \
ST(0) = sv_newmortal(); \
sv_setref_pv(ST(0), "Sun::Solaris::Ucred::UcredPtr", \
(void*)(uc)); \
SvREADONLY_on(SvRV(ST(0)))
/*
* The XS code exported to perl is below here. Note that the XS preprocessor
* has its own commenting syntax, so all comments from this point on are in
Expand Down Expand Up @@ -111,9 +100,10 @@ CODE:
val = ucred_getprivset(uc, which);
if (val == NULL || (RETVAL = dupset(val)) == NULL)
XSRETURN_UNDEF;
RETPRIVSET(RETVAL);
OUTPUT:
RETVAL
CLEANUP:
SvREADONLY_on(SvRV(ST(0)));

Sun::Solaris::Ucred::Ucred *
getpeerucred(fd)
Expand All @@ -122,9 +112,10 @@ CODE:
RETVAL = NULL;
if (getpeerucred(fd, &RETVAL) != 0)
XSRETURN_UNDEF;
RETUCRED(RETVAL);
OUTPUT:
RETVAL
CLEANUP:
SvREADONLY_on(SvRV(ST(0)));

void
ucred_getgroups(uc)
Expand Down

0 comments on commit 1fbd874

Please sign in to comment.