--- Convert-UUlib/UUlib.xs 2015/07/10 01:17:08 1.16 +++ Convert-UUlib/UUlib.xs 2020/02/28 06:57:25 1.17 @@ -2,10 +2,20 @@ #include "perl.h" #include "XSUB.h" +#include "perlmulticore.h" + #include "uulib/fptools.h" #include "uulib/uudeview.h" #include "uulib/uuint.h" +static int released; + +#define RELEASE do { released = 1; perlinterp_release (); } while (0) +#define ACQUIRE do { perlinterp_acquire (); released = 0; } while (0) + +#define TEMP_ACQUIRE if (released) perlinterp_acquire (); +#define TEMP_RELEASE if (released) perlinterp_release (); + static int not_here (char *s) { @@ -100,6 +110,8 @@ static void uu_msg_callback (void *cb, char *msg, int level) { + TEMP_ACQUIRE { + dSP; ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); @@ -109,14 +121,19 @@ PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN; PUTBACK; FREETMPS; LEAVE; + + } TEMP_RELEASE; } static int uu_busy_callback (void *cb, uuprogress *uup) { + int retval; + + TEMP_ACQUIRE { + dSP; int count; - int retval; ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); @@ -136,15 +153,20 @@ PUTBACK; FREETMPS; LEAVE; + } TEMP_RELEASE; + return retval; } static char * uu_fnamefilter_callback (void *cb, char *fname) { + static char *str; + + TEMP_ACQUIRE { + dSP; int count; - static char *str; ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); @@ -159,15 +181,20 @@ PUTBACK; FREETMPS; LEAVE; + } TEMP_RELEASE; + return str; } static int uu_file_callback (void *cb, char *id, char *fname, int retrieve) { + int retval; + + TEMP_ACQUIRE { + dSP; int count; - int retval; SV *xfname = newSVpv ("", 0); ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); @@ -186,12 +213,16 @@ PUTBACK; FREETMPS; LEAVE; + } TEMP_RELEASE; + return retval; } static char * uu_filename_callback (void *cb, char *subject, char *filename) { + TEMP_ACQUIRE { + dSP; int count; @@ -216,6 +247,8 @@ PUTBACK; FREETMPS; LEAVE; + } TEMP_RELEASE; + return filename; } @@ -226,9 +259,12 @@ static int uu_info_file (void *cb, char *info) { + int retval; + + TEMP_ACQUIRE { + dSP; int count; - int retval; ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); @@ -243,6 +279,8 @@ PUTBACK; FREETMPS; LEAVE; + } TEMP_RELEASE; + return retval; } @@ -378,8 +416,13 @@ PPCODE: { int count; + IV ret; + + RELEASE; + ret = UULoadFileWithPartNo (fname, id, delflag, partno, &count); + ACQUIRE; - XPUSHs (sv_2mortal (newSViv (UULoadFileWithPartNo (fname, id, delflag, partno, &count)))); + XPUSHs (sv_2mortal (newSViv (ret))); if (GIMME_V == G_ARRAY) XPUSHs (sv_2mortal (newSViv (count))); } @@ -483,7 +526,9 @@ decode_temp (item) uulist *item CODE: + RELEASE; RETVAL = UUDecodeToTemp (item); + ACQUIRE; OUTPUT: RETVAL @@ -491,7 +536,9 @@ remove_temp (item) uulist *item CODE: + RELEASE; RETVAL = UURemoveTemp (item); + ACQUIRE; OUTPUT: RETVAL @@ -500,7 +547,9 @@ uulist *item char * target CODE: + RELEASE; RETVAL = UUDecodeFile (item, target); + ACQUIRE; OUTPUT: RETVAL @@ -509,7 +558,9 @@ uulist *item SV * func CODE: - UUInfoFile (item,(void *)func, uu_info_file); + RELEASE; + UUInfoFile (item, (void *)func, uu_info_file); + ACQUIRE; short state(li)