C: Support more intrinsic functions
https://github.com/lfortran/lfortran/pull/1747
These are good changes. It would be good to figure out how to test them, and possibly we can simply test it in LFortran. Let's keep this open and merge it in LFortran first.
I'll get the Fortran version in shape first.
@certik The change is reflected in LPython after the sync. Just added a test so that we can merge this.
Oh, the tests fail because of infinite recursion caused due to:
// in main.c
double log(double x)
{
double _lpython_return_variable;
_lpython_return_variable = _lfortran_dlog(x);
return _lpython_return_variable;
}
// in lfortran_intrinsics.h
LFORTRAN_API double _lfortran_dlog(double x)
{
return log(x);
}
Yes. I have experienced this too. I don't know how to fix this.
That seems like a bug in the runtime library.
I think mangling the log name here would fix the issue: https://github.com/lcompilers/lpython/blob/d78559ba5eb15ba45af7218cdedc703c60a9ad06/src/runtime/math.py#L579-L580