Add macros for perl stack manipulation
FossilOrigin-Name: b6526e43663896b8e12ffeeec48bdc4ef940fcf73d5c6a8f1a593b9bdb9f9ba8
This commit is contained in:
parent
9917ac981e
commit
cbeba98890
2 changed files with 22 additions and 15 deletions
|
@ -28,6 +28,24 @@
|
|||
#define hvstores_ref(hv, key, val) hv_stores((hv), key, \
|
||||
((val) ? newRV_inc((SV* const)(val)) : &PL_sv_undef))
|
||||
|
||||
/* Seeing all this shit littered in Treebird's code made me decide to write some macros */
|
||||
#define PERL_STACK_INIT perl_lock(); \
|
||||
dSP; \
|
||||
ENTER; \
|
||||
SAVETMPS; \
|
||||
PUSHMARK(SP)
|
||||
|
||||
#define PERL_STACK_SCALAR_CALL(name) PUTBACK; \
|
||||
call_pv((name), G_SCALAR); \
|
||||
SPAGAIN
|
||||
|
||||
/* you MUST assign scalar from savesharedsvpv, then free when done */
|
||||
#define PERL_GET_STACK_EXIT savesharedsvpv(POPs); \
|
||||
PUTBACK; \
|
||||
FREETMPS; \
|
||||
LEAVE; \
|
||||
perl_unlock()
|
||||
|
||||
extern PerlInterpreter* my_perl;
|
||||
extern HV* template_files;
|
||||
extern pthread_mutex_t perllock_mutex;
|
||||
|
|
19
src/status.c
19
src/status.c
|
@ -941,11 +941,8 @@ void content_status(PATH_ARGS, uint8_t flags)
|
|||
&statuses_before, &statuses_after,
|
||||
&stat_before_len, &stat_after_len);
|
||||
|
||||
perl_lock();
|
||||
dSP;
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(SP);
|
||||
|
||||
PERL_STACK_INIT;
|
||||
HV* session_hv = perlify_session(ssn);
|
||||
XPUSHs(newRV_noinc((SV*)session_hv));
|
||||
XPUSHs(newRV_noinc((SV*)template_files));
|
||||
|
@ -959,18 +956,10 @@ void content_status(PATH_ARGS, uint8_t flags)
|
|||
XPUSHs(newRV_noinc((SV*)perlify_statuses(statuses_after, stat_after_len)));
|
||||
else
|
||||
ARG_UNDEFINED();
|
||||
// ARGS
|
||||
PUTBACK;
|
||||
call_pv("status::content_status", G_SCALAR);
|
||||
SPAGAIN;
|
||||
|
||||
// Duplicate so we can free the TMPs
|
||||
char* dup = savesharedsvpv(POPs);
|
||||
PERL_STACK_SCALAR_CALL("status::content_status");
|
||||
|
||||
PUTBACK;
|
||||
FREETMPS;
|
||||
LEAVE;
|
||||
perl_unlock();
|
||||
char* dup = PERL_GET_STACK_EXIT;
|
||||
|
||||
struct base_page b = {
|
||||
.category = BASE_CAT_NONE,
|
||||
|
|
Loading…
Reference in a new issue