From patchwork Tue Oct 27 22:10:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 40900 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A6709385783D; Tue, 27 Oct 2020 22:13:00 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id F1E4A3857C4D for ; Tue, 27 Oct 2020 22:12:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F1E4A3857C4D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CLQtv3CSqz1qs0Z; Tue, 27 Oct 2020 23:12:55 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CLQtv1f0Qz1qxgw; Tue, 27 Oct 2020 23:12:55 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id z77_7O9ltpbe; Tue, 27 Oct 2020 23:12:53 +0100 (CET) X-Auth-Info: cFCNBnkCXhKGIcSDFWrRsx42hNDhTZi1anmFEjqVkyo= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 27 Oct 2020 23:12:53 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [PATCH 1/3] msg: Remove redundant #include header Date: Tue, 27 Oct 2020 23:10:22 +0100 Message-Id: <20201027221024.15147-1-lukma@denx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-16.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The #include is redundant as we do not use message specific types for issuing syscalls to handle msg and shm. Only msgctl requires this header. Build tests: ./src/scripts/build-many-glibcs.py glibcs --- sysdeps/unix/sysv/linux/msgget.c | 1 - sysdeps/unix/sysv/linux/msgrcv.c | 1 - sysdeps/unix/sysv/linux/msgsnd.c | 1 - sysdeps/unix/sysv/linux/shmat.c | 1 - sysdeps/unix/sysv/linux/shmdt.c | 1 - sysdeps/unix/sysv/linux/shmget.c | 1 - 6 files changed, 6 deletions(-) diff --git a/sysdeps/unix/sysv/linux/msgget.c b/sysdeps/unix/sysv/linux/msgget.c index 7968b738a4..f5ed417a1f 100644 --- a/sysdeps/unix/sysv/linux/msgget.c +++ b/sysdeps/unix/sysv/linux/msgget.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include diff --git a/sysdeps/unix/sysv/linux/msgrcv.c b/sysdeps/unix/sysv/linux/msgrcv.c index 95edc7a787..f3567033e2 100644 --- a/sysdeps/unix/sysv/linux/msgrcv.c +++ b/sysdeps/unix/sysv/linux/msgrcv.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include diff --git a/sysdeps/unix/sysv/linux/msgsnd.c b/sysdeps/unix/sysv/linux/msgsnd.c index 554516f2ca..6369782706 100644 --- a/sysdeps/unix/sysv/linux/msgsnd.c +++ b/sysdeps/unix/sysv/linux/msgsnd.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c index 3bc791c05f..89df350d84 100644 --- a/sysdeps/unix/sysv/linux/shmat.c +++ b/sysdeps/unix/sysv/linux/shmat.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include diff --git a/sysdeps/unix/sysv/linux/shmdt.c b/sysdeps/unix/sysv/linux/shmdt.c index c506064a48..48e223e037 100644 --- a/sysdeps/unix/sysv/linux/shmdt.c +++ b/sysdeps/unix/sysv/linux/shmdt.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include diff --git a/sysdeps/unix/sysv/linux/shmget.c b/sysdeps/unix/sysv/linux/shmget.c index 6f7ce8c057..71de81c365 100644 --- a/sysdeps/unix/sysv/linux/shmget.c +++ b/sysdeps/unix/sysv/linux/shmget.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include From patchwork Tue Oct 27 22:10:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 40902 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 64F9E3953C06; Tue, 27 Oct 2020 22:13:05 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id 13AE83865C2D for ; Tue, 27 Oct 2020 22:13:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 13AE83865C2D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CLQty0WlYz1rvxj; Tue, 27 Oct 2020 23:12:58 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CLQty009Vz1qxgw; Tue, 27 Oct 2020 23:12:57 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id kExlZSjnI66A; Tue, 27 Oct 2020 23:12:55 +0100 (CET) X-Auth-Info: dqytEIwn3Bs3oiUy5oO8pPys2UY3M8g0hwIMvxDnNVk= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 27 Oct 2020 23:12:55 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [PATCH 2/3] msqid: Provide internal copy of struct __msqid64_ds Date: Tue, 27 Oct 2020 23:10:23 +0100 Message-Id: <20201027221024.15147-2-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201027221024.15147-1-lukma@denx.de> References: <20201027221024.15147-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-16.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" After the commit SHA1: 3283f711132eaadc4f04bd8c1d84c910c29ba "sysv: linux: Add 64-bit time_t variant for msgctl" The glibc internal, 64 bit supporting version of struct __msqid64_ds has been exported. This approach has issue when one would like to add Y2038 support to glibc. The problem is that both struct msqid_ds and __msqid64_ds rely on exported implementation of the msg.h header (./sysvipc/sys/msg.h) which unconditionally includes ./sysdeps/unix/sysv/linux/bits/msq.h which in turn includes ./sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h As a result the externally exported struct msqid_ds.h is used internally by glibc. Problem starts when one wants to extend this struct with 64 bit time support: | In file included from ../sysdeps/unix/sysv/linux/bits/msq.h:28, | from ../sysvipc/sys/msg.h:30, | from ../sysdeps/unix/sysv/linux/include/sys/msg.h:2, | from ../include/sys/msg.h:1, | from ../sysdeps/unix/sysv/linux/msgctl.c:19: | ../sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h:31:6: error: "__USE_TIME_BITS64" is not defined, evaluates to 0 [-Werror=undef] | # if __USE_TIME_BITS64 | ^~~~~~~~~~~~~~~~~ To fix this issue - the internal,for glibc, copy of struct __msqid64_ds has been re-introduced. This will allow clear separation between exported and internal glibc types. Moreover, the __TIMESIZE based alias shall be internal to glibc. Build tests: ./src/scripts/build-many-glibcs.py glibcs --- include/bits/types/struct_msqid64_ds.h | 36 +++++++++++++++++++ .../sysv/linux/bits/types/struct_msqid64_ds.h | 4 --- 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 include/bits/types/struct_msqid64_ds.h diff --git a/include/bits/types/struct_msqid64_ds.h b/include/bits/types/struct_msqid64_ds.h new file mode 100644 index 0000000000..8c39a2a872 --- /dev/null +++ b/include/bits/types/struct_msqid64_ds.h @@ -0,0 +1,36 @@ +/* Internal for glibc implementation of the SysV message struct msqid64_ds. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#if __TIMESIZE == 64 +# define __msqid64_ds msqid_ds +#else +struct __msqid64_ds +{ + 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 msgsnd command */ + __time64_t msg_ctime; /* time of last change */ + __syscall_ulong_t __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() */ +}; +#endif diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h index 3536c8ea62..07cc1036ab 100644 --- a/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h +++ b/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h @@ -20,9 +20,6 @@ # error "Never use directly; include instead." #endif -#if __TIMESIZE == 64 -# define __msqid64_ds msqid_ds -#else struct __msqid64_ds { struct ipc_perm msg_perm; /* structure describing operation permission */ @@ -35,4 +32,3 @@ struct __msqid64_ds __pid_t msg_lspid; /* pid of last msgsnd() */ __pid_t msg_lrpid; /* pid of last msgrcv() */ }; -#endif From patchwork Tue Oct 27 22:10:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 40901 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CA4239540F0; Tue, 27 Oct 2020 22:13:03 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id ED18F3953C06 for ; Tue, 27 Oct 2020 22:13:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ED18F3953C06 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CLQv00FdKz1qs10; Tue, 27 Oct 2020 23:13:00 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CLQtz6bLhz1qxgx; Tue, 27 Oct 2020 23:12:59 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id g4RWbCTxjfiV; Tue, 27 Oct 2020 23:12:58 +0100 (CET) X-Auth-Info: k6EHQyFjhk+4SKRAql+WXs/Z9Z0cmzTRLNJp9yoe2+0= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 27 Oct 2020 23:12:58 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [PATCH 3/3] msg: provide glibc local copy of struct msqid_ds Date: Tue, 27 Oct 2020 23:10:24 +0100 Message-Id: <20201027221024.15147-3-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201027221024.15147-1-lukma@denx.de> References: <20201027221024.15147-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-16.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The rationale for this change is to provide y2038 support for syscalls which use struct msqid_ds as __USE_TIME64_BITS is only available in exported headers. After this commit there is no need to unconditionally #include header, which prevents from using the exported struct msqid_ds. The aforementioned header is only included when _ISOMAC is defined - e.g. when the testsuite is built and executed. For example the ./sysdeps/unix/sysv/linux/msgctl.c includes : (include/sys/msg.h) which has #include_next | \|/ ./sysdeps/unix/sysv/linux/include/sys/msg.h | \|/ (./sysvipc/sys/msg.h) which unconditionally includes ./sysdeps/unix/sysv/linux/bits/msq.h | \|/ ./sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h As a result the externally exported struct msqid_ds.h is used internally by glibc. To fix this issue - the internal for glibc copy of struct msqid_ds has been re-introduced. This will allow clear separation between exported and internal glibc types. Build tests: ./src/scripts/build-many-glibcs.py glibcs --- sysdeps/unix/sysv/linux/include/sys/msg.h | 66 +++++++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/sysdeps/unix/sysv/linux/include/sys/msg.h b/sysdeps/unix/sysv/linux/include/sys/msg.h index 522903f818..1057c2e278 100644 --- a/sysdeps/unix/sysv/linux/include/sys/msg.h +++ b/sysdeps/unix/sysv/linux/include/sys/msg.h @@ -1,7 +1,63 @@ #ifndef _SYS_MSG_H -#include - #ifndef _ISOMAC +# include +# include + +/* Types used in the MSQID_DS structure definition. */ +typedef __syscall_ulong_t msgqnum_t; +typedef __syscall_ulong_t msglen_t; + +struct msqid_ds +{ + struct ipc_perm msg_perm; /* structure describing operation permission */ +# if __TIMESIZE == 32 + __time_t msg_stime; /* time of last msgsnd command */ + unsigned long int __msg_stime_high; + __time_t msg_rtime; /* time of last msgsnd command */ + unsigned long int __msg_rtime_high; + __time_t msg_ctime; /* time of last change */ + unsigned long int __msg_ctime_high; +# else + __time_t msg_stime; /* time of last msgsnd command */ + __time_t msg_rtime; /* time of last msgsnd command */ + __time_t msg_ctime; /* time of last change */ +# endif + __syscall_ulong_t __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() */ + __syscall_ulong_t __glibc_reserved4; + __syscall_ulong_t __glibc_reserved5; +}; + +# ifdef __USE_MISC +# define msg_cbytes __msg_cbytes + +/* ipcs ctl commands */ +# define MSG_STAT 11 +# define MSG_INFO 12 +# define MSG_STAT_ANY 13 + +/* buffer for msgctl calls IPC_INFO, MSG_INFO */ +struct msginfo + { + int msgpool; + int msgmap; + int msgmax; + int msgmnb; + int msgmni; + int msgssz; + int msgtql; + unsigned short int msgseg; + }; +# endif /* __USE_MISC */ + +# ifndef __ssize_t_defined +typedef __ssize_t ssize_t; +# define __ssize_t_defined +# endif + extern ssize_t __libc_msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp, int msgflg); extern int __libc_msgsnd (int msqid, const void *msgp, size_t msgsz, @@ -15,7 +71,9 @@ extern int __libc_msgsnd (int msqid, const void *msgp, size_t msgsz, extern int __msgctl64 (int msqid, int cmd, struct __msqid64_ds *buf); libc_hidden_proto (__msgctl64); # endif - -#endif +#else /* _ISOMAC = 1 - e.g. testsuite */ +/* Provide exported sys/msg.h header */ +# include +#endif /* _ISOMAC */ #endif