diff options
| author | [email protected] <[email protected]> | 2010-11-24 23:59:27 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2010-11-24 23:59:27 +0000 |
| commit | 7191e2220fe1dc6e7ae4ff0af657bfe25b43379f (patch) | |
| tree | d3f066721f6e5b6b9672a82da4c361a961bbcc93 /components | |
| parent | f5d2b36adb96c7fc2b8984ef7c9c34ec23edb497 (diff) | |
add pthread magic assert.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1112 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components')
| -rw-r--r-- | components/pthreads/mqueue.c | 24 | ||||
| -rw-r--r-- | components/pthreads/pthread.c | 1 | ||||
| -rw-r--r-- | components/pthreads/pthread_internal.h | 7 |
3 files changed, 10 insertions, 22 deletions
diff --git a/components/pthreads/mqueue.c b/components/pthreads/mqueue.c index bd31b4450a..f4869a0476 100644 --- a/components/pthreads/mqueue.c +++ b/components/pthreads/mqueue.c @@ -55,13 +55,15 @@ static posix_mq_t *posix_mq_find(const char* name) for (iter = posix_mq_list; iter != RT_NULL; iter = iter->next)
{
- object = (rt_object_t)&(iter->mq);
+ object = (rt_object_t)(iter->mq);
if (strncmp(object->name, name, RT_NAME_MAX) == 0)
{
return iter;
}
}
+
+ return RT_NULL;
}
int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat,
@@ -193,13 +195,6 @@ ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_pri return -1;
}
- /* permission check */
- if (!(mqdes->flags & O_RDONLY))
- {
- rt_set_errno(EBADF);
- return -1;
- }
-
result = rt_mq_recv(mqdes->mq->mq, msg_ptr, msg_len, RT_WAITING_FOREVER);
if (result == RT_EOK)
return msg_len;
@@ -218,13 +213,6 @@ int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio) return -1;
}
- /* permission check */
- if (!(mqdes->flags & O_WRONLY))
- {
- rt_set_errno(EBADF);
- return -1;
- }
-
result = rt_mq_send(mqdes->mq->mq, (void*)msg_ptr, msg_len);
if (result == RT_EOK)
return 0;
@@ -245,12 +233,6 @@ ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, rt_set_errno(EINVAL);
return -1;
}
- /* permission check */
- if (!(mqdes->flags & O_RDONLY))
- {
- rt_set_errno(EBADF);
- return -1;
- }
tick = libc_time_to_tick(abs_timeout);
diff --git a/components/pthreads/pthread.c b/components/pthreads/pthread.c index fc312dfd11..c4743c0a91 100644 --- a/components/pthreads/pthread.c +++ b/components/pthreads/pthread.c @@ -65,6 +65,7 @@ int pthread_create (pthread_t *tid, const pthread_attr_t *attr, ptd->canceled = 0;
ptd->cancelstate = PTHREAD_CANCEL_DISABLE;
ptd->canceltype = PTHREAD_CANCEL_DEFERRED;
+ ptd->magic = PTHREAD_MAGIC;
if (attr != RT_NULL) ptd->attr = *attr;
else
diff --git a/components/pthreads/pthread_internal.h b/components/pthreads/pthread_internal.h index 5d00d15091..d9550fe50f 100644 --- a/components/pthreads/pthread_internal.h +++ b/components/pthreads/pthread_internal.h @@ -48,9 +48,14 @@ typedef struct _pthread_data _pthread_data_t; rt_inline _pthread_data_t* _pthread_get_data(pthread_t thread)
{
+ _pthread_data_t* ptd;
RT_ASSERT(thread != RT_NULL);
- return (_pthread_data_t*)thread->user_data;
+ ptd = (_pthread_data_t*)thread->user_data;
+ RT_ASSERT(ptd != RT_NULL);
+ RT_ASSERT(ptd->magic == PTHREAD_MAGIC);
+
+ return ptd;
}
extern int libc_time_to_tick(const struct timespec *time);
|
