Message ID | 20201204233604.7430-6-lukma@denx.de |
---|---|
State | New |
Headers | show |
Series | y2038: Prepare glibc to be Y2038 safe for 32 bit ports | expand |
Hi Adhemerval, > 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 We had a discussion regarding this patch some time ago [1]. The conclusion was that we would need to duplicate this structure to have a copy of msqid_ds structure as adding new members to exported (and POSIX standardized) headers causes POSIX naming pollution. Can we have a final agreement on this patch? This also would require discussion about related patch - "msg: provide glibc local copy of struct msqid_ds" [2] Links: [1] - https://marc.info/?t=160383682700004&r=1&w=2 [2] - https://marc.info/?t=160383682700003&r=1&w=2 > --- > 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 > + <https://www.gnu.org/licenses/>. */ > + > +#include <time.h> > + > +#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 <bits/msq.h> directly; include > <sys/msg.h> 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 Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
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 + <https://www.gnu.org/licenses/>. */ + +#include <time.h> + +#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 <bits/msq.h> directly; include <sys/msg.h> 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