From bf47b6f40a04ecf6e4daabe8e854bc295b29f0b7 Mon Sep 17 00:00:00 2001 From: yliu Date: Mon, 21 Jul 2025 15:51:14 +0800 Subject: time64: fixed msgctl/semctl/shmctl result errors for for MIPS32/RISCV32 --- libc/misc/sysvipc/shm.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'libc/misc/sysvipc/shm.c') 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 #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 -- cgit v1.2.3