integrate cfgperl contents into mainline
[p5sagit/p5-mst-13.2.git] / perl.c
diff --git a/perl.c b/perl.c
index d1bbb27..9da19e0 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -59,11 +59,25 @@ perl_alloc_using(struct IPerlMem* ipM, struct IPerlMem* ipMS,
 #ifdef PERL_OBJECT
     my_perl = (PerlInterpreter*)new(ipM) CPerlObj(ipM, ipMS, ipMP, ipE, ipStd,
                                                  ipLIO, ipD, ipS, ipP);
-    PERL_SET_INTERP(my_perl);
+    if (!PL_curinterp) {
+       PERL_SET_INTERP(my_perl);
+#if defined(USE_THREADS) || defined(USE_ITHREADS)
+       INIT_THREADS;
+        ALLOC_THREAD_KEY;
+#endif
+    }
+    PERL_SET_THX(my_perl);
 #else
     /* New() needs interpreter, so call malloc() instead */
     my_perl = (PerlInterpreter*)(*ipM->pMalloc)(ipM, sizeof(PerlInterpreter));
-    PERL_SET_INTERP(my_perl);
+    if (!PL_curinterp) {
+       PERL_SET_INTERP(my_perl);
+#if defined(USE_THREADS) || defined(USE_ITHREADS)
+       INIT_THREADS;
+        ALLOC_THREAD_KEY;
+#endif
+    }
+    PERL_SET_THX(my_perl);
     Zero(my_perl, 1, PerlInterpreter);
     PL_Mem = ipM;
     PL_MemShared = ipMS;
@@ -95,7 +109,15 @@ perl_alloc(void)
 
     /* New() needs interpreter, so call malloc() instead */
     my_perl = (PerlInterpreter*)PerlMem_malloc(sizeof(PerlInterpreter));
-    PERL_SET_INTERP(my_perl);
+
+    if (!PL_curinterp) {
+       PERL_SET_INTERP(my_perl);
+#if defined(USE_THREADS) || defined(USE_ITHREADS)
+       INIT_THREADS;
+        ALLOC_THREAD_KEY;
+#endif
+    }
+    PERL_SET_THX(my_perl);
     Zero(my_perl, 1, PerlInterpreter);
     return my_perl;
 }
@@ -118,7 +140,7 @@ perl_construct(pTHXx)
     struct perl_thread *thr = NULL;
 #endif /* FAKE_THREADS */
 #endif /* USE_THREADS */
-    
+
 #ifdef MULTIPLICITY
     init_interp();
     PL_perl_destruct_level = 1; 
@@ -129,14 +151,7 @@ perl_construct(pTHXx)
 
    /* Init the real globals (and main thread)? */
     if (!PL_linestr) {
-       INIT_THREADS;
 #ifdef USE_THREADS
-#ifdef ALLOC_THREAD_KEY
-        ALLOC_THREAD_KEY;
-#else
-       if (pthread_key_create(&PL_thr_key, 0))
-           Perl_croak(aTHX_ "panic: pthread_key_create");
-#endif
        MUTEX_INIT(&PL_sv_mutex);
        /*
         * Safe to use basic SV functions from now on (though
@@ -146,9 +161,9 @@ perl_construct(pTHXx)
        COND_INIT(&PL_eval_cond);
        MUTEX_INIT(&PL_threads_mutex);
        COND_INIT(&PL_nthreads_cond);
-#ifdef EMULATE_ATOMIC_REFCOUNTS
+#  ifdef EMULATE_ATOMIC_REFCOUNTS
        MUTEX_INIT(&PL_svref_mutex);
-#endif /* EMULATE_ATOMIC_REFCOUNTS */
+#  endif /* EMULATE_ATOMIC_REFCOUNTS */
        
        MUTEX_INIT(&PL_cred_mutex);
 
@@ -220,7 +235,7 @@ perl_construct(pTHXx)
        PL_patchlevel = NEWSV(0,4);
        SvUPGRADE(PL_patchlevel, SVt_PVNV);
        if (PERL_REVISION > 127 || PERL_VERSION > 127 || PERL_SUBVERSION > 127)
-           SvGROW(PL_patchlevel,24);
+           SvGROW(PL_patchlevel, UTF8_MAXLEN*3+1);
        s = (U8*)SvPVX(PL_patchlevel);
        s = uv_to_utf8(s, (UV)PERL_REVISION);
        s = uv_to_utf8(s, (UV)PERL_VERSION);
@@ -985,8 +1000,11 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
 #  ifdef USE_ITHREADS
                sv_catpv(PL_Sv," USE_ITHREADS");
 #  endif
-#  ifdef USE_64_BITS
-               sv_catpv(PL_Sv," USE_64_BITS");
+#  ifdef USE_64_BIT_INT
+               sv_catpv(PL_Sv," USE_64_BIT_INT");
+#  endif
+#  ifdef USE_64_BIT_ALL
+               sv_catpv(PL_Sv," USE_64_BIT_ALL");
 #  endif
 #  ifdef USE_LONG_DOUBLE
                sv_catpv(PL_Sv," USE_LONG_DOUBLE");
@@ -1174,7 +1192,7 @@ print \"  \\@INC:\\n    @INC\\n\";");
 
     if (xsinit)
        (*xsinit)(aTHXo);       /* in case linked C routines want magical variables */
-#if defined(VMS) || defined(WIN32) || defined(DJGPP)
+#if defined(VMS) || defined(WIN32) || defined(DJGPP) || defined(__CYGWIN__)
     init_os_extras();
 #endif
 
@@ -1907,6 +1925,8 @@ S_usage(pTHX_ char *name)         /* XXX move this out into a module ? */
 "-v              print version, subversion (includes VERY IMPORTANT perl info)",
 "-V[:variable]   print configuration summary (or a single Config.pm variable)",
 "-w              enable many useful warnings (RECOMMENDED)",
+"-W              enable all warnings",
+"-X              disable all warnings",
 "-x[directory]   strip off text before #!perl line and perhaps cd to directory",
 "\n",
 NULL
@@ -2537,7 +2557,7 @@ sed %s -e \"/^[^#]/b\" \
 /* Mention
  * I_SYSSTATVFS        HAS_FSTATVFS
  * I_SYSMOUNT
- * I_STATFS    HAS_FSTATFS
+ * I_STATFS    HAS_FSTATFS     HAS_GETFSSTAT
  * I_MNTENT    HAS_GETMNTENT   HAS_HASMNTOPT
  * here so that metaconfig picks them up. */