Change name of OP_SPECIFIC to OP_THREADSV. Fixed perl_get_sv when
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>
Tue, 11 Nov 1997 15:20:43 +0000 (15:20 +0000)
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>
Tue, 11 Nov 1997 15:20:43 +0000 (15:20 +0000)
getting per-thread magicals. Fixed thr->errsv initialisation.

p4raw-id: //depot/perl@229

ext/Opcode/Opcode.pm
op.c
opcode.h
opcode.pl
perl.c
pp.c
t/lib/safe2.t
toke.c

index d2db5ec..dcc5d74 100644 (file)
@@ -431,7 +431,7 @@ beyond the scope of the compartment.
 
 These ops are related to multi-threading.
 
-    lock specific
+    lock threadsv
 
 =item :default
 
diff --git a/op.c b/op.c
index 06f027c..50073b1 100644 (file)
--- a/op.c
+++ b/op.c
@@ -576,7 +576,7 @@ OP *o;
        o->op_targ = 0; /* Was holding hints. */
        break;
 #ifdef USE_THREADS
-    case OP_SPECIFIC:
+    case OP_THREADSV:
        o->op_targ = 0; /* Was holding index into thr->magicals AV. */
        break;
 #endif /* USE_THREADS */
@@ -1203,12 +1203,8 @@ I32 type;
        break;
 
 #ifdef USE_THREADS
-    case OP_SPECIFIC:
+    case OP_THREADSV:
        modcount++;     /* XXX ??? */
-#if 0
-       if (!type) 
-           croak("Can't localize thread-specific variable");
-#endif
        break;
 #endif /* USE_THREADS */
 
@@ -1368,7 +1364,7 @@ I32 type;
        }
        break;
       
-    case OP_SPECIFIC:
+    case OP_THREADSV:
        o->op_flags |= OPf_MOD;         /* XXX ??? */
        break;
 
@@ -1641,7 +1637,7 @@ OP *o;
     if (o->op_type == OP_LIST) {
        OP *o2;
 #ifdef USE_THREADS
-       o2 = newOP(OP_SPECIFIC, 0);
+       o2 = newOP(OP_THREADSV, 0);
        o2->op_targ = find_thread_magical(";");
 #else
        o2 = newSVREF(newGVOP(OP_GV, 0, gv_fetchpv(";", TRUE, SVt_PV))),
@@ -2190,7 +2186,7 @@ OP *repl;
        if (pm->op_pmflags & PMf_EVAL)
            curop = 0;
 #ifdef USE_THREADS
-       else if (repl->op_type == OP_SPECIFIC
+       else if (repl->op_type == OP_THREADSV
                 && strchr("&`'123456789+",
                           per_thread_magicals[repl->op_targ]))
        {
@@ -2204,7 +2200,7 @@ OP *repl;
            for (curop = LINKLIST(repl); curop!=repl; curop = LINKLIST(curop)) {
                if (opargs[curop->op_type] & OA_DANGEROUS) {
 #ifdef USE_THREADS
-                   if (curop->op_type == OP_SPECIFIC
+                   if (curop->op_type == OP_THREADSV
                        && strchr("&`'123456789+", curop->op_private)) {
                        break;
                    }
@@ -3876,7 +3872,7 @@ OP *o;
        o->op_ppaddr = ppaddr[OP_PADSV];
        return o;
     }
-    else if (o->op_type == OP_SPECIFIC)
+    else if (o->op_type == OP_THREADSV)
        return o;
     return newUNOP(OP_RV2SV, 0, scalar(o));
 }
index 936831b..b560369 100644 (file)
--- a/opcode.h
+++ b/opcode.h
@@ -349,7 +349,7 @@ typedef enum {
        OP_GETLOGIN,    /* 342 */
        OP_SYSCALL,     /* 343 */
        OP_LOCK,        /* 344 */
-       OP_SPECIFIC,    /* 345 */
+       OP_THREADSV,    /* 345 */
        OP_max          
 } opcode;
 
@@ -704,7 +704,7 @@ EXT char *op_name[] = {
        "getlogin",
        "syscall",
        "lock",
-       "specific",
+       "threadsv",
 };
 #endif
 
@@ -1057,7 +1057,7 @@ EXT char *op_desc[] = {
        "getlogin",
        "syscall",
        "lock",
-       "thread-specific",
+       "per-thread variable",
 };
 #endif
 
@@ -1439,7 +1439,7 @@ OP *      pp_egrent       _((ARGSproto));
 OP *   pp_getlogin     _((ARGSproto));
 OP *   pp_syscall      _((ARGSproto));
 OP *   pp_lock         _((ARGSproto));
-OP *   pp_specific     _((ARGSproto));
+OP *   pp_threadsv     _((ARGSproto));
 
 #ifndef DOINIT
 EXT OP * (*ppaddr[])();
@@ -1790,7 +1790,7 @@ EXT OP * (*ppaddr[])() = {
        pp_getlogin,
        pp_syscall,
        pp_lock,
-       pp_specific,
+       pp_threadsv,
 };
 #endif
 
@@ -2143,7 +2143,7 @@ EXT OP * (*check[]) _((OP *op)) = {
        ck_null,        /* getlogin */
        ck_fun,         /* syscall */
        ck_rfun,        /* lock */
-       ck_null,        /* specific */
+       ck_null,        /* threadsv */
 };
 #endif
 
@@ -2496,6 +2496,6 @@ EXT U32 opargs[] = {
        0x0000000c,     /* getlogin */
        0x0002151d,     /* syscall */
        0x00001c04,     /* lock */
-       0x00000044,     /* specific */
+       0x00000044,     /* threadsv */
 };
 #endif
index a97e987..c67f142 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -677,4 +677,4 @@ syscall             syscall                 ck_fun          imst@   S L
 
 # For multi-threading
 lock           lock                    ck_rfun         s%      S
-specific       thread-specific         ck_null         ds0
+threadsv       per-thread variable     ck_null         ds0
diff --git a/perl.c b/perl.c
index dce37a4..3f30f6d 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1086,14 +1086,17 @@ perl_get_sv(name, create)
 char* name;
 I32 create;
 {
+    GV *gv;
 #ifdef USE_THREADS
-    PADOFFSET tmp;
-    if (name[1] == '\0' && !isALPHA(name[0])
-       && (tmp = find_thread_magical(name)) != NOT_IN_PAD) {
-       return *av_fetch(thr->magicals, tmp, FALSE);
+    if (name[1] == '\0' && !isALPHA(name[0])) {
+       PADOFFSET tmp = find_thread_magical(name);
+       if (tmp != NOT_IN_PAD) {
+           dTHR;
+           return *av_fetch(thr->magicals, tmp, FALSE);
+       }
     }
 #endif /* USE_THREADS */
-    GV* gv = gv_fetchpv(name, create, SVt_PV);
+    gv = gv_fetchpv(name, create, SVt_PV);
     if (gv)
        return GvSV(gv);
     return Nullsv;
@@ -2846,7 +2849,6 @@ init_main_thread()
     thr->cvcache = newHV();
     thr->magicals = newAV();
     thr->specific = newAV();
-    thr->errsv = newSVpv("", 0);
     thr->errhv = newHV();
     thr->flags = THRf_R_JOINABLE;
     MUTEX_INIT(&thr->mutex);
@@ -2889,6 +2891,7 @@ init_main_thread()
     sv_upgrade(bodytarget, SVt_PVFM);
     sv_setpvn(bodytarget, "", 0);
     formtarget = bodytarget;
+    thr->errsv = newSVpv("", 0);
     return thr;
 }
 #endif /* USE_THREADS */
diff --git a/pp.c b/pp.c
index c2585ae..45ff756 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -4296,20 +4296,20 @@ PP(pp_lock)
     RETURN;
 }
 
-PP(pp_specific)
+PP(pp_threadsv)
 {
     dSP;
 #ifdef USE_THREADS
     SV **svp = av_fetch(thr->magicals, op->op_targ, FALSE);
     if (!svp)
-       croak("panic: pp_specific");
+       croak("panic: pp_threadsv");
     EXTEND(sp, 1);
     if (op->op_private & OPpLVAL_INTRO)
        PUSHs(save_svref(svp));
     else
        PUSHs(*svp);
 #else
-    DIE("tried to access thread-specific data in non-threaded perl");
+    DIE("tried to access per-thread data in non-threaded perl");
 #endif /* USE_THREADS */
     RETURN;
 }
index 40c5098..a9d2405 100755 (executable)
@@ -64,7 +64,8 @@ $glob = "ok 11\n";
 
 sub sayok { print "ok @_\n" }
 
-$cpt->share(qw($foo %bar @baz *glob sayok $"));
+$cpt->share(qw($foo %bar @baz *glob sayok));
+$cpt->share('$"') unless $Config{archname} =~ /-thread$/;
 
 $cpt->reval(q{
     package other;
diff --git a/toke.c b/toke.c
index 5ba993c..80179d5 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1263,7 +1263,7 @@ yylex()
                && !isALPHA(tokenbuf[1]) /* Rule out obvious non-magicals */
                && (tmp = find_thread_magical(&tokenbuf[1])) != NOT_IN_PAD)
            {
-               yylval.opval = newOP(OP_SPECIFIC, 0);
+               yylval.opval = newOP(OP_THREADSV, 0);
                yylval.opval->op_targ = tmp;
                return PRIVATEREF;
            }
@@ -1404,7 +1404,7 @@ yylex()
            nextval[nexttoke].ival = 0;
            force_next(',');
 #ifdef USE_THREADS
-           nextval[nexttoke].opval = newOP(OP_SPECIFIC, 0);
+           nextval[nexttoke].opval = newOP(OP_THREADSV, 0);
            nextval[nexttoke].opval->op_targ = find_thread_magical("\"");
            force_next(PRIVATEREF);
 #else