Change 20646 by [EMAIL PROTECTED] on 2003/08/12 11:51:25

        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.

Affected files ...

... //depot/perl/Makefile.micro#15 edit
... //depot/perl/README.micro#3 edit
... //depot/perl/doio.c#225 edit
... //depot/perl/mg.c#273 edit
... //depot/perl/perl.c#518 edit
... //depot/perl/perl.h#533 edit
... //depot/perl/perlvars.h#58 edit
... //depot/perl/pp_sys.c#349 edit
... //depot/perl/sv.c#684 edit
... //depot/perl/uconfig.h#72 edit
... //depot/perl/uconfig.sh#59 edit
... //depot/perl/util.c#399 edit

Differences ...

==== //depot/perl/Makefile.micro#15 (text) ====
Index: perl/Makefile.micro
--- perl/Makefile.micro#14~18516~       Sun Jan 19 05:48:10 2003
+++ perl/Makefile.micro Tue Aug 12 04:51:25 2003
@@ -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 @@
        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 @@
 # 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 @@
        $(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 @@
 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!

==== //depot/perl/README.micro#3 (text) ====
Index: perl/README.micro
--- perl/README.micro#2~10461~  Wed Jun  6 16:10:00 2001
+++ perl/README.micro   Tue Aug 12 04:51:25 2003
@@ -6,6 +6,16 @@
 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:
+- <stdlib.h>
+- 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

==== //depot/perl/mg.c#273 (text) ====
Index: perl/mg.c
--- perl/mg.c#272~20565~        Fri Aug  8 11:59:40 2003
+++ perl/mg.c   Tue Aug 12 04:51:25 2003
@@ -1018,6 +1018,7 @@
 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 @@
     }
 #    endif /* USE_ENVIRON_ARRAY */
 #   endif /* PERL_IMPLICIT_SYS || WIN32 */
-#endif /* VMS || EPC */
+#endif /* VMS || EPOC */
+#endif /* !PERL_MICRO */
     return 0;
 }
 
@@ -2538,7 +2540,7 @@
 
     PL_Sv = tSv;                       /* Restore global temporaries. */
     PL_Xpv = tXpv;
-    return;
+    return 0;
 }
 
 

==== //depot/perl/perl.c#518 (text) ====
Index: perl/perl.c
--- perl/perl.c#517~20475~      Mon Aug  4 02:35:55 2003
+++ perl/perl.c Tue Aug 12 04:51:25 2003
@@ -263,8 +263,10 @@
        ("__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 @@
     /* 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 @@
        environ = PL_origenviron;
     }
 #endif
+#endif /* !PERL_MICRO */
 
 #ifdef USE_ITHREADS
     /* the syntax tree is shared between clones
@@ -1445,9 +1449,7 @@
 
     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 @@
     }
     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 @@
        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 @@
                mg_set(sv);
          }
 #endif /* USE_ENVIRON_ARRAY */
+#endif /* !PERL_MICRO */
     }
     TAINT_NOT;
     if ((tmpgv = gv_fetchpv("$",TRUE, SVt_PV))) {

==== //depot/perl/perl.h#533 (text) ====
Index: perl/perl.h
--- perl/perl.h#532~20605~      Sun Aug 10 13:38:39 2003
+++ perl/perl.h Tue Aug 12 04:51:25 2003
@@ -279,7 +279,7 @@
 # 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 @@
 #   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 @@
 #    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

==== //depot/perl/perlvars.h#58 (text) ====
Index: perl/perlvars.h
--- perl/perlvars.h#57~20565~   Fri Aug  8 11:59:40 2003
+++ perl/perlvars.h     Tue Aug 12 04:51:25 2003
@@ -55,13 +55,17 @@
 /* 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
 

==== //depot/perl/pp_sys.c#349 (text) ====
Index: perl/pp_sys.c
--- perl/pp_sys.c#348~20643~    Tue Aug 12 03:13:53 2003
+++ perl/pp_sys.c       Tue Aug 12 04:51:25 2003
@@ -4384,7 +4384,19 @@
     }
     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 */
 }
 

==== //depot/perl/sv.c#684 (text) ====
Index: perl/sv.c
--- perl/sv.c#683~20574~        Sat Aug  9 00:11:32 2003
+++ perl/sv.c   Tue Aug 12 04:51:25 2003
@@ -7379,6 +7379,7 @@
                }
                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 @@
                        environ[0] = Nullch;
                    }
 #endif
+#endif /* !PERL_MICRO */
                }
            }
        }

==== //depot/perl/uconfig.h#72 (text) ====
Index: perl/uconfig.h
--- perl/uconfig.h#71~19897~    Mon Jun 30 22:04:50 2003
+++ perl/uconfig.h      Tue Aug 12 04:51:25 2003
@@ -361,7 +361,7 @@
  *     available to read directory entries. You may have to include
  *     <dirent.h>. 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 <stdlib.h> 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

==== //depot/perl/uconfig.sh#59 (xtext) ====
Index: perl/uconfig.sh
--- perl/uconfig.sh#58~19897~   Mon Jun 30 22:04:50 2003
+++ perl/uconfig.sh     Tue Aug 12 04:51:25 2003
@@ -55,7 +55,7 @@
 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_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_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_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_socks='undef'
 i_stdarg='define'
 i_stddef='undef'
-i_stdlib='undef'
+i_stdlib='define'
 i_string='define'
 i_sunmath='undef'
 i_sysaccess='undef'

==== //depot/perl/util.c#399 (text) ====
Index: perl/util.c
--- perl/util.c#398~20644~      Tue Aug 12 03:37:55 2003
+++ perl/util.c Tue Aug 12 04:51:25 2003
@@ -1516,6 +1516,7 @@
 
 #endif /* WIN32 || NETWARE */
 
+#ifndef PERL_MICRO
 I32
 Perl_setenv_getix(pTHX_ char *nam)
 {
@@ -1533,6 +1534,7 @@
     }                                  /* potential SEGV's */
     return i;
 }
+#endif /* !PERL_MICRO */
 
 #endif /* !VMS && !EPOC*/
 
End of Patch.

Reply via email to