From: Gurusamy Sarathy Date: Tue, 16 Jul 2002 02:57:47 +0000 (+0000) Subject: integrate a variant of change#17568 from maint-5.6 branch (the X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=54725af65d49b2ed8413041530c71b8d3bde0714;p=p5sagit%2Fp5-mst-13.2.git integrate a variant of change#17568 from maint-5.6 branch (the do_exec parts elided so that change is restricted strictly to windows; binary compatibility stubs not needed) p4raw-link: @17568 on //depot/maint-5.6/perl: 07691bcd6c6d7fd92f508fd5268e700370ea47c2 p4raw-id: //depot/perl@17570 --- diff --git a/embed.fnc b/embed.fnc index 698741c..a2c83b5 100644 --- a/embed.fnc +++ b/embed.fnc @@ -172,6 +172,11 @@ p |void |do_chop |SV* asv|SV* sv Ap |bool |do_close |GV* gv|bool not_implicit p |bool |do_eof |GV* gv p |bool |do_exec |char* cmd +#if defined(WIN32) +Ap |int |do_aspawn |SV* really|SV** mark|SV** sp +Ap |int |do_spawn |char* cmd +Ap |int |do_spawn_nowait|char* cmd +#endif #if !defined(WIN32) p |bool |do_exec3 |char* cmd|int fd|int flag #endif diff --git a/embed.h b/embed.h index 9f8605a..747224f 100644 --- a/embed.h +++ b/embed.h @@ -133,6 +133,11 @@ #define do_close Perl_do_close #define do_eof Perl_do_eof #define do_exec Perl_do_exec +#if defined(WIN32) +#define do_aspawn Perl_do_aspawn +#define do_spawn Perl_do_spawn +#define do_spawn_nowait Perl_do_spawn_nowait +#endif #if !defined(WIN32) #define do_exec3 Perl_do_exec3 #endif @@ -1700,6 +1705,11 @@ #define do_close(a,b) Perl_do_close(aTHX_ a,b) #define do_eof(a) Perl_do_eof(aTHX_ a) #define do_exec(a) Perl_do_exec(aTHX_ a) +#if defined(WIN32) +#define do_aspawn(a,b,c) Perl_do_aspawn(aTHX_ a,b,c) +#define do_spawn(a) Perl_do_spawn(aTHX_ a) +#define do_spawn_nowait(a) Perl_do_spawn_nowait(aTHX_ a) +#endif #if !defined(WIN32) #define do_exec3(a,b,c) Perl_do_exec3(aTHX_ a,b,c) #endif diff --git a/global.sym b/global.sym index d9053e0..35e4dfd 100644 --- a/global.sym +++ b/global.sym @@ -96,6 +96,9 @@ Perl_die Perl_dounwind Perl_do_binmode Perl_do_close +Perl_do_aspawn +Perl_do_spawn +Perl_do_spawn_nowait Perl_do_join Perl_do_open Perl_do_open9 diff --git a/iperlsys.h b/iperlsys.h index 86823df..c82ffa7 100644 --- a/iperlsys.h +++ b/iperlsys.h @@ -945,12 +945,8 @@ typedef int (*LPProcGetpid)(struct IPerlProc*); typedef void* (*LPProcDynaLoader)(struct IPerlProc*, const char*); typedef void (*LPProcGetOSError)(struct IPerlProc*, SV* sv, DWORD dwErr); -typedef void (*LPProcFreeBuf)(struct IPerlProc*, char*); -typedef BOOL (*LPProcDoCmd)(struct IPerlProc*, char*); -typedef int (*LPProcSpawn)(struct IPerlProc*, char*); typedef int (*LPProcSpawnvp)(struct IPerlProc*, int, const char*, const char*const*); -typedef int (*LPProcASpawn)(struct IPerlProc*, void*, void**, void**); #endif typedef int (*LPProcLastHost)(struct IPerlProc*); typedef int (*LPProcGetTimeOfDay)(struct IPerlProc*, @@ -988,10 +984,7 @@ struct IPerlProc #ifdef WIN32 LPProcDynaLoader pDynaLoader; LPProcGetOSError pGetOSError; - LPProcDoCmd pDoCmd; - LPProcSpawn pSpawn; LPProcSpawnvp pSpawnvp; - LPProcASpawn pASpawn; #endif LPProcLastHost pLastHost; LPProcPopenList pPopenList; @@ -1068,14 +1061,8 @@ struct IPerlProcInfo (*PL_Proc->pDynaLoader)(PL_Proc, (f)) #define PerlProc_GetOSError(s,e) \ (*PL_Proc->pGetOSError)(PL_Proc, (s), (e)) -#define PerlProc_Cmd(s) \ - (*PL_Proc->pDoCmd)(PL_Proc, (s)) -#define do_spawn(s) \ - (*PL_Proc->pSpawn)(PL_Proc, (s)) -#define do_spawnvp(m, c, a) \ +#define PerlProc_spawnvp(m, c, a) \ (*PL_Proc->pSpawnvp)(PL_Proc, (m), (c), (a)) -#define PerlProc_aspawn(m,c,a) \ - (*PL_Proc->pASpawn)(PL_Proc, (m), (c), (a)) #endif #define PerlProc_lasthost() \ (*PL_Proc->pLastHost)(PL_Proc) @@ -1122,6 +1109,8 @@ struct IPerlProcInfo win32_dynaload((f)) #define PerlProc_GetOSError(s,e) \ win32_str_os_error((s), (e)) +#define PerlProc_spawnvp(m, c, a) \ + win32_spawnvp((m), (c), (a)) #undef PerlProc_signal #define PerlProc_signal(n, h) win32_signal((n), (h)) #endif diff --git a/makedef.pl b/makedef.pl index 9b1f977..f22b34d 100644 --- a/makedef.pl +++ b/makedef.pl @@ -244,7 +244,14 @@ if ($PLATFORM eq 'win32') { Perl_my_popen )]; } -elsif ($PLATFORM eq 'wince') { +else { + skip_symbols [qw( + Perl_do_spawn + Perl_do_spawn_nowait + Perl_do_aspawn + )]; +} +if ($PLATFORM eq 'wince') { skip_symbols [qw( PL_statusvalue_vms PL_archpat_auto diff --git a/pp_sys.c b/pp_sys.c index 2639fe9..ba573be 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -4154,10 +4154,19 @@ PP(pp_system) result = 0; if (PL_op->op_flags & OPf_STACKED) { SV *really = *++MARK; +# ifdef WIN32 + value = (I32)do_aspawn(really, MARK, SP); +# else value = (I32)do_aspawn(really, (void **)MARK, (void **)SP); +# endif } - else if (SP - MARK != 1) + else if (SP - MARK != 1) { +# ifdef WIN32 + value = (I32)do_aspawn(Nullsv, MARK, SP); +# else value = (I32)do_aspawn(Nullsv, (void **)MARK, (void **)SP); +# endif + } else { value = (I32)do_spawn(SvPVx(sv_mortalcopy(*SP), n_a)); } diff --git a/proto.h b/proto.h index e201596..666caa1 100644 --- a/proto.h +++ b/proto.h @@ -217,6 +217,11 @@ PERL_CALLCONV void Perl_do_chop(pTHX_ SV* asv, SV* sv); PERL_CALLCONV bool Perl_do_close(pTHX_ GV* gv, bool not_implicit); PERL_CALLCONV bool Perl_do_eof(pTHX_ GV* gv); PERL_CALLCONV bool Perl_do_exec(pTHX_ char* cmd); +#if defined(WIN32) +PERL_CALLCONV int Perl_do_aspawn(pTHX_ SV* really, SV** mark, SV** sp); +PERL_CALLCONV int Perl_do_spawn(pTHX_ char* cmd); +PERL_CALLCONV int Perl_do_spawn_nowait(pTHX_ char* cmd); +#endif #if !defined(WIN32) PERL_CALLCONV bool Perl_do_exec3(pTHX_ char* cmd, int fd, int flag); #endif diff --git a/win32/perlhost.h b/win32/perlhost.h index c91d9a8..7926142 100644 --- a/win32/perlhost.h +++ b/win32/perlhost.h @@ -22,7 +22,6 @@ extern char * g_win32_get_privlib(const char *pl); extern char * g_win32_get_sitelib(const char *pl); extern char * g_win32_get_vendorlib(const char *pl); extern char * g_getlogin(void); -extern int do_spawn2(char *cmd, int exectype); END_EXTERN_C class CPerlHost @@ -1871,19 +1870,6 @@ PerlProcGetOSError(struct IPerlProc* piPerl, SV* sv, DWORD dwErr) win32_str_os_error(sv, dwErr); } -BOOL -PerlProcDoCmd(struct IPerlProc* piPerl, char *cmd) -{ - do_spawn2(cmd, EXECF_EXEC); - return FALSE; -} - -int -PerlProcSpawn(struct IPerlProc* piPerl, char* cmds) -{ - return do_spawn2(cmds, EXECF_SPAWN); -} - int PerlProcSpawnvp(struct IPerlProc* piPerl, int mode, const char *cmdname, const char *const *argv) { @@ -1891,12 +1877,6 @@ PerlProcSpawnvp(struct IPerlProc* piPerl, int mode, const char *cmdname, const c } int -PerlProcASpawn(struct IPerlProc* piPerl, void *vreally, void **vmark, void **vsp) -{ - return do_aspawn(vreally, vmark, vsp); -} - -int PerlProcLastHost(struct IPerlProc* piPerl) { dTHX; @@ -1935,10 +1915,7 @@ struct IPerlProc perlProc = PerlProcGetpid, PerlProcDynaLoader, PerlProcGetOSError, - PerlProcDoCmd, - PerlProcSpawn, PerlProcSpawnvp, - PerlProcASpawn, PerlProcLastHost, PerlProcPopenList, PerlProcGetTimeOfDay diff --git a/win32/win32.c b/win32/win32.c index 6f96431..4178827 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -85,15 +85,13 @@ int _fcloseall(); # define win32_get_sitelib g_win32_get_sitelib # undef win32_get_vendorlib # define win32_get_vendorlib g_win32_get_vendorlib -# undef do_spawn -# define do_spawn g_do_spawn # undef getlogin # define getlogin g_getlogin #endif static void get_shell(void); static long tokenize(const char *str, char **dest, char ***destv); - int do_spawn2(char *cmd, int exectype); +static int do_spawn2(pTHX_ char *cmd, int exectype); static BOOL has_shell_metachars(char *ptr); static long filetime_to_clock(PFILETIME ft); static BOOL filetime_from_time(PFILETIME ft, time_t t); @@ -516,12 +514,8 @@ get_shell(void) } int -do_aspawn(void *vreally, void **vmark, void **vsp) +Perl_do_aspawn(pTHX_ SV *really, SV **mark, SV **sp) { - dTHX; - SV *really = (SV*)vreally; - SV **mark = (SV**)vmark; - SV **sp = (SV**)vsp; char **argv; char *str; int status; @@ -607,10 +601,9 @@ find_next_space(const char *s) return (char*)s; } -int -do_spawn2(char *cmd, int exectype) +static int +do_spawn2(pTHX_ char *cmd, int exectype) { - dTHX; char **a; char *s; char **argv; @@ -700,21 +693,21 @@ do_spawn2(char *cmd, int exectype) } int -do_spawn(char *cmd) +Perl_do_spawn(pTHX_ char *cmd) { - return do_spawn2(cmd, EXECF_SPAWN); + return do_spawn2(aTHX_ cmd, EXECF_SPAWN); } int -do_spawn_nowait(char *cmd) +Perl_do_spawn_nowait(pTHX_ char *cmd) { - return do_spawn2(cmd, EXECF_SPAWN_NOWAIT); + return do_spawn2(aTHX_ cmd, EXECF_SPAWN_NOWAIT); } bool Perl_do_exec(pTHX_ char *cmd) { - do_spawn2(cmd, EXECF_EXEC); + do_spawn2(aTHX_ cmd, EXECF_EXEC); return FALSE; } diff --git a/win32/win32.h b/win32/win32.h index f37829b..8975885 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -307,9 +307,6 @@ extern FILE * my_fdopen(int, char *); #endif extern int my_fclose(FILE *); extern int my_fstat(int fd, Stat_t *sbufptr); -extern int do_aspawn(void *really, void **mark, void **sp); -extern int do_spawn(char *cmd); -extern int do_spawn_nowait(char *cmd); extern char * win32_get_privlib(const char *pl); extern char * win32_get_sitelib(const char *pl); extern char * win32_get_vendorlib(const char *pl);