Apply clang format for samples files (#833)
Apply clang format for c source files under samples folder
This commit is contained in:
@ -8,21 +8,25 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int intToStr(int x, char* str, int str_len, int digit);
|
||||
int get_pow(int x, int y);
|
||||
int32_t calculate_native(int32_t n, int32_t func1, int32_t func2);
|
||||
int
|
||||
intToStr(int x, char *str, int str_len, int digit);
|
||||
int
|
||||
get_pow(int x, int y);
|
||||
int32_t
|
||||
calculate_native(int32_t n, int32_t func1, int32_t func2);
|
||||
|
||||
//
|
||||
// Primitive parameters functions
|
||||
//
|
||||
float generate_float(int iteration, double seed1, float seed2)
|
||||
float
|
||||
generate_float(int iteration, double seed1, float seed2)
|
||||
{
|
||||
float ret;
|
||||
|
||||
printf ("calling into WASM function: %s\n", __FUNCTION__);
|
||||
printf("calling into WASM function: %s\n", __FUNCTION__);
|
||||
|
||||
for (int i=0; i<iteration; i++){
|
||||
ret += 1.0f/seed1 + seed2;
|
||||
for (int i = 0; i < iteration; i++) {
|
||||
ret += 1.0f / seed1 + seed2;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -30,10 +34,11 @@ float generate_float(int iteration, double seed1, float seed2)
|
||||
|
||||
// Converts a floating-point/double number to a string.
|
||||
// intToStr() is implemented outside wasm app
|
||||
void float_to_string(float n, char* res, int res_size, int afterpoint)
|
||||
void
|
||||
float_to_string(float n, char *res, int res_size, int afterpoint)
|
||||
{
|
||||
|
||||
printf ("calling into WASM function: %s\n", __FUNCTION__);
|
||||
printf("calling into WASM function: %s\n", __FUNCTION__);
|
||||
|
||||
// Extract integer part
|
||||
int ipart = (int)n;
|
||||
@ -57,25 +62,28 @@ void float_to_string(float n, char* res, int res_size, int afterpoint)
|
||||
}
|
||||
}
|
||||
|
||||
int32_t mul7(int32_t n)
|
||||
int32_t
|
||||
mul7(int32_t n)
|
||||
{
|
||||
printf ("calling into WASM function: %s,", __FUNCTION__);
|
||||
printf("calling into WASM function: %s,", __FUNCTION__);
|
||||
n = n * 7;
|
||||
printf (" %s return %d \n", __FUNCTION__, n);
|
||||
printf(" %s return %d \n", __FUNCTION__, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
int32_t mul5(int32_t n)
|
||||
int32_t
|
||||
mul5(int32_t n)
|
||||
{
|
||||
printf ("calling into WASM function: %s,", __FUNCTION__);
|
||||
printf("calling into WASM function: %s,", __FUNCTION__);
|
||||
n = n * 5;
|
||||
printf (" %s return %d \n", __FUNCTION__, n);
|
||||
printf(" %s return %d \n", __FUNCTION__, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
int32_t calculate(int32_t n)
|
||||
int32_t
|
||||
calculate(int32_t n)
|
||||
{
|
||||
printf ("calling into WASM function: %s\n", __FUNCTION__);
|
||||
printf("calling into WASM function: %s\n", __FUNCTION__);
|
||||
int32_t (*f1)(int32_t) = &mul5;
|
||||
int32_t (*f2)(int32_t) = &mul7;
|
||||
return calculate_native(n, (uint32_t)f1, (uint32_t)f2);
|
||||
|
||||
Reference in New Issue
Block a user