Commit | Line | Data |
---|---|---|
9ec65acb | 1 | /* subr_xxx.c 6.2 83/09/09 */ |
961945a8 SL |
2 | |
3 | #include "../machine/pte.h" | |
ae9e2121 BJ |
4 | |
5 | #include "../h/param.h" | |
6 | #include "../h/systm.h" | |
7 | #include "../h/conf.h" | |
8 | #include "../h/inode.h" | |
9 | #include "../h/dir.h" | |
10 | #include "../h/user.h" | |
11 | #include "../h/buf.h" | |
12 | #include "../h/proc.h" | |
6459ebe0 | 13 | #include "../h/fs.h" |
cb99a88a | 14 | #include "../h/vm.h" |
cb99a88a | 15 | #include "../h/cmap.h" |
d6d7360b | 16 | #include "../h/uio.h" |
ae9e2121 | 17 | |
ae9e2121 | 18 | /* |
50a84b40 | 19 | * Routine placed in illegal entries in the bdevsw and cdevsw tables. |
ae9e2121 BJ |
20 | */ |
21 | nodev() | |
22 | { | |
23 | ||
50a84b40 | 24 | return (ENODEV); |
ae9e2121 BJ |
25 | } |
26 | ||
27 | /* | |
28 | * Null routine; placed in insignificant entries | |
29 | * in the bdevsw and cdevsw tables. | |
30 | */ | |
31 | nulldev() | |
32 | { | |
33 | ||
50a84b40 | 34 | return (0); |
ae9e2121 BJ |
35 | } |
36 | ||
37 | imin(a, b) | |
38 | { | |
39 | ||
40 | return (a < b ? a : b); | |
41 | } | |
42 | ||
43 | imax(a, b) | |
44 | { | |
45 | ||
46 | return (a > b ? a : b); | |
47 | } | |
48 | ||
6459ebe0 KM |
49 | unsigned |
50 | min(a, b) | |
b32450f4 | 51 | u_int a, b; |
6459ebe0 KM |
52 | { |
53 | ||
54 | return (a < b ? a : b); | |
55 | } | |
56 | ||
57 | unsigned | |
58 | max(a, b) | |
b32450f4 | 59 | u_int a, b; |
6459ebe0 KM |
60 | { |
61 | ||
62 | return (a > b ? a : b); | |
63 | } | |
b32450f4 | 64 | |
cb99a88a BJ |
65 | extern cabase, calimit; |
66 | extern struct pte camap[]; | |
67 | ||
68 | caddr_t cacur = (caddr_t)&cabase; | |
69 | caddr_t camax = (caddr_t)&cabase; | |
70 | int cax = 0; | |
71 | /* | |
72 | * This is a kernel-mode storage allocator. | |
73 | * It is very primitive, currently, in that | |
74 | * there is no way to give space back. | |
75 | * It serves, for the time being, the needs of | |
76 | * auto-configuration code and the like which | |
77 | * need to allocate some stuff at boot time. | |
78 | */ | |
79 | caddr_t | |
80 | calloc(size) | |
81 | int size; | |
82 | { | |
83 | register caddr_t res; | |
84 | register int i; | |
85 | ||
86 | if (cacur+size >= (caddr_t)&calimit) | |
87 | panic("calloc"); | |
88 | while (cacur+size > camax) { | |
89 | (void) vmemall(&camap[cax], CLSIZE, &proc[0], CSYS); | |
90 | vmaccess(&camap[cax], camax, CLSIZE); | |
91 | for (i = 0; i < CLSIZE; i++) | |
92 | clearseg(camap[cax++].pg_pfnum); | |
93 | camax += NBPG * CLSIZE; | |
94 | } | |
95 | res = cacur; | |
96 | cacur += size; | |
97 | return (res); | |
98 | } | |
febd1daa | 99 | |
cb99a88a BJ |
100 | #ifndef vax |
101 | ffs(mask) | |
102 | register long mask; | |
103 | { | |
104 | register int i; | |
105 | ||
88a7a62a | 106 | for(i = 1; i < NSIG; i++) { |
cb99a88a BJ |
107 | if (mask & 1) |
108 | return (i); | |
109 | mask >>= 1; | |
110 | } | |
111 | return (0); | |
112 | } | |
febd1daa | 113 | |
febd1daa BJ |
114 | bcmp(s1, s2, len) |
115 | register char *s1, *s2; | |
116 | register int len; | |
117 | { | |
118 | ||
f49dd739 | 119 | while (len--) |
febd1daa BJ |
120 | if (*s1++ != *s2++) |
121 | return (1); | |
122 | return (0); | |
123 | } | |
124 | ||
125 | strlen(s1) | |
126 | register char *s1; | |
127 | { | |
128 | register int len; | |
129 | ||
130 | for (len = 0; *s1++ != '\0'; len++) | |
131 | /* void */; | |
132 | return (len); | |
133 | } | |
134 | #endif |