Annotation of gforth/lib.fs, revision 1.31

1.1       pazsan      1: \ lib.fs       shared library support package          11may97py
                      2: 
1.26      anton       3: \ Copyright (C) 1995,1996,1997,1998,2000,2003,2005,2006,2007,2008 Free Software Foundation, Inc.
1.1       pazsan      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
1.22      anton       9: \ as published by the Free Software Foundation, either version 3
1.1       pazsan     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
1.22      anton      18: \ along with this program. If not, see http://www.gnu.org/licenses/.
1.1       pazsan     19: 
1.30      pazsan     20: s" os-type" environment? [IF]
1.31    ! pazsan     21:     2dup s" linux-gnu" str= [IF] 2drop
        !            22:        cell 8 = [IF] s" /usr/lib64/libffi.so" [ELSE] s" libffi.so" [THEN]
1.30      pazsan     23:     [ELSE] 2dup s" bsd" search nip nip [IF] 2drop s" libffi.so"
                     24:        [ELSE] 2dup s" cygwin" str= [IF] 2drop s" libffi.dll"
1.31    ! pazsan     25:            [ELSE] 2dup s" darwin" str-prefix? [IF] 2drop s" libffi.dylib"
        !            26:                [ELSE] 2drop s" libffi" [THEN] [THEN] [THEN] [THEN] [THEN]
1.30      pazsan     27: open-lib [if]
1.29      pazsan     28:     .( including libffi.fs )
                     29:     include libffi.fs
1.7       pazsan     30: [ELSE]
1.29      pazsan     31:     s" libavcall.so"     open-lib 0<>
                     32:     s" libcallback.so"   open-lib 0<> and [if]
                     33:        .( including fflib.fs [ffcall] )
                     34:        include fflib.fs
1.10      pazsan     35:     [ELSE]
1.29      pazsan     36:        .( Neither libffi nor ffcall are available ) cr
                     37:        abort
1.19      anton      38:         .( Using oldlib.fs; incompatible with fflib.fs and libffi.fs) cr
1.10      pazsan     39:        include oldlib.fs
                     40:     [THEN]
1.7       pazsan     41: [THEN]
1.1       pazsan     42: 
1.11      pazsan     43: \ testing stuff
                     44: 
1.18      pazsan     45: [IFUNDEF] libc
                     46:     s" os-type" environment? [IF]
                     47:        2dup s" linux-gnu" str= [IF]  2drop
1.28      pazsan     48:            cell 8 = [IF]
                     49:                library libc /lib64/libc.so.6
                     50:            [ELSE]
                     51:                library libc /lib/libc.so.6
                     52:            [THEN]
1.18      pazsan     53:        [ELSE] 2dup s" cygwin" str= [IF]  2drop
                     54:                library libc cygwin1.dll
1.20      pazsan     55:            [ELSE]  2dup s" bsd" search nip nip [IF]  2drop
1.18      pazsan     56:                    library libc libc.so
1.20      pazsan     57:                [ELSE]  2dup s" darwin" string-prefix? [IF]  2drop
                     58:                        library libc libc.dylib
                     59:                    [ELSE]  2drop \ or add your stuff here
                     60:                    [THEN]
1.18      pazsan     61:                [THEN]
                     62:            [THEN]
                     63:        [THEN]
                     64:     [THEN]
                     65: [THEN]
                     66: 
1.11      pazsan     67: [ifdef] testing
                     68: 
                     69: library libc libc.so.6
                     70:                 
                     71: libc sleep int (int) sleep
1.16      anton      72: libc open  ptr int int (int) open
1.11      pazsan     73: libc lseek int llong int (llong) lseek64
                     74: libc read  int ptr int (int) read
                     75: libc close int (int) close
                     76: 
                     77: library libm libm.so.6
                     78: 
                     79: libm fmodf sf sf (sf) fmodf
                     80: libm fmod  df df (fp) fmod
                     81: 
                     82: \ example for a windows callback
                     83:     
                     84: callback wincall (int) int int int int callback;
                     85: 
                     86: :noname ( a b c d -- e )  2drop 2drop 0 ; wincall do_timer
                     87: 
                     88: \ test a callback
                     89: 
                     90: callback 2:1 (int) int int callback;
                     91: 
                     92: : cb-test ( a b -- c )
                     93:     cr ." Testing callback"
                     94:     cr ." arguments: " .s
                     95:     cr ." result " + .s cr ;
                     96: ' cb-test 2:1 c_plus
                     97: 
1.14      pazsan     98: fptr 2:1call int int (int)
1.12      pazsan     99: 
                    100: : test  c_plus 2:1call ;
1.11      pazsan    101: 
                    102: \ 3 4 test
                    103: 
                    104: \ bigFORTH legacy library test
                    105: 
                    106: library libX11 libX11.so.6
                    107: 
                    108: legacy on
                    109: 
                    110: 1 libX11 XOpenDisplay XOpenDisplay    ( name -- dpy )
                    111: 5 libX11 XInternAtoms XInternAtoms    ( atoms flag count names dpy -- status )
                    112: 
                    113: legacy off
                    114: 
                    115: [then]    

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