Annotation of gforth/contrib/syscalls386.fs, revision 1.2

1.1       anton       1: \ syscalls386.fs
                      2: \
1.2     ! anton       3: \ Selected Unix system calls for gforth >=0.7.x
        !             4: 
        !             5: \ Replacement for the original non-portable syscalls386 implementation
        !             6: \ this one ports to other Gforth installations, other architectures,
        !             7: \ and other Unix implementations.
        !             8: 
        !             9: \ The following original note is probably still applicable.
        !            10: 
1.1       anton      11: \ 3)   Compatibility with low-level kForth words is maintained to allow 
                     12: \        kForth code to be used under gforth, e.g. serial.fs, terminal.fs.
                     13: \        Other driver interface examples from kForth should also
                     14: \        work, e.g. the National Instruments GPIB interface nigpib.4th.
                     15: 
1.2     ! anton      16: c-library syscalls386
1.1       anton      17: 
1.2     ! anton      18: \c #include <sys/types.h>
        !            19: \c #include <sys/stat.h>
        !            20: \c #include <fcntl.h>
        !            21: \c #include <unistd.h>
        !            22: \c #include <sys/ioctl.h>
1.1       anton      23: 
                     24: \ sysexit ( code --  | exit to system with code )
                     25: \   sysexit is NOT the recommended way to exit back to the 
                     26: \   system from Forth. It is provided here as a demo of a very 
                     27: \   simple syscall.
1.2     ! anton      28: c-function sysexit _exit n -- void
        !            29: c-function getpid getpid -- n  ( -- u | get process id )
        !            30: c-function open open a n -- n  ( ^zaddr  flags -- fd )
        !            31: \   file descriptor is returned)
1.1       anton      32: \   Note zaddr points to a buffer containing the counted filename
                     33: \   string terminated with a null character.
1.2     ! anton      34: c-function close close n -- n ( fd -- flag )
        !            35: c-function read read n a n -- n ( fd  buf  count --  n )
        !            36: \ read count byes into buf from file
        !            37: c-function write write n a n -- n ( fd  buf  count  --  n )
        !            38: \ write count bytes from buf to file
        !            39: c-function lseek lseek n n n -- n ( fd  offset  type  --  offs )
        !            40: \ reposition the file ptr
        !            41: c-function ioctl ioctl n n a -- n ( fd  request argp -- error )
1.1       anton      42: 
1.2     ! anton      43: end-c-library
1.1       anton      44: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>