The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/systm.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

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

Cache object: d230ce372d62c9c6b0a8a1209af7ffc2


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.