Annotation of gforth/lib.fs, revision 1.30

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

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