Changeset 14003


Ignore:
Timestamp:
Nov 9, 2019 12:09:01 PM (10 days ago)
Author:
Christian Andersson
Message:

Fixed segfault and minor refactoring of math.h. Related to ticket:5868

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-cw-2658/RuntimeLibrary/src/jmi/jmi_math.c

    r10859 r14003  
    2222
    2323
    24 void jmi_log_func_or_eq(jmi_t *jmi, const char cathegory_name[], const char func_name[], const char msg[], const char val[]) {
     24void jmi_log_func_or_eq(jmi_t *jmi, const char category_name[], const char func_name[], const char msg[], const char val[]) {
     25    if (jmi == NULL) jmi = jmi_get_current();
     26   
    2527    if (func_name != NULL) {
    2628        char buf[64];
    27         sprintf(buf, "%s%s", cathegory_name, "InFunc");
     29        sprintf(buf, "%s%s", category_name, "InFunc");
    2830        jmi_log_node(jmi->log, logWarning, buf, "<func: %s, exp: %s, val:%s>", func_name, msg, val);
    2931    } else {
    30         jmi_log_node(jmi->log, logWarning, cathegory_name, "<exp:%s, val: %s>", msg, val);
     32        jmi_log_node(jmi->log, logWarning, category_name, "<exp:%s, val: %s>", msg, val);
    3133    }
    3234}
     
    4547void jmi_inf_log(jmi_t *jmi, const char func_name[], const char msg[], jmi_real_t res, jmi_real_t x) {
    4648    if (((res - res) != 0)) {
    47         if (jmi == NULL) jmi = jmi_get_current();
    4849       
    4950        if (res > 0) {
     
    6768        sprintf(val, "%.14E, %.14E", num, den);
    6869       
    69         if (jmi == NULL) jmi = jmi_get_current();
    7070        jmi_log_func_or_eq(jmi, "DivideByZero", func_name, msg, val);
    7171    }
     
    152152        sprintf(val, "%.14E, %.14E", x, y);
    153153       
    154         if (jmi == NULL) jmi = jmi_get_current();
    155154        jmi_log_func_or_eq(jmi, "IllegalAtan2Input", func_name, msg, val);
    156155    }
     
    170169    jmi_real_t to_return = pow(x, y);
    171170
     171    /* The returned value is not a number */
    172172    if ((to_return - to_return) != 0) {
    173         /* The returned value is not a number */
    174         if (jmi == NULL)
    175             jmi = jmi_get_current();
    176173
    177174        /* Check that the inputs are in the domain of the function*/
     
    219216    jmi_real_t to_return = log(x);
    220217   
     218    /* The returned value is not a number */
    221219    if ((to_return - to_return) != 0) {
    222         /* The returned value is not a number */
    223         if (jmi == NULL) jmi = jmi_get_current();
    224220       
    225221        if (x == 0) {
     
    250246    jmi_real_t to_return = log10(x);
    251247   
     248    /* The returned value is not a number */
    252249    if ((to_return - to_return) != 0) {
    253         /* The returned value is not a number */
    254         if (jmi == NULL) jmi = jmi_get_current();
    255        
     250
    256251        if (x == 0) {
    257252            /* Pole problem, will return -JMI_INF */
Note: See TracChangeset for help on using the changeset viewer.