[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 : anton 1.34 libffi-present [if]
21 :     require ./libffi.fs
22 :     [else]
23 :     ffcall-present [if]
24 :     require ./fflib.fs
25 :     [else]
26 :     .( Neither libffi nor ffcall are configured ) cr
27 :     .( If you have installed one of them, you can use libffi.fs or fflib.fs directly ) cr
28 :     .( Or you can just use the new, documented and better, but different, libcc.fs ) cr
29 : pazsan 1.29 abort
30 : anton 1.34 [then]
31 :     [then]
32 : pazsan 1.1
33 : pazsan 1.11 \ testing stuff
34 :    
35 : pazsan 1.36 [IFUNDEF] libc
36 :     s" os-type" environment? [IF]
37 :     2dup s" linux-gnu" str= [IF] 2drop
38 :     library libc libc.so.6
39 :     [ELSE] 2dup s" cygwin" str= [IF] 2drop
40 :     library libc cygwin1.dll
41 :     [ELSE] 2dup s" bsd" search nip nip [IF] 2drop
42 :     library libc libc.so
43 :     [ELSE] 2dup s" darwin" string-prefix? [IF] 2drop
44 :     library libc libc.dylib
45 :     [ELSE] 2drop \ or add your stuff here
46 :     [THEN]
47 :     [THEN]
48 :     [THEN]
49 :     [THEN]
50 :     [THEN]
51 :     [THEN]
52 : pazsan 1.18
53 : anton 1.35 0 [if]
54 : pazsan 1.11
55 :     library libc libc.so.6
56 :    
57 :     libc sleep int (int) sleep
58 : anton 1.16 libc open ptr int int (int) open
59 : pazsan 1.11 libc lseek int llong int (llong) lseek64
60 :     libc read int ptr int (int) read
61 :     libc close int (int) close
62 :    
63 :     library libm libm.so.6
64 :    
65 :     libm fmodf sf sf (sf) fmodf
66 :     libm fmod df df (fp) fmod
67 :    
68 :     \ example for a windows callback
69 :    
70 :     callback wincall (int) int int int int callback;
71 :    
72 :     :noname ( a b c d -- e ) 2drop 2drop 0 ; wincall do_timer
73 :    
74 :     \ test a callback
75 :    
76 :     callback 2:1 (int) int int callback;
77 :    
78 :     : cb-test ( a b -- c )
79 :     cr ." Testing callback"
80 :     cr ." arguments: " .s
81 :     cr ." result " + .s cr ;
82 :     ' cb-test 2:1 c_plus
83 :    
84 : pazsan 1.14 fptr 2:1call int int (int)
85 : pazsan 1.12
86 :     : test c_plus 2:1call ;
87 : pazsan 1.11
88 :     \ 3 4 test
89 :    
90 :     \ bigFORTH legacy library test
91 :    
92 :     library libX11 libX11.so.6
93 :    
94 :     legacy on
95 :    
96 :     1 libX11 XOpenDisplay XOpenDisplay ( name -- dpy )
97 :     5 libX11 XInternAtoms XInternAtoms ( atoms flag count names dpy -- status )
98 :    
99 :     legacy off
100 :    
101 :     [then]

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help