diff options
author | yliu <yu.liu@ingenic.com> | 2025-07-21 15:51:14 +0800 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2025-08-10 19:27:56 +0200 |
commit | bf47b6f40a04ecf6e4daabe8e854bc295b29f0b7 (patch) | |
tree | fc86fbdf47a1044e07d7f72cd8282fabfc91ee48 /libc/misc/sysvipc | |
parent | 133a547b54894dfe55611d9dc3d8ef273e753a46 (diff) |
time64: fixed msgctl/semctl/shmctl result errors for for MIPS32/RISCV32
Diffstat (limited to 'libc/misc/sysvipc')
-rw-r--r-- | libc/misc/sysvipc/msgq.c | 20 | ||||
-rw-r--r-- | libc/misc/sysvipc/sem.c | 6 | ||||
-rw-r--r-- | libc/misc/sysvipc/shm.c | 18 |
3 files changed, 39 insertions, 5 deletions
diff --git a/libc/misc/sysvipc/msgq.c b/libc/misc/sysvipc/msgq.c index 185cd268b..ab6d806d8 100644 --- a/libc/misc/sysvipc/msgq.c +++ b/libc/misc/sysvipc/msgq.c @@ -1,5 +1,6 @@ #include <errno.h> #include <sys/msg.h> +#include <stddef.h> #include "ipc.h" #ifdef __UCLIBC_HAS_THREADS_NATIVE__ #include "sysdep-cancel.h" @@ -7,6 +8,12 @@ #define SINGLE_THREAD_P 1 #endif +#if defined(__UCLIBC_USE_TIME64__) +union msqun { + struct msqid_ds* buff; + void *__pad; +}; +#endif #ifdef L_msgctl @@ -18,9 +25,18 @@ static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msq int msgctl(int msqid, int cmd, struct msqid_ds *buf) { #ifdef __NR_msgctl - return __libc_msgctl(msqid, cmd | __IPC_64, buf); + int __ret = __libc_msgctl(msqid, cmd | __IPC_64, buf); +#if (__WORDSIZE == 32) && defined(__UCLIBC_USE_TIME64__) && (defined(__MIPSEL__) || defined(__riscv)) + union msqun arg = {.buff = buf}; + if (arg.__pad != NULL) { + arg.buff->msg_stime = (__time_t)arg.buff->msg_stime_internal_1 | (__time_t)(arg.buff->msg_stime_internal_2) << 32; + arg.buff->msg_rtime = (__time_t)arg.buff->msg_rtime_internal_1 | (__time_t)(arg.buff->msg_rtime_internal_2) << 32; + arg.buff->msg_ctime = (__time_t)arg.buff->msg_ctime_internal_1 | (__time_t)(arg.buff->msg_ctime_internal_2) << 32; + } +#endif + return __ret; #else - return __syscall_ipc(IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf, 0); + return __syscall_ipc(IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf, 0); #endif } #endif diff --git a/libc/misc/sysvipc/sem.c b/libc/misc/sysvipc/sem.c index 07076eff7..041b20df2 100644 --- a/libc/misc/sysvipc/sem.c +++ b/libc/misc/sysvipc/sem.c @@ -58,8 +58,10 @@ int semctl(int semid, int semnum, int cmd, ...) #ifdef __NR_semctl int __ret = __semctl(semid, semnum, cmd | __IPC_64, arg.__pad); #if defined(__UCLIBC_USE_TIME64__) - arg.buf->sem_otime = (__time_t)arg.buf->__sem_otime_internal_1 | (__time_t)(arg.buf->__sem_otime_internal_2) << 32; - arg.buf->sem_ctime = (__time_t)arg.buf->__sem_ctime_internal_1 | (__time_t)(arg.buf->__sem_ctime_internal_2) << 32; + if (arg.__pad != NULL) { + arg.buf->sem_otime = (__time_t)arg.buf->__sem_otime_internal_1 | (__time_t)(arg.buf->__sem_otime_internal_2) << 32; + arg.buf->sem_ctime = (__time_t)arg.buf->__sem_ctime_internal_1 | (__time_t)(arg.buf->__sem_ctime_internal_2) << 32; + } #endif return __ret; #else diff --git a/libc/misc/sysvipc/shm.c b/libc/misc/sysvipc/shm.c index cd46ff0dd..f195072e9 100644 --- a/libc/misc/sysvipc/shm.c +++ b/libc/misc/sysvipc/shm.c @@ -25,6 +25,13 @@ #include <syscall.h> #include "ipc.h" +#if defined(__UCLIBC_USE_TIME64__) +union shmun { + struct shmid_ds* buff; + void *__pad; +}; +#endif + #ifdef L_shmat /* Attach the shared memory segment associated with SHMID to the data segment of the calling process. SHMADDR and SHMFLG determine how @@ -59,7 +66,16 @@ static __always_inline _syscall3(int, __syscall_shmctl, int, shmid, int, cmd, st int shmctl(int shmid, int cmd, struct shmid_ds *buf) { #ifdef __NR_shmctl - return __syscall_shmctl(shmid, cmd | __IPC_64, buf); + int __ret = __syscall_shmctl(shmid, cmd | __IPC_64, buf); +#if (__WORDSIZE == 32) && defined(__MIPSEL__) && defined(__UCLIBC_USE_TIME64__) + union shmun arg = {.buff = buf}; + if (arg.__pad != NULL) { + arg.buff->shm_atime = (__time_t)arg.buff->shm_atime_internal_1 | (__time_t)(arg.buff->shm_atime_internal_2) << 32; + arg.buff->shm_dtime = (__time_t)arg.buff->shm_dtime_internal_1 | (__time_t)(arg.buff->shm_dtime_internal_2) << 32; + arg.buff->shm_ctime = (__time_t)arg.buff->shm_ctime_internal_1 | (__time_t)(arg.buff->shm_ctime_internal_2) << 32; + } +#endif + return __ret; #else return __syscall_ipc(IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf, 0); #endif |