From: Ulrich Drepper The value of O_NONBLOCK clashes on Alpha dn PARISC with the bits used for socket types. Therefore we cannot define SOCK_NONBLOCK as O_NONBLOCK on these platforms. This patch adds support for an arch-specific SOCK_NONBLOCK value which doesn't add costs for other architectures. Signed-off-by: Ulrich Drepper Cc: Davide Libenzi Cc: Michael Kerrisk Cc: Ulrich Drepper Cc: Roland McGrath Signed-off-by: Andrew Morton --- include/asm-alpha/socket.h | 5 +++++ include/asm-parisc/socket.h | 5 +++++ net/socket.c | 9 +++++++++ 3 files changed, 19 insertions(+) diff -puN include/asm-alpha/socket.h~flag-parameters-paccept-fix-flag-parameters-arch-specific-sock_nonblock include/asm-alpha/socket.h --- a/include/asm-alpha/socket.h~flag-parameters-paccept-fix-flag-parameters-arch-specific-sock_nonblock +++ a/include/asm-alpha/socket.h @@ -62,4 +62,9 @@ #define SO_MARK 36 +/* O_NONBLOCK clashes with the bits used for socket types. Therefore we + * have to define SOCK_NONBLOCK to a different value here. + */ +#define SOCK_NONBLOCK 0x40000000 + #endif /* _ASM_SOCKET_H */ diff -puN include/asm-parisc/socket.h~flag-parameters-paccept-fix-flag-parameters-arch-specific-sock_nonblock include/asm-parisc/socket.h --- a/include/asm-parisc/socket.h~flag-parameters-paccept-fix-flag-parameters-arch-specific-sock_nonblock +++ a/include/asm-parisc/socket.h @@ -54,4 +54,9 @@ #define SO_MARK 0x401f +/* O_NONBLOCK clashes with the bits used for socket types. Therefore we + * have to define SOCK_NONBLOCK to a different value here. + */ +#define SOCK_NONBLOCK 0x40000000 + #endif /* _ASM_SOCKET_H */ diff -puN include/linux/net.h~flag-parameters-paccept-fix-flag-parameters-arch-specific-sock_nonblock include/linux/net.h diff -puN net/socket.c~flag-parameters-paccept-fix-flag-parameters-arch-specific-sock_nonblock net/socket.c --- a/net/socket.c~flag-parameters-paccept-fix-flag-parameters-arch-specific-sock_nonblock +++ a/net/socket.c @@ -1225,6 +1225,9 @@ asmlinkage long sys_socket(int family, i return -EINVAL; type &= SOCK_TYPE_MASK; + if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK)) + flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK; + retval = sock_create(family, type, protocol, &sock); if (retval < 0) goto out; @@ -1259,6 +1262,9 @@ asmlinkage long sys_socketpair(int famil return -EINVAL; type &= SOCK_TYPE_MASK; + if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK)) + flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK; + /* * Obtain the first socket and check if the underlying protocol * supports the socketpair call. @@ -1424,6 +1430,9 @@ long do_accept(int fd, struct sockaddr _ if (flags & ~SOCK_CLOEXEC) return -EINVAL; + if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK)) + flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK; + sock = sockfd_lookup_light(fd, &err, &fput_needed); if (!sock) goto out; _