From: Lukasz Majewski <lukma@denx.de>
To: Joseph Myers <joseph@codesourcery.com>,
Paul Eggert <eggert@cs.ucla.edu>,
Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: Alistair Francis <alistair23@gmail.com>,
Arnd Bergmann <arnd@arndb.de>,
Alistair Francis <alistair.francis@wdc.com>,
GNU C Library <libc-alpha@sourceware.org>,
Florian Weimer <fweimer@redhat.com>,
Carlos O'Donell <carlos@redhat.com>,
Stepan Golosunov <stepan@golosunov.pp.ru>,
Andreas Schwab <schwab@suse.de>, Zack Weinberg <zackw@panix.com>,
Siddhesh Poyarekar <siddhesh@redhat.com>,
Lukasz Majewski <lukma@denx.de>
Subject: [RFC 6/6] msg: provide glibc local copy of struct msqid_ds
Date: Sat, 5 Dec 2020 00:36:04 +0100 [thread overview]
Message-ID: <20201204233604.7430-7-lukma@denx.de> (raw)
In-Reply-To: <20201204233604.7430-1-lukma@denx.de>
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 <sysvipc/sys/msg.h> 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 <sys/msg.h>:
(include/sys/msg.h) which has
#include_next <sys/msg.h>
|
\|/
./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 <sysvipc/sys/msg.h>
-
#ifndef _ISOMAC
+# include <time.h>
+# include <sys/ipc.h>
+
+/* 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 <sysvipc/sys/msg.h>
+#endif /* _ISOMAC */
#endif
--
2.20.1
next prev parent reply other threads:[~2020-12-04 23:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-04 23:35 [RFC 0/6] y2038: Prepare glibc to be Y2038 safe for 32 bit ports Lukasz Majewski
2020-12-04 23:35 ` [RFC 1/6] y2038: Introduce _TIME_BITS flag to support 64 bit time on 32 bit systems Lukasz Majewski
2020-12-05 0:12 ` Joseph Myers
2020-12-07 13:00 ` Lukasz Majewski
2020-12-04 23:36 ` [RFC 2/6] y2038: stat: {f}stat{at}64_time64 redirection to be used on Y2038 systems Lukasz Majewski
2020-12-05 0:04 ` Joseph Myers
2020-12-07 10:28 ` Lukasz Majewski
2020-12-07 18:07 ` Joseph Myers
2020-12-04 23:36 ` [RFC 3/6] y2038: Export struct_stat_time64_helper.h with Y2038 safe stat{64} content Lukasz Majewski
2020-12-29 10:30 ` Lukasz Majewski
2020-12-04 23:36 ` [RFC 4/6] y2038: Enhance struct msqid_ds to support 64 bit time Lukasz Majewski
2020-12-29 10:34 ` Lukasz Majewski
2020-12-04 23:36 ` [RFC 5/6] msqid: Provide internal copy of struct __msqid64_ds Lukasz Majewski
2020-12-29 10:54 ` Lukasz Majewski
2020-12-04 23:36 ` Lukasz Majewski [this message]
2020-12-05 0:01 ` [RFC 0/6] y2038: Prepare glibc to be Y2038 safe for 32 bit ports Joseph Myers
2020-12-07 10:22 ` Lukasz Majewski
2020-12-07 18:01 ` Joseph Myers
2020-12-08 10:07 ` Lukasz Majewski
2020-12-08 15:25 ` Joseph Myers
2020-12-13 11:49 ` Lukasz Majewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201204233604.7430-7-lukma@denx.de \
--to=lukma@denx.de \
--cc=adhemerval.zanella@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=arnd@arndb.de \
--cc=carlos@redhat.com \
--cc=eggert@cs.ucla.edu \
--cc=fweimer@redhat.com \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=schwab@suse.de \
--cc=siddhesh@redhat.com \
--cc=stepan@golosunov.pp.ru \
--cc=zackw@panix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).