4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-31 20:10:23 +08:00

修改 mq 句柄偏移

This commit is contained in:
zhkag 2023-01-06 01:55:15 +00:00 committed by guo
parent 7c05d8517c
commit 0c3a705482

View File

@ -93,6 +93,7 @@ RTM_EXPORT(mq_setattr);
int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat) int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat)
{ {
mqdes = (mqd_t)((uintptr_t)mqdes << 1);
if ((mqdes == RT_NULL) || mqstat == RT_NULL) if ((mqdes == RT_NULL) || mqstat == RT_NULL)
{ {
rt_set_errno(EBADF); rt_set_errno(EBADF);
@ -173,7 +174,7 @@ mqd_t mq_open(const char *name, int oflag, ...)
} }
rt_sem_release(&posix_mq_lock); rt_sem_release(&posix_mq_lock);
return mqdes; return (mqd_t)((uintptr_t)mqdes >> 1);
__return: __return:
/* release lock */ /* release lock */
@ -195,6 +196,7 @@ RTM_EXPORT(mq_open);
ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio) ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
{ {
mqdes = (mqd_t)((uintptr_t)mqdes << 1);
rt_err_t result; rt_err_t result;
if ((mqdes == RT_NULL) || (msg_ptr == RT_NULL)) if ((mqdes == RT_NULL) || (msg_ptr == RT_NULL))
@ -215,6 +217,7 @@ RTM_EXPORT(mq_receive);
int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio) int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
{ {
mqdes = (mqd_t)((uintptr_t)mqdes << 1);
rt_err_t result; rt_err_t result;
if ((mqdes == RT_NULL) || (msg_ptr == RT_NULL)) if ((mqdes == RT_NULL) || (msg_ptr == RT_NULL))
@ -240,7 +243,8 @@ ssize_t mq_timedreceive(mqd_t mqdes,
unsigned *msg_prio, unsigned *msg_prio,
const struct timespec *abs_timeout) const struct timespec *abs_timeout)
{ {
int tick; mqdes = (mqd_t)((uintptr_t)mqdes << 1);
int tick = 0;
rt_err_t result; rt_err_t result;
/* parameters check */ /* parameters check */
@ -279,6 +283,7 @@ RTM_EXPORT(mq_timedsend);
int mq_notify(mqd_t mqdes, const struct sigevent *notification) int mq_notify(mqd_t mqdes, const struct sigevent *notification)
{ {
mqdes = (mqd_t)((uintptr_t)mqdes << 1);
rt_set_errno(-RT_ERROR); rt_set_errno(-RT_ERROR);
return -1; return -1;
@ -287,6 +292,7 @@ RTM_EXPORT(mq_notify);
int mq_close(mqd_t mqdes) int mq_close(mqd_t mqdes)
{ {
mqdes = (mqd_t)((uintptr_t)mqdes << 1);
if (mqdes == RT_NULL) if (mqdes == RT_NULL)
{ {
rt_set_errno(EINVAL); rt_set_errno(EINVAL);