This file is a description of the changes made in the Elk2.0 kernel.

The following files are changed:
object.h, 
load.c, main.c, proc.c, stab.c, type.c, math.c, 

BEWARE - The installation copies over these files in src/,
and scm/toplevel!

Also note that the diff listings below are with respect to
the Oct15/92 pre-release of elk2.0.

config/system================

The optional vector math file fvector.c must be compiled with an 
ANSI compiler.  In the sun/cc version of config/system, config/zelk
nevertheless tries to use gcc to compile this file.  
Since gcc aligns on 8, the alignment in the sun/cc file is set to 8
(otherwise calling fvector is not possible).
One of the gcc authors told me that code runs faster on the sun
when aligned on 8 in any case.

Object.h================================
In the primitive structure add a new pointer which if non-null
points to a foreign function argument description string;
add new discipline FOREIGN:
127c127,131
< enum discipline { EVAL, NOEVAL, VARARGS };
---
> #if ZELK
>  enum discipline { EVAL, NOEVAL, VARARGS, FOREIGN };
> #else
>  enum discipline { EVAL, NOEVAL, VARARGS };
> #endif
134a139,141
> #if ZELK
>     unsigned char *forfunargs;  /* foreign function arguments */
> #endif


proc.c================================
If the discipline is FOREIGN, call ZLforcall, passing everything
and the new forfunargs string.
4a5,7
> #if ZELK
> # include <zelk.h>
> #endif
222c225,232
< 	} else {
---
> 	}
> # ifdef ZELK 
>         else if (prim->disc == FOREIGN) {
>             ret = ZLforcall(prim->name,(function *)prim->fun,prim->forfunargs,
>                             argc,argv);
>         }
> # endif
>         else {


main.c================================
in Init_Everything(), add a call to initialize the extensions last:
1a2
> #include <zelk.h>
204a206,208
> #endif
> #if ZELK
>     Init_Zelk ();


type.c================================
The foreign function argument specification uses T_Fixnum, etc
(primitive->forfunargs is an array of T_codes).
T_Returns is a new meta code indicating that the following T_code
is the return type of the foreign function; T_End is a meta code
indicating the end of the foreign function argument specification.
T_Returns and T_End are allocated at the top of the type range- 254,255.
The foreign function interface on the sgi also uses a code T_Double
with the value 253.
This change checks that Elk allocated types do not overrun 
our meta-codes:
1a2,4
> #if ZELK
> # include <zelk.h>
> #endif
78a82,91
> 
> #if ZELK
>     /* the foreign function argspec uses 8bit ids, with 253,254,255
>      * used as meta-codes such as T_Returns and T_End.
>      * if more than 253 types, must extend the argspec to 16bits
>      */
>     if (t >= 253)
>       Panic("type id > 253: extend foreign types > 8bits");
> #endif
> 


stab.c================================
Call_Initializers() looks for and calls init_XX routines in .o files.
Modify this so that it also calls routines named PKGrtn_XX(),
and passes the result on to Zforpkginit().
The rationale for this is described in the tutorial.
4a5,7
> #if ZELK
> # include <zelk.h>
> #endif
89c92,110
< 	}
---
>         }
> #ifdef ZELK
> # ifdef SYMS_UNDERL
> #  define FORLIB "_PKGrtn_"
> #  define FORLEN 8
> # else
> #  define FORLIB "PKGrtn_"
> #  define FORLEN 7
> # endif
>         /* load foreign libraries */
>         if (strncmp(sp->name,FORLIB,FORLEN)==0) {
>             PKG_type *pkgtab;
>             /*printf("got forlib symbol :%s:\n",sp->name);*/
>             pkgtab = (PKG_type *) ( (GENERIC (*)()) sp->value )();
>             Zforpkginit(sp->name+FORLEN,pkgtab);
>             got_one = 1;
>         }
> #endif /*ZELK*/
> 
91c112
<     }
---
>       }

load.c================================
Make these variables global - they are used in forpkg.c.
   /*static*/ Object V_Load_Path, V_Load_Noisilyp, V_Load_Libraries;


math.c================================
This change is not part of the foreign function interface.
1a2,12
>  * modified (zilla)
>  * Elk math has several characteristics which are altered
>  * as follows:
>  *- (/ x y) when both x,y are integer is treated as if x,y are both
>  *  real, e.g. (/ 5 3) => 1.6666.  Xscheme and Scm also act this way;
>  *  vscm has (/ 5 3) => 1 (integer).
>  *  ZELK_INTEGER_DIV changed this so that (/ 5 3) => 1 (as in C).
>  *
>  *- Real numbers equal to integers become integers, 
>  *  e.g. (/ 6. 3.) => 2 (integer); (type 2.0) => integer
>  *  ZELK_CONTAGIOUS_FLT makes floats 'contagious'.
7a19,20
> #include <zelk.h>
> 
121a135
> #if (!ZELK_CONTAGIOUS_FLT)
128a143
> #endif
477a493,495
> # if ZELK_INTEGER_DIV
>             return Make_Integer( FIXNUM(x) / FIXNUM(y) );
> # else
478a497
> # endif
507a527,529
> # if ZELK_INTEGER_DIV
>             return Car(ret);
> # else
509a532
> # endif
517a541,543
> # if ZELK_INTEGER_DIV
>             return Car(ret);
> # else 
519a546
> # endif
