[gforth] / gforth / lib.fs  

gforth: gforth/lib.fs


1 : pazsan 1.1 \ lib.fs shared library support package 11may97py
2 :    
3 : anton 1.26 \ Copyright (C) 1995,1996,1997,1998,2000,2003,2005,2006,2007,2008 Free Software Foundation, Inc.
4 : pazsan 1.1
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 : anton 1.22 \ as published by the Free Software Foundation, either version 3
10 : pazsan 1.1 \ 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 : anton 1.22 \ along with this program. If not, see http://www.gnu.org/licenses/.
19 : pazsan 1.1
20 : pazsan 1.30 s" os-type" environment? [IF]
21 : pazsan 1.31 2dup s" linux-gnu" str= [IF] 2drop
22 :     cell 8 = [IF] s" /usr/lib64/libffi.so" [ELSE] s" libffi.so" [THEN]
23 : pazsan 1.30 [ELSE] 2dup s" bsd" search nip nip [IF] 2drop s" libffi.so"
24 :     [ELSE] 2dup s" cygwin" str= [IF] 2drop s" libffi.dll"
25 : pazsan 1.32 [ELSE] 2dup s" darwin" string-prefix? [IF] 2drop s" libffi.dylib"
26 : pazsan 1.31 [ELSE] 2drop s" libffi" [THEN] [THEN] [THEN] [THEN] [THEN]
27 : pazsan 1.30 open-lib [if]
28 : pazsan 1.33 \ warnings @ [IF] .( including libffi.fs ) [THEN]
29 : pazsan 1.29 include libffi.fs
30 : pazsan 1.7 [ELSE]
31 : pazsan 1.29 s" libavcall.so" open-lib 0<>
32 :     s" libcallback.so" open-lib 0<> and [if]
33 : pazsan 1.33 \ warnings @ [IF] .( including fflib.fs [ffcall] ) [THEN]
34 : pazsan 1.29 include fflib.fs
35 : pazsan 1.10 [ELSE]
36 : pazsan 1.29 .( Neither libffi nor ffcall are available ) cr
37 :     abort
38 : anton 1.19 .( Using oldlib.fs; incompatible with fflib.fs and libffi.fs) cr
39 : pazsan 1.10 include oldlib.fs
40 :     [THEN]
41 : pazsan 1.7 [THEN]
42 : pazsan 1.1
43 : pazsan 1.11 \ testing stuff
44 :    
45 : pazsan 1.18 [IFUNDEF] libc
46 :     s" os-type" environment? [IF]
47 :     2dup s" linux-gnu" str= [IF] 2drop
48 : pazsan 1.28 cell 8 = [IF]
49 :     library libc /lib64/libc.so.6
50 :     [ELSE]
51 :     library libc /lib/libc.so.6
52 :     [THEN]
53 : pazsan 1.18 [ELSE] 2dup s" cygwin" str= [IF] 2drop
54 :     library libc cygwin1.dll
55 : pazsan 1.20 [ELSE] 2dup s" bsd" search nip nip [IF] 2drop
56 : pazsan 1.18 library libc libc.so
57 : pazsan 1.20 [ELSE] 2dup s" darwin" string-prefix? [IF] 2drop
58 :     library libc libc.dylib
59 :     [ELSE] 2drop \ or add your stuff here
60 :     [THEN]
61 : pazsan 1.18 [THEN]
62 :     [THEN]
63 :     [THEN]
64 :     [THEN]
65 :     [THEN]
66 :    
67 : pazsan 1.11 [ifdef] testing
68 :    
69 :     library libc libc.so.6
70 :    
71 :     libc sleep int (int) sleep
72 : anton 1.16 libc open ptr int int (int) open
73 : pazsan 1.11 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 :    
98 : pazsan 1.14 fptr 2:1call int int (int)
99 : pazsan 1.12
100 :     : test c_plus 2:1call ;
101 : pazsan 1.11
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]

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help