1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1982, 1988, 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)systm.h 8.7 (Berkeley) 3/29/95
37 */
38
39 #ifndef _SYS_SYSTM_H_
40 #define _SYS_SYSTM_H_
41
42 #include <sys/cdefs.h>
43 #include <machine/atomic.h>
44 #include <machine/cpufunc.h>
45 #include <sys/callout.h>
46 #include <sys/kassert.h>
47 #include <sys/queue.h>
48 #include <sys/stdint.h> /* for people using printf mainly */
49
50 __NULLABILITY_PRAGMA_PUSH
51
52 #ifdef _KERNEL
53 extern int cold; /* nonzero if we are doing a cold boot */
54 extern int suspend_blocked; /* block suspend due to pending shutdown */
55 extern int rebooting; /* kern_reboot() has been called. */
56 extern const char version[]; /* system version */
57 extern const char compiler_version[]; /* compiler version */
58 extern const char copyright[]; /* system copyright */
59 extern int kstack_pages; /* number of kernel stack pages */
60
61 extern u_long pagesizes[]; /* supported page sizes */
62 extern long physmem; /* physical memory */
63 extern long realmem; /* 'real' memory */
64
65 extern char *rootdevnames[2]; /* names of possible root devices */
66
67 extern int boothowto; /* reboot flags, from console subsystem */
68 extern int bootverbose; /* nonzero to print verbose messages */
69
70 extern int maxusers; /* system tune hint */
71 extern int ngroups_max; /* max # of supplemental groups */
72 extern int vm_guest; /* Running as virtual machine guest? */
73
74 extern u_long maxphys; /* max raw I/O transfer size */
75
76 /*
77 * Detected virtual machine guest types. The intention is to expand
78 * and/or add to the VM_GUEST_VM type if specific VM functionality is
79 * ever implemented (e.g. vendor-specific paravirtualization features).
80 * Keep in sync with vm_guest_sysctl_names[].
81 */
82 enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV,
83 VM_GUEST_VMWARE, VM_GUEST_KVM, VM_GUEST_BHYVE, VM_GUEST_VBOX,
84 VM_GUEST_PARALLELS, VM_GUEST_NVMM, VM_LAST };
85
86 #endif /* KERNEL */
87
88 /*
89 * Align variables.
90 */
91 #define __read_mostly __section(".data.read_mostly")
92 #define __read_frequently __section(".data.read_frequently")
93 #define __exclusive_cache_line __aligned(CACHE_LINE_SIZE) \
94 __section(".data.exclusive_cache_line")
95 #if defined(_STANDALONE)
96 struct ucred;
97 #endif
98
99 #ifdef _KERNEL
100 #include <sys/param.h> /* MAXCPU */
101 #include <sys/pcpu.h> /* curthread */
102 #include <sys/kpilite.h>
103
104 /*
105 * If we have already panic'd and this is the thread that called
106 * panic(), then don't block on any mutexes but silently succeed.
107 * Otherwise, the kernel will deadlock since the scheduler isn't
108 * going to run the thread that holds any lock we need.
109 */
110 #define SCHEDULER_STOPPED_TD(td) ({ \
111 MPASS((td) == curthread); \
112 __predict_false((td)->td_stopsched); \
113 })
114 #define SCHEDULER_STOPPED() SCHEDULER_STOPPED_TD(curthread)
115
116 extern const int osreldate;
117
118 extern const void *zero_region; /* address space maps to a zeroed page */
119
120 extern int unmapped_buf_allowed;
121
122 #ifdef __LP64__
123 #define IOSIZE_MAX iosize_max()
124 #define DEVFS_IOSIZE_MAX devfs_iosize_max()
125 #else
126 #define IOSIZE_MAX SSIZE_MAX
127 #define DEVFS_IOSIZE_MAX SSIZE_MAX
128 #endif
129
130 /*
131 * General function declarations.
132 */
133
134 struct inpcb;
135 struct lock_object;
136 struct malloc_type;
137 struct mtx;
138 struct proc;
139 struct socket;
140 struct thread;
141 struct tty;
142 struct ucred;
143 struct uio;
144 struct _jmp_buf;
145 struct trapframe;
146 struct eventtimer;
147
148 int setjmp(struct _jmp_buf *) __returns_twice;
149 void longjmp(struct _jmp_buf *, int) __dead2;
150 int dumpstatus(vm_offset_t addr, off_t count);
151 int nullop(void);
152 int eopnotsupp(void);
153 int ureadc(int, struct uio *);
154 void hashdestroy(void *, struct malloc_type *, u_long);
155 void *hashinit(int count, struct malloc_type *type, u_long *hashmask);
156 void *hashinit_flags(int count, struct malloc_type *type,
157 u_long *hashmask, int flags);
158 #define HASH_NOWAIT 0x00000001
159 #define HASH_WAITOK 0x00000002
160
161 void *phashinit(int count, struct malloc_type *type, u_long *nentries);
162 void *phashinit_flags(int count, struct malloc_type *type, u_long *nentries,
163 int flags);
164 void g_waitidle(void);
165
166 void cpu_flush_dcache(void *, size_t);
167 void cpu_rootconf(void);
168 void critical_enter_KBI(void);
169 void critical_exit_KBI(void);
170 void critical_exit_preempt(void);
171 void init_param1(void);
172 void init_param2(long physpages);
173 void init_static_kenv(char *, size_t);
174 void tablefull(const char *);
175
176 /*
177 * Allocate per-thread "current" state in the linuxkpi
178 */
179 extern int (*lkpi_alloc_current)(struct thread *, int);
180 int linux_alloc_current_noop(struct thread *, int);
181
182 #if defined(KLD_MODULE) || defined(KTR_CRITICAL) || !defined(_KERNEL) || defined(GENOFFSET)
183 #define critical_enter() critical_enter_KBI()
184 #define critical_exit() critical_exit_KBI()
185 #else
186 static __inline void
critical_enter(void)187 critical_enter(void)
188 {
189 struct thread_lite *td;
190
191 td = (struct thread_lite *)curthread;
192 td->td_critnest++;
193 atomic_interrupt_fence();
194 }
195
196 static __inline void
critical_exit(void)197 critical_exit(void)
198 {
199 struct thread_lite *td;
200
201 td = (struct thread_lite *)curthread;
202 KASSERT(td->td_critnest != 0,
203 ("critical_exit: td_critnest == 0"));
204 atomic_interrupt_fence();
205 td->td_critnest--;
206 atomic_interrupt_fence();
207 if (__predict_false(td->td_owepreempt))
208 critical_exit_preempt();
209
210 }
211 #endif
212
213 #ifdef EARLY_PRINTF
214 typedef void early_putc_t(int ch);
215 extern early_putc_t *early_putc;
216 #endif
217 int kvprintf(char const *, void (*)(int, void*), void *, int,
218 __va_list) __printflike(1, 0);
219 void log(int, const char *, ...) __printflike(2, 3);
220 void log_console(struct uio *);
221 void vlog(int, const char *, __va_list) __printflike(2, 0);
222 int asprintf(char **ret, struct malloc_type *mtp, const char *format,
223 ...) __printflike(3, 4);
224 int printf(const char *, ...) __printflike(1, 2);
225 int snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
226 int sprintf(char *buf, const char *, ...) __printflike(2, 3);
227 int uprintf(const char *, ...) __printflike(1, 2);
228 int vprintf(const char *, __va_list) __printflike(1, 0);
229 int vasprintf(char **ret, struct malloc_type *mtp, const char *format,
230 __va_list ap) __printflike(3, 0);
231 int vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0);
232 int vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0);
233 int vsprintf(char *buf, const char *, __va_list) __printflike(2, 0);
234 int sscanf(const char *, char const * _Nonnull, ...) __scanflike(2, 3);
235 int vsscanf(const char * _Nonnull, char const * _Nonnull, __va_list) __scanflike(2, 0);
236 long strtol(const char *, char **, int);
237 u_long strtoul(const char *, char **, int);
238 quad_t strtoq(const char *, char **, int);
239 u_quad_t strtouq(const char *, char **, int);
240 void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4);
241 void vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0);
242 void hexdump(const void *ptr, int length, const char *hdr, int flags);
243 #define HD_COLUMN_MASK 0xff
244 #define HD_DELIM_MASK 0xff00
245 #define HD_OMIT_COUNT (1 << 16)
246 #define HD_OMIT_HEX (1 << 17)
247 #define HD_OMIT_CHARS (1 << 18)
248
249 #define ovbcopy(f, t, l) bcopy((f), (t), (l))
250 void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len);
251 void bzero(void * _Nonnull buf, size_t len);
252 void explicit_bzero(void * _Nonnull, size_t);
253 int bcmp(const void *b1, const void *b2, size_t len);
254
255 void *memset(void * _Nonnull buf, int c, size_t len);
256 void *memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len);
257 void *memmove(void * _Nonnull dest, const void * _Nonnull src, size_t n);
258 int memcmp(const void *b1, const void *b2, size_t len);
259
260 #ifdef SAN_NEEDS_INTERCEPTORS
261 #define SAN_INTERCEPTOR(func) \
262 __CONCAT(SAN_INTERCEPTOR_PREFIX, __CONCAT(_, func))
263 void *SAN_INTERCEPTOR(memset)(void *, int, size_t);
264 void *SAN_INTERCEPTOR(memcpy)(void *, const void *, size_t);
265 void *SAN_INTERCEPTOR(memmove)(void *, const void *, size_t);
266 int SAN_INTERCEPTOR(memcmp)(const void *, const void *, size_t);
267 #ifndef SAN_RUNTIME
268 #define bcopy(from, to, len) SAN_INTERCEPTOR(memmove)((to), (from), (len))
269 #define bzero(buf, len) SAN_INTERCEPTOR(memset)((buf), 0, (len))
270 #define bcmp(b1, b2, len) SAN_INTERCEPTOR(memcmp)((b1), (b2), (len))
271 #define memset(buf, c, len) SAN_INTERCEPTOR(memset)((buf), (c), (len))
272 #define memcpy(to, from, len) SAN_INTERCEPTOR(memcpy)((to), (from), (len))
273 #define memmove(dest, src, n) SAN_INTERCEPTOR(memmove)((dest), (src), (n))
274 #define memcmp(b1, b2, len) SAN_INTERCEPTOR(memcmp)((b1), (b2), (len))
275 #endif /* !SAN_RUNTIME */
276 #else /* !SAN_NEEDS_INTERCEPTORS */
277 #define bcopy(from, to, len) __builtin_memmove((to), (from), (len))
278 #define bzero(buf, len) __builtin_memset((buf), 0, (len))
279 #define bcmp(b1, b2, len) __builtin_memcmp((b1), (b2), (len))
280 #define memset(buf, c, len) __builtin_memset((buf), (c), (len))
281 #define memcpy(to, from, len) __builtin_memcpy((to), (from), (len))
282 #define memmove(dest, src, n) __builtin_memmove((dest), (src), (n))
283 #define memcmp(b1, b2, len) __builtin_memcmp((b1), (b2), (len))
284 #endif /* SAN_NEEDS_INTERCEPTORS */
285
286 void *memset_early(void * _Nonnull buf, int c, size_t len);
287 #define bzero_early(buf, len) memset_early((buf), 0, (len))
288 void *memcpy_early(void * _Nonnull to, const void * _Nonnull from, size_t len);
289 void *memmove_early(void * _Nonnull dest, const void * _Nonnull src, size_t n);
290 #define bcopy_early(from, to, len) memmove_early((to), (from), (len))
291
292 #define copystr(src, dst, len, outlen) ({ \
293 size_t __r, __len, *__outlen; \
294 \
295 __len = (len); \
296 __outlen = (outlen); \
297 __r = strlcpy((dst), (src), __len); \
298 if (__outlen != NULL) \
299 *__outlen = ((__r >= __len) ? __len : __r + 1); \
300 ((__r >= __len) ? ENAMETOOLONG : 0); \
301 })
302
303 int copyinstr(const void * __restrict udaddr,
304 void * _Nonnull __restrict kaddr, size_t len,
305 size_t * __restrict lencopied);
306 int copyin(const void * __restrict udaddr,
307 void * _Nonnull __restrict kaddr, size_t len);
308 int copyin_nofault(const void * __restrict udaddr,
309 void * _Nonnull __restrict kaddr, size_t len);
310 int copyout(const void * _Nonnull __restrict kaddr,
311 void * __restrict udaddr, size_t len);
312 int copyout_nofault(const void * _Nonnull __restrict kaddr,
313 void * __restrict udaddr, size_t len);
314
315 #ifdef SAN_NEEDS_INTERCEPTORS
316 int SAN_INTERCEPTOR(copyin)(const void *, void *, size_t);
317 int SAN_INTERCEPTOR(copyinstr)(const void *, void *, size_t, size_t *);
318 int SAN_INTERCEPTOR(copyout)(const void *, void *, size_t);
319 #ifndef SAN_RUNTIME
320 #define copyin(u, k, l) SAN_INTERCEPTOR(copyin)((u), (k), (l))
321 #define copyinstr(u, k, l, lc) SAN_INTERCEPTOR(copyinstr)((u), (k), (l), (lc))
322 #define copyout(k, u, l) SAN_INTERCEPTOR(copyout)((k), (u), (l))
323 #endif /* !SAN_RUNTIME */
324 #endif /* SAN_NEEDS_INTERCEPTORS */
325
326 int fubyte(volatile const void *base);
327 long fuword(volatile const void *base);
328 int fuword16(volatile const void *base);
329 int32_t fuword32(volatile const void *base);
330 int64_t fuword64(volatile const void *base);
331 int fueword(volatile const void *base, long *val);
332 int fueword32(volatile const void *base, int32_t *val);
333 int fueword64(volatile const void *base, int64_t *val);
334 int subyte(volatile void *base, int byte);
335 int suword(volatile void *base, long word);
336 int suword16(volatile void *base, int word);
337 int suword32(volatile void *base, int32_t word);
338 int suword64(volatile void *base, int64_t word);
339 uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval);
340 u_long casuword(volatile u_long *p, u_long oldval, u_long newval);
341 int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp,
342 uint32_t newval);
343 int casueword(volatile u_long *p, u_long oldval, u_long *oldvalp,
344 u_long newval);
345
346 int sysbeep(int hertz, sbintime_t duration);
347
348 void hardclock(int cnt, int usermode);
349 void hardclock_sync(int cpu);
350 void softclock(void *);
351 void statclock(int cnt, int usermode);
352 void profclock(int cnt, int usermode, uintfptr_t pc);
353
354 int hardclockintr(void);
355
356 void startprofclock(struct proc *);
357 void stopprofclock(struct proc *);
358 void cpu_startprofclock(void);
359 void cpu_stopprofclock(void);
360 void suspendclock(void);
361 void resumeclock(void);
362 sbintime_t cpu_idleclock(void);
363 void cpu_activeclock(void);
364 void cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt);
365 void cpu_et_frequency(struct eventtimer *et, uint64_t newfreq);
366 extern int cpu_disable_c2_sleep;
367 extern int cpu_disable_c3_sleep;
368
369 char *kern_getenv(const char *name);
370 void freeenv(char *env);
371 int getenv_int(const char *name, int *data);
372 int getenv_uint(const char *name, unsigned int *data);
373 int getenv_long(const char *name, long *data);
374 int getenv_ulong(const char *name, unsigned long *data);
375 int getenv_string(const char *name, char *data, int size);
376 int getenv_int64(const char *name, int64_t *data);
377 int getenv_uint64(const char *name, uint64_t *data);
378 int getenv_quad(const char *name, quad_t *data);
379 int getenv_bool(const char *name, bool *data);
380 bool getenv_is_true(const char *name);
381 bool getenv_is_false(const char *name);
382 int kern_setenv(const char *name, const char *value);
383 int kern_unsetenv(const char *name);
384 int testenv(const char *name);
385
386 int getenv_array(const char *name, void *data, int size, int *psize,
387 int type_size, bool allow_signed);
388 #define GETENV_UNSIGNED false /* negative numbers not allowed */
389 #define GETENV_SIGNED true /* negative numbers allowed */
390
391 typedef uint64_t (cpu_tick_f)(void);
392 void set_cputicker(cpu_tick_f *func, uint64_t freq, bool isvariable);
393 extern cpu_tick_f *cpu_ticks;
394 uint64_t cpu_tickrate(void);
395 uint64_t cputick2usec(uint64_t tick);
396
397 #include <sys/libkern.h>
398
399 /* Initialize the world */
400 void consinit(void);
401 void cpu_initclocks(void);
402 void cpu_initclocks_bsp(void);
403 void cpu_initclocks_ap(void);
404 void usrinfoinit(void);
405
406 /* Finalize the world */
407 void kern_reboot(int) __dead2;
408 void shutdown_nice(int);
409
410 /* Stubs for obsolete functions that used to be for interrupt management */
splhigh(void)411 static __inline intrmask_t splhigh(void) { return 0; }
splimp(void)412 static __inline intrmask_t splimp(void) { return 0; }
splnet(void)413 static __inline intrmask_t splnet(void) { return 0; }
spltty(void)414 static __inline intrmask_t spltty(void) { return 0; }
splx(intrmask_t ipl __unused)415 static __inline void splx(intrmask_t ipl __unused) { return; }
416
417 /*
418 * Common `proc' functions are declared here so that proc.h can be included
419 * less often.
420 */
421 int _sleep(const void * _Nonnull chan, struct lock_object *lock, int pri,
422 const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags);
423 #define msleep(chan, mtx, pri, wmesg, timo) \
424 _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), \
425 tick_sbt * (timo), 0, C_HARDCLOCK)
426 #define msleep_sbt(chan, mtx, pri, wmesg, bt, pr, flags) \
427 _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), (bt), (pr), \
428 (flags))
429 int msleep_spin_sbt(const void * _Nonnull chan, struct mtx *mtx,
430 const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags);
431 #define msleep_spin(chan, mtx, wmesg, timo) \
432 msleep_spin_sbt((chan), (mtx), (wmesg), tick_sbt * (timo), \
433 0, C_HARDCLOCK)
434 int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr,
435 int flags);
436 static __inline int
pause(const char * wmesg,int timo)437 pause(const char *wmesg, int timo)
438 {
439 return (pause_sbt(wmesg, tick_sbt * timo, 0, C_HARDCLOCK));
440 }
441 #define pause_sig(wmesg, timo) \
442 pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK | C_CATCH)
443 #define tsleep(chan, pri, wmesg, timo) \
444 _sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo), \
445 0, C_HARDCLOCK)
446 #define tsleep_sbt(chan, pri, wmesg, bt, pr, flags) \
447 _sleep((chan), NULL, (pri), (wmesg), (bt), (pr), (flags))
448 void wakeup(const void *chan);
449 void wakeup_one(const void *chan);
450 void wakeup_any(const void *chan);
451
452 /*
453 * Common `struct cdev *' stuff are declared here to avoid #include poisoning
454 */
455
456 struct cdev;
457 dev_t dev2udev(struct cdev *x);
458 const char *devtoname(struct cdev *cdev);
459
460 #ifdef __LP64__
461 size_t devfs_iosize_max(void);
462 size_t iosize_max(void);
463 #endif
464
465 int poll_no_poll(int events);
466
467 /* XXX: Should be void nanodelay(u_int nsec); */
468 void DELAY(int usec);
469
470 int kcmp_cmp(uintptr_t a, uintptr_t b);
471
472 /* Root mount holdback API */
473 struct root_hold_token {
474 int flags;
475 const char *who;
476 TAILQ_ENTRY(root_hold_token) list;
477 };
478
479 struct root_hold_token *root_mount_hold(const char *identifier);
480 void root_mount_hold_token(const char *identifier, struct root_hold_token *h);
481 void root_mount_rel(struct root_hold_token *h);
482 int root_mounted(void);
483
484 /*
485 * Unit number allocation API. (kern/subr_unit.c)
486 */
487 struct unrhdr;
488 #define UNR_NO_MTX ((void *)(uintptr_t)-1)
489 struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex);
490 void init_unrhdr(struct unrhdr *uh, int low, int high, struct mtx *mutex);
491 void delete_unrhdr(struct unrhdr *uh);
492 void clear_unrhdr(struct unrhdr *uh);
493 void clean_unrhdr(struct unrhdr *uh);
494 void clean_unrhdrl(struct unrhdr *uh);
495 int alloc_unr(struct unrhdr *uh);
496 int alloc_unr_specific(struct unrhdr *uh, u_int item);
497 int alloc_unrl(struct unrhdr *uh);
498 void free_unr(struct unrhdr *uh, u_int item);
499 void *create_iter_unr(struct unrhdr *uh);
500 int next_iter_unr(void *handle);
501 void free_iter_unr(void *handle);
502
503 #ifndef __LP64__
504 #define UNR64_LOCKED
505 #endif
506
507 struct unrhdr64 {
508 uint64_t counter;
509 };
510
511 static __inline void
new_unrhdr64(struct unrhdr64 * unr64,uint64_t low)512 new_unrhdr64(struct unrhdr64 *unr64, uint64_t low)
513 {
514
515 unr64->counter = low;
516 }
517
518 #ifdef UNR64_LOCKED
519 uint64_t alloc_unr64(struct unrhdr64 *);
520 #else
521 static __inline uint64_t
alloc_unr64(struct unrhdr64 * unr64)522 alloc_unr64(struct unrhdr64 *unr64)
523 {
524
525 return (atomic_fetchadd_64(&unr64->counter, 1));
526 }
527 #endif
528
529 void intr_prof_stack_use(struct thread *td, struct trapframe *frame);
530
531 void counted_warning(unsigned *counter, const char *msg);
532
533 /*
534 * APIs to manage deprecation and obsolescence.
535 */
536 void _gone_in(int major, const char *msg);
537 void _gone_in_dev(device_t dev, int major, const char *msg);
538 #ifdef NO_OBSOLETE_CODE
539 #define __gone_ok(m, msg) \
540 _Static_assert(m < P_OSREL_MAJOR(__FreeBSD_version)), \
541 "Obsolete code: " msg);
542 #else
543 #define __gone_ok(m, msg)
544 #endif
545 #define gone_in(major, msg) __gone_ok(major, msg) _gone_in(major, msg)
546 #define gone_in_dev(dev, major, msg) __gone_ok(major, msg) _gone_in_dev(dev, major, msg)
547
548 #if defined(INVARIANTS) || defined(WITNESS)
549 #define __diagused
550 #else
551 #define __diagused __unused
552 #endif
553
554 #endif /* _KERNEL */
555
556 __NULLABILITY_PRAGMA_POP
557 #endif /* !_SYS_SYSTM_H_ */
558