diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-06-09 18:03:01 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-06-09 18:03:01 +0000 |
commit | cea2e8a9dd23747fd2b66edc86c58c64e9970321 (patch) | |
tree | 50e1ad203239e885681b4e804c46363e763ca432 /thread.h | |
parent | f019efd000a9017df645fb6c4cce1e7401ac9445 (diff) | |
download | perl-cea2e8a9dd23747fd2b66edc86c58c64e9970321.tar.gz |
more complete support for implicit thread/interpreter pointer,
enabled via -DPERL_IMPLICIT_CONTEXT (all changes are noops
without that enabled):
- USE_THREADS now enables PERL_IMPLICIT_CONTEXT, so dTHR
is a noop; tests pass on Solaris; should be faster now!
- MULTIPLICITY has been tested with and without
PERL_IMPLICIT_CONTEXT on Solaris
- improved function database now merged with embed.pl
- everything except the varargs functions have foo(a,b,c) macros
to provide compatibility
- varargs functions default to compatibility variants that
get the context pointer using dTHX
- there should be almost no source compatibility issues as a
result of all this
- dl_foo.xs changes other than dl_dlopen.xs untested
- still needs documentation, fixups for win32 etc
Next step: migrate most non-mutex variables from perlvars.h
to intrpvar.h
p4raw-id: //depot/perl@3524
Diffstat (limited to 'thread.h')
-rw-r--r-- | thread.h | 51 |
1 files changed, 29 insertions, 22 deletions
@@ -8,7 +8,7 @@ STMT_START { \ if (pthread_detach(&(t)->self)) { \ MUTEX_UNLOCK(&(t)->mutex); \ - croak("panic: DETACH"); \ + Perl_croak(aTHX_ "panic: DETACH"); \ } \ } STMT_END # define THR getTHR() @@ -70,7 +70,7 @@ struct perl_thread *getTHR (void); if (*m) { \ mutex_init(*m); \ } else { \ - croak("panic: MUTEX_INIT"); \ + Perl_croak(aTHX_ "panic: MUTEX_INIT"); \ } \ } STMT_END @@ -88,7 +88,7 @@ struct perl_thread *getTHR (void); if (*c) { \ condition_init(*c); \ } else { \ - croak("panic: COND_INIT"); \ + Perl_croak(aTHX_ "panic: COND_INIT"); \ } \ } STMT_END @@ -147,29 +147,39 @@ struct perl_thread *getTHR (void); STMT_START { \ Zero((m), 1, perl_mutex); \ if (pthread_mutex_init((m), pthread_mutexattr_default)) \ - croak("panic: MUTEX_INIT"); \ + Perl_croak(aTHX_ "panic: MUTEX_INIT"); \ } STMT_END #else #define MUTEX_INIT(m) \ STMT_START { \ if (pthread_mutex_init((m), pthread_mutexattr_default)) \ - croak("panic: MUTEX_INIT"); \ + Perl_croak(aTHX_ "panic: MUTEX_INIT"); \ } STMT_END #endif #define MUTEX_LOCK(m) \ STMT_START { \ if (pthread_mutex_lock((m))) \ - croak("panic: MUTEX_LOCK"); \ + Perl_croak(aTHX_ "panic: MUTEX_LOCK"); \ } STMT_END #define MUTEX_UNLOCK(m) \ STMT_START { \ if (pthread_mutex_unlock((m))) \ - croak("panic: MUTEX_UNLOCK"); \ + Perl_croak(aTHX_ "panic: MUTEX_UNLOCK"); \ + } STMT_END +#define MUTEX_LOCK_NOCONTEXT(m) \ + STMT_START { \ + if (pthread_mutex_lock((m))) \ + Perl_croak_nocontext("panic: MUTEX_LOCK"); \ + } STMT_END +#define MUTEX_UNLOCK_NOCONTEXT(m) \ + STMT_START { \ + if (pthread_mutex_unlock((m))) \ + Perl_croak_nocontext("panic: MUTEX_UNLOCK");\ } STMT_END #define MUTEX_DESTROY(m) \ STMT_START { \ if (pthread_mutex_destroy((m))) \ - croak("panic: MUTEX_DESTROY"); \ + Perl_croak(aTHX_ "panic: MUTEX_DESTROY"); \ } STMT_END #endif /* MUTEX_INIT */ @@ -177,27 +187,27 @@ struct perl_thread *getTHR (void); #define COND_INIT(c) \ STMT_START { \ if (pthread_cond_init((c), pthread_condattr_default)) \ - croak("panic: COND_INIT"); \ + Perl_croak(aTHX_ "panic: COND_INIT"); \ } STMT_END #define COND_SIGNAL(c) \ STMT_START { \ if (pthread_cond_signal((c))) \ - croak("panic: COND_SIGNAL"); \ + Perl_croak(aTHX_ "panic: COND_SIGNAL"); \ } STMT_END #define COND_BROADCAST(c) \ STMT_START { \ if (pthread_cond_broadcast((c))) \ - croak("panic: COND_BROADCAST"); \ + Perl_croak(aTHX_ "panic: COND_BROADCAST"); \ } STMT_END #define COND_WAIT(c, m) \ STMT_START { \ if (pthread_cond_wait((c), (m))) \ - croak("panic: COND_WAIT"); \ + Perl_croak(aTHX_ "panic: COND_WAIT"); \ } STMT_END #define COND_DESTROY(c) \ STMT_START { \ if (pthread_cond_destroy((c))) \ - croak("panic: COND_DESTROY"); \ + Perl_croak(aTHX_ "panic: COND_DESTROY"); \ } STMT_END #endif /* COND_INIT */ @@ -207,7 +217,7 @@ struct perl_thread *getTHR (void); STMT_START { \ if (pthread_detach((t)->self)) { \ MUTEX_UNLOCK(&(t)->mutex); \ - croak("panic: DETACH"); \ + Perl_croak(aTHX_ "panic: DETACH"); \ } \ } STMT_END #endif /* DETACH */ @@ -216,7 +226,7 @@ struct perl_thread *getTHR (void); #define JOIN(t, avp) \ STMT_START { \ if (pthread_join((t)->self, (void**)(avp))) \ - croak("panic: pthread_join"); \ + Perl_croak(aTHX_ "panic: pthread_join"); \ } STMT_END #endif /* JOIN */ @@ -224,7 +234,7 @@ struct perl_thread *getTHR (void); #define SET_THR(t) \ STMT_START { \ if (pthread_setspecific(PL_thr_key, (void *) (t))) \ - croak("panic: pthread_setspecific"); \ + Perl_croak(aTHX_ "panic: pthread_setspecific"); \ } STMT_END #endif /* SET_THR */ @@ -325,7 +335,9 @@ typedef struct condpair { #else /* USE_THREADS is not defined */ #define MUTEX_LOCK(m) +#define MUTEX_LOCK_NOCONTEXT(m) #define MUTEX_UNLOCK(m) +#define MUTEX_UNLOCK_NOCONTEXT(m) #define MUTEX_INIT(m) #define MUTEX_DESTROY(m) #define COND_INIT(c) @@ -339,10 +351,5 @@ typedef struct condpair { #define UNLOCK_STRTAB_MUTEX #define THR -/* Rats: if dTHR is just blank then the subsequent ";" throws an error */ -#ifdef WIN32 -#define dTHR extern int Perl___notused -#else -#define dTHR extern int errno -#endif +#define dTHR dNOOP #endif /* USE_THREADS */ |