Remove global macro "self". Change thr->Tself to thr->self.
Malcolm Beattie [Wed, 29 Oct 1997 14:39:54 +0000 (14:39 +0000)]
p4raw-id: //depot/perl@190

ext/Thread/Thread.xs
fakethr.h
perl.c
thread.h
win32/win32thread.c
win32/win32thread.h

index 24a11df..7d309b6 100644 (file)
@@ -256,7 +256,8 @@ char *class;
     sigfillset(&fullmask);
     if (sigprocmask(SIG_SETMASK, &fullmask, &oldmask) == -1)
        croak("panic: sigprocmask");
-    err = pthread_create(&self, pthread_attr_default, threadstart, (void*) thr);
+    err = pthread_create(&thr->self, pthread_attr_default,
+                        threadstart, (void*) thr);
     /* Go */
     MUTEX_UNLOCK(&thr->mutex);
 #endif
index eaab4b8..e09a757 100644 (file)
--- a/fakethr.h
+++ b/fakethr.h
@@ -22,7 +22,7 @@ struct thread_intern {
 
 #define init_thread_intern(t)                          \
     STMT_START {                                       \
-       t->Tself = (t);                                 \
+       t->self = (t);                                  \
        (t)->i.next_run = (t)->i.prev_run = (t);        \
        (t)->i.wait_queue = 0;                          \
        (t)->i.private = 0;                             \
diff --git a/perl.c b/perl.c
index f816892..a1dd4e5 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -155,7 +155,7 @@ register PerlInterpreter *sv_interp;
 #ifdef HAVE_THREAD_INTERN
        init_thread_intern(thr);
 #else
-       self = pthread_self();
+       thr->self = pthread_self();
        if (pthread_key_create(&thr_key, 0))
            croak("panic: pthread_key_create");
 #endif /* HAVE_THREAD_INTERN */
index b92e832..fb6a7c0 100644 (file)
--- a/thread.h
+++ b/thread.h
@@ -13,7 +13,7 @@ typedef pthread_t perl_thread;
 #  define YIELD pthread_yield()
 #  define DETACH(t)                            \
     STMT_START {                               \
-       if (pthread_detach(&(t)->Tself)) {      \
+       if (pthread_detach(&(t)->self)) {       \
            MUTEX_UNLOCK(&(t)->mutex);          \
            croak("panic: DETACH");             \
        }                                       \
@@ -83,7 +83,7 @@ typedef pthread_t perl_thread;
 #ifndef DETACH
 #define DETACH(t)                              \
     STMT_START {                               \
-       if (pthread_detach((t)->Tself)) {       \
+       if (pthread_detach((t)->self)) {        \
            MUTEX_UNLOCK(&(t)->mutex);          \
            croak("panic: DETACH");             \
        }                                       \
@@ -93,7 +93,7 @@ typedef pthread_t perl_thread;
 #ifndef JOIN
 #define JOIN(t, avp)                                   \
     STMT_START {                                       \
-       if (pthread_join((t)->Tself, (void**)(avp)))    \
+       if (pthread_join((t)->self, (void**)(avp)))     \
            croak("panic: pthread_join");               \
     } STMT_END
 #endif /* JOIN */
@@ -198,9 +198,9 @@ struct thread {
 
     /* XXX Sort stuff, firstgv, secongv and so on? */
 
-    perl_thread        Tself;
     SV *       Toursv;
     HV *       Tcvcache;
+    perl_thread        self;                   /* Underlying thread object */
     U32                flags;
     perl_mutex mutex;                  /* For the fields others can change */
     U32                tid;
@@ -285,7 +285,6 @@ typedef struct condpair {
 #undef dirty
 #undef localizing
 
-#define self           (thr->Tself)
 #define oursv          (thr->Toursv)
 #define stack_base     (thr->Tstack_base)
 #define stack_sp       (thr->Tstack_sp)
index e74d7e8..9f63d17 100644 (file)
@@ -8,7 +8,7 @@ init_thread_intern(struct thread *thr)
     DuplicateHandle(GetCurrentProcess(),
                    GetCurrentThread(),
                    GetCurrentProcess(),
-                   &self,
+                   &thr->self,
                    0,
                    FALSE,
                    DUPLICATE_SAME_ACCESS);
@@ -24,7 +24,7 @@ thread_create(struct thread *thr, THREAD_RET_TYPE (*fn)(void *))
     DWORD junk;
 
     MUTEX_LOCK(&thr->mutex);
-    self = CreateThread(NULL, 0, fn, (void*)thr, 0, &junk);
+    thr->self = CreateThread(NULL, 0, fn, (void*)thr, 0, &junk);
     MUTEX_UNLOCK(&thr->mutex);
-    return self ? 0 : -1;
+    return thr->self ? 0 : -1;
 }
index 46e0a58..ab0dbc5 100644 (file)
@@ -72,7 +72,7 @@ typedef HANDLE perl_thread;
 
 #define DETACH(t) \
     STMT_START {                                               \
-       if (CloseHandle((t)->Tself) == 0) {                     \
+       if (CloseHandle((t)->self) == 0) {                      \
            MUTEX_UNLOCK(&(t)->mutex);                          \
            croak("panic: DETACH");                             \
        }                                                       \
@@ -84,8 +84,8 @@ typedef HANDLE perl_thread;
 
 #define JOIN(t, avp)                                                   \
     STMT_START {                                                       \
-       if ((WaitForSingleObject((t)->Tself,INFINITE) == WAIT_FAILED)   \
-             || (GetExitCodeThread((t)->Tself,(LPDWORD)(avp)) == 0))   \
+       if ((WaitForSingleObject((t)->self,INFINITE) == WAIT_FAILED)    \
+             || (GetExitCodeThread((t)->self,(LPDWORD)(avp)) == 0))    \
            croak("panic: JOIN");                                       \
     } STMT_END