[gforth] / gforth / lib.fs  

gforth: gforth/lib.fs


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

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help