From 377aa2cbb69aa2189626e0e42a4a5edebaa79cdc Mon Sep 17 00:00:00 2001 From: John Birrell Date: Sat, 4 Apr 1998 07:27:29 +0000 Subject: [PATCH] Move the magic field initialisation to a place when it is more magic. --- lib/libc_r/uthread/uthread_create.c | 13 +++++++------ lib/libkse/thread/thr_create.c | 13 +++++++------ lib/libpthread/thread/thr_create.c | 13 +++++++------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/libc_r/uthread/uthread_create.c b/lib/libc_r/uthread/uthread_create.c index 412f5580174..3dcd944bced 100644 --- a/lib/libc_r/uthread/uthread_create.c +++ b/lib/libc_r/uthread/uthread_create.c @@ -60,12 +60,6 @@ _thread_create(pthread_t * thread, const pthread_attr_t * attr, /* Insufficient memory to create a thread: */ ret = EAGAIN; } else { - /* - * Write a magic value to the thread structure to help - * identify valid ones: - */ - new_thread->magic = PTHREAD_MAGIC; - /* Check if default thread attributes are required: */ if (attr == NULL || *attr == NULL) { /* Use the default thread attributes: */ @@ -92,6 +86,13 @@ _thread_create(pthread_t * thread, const pthread_attr_t * attr, new_thread->stack = stack; new_thread->start_routine = start_routine; new_thread->arg = arg; + + /* + * Write a magic value to the thread structure + * to help identify valid ones: + */ + new_thread->magic = PTHREAD_MAGIC; + if (pattr->suspend == PTHREAD_CREATE_SUSPENDED) { PTHREAD_NEW_STATE(new_thread,PS_SUSPENDED); } else { diff --git a/lib/libkse/thread/thr_create.c b/lib/libkse/thread/thr_create.c index 412f5580174..3dcd944bced 100644 --- a/lib/libkse/thread/thr_create.c +++ b/lib/libkse/thread/thr_create.c @@ -60,12 +60,6 @@ _thread_create(pthread_t * thread, const pthread_attr_t * attr, /* Insufficient memory to create a thread: */ ret = EAGAIN; } else { - /* - * Write a magic value to the thread structure to help - * identify valid ones: - */ - new_thread->magic = PTHREAD_MAGIC; - /* Check if default thread attributes are required: */ if (attr == NULL || *attr == NULL) { /* Use the default thread attributes: */ @@ -92,6 +86,13 @@ _thread_create(pthread_t * thread, const pthread_attr_t * attr, new_thread->stack = stack; new_thread->start_routine = start_routine; new_thread->arg = arg; + + /* + * Write a magic value to the thread structure + * to help identify valid ones: + */ + new_thread->magic = PTHREAD_MAGIC; + if (pattr->suspend == PTHREAD_CREATE_SUSPENDED) { PTHREAD_NEW_STATE(new_thread,PS_SUSPENDED); } else { diff --git a/lib/libpthread/thread/thr_create.c b/lib/libpthread/thread/thr_create.c index 412f5580174..3dcd944bced 100644 --- a/lib/libpthread/thread/thr_create.c +++ b/lib/libpthread/thread/thr_create.c @@ -60,12 +60,6 @@ _thread_create(pthread_t * thread, const pthread_attr_t * attr, /* Insufficient memory to create a thread: */ ret = EAGAIN; } else { - /* - * Write a magic value to the thread structure to help - * identify valid ones: - */ - new_thread->magic = PTHREAD_MAGIC; - /* Check if default thread attributes are required: */ if (attr == NULL || *attr == NULL) { /* Use the default thread attributes: */ @@ -92,6 +86,13 @@ _thread_create(pthread_t * thread, const pthread_attr_t * attr, new_thread->stack = stack; new_thread->start_routine = start_routine; new_thread->arg = arg; + + /* + * Write a magic value to the thread structure + * to help identify valid ones: + */ + new_thread->magic = PTHREAD_MAGIC; + if (pattr->suspend == PTHREAD_CREATE_SUSPENDED) { PTHREAD_NEW_STATE(new_thread,PS_SUSPENDED); } else {