[gforth] / gforth / lib.fs  

gforth: gforth/lib.fs


1 : pazsan 1.1 \ lib.fs shared library support package 11may97py
2 :    
3 : anton 1.17 \ Copyright (C) 1995,1996,1997,1998,2000,2003,2005,2006 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 :     \ as published by the Free Software Foundation; either version 2
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, write to the Free Software
19 : anton 1.5 \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
20 : pazsan 1.1
21 : pazsan 1.7 [IFDEF] av-call-int
22 :     include fflib.fs
23 :     [ELSE]
24 : pazsan 1.10 [IFDEF] ffi-call
25 :     include libffi.fs
26 :     [ELSE]
27 :     include oldlib.fs
28 :     [THEN]
29 : pazsan 1.7 [THEN]
30 : pazsan 1.1
31 : pazsan 1.11 \ testing stuff
32 :    
33 : pazsan 1.18 [IFUNDEF] libc
34 :     s" os-type" environment? [IF]
35 :     2dup s" linux-gnu" str= [IF] 2drop
36 :     library libc libc.so.6
37 :     [ELSE] 2dup s" cygwin" str= [IF] 2drop
38 :     library libc cygwin1.dll
39 :     [ELSE] s" bsd" search nip nip [IF]
40 :     library libc libc.so
41 :     [THEN]
42 :     [THEN]
43 :     [THEN]
44 :     [THEN]
45 :     [THEN]
46 :    
47 : pazsan 1.11 [ifdef] testing
48 :    
49 :     library libc libc.so.6
50 :    
51 :     libc sleep int (int) sleep
52 : anton 1.16 libc open ptr int int (int) open
53 : pazsan 1.11 libc lseek int llong int (llong) lseek64
54 :     libc read int ptr int (int) read
55 :     libc close int (int) close
56 :    
57 :     library libm libm.so.6
58 :    
59 :     libm fmodf sf sf (sf) fmodf
60 :     libm fmod df df (fp) fmod
61 :    
62 :     \ example for a windows callback
63 :    
64 :     callback wincall (int) int int int int callback;
65 :    
66 :     :noname ( a b c d -- e ) 2drop 2drop 0 ; wincall do_timer
67 :    
68 :     \ test a callback
69 :    
70 :     callback 2:1 (int) int int callback;
71 :    
72 :     : cb-test ( a b -- c )
73 :     cr ." Testing callback"
74 :     cr ." arguments: " .s
75 :     cr ." result " + .s cr ;
76 :     ' cb-test 2:1 c_plus
77 :    
78 : pazsan 1.14 fptr 2:1call int int (int)
79 : pazsan 1.12
80 :     : test c_plus 2:1call ;
81 : pazsan 1.11
82 :     \ 3 4 test
83 :    
84 :     \ bigFORTH legacy library test
85 :    
86 :     library libX11 libX11.so.6
87 :    
88 :     legacy on
89 :    
90 :     1 libX11 XOpenDisplay XOpenDisplay ( name -- dpy )
91 :     5 libX11 XInternAtoms XInternAtoms ( atoms flag count names dpy -- status )
92 :    
93 :     legacy off
94 :    
95 :     [then]

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help