annotate erlang/erldc/test/callf_SUITE.erl @ 45:da553362fa7c

- forgot to bounce version for last commit on oct 27
author Tassilo Philipp
date Thu, 12 Nov 2020 19:56:33 +0100
parents 0cfcc391201f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 %% Copyright (c) 2014 Erik Mackdanz <erikmack@gmail.com>
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 %% Permission to use, copy, modify, and distribute this software for any
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 %% purpose with or without fee is hereby granted, provided that the above
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 %% copyright notice and this permission notice appear in all copies.
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 %% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 %% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
9 %% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 %% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11 %% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15 -module(callf_SUITE).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 -compile(export_all).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 -define(VMSZ, 1024).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 all() ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 [
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 argf_one,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 argf_excessive_format,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23 argf_excessive_args,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 argf_struct,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25 callf_one,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26 callf_bool,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27 callf_void,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 callf_char,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29 callf_uchar,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30 callf_short,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31 callf_ushort,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32 callf_int,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33 callf_uint,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34 callf_long,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
35 callf_ulong,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36 callf_longlong,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
37 callf_ulonglong,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
38 callf_float,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39 callf_double,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
40 callf_pointer,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
41 callf_struct
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42 ].
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
43
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
44 argf_one(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
45 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
46 {ok,Sym} = dyncall:find_symbol(Libm, "several_args"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
47 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
48 ok = dyncall:argf(CallVm,"jcZf)Z",[-125,$[,"foo",6.2]),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
49 {ok,"Your args were -125, [, foo, 6.2"} = dyncall:call_string(CallVm,Sym).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
50
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
51 argf_excessive_format(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
52 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
53 {error,invalid_format} = dyncall:argf(CallVm,"jjjjjjjjcZf)Z",[-125,91,"foo",6.2]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
54
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
55 argf_excessive_args(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
56 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
57 {error,invalid_format} = dyncall:argf(CallVm,"jcZf)Z",[-125,91,"foo",6.2,7,7,7,7,7,7]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
58
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
59 argf_struct(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
60 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
61 {error,not_implemented} = dyncall:argf(CallVm,"jTZf)Z",[-125,91,"foo",6.2]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
62
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
63 callf_one(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
64 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
65 {ok,Sym} = dyncall:find_symbol(Libm, "several_args"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
66 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
67 {ok,"Your args were -125, [, foo, 6.2"} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
68 dyncall:callf(CallVm,Sym,"jcZf)Z",[-125,91,"foo",6.2]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
69
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
70 callf_bool(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
71 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72 {ok,Sym} = dyncall:find_symbol(Libm, "is_false"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74 {ok,true} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
75 dyncall:callf(CallVm,Sym,"B)B",[false]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
76
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
77 callf_void(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
79 {ok,Sym} = dyncall:find_symbol(Libm, "noop"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
80 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
81 ok = dyncall:callf(CallVm,Sym,")v",[]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
82
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83 callf_struct(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
84 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
85 {ok,Sym} = dyncall:find_symbol(Libm, "several_args"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
86 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
87 {error,not_implemented} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
88 dyncall:callf(CallVm,Sym,"jcZf)T",[-125,91,"foo",6.2]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
89
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
90 callf_char(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
91 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
92 {ok,Sym} = dyncall:find_symbol(Libm, "get_next_char"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
93 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
94 {ok,120} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
95 dyncall:callf(CallVm,Sym,"c)c",[119]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
96
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
97 callf_uchar(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
98 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
99 {ok,Sym} = dyncall:find_symbol(Libm, "get_next_char_u"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
100 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
101 {ok,222} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
102 dyncall:callf(CallVm,Sym,"C)C",[221]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
103
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
104 callf_short(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
105 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
106 {ok,Sym} = dyncall:find_symbol(Libm, "times_three"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
107 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
108 {ok,-12} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
109 dyncall:callf(CallVm,Sym,"s)s",[-4]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
110
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
111 callf_ushort(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
112 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
113 {ok,Sym} = dyncall:find_symbol(Libm, "times_three_u"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
114 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
115 {ok,12} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
116 dyncall:callf(CallVm,Sym,"S)S",[4]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
117
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
118 callf_int(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
119 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
120 {ok,Sym} = dyncall:find_symbol(Libm, "is_false"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
121 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
122 {ok,1} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
123 dyncall:callf(CallVm,Sym,"i)i",[0]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
124
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
125 callf_uint(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
126 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
127 {ok,Sym} = dyncall:find_symbol(Libm, "dual_increment_u"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
128 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
129 {ok,6} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
130 dyncall:callf(CallVm,Sym,"I)I",[4]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
131
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
132 callf_long(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
133 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
134 {ok,Sym} = dyncall:find_symbol(Libm, "add_nineteen"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
135 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
136 {ok,19} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
137 dyncall:callf(CallVm,Sym,"j)j",[0]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
138
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
139 callf_ulong(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
140 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
141 {ok,Sym} = dyncall:find_symbol(Libm, "add_nineteen_u"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
142 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
143 {ok,23} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
144 dyncall:callf(CallVm,Sym,"J)J",[4]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
145
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
146 callf_longlong(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
147 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
148 {ok,Sym} = dyncall:find_symbol(Libm, "subtract_four"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
149 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
150 {ok,-1} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
151 dyncall:callf(CallVm,Sym,"l)l",[3]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
152
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
153 callf_ulonglong(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
154 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
155 {ok,Sym} = dyncall:find_symbol(Libm, "subtract_four_u"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
156 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
157 {ok,5} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
158 dyncall:callf(CallVm,Sym,"L)L",[9]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
159
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
160 callf_float(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
161 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
162 {ok,Sym} = dyncall:find_symbol(Libm, "calculate_pi"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
163 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
164 {ok,3.0} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
165 dyncall:callf(CallVm,Sym,"f)f",[1.0]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
166
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
167 callf_double(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
168 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
169 {ok,Sym} = dyncall:find_symbol(Libm, "times_pi"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
170 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
171 {ok,6.2} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
172 dyncall:callf(CallVm,Sym,"d)d",[2.0]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
173
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
174 callf_pointer(_) ->
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
175 {ok,Libm} = dyncall:load_library("erldc_testtargets"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
176 {ok,Sym} = dyncall:find_symbol(Libm, "coolmalloc"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
177 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
178 {ok,MyMemory} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
179 dyncall:callf(CallVm,Sym,"j)p",[42]),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
180 ok = dyncall:reset(CallVm),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
181 {ok,Sym2} = dyncall:find_symbol(Libm, "coolidentity"),
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
182 %% Surprisingly, this works. The _resource handle
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
183 %% returned to erlang from callf compares equal in
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
184 %% erlang to the _resource handle passed as an arg.
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
185 {ok,MyMemory} =
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
186 dyncall:callf(CallVm,Sym2,"p)p",[MyMemory]).
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
187
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
188
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
189
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
190
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
191
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
192