#define round(x,s) ((((x)-1) & ~((s)-1)) + (s))
/* this is the original fasl, which used nld to do relocation.
* On nov 4, it was replaced by rfasl
static char stabbuf
[32]="";
static struct exec header
;
static lispval
*linkaddr
;
register struct argent
*mlbot
= lbot
;
lispval
csegment(), errorh();
char *sbrk(), *tfile
, cbuf
[512], *mytemp(), *gstab();
struct nament
*obnp
= bnp
;
if(np
- mlbot
!= 1 || TYPE(mlbot
[0].val
)!=ATOM
)
mlbot
[0].val
= errorh(Vermisc
,
"fasl: Incorrect .o file specification:",
"/usr/lib/lisp/nld -A %s -T %x -N %s -o %s",
/* printf(cbuf); fflush(stdout); debugging */
printf("[fasl: %s]",mlbot
[0].val
->pname
);
putchar('\n'); /* signal end of nld */
if((fildes
= open(tfile
,0))<0)
strcpyn(stabbuf
,tfile
,31);
* Read a.out header to find out how much room to
* allocate and attempt to do so.
if(read(fildes
,(char *)&header
,sizeof(header
)) <= 0) {
readsize
= header
.a_text
;
totsize
= round(totsize
,PAGSIZ
);
* Fix up system indicators, typing info, etc.
currend
= (char *)csegment(int_name
,totsize
/(sizeof(int)));
if(readsize
!=read(fildes
,currend
,readsize
))
linkaddr
= (lispval
*)*(int *)currend
;
currtab
= Vreadtable
->clb
;
Vreadtable
->clb
= strtab
;
ibase
->clb
= inewint(10);
Vreadtable
->clb
= currtab
;
chkrtab(currtab
); /* added by jkf, shouldnt be needed */
static seed
=0, mypid
= 0;
if(mypid
==0) mypid
= getpid();
sprintf(mybuff
,"/tmp/Li%d.%d",mypid
,seed
++);
register int *i
, *end
, temp
;
extern lispval
*bind_lists
;
/* first link this linkage table to the garbage
collector's list. We will try to be tricky
so that if the garbage collector is invoked
by mkptr we will not cause markdp() to go off
*(linkaddr
-1) = (lispval
) bind_lists
;
end
= (int *)(currend
+ header
.a_text
- 7);
*i
= -1; /* clobber to short circuit gc */
struct {lispval (*b_entry
)();
pos
= lseek(fildes
, (sizeof header
)+header
.a_text
, 0);
while(read(fildes
, &bindage
, sizeof bindage
)==sizeof bindage
&& bindage
.b_atmlnk
!= -1) {
if( bindage
.b_type
== 99) {
/* we must evaluate this form for effect */
/* and must take care that setsyntax works
on the proper read table */
findstr(bindage
.b_atmlnk
, array
);
if(ISNIL(copval(gcload
,CNIL
)) && loading
->clb
!= tatom
)
gc(CNIL
); /* do a gc if gc will be off */
Vreadtable
->clb
= currtab
;
Vreadtable
->clb
= strtab
;
ibase
->clb
= inewint(10);
handy
->entry
= bindage
.b_entry
;
handy
->discipline
= (bindage
.b_type
== 0 ? lambda
:
bindage
.b_type
== 1 ? nlambda
:
findstr(bindage
.b_atmlnk
, array
);
mkptr(array
)->fnbnd
= handy
;
protect(prop
= mkptr(array
+1));
Iputprop(atom
,handy
,prop
);
pos
= lseek(fildes
, pos
+ sizeof bindage
, 0);
lseek(fildes
, sizeof header
+ header
.a_text
+ ptr
, 0);
while(cnt
<STRLIM
&& read(fildes
,&array
[cnt
],1)==1
if(cnt
>= STRLIM
) error("fasl string table overflow",FALSE
);
/* find free file descriptor */
for(;p
->_flag
&(_IOREAD
|_IOWRT
);p
++)
error("Too many open files to do readlist",FALSE
);
p
->_flag
= _IOREAD
| _IOSTRG
;
p
->_base
= p
->_ptr
= str
;
p
->_cnt
= strlen(str
) + 1;