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