------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 199x by International Computer Science Institute            --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------

-- C calls used by the library classes.

external class RUNTIME is

    fopen(nm:STR,tp:STR):EXT_OB;
    feof(fp:EXT_OB):BOOL;
    ferror(fp:EXT_OB):BOOL;
    clearerr(fp:EXT_OB);
    fclose(fp:EXT_OB);
    fseek(fp:EXT_OB,off:INT,loc:INT):INT;
    ftell(fp:EXT_OB):INT;
    fread(fs:FSTR,sz,items:INT,fp:EXT_OB):INT;
    fwrite(fs:STR,sz,items:INT,fp:EXT_OB):INT;
    fputc(c:CHAR,fp:EXT_OB);
    fgetc(fp:EXT_OB):CHAR;
    unlink(s:STR);
    tmpfile:EXT_OB;
    tempnam(dir:EXT_OB,pfx:STR):EXT_OB;
    fflush(fp:EXT_OB);
    setbuffer(fp:EXT_OB,buf:FSTR,sz:INT);
    getwd(buf:FSTR):EXT_OB;
    mkdir(nm:STR,md:INT);

    r_acos(f:FLT):FLT;
    r_acospi(f:FLT):FLT;
    r_acosh(f:FLT):FLT;
    --r_aint(f:FLT):FLT;
    r_anint(f:FLT):FLT;
    r_annuity(f:FLT):FLT;
    r_asin(f:FLT):FLT;
    r_asinpi(f:FLT):FLT;
    r_asinh(f:FLT):FLT;
    r_atan(f:FLT):FLT;
    r_atanpi(f:FLT):FLT;
    r_atanh(f:FLT):FLT;
    r_atan2(f,g:FLT):FLT;
    r_atan2pi(f,g:FLT):FLT;
    r_cbrt(f:FLT):FLT;
    r_ceil(f:FLT):FLT;
    r_compound(f,g:FLT):FLT;
    r_copysign(f,g:FLT):FLT;
    r_cos(f:FLT):FLT;
    r_cospi(f:FLT):FLT;
    r_cosh(f:FLT):FLT;
    r_erf(f:FLT):FLT;
    r_erfc(f:FLT):FLT;
    r_exp(f:FLT):FLT;
    r_expm1(f:FLT):FLT;
    r_exp2(f:FLT):FLT;
    r_exp10(f:FLT):FLT;
    r_fabs(f:FLT):FLT;
    ir_finite(f:FLT):BOOL;
    r_floor(f:FLT):FLT;
    r_fmod(f,g:FLT):FLT;
    r_hypot(f,g:FLT):FLT;
    ir_ilogb(f:FLT):INT;
    ir_irint(f:FLT):INT;
    ir_isinf(f:FLT):BOOL;
    ir_isnormal(f:FLT):BOOL;
    ir_issubnormal(f:FLT):BOOL;
    ir_iszero(f:FLT):BOOL;
    ir_nint(f:FLT):INT;
    r_infinity:FLT;
    r_j0(f:FLT):FLT;
    r_j1(f:FLT):FLT;
    r_jn(n:INT,f:FLT):FLT;
    r_lgamma(f:FLT):FLT;
    r_logb(f:FLT):FLT;
    r_log(f:FLT):FLT;
    r_log1p(f:FLT):FLT;
    --r_log2(f:FLT):FLT;
    r_log10(f:FLT):FLT;
    --r_max_normal:FLT;
    --r_max_subnormal:FLT;
    --r_min_normal:FLT;
    --r_min_subnormal:FLT;
    r_nextafter(f,g:FLT):FLT;
    r_pow(f,g:FLT):FLT;
    r_quiet_nan(n:INT):FLT;
    r_remainder(f,g:FLT):FLT;
    r_scalbn(f:FLT,n:INT):FLT;
    r_signaling_nan(n:INT):FLT;
    ir_signbit(f:FLT):BOOL;
    r_significand(f:FLT):FLT;
    r_sin(f:FLT):FLT;
    r_sinpi(f:FLT):FLT;
    -- the next two are hacks, as they work with AREF{FLT}
    r_sincos(f:FLT,g:AREF{FLT});
    r_sincospi(f:FLT,g:AREF{FLT});
    r_sinh(f:FLT):FLT;
    r_sqrt(f:FLT):FLT;
    r_tan(f:FLT):FLT;
    r_tanpi(f:FLT):FLT;
    r_tanh(f:FLT):FLT;
    r_y0(f:FLT):FLT;
    r_y1(f:FLT):FLT;
    r_yn(n:INT,f:FLT):FLT;

    acos(f:FLTD):FLTD;
    acospi(f:FLTD):FLTD;
    acosh(f:FLTD):FLTD;
    anint(f:FLTD):FLTD;
    annuity(f:FLTD):FLTD;
    asin(f:FLTD):FLTD;
    asinpi(f:FLTD):FLTD;
    asinh(f:FLTD):FLTD;
    atan(f:FLTD):FLTD;
    atanpi(f:FLTD):FLTD;
    atanh(f:FLTD):FLTD;
    atan2(f,g:FLTD):FLTD;
    atan2pi(f,g:FLTD):FLTD;
    cbrt(f:FLTD):FLTD;
    ceil(f:FLTD):FLTD;
    compound(f,g:FLTD):FLTD;
    copysign(f,g:FLTD):FLTD;
    cos(f:FLTD):FLTD;
    cospi(f:FLTD):FLTD;
    cosh(f:FLTD):FLTD;
    erf(f:FLTD):FLTD;
    erfc(f:FLTD):FLTD;
    exp(f:FLTD):FLTD;
    expm1(f:FLTD):FLTD;
    exp2(f:FLTD):FLTD;
    exp10(f:FLTD):FLTD;
    fabs(f:FLTD):FLTD;
    finite(f:FLTD):INT;
    floor(f:FLTD):FLTD;
    fmod(f,g:FLTD):FLTD;
    hypot(f,g:FLTD):FLTD;
    ilogb(f:FLTD):INT;
    irint(f:FLTD):INT;
    isinf(f:FLTD):INT;
    isnormal(f:FLTD):INT;
    issubnormal(f:FLTD):INT;
    iszero(f:FLTD):INT;
    nint(f:FLTD):INT;
    infinity:FLTD;
    j0(f:FLTD):FLTD;
    j1(f:FLTD):FLTD;
    jn(n:INT,f:FLTD):FLTD;
    lgamma(f:FLTD):FLTD;
    logb(f:FLTD):FLTD;
    log(f:FLTD):FLTD;
    log1p(f:FLTD):FLTD;
    --log2(f:FLTD):FLTD;
    log10(f:FLTD):FLTD;
    --max_normal:FLTD;
    --max_subnormal:FLTD;
    --min_normal:FLTD;
    --min_subnormal:FLTD;
    nextafter(f,g:FLTD):FLTD;
    pow(f,g:FLTD):FLTD;
    quiet_nan(n:INT):FLTD;
    remainder(f,g:FLTD):FLTD;
    scalbn(f:FLTD,n:INT):FLTD;
    signaling_nan(n:INT):FLTD;
    signbit(f:FLTD):INT;
    significand(f:FLTD):FLTD;
    sin(f:FLTD):FLTD;
    sinpi(f:FLTD):FLTD;
    -- the next two are hacks, as they work with AREF{FLTD}
    sincos(f:FLTD,g:AREF{FLTD});
    sincospi(f:FLTD,g:AREF{FLTD});
    sinh(f:FLTD):FLTD;
    sqrt(f:FLTD):FLTD;
    tan(f:FLTD):FLTD;
    tanpi(f:FLTD):FLTD;
    tanh(f:FLTD):FLTD;
    y0(f:FLTD):FLTD;
    y1(f:FLTD):FLTD;
    yn(n:INT,f:FLTD):FLTD;
    atof(s: STR): FLTD;

    atoi(s: STR): INT;

    rt_file_open(s:STR):INT; -- Try to open the file named `s'
    -- for reading and return the file descriptor. -1 for failure.
    
    rt_file_size(fd:INT):INT;	-- The size in characters of the 
    -- file described by descriptor `fd'.
    
    rt_file_in_str(fd:INT,s:STR,st,sz:INT); -- Fill in the string `s' 
    -- with the characters from the file described by `fd' starting
    -- at character `st' and going for `sz' chars (which should be
    -- the length of `s'). THIS SHOULD NOT BE CALLED OUTSIDE OF
    -- STR (to avoid breaking the immutability property of strings). 
    
    rt_file_in_fstr(fd:INT,s:FSTR,st,sz,bst:INT); -- Insert into 
    -- the string buffer `s' characters from the file described by
    -- `fd' starting at character `st' and going for `sz' chars. Start
    -- inserting at character `bst' of the buffer (there must be
    -- room!).   
    
    rt_file_close(fd:INT);	-- Close the file described by the 
    -- descriptor `fd'.

    rt_create_astr(i:INT, s:STR): EXT_OB; -- Split concatinate
    -- strings separated by '\0' into array of string in C.

    strlen(s:EXT_OB):INT;
    memcpy(r:STR,s:EXT_OB,i:INT):EXT_OB;

end;
