mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 23:21:46 +00:00
posix_types: Remove fd_set macros
<asm/posix_types.h> includes a set of macros that operate on file descriptors. Way long ago those were exported to user space, but nowadays they are #ifdef __KERNEL__. However, they are nothing but standard (nonatomic) bit operations, and we already have optimized versions of bit operations in the kernel. We can't include <linux/bitops.h> in <asm/posix_types.h> but we can move the definitions to <linux/time.h> and define them there in terms of standard kernel bitops. [ v2: folds the following fixes in: a) Stray space in __FD_SET(), reported by Andrew Morton b) #include <linux/string.h> needed for memset(), reported by Tony Luck ] Signed-off-by: H. Peter Anvin <hpa@zytor.com> Link: http://lkml.kernel.org/r/1328677745-20121-22-git-send-email-hpa@zytor.com Cc: Arnd Bergmann <arnd@arndb.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
2759e6512e
commit
8b3d1cda4f
2 changed files with 24 additions and 72 deletions
|
@ -4,8 +4,11 @@
|
|||
#include <linux/types.h>
|
||||
|
||||
#ifdef __KERNEL__
|
||||
# include <linux/bitops.h>
|
||||
# include <linux/cache.h>
|
||||
# include <linux/posix_types.h>
|
||||
# include <linux/seqlock.h>
|
||||
# include <linux/string.h>
|
||||
# include <linux/math64.h>
|
||||
#endif
|
||||
|
||||
|
@ -256,6 +259,27 @@ static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
|
|||
a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
|
||||
a->tv_nsec = ns;
|
||||
}
|
||||
|
||||
static inline void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp)
|
||||
{
|
||||
__set_bit(__fd, __fdsetp->fds_bits);
|
||||
}
|
||||
|
||||
static inline void __FD_CLR(unsigned long __fd, __kernel_fd_set *__fdsetp)
|
||||
{
|
||||
__clear_bit(__fd, __fdsetp->fds_bits);
|
||||
}
|
||||
|
||||
static inline int __FD_ISSET(unsigned long __fd, const __kernel_fd_set *__fdsetp)
|
||||
{
|
||||
return test_bit(__fd, __fdsetp->fds_bits);
|
||||
}
|
||||
|
||||
static inline void __FD_ZERO(__kernel_fd_set *__fdsetp)
|
||||
{
|
||||
memset(__fdsetp->fds_bits, 0, sizeof __fdsetp->fds_bits);
|
||||
}
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#define NFDBITS __NFDBITS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue