-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdint.h> | ||
|
||
#define WASM_EXPORT __attribute__((visibility("default"))) | ||
|
||
static uint64_t fnv1(uint64_t state, uint64_t input) | ||
{ | ||
return (state ^ input) * 0x100000001b3; | ||
} | ||
|
||
static uint64_t threeab(uint64_t state, uint64_t input) | ||
{ | ||
return (3 * state) + input; | ||
} | ||
|
||
typedef uint64_t (*hashfn)(uint64_t state, uint64_t input); | ||
|
||
static hashfn fns[] = {fnv1, threeab}; | ||
|
||
WASM_EXPORT unsigned icall(unsigned steps) | ||
{ | ||
uint64_t input = 0x1234567890abcdef; | ||
|
||
uint64_t state = 0xcbf29ce484222325; | ||
for (unsigned i = 0; i < steps; i++) | ||
state = fns[i % 2](state, input); | ||
return state; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
1000_steps | ||
icall | ||
i:i | ||
1000 | ||
|
||
3242341221 | ||
|
Binary file not shown.