diff mbox series

provide y2038 safe socket constants

Message ID 20200329041612.4071-1-vgupta@synopsys.com
State New
Headers show
Series provide y2038 safe socket constants | expand

Commit Message

Vineet Gupta March 29, 2020, 4:16 a.m. UTC
These will be used by upcoming RV32 and ARC ports and any future ports

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 sysdeps/unix/sysv/linux/bits/socket-constants.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Vineet Gupta March 31, 2020, 7:24 p.m. UTC | #1
ping !

On 3/28/20 9:16 PM, Vineet Gupta wrote:
> These will be used by upcoming RV32 and ARC ports and any future ports
> 
> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> ---
>  sysdeps/unix/sysv/linux/bits/socket-constants.h | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/bits/socket-constants.h b/sysdeps/unix/sysv/linux/bits/socket-constants.h
> index 9dcc19cd5380..8a48ae7d0ca2 100644
> --- a/sysdeps/unix/sysv/linux/bits/socket-constants.h
> +++ b/sysdeps/unix/sysv/linux/bits/socket-constants.h
> @@ -20,6 +20,8 @@
>  # error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
>  #endif
>  
> +#include <bits/timesize.h>
> +
>  #define SOL_SOCKET 1
>  #define SO_ACCEPTCONN 30
>  #define SO_BROADCAST 6
> @@ -30,9 +32,17 @@
>  #define SO_OOBINLINE 10
>  #define SO_RCVBUF 8
>  #define SO_RCVLOWAT 18
> -#define SO_RCVTIMEO 20
> +#if __TIMESIZE == 64 && __WORDSIZE == 32
> +# define SO_RCVTIMEO 66
> +#else
> +# define SO_RCVTIMEO 20
> +#endif
>  #define SO_REUSEADDR 2
>  #define SO_SNDBUF 7
>  #define SO_SNDLOWAT 19
> -#define SO_SNDTIMEO 21
> +#if __TIMESIZE == 64 && __WORDSIZE == 32
> +# define SO_SNDTIMEO 67
> +#else
> +# define SO_SNDTIMEO 21
> +#endif
>  #define SO_TYPE 3
>
Florian Weimer March 31, 2020, 7:34 p.m. UTC | #2
* Vineet Gupta via Libc-alpha:

> These will be used by upcoming RV32 and ARC ports and any future ports
>
> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> ---
>  sysdeps/unix/sysv/linux/bits/socket-constants.h | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/bits/socket-constants.h b/sysdeps/unix/sysv/linux/bits/socket-constants.h
> index 9dcc19cd5380..8a48ae7d0ca2 100644
> --- a/sysdeps/unix/sysv/linux/bits/socket-constants.h
> +++ b/sysdeps/unix/sysv/linux/bits/socket-constants.h

What about the parallel changes to the sysdeps overrides?  I would
expect changes for hppa, mips, powerpc.  (Not sure about the alpha
situation.)
Vineet Gupta March 31, 2020, 8:28 p.m. UTC | #3
+CC libc-alpha which got lost in the thread.

On 3/31/20 1:18 PM, Florian Weimer wrote:
> * Vineet Gupta:
> 
>> On 3/31/20 12:34 PM, Florian Weimer wrote:
>>> What about the parallel changes to the sysdeps overrides? I would> expect changes for hppa, mips, powerpc.  (Not sure about the alpha
>>> situation.)
>>
>> This patch fixes the existing/future asm-generic ABI enabled arches
>> and the ones you refer to are not. So IMHO that would be a separate
>> patch if at all.
> 
> Ahh, I think the commit message could make this clearer (although it
> it's somewhat implied). 

Sure I can make it more explicit.

> The commit message also lacks a period at the
> end.

Will fix for v2.

> But is the conditional correct for x32?  It has to be keep using the
> old macro definitions.

I was not sure as some of the other patches in area don't seem to do that. Hence I
CC'ed Stephan who had earlier commented on x32.
Joseph Myers March 31, 2020, 8:45 p.m. UTC | #4
On Tue, 31 Mar 2020, Florian Weimer wrote:

> What about the parallel changes to the sysdeps overrides?  I would
> expect changes for hppa, mips, powerpc.  (Not sure about the alpha
> situation.)

This fix is only about the case where the *default* ABI in glibc requires 
these different values.

The header will need further changes (to use a conditional not based on 
__TIMESIZE) when _TIME_BITS=64 is supported on platforms that currently 
have 32-bit time_t.  That's the point at which changes for other 
architectures are needed - once we have an appropriate conditional for 
"the current compilation uses 64-bit time but kernel long is 32-bit" (or 
something like that).

I'm concerned the present patch is wrong for x32, however; that has 
__TIMESIZE == 64 && __WORDSIZE == 32 but should use the old values; the 
patch should be using __SYSCALL_WORDSIZE when available in place of 
__WORDSIZE.
Vineet Gupta March 31, 2020, 9 p.m. UTC | #5
On 3/31/20 1:45 PM, Joseph Myers wrote:
> I'm concerned the present patch is wrong for x32, however; that has 
> __TIMESIZE == 64 && __WORDSIZE == 32 but should use the old values; the 
> patch should be using __SYSCALL_WORDSIZE when available in place of 
> __WORDSIZE.

Something like below ?

-#if __TIMESIZE == 64 && __WORDSIZE == 32

+#if TIMESIZE == 64 && (__WORDSIZE == 32 \
     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))

Also is it ok to littler the code (multiple times, this patch and else where) with
this or should we define a new __32BIT_ARCH_NOT_X32 or some such ?
Joseph Myers March 31, 2020, 9:22 p.m. UTC | #6
On Tue, 31 Mar 2020, Vineet Gupta via Libc-alpha wrote:

> On 3/31/20 1:45 PM, Joseph Myers wrote:
> > I'm concerned the present patch is wrong for x32, however; that has 
> > __TIMESIZE == 64 && __WORDSIZE == 32 but should use the old values; the 
> > patch should be using __SYSCALL_WORDSIZE when available in place of 
> > __WORDSIZE.
> 
> Something like below ?
> 
> -#if __TIMESIZE == 64 && __WORDSIZE == 32
> 
> +#if TIMESIZE == 64 && (__WORDSIZE == 32 \
>      && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))

Yes, that sort of thing.
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/bits/socket-constants.h b/sysdeps/unix/sysv/linux/bits/socket-constants.h
index 9dcc19cd5380..8a48ae7d0ca2 100644
--- a/sysdeps/unix/sysv/linux/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/bits/socket-constants.h
@@ -20,6 +20,8 @@ 
 # error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
 #endif
 
+#include <bits/timesize.h>
+
 #define SOL_SOCKET 1
 #define SO_ACCEPTCONN 30
 #define SO_BROADCAST 6
@@ -30,9 +32,17 @@ 
 #define SO_OOBINLINE 10
 #define SO_RCVBUF 8
 #define SO_RCVLOWAT 18
-#define SO_RCVTIMEO 20
+#if __TIMESIZE == 64 && __WORDSIZE == 32
+# define SO_RCVTIMEO 66
+#else
+# define SO_RCVTIMEO 20
+#endif
 #define SO_REUSEADDR 2
 #define SO_SNDBUF 7
 #define SO_SNDLOWAT 19
-#define SO_SNDTIMEO 21
+#if __TIMESIZE == 64 && __WORDSIZE == 32
+# define SO_SNDTIMEO 67
+#else
+# define SO_SNDTIMEO 21
+#endif
 #define SO_TYPE 3