lpython icon indicating copy to clipboard operation
lpython copied to clipboard

C: Support more intrinsic functions

Open Smit-create opened this issue 2 years ago • 7 comments

https://github.com/lfortran/lfortran/pull/1747

Smit-create avatar Jun 03 '23 04:06 Smit-create

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.

certik avatar Jun 04 '23 01:06 certik

I'll get the Fortran version in shape first.

certik avatar Jun 12 '23 18:06 certik

@certik The change is reflected in LPython after the sync. Just added a test so that we can merge this.

Smit-create avatar Jul 31 '23 11:07 Smit-create

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);
}

Smit-create avatar Jul 31 '23 12:07 Smit-create

Yes. I have experienced this too. I don't know how to fix this.

czgdp1807 avatar Aug 03 '23 04:08 czgdp1807

That seems like a bug in the runtime library.

certik avatar Aug 04 '23 03:08 certik

I think mangling the log name here would fix the issue: https://github.com/lcompilers/lpython/blob/d78559ba5eb15ba45af7218cdedc703c60a9ad06/src/runtime/math.py#L579-L580

Thirumalai-Shaktivel avatar Oct 03 '23 04:10 Thirumalai-Shaktivel