Skip to content

Instantly share code, notes, and snippets.

@gskachkov
Created June 27, 2018 07:40
Show Gist options
  • Save gskachkov/499edb11e2a32320c9b279cc93340aa5 to your computer and use it in GitHub Desktop.
Save gskachkov/499edb11e2a32320c9b279cc93340aa5 to your computer and use it in GitHub Desktop.
#define WASM_EXPORT __attribute__((visibility("default")))
extern long add_js(long int a, long int b);
long int add_wasm(long int a, long int b)
{
return a + b;
}
WASM_EXPORT
long int fibonacci_wasm(long int num)
{
long int a = 1, b = 0, temp;
while (num >= 0) {
temp = a;
a = add_wasm(a, b);
b = temp;
num--;
}
return b;
}
WASM_EXPORT
long int fibonacci_js(long int num)
{
long int a = 1, b = 0, temp;
while (num >= 0) {
temp = a;
a = add_js(a, b);
b = temp;
num--;
}
return b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment