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
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)
# 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.
$(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
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!
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
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
}
# endif /* USE_ENVIRON_ARRAY */
# endif /* PERL_IMPLICIT_SYS || WIN32 */
-#endif /* VMS || EPC */
+#endif /* VMS || EPOC */
+#endif /* !PERL_MICRO */
return 0;
}
PL_Sv = tSv; /* Restore global temporaries. */
PL_Xpv = tXpv;
- return;
+ return 0;
}
("__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
/* 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
environ = PL_origenviron;
}
#endif
+#endif /* !PERL_MICRO */
#ifdef USE_ITHREADS
/* the syntax tree is shared between clones
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 */
}
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);
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
mg_set(sv);
}
#endif /* USE_ENVIRON_ARRAY */
+#endif /* !PERL_MICRO */
}
TAINT_NOT;
if ((tmpgv = gv_fetchpv("$",TRUE, SVt_PV))) {
# 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
# 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
# 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
/* 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
}
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 */
}
}
if (GvHV(gv) && !HvNAME(GvHV(gv))) {
hv_clear(GvHV(gv));
+#ifndef PERL_MICRO
#ifdef USE_ENVIRON_ARRAY
if (gv == PL_envgv
# ifdef USE_ITHREADS
environ[0] = Nullch;
}
#endif
+#endif /* !PERL_MICRO */
}
}
}
* 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
* 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
* 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
* 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
* 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
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'
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'
d_strtold='undef'
d_strtoll='undef'
d_strtoq='undef'
-d_strtoul='undef'
+d_strtoul='define'
d_strtoull='undef'
d_strtouq='undef'
d_strxfrm='undef'
i_crypt='undef'
i_db='undef'
i_dbm='undef'
-i_dirent='undef'
+i_dirent='define'
i_dld='undef'
i_dlfcn='undef'
i_fcntl='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'
#endif /* WIN32 || NETWARE */
+#ifndef PERL_MICRO
I32
Perl_setenv_getix(pTHX_ char *nam)
{
} /* potential SEGV's */
return i;
}
+#endif /* !PERL_MICRO */
#endif /* !VMS && !EPOC*/