Source-Changes-HG archive

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

[src/trunk]: src Switch kevent udata from intptr_t void*



details:   https://anonhg.NetBSD.org/src/rev/b311f61a7664
branches:  trunk
changeset: 454980:b311f61a7664
user:      kamil <kamil%NetBSD.org@localhost>
date:      Thu Oct 03 22:16:52 2019 +0000

description:
Switch kevent udata from intptr_t void*

Synchromize the struct field format with other BSDs and Darwin.

No ABI change between older and newer struct form on the ports.

The change will require no changes to most C users during the transition
period as the header keeps a caller cast.

Discussed with core@ and there were no objections for this move.

diffstat:

 external/bsd/libevent/dist/kqueue.c   |   9 ++++--
 sys/compat/linux/common/linux_sched.c |   6 ++--
 sys/compat/netbsd32/netbsd32.h        |   4 +-
 sys/compat/netbsd32/netbsd32_conv.h   |   6 ++--
 sys/sys/event.h                       |  45 ++--------------------------------
 5 files changed, 17 insertions(+), 53 deletions(-)

diffs (175 lines):

diff -r da8cc47cba80 -r b311f61a7664 external/bsd/libevent/dist/kqueue.c
--- a/external/bsd/libevent/dist/kqueue.c       Thu Oct 03 20:29:19 2019 +0000
+++ b/external/bsd/libevent/dist/kqueue.c       Thu Oct 03 22:16:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kqueue.c,v 1.1.1.3 2017/01/31 21:14:52 christos Exp $  */
+/*     $NetBSD: kqueue.c,v 1.2 2019/10/03 22:16:52 kamil Exp $ */
 /*     $OpenBSD: kqueue.c,v 1.5 2002/07/10 14:41:31 art Exp $  */
 
 /*
@@ -29,7 +29,7 @@
  */
 #include "event2/event-config.h"
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: kqueue.c,v 1.1.1.3 2017/01/31 21:14:52 christos Exp $");
+__RCSID("$NetBSD: kqueue.c,v 1.2 2019/10/03 22:16:52 kamil Exp $");
 #include "evconfig-private.h"
 
 #ifdef EVENT__HAVE_KQUEUE
@@ -53,7 +53,10 @@
 /* Some platforms apparently define the udata field of struct kevent as
  * intptr_t, whereas others define it as void*.  There doesn't seem to be an
  * easy way to tell them apart via autoconf, so we need to use OS macros. */
-#if defined(EVENT__HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__darwin__) && !defined(__APPLE__) && !defined(__CloudABI__)
+#if defined(__NetBSD__)
+#define PTR_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(x))
+#define INT_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(intptr_t)(x))
+#elif defined(EVENT__HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__darwin__) && !defined(__APPLE__) && !defined(__CloudABI__)
 #define PTR_TO_UDATA(x)        ((intptr_t)(x))
 #define INT_TO_UDATA(x) ((intptr_t)(x))
 #else
diff -r da8cc47cba80 -r b311f61a7664 sys/compat/linux/common/linux_sched.c
--- a/sys/compat/linux/common/linux_sched.c     Thu Oct 03 20:29:19 2019 +0000
+++ b/sys/compat/linux/common/linux_sched.c     Thu Oct 03 22:16:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_sched.c,v 1.71 2018/04/16 14:51:59 kamil Exp $   */
+/*     $NetBSD: linux_sched.c,v 1.72 2019/10/03 22:16:53 kamil Exp $   */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.71 2018/04/16 14:51:59 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.72 2019/10/03 22:16:53 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -255,7 +255,7 @@
        mutex_enter(p->p_lock);
        lwp_lock(l2);
        spc = &l2->l_cpu->ci_schedstate;
-       if ((l->l_flag & (LW_WREBOOT | LW_WSUSPEND | LW_WEXIT)) == 0) {
+       if ((l->l_flag & (LW_WREBOOT | LW_DBGSUSPEND | LW_WSUSPEND | LW_WEXIT)) == 0) {
                if (p->p_stat == SSTOP || (p->p_sflag & PS_STOPPING) != 0) {
                        KASSERT(l2->l_wchan == NULL);
                        l2->l_stat = LSSTOP;
diff -r da8cc47cba80 -r b311f61a7664 sys/compat/netbsd32/netbsd32.h
--- a/sys/compat/netbsd32/netbsd32.h    Thu Oct 03 20:29:19 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32.h    Thu Oct 03 22:16:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32.h,v 1.126 2019/09/26 01:30:46 christos Exp $  */
+/*     $NetBSD: netbsd32.h,v 1.127 2019/10/03 22:16:53 kamil Exp $     */
 
 /*
  * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -1003,7 +1003,7 @@
        uint32_t                flags;
        uint32_t                fflags;
        netbsd32_int64          data;
-       netbsd32_intptr_t       udata;
+       netbsd32_pointer_t      udata;
 };
 
 /* from <sys/sched.h> */
diff -r da8cc47cba80 -r b311f61a7664 sys/compat/netbsd32/netbsd32_conv.h
--- a/sys/compat/netbsd32/netbsd32_conv.h       Thu Oct 03 20:29:19 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32_conv.h       Thu Oct 03 22:16:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_conv.h,v 1.39 2019/09/22 22:59:38 christos Exp $      */
+/*     $NetBSD: netbsd32_conv.h,v 1.40 2019/10/03 22:16:53 kamil Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -754,7 +754,7 @@
        ke->flags = ke32->flags;
        ke->fflags = ke32->fflags;
        ke->data = ke32->data;
-       ke->udata = ke32->udata;
+       ke->udata = NETBSD32PTR64(ke32->udata);
 }
 
 static __inline void
@@ -765,7 +765,7 @@
        ke32->flags = ke->flags;
        ke32->fflags = ke->fflags;
        ke32->data = ke->data;
-       ke32->udata = ke->udata;
+       NETBSD32PTR32(ke32->udata, ke->udata);
 }
 
 static __inline void
diff -r da8cc47cba80 -r b311f61a7664 sys/sys/event.h
--- a/sys/sys/event.h   Thu Oct 03 20:29:19 2019 +0000
+++ b/sys/sys/event.h   Thu Oct 03 22:16:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: event.h,v 1.37 2019/08/10 23:47:13 kamil Exp $ */
+/*     $NetBSD: event.h,v 1.38 2019/10/03 22:16:52 kamil Exp $ */
 
 /*-
  * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon%FreeBSD.org@localhost>
@@ -52,17 +52,9 @@
        uint32_t        flags;          /* action flags for kqueue */
        uint32_t        fflags;         /* filter flag value */
        int64_t         data;           /* filter data value */
-       intptr_t        udata;          /* opaque user data identifier */
+       void            *udata;         /* opaque user data identifier */
 };
 
-#ifdef __cplusplus
-#define EV_SET(kevp, ident, filter, flags, fflags, data, udata)        \
-    _EV_SET((kevp), __CAST(uintptr_t, (ident)), (filter), (flags), \
-    (fflags), (data), (udata))
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion-null"
-
 static __inline void
 _EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
     uint32_t _flags, uint32_t _fflags, int64_t _data, void *_udata)
@@ -72,43 +64,12 @@
        _kevp->flags = _flags;
        _kevp->fflags = _fflags;
        _kevp->data = _data;
-       _kevp->udata = reinterpret_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)));   \
-}
-
-_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 diagnostic pop
-#else
-static __inline void
-_EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
-    uint32_t _flags, uint32_t _fflags, int64_t _data, intptr_t _udata)
-{
-       _kevp->ident = _ident;
-       _kevp->filter = _filter;
-       _kevp->flags = _flags;
-       _kevp->fflags = _fflags;
-       _kevp->data = _data;
        _kevp->udata = _udata;
 }
 
 #define EV_SET(kevp, ident, filter, flags, fflags, data, udata)        \
     _EV_SET((kevp), __CAST(uintptr_t, (ident)), (filter), (flags), \
-    (fflags), (data), __CAST(intptr_t, (udata)))
-#endif
+    (fflags), (data), __CAST(void *, (udata)))
 
 /* actions */
 #define        EV_ADD          0x0001U         /* add event to kq (implies ENABLE) */



Home | Main Index | Thread Index | Old Index