From 2bbc33b4b2bac6fd98f1e04359e01bff796b8332 Mon Sep 17 00:00:00 2001 From: "Albert ARIBAUD (3ADEV)" Date: Fri, 8 Sep 2017 00:42:02 +0200 Subject: Y2038: add function __msgctl64 --- sysdeps/unix/sysv/linux/msgctl.c | 57 ++++++++++++++++++++++++++++++++++++++++ sysvipc/Versions | 3 +++ 2 files changed, 60 insertions(+) diff --git a/sysdeps/unix/sysv/linux/msgctl.c b/sysdeps/unix/sysv/linux/msgctl.c index 7280cba31a..f785804cbe 100644 --- a/sysdeps/unix/sysv/linux/msgctl.c +++ b/sysdeps/unix/sysv/linux/msgctl.c @@ -69,3 +69,60 @@ __old_msgctl (int msqid, int cmd, struct __old_msqid_ds *buf) } compat_symbol (libc, __old_msgctl, msgctl, GLIBC_2_0); #endif + +/* 64-bit time version */ + +struct __msqid_ds64 +{ + struct ipc_perm msg_perm; /* structure describing operation permission */ + __time64_t msg_stime; /* time of last msgsnd command */ + __time64_t msg_rtime; /* time of last msgrcv command */ + __time64_t msg_ctime; /* time of last change */ + unsigned long int __msg_cbytes; /* current number of bytes on queue */ + msgqnum_t msg_qnum; /* number of messages currently on queue */ + msglen_t msg_qbytes; /* max number of bytes allowed on queue */ + __pid_t msg_lspid; /* pid of last msgsnd() */ + __pid_t msg_lrpid; /* pid of last msgrcv() */ + unsigned long int __glibc_reserved4; + unsigned long int __glibc_reserved5; +}; + +int +__msgctl64 (int msqid, int cmd, struct __msqid_ds64 *buf) +{ + int result; + struct msqid_ds buf32, *pbuf32 = NULL; + + if (cmd == IPC_SET && buf != NULL) + { + buf32.msg_qbytes = buf->msg_qbytes; + buf32.msg_perm.uid = buf->msg_perm.uid; + buf32.msg_perm.gid = buf->msg_perm.gid; + buf32.msg_perm.mode = buf->msg_perm.mode; + } + + if (cmd == IPC_SET || cmd == IPC_STAT) + pbuf32 = &buf32; + +#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS + result = INLINE_SYSCALL_CALL (msgctl, msqid, cmd | __IPC_64, pbuf32); +#else + result = INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd | __IPC_64, + 0, pbuf32); +#endif + + if (cmd == IPC_STAT && result == 0 && buf != NULL) + { + buf->msg_perm = buf32.msg_perm; + buf->msg_stime = buf32.msg_stime; + buf->msg_rtime = buf32.msg_rtime; + buf->msg_ctime = buf32.msg_ctime; + buf->__msg_cbytes = buf32.__msg_cbytes; + buf->msg_qnum = buf32.msg_qnum; + buf->msg_qbytes = buf32.msg_qbytes; + buf->msg_lspid = buf32.msg_lspid; + buf->msg_lrpid = buf32.msg_lrpid; + } + + return result; +} diff --git a/sysvipc/Versions b/sysvipc/Versions index 4c797e25ce..0e7f29751f 100644 --- a/sysvipc/Versions +++ b/sysvipc/Versions @@ -13,6 +13,9 @@ libc { # Non-standard function. semtimedop; } + GLIBC_2.28 { + __msgctl64; + } GLIBC_PRIVATE { # Cancellation point entries. __libc_msgrcv; __libc_msgsnd; -- cgit v1.2.1