From patchwork Thu Sep 7 22:42:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 811236 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84353-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="CWtUUfyo"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xpFxj1lr5z9sDB for ; Fri, 8 Sep 2017 08:49:13 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=NJBfGFaZ4HssbB20NZOqBtO6coy6h2C XuBIn/YmaTf5mOZ91gNcZq/R7OkizpgA9eupY+3wOOyQLNiKMDb2Ic65AeET9t3a cjNPFc6xDZXvbBn6zKxGmmRyKbxAi9Ez4sBaR+xPskRw/CeSux3yS9HQwODrZjnQ NMENPiZVumz4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=qQgCAEFJquqApO4vJQrOpFYnay4=; b=CWtUU fyoSE1M8gMdlxJ3ndaQ2SJX8o+7XePb88qFCNWOxko5fwRRLODO5TYjhajm20RIc 8E+rh3+hEWa6P/ZSs8u1SzH0JiYBAbfFkiWLqUo7c6oy2rrzH0ZhYCFLipFHzZ8j iZ8K7Dt6ZCx3ZpNWhwT55quDNA4fLXpKx7ZNjA= Received: (qmail 98567 invoked by alias); 7 Sep 2017 22:44:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 98335 invoked by uid 89); 7 Sep 2017 22:44:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: smtp6-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Cc: "Albert ARIBAUD (3ADEV)" Subject: [RFC PATCH 35/52] Y2038: add function __msgctl_t64 Date: Fri, 8 Sep 2017 00:42:02 +0200 Message-Id: <20170907224219.12483-36-albert.aribaud@3adev.fr> In-Reply-To: <20170907224219.12483-35-albert.aribaud@3adev.fr> References: <20170907224219.12483-1-albert.aribaud@3adev.fr> <20170907224219.12483-2-albert.aribaud@3adev.fr> <20170907224219.12483-3-albert.aribaud@3adev.fr> <20170907224219.12483-4-albert.aribaud@3adev.fr> <20170907224219.12483-5-albert.aribaud@3adev.fr> <20170907224219.12483-6-albert.aribaud@3adev.fr> <20170907224219.12483-7-albert.aribaud@3adev.fr> <20170907224219.12483-8-albert.aribaud@3adev.fr> <20170907224219.12483-9-albert.aribaud@3adev.fr> <20170907224219.12483-10-albert.aribaud@3adev.fr> <20170907224219.12483-11-albert.aribaud@3adev.fr> <20170907224219.12483-12-albert.aribaud@3adev.fr> <20170907224219.12483-13-albert.aribaud@3adev.fr> <20170907224219.12483-14-albert.aribaud@3adev.fr> <20170907224219.12483-15-albert.aribaud@3adev.fr> <20170907224219.12483-16-albert.aribaud@3adev.fr> <20170907224219.12483-17-albert.aribaud@3adev.fr> <20170907224219.12483-18-albert.aribaud@3adev.fr> <20170907224219.12483-19-albert.aribaud@3adev.fr> <20170907224219.12483-20-albert.aribaud@3adev.fr> <20170907224219.12483-21-albert.aribaud@3adev.fr> <20170907224219.12483-22-albert.aribaud@3adev.fr> <20170907224219.12483-23-albert.aribaud@3adev.fr> <20170907224219.12483-24-albert.aribaud@3adev.fr> <20170907224219.12483-25-albert.aribaud@3adev.fr> <20170907224219.12483-26-albert.aribaud@3adev.fr> <20170907224219.12483-27-albert.aribaud@3adev.fr> <20170907224219.12483-28-albert.aribaud@3adev.fr> <20170907224219.12483-29-albert.aribaud@3adev.fr> <20170907224219.12483-30-albert.aribaud@3adev.fr> <20170907224219.12483-31-albert.aribaud@3adev.fr> <20170907224219.12483-32-albert.aribaud@3adev.fr> <20170907224219.12483-33-albert.aribaud@3adev.fr> <20170907224219.12483-34-albert.aribaud@3adev.fr> <20170907224219.12483-35-albert.aribaud@3adev.fr> Signed-off-by: Albert ARIBAUD (3ADEV) --- sysdeps/unix/sysv/linux/Versions | 7 ++++ sysdeps/unix/sysv/linux/bits/msq.h | 20 +++++++++++ sysdeps/unix/sysv/linux/msgctl.c | 72 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 202ffccc29..3fcd1c252b 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -172,4 +172,11 @@ libc { # functions used by nscd __netlink_assert_response; } + + # Y2038 symbols are given their own version until they can be put in + # the right place + + GLIBC_Y2038 { + __msgctl_t64; + } } diff --git a/sysdeps/unix/sysv/linux/bits/msq.h b/sysdeps/unix/sysv/linux/bits/msq.h index 31c4863e7b..ba3f24f720 100644 --- a/sysdeps/unix/sysv/linux/bits/msq.h +++ b/sysdeps/unix/sysv/linux/bits/msq.h @@ -35,6 +35,25 @@ typedef unsigned long int msglen_t; /* Structure of record for one message inside the kernel. The type `struct msg' is opaque. */ +#ifdef __USE_TIME_BITS64 +struct msqid_ds +{ + struct ipc_perm msg_perm; /* structure describing operation permission */ + __time64_t msg_stime; /* time of last msgsnd command */ + unsigned long int __glibc_reserved1; + __time64_t msg_rtime; /* time of last msgrcv command */ + unsigned long int __glibc_reserved2; + __time64_t msg_ctime; /* time of last change */ + unsigned long int __glibc_reserved3; + 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; +}; +#else struct msqid_ds { struct ipc_perm msg_perm; /* structure describing operation permission */ @@ -52,6 +71,7 @@ struct msqid_ds unsigned long int __glibc_reserved4; unsigned long int __glibc_reserved5; }; +#endif #ifdef __USE_MISC diff --git a/sysdeps/unix/sysv/linux/msgctl.c b/sysdeps/unix/sysv/linux/msgctl.c index e5ae621420..d62faf71ce 100644 --- a/sysdeps/unix/sysv/linux/msgctl.c +++ b/sysdeps/unix/sysv/linux/msgctl.c @@ -69,3 +69,75 @@ __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_ds_t64 +{ + struct ipc_perm msg_perm; /* structure describing operation permission */ + __time64_t msg_stime; /* time of last msgsnd command */ + unsigned long int __glibc_reserved1; + __time64_t msg_rtime; /* time of last msgrcv command */ + unsigned long int __glibc_reserved2; + __time64_t msg_ctime; /* time of last change */ + unsigned long int __glibc_reserved3; + 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; +}; + +extern int __y2038_linux_support; + +int +__msgctl_t64 (int msqid, int cmd, struct __msqid_ds_t64 *buf) +{ + int result; + struct msqid_ds buf32, *pbuf32 = NULL; + + if (__y2038_linux_support) + { + /* TODO: use 64-bit syscalls */ + } + + 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->__glibc_reserved1 = buf32.__glibc_reserved1; + buf->msg_rtime = buf32.msg_rtime; + buf->__glibc_reserved2 = buf32.__glibc_reserved2; + buf->msg_ctime = buf32.msg_ctime; + buf->__glibc_reserved3 = buf32.__glibc_reserved3; + 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; + buf->__glibc_reserved4 = buf32.__glibc_reserved4; + buf->__glibc_reserved5 = buf32.__glibc_reserved5; + } + + return result; +}