Skip to content

Commit 1855ece

Browse files
committed
update tools/compat/include/sys/*.h
1 parent 41ed021 commit 1855ece

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+5540
-1022
lines changed

freebsd/sys/user.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
#define LOGINCLASSLEN 17 /* size of returned ki_loginclass */
107107

108108
#ifndef BURN_BRIDGES
109-
#define OCOMMLEN TDNAMLEN
109+
#define OCOMMLEN TDNAMLEN
110110
#define ki_ocomm ki_tdname
111111
#endif
112112

tools/compat/include/sys/_bitset.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*-
2+
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3+
*
24
* Copyright (c) 2008, Jeffrey Roberson <[email protected]>
35
* All rights reserved.
46
*
@@ -55,4 +57,10 @@ struct t { \
5557
*/
5658
#define BITSET_DEFINE_VAR(t) BITSET_DEFINE(t, 1)
5759

60+
/*
61+
* Define a default type that can be used while manually specifying size
62+
* to every call.
63+
*/
64+
BITSET_DEFINE(bitset, 1);
65+
5866
#endif /* !_SYS__BITSET_H_ */

tools/compat/include/sys/_callout.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*-
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
*
24
* Copyright (c) 1990, 1993
35
* The Regents of the University of California. All rights reserved.
46
* (c) UNIX System Laboratories, Inc.
@@ -15,7 +17,7 @@
1517
* 2. Redistributions in binary form must reproduce the above copyright
1618
* notice, this list of conditions and the following disclaimer in the
1719
* documentation and/or other materials provided with the distribution.
18-
* 4. Neither the name of the University nor the names of its contributors
20+
* 3. Neither the name of the University nor the names of its contributors
1921
* may be used to endorse or promote products derived from this software
2022
* without specific prior written permission.
2123
*
@@ -46,6 +48,8 @@ LIST_HEAD(callout_list, callout);
4648
SLIST_HEAD(callout_slist, callout);
4749
TAILQ_HEAD(callout_tailq, callout);
4850

51+
typedef void callout_func_t(void *);
52+
4953
struct callout {
5054
union {
5155
LIST_ENTRY(callout) le;
@@ -55,7 +59,7 @@ struct callout {
5559
sbintime_t c_time; /* ticks to the event */
5660
sbintime_t c_precision; /* delta allowed wrt opt */
5761
void *c_arg; /* function argument */
58-
void (*c_func)(void *); /* function to call */
62+
callout_func_t *c_func; /* function to call */
5963
struct lock_object *c_lock; /* lock to handle */
6064
short c_flags; /* User State */
6165
short c_iflags; /* Internal State */

tools/compat/include/sys/_cpuset.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*-
2+
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3+
*
24
* Copyright (c) 2008, Jeffrey Roberson <[email protected]>
35
* All rights reserved.
46
*

tools/compat/include/sys/_iovec.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*-
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
*
24
* Copyright (c) 1982, 1986, 1993, 1994
35
* The Regents of the University of California. All rights reserved.
46
*
@@ -10,7 +12,7 @@
1012
* 2. Redistributions in binary form must reproduce the above copyright
1113
* notice, this list of conditions and the following disclaimer in the
1214
* documentation and/or other materials provided with the distribution.
13-
* 4. Neither the name of the University nor the names of its contributors
15+
* 3. Neither the name of the University nor the names of its contributors
1416
* may be used to endorse or promote products derived from this software
1517
* without specific prior written permission.
1618
*
@@ -33,6 +35,13 @@
3335
#ifndef _COMPAT_SYS__IOVEC_H_
3436
#define _COMPAT_SYS__IOVEC_H_
3537

38+
#include <sys/_types.h>
39+
40+
#ifndef _SIZE_T_DECLARED
41+
typedef __size_t size_t;
42+
#define _SIZE_T_DECLARED
43+
#endif
44+
3645
struct iovec {
3746
void *iov_base; /* Base address. */
3847
size_t iov_len; /* Length. */

tools/compat/include/sys/_lock.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*-
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
*
24
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
35
*
46
* Redistribution and use in source and binary forms, with or without
@@ -38,4 +40,38 @@ struct lock_object {
3840
struct witness *lo_witness; /* Data for witness. */
3941
};
4042

43+
#ifdef _KERNEL
44+
/*
45+
* If any of WITNESS, INVARIANTS, or KTR_LOCK KTR tracing has been enabled,
46+
* then turn on LOCK_DEBUG. When this option is on, extra debugging
47+
* facilities such as tracking the file and line number of lock operations
48+
* are enabled. Also, mutex locking operations are not inlined to avoid
49+
* bloat from all the extra debugging code. We also have to turn on all the
50+
* calling conventions for this debugging code in modules so that modules can
51+
* work with both debug and non-debug kernels.
52+
*/
53+
#if (defined(KLD_MODULE) && !defined(KLD_TIED)) || defined(WITNESS) || defined(INVARIANTS) || \
54+
defined(LOCK_PROFILING) || defined(KTR)
55+
#define LOCK_DEBUG 1
56+
#else
57+
#define LOCK_DEBUG 0
58+
#endif
59+
60+
/*
61+
* In the LOCK_DEBUG case, use the filename and line numbers for debugging
62+
* operations. Otherwise, use default values to avoid the unneeded bloat.
63+
*/
64+
#if LOCK_DEBUG > 0
65+
#define LOCK_FILE_LINE_ARG_DEF , const char *file, int line
66+
#define LOCK_FILE_LINE_ARG , file, line
67+
#define LOCK_FILE __FILE__
68+
#define LOCK_LINE __LINE__
69+
#else
70+
#define LOCK_FILE_LINE_ARG_DEF
71+
#define LOCK_FILE_LINE_ARG
72+
#define LOCK_FILE NULL
73+
#define LOCK_LINE 0
74+
#endif
75+
#endif /* _KERNEL */
76+
4177
#endif /* !_SYS__LOCK_H_ */

tools/compat/include/sys/_mutex.h

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,66 @@
1-
/*
2-
* Copyright (c) 2010 Kip Macy All rights reserved.
3-
* Copyright (c) 2013 Patrick Kelsey. All rights reserved.
4-
* Copyright (C) 2017-2021 THL A29 Limited, a Tencent company.
5-
* All rights reserved.
1+
/*-
2+
* SPDX-License-Identifier: BSD-3-Clause
63
*
7-
* Redistribution and use in source and binary forms, with or without
8-
* modification, are permitted provided that the following conditions are met:
4+
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
95
*
10-
* 1. Redistributions of source code must retain the above copyright notice, this
11-
* list of conditions and the following disclaimer.
12-
* 2. Redistributions in binary form must reproduce the above copyright notice,
13-
* this list of conditions and the following disclaimer in the documentation
14-
* and/or other materials provided with the distribution.
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions
8+
* are met:
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
* 3. Berkeley Software Design Inc's name may not be used to endorse or
15+
* promote products derived from this software without specific prior
16+
* written permission.
1517
*
16-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20-
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18+
* THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
22+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28+
* SUCH DAMAGE.
2629
*
30+
* $FreeBSD$
2731
*/
2832

2933
#ifndef _SYS__MUTEX_H_
30-
#define _SYS__MUTEX_H_
34+
#define _SYS__MUTEX_H_
35+
36+
#include <sys/_types.h>
3137

3238
/*
33-
* Sleep/spin mutex
39+
* Sleep/spin mutex.
40+
*
41+
* All mutex implementations must always have a member called mtx_lock.
42+
* Other locking primitive structures are not allowed to use this name
43+
* for their members.
44+
* If this rule needs to change, the bits in the mutex implementation must
45+
* be modified appropriately.
3446
*/
3547
struct mtx {
36-
struct lock_object lock_object;
37-
void* mtx_lock;
48+
struct lock_object lock_object; /* Common lock properties. */
49+
volatile uintptr_t mtx_lock; /* Owner and flags. */
3850
};
3951

4052
/*
4153
* Members of struct mtx_padalign must mirror members of struct mtx.
4254
* mtx_padalign mutexes can use the mtx(9) API transparently without
4355
* modification.
56+
* Pad-aligned mutexes used within structures should generally be the
57+
* first member of the struct. Otherwise, the compiler can generate
58+
* additional padding for the struct to keep a correct alignment for
59+
* the mutex.
4460
*/
4561
struct mtx_padalign {
46-
struct lock_object lock_object;
47-
void* mtx_lock;
62+
struct lock_object lock_object; /* Common lock properties. */
63+
volatile uintptr_t mtx_lock; /* Owner and flags. */
4864
} __attribute__((__aligned__(64)));
4965

50-
#endif
66+
#endif /* !_SYS__MUTEX_H_ */

tools/compat/include/sys/_rwlock.h

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,61 @@
1-
/*
2-
* Copyright (c) 2010 Kip Macy All rights reserved.
3-
* Copyright (c) 2013 Patrick Kelsey. All rights reserved.
4-
* Copyright (C) 2017-2021 THL A29 Limited, a Tencent company.
5-
* All rights reserved.
1+
/*-
2+
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
63
*
7-
* Redistribution and use in source and binary forms, with or without
8-
* modification, are permitted provided that the following conditions are met:
4+
* Copyright (c) 2006 John Baldwin <[email protected]>
95
*
10-
* 1. Redistributions of source code must retain the above copyright notice, this
11-
* list of conditions and the following disclaimer.
12-
* 2. Redistributions in binary form must reproduce the above copyright notice,
13-
* this list of conditions and the following disclaimer in the documentation
14-
* and/or other materials provided with the distribution.
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions
8+
* are met:
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
1514
*
16-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20-
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25+
* SUCH DAMAGE.
2626
*
27+
* $FreeBSD$
2728
*/
2829

2930
#ifndef _SYS__RWLOCK_H_
30-
#define _SYS__RWLOCK_H_
31-
31+
#define _SYS__RWLOCK_H_
3232

3333
/*
3434
* Reader/writer lock.
35+
*
36+
* All reader/writer lock implementations must always have a member
37+
* called rw_lock. Other locking primitive structures are not allowed to
38+
* use this name for their members.
39+
* If this rule needs to change, the bits in the reader/writer lock
40+
* implementation must be modified appropriately.
3541
*/
3642
struct rwlock {
37-
struct lock_object lock_object;
38-
void* rw_lock;
43+
struct lock_object lock_object;
44+
volatile uintptr_t rw_lock;
3945
};
4046

47+
/*
48+
* Members of struct rwlock_padalign must mirror members of struct rwlock.
49+
* rwlock_padalign rwlocks can use the rwlock(9) API transparently without
50+
* modification.
51+
* Pad-aligned rwlocks used within structures should generally be the
52+
* first member of the struct. Otherwise, the compiler can generate
53+
* additional padding for the struct to keep a correct alignment for
54+
* the rwlock.
55+
*/
4156
struct rwlock_padalign {
42-
struct lock_object lock_object;
43-
void* rw_lock;
57+
struct lock_object lock_object;
58+
volatile uintptr_t rw_lock;
4459
} __attribute__((__aligned__(64)));
4560

46-
#endif
61+
#endif /* !_SYS__RWLOCK_H_ */

tools/compat/include/sys/_sockaddr_storage.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*-
2+
* SPDX-License-Identifier: BSD-3-Clause
3+
*
24
* Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
35
* The Regents of the University of California. All rights reserved.
46
*
@@ -10,7 +12,7 @@
1012
* 2. Redistributions in binary form must reproduce the above copyright
1113
* notice, this list of conditions and the following disclaimer in the
1214
* documentation and/or other materials provided with the distribution.
13-
* 4. Neither the name of the University nor the names of its contributors
15+
* 3. Neither the name of the University nor the names of its contributors
1416
* may be used to endorse or promote products derived from this software
1517
* without specific prior written permission.
1618
*

tools/compat/include/sys/_sx.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/*-
2+
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3+
*
24
* Copyright (c) 2007 Attilio Rao <[email protected]>
35
* All rights reserved.
46
*
@@ -36,7 +38,7 @@
3638
*/
3739
struct sx {
3840
struct lock_object lock_object;
39-
void* sx_lock;
41+
volatile uintptr_t sx_lock;
4042
};
4143

4244
#endif /* !_SYS__SX_H_ */

0 commit comments

Comments
 (0)