static char *sccsid
= "@(#)ffasl.c 34.3 10/23/80";
#define round(x,s) ((((x)-1) & ~((s)-1)) + (s))
static seed
=0, mypid
= 0;
/* dispget - get discipline of function
* this is used to handle the tricky defaulting of the discipline
* field of such functions as cfasl and getaddress.
* dispget is given the value supplied by the caller,
* the error message to print if something goes wrong,
* the default to use if nil was supplied.
* the discipline can be an atom or string. If an atom it is supplied
* it must be lambda, nlambda or macro. Otherwise the atoms pname
dispget(given
,messg
,defult
)
if((typ
=TYPE(given
)) == ATOM
)
given
== macro
) return(given
);
else return((lispval
) given
->a
.pname
);
} else if(typ
== STRNG
) return(given
);
given
= errorh(Vermisc
,messg
,nil
,TRUE
,0,given
);
register struct argent
*mlbot
= lbot
;
register int fildes
, totsize
;
register struct argent
*lbot
, *np
;
char *sbrk(), *currend
, *tfile
, cbuf
[6000], *mytemp(), *gstab();
case 3: protect(nil
); /* no discipline given */
case 4: protect(nil
); /* no library given */
mlbot
[0].val
= verify(mlbot
[0].val
,"Incorrect .o file specification");
mlbot
[1].val
= verify(mlbot
[1].val
,"Incorrect entry specification for cfasl");
mlbot
[3].val
= dispget(mlbot
[3].val
,"Incorrect discipline specification for cfasl",Vsubrou
->a
.pname
);
while(TYPE(mlbot
[2].val
)!= ATOM
)
mlbot
[2].val
= errorh(Vermisc
,"Bad associated atom name for fasl",
nil
,TRUE
,0,mlbot
[2].val
);
largs
= (char *) verify(work
,"Bad loader flags");
"/usr/lib/lisp/nld -N -A %s -T %x %s -e %s -o %s %s -lc",
printf(cbuf
); fflush(stdout
);
fprintf(stderr
,"Ld returns error status\n");
putchar('\n'); fflush(stdout
);
if((fildes
= open(tfile
,0))<0) {
fprintf(stderr
,"Couldn't open temporary file: %s\n",tfile
);
* 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
= round(header
.a_text
,4) + round(header
.a_data
,4);
totsize
= readsize
+ header
.a_bss
;
totsize
= round(totsize
,512);
* Fix up system indicators, typing info, etc.
currend
= (char *)csegment(str_name
,totsize
,FALSE
);
if(readsize
!=read(fildes
,currend
,readsize
))
work
->bcd
.entry
= (lispval (*)())header
.a_entry
;
work
->bcd
.discipline
= mlbot
[3].val
;
return(mlbot
[2].val
->a
.fnbnd
= work
);
register char *cp
, *cp2
; char *getenv();
cp
=":/usr/ucb:/bin:/usr/bin";
if(*cp
==':'||*Xargv
[0]=='/') {
if(stat(Xargv
[0],&stbuf
)==0) {
/* copy over current directory
and then append argv[0] */
for(cp2
=myname
;(*cp
)!=0 && (*cp
)!=':';)
if(0!=stat(myname
,&stbuf
)) continue;
error("Could not find which file is being executed.",FALSE
);
if(mypid
==0) mypid
= getpid();
sprintf(mybuff
,"/tmp/Li%d.%d",mypid
,seed
++);
sprintf(mybuff
,"/tmp/Li%d.%d",mypid
,seed
-1);
return((lispval
)in
->a
.pname
);
in
= errorh(Vermisc
,error
,nil
,TRUE
,0,in
);