mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 14:41:32 +00:00
Isolated emscripten in new lib
This commit is contained in:
37
lib/emscripten/emtests/test_llvm_fabs.c
Normal file
37
lib/emscripten/emtests/test_llvm_fabs.c
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <float.h>
|
||||
#include <emscripten/emscripten.h>
|
||||
|
||||
float __attribute__((noinline)) negative10()
|
||||
{
|
||||
return (emscripten_random() < -1) ? 0.f : -10.5f;
|
||||
}
|
||||
|
||||
float __attribute__((noinline)) positive42()
|
||||
{
|
||||
return (emscripten_random() < -1) ? 0.f : 42.25f;
|
||||
}
|
||||
|
||||
double __attribute__((noinline)) negative_dbl_max()
|
||||
{
|
||||
return (emscripten_random() < -1) ? 0.f : -DBL_MAX;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("%f\n", __builtin_fabsf(negative10()));
|
||||
printf("%f\n", __builtin_fabsf(positive42()));
|
||||
printf("%f\n", __builtin_fabsf((float)negative_dbl_max()));
|
||||
|
||||
printf("%f\n", __builtin_fabs(negative10()));
|
||||
printf("%f\n", __builtin_fabs(positive42()));
|
||||
printf("%f\n", __builtin_fabs(negative_dbl_max()));
|
||||
}
|
Reference in New Issue
Block a user