posix_types.h: Cleanup stale __NFDBITS and related definitions
Recently, glibc made a change to suppress sign-conversion warnings in
FD_SET (glibc commit ceb9e56b3d1). This uncovered an issue with the
kernel's definition of __NFDBITS if applications #include
<linux/types.h> after including <sys/select.h>. A build failure would
be seen when passing the -Werror=sign-compare and -D_FORTIFY_SOURCE=2
flags to gcc.
It was suggested that the kernel should either match the glibc
definition of __NFDBITS or remove that entirely. The current in-kernel
uses of __NFDBITS can be replaced with BITS_PER_LONG, and there are no
uses of the related __FDELT and __FDMASK defines. Given that, we'll
continue the cleanup that was started with commit 8b3d1cda4f
("posix_types: Remove fd_set macros") and drop the remaining unused
macros.
Additionally, linux/time.h has similar macros defined that expand to
nothing so we'll remove those at the same time.
Reported-by: Jeff Law <law@redhat.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
CC: <stable@vger.kernel.org>
Signed-off-by: Josh Boyer <jwboyer@redhat.com>
[ .. and fix up whitespace as per akpm ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
4cb38750d4
commit
8ded2bbc18
@@ -15,26 +15,14 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Those macros may have been defined in <gnu/types.h>. But we always
|
||||
* use the ones here.
|
||||
* This macro may have been defined in <gnu/types.h>. But we always
|
||||
* use the one here.
|
||||
*/
|
||||
#undef __NFDBITS
|
||||
#define __NFDBITS (8 * sizeof(unsigned long))
|
||||
|
||||
#undef __FD_SETSIZE
|
||||
#define __FD_SETSIZE 1024
|
||||
|
||||
#undef __FDSET_LONGS
|
||||
#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS)
|
||||
|
||||
#undef __FDELT
|
||||
#define __FDELT(d) ((d) / __NFDBITS)
|
||||
|
||||
#undef __FDMASK
|
||||
#define __FDMASK(d) (1UL << ((d) % __NFDBITS))
|
||||
|
||||
typedef struct {
|
||||
unsigned long fds_bits [__FDSET_LONGS];
|
||||
unsigned long fds_bits[__FD_SETSIZE / (8 * sizeof(long))];
|
||||
} __kernel_fd_set;
|
||||
|
||||
/* Type of a signal handler. */
|
||||
|
||||
@@ -257,14 +257,6 @@ static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#define NFDBITS __NFDBITS
|
||||
|
||||
#define FD_SETSIZE __FD_SETSIZE
|
||||
#define FD_SET(fd,fdsetp) __FD_SET(fd,fdsetp)
|
||||
#define FD_CLR(fd,fdsetp) __FD_CLR(fd,fdsetp)
|
||||
#define FD_ISSET(fd,fdsetp) __FD_ISSET(fd,fdsetp)
|
||||
#define FD_ZERO(fdsetp) __FD_ZERO(fdsetp)
|
||||
|
||||
/*
|
||||
* Names of the interval timers, and structure
|
||||
* defining a timer setting:
|
||||
|
||||
Reference in New Issue
Block a user