From: Dave Mitchell Date: Tue, 25 Sep 2007 18:00:32 +0000 (+0000) Subject: make PERL_SYS_INIT/INIT3/TERM into functions X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cbec8ebe2f7855c619451e56c6921e1537d3eba5;p=p5sagit%2Fp5-mst-13.2.git make PERL_SYS_INIT/INIT3/TERM into functions p4raw-id: //depot/perl@31970 --- diff --git a/dosish.h b/dosish.h index 35ed99d..c7a780c 100644 --- a/dosish.h +++ b/dosish.h @@ -16,7 +16,7 @@ #ifdef DJGPP # define BIT_BUCKET "nul" # define OP_BINARY O_BINARY -# define PERL_SYS_INIT(c,v) \ +# define PERL_SYS_INIT_BODY(c,v) \ MALLOC_CHECK_TAINT2(*c,*v) Perl_DJGPP_init(c,v); PERLIO_INIT # define init_os_extras Perl_init_os_extras # define HAS_UTIME @@ -29,25 +29,25 @@ # define PERL_FS_VER_FMT "%d_%d_%d" #else /* DJGPP */ # ifdef WIN32 -# define PERL_SYS_INIT(c,v) \ +# define PERL_SYS_INIT_BODY(c,v) \ MALLOC_CHECK_TAINT2(*c,*v) Perl_win32_init(c,v); PERLIO_INIT -# define PERL_SYS_TERM() Perl_win32_term() +# define PERL_SYS_TERM_BODY() Perl_win32_term() # define BIT_BUCKET "nul" # else # ifdef NETWARE -# define PERL_SYS_INIT(c,v) \ +# define PERL_SYS_INIT_BODY(c,v) \ MALLOC_CHECK_TAINT2(*c,*v) Perl_nw5_init(c,v); PERLIO_INIT # define BIT_BUCKET "nwnul" # else -# define PERL_SYS_INIT(c,v) \ +# define PERL_SYS_INIT_BODY(c,v) \ MALLOC_CHECK_TAINT2(*c,*v); PERLIO_INIT # define BIT_BUCKET "\\dev\\nul" /* "wanna be like, umm, Newlined, or somethin?" */ # endif /* NETWARE */ # endif #endif /* DJGPP */ -#ifndef PERL_SYS_TERM -# define PERL_SYS_TERM() HINTS_REFCNT_TERM; OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM +#ifndef PERL_SYS_TERM_BODY +# define PERL_SYS_TERM_BODY() HINTS_REFCNT_TERM; OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM #endif #define dXSUB_SYS diff --git a/embed.fnc b/embed.fnc index bd86a1f..c12ca2a 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1890,6 +1890,10 @@ sd |AV* |mro_get_linear_isa_dfs|NN HV* stash|I32 level pd |void |mro_isa_changed_in|NN HV* stash Apd |void |mro_method_changed_in |NN HV* stash p |void |boot_core_mro +Apon |void |sys_init |NN int* argc|NN char*** argv +Apon |void |sys_init3 |NN int* argc|NN char*** argv|NN char*** env +Apo |void |sys_term + END_EXTERN_C /* diff --git a/epoc/epocish.h b/epoc/epocish.h index 34121ef..bd364ec 100644 --- a/epoc/epocish.h +++ b/epoc/epocish.h @@ -107,14 +107,14 @@ /* epocemx setenv bug workaround */ -#ifndef PERL_SYS_INIT -# define PERL_SYS_INIT(c,v) \ +#ifndef PERL_SYS_INIT_BODY +# define PERL_SYS_INIT_BODY(c,v) \ MALLOC_CHECK_TAINT2(*c,*v) putenv(".dummy=foo"); putenv(".dummy"); \ PERLIO_INIT; MALLOC_INIT #endif -#ifndef PERL_SYS_TERM -#define PERL_SYS_TERM() PERLIO_TERM; MALLOC_TERM +#ifndef PERL_SYS_TERM_BODY +#define PERL_SYS_TERM_BODY() PERLIO_TERM; MALLOC_TERM #endif #define BIT_BUCKET "/dev/null" diff --git a/global.sym b/global.sym index a260a86..39cdaf2 100644 --- a/global.sym +++ b/global.sym @@ -763,4 +763,7 @@ Perl_emulate_cop_io Perl_get_re_arg Perl_mro_get_linear_isa Perl_mro_method_changed_in +Perl_sys_init +Perl_sys_init3 +Perl_sys_term # ex: set ro: diff --git a/mpeix/mpeixish.h b/mpeix/mpeixish.h index 8364720..f4ce38e 100644 --- a/mpeix/mpeixish.h +++ b/mpeix/mpeixish.h @@ -110,12 +110,12 @@ #define Fflush(fp) fflush(fp) #define Mkdir(path,mode) mkdir((path),(mode)) -#ifndef PERL_SYS_INIT -# define PERL_SYS_INIT(c,v) PERL_FPU_INIT; PERLIO_INIT; MALLOC_INIT +#ifndef PERL_SYS_INIT_BODY +# define PERL_SYS_INIT_BODY(c,v) PERL_FPU_INIT; PERLIO_INIT; MALLOC_INIT #endif -#ifndef PERL_SYS_TERM -#define PERL_SYS_TERM() PERLIO_TERM; MALLOC_TERM +#ifndef PERL_SYS_TERM_BODY +#define PERL_SYS_TERM_BODY() PERLIO_TERM; MALLOC_TERM #endif #define BIT_BUCKET "/dev/null" diff --git a/os2/os2ish.h b/os2/os2ish.h index a4b972f..a1072a3 100644 --- a/os2/os2ish.h +++ b/os2/os2ish.h @@ -223,7 +223,7 @@ void Perl_OS2_term(void **excH, int exitstatus, int flags); /* These ones should be in the same block as PERL_SYS_TERM() */ #ifdef PERL_CORE -# define PERL_SYS_INIT3(argcp, argvp, envp) \ +# define PERL_SYS_INIT3_BODY(argcp, argvp, envp) \ { void *xreg[2]; \ MALLOC_CHECK_TAINT(*argcp, *argvp, *envp) \ _response(argcp, argvp); \ @@ -231,7 +231,7 @@ void Perl_OS2_term(void **excH, int exitstatus, int flags); Perl_OS2_init3(*envp, xreg, 0); \ PERLIO_INIT -# define PERL_SYS_INIT(argcp, argvp) { \ +# define PERL_SYS_INIT_BODY(argcp, argvp) { \ { void *xreg[2]; \ _response(argcp, argvp); \ _wildcard(argcp, argvp); \ @@ -240,11 +240,11 @@ void Perl_OS2_term(void **excH, int exitstatus, int flags); #else /* Compiling embedded Perl or Perl extension */ -# define PERL_SYS_INIT3(argcp, argvp, envp) \ +# define PERL_SYS_INIT3_BODY(argcp, argvp, envp) \ { void *xreg[2]; \ Perl_OS2_init3(*envp, xreg, 0); \ PERLIO_INIT -# define PERL_SYS_INIT(argcp, argvp) { \ +# define PERL_SYS_INIT_BODY(argcp, argvp) { \ { void *xreg[2]; \ Perl_OS2_init3(NULL, xreg, 0); \ PERLIO_INIT @@ -262,8 +262,8 @@ void Perl_OS2_term(void **excH, int exitstatus, int flags); #define PERL_SYS_TERM1(xreg) \ Perl_OS2_term(xreg, 0, FORCE_EMX_DEINIT_RUN_ATEXIT) -/* This one should come in pair with PERL_SYS_INIT() and in the same block */ -#define PERL_SYS_TERM() \ +/* This one should come in pair with PERL_SYS_INIT_BODY() and in the same block */ +#define PERL_SYS_TERM_BODY() \ PERL_SYS_TERM1(xreg); \ } @@ -271,7 +271,7 @@ void Perl_OS2_term(void **excH, int exitstatus, int flags); # define PERL_CALLCONV _System #endif -/* #define PERL_SYS_TERM() STMT_START { \ +/* #define PERL_SYS_TERM_BODY() STMT_START { \ if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */ #define dXSUB_SYS OS2_XS_init() diff --git a/perl.c b/perl.c index 0bc2b25..9fe1042 100644 --- a/perl.c +++ b/perl.c @@ -181,6 +181,33 @@ S_init_tls_and_interp(PerlInterpreter *my_perl) } } + +/* these implement the PERL_SYS_INIT, PERL_SYS_INIT3, PERL_SYS_TERM macros */ + +void +Perl_sys_init(int* argc, char*** argv) +{ + PERL_UNUSED_ARG(argc); /* may not be used depending on _BODY macro */ + PERL_UNUSED_ARG(argv); + PERL_SYS_INIT_BODY(argc, argv); +} + +void +Perl_sys_init3(int* argc, char*** argv, char*** env) +{ + PERL_UNUSED_ARG(argc); /* may not be used depending on _BODY macro */ + PERL_UNUSED_ARG(argv); + PERL_UNUSED_ARG(env); + PERL_SYS_INIT3_BODY(argc, argv, env); +} + +void +Perl_sys_term(pTHX) +{ + PERL_SYS_TERM_BODY(); +} + + #ifdef PERL_IMPLICIT_SYS PerlInterpreter * perl_alloc_using(struct IPerlMem* ipM, struct IPerlMem* ipMS, diff --git a/perl.h b/perl.h index ff4746d..5c6d656 100644 --- a/perl.h +++ b/perl.h @@ -2648,10 +2648,14 @@ typedef struct clone_params CLONE_PARAMS; # define PERL_FPU_POST_EXEC } #endif -#ifndef PERL_SYS_INIT3 -# define PERL_SYS_INIT3(argvp,argcp,envp) PERL_SYS_INIT(argvp,argcp) +#ifndef PERL_SYS_INIT3_BODY +# define PERL_SYS_INIT3_BODY(argvp,argcp,envp) PERL_SYS_INIT_BODY(argvp,argcp) #endif +#define PERL_SYS_INIT(argc, argv) Perl_sys_init(argc, argv) +#define PERL_SYS_INIT3(argc, argv, env) Perl_sys_init3(argc, argv, env) +#define PERL_SYS_TERM() Perl_sys_term(aTHX) + #ifndef PERL_WRITE_MSG_TO_CONSOLE # define PERL_WRITE_MSG_TO_CONSOLE(io, msg, len) PerlIO_write(io, msg, len) #endif diff --git a/plan9/plan9ish.h b/plan9/plan9ish.h index 20db6e9..0fdce12 100644 --- a/plan9/plan9ish.h +++ b/plan9/plan9ish.h @@ -104,10 +104,10 @@ #define ABORT() kill(PerlProc_getpid(),SIGABRT); #define BIT_BUCKET "/dev/null" -#define PERL_SYS_INIT(c,v) \ +#define PERL_SYS_INIT_BODY(c,v) \ MALLOC_CHECK_TAINT2(*c,*v) PERLIO_INIT; MALLOC_INIT #define dXSUB_SYS -#define PERL_SYS_TERM() PERLIO_TERM; MALLOC_TERM +#define PERL_SYS_TERM_BODY() PERLIO_TERM; MALLOC_TERM /* * fwrite1() should be a routine with the same calling sequence as fwrite(), diff --git a/proto.h b/proto.h index c5979a4..8586650 100644 --- a/proto.h +++ b/proto.h @@ -4701,6 +4701,17 @@ PERL_CALLCONV void Perl_mro_method_changed_in(pTHX_ HV* stash) __attribute__nonnull__(pTHX_1); PERL_CALLCONV void Perl_boot_core_mro(pTHX); +PERL_CALLCONV void Perl_sys_init(int* argc, char*** argv) + __attribute__nonnull__(1) + __attribute__nonnull__(2); + +PERL_CALLCONV void Perl_sys_init3(int* argc, char*** argv, char*** env) + __attribute__nonnull__(1) + __attribute__nonnull__(2) + __attribute__nonnull__(3); + +PERL_CALLCONV void Perl_sys_term(pTHX); + END_EXTERN_C /* diff --git a/symbian/symbianish.h b/symbian/symbianish.h index b8e6940..a76a755 100644 --- a/symbian/symbianish.h +++ b/symbian/symbianish.h @@ -119,8 +119,9 @@ #define Fflush(fp) fflush(fp) #define Mkdir(path,mode) mkdir((path),(mode)) -#ifndef PERL_SYS_TERM -#define PERL_SYS_TERM() HINTS_REFCNT_TERM; OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM; CloseSTDLIB(); +#ifndef PERL_SYS_TERM_BODY +#define PERL_SYS_TERM_BODY() HINTS_REFCNT_TERM; OP_REFCNT_TERM; \ + PERLIO_TERM; MALLOC_TERM; CloseSTDLIB(); #endif #define BIT_BUCKET "NUL:" @@ -170,7 +171,7 @@ pid_t wait(int *status); #define times(b) symbian_times(b) #define usleep(u) symbian_usleep(u) -#define PERL_SYS_INIT(c, v) symbian_sys_init(c, v) +#define PERL_SYS_INIT_BODY(c, v) symbian_sys_init(c, v) #ifdef __SERIES60_1X__ # error "Unfortunately Perl does not work in S60 1.2 (see FAQ-0929)" diff --git a/unixish.h b/unixish.h index 5f95ba5..5abb42c 100644 --- a/unixish.h +++ b/unixish.h @@ -126,13 +126,13 @@ #define Fflush(fp) fflush(fp) #define Mkdir(path,mode) mkdir((path),(mode)) -#ifndef PERL_SYS_INIT -# define PERL_SYS_INIT(c,v) \ +#ifndef PERL_SYS_INIT_BODY +# define PERL_SYS_INIT_BODY(c,v) \ MALLOC_CHECK_TAINT2(*c,*v) PERL_FPU_INIT; PERLIO_INIT; MALLOC_INIT #endif -#ifndef PERL_SYS_TERM -# define PERL_SYS_TERM() \ +#ifndef PERL_SYS_TERM_BODY +# define PERL_SYS_TERM_BODY() \ if (!PL_veto_cleanup) { \ HINTS_REFCNT_TERM; OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM; \ } diff --git a/vms/vmsish.h b/vms/vmsish.h index a9452eb..a0a52a3 100644 --- a/vms/vmsish.h +++ b/vms/vmsish.h @@ -402,8 +402,8 @@ struct interp_intern { #else #define BIT_BUCKET "/dev/null" #endif -#define PERL_SYS_INIT(c,v) MALLOC_CHECK_TAINT2(*c,*v) vms_image_init((c),(v)); PERLIO_INIT; MALLOC_INIT -#define PERL_SYS_TERM() HINTS_REFCNT_TERM; OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM +#define PERL_SYS_INIT_BODY(c,v) MALLOC_CHECK_TAINT2(*c,*v) vms_image_init((c),(v)); PERLIO_INIT; MALLOC_INIT +#define PERL_SYS_TERM_BODY() HINTS_REFCNT_TERM; OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM #define dXSUB_SYS #define HAS_KILL #define HAS_WAIT