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