diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 1997-11-07 01:37:28 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 1997-11-07 01:37:28 +0000 |
commit | e77eedc24c0252a902559034f2aa207f216529cc (patch) | |
tree | d59ef6c28b87613607887003bd9d900644335b67 /perl.c | |
parent | 4e35701fd273ba8d0093a29660dee38a92408e9b (diff) | |
parent | 5756a3ac9bce8d31d81b13d0e57cdc87e2565fe4 (diff) | |
download | perl-e77eedc24c0252a902559034f2aa207f216529cc.tar.gz |
Raw integrate of latest perl
p4raw-id: //depot/ansiperl@208
Diffstat (limited to 'perl.c')
-rw-r--r-- | perl.c | 105 |
1 files changed, 72 insertions, 33 deletions
@@ -69,6 +69,9 @@ static void init_ids _((void)); static void init_debugger _((void)); static void init_lexer _((void)); static void init_main_stash _((void)); +#ifdef USE_THREADS +static struct thread * init_main_thread _((void)); +#endif /* USE_THREADS */ static void init_perllib _((void)); static void init_postdump_symbols _((int, char **, char **)); static void init_predump_symbols _((void)); @@ -131,34 +134,8 @@ perl_construct(register PerlInterpreter *sv_interp) COND_INIT(&eval_cond); MUTEX_INIT(&threads_mutex); COND_INIT(&nthreads_cond); - nthreads = 1; - cvcache = newHV(); - curcop = &compiling; - thr->flags = THRf_R_JOINABLE; - MUTEX_INIT(&thr->mutex); - thr->next = thr; - thr->prev = thr; - thr->tid = 0; - - /* Handcraft thrsv similarly to mess_sv */ - New(53, thrsv, 1, SV); - Newz(53, xpv, 1, XPV); - SvFLAGS(thrsv) = SVt_PV; - SvANY(thrsv) = (void*)xpv; - SvREFCNT(thrsv) = 1 << 30; /* practically infinite */ - SvPVX(thrsv) = (char*)thr; - SvCUR_set(thrsv, sizeof(thr)); - SvLEN_set(thrsv, sizeof(thr)); - *SvEND(thrsv) = '\0'; /* in the trailing_nul field */ - oursv = thrsv; -#ifdef HAVE_THREAD_INTERN - init_thread_intern(thr); -#else - thr->self = pthread_self(); - if (pthread_key_create(&thr_key, 0)) - croak("panic: pthread_key_create"); -#endif /* HAVE_THREAD_INTERN */ - SET_THR(thr); + + thr = init_main_thread(); #endif /* USE_THREADS */ linestr = NEWSV(65,80); @@ -979,6 +956,9 @@ print \" \\@INC:\\n @INC\\n\";"); /* now that script is parsed, we can modify record separator */ SvREFCNT_dec(rs); rs = SvREFCNT_inc(nrs); +#ifdef USE_THREADS + sv_setsv(*av_fetch(thr->magicals, find_thread_magical("/"), FALSE), rs); +#else sv_setsv(GvSV(gv_fetchpv("/", TRUE, SVt_PV)), rs); if (do_undump) @@ -2522,6 +2502,9 @@ init_predump_symbols(void) GV *tmpgv; GV *othergv; +#ifdef USE_THREADS + sv_setpvn(*av_fetch(thr->magicals,find_thread_magical("\""),FALSE)," ", 1); +#else sv_setpvn(GvSV(gv_fetchpv("\"", TRUE, SVt_PV)), " ", 1); stdingv = gv_fetchpv("STDIN",TRUE, SVt_PVIO); @@ -2796,6 +2779,63 @@ incpush(char *p, int addsubdirs) SvREFCNT_dec(subdir); } +#ifdef USE_THREADS +static struct thread * +init_main_thread() +{ + struct thread *thr; + XPV *xpv; + + Newz(53, thr, 1, struct thread); + curcop = &compiling; + thr->cvcache = newHV(); + thr->magicals = newAV(); + thr->specific = newAV(); + thr->flags = THRf_R_JOINABLE; + MUTEX_INIT(&thr->mutex); + /* Handcraft thrsv similarly to mess_sv */ + New(53, thrsv, 1, SV); + Newz(53, xpv, 1, XPV); + SvFLAGS(thrsv) = SVt_PV; + SvANY(thrsv) = (void*)xpv; + SvREFCNT(thrsv) = 1 << 30; /* practically infinite */ + SvPVX(thrsv) = (char*)thr; + SvCUR_set(thrsv, sizeof(thr)); + SvLEN_set(thrsv, sizeof(thr)); + *SvEND(thrsv) = '\0'; /* in the trailing_nul field */ + thr->oursv = thrsv; + curcop = &compiling; + chopset = " \n-"; + + MUTEX_LOCK(&threads_mutex); + nthreads++; + thr->tid = 0; + thr->next = thr; + thr->prev = thr; + MUTEX_UNLOCK(&threads_mutex); + +#ifdef HAVE_THREAD_INTERN + init_thread_intern(thr); +#else + thr->self = pthread_self(); +#endif /* HAVE_THREAD_INTERN */ + SET_THR(thr); + + /* + * These must come after the SET_THR because sv_setpvn does + * SvTAINT and the taint fields require dTHR. + */ + toptarget = NEWSV(0,0); + sv_upgrade(toptarget, SVt_PVFM); + sv_setpvn(toptarget, "", 0); + bodytarget = NEWSV(0,0); + sv_upgrade(bodytarget, SVt_PVFM); + sv_setpvn(bodytarget, "", 0); + formtarget = bodytarget; + return thr; +} +#endif /* USE_THREADS */ + void call_list(I32 oldscope, AV *list) { @@ -2813,21 +2853,20 @@ call_list(I32 oldscope, AV *list) JMPENV_PUSH(ret); switch (ret) { case 0: { - SV* atsv = GvSV(errgv); PUSHMARK(stack_sp); perl_call_sv((SV*)cv, G_EVAL|G_DISCARD); - (void)SvPV(atsv, len); + (void)SvPV(errsv, len); if (len) { JMPENV_POP; curcop = &compiling; curcop->cop_line = oldline; if (list == beginav) - sv_catpv(atsv, "BEGIN failed--compilation aborted"); + sv_catpv(errsv, "BEGIN failed--compilation aborted"); else - sv_catpv(atsv, "END failed--cleanup aborted"); + sv_catpv(errsv, "END failed--cleanup aborted"); while (scopestack_ix > oldscope) LEAVE; - croak("%s", SvPVX(atsv)); + croak("%s", SvPVX(errsv)); } } break; |