# HG changeset patch # User lbessard # Date 1231958861 -3600 # Node ID 83963465b7739312d861aadc364c2d665e0fcbe0 # Parent a0679c78143a78cc43399e9799242e3b11e0143c Bug on standard function not defined with EN/ENO fixed diff -r a0679c78143a -r 83963465b773 lib/iec_std_lib.h --- a/lib/iec_std_lib.h Fri Jan 09 17:05:24 2009 +0100 +++ b/lib/iec_std_lib.h Wed Jan 14 19:47:41 2009 +0100 @@ -956,6 +956,91 @@ /* Call previously defined macro for each ANY_NBIT */ ANY_NBIT(__rol_) +/*******************************************/ +/* Arithmetic and bitwise functions */ +/*******************************************/ + +#define __numeric(fname,TYPENAME, FUNC) \ +static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS, TYPENAME op){\ + TEST_EN(TYPENAME)\ + return FUNC(op);\ +} + + /**************/ + /* ABS */ + /**************/ +#define __abs_(TYPENAME) __numeric(__abs_, TYPENAME, abs) +ANY_NUM(__abs_) + + /**************/ + /* SQRT */ + /**************/ +#define __sqrt_(TYPENAME) __numeric(__sqrt_, TYPENAME, sqrt) +ANY_REAL(__sqrt_) + + /**************/ + /* LN */ + /**************/ +#define __ln_(TYPENAME) __numeric(__ln_, TYPENAME, ln) +ANY_REAL(__ln_) + + /**************/ + /* LOG */ + /**************/ +#define __log_(TYPENAME) __numeric(__log_, TYPENAME, log) +ANY_REAL(__log_) + + /**************/ + /* EXP */ + /**************/ +#define __exp_(TYPENAME) __numeric(__exp_, TYPENAME, exp) +ANY_REAL(__exp_) + + /**************/ + /* SIN */ + /**************/ +#define __sin_(TYPENAME) __numeric(__sin_, TYPENAME, sin) +ANY_REAL(__sin_) + + /**************/ + /* COS */ + /**************/ +#define __cos_(TYPENAME) __numeric(__cos_, TYPENAME, cos) +ANY_REAL(__cos_) + + /**************/ + /* TAN */ + /**************/ +#define __tan_(TYPENAME) __numeric(__tan_, TYPENAME, tan) +ANY_REAL(__tan_) + + /**************/ + /* ASIN */ + /**************/ +#define __asin_(TYPENAME) __numeric(__asin_, TYPENAME, asin) +ANY_REAL(__asin_) + + /**************/ + /* ACOS */ + /**************/ +#define __acos_(TYPENAME) __numeric(__acos_, TYPENAME, acos) +ANY_REAL(__acos_) + + /**************/ + /* ATAN */ + /**************/ +#define __atan_(TYPENAME) __numeric(__atan_, TYPENAME, atan) +ANY_REAL(__atan_) + + /**************/ + /* EXPT */ + /**************/ +#define __expt_(TYPENAME)\ +static inline TYPENAME __expt_##TYPENAME(EN_ENO_PARAMS, TYPENAME IN1, REAL IN2){\ + TEST_EN(TYPENAME)\ + return pow(IN1, IN2);\ +}ANY_REAL(__expt_) + /**************/ /* Selection */ /**************/ @@ -1014,7 +1099,7 @@ \ va_start (ap, op1); /* Initialize the argument list. */\ \ - for (i = 0; i < param_count; i++){\ + for (i = 0; i < param_count - 1; i++){\ TYPENAME tmp = va_arg (ap, VA_ARGS_##TYPENAME);\ op1 = COND ? tmp : op1;\ }\ @@ -1037,11 +1122,11 @@ /**************/ /* MIN */ /**************/ -#define __min_num(TYPENAME) __extrem_(__min, TYPENAME, op1 > tmp) +#define __min_num(TYPENAME) __extrem_(__min_, TYPENAME, op1 > tmp) ANY_NBIT(__min_num) ANY_NUM(__min_num) -__extrem_(__min, STRING, __STR_CMP(op1,tmp) > 0) +__extrem_(__min_, STRING, __STR_CMP(op1,tmp) > 0) #define __min_time(TYPENAME) __extrem_(__min_, TYPENAME, __TIME_CMP(op1, tmp) > 0) diff -r a0679c78143a -r 83963465b773 stage4/generate_c/il_code_gen.c --- a/stage4/generate_c/il_code_gen.c Fri Jan 09 17:05:24 2009 +0100 +++ b/stage4/generate_c/il_code_gen.c Wed Jan 14 19:47:41 2009 +0100 @@ -11866,9 +11866,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("sqrt")); + function_name = (symbol_c*)(new pragma_c("__sqrt_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -11897,9 +11898,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("ln")); + function_name = (symbol_c*)(new pragma_c("__ln_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -11928,9 +11930,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("log")); + function_name = (symbol_c*)(new pragma_c("__log_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -11959,9 +11962,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("exp")); + function_name = (symbol_c*)(new pragma_c("__exp_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -11990,9 +11994,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("sin")); + function_name = (symbol_c*)(new pragma_c("__sin_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -12021,9 +12026,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("cos")); + function_name = (symbol_c*)(new pragma_c("__cos_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -12052,9 +12058,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("tan")); + function_name = (symbol_c*)(new pragma_c("__tan_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -12083,9 +12090,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("asin")); + function_name = (symbol_c*)(new pragma_c("__asin_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -12114,9 +12122,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("acos")); + function_name = (symbol_c*)(new pragma_c("__acos_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -12145,9 +12154,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("atan")); + function_name = (symbol_c*)(new pragma_c("__atan_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -12793,7 +12803,7 @@ symbol_c *IN1_type_symbol = param_data_type; last_type_symbol = param_data_type; - if(search_expression_type->is_num_type(IN1_type_symbol)) + if(search_expression_type->is_real_type(IN1_type_symbol)) { { @@ -12810,10 +12820,11 @@ if(search_expression_type->is_num_type(IN2_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("pow")); + function_name = (symbol_c*)(new pragma_c("__expt_")); ADD_PARAM_LIST(IN1_param_value, IN1_type_symbol, function_param_iterator_c::direction_in) ADD_PARAM_LIST(IN2_param_value, IN2_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = last_type_symbol; + function_type_suffix = IN1_type_symbol; break; } diff -r a0679c78143a -r 83963465b773 stage4/generate_c/search_type_code.c --- a/stage4/generate_c/search_type_code.c Fri Jan 09 17:05:24 2009 +0100 +++ b/stage4/generate_c/search_type_code.c Wed Jan 14 19:47:41 2009 +0100 @@ -13336,7 +13336,7 @@ symbol_c *IN1_type_symbol = search_expression_type->get_type(IN1_param_value); last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN1_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN1_type_symbol, last_type_symbol) : IN1_type_symbol ; - if(search_expression_type->is_num_type(IN1_type_symbol)) + if(search_expression_type->is_real_type(IN1_type_symbol)) { { @@ -25595,7 +25595,7 @@ symbol_c *IN1_type_symbol = param_data_type; last_type_symbol = param_data_type; - if(search_expression_type->is_num_type(IN1_type_symbol)) + if(search_expression_type->is_real_type(IN1_type_symbol)) { { diff -r a0679c78143a -r 83963465b773 stage4/generate_c/st_code_gen.c --- a/stage4/generate_c/st_code_gen.c Fri Jan 09 17:05:24 2009 +0100 +++ b/stage4/generate_c/st_code_gen.c Wed Jan 14 19:47:41 2009 +0100 @@ -13374,9 +13374,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("sqrt")); + function_name = (symbol_c*)(new pragma_c("__sqrt_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -13409,9 +13410,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("ln")); + function_name = (symbol_c*)(new pragma_c("__ln_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -13444,9 +13446,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("log")); + function_name = (symbol_c*)(new pragma_c("__log_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -13479,9 +13482,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("exp")); + function_name = (symbol_c*)(new pragma_c("__exp_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -13514,9 +13518,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("sin")); + function_name = (symbol_c*)(new pragma_c("__sin_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -13549,9 +13554,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("cos")); + function_name = (symbol_c*)(new pragma_c("__cos_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -13584,9 +13590,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("tan")); + function_name = (symbol_c*)(new pragma_c("__tan_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -13619,9 +13626,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("asin")); + function_name = (symbol_c*)(new pragma_c("__asin_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -13654,9 +13662,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("acos")); + function_name = (symbol_c*)(new pragma_c("__acos_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -13689,9 +13698,10 @@ if(search_expression_type->is_real_type(IN_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("atan")); + function_name = (symbol_c*)(new pragma_c("__atan_")); ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = IN_type_symbol; + function_type_suffix = IN_type_symbol; break; } @@ -14361,7 +14371,7 @@ symbol_c *IN1_type_symbol = search_expression_type->get_type(IN1_param_value); last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN1_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN1_type_symbol, last_type_symbol) : IN1_type_symbol ; - if(search_expression_type->is_num_type(IN1_type_symbol)) + if(search_expression_type->is_real_type(IN1_type_symbol)) { { @@ -14378,10 +14388,11 @@ if(search_expression_type->is_num_type(IN2_type_symbol)) { - function_name = (symbol_c*)(new pragma_c("pow")); + function_name = (symbol_c*)(new pragma_c("__expt_")); ADD_PARAM_LIST(IN1_param_value, IN1_type_symbol, function_param_iterator_c::direction_in) ADD_PARAM_LIST(IN2_param_value, IN2_type_symbol, function_param_iterator_c::direction_in) symbol_c * return_type_symbol = last_type_symbol; + function_type_suffix = IN1_type_symbol; break; }