Interdata_v6/usr/source/libc/src.a
eabort.s n * abort - force an illegal instruction fault
entry abort
pure
abort equ *
dc h'0' illegal instruction
end
alloc.c /* c storage allocator
* circular first fit strategy
*/
#define BLOK 512
#define BUSY 01
static char *allocs[2] {
(int)&allocs[1]+BUSY,
(int)&allocs[0]+BUSY
};
struct { int word; };
static char **allocp &allocs[1]; /* current search pointer */
static char **alloct &allocs[1]; /* top of arena (last cell) */
alloc(nbytes) {
register int nwords;
register char **p, **q;
register char **t;
nwords = (nbytes+(2*sizeof(p)-1))/sizeof(p);
for(p=allocp;;) {
do {
if((p->word&BUSY)==0) {
/* combine adjancent free blocks */
while(((q = *p)->word&BUSY)==0)
*p = *q;
/* q -> end of current free block */
if(q >= &p[nwords])
goto found;
}
q = p;
p = p->word & ~BUSY;
} while(q>=allocp || p<allocp); /*check all blocks form current end around */
if((*alloct=t=sbrk(BLOK*sizeof(p))) == -1)
return(-1);
if(t!=alloct+1) /* only on 1st storage request */
alloct->word =| BUSY;
alloct = (*t = &t[BLOK]-1);
*alloct = allocs;
alloct->word =| BUSY;
}
found:
allocp = &p[nwords];
if(q>allocp)
*allocp = *p; /*ie if only part of a free block reqd*/
*p = allocp.word|BUSY;
return(p+1);
}
free(p)
char **p;
{
allocp = p-1;
allocp->word =& ~BUSY; /* set pointer not busy */
}
oatof.c i _ /*
* Quick-and-dirty floating-poi scanner:
* converts a string of digits with optional sign, decimal point, and
* signed exponent to a floating-point value
*/
double atof(str)
char *str;
{
double f;
register char *s, c;
register n, exp, neg;
int expsign;
/* check leading sign */
neg = 0;
if ((c = *(s = str)) == '-') {
neg = 1;
str++;
}
else if (c == '+')
str++;
/* scan digits before decimal pt */
f = 0.0;
while ((c = *str++) <= '9' && c >= '0') {
f =* 10.0;
f =+ c - '0';
}
/* scan digits after decimal pt */
exp = 0;
if (c == '.')
while ((c = *str++) <= '9' && c >= '0') {
f =* 10.0;
f =+ c - '0';
exp--;
}
/* scan exponent */
if (c == 'e' || c == 'E') {
expsign = 1;
if ((c = *str) == '-') {
expsign = -1;
str++;
}
else if (c == '+')
str++;
n = 0;
while ((c = *str++) <= '9' && c >= '0') {
n =* 10;
n =+ c - '0';
}
exp =+ expsign*n;
}
/* combine no. & exponent by inefficient repeated multiplication */
if (exp) {
if (exp < 0) do
f =/ 10.0;
while (++exp);
else do
f =* 10.0;
while (--exp);
}
return(neg? -f : f);
}
'atoi.c ߣV atoi(s)
char *s;
{
register n, neg, c;
register char *p;
n = neg = 0;
for (p = s; (c = *p) == ' ' || c == 'T'; p++) ;
if (c == '-') {
neg++;
p++;
}
n = 0;
while ((c = *p) <= '9' && c >= '0') {
n =* 10;
n =+ c - '0';
p++;
}
return(neg? -n : n);
}
crt0.s >