xref: /illumos-gate/usr/src/lib/libumem/common/stub_stand.c (revision 533affcbc7fc4d0c8132976ea454aaa715fe2307)
1 /*
2  * CDDL HEADER START
3  *
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 /*
23  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 /*
28  * Copyright (c) 2012, Joyent, Inc.  All rights reserved.
29  */
30 
31 /*
32  * Stubs for the standalone to reduce the dependence on external libraries
33  */
34 
35 #include <string.h>
36 #include "misc.h"
37 
38 /*ARGSUSED*/
39 int
40 cond_init(cond_t *cvp, int type, void *arg)
41 {
42 	return (0);
43 }
44 
45 /*ARGSUSED*/
46 int
47 cond_destroy(cond_t *cvp)
48 {
49 	return (0);
50 }
51 
52 /*ARGSUSED*/
53 int
54 cond_wait(cond_t *cv, mutex_t *mutex)
55 {
56 	umem_panic("attempt to wait on standumem cv %p", cv);
57 
58 	/*NOTREACHED*/
59 	return (0);
60 }
61 
62 /*ARGSUSED*/
63 int
64 cond_broadcast(cond_t *cvp)
65 {
66 	return (0);
67 }
68 
69 /*ARGSUSED*/
70 int
71 pthread_setcancelstate(int state, int *oldstate)
72 {
73 	return (0);
74 }
75 
76 thread_t
77 thr_self(void)
78 {
79 	return ((thread_t)1);
80 }
81 
82 static mutex_t _mp = DEFAULTMUTEX;
83 
84 /*ARGSUSED*/
85 int
86 mutex_init(mutex_t *mp, int type, void *arg)
87 {
88 	(void) memcpy(mp, &_mp, sizeof (mutex_t));
89 	return (0);
90 }
91 
92 /*ARGSUSED*/
93 int
94 mutex_destroy(mutex_t *mp)
95 {
96 	return (0);
97 }
98 
99 /*ARGSUSED*/
100 int
101 _mutex_held(void *mp)
102 {
103 	return (1);
104 }
105 
106 /*ARGSUSED*/
107 int
108 mutex_lock(mutex_t *mp)
109 {
110 	return (0);
111 }
112 
113 /*ARGSUSED*/
114 int
115 mutex_trylock(mutex_t *mp)
116 {
117 	return (0);
118 }
119 
120 /*ARGSUSED*/
121 int
122 mutex_unlock(mutex_t *mp)
123 {
124 	return (0);
125 }
126 
127 int
128 issetugid(void)
129 {
130 	return (1);
131 }
132 
133 int
134 _tmem_get_nentries(void)
135 {
136 	return (0);
137 }
138 
139 uintptr_t
140 _tmem_get_base(void)
141 {
142 	return (0);
143 }
144 
145 /*ARGSUSED*/
146 void
147 _tmem_set_cleanup(void (*f)(int, void *))
148 {
149 }
150 
151 int
152 isspace(int c)
153 {
154 	switch (c) {
155 	case ' ':
156 	case '\t':
157 	case '\n':
158 	case '\r':
159 	case '\f':
160 	case '\v':
161 		return (1);
162 	}
163 	return (0);
164 }
165