Aggiorna index.js
This commit is contained in:
parent
f4f473b949
commit
96c5a78739
1 changed files with 13 additions and 6 deletions
19
index.js
19
index.js
|
|
@ -1,14 +1,21 @@
|
||||||
import { dlopen, FFIType, suffix } from "bun:ffi";
|
import { dlopen, FFIType, suffix } from "bun:ffi";
|
||||||
|
|
||||||
const path = `./libfibonacci.so`;
|
const path = `./libtesticolo.so`;
|
||||||
|
|
||||||
const { symbols } = dlopen(path, {
|
const { symbols } = dlopen(path, {
|
||||||
fibonacci_gmp: {
|
testicolo: {
|
||||||
args: [],
|
args: [FFIType.cstring, FFIType.cstring],
|
||||||
returns: FFIType.cstring,
|
returns: FFIType.void,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = symbols.fibonacci_gmp();
|
const input = "qwertyuiopasdfghjkllzxcvbnm123456789mnbvcxzlkjhgfdsapoiuytrewq1234567890";
|
||||||
console.log("Fibonacci(25000) =", result);
|
const output = new ArrayBuffer(input.length + 1);
|
||||||
|
const outputView = new Uint8Array(output);
|
||||||
|
|
||||||
|
// Call the function with the input string
|
||||||
|
symbols.testicolo(input, outputView);
|
||||||
|
|
||||||
|
// Convert the output buffer to a string and log it
|
||||||
|
const result = new TextDecoder().decode(outputView);
|
||||||
|
console.log(result);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue