xref: /original-bsd/sys/kern/subr_xxx.c (revision da7c76f1)
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.7 (Berkeley) 05/15/90
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 	unsigned a, b;
50 {
51 
52 	return (a < b ? a : b);
53 }
54 
55 unsigned
56 max(a, b)
57 	unsigned a, b;
58 {
59 
60 	return (a > b ? a : b);
61 }
62 #endif
63 
64 #if !defined(vax) && !defined(tahoe) && !defined(hp300)
65 ffs(mask)
66 	register long mask;
67 {
68 	register int bit;
69 
70 	if (!mask)
71 		return(0);
72 	for (bit = 1;; ++bit)
73 		if (mask&0x01)
74 			return(bit);
75 		mask >>= 1;
76 	}
77 }
78 #endif
79 
80 #if !defined(vax) && !defined(hp300)
81 bcmp(s1, s2, len)
82 	register char *s1, *s2;
83 	register unsigned len;
84 {
85 
86 	while (len--)
87 		if (*s1++ != *s2++)
88 			return (1);
89 	return (0);
90 }
91 
92 strlen(s1)
93 	register char *s1;
94 {
95 	register int len;
96 
97 	for (len = 0; *s1++ != '\0'; len++)
98 		/* void */;
99 	return (len);
100 }
101 #endif
102