xref: /illumos-gate/usr/src/lib/libfakekernel/common/kmisc.c (revision 8c69cc8fbe729fa7b091e901c4b50508ccc6bb33)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
14  */
15 
16 #include <sys/types.h>
17 #include <sys/time.h>
18 #include <sys/thread.h>
19 #include <sys/proc.h>
20 #include <sys/zone.h>
21 
22 #include <sys/poll.h>
23 
24 #include <time.h>
25 #include <stdlib.h>
26 #include <unistd.h>
27 
28 #include <fakekernel.h>
29 
30 pri_t minclsyspri = 60;
31 
32 /* Some kernel code takes the address of this. */
33 proc_t p0;
34 
35 proc_t *
36 _curproc(void)
37 {
38 	return (&p0);
39 }
40 
41 zone_t zone0 = {
42 	.zone_name = "global",
43 	.zone_zsched = &p0, 0
44 };
45 
46 zone_t *
47 _curzone(void)
48 {
49 	return (&zone0);
50 }
51 
52 pid_t
53 ddi_get_pid(void)
54 {
55 	return ((pid_t)getpid());
56 }
57 
58 int
59 ddi_strtoul(const char *str, char **endp, int base, unsigned long *res)
60 {
61 	*res = strtoul(str, endp, base);
62 	return (0);
63 }
64 
65 void
66 delay(clock_t ticks)
67 {
68 	int msec = ticks;  /* NB: hz==1000 */
69 	(void) poll(0, 0, msec);
70 }
71 
72 /*
73  * This library does not really need an "init" function, but
74  * providing one the main program can call is an easy way to
75  * make sure this library is loaded into the debugger, and
76  * gives us a way to avoid elfcheck complaints in the build.
77  */
78 void
79 fakekernel_init(void)
80 {
81 }
82