File:  [gforth] / gforth / lib.fs
Revision 1.21: download - view: text, annotated - select for diffs
Mon Dec 31 17:34:58 2007 UTC (11 years, 8 months ago) by anton
Branches: MAIN
CVS tags: HEAD
updated copyright years

    1: \ lib.fs	shared library support package 		11may97py
    2: 
    3: \ Copyright (C) 1995,1996,1997,1998,2000,2003,2005,2006,2007 Free Software Foundation, Inc.
    4: 
    5: \ This file is part of Gforth.
    6: 
    7: \ Gforth is free software; you can redistribute it and/or
    8: \ modify it under the terms of the GNU General Public License
    9: \ as published by the Free Software Foundation; either version 2
   10: \ of the License, or (at your option) any later version.
   11: 
   12: \ This program is distributed in the hope that it will be useful,
   13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
   14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15: \ GNU General Public License for more details.
   16: 
   17: \ You should have received a copy of the GNU General Public License
   18: \ along with this program; if not, write to the Free Software
   19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   20: 
   21: [IFDEF] av-call-int
   22:     include fflib.fs
   23: [ELSE]
   24:     [IFDEF] ffi-call
   25: 	include libffi.fs
   26:     [ELSE]
   27:         .( Neither libffi nor ffcall are available ) cr
   28:         abort
   29:         .( Using oldlib.fs; incompatible with fflib.fs and libffi.fs) cr
   30: 	include oldlib.fs
   31:     [THEN]
   32: [THEN]
   33: 
   34: \ testing stuff
   35: 
   36: [IFUNDEF] libc
   37:     s" os-type" environment? [IF]
   38: 	2dup s" linux-gnu" str= [IF]  2drop
   39: 	    library libc libc.so.6
   40: 	[ELSE] 2dup s" cygwin" str= [IF]  2drop
   41: 		library libc cygwin1.dll
   42: 	    [ELSE]  2dup s" bsd" search nip nip [IF]  2drop
   43: 		    library libc libc.so
   44: 		[ELSE]  2dup s" darwin" string-prefix? [IF]  2drop
   45: 			library libc libc.dylib
   46: 		    [ELSE]  2drop \ or add your stuff here
   47: 		    [THEN]
   48: 		[THEN]
   49: 	    [THEN]
   50: 	[THEN]
   51:     [THEN]
   52: [THEN]
   53: 
   54: [ifdef] testing
   55: 
   56: library libc libc.so.6
   57:                 
   58: libc sleep int (int) sleep
   59: libc open  ptr int int (int) open
   60: libc lseek int llong int (llong) lseek64
   61: libc read  int ptr int (int) read
   62: libc close int (int) close
   63: 
   64: library libm libm.so.6
   65: 
   66: libm fmodf sf sf (sf) fmodf
   67: libm fmod  df df (fp) fmod
   68: 
   69: \ example for a windows callback
   70:     
   71: callback wincall (int) int int int int callback;
   72: 
   73: :noname ( a b c d -- e )  2drop 2drop 0 ; wincall do_timer
   74: 
   75: \ test a callback
   76: 
   77: callback 2:1 (int) int int callback;
   78: 
   79: : cb-test ( a b -- c )
   80:     cr ." Testing callback"
   81:     cr ." arguments: " .s
   82:     cr ." result " + .s cr ;
   83: ' cb-test 2:1 c_plus
   84: 
   85: fptr 2:1call int int (int)
   86: 
   87: : test  c_plus 2:1call ;
   88: 
   89: \ 3 4 test
   90: 
   91: \ bigFORTH legacy library test
   92: 
   93: library libX11 libX11.so.6
   94: 
   95: legacy on
   96: 
   97: 1 libX11 XOpenDisplay XOpenDisplay    ( name -- dpy )
   98: 5 libX11 XInternAtoms XInternAtoms    ( atoms flag count names dpy -- status )
   99: 
  100: legacy off
  101: 
  102: [then]    

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