|
|
1.1 root 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: *
1.1.1.3 ! root 33: * from: @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91
! 34: * subr_xxx.c,v 1.5 1993/06/27 06:01:54 andrew Exp
1.1 root 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: */
1.1.1.3 ! root 48: int
1.1 root 49: enodev()
50: {
51:
52: return (ENODEV);
53: }
54:
55: /*
56: * Unconfigured device function; driver not configured.
57: */
1.1.1.3 ! root 58: int
1.1 root 59: enxio()
60: {
61:
62: return (ENXIO);
63: }
64:
65: /*
66: * Unsupported ioctl function.
67: */
1.1.1.3 ! root 68: int
1.1 root 69: enoioctl()
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: */
1.1.1.3 ! root 80: int
1.1 root 81: enosys()
82: {
83:
84: return (ENOSYS);
85: }
86:
87: /*
88: * Return error for operation not supported
89: * on a specific object or file type.
90: */
1.1.1.3 ! root 91: int
1.1 root 92: eopnotsupp()
93: {
94:
95: return (EOPNOTSUPP);
96: }
97:
98: /*
99: * Generic null operation, always returns success.
100: */
1.1.1.3 ! root 101: int
1.1 root 102: nullop()
103: {
104:
105: return (0);
106: }
107:
108: /*
1.1.1.3 ! root 109: * Generic null operation, returning void.
! 110: */
! 111: void
! 112: voidop()
! 113: {
! 114: }
! 115:
! 116: /*
1.1 root 117: * Definitions of various trivial functions;
118: * usually expanded inline rather than being defined here.
119: */
120: #ifdef NEED_MINMAX
1.1.1.3 ! root 121: int
1.1 root 122: imin(a, b)
123: int a, b;
124: {
125:
126: return (a < b ? a : b);
127: }
128:
1.1.1.3 ! root 129: int
1.1 root 130: imax(a, b)
131: int a, b;
132: {
133:
134: return (a > b ? a : b);
135: }
136:
137: unsigned int
138: min(a, b)
139: unsigned int a, b;
140: {
141:
142: return (a < b ? a : b);
143: }
144:
145: unsigned int
146: max(a, b)
147: unsigned int a, b;
148: {
149:
150: return (a > b ? a : b);
151: }
152:
153: long
154: lmin(a, b)
155: long a, b;
156: {
157:
158: return (a < b ? a : b);
159: }
160:
161: long
162: lmax(a, b)
163: long a, b;
164: {
165:
166: return (a > b ? a : b);
167: }
168:
169: unsigned long
170: ulmin(a, b)
171: unsigned long a, b;
172: {
173:
174: return (a < b ? a : b);
175: }
176:
177: unsigned long
178: ulmax(a, b)
179: unsigned long a, b;
180: {
181:
182: return (a > b ? a : b);
183: }
184: #endif /* NEED_MINMAX */
185:
186: #ifdef NEED_FFS
1.1.1.3 ! root 187: int
1.1 root 188: ffs(mask)
189: register long mask;
190: {
191: register int bit;
192:
193: if (!mask)
194: return(0);
195: for (bit = 1;; ++bit) {
196: if (mask&0x01)
197: return(bit);
198: mask >>= 1;
199: }
1.1.1.3 ! root 200:
! 201: return 0;
1.1 root 202: }
203: #endif /* NEED_FFS */
204:
205: #ifdef NEED_BCMP
1.1.1.3 ! root 206: int
1.1 root 207: bcmp(v1, v2, len)
208: void *v1, *v2;
209: register unsigned len;
210: {
211: register u_char *s1 = v1, *s2 = v2;
212:
213: while (len--)
214: if (*s1++ != *s2++)
215: return (1);
216: return (0);
217: }
218: #endif /* NEED_BCMP */
219:
220: #ifdef NEED_STRLEN
1.1.1.3 ! root 221: size_t
1.1 root 222: strlen(s1)
1.1.1.3 ! root 223: register const char *s1;
1.1 root 224: {
1.1.1.3 ! root 225: register size_t len;
1.1 root 226:
227: for (len = 0; *s1++ != '\0'; len++)
228: ;
229: return (len);
230: }
231: #endif /* NEED_STRLEN */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.