From: Jarkko Hietaniemi Date: Tue, 12 Aug 2003 11:51:25 +0000 (+0000) Subject: Apply much of Ilya's microperl patch, but instead of X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2f42fcb0c2cd8c2699589848aee7b8ee07b30c4f;p=p5sagit%2Fp5-mst-13.2.git Apply much of Ilya's microperl patch, but instead of implementing the opendir()/readdir()/closedir() using external commands give up "ANSI-pureness" and define them in uconfig.sh, also define other stuff like rename() and putenv(). Leave out the $| emulation in my_fork() since we are not supposed to have fork() under microperl. p4raw-id: //depot/perl@20646 --- diff --git a/Makefile.micro b/Makefile.micro index 7950f71..b509448 100644 --- a/Makefile.micro +++ b/Makefile.micro @@ -1,9 +1,10 @@ LD = $(CC) -DEFINES = -DPERL_CORE -DPERL_MICRO -OPTIMIZE = +DEFINES = -DPERL_CORE -DPERL_MICRO -DSTANDARD_C -DPERL_USE_SAFE_PUTENV +OPTIMIZE = CFLAGS = $(DEFINES) $(OPTIMIZE) LIBS = -lm _O = .o +ENV = env all: microperl @@ -15,7 +16,7 @@ O = uav$(_O) udeb$(_O) udoio$(_O) udoop$(_O) udump$(_O) \ uregcomp$(_O) uregexec$(_O) urun$(_O) \ uscope$(_O) usv$(_O) utaint$(_O) utoke$(_O) \ unumeric$(_O) ulocale$(_O) \ - uuniversal$(_O) uutf8$(_O) uutil$(_O) uperlapi$(_O) + uuniversal$(_O) uutf8$(_O) uutil$(_O) uperlapi$(_O) uxsutils$(_O) microperl: $(O) $(LD) -o $@ $(O) $(LIBS) @@ -37,7 +38,7 @@ distclean: clean # The microconfiguration. uconfig.h: uconfig.sh config_h.SH - CONFIG_SH=uconfig.sh CONFIG_H=uconfig.h sh ./config_h.SH + $(ENV) CONFIG_SH=uconfig.sh CONFIG_H=uconfig.h sh ./config_h.SH # Do not regenerate perly.c and perly.h. @@ -80,7 +81,7 @@ uperlmain$(_O): $(HE) miniperlmain.c $(CC) -c -o $@ $(CFLAGS) miniperlmain.c uop$(_O): $(HE) op.c keywords.h - $(CC) -c -o $@ $(CFLAGS) op.c + $(CC) -c -o $@ $(CFLAGS) -DPERL_EXTERNAL_GLOB op.c ureentr$(_O): $(HE) reentr.c $(CC) -c -o $@ $(CFLAGS) reentr.c @@ -154,4 +155,7 @@ uutil$(_O): $(HE) util.c uperlapi$(_O): $(HE) perlapi.c perlapi.h $(CC) -c -o $@ $(CFLAGS) perlapi.c +uxsutils$(_O): $(HE) xsutils.c + $(CC) -c -o $@ $(CFLAGS) xsutils.c +# That's it, folks! diff --git a/README.micro b/README.micro index e495cdb..976742a 100644 --- a/README.micro +++ b/README.micro @@ -6,6 +6,16 @@ operating system are left very -- minimal. All this is experimental. If you don't know what to do with microperl you probably shouldn't. Do not report bugs in microperl; fix the bugs. +We assume ANSI C plus the following: +- +- rename() +- opendir(), readdir(), closedir() (via dirent.h) +- memchr (via string.h) +- (a safe) putenv() (via stdlib.h) +- strtoul() (via stdlib.h) +(grep for 'define' in uconfig.sh.) +Also, Perl times() is defined to always return zeroes. + If you are still reading this and you are itching to try out microperl: make -f Makefile.micro diff --git a/mg.c b/mg.c index b272c7a..712a339 100644 --- a/mg.c +++ b/mg.c @@ -1018,6 +1018,7 @@ Perl_magic_set_all_env(pTHX_ SV *sv, MAGIC *mg) int Perl_magic_clear_all_env(pTHX_ SV *sv, MAGIC *mg) { +#ifndef PERL_MICRO #if defined(VMS) || defined(EPOC) Perl_die(aTHX_ "Can't make list assignment to %%ENV on this system"); #else @@ -1044,7 +1045,8 @@ Perl_magic_clear_all_env(pTHX_ SV *sv, MAGIC *mg) } # endif /* USE_ENVIRON_ARRAY */ # endif /* PERL_IMPLICIT_SYS || WIN32 */ -#endif /* VMS || EPC */ +#endif /* VMS || EPOC */ +#endif /* !PERL_MICRO */ return 0; } @@ -2538,7 +2540,7 @@ cleanup: PL_Sv = tSv; /* Restore global temporaries. */ PL_Xpv = tXpv; - return; + return 0; } diff --git a/perl.c b/perl.c index fb9fd20..0a3ec0f 100644 --- a/perl.c +++ b/perl.c @@ -263,8 +263,10 @@ perl_construct(pTHXx) ("__environ", (unsigned long *) &environ_pointer, NULL); #endif /* environ */ -#ifdef USE_ENVIRON_ARRAY +#ifndef PERL_MICRO +# ifdef USE_ENVIRON_ARRAY PL_origenviron = environ; +# endif #endif /* Use sysconf(_SC_CLK_TCK) if available, if not @@ -409,6 +411,7 @@ perl_destruct(pTHXx) /* if PERL_USE_SAFE_PUTENV is defined environ will not have been copied * so we certainly shouldn't free it here */ +#ifndef PERL_MICRO #if defined(USE_ENVIRON_ARRAY) && !defined(PERL_USE_SAFE_PUTENV) if (environ != PL_origenviron #ifdef USE_ITHREADS @@ -428,6 +431,7 @@ perl_destruct(pTHXx) environ = PL_origenviron; } #endif +#endif /* !PERL_MICRO */ #ifdef USE_ITHREADS /* the syntax tree is shared between clones @@ -1445,9 +1449,7 @@ print \" \\@INC:\\n @INC\\n\";"); boot_core_PerlIO(); boot_core_UNIVERSAL(); -#ifndef PERL_MICRO boot_core_xsutils(); -#endif if (xsinit) (*xsinit)(aTHX); /* in case linked C routines want magical variables */ @@ -2875,6 +2877,9 @@ S_open_script(pTHX_ char *scriptname, bool dosearch, SV *sv, int *fdscript) } else if (PL_preprocess) { char *cpp_cfg = CPPSTDIN; + + if (cpp_cfg[0] == 0) /* PERL_MICRO? */ + Perl_croak(aTHX_ "Can't run with cpp -P with CPPSTDIN undefined"); SV *cpp = newSVpvn("",0); SV *cmd = NEWSV(0,0); @@ -3734,6 +3739,7 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register GvMULTI_on(PL_envgv); hv = GvHVn(PL_envgv); hv_magic(hv, Nullgv, PERL_MAGIC_env); +#ifndef PERL_MICRO #ifdef USE_ENVIRON_ARRAY /* Note that if the supplied env parameter is actually a copy of the global environ then it may now point to free'd memory @@ -3765,6 +3771,7 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register mg_set(sv); } #endif /* USE_ENVIRON_ARRAY */ +#endif /* !PERL_MICRO */ } TAINT_NOT; if ((tmpgv = gv_fetchpv("$",TRUE, SVt_PV))) { diff --git a/perl.h b/perl.h index 682bdbe..376c6e7 100644 --- a/perl.h +++ b/perl.h @@ -279,7 +279,7 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER)); # define STANDARD_C 1 #endif -#if defined(__cplusplus) || defined(WIN32) || defined(__sgi) || defined(OS2) || defined(__DGUX) || defined( EPOC) || defined(__QNX__) || defined(NETWARE) +#if defined(__cplusplus) || defined(WIN32) || defined(__sgi) || defined(OS2) || defined(__DGUX) || defined( EPOC) || defined(__QNX__) || defined(NETWARE) || defined(PERL_MICRO) # define DONT_DECLARE_STD 1 #endif @@ -600,11 +600,13 @@ int usleep(unsigned int); # endif #endif +#ifndef PERL_MICRO #ifndef memchr # ifndef HAS_MEMCHR # define memchr(s,c,n) ninstr((char*)(s), ((char*)(s)) + n, &(c), &(c) + 1) # endif #endif +#endif #ifndef HAS_BCMP # ifndef bcmp @@ -1941,12 +1943,13 @@ typedef struct clone_params CLONE_PARAMS; # endif # define PERL_FPU_INIT fpsetmask(0); # else -# if defined(SIGFPE) && defined(SIG_IGN) +# if defined(SIGFPE) && defined(SIG_IGN) && !defined(PERL_MICRO) # define PERL_FPU_INIT PL_sigfpe_saved = signal(SIGFPE, SIG_IGN); # define PERL_FPU_PRE_EXEC { Sigsave_t xfpe; rsignal_save(SIGFPE, PL_sigfpe_saved, &xfpe); # define PERL_FPU_POST_EXEC rsignal_restore(SIGFPE, &xfpe); } # else # define PERL_FPU_INIT + # endif # endif #endif diff --git a/perlvars.h b/perlvars.h index e0f6530..9cc8a2f 100644 --- a/perlvars.h +++ b/perlvars.h @@ -55,13 +55,17 @@ PERLVAR(Gdollarzero_mutex, perl_mutex) /* Modifying $0 */ /* This is constant on most architectures, a global on OS/2 */ PERLVARI(Gsh_path, char *, SH_PATH)/* full path of shell */ +#ifndef PERL_MICRO /* If Perl has to ignore SIGPFE, this is its saved state. * See perl.h macros PERL_FPU_INIT and PERL_FPU_{PRE,POST}_EXEC. */ PERLVAR(Gsigfpe_saved, Sighandler_t) +#endif /* Restricted hashes placeholder value. * The contents are never used, only the address. */ PERLVAR(Gsv_placeholder, SV) +#ifndef PERL_MICRO PERLVARI(Gcsighandlerp, Sighandler_t, &Perl_csighandler) /* Pointer to C-level sighandler */ +#endif diff --git a/pp_sys.c b/pp_sys.c index 4fb055f..25926a2 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -4384,7 +4384,19 @@ PP(pp_tms) } RETURN; #else +# ifdef PERL_MICRO + dSP; + PUSHs(sv_2mortal(newSVnv((NV)0.0))); + EXTEND(SP, 4); + if (GIMME == G_ARRAY) { + PUSHs(sv_2mortal(newSVnv((NV)0.0))); + PUSHs(sv_2mortal(newSVnv((NV)0.0))); + PUSHs(sv_2mortal(newSVnv((NV)0.0))); + } + RETURN; +# else DIE(aTHX_ "times not implemented"); +# endif #endif /* HAS_TIMES */ } diff --git a/sv.c b/sv.c index 2c24d26..c93c0ea 100644 --- a/sv.c +++ b/sv.c @@ -7379,6 +7379,7 @@ Perl_sv_reset(pTHX_ register char *s, HV *stash) } if (GvHV(gv) && !HvNAME(GvHV(gv))) { hv_clear(GvHV(gv)); +#ifndef PERL_MICRO #ifdef USE_ENVIRON_ARRAY if (gv == PL_envgv # ifdef USE_ITHREADS @@ -7389,6 +7390,7 @@ Perl_sv_reset(pTHX_ register char *s, HV *stash) environ[0] = Nullch; } #endif +#endif /* !PERL_MICRO */ } } } diff --git a/uconfig.h b/uconfig.h index 5f912ee..ae3467b 100644 --- a/uconfig.h +++ b/uconfig.h @@ -361,7 +361,7 @@ * available to read directory entries. You may have to include * . See I_DIRENT. */ -/*#define HAS_READDIR / **/ +#define HAS_READDIR /**/ /* HAS_SEEKDIR: * This symbol, if defined, indicates that the seekdir routine is @@ -392,7 +392,7 @@ * to rename files. Otherwise you should do the unlink(), link(), unlink() * trick. */ -/*#define HAS_RENAME / **/ +#define HAS_RENAME /**/ /* HAS_RMDIR: * This symbol, if defined, indicates that the rmdir routine is @@ -663,7 +663,7 @@ * whether dirent is available or not. You should use this pseudo type to * portably declare your directory entries. */ -/*#define I_DIRENT / **/ +#define I_DIRENT /**/ /*#define DIRNAMLEN / **/ #define Direntry_t struct dirent @@ -738,7 +738,7 @@ * This symbol, if defined, indicates that exists and should * be included. */ -/*#define I_STDLIB / **/ +#define I_STDLIB /**/ /* I_STRING: * This symbol, if defined, indicates to the C program that it should @@ -1999,7 +1999,7 @@ * This symbol, if defined, indicates that the strtoul routine is * available to provide conversion of strings to unsigned long. */ -/*#define HAS_STRTOUL / **/ +#define HAS_STRTOUL /**/ /* HAS_UNION_SEMUN: * This symbol, if defined, indicates that the union semun is diff --git a/uconfig.sh b/uconfig.sh index 93c4194..2060b43 100755 --- a/uconfig.sh +++ b/uconfig.sh @@ -55,7 +55,7 @@ d_chown='undef' d_chroot='undef' d_chsize='undef' d_class='undef' -d_closedir='undef' +d_closedir='define' d_cmsghdr_s='undef' d_const='undef' d_copysignl='undef' @@ -271,12 +271,12 @@ d_qgcvt='undef' d_quad='undef' d_random_r='undef' d_readdir64_r='undef' -d_readdir='undef' +d_readdir='define' d_readdir_r='undef' d_readlink='undef' d_readv='undef' d_recvmsg='undef' -d_rename='undef' +d_rename='define' d_rewinddir='undef' d_rmdir='undef' d_safebcpy='undef' @@ -371,7 +371,7 @@ d_strtol='undef' d_strtold='undef' d_strtoll='undef' d_strtoq='undef' -d_strtoul='undef' +d_strtoul='define' d_strtoull='undef' d_strtouq='undef' d_strxfrm='undef' @@ -481,7 +481,7 @@ i_bsdioctl='' i_crypt='undef' i_db='undef' i_dbm='undef' -i_dirent='undef' +i_dirent='define' i_dld='undef' i_dlfcn='undef' i_fcntl='undef' @@ -517,7 +517,7 @@ i_shadow='undef' i_socks='undef' i_stdarg='define' i_stddef='undef' -i_stdlib='undef' +i_stdlib='define' i_string='define' i_sunmath='undef' i_sysaccess='undef' diff --git a/util.c b/util.c index ea0c43e..cec92e2 100644 --- a/util.c +++ b/util.c @@ -1516,6 +1516,7 @@ Perl_my_setenv(pTHX_ char *nam,char *val) #endif /* WIN32 || NETWARE */ +#ifndef PERL_MICRO I32 Perl_setenv_getix(pTHX_ char *nam) { @@ -1533,6 +1534,7 @@ Perl_setenv_getix(pTHX_ char *nam) } /* potential SEGV's */ return i; } +#endif /* !PERL_MICRO */ #endif /* !VMS && !EPOC*/