mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 22:51:32 +00:00
Isolated emscripten in new lib
This commit is contained in:
28
lib/emscripten/emtests/test_stack_byval.c
Normal file
28
lib/emscripten/emtests/test_stack_byval.c
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2016 The Emscripten Authors. All rights reserved.
|
||||
* Emscripten is available under two separate licenses, the MIT license and the
|
||||
* University of Illinois/NCSA Open Source License. Both these licenses can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// We should also not blow up the stack with byval arguments
|
||||
#include <stdio.h>
|
||||
struct vec {
|
||||
int x, y, z;
|
||||
vec(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {}
|
||||
static vec add(vec a, vec b) { return vec(a.x + b.x, a.y + b.y, a.z + b.z); }
|
||||
};
|
||||
int main() {
|
||||
int total = 0;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
for (int j = 0; j < 1000; j++) {
|
||||
vec c(i + i % 10, j * 2, i % 255);
|
||||
vec d(j * 2, j % 255, i % 120);
|
||||
vec f = vec::add(c, d);
|
||||
total += (f.x + f.y + f.z) % 100;
|
||||
total %= 10240;
|
||||
}
|
||||
}
|
||||
printf("sum:%d*\n", total);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user