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