Sat Jul 29 11:58:53 2023 UTC ()
Sprinkle __inline to compat_100___kevent50_{fetch_changes,put_events}


(rin)
diff -r1.3 -r1.4 src/sys/compat/sys/event.h

cvs diff -r1.3 -r1.4 src/sys/compat/sys/event.h (switch to unified diff)

--- src/sys/compat/sys/event.h 2023/07/28 18:19:01 1.3
+++ src/sys/compat/sys/event.h 2023/07/29 11:58:53 1.4
@@ -1,123 +1,123 @@ @@ -1,123 +1,123 @@
1/* $NetBSD: event.h,v 1.3 2023/07/28 18:19:01 christos Exp $ */ 1/* $NetBSD: event.h,v 1.4 2023/07/29 11:58:53 rin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> 4 * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 * 27 *
28 * $FreeBSD: src/sys/sys/event.h,v 1.12 2001/02/24 01:44:03 jlemon Exp $ 28 * $FreeBSD: src/sys/sys/event.h,v 1.12 2001/02/24 01:44:03 jlemon Exp $
29 */ 29 */
30 30
31#ifndef _COMPAT_SYS_EVENT_H_ 31#ifndef _COMPAT_SYS_EVENT_H_
32#define _COMPAT_SYS_EVENT_H_ 32#define _COMPAT_SYS_EVENT_H_
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35struct timespec; 35struct timespec;
36 36
37#ifdef _KERNEL 37#ifdef _KERNEL
38#include <lib/libkern/libkern.h> 38#include <lib/libkern/libkern.h>
39#else 39#else
40#include <string.h> 40#include <string.h>
41#endif 41#endif
42 42
43struct kevent100 { 43struct kevent100 {
44 uintptr_t ident; /* identifier for this event */ 44 uintptr_t ident; /* identifier for this event */
45 uint32_t filter; /* filter for event */ 45 uint32_t filter; /* filter for event */
46 uint32_t flags; /* action flags for kqueue */ 46 uint32_t flags; /* action flags for kqueue */
47 uint32_t fflags; /* filter flag value */ 47 uint32_t fflags; /* filter flag value */
48 int64_t data; /* filter data value */ 48 int64_t data; /* filter data value */
49 void *udata; /* opaque user data identifier */ 49 void *udata; /* opaque user data identifier */
50}; 50};
51 51
52static __inline void 52static __inline void
53kevent100_to_kevent(const struct kevent100 *kev100, struct kevent *kev) 53kevent100_to_kevent(const struct kevent100 *kev100, struct kevent *kev)
54{ 54{
55 memset(kev, 0, sizeof(*kev)); 55 memset(kev, 0, sizeof(*kev));
56 memcpy(kev, kev100, sizeof(*kev100)); 56 memcpy(kev, kev100, sizeof(*kev100));
57} 57}
58 58
59static __inline void 59static __inline void
60kevent_to_kevent100(const struct kevent *kev, struct kevent100 *kev100) 60kevent_to_kevent100(const struct kevent *kev, struct kevent100 *kev100)
61{ 61{
62 memcpy(kev100, kev, sizeof(*kev100)); 62 memcpy(kev100, kev, sizeof(*kev100));
63} 63}
64 64
65#ifdef _KERNEL 65#ifdef _KERNEL
66static int 66static __inline int
67compat_100___kevent50_fetch_changes(void *ctx, const struct kevent *changelist, 67compat_100___kevent50_fetch_changes(void *ctx, const struct kevent *changelist,
68 struct kevent *changes, size_t index, int n) 68 struct kevent *changes, size_t index, int n)
69{ 69{
70 int error, i; 70 int error, i;
71 struct kevent100 *buf; 71 struct kevent100 *buf;
72 const size_t buf_size = sizeof(*buf) * n; 72 const size_t buf_size = sizeof(*buf) * n;
73 const struct kevent100 *changelist100 = (const struct kevent100 *)changelist; 73 const struct kevent100 *changelist100 = (const struct kevent100 *)changelist;
74 74
75 KASSERT(n >= 0); 75 KASSERT(n >= 0);
76 76
77 buf = kmem_alloc(buf_size, KM_SLEEP); 77 buf = kmem_alloc(buf_size, KM_SLEEP);
78 78
79 error = copyin(changelist100 + index, buf, buf_size); 79 error = copyin(changelist100 + index, buf, buf_size);
80 if (error != 0) 80 if (error != 0)
81 goto leave; 81 goto leave;
82 82
83 for (i = 0; i < n; i++) 83 for (i = 0; i < n; i++)
84 kevent100_to_kevent(buf + i, changes + i); 84 kevent100_to_kevent(buf + i, changes + i);
85 85
86leave: 86leave:
87 kmem_free(buf, buf_size); 87 kmem_free(buf, buf_size);
88 return error; 88 return error;
89} 89}
90 90
91static int 91static __inline int
92compat_100___kevent50_put_events(void *ctx, struct kevent *events, 92compat_100___kevent50_put_events(void *ctx, struct kevent *events,
93 struct kevent *eventlist, size_t index, int n) 93 struct kevent *eventlist, size_t index, int n)
94{ 94{
95 int error, i; 95 int error, i;
96 struct kevent100 *buf; 96 struct kevent100 *buf;
97 const size_t buf_size = sizeof(*buf) * n; 97 const size_t buf_size = sizeof(*buf) * n;
98 struct kevent100 *eventlist100 = (struct kevent100 *)eventlist; 98 struct kevent100 *eventlist100 = (struct kevent100 *)eventlist;
99 99
100 KASSERT(n >= 0); 100 KASSERT(n >= 0);
101 101
102 buf = kmem_alloc(buf_size, KM_SLEEP); 102 buf = kmem_alloc(buf_size, KM_SLEEP);
103 103
104 for (i = 0; i < n; i++) 104 for (i = 0; i < n; i++)
105 kevent_to_kevent100(events + i, buf + i); 105 kevent_to_kevent100(events + i, buf + i);
106 106
107 error = copyout(buf, eventlist100 + index, buf_size); 107 error = copyout(buf, eventlist100 + index, buf_size);
108 108
109 kmem_free(buf, buf_size); 109 kmem_free(buf, buf_size);
110 return error; 110 return error;
111} 111}
112#endif /* _KERNEL */ 112#endif /* _KERNEL */
113 113
114__BEGIN_DECLS 114__BEGIN_DECLS
115int kevent(int, const struct kevent100 *, size_t, struct kevent100 *, 115int kevent(int, const struct kevent100 *, size_t, struct kevent100 *,
116 size_t, const struct timespec50 *); 116 size_t, const struct timespec50 *);
117int __kevent50(int, const struct kevent100 *, size_t, struct kevent100 *, 117int __kevent50(int, const struct kevent100 *, size_t, struct kevent100 *,
118 size_t, const struct timespec *); 118 size_t, const struct timespec *);
119int __kevent100(int, const struct kevent *, size_t, struct kevent *, 119int __kevent100(int, const struct kevent *, size_t, struct kevent *,
120 size_t, const struct timespec *); 120 size_t, const struct timespec *);
121__END_DECLS 121__END_DECLS
122 122
123#endif /* !_COMPAT_SYS_EVENT_H_ */ 123#endif /* !_COMPAT_SYS_EVENT_H_ */