This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
authorNicholas Clark <nick@ccl4.org>
Sun, 4 Feb 2007 21:32:10 +0000 (21:32 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 4 Feb 2007 21:32:10 +0000 (21:32 +0000)
[ 23753]
Turn INIT_TLS_AND_INTERP into a static function

[ 23755]
Foolishly I committed change 23753 before remembering to test without
ithreads. No tests => bugs. This should fix them.

[ 30119]
Change 23753 wasn't quite a perfect refactoring, as it omitted calling
PERL_SET_THX(my_perl); when !PL_curinterp for non-ithreads.
However, this would not have made a difference for any configuration
buildable from the blead source alone.
p4raw-link: @30119 on //depot/perl: c0bce9aa45a3d3e9c7a6fd9886d453d0ab22e69d
p4raw-link: @23755 on //depot/perl: daa7d858611c04f05c8f8e9aadf2e84dafe7e1e8
p4raw-link: @23753 on //depot/perl: e6827a76d6739cf7ead59ff0f2fbe7afeb7086ed

p4raw-id: //depot/maint-5.8/perl@30121
p4raw-integrated: from //depot/perl@30118 'edit in' perl.c (@30105..)

perl.c

diff --git a/perl.c b/perl.c
index 5e5e833..728855c 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -137,41 +137,33 @@ static I32 read_e_script(pTHX_ int idx, SV *buf_sv, int maxlen);
 #endif
 #endif
 
+static void
+S_init_tls_and_interp(PerlInterpreter *my_perl)
+{
+    if (!PL_curinterp) {                       
+       PERL_SET_INTERP(my_perl);
 #if defined(USE_5005THREADS)
-#  define INIT_TLS_AND_INTERP \
-    STMT_START {                               \
-       if (!PL_curinterp) {                    \
-           PERL_SET_INTERP(my_perl);           \
-           INIT_THREADS;                       \
-           ALLOC_THREAD_KEY;                   \
-       }                                       \
-    } STMT_END
+        INIT_THREADS;
+       ALLOC_THREAD_KEY;
 #else
 #  if defined(USE_ITHREADS)
-#  define INIT_TLS_AND_INTERP \
-    STMT_START {                               \
-       if (!PL_curinterp) {                    \
-           PERL_SET_INTERP(my_perl);           \
-           INIT_THREADS;                       \
-           ALLOC_THREAD_KEY;                   \
-           PERL_SET_THX(my_perl);              \
-           OP_REFCNT_INIT;                     \
-           MUTEX_INIT(&PL_dollarzero_mutex);   \
-       }                                       \
-       else {                                  \
-           PERL_SET_THX(my_perl);              \
-       }                                       \
-    } STMT_END
-#  else
-#  define INIT_TLS_AND_INTERP \
-    STMT_START {                               \
-       if (!PL_curinterp) {                    \
-           PERL_SET_INTERP(my_perl);           \
-       }                                       \
-       PERL_SET_THX(my_perl);                  \
-    } STMT_END
+       INIT_THREADS;
+       ALLOC_THREAD_KEY;
+       PERL_SET_THX(my_perl);
+       OP_REFCNT_INIT;
+       MUTEX_INIT(&PL_dollarzero_mutex);
+    }
+#if defined(USE_ITHREADS)
+    else
+#else
+    /* This always happens for non-ithreads  */
+#endif
+    {
+       PERL_SET_THX(my_perl);
 #  endif
 #endif
+    }
+}
 
 #ifdef PERL_IMPLICIT_SYS
 PerlInterpreter *
@@ -184,7 +176,7 @@ perl_alloc_using(struct IPerlMem* ipM, struct IPerlMem* ipMS,
     PerlInterpreter *my_perl;
     /* Newx() needs interpreter, so call malloc() instead */
     my_perl = (PerlInterpreter*)(*ipM->pMalloc)(ipM, sizeof(PerlInterpreter));
-    INIT_TLS_AND_INTERP;
+    S_init_tls_and_interp(my_perl);
     Zero(my_perl, 1, PerlInterpreter);
     PL_Mem = ipM;
     PL_MemShared = ipMS;
@@ -222,7 +214,7 @@ perl_alloc(void)
     /* Newx() needs interpreter, so call malloc() instead */
     my_perl = (PerlInterpreter*)PerlMem_malloc(sizeof(PerlInterpreter));
 
-    INIT_TLS_AND_INTERP;
+    S_init_tls_and_interp(my_perl);
 #ifndef PERL_TRACK_MEMPOOL
     return (PerlInterpreter *) ZeroD(my_perl, 1, PerlInterpreter);
 #else