Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

Comments

(Trivial) (DragonFly) Some of the core/stdc/math c-library functions had the 'pure' attribute set#2161

Merged
dlang-bot merged 1 commit intodlang:masterfrom
dkgroot-dlang:fix_core_stdc_math
Apr 21, 2018
Merged

(Trivial) (DragonFly) Some of the core/stdc/math c-library functions had the 'pure' attribute set#2161
dlang-bot merged 1 commit intodlang:masterfrom
dkgroot-dlang:fix_core_stdc_math

Conversation

@dkgroot
Copy link
Contributor

@dkgroot dkgroot commented Apr 11, 2018

Phobos Compile Error:
std/math.d(4598): Error: pure function std.math.nearbyint cannot call impure function core.stdc.math.nearbyintl

Issue got apparent when dlang/phobos#6409 was merged.
Note: This fix only references DragonFly specific code

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @dkgroot! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + druntime#2161"

@dkgroot
Copy link
Contributor Author

dkgroot commented Apr 11, 2018

The pure attribute seems to be scattered around a little here.

Why aren't most or even all of these extern c-library math function calls 'pure'? I do not see how any of them could have side-effects. Maybe i am missing something :-)

BTW: I followed the GLIBC version and matched the ones that had to 'pure' attribute (for now).

@n8sh
Copy link
Member

n8sh commented Apr 17, 2018

@dkgroot The source for which functions are annotated pure is @ibuclaw's comment #2045 (comment):

I'll use gcc as a reference, math functions that set errno are marked as MATHFN_ERRNO

@@ -3378,25 +3378,25 @@ else version(DragonFlyBSD)
double cbrt(double x);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cbrt not pure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added pure to the cbrt function... Thanks for checking !

real fmaxl(real x, real y);
real fminl(real x, real y);
pure real fdiml(real x, real y);
pure real fmaxl(real x, real y);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fmax and fmaxf

real fdiml(real x, real y);
real fmaxl(real x, real y);
real fminl(real x, real y);
pure real fdiml(real x, real y);
Copy link
Member

@n8sh n8sh Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-DragonFlyBSD fdiml isn't marked pure. Same for nexttoward, nextafter.

EDIT: correction

pure real erfl(real x);
pure real erfcl(real x);
pure real lgammal(real x);
pure real tgammal(real x);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-DragonFlyBSD erf is marked pure but not erfc, lgamma, tgamma.

pure real fabsl(real x);
pure real hypotl(real x, real y);
pure real powl(real x, real y);
pure real sqrtl(real x);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-DragonFlyBSD cbrt and fabs are marked pure but not hypot, pow, sqrt.

pure real logbl(real x);
pure real modfl(real x, real *iptr);
pure real scalbnl(real x, int y);
pure real scalblnl(real x, c_long y);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-DragonFlyBSD modf is marked pure but not logb, scalb.

pure real frexpl(real x, int *exp);
int ilogbl(real x);
real ldexpl(real x, int exp);
pure real ldexpl(real x, int exp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-DragonFlyBSD frexp is marked pure but not exp, exp2, expm1, ldexp.

pure real atanhl(real x);
pure real coshl(real x);
pure real sinhl(real x);
pure real tanhl(real x);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-DragonFlyBSD tanh and asinh are marked pure but not acosh, atanh, cosh, sinh.

pure real acosl(real x);
pure real asinl(real x);
pure real atanl(real x);
pure real atan2l(real x, real y);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-DragonFlyBSD atan2 is not marked pure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking all of these. I guess i thought i saw a pattern when making the corrections, which was faulty.

@dkgroot
Copy link
Contributor Author

dkgroot commented Apr 18, 2018

@n8sh Thanks got checking ! Much appreciated.

@ibuclaw
Copy link
Member

ibuclaw commented Apr 20, 2018

Check whitespace is failing.

…te needed for DragonFly.

Caused trouble compiling phobos since dlang/phobos#6409

Phobos Compile Error:
std/math.d(4598): Error: `pure` function `std.math.nearbyint` cannot call impure function `core.stdc.math.nearbyintl`
@dkgroot dkgroot force-pushed the fix_core_stdc_math branch from 3b28cb8 to 8a70692 Compare April 21, 2018 12:51
@dlang-bot dlang-bot merged commit b2dc234 into dlang:master Apr 21, 2018
@dkgroot
Copy link
Contributor Author

dkgroot commented Apr 22, 2018

Thanks everyone !

dkgroot added a commit to dkgroot-ldc/druntime that referenced this pull request May 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants