Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Use common macro for _EV_SET() for integer types



details:   https://anonhg.NetBSD.org/src/rev/7b7fdbe3e3ca
branches:  trunk
changeset: 844280:7b7fdbe3e3ca
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Aug 10 20:33:01 2019 +0000

description:
Use common macro for _EV_SET() for integer types

Deduplicate code.

No functional change change intended.

diffstat:

 sys/sys/event.h |  61 +++++++++++++-------------------------------------------
 1 files changed, 14 insertions(+), 47 deletions(-)

diffs (77 lines):

diff -r eddd60314332 -r 7b7fdbe3e3ca sys/sys/event.h
--- a/sys/sys/event.h   Sat Aug 10 17:03:59 2019 +0000
+++ b/sys/sys/event.h   Sat Aug 10 20:33:01 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: event.h,v 1.35 2019/08/10 15:02:03 kamil Exp $ */
+/*     $NetBSD: event.h,v 1.36 2019/08/10 20:33:01 kamil Exp $ */
 
 /*-
  * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon%FreeBSD.org@localhost>
@@ -75,54 +75,21 @@
        _kevp->udata = reinterpret_cast<intptr_t>(_udata);
 }
 
-static __inline void
-_EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
-    uint32_t _flags, uint32_t _fflags, int64_t _data, int _udata)
-{
-       _EV_SET(_kevp, _ident, _filter, _flags, _fflags, _data,
-           reinterpret_cast<void *>(static_cast<intptr_t>(_udata)));
-}
-
-static __inline void
-_EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
-    uint32_t _flags, uint32_t _fflags, int64_t _data, long int _udata)
-{
-       _EV_SET(_kevp, _ident, _filter, _flags, _fflags, _data,
-           reinterpret_cast<void *>(static_cast<intptr_t>(_udata)));
-}
-
-static __inline void
-_EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
-    uint32_t _flags, uint32_t _fflags, int64_t _data, long long int _udata)
-{
-       _EV_SET(_kevp, _ident, _filter, _flags, _fflags, _data,
-           reinterpret_cast<void *>(static_cast<intptr_t>(_udata)));
+#define _EV_SET_INTEGER_TYPE(_UTYPE)                                   \
+static __inline void                                                   \
+_EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,      \
+    uint32_t _flags, uint32_t _fflags, int64_t _data, _UTYPE _udata)   \
+{                                                                      \
+       _EV_SET(_kevp, _ident, _filter, _flags, _fflags, _data,         \
+           reinterpret_cast<void *>(static_cast<intptr_t>(_udata)));   \
 }
 
-static __inline void
-_EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
-    uint32_t _flags, uint32_t _fflags, int64_t _data, unsigned int _udata)
-{
-       _EV_SET(_kevp, _ident, _filter, _flags, _fflags, _data,
-           reinterpret_cast<void *>(static_cast<intptr_t>(_udata)));
-}
-
-static __inline void
-_EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
-    uint32_t _flags, uint32_t _fflags, int64_t _data, unsigned long int _udata)
-{
-       _EV_SET(_kevp, _ident, _filter, _flags, _fflags, _data,
-           reinterpret_cast<void *>(static_cast<intptr_t>(_udata)));
-}
-
-static __inline void
-_EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
-    uint32_t _flags, uint32_t _fflags, int64_t _data,
-    unsigned long long int _udata)
-{
-       _EV_SET(_kevp, _ident, _filter, _flags, _fflags, _data,
-           reinterpret_cast<void *>(static_cast<intptr_t>(_udata)));
-}
+_EV_SET_INTEGER_TYPE(int)
+_EV_SET_INTEGER_TYPE(long int)
+_EV_SET_INTEGER_TYPE(long long int)
+_EV_SET_INTEGER_TYPE(unsigned int)
+_EV_SET_INTEGER_TYPE(unsigned long int)
+_EV_SET_INTEGER_TYPE(unsigned long long int)
 
 #pragma GCC diagnistic pop
 #else



Home | Main Index | Thread Index | Old Index