4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 2013 by Delphix. All rights reserved.
25 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
26 */
27
28 #ifndef _SYS_ZFS_CONTEXT_H
29 #define _SYS_ZFS_CONTEXT_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define _SYS_MUTEX_H
36 #define _SYS_RWLOCK_H
37 #define _SYS_CONDVAR_H
38 #define _SYS_SYSTM_H
39 #define _SYS_T_LOCK_H
40 #define _SYS_VNODE_H
41 #define _SYS_VFS_H
42 #define _SYS_SUNDDI_H
43 #define _SYS_CALLB_H
44
499 #define gethrestime(t) \
500 do {\
501 (t)->tv_sec = gethrestime_sec();\
502 (t)->tv_nsec = 0;\
503 } while (0);
504
505 #define max_ncpus 64
506
507 #define minclsyspri 60
508 #define maxclsyspri 99
509
510 #define CPU_SEQID (thr_self() & (max_ncpus - 1))
511
512 #define kcred NULL
513 #define CRED() NULL
514
515 #define ptob(x) ((x) * PAGESIZE)
516
517 extern uint64_t physmem;
518
519 extern int highbit(ulong_t i);
520 extern int random_get_bytes(uint8_t *ptr, size_t len);
521 extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len);
522
523 extern void kernel_init(int);
524 extern void kernel_fini(void);
525
526 struct spa;
527 extern void nicenum(uint64_t num, char *buf);
528 extern void show_pool_stats(struct spa *);
529
530 typedef struct callb_cpr {
531 kmutex_t *cc_lockp;
532 } callb_cpr_t;
533
534 #define CALLB_CPR_INIT(cp, lockp, func, name) { \
535 (cp)->cc_lockp = lockp; \
536 }
537
538 #define CALLB_CPR_SAFE_BEGIN(cp) { \
539 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
25 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
26 */
27
28 #ifndef _SYS_ZFS_CONTEXT_H
29 #define _SYS_ZFS_CONTEXT_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define _SYS_MUTEX_H
36 #define _SYS_RWLOCK_H
37 #define _SYS_CONDVAR_H
38 #define _SYS_SYSTM_H
39 #define _SYS_T_LOCK_H
40 #define _SYS_VNODE_H
41 #define _SYS_VFS_H
42 #define _SYS_SUNDDI_H
43 #define _SYS_CALLB_H
44
499 #define gethrestime(t) \
500 do {\
501 (t)->tv_sec = gethrestime_sec();\
502 (t)->tv_nsec = 0;\
503 } while (0);
504
505 #define max_ncpus 64
506
507 #define minclsyspri 60
508 #define maxclsyspri 99
509
510 #define CPU_SEQID (thr_self() & (max_ncpus - 1))
511
512 #define kcred NULL
513 #define CRED() NULL
514
515 #define ptob(x) ((x) * PAGESIZE)
516
517 extern uint64_t physmem;
518
519 extern int highbit64(uint64_t i);
520 extern int random_get_bytes(uint8_t *ptr, size_t len);
521 extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len);
522
523 extern void kernel_init(int);
524 extern void kernel_fini(void);
525
526 struct spa;
527 extern void nicenum(uint64_t num, char *buf);
528 extern void show_pool_stats(struct spa *);
529
530 typedef struct callb_cpr {
531 kmutex_t *cc_lockp;
532 } callb_cpr_t;
533
534 #define CALLB_CPR_INIT(cp, lockp, func, name) { \
535 (cp)->cc_lockp = lockp; \
536 }
537
538 #define CALLB_CPR_SAFE_BEGIN(cp) { \
539 ASSERT(MUTEX_HELD((cp)->cc_lockp)); \
|