xref: /original-bsd/sys/kern/subr_xxx.c (revision 262b24ac)
1 /*
2  * Copyright (c) 1982, 1986 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)subr_xxx.c	7.5 (Berkeley) 07/21/87
7  */
8 
9 #include "errno.h"
10 
11 /*
12  * Routine placed in illegal entries in the bdevsw and cdevsw tables.
13  */
14 nodev()
15 {
16 
17 	return (ENODEV);
18 }
19 
20 /*
21  * Null routine; placed in insignificant entries
22  * in the bdevsw and cdevsw tables.
23  */
24 nulldev()
25 {
26 
27 	return (0);
28 }
29 
30 /*
31  * Definitions of various trivial functions;
32  * usually expanded inline rather than being defined here.
33  */
34 #if !defined(vax) && !defined(tahoe)
35 imin(a, b)
36 {
37 
38 	return (a < b ? a : b);
39 }
40 
41 imax(a, b)
42 {
43 
44 	return (a > b ? a : b);
45 }
46 
47 unsigned
48 min(a, b)
49 	u_int a, b;
50 {
51 
52 	return (a < b ? a : b);
53 }
54 
55 unsigned
56 max(a, b)
57 	u_int a, b;
58 {
59 
60 	return (a > b ? a : b);
61 }
62 #endif
63 
64 #if !defined(vax) && !defined(tahoe)
65 ffs(mask)
66 	register long mask;
67 {
68 	register int i;
69 
70 	for(i = 1; i < NSIG; i++) {
71 		if (mask & 1)
72 			return (i);
73 		mask >>= 1;
74 	}
75 	return (0);
76 }
77 #endif
78 
79 #if !defined(vax)
80 bcmp(s1, s2, len)
81 	register char *s1, *s2;
82 	register unsigned len;
83 {
84 
85 	while (len--)
86 		if (*s1++ != *s2++)
87 			return (1);
88 	return (0);
89 }
90 
91 strlen(s1)
92 	register char *s1;
93 {
94 	register int len;
95 
96 	for (len = 0; *s1++ != '\0'; len++)
97 		/* void */;
98 	return (len);
99 }
100 #endif
101