comparison java/jdc/examples/UnixMathExample.java @ 21:40a2c4198016

- working jdc (but with memleaks, currently) - added example
author cslag
date Wed, 30 Mar 2016 23:40:52 +0200
parents
children 4ee8d6aa7721
comparison
equal deleted inserted replaced
20:77ca609422f1 21:40a2c4198016
1 import org.dyncall.DC;
2
3 class UnixMathExample
4 {
5 public static void main(String args[])
6 {
7 long lib = DC.load("/usr/lib/libm.so");
8 System.out.format("libm.so handle: %x\n", lib);
9
10 long f0 = DC.find(lib, "sqrtf");
11 System.out.format("found sqrft at: %x\n", f0);
12
13 long f1 = DC.find(lib, "pow");
14 System.out.format("found pow at: %x\n", f1);
15
16 long vm = DC.newCallVM(4096);
17 DC.argFloat(vm, 36.f);
18 float r0 = DC.callFloat(vm, f0);
19 System.out.format("sqrtf(36.f) = %f\n", r0);
20
21 DC.reset(vm);
22 DC.argDouble(vm, 2.);
23 DC.argDouble(vm, 10.);
24 double r1 = DC.callDouble(vm, f1);
25 System.out.format("pow(2., 10.) = %f\n", r1);
26 }
27 }
28