make sure that the pseudo_set isn't empty.
[unix-history] / sys / kern / subr_xxx.c
CommitLineData
15637ed4
RG
1/*
2 * Copyright (c) 1982, 1986, 1991 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
600f7f07 33 * from: @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91
4c45483e 34 * $Id: subr_xxx.c,v 1.2 1993/10/16 15:24:45 rgrimes Exp $
15637ed4
RG
35 */
36
37/*
38 * Miscellaneous trivial functions, including many
39 * that are often inline-expanded or done in assembler.
40 */
41#include "param.h"
42#include "systm.h"
43#include "machine/cpu.h"
44
45/*
46 * Unsupported device function (e.g. writing to read-only device).
47 */
4c45483e 48int
15637ed4
RG
49enodev()
50{
51
52 return (ENODEV);
53}
54
55/*
56 * Unconfigured device function; driver not configured.
57 */
4c45483e 58int
15637ed4
RG
59enxio()
60{
61
62 return (ENXIO);
63}
64
65/*
66 * Unsupported ioctl function.
67 */
4c45483e 68int
15637ed4
RG
69enoioctl()
70{
71
72 return (ENOTTY);
73}
74
75/*
76 * Unsupported system function.
77 * This is used for an otherwise-reasonable operation
78 * that is not supported by the current system binary.
79 */
4c45483e 80int
15637ed4
RG
81enosys()
82{
83
84 return (ENOSYS);
85}
86
87/*
88 * Return error for operation not supported
89 * on a specific object or file type.
90 */
4c45483e 91int
15637ed4
RG
92eopnotsupp()
93{
94
95 return (EOPNOTSUPP);
96}
97
98/*
99 * Generic null operation, always returns success.
100 */
4c45483e 101int
15637ed4
RG
102nullop()
103{
104
105 return (0);
106}
107
108/*
109 * Definitions of various trivial functions;
110 * usually expanded inline rather than being defined here.
111 */
112#ifdef NEED_MINMAX
113imin(a, b)
114 int a, b;
115{
116
117 return (a < b ? a : b);
118}
119
120imax(a, b)
121 int a, b;
122{
123
124 return (a > b ? a : b);
125}
126
127unsigned int
128min(a, b)
129 unsigned int a, b;
130{
131
132 return (a < b ? a : b);
133}
134
135unsigned int
136max(a, b)
137 unsigned int a, b;
138{
139
140 return (a > b ? a : b);
141}
142
143long
144lmin(a, b)
145 long a, b;
146{
147
148 return (a < b ? a : b);
149}
150
151long
152lmax(a, b)
153 long a, b;
154{
155
156 return (a > b ? a : b);
157}
158
159unsigned long
160ulmin(a, b)
161 unsigned long a, b;
162{
163
164 return (a < b ? a : b);
165}
166
167unsigned long
168ulmax(a, b)
169 unsigned long a, b;
170{
171
172 return (a > b ? a : b);
173}
174#endif /* NEED_MINMAX */
175
176#ifdef NEED_FFS
177ffs(mask)
178 register long mask;
179{
180 register int bit;
181
182 if (!mask)
183 return(0);
184 for (bit = 1;; ++bit) {
185 if (mask&0x01)
186 return(bit);
187 mask >>= 1;
188 }
189}
190#endif /* NEED_FFS */
191
192#ifdef NEED_BCMP
193bcmp(v1, v2, len)
194 void *v1, *v2;
195 register unsigned len;
196{
197 register u_char *s1 = v1, *s2 = v2;
198
199 while (len--)
200 if (*s1++ != *s2++)
201 return (1);
202 return (0);
203}
204#endif /* NEED_BCMP */
205
206#ifdef NEED_STRLEN
207size_t
208strlen(s1)
209 register const char *s1;
210{
211 register size_t len;
212
213 for (len = 0; *s1++ != '\0'; len++)
214 ;
215 return (len);
216}
217#endif /* NEED_STRLEN */