Skip to content

Commit

Permalink
Merge pull request #4980 from chrishavlin/fix_platform_deps
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Sep 5, 2024
2 parents f39ed50 + 851d57e commit c9b12af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
os: [
ubuntu-20.04,
windows-2019,
windows-2022,
macos-13, # x86_64
macos-14, # arm64
]
Expand Down
59 changes: 7 additions & 52 deletions yt/utilities/lib/platform_dep.h
Original file line number Diff line number Diff line change
@@ -1,59 +1,14 @@
#include <math.h>
#ifdef MS_WIN32
#include "malloc.h"
/*
note: the following implicitly sets a mininum VS version: conservative
minimum is _MSC_VER >= 1928 (VS 2019, 16.8), but may work for VS 2015
but that has not been tested. see https://github.com/yt-project/yt/pull/4980
and https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance
*/
#include <float.h>
typedef int int32_t;
typedef long long int64_t;
/* Taken from http://siliconandlithium.blogspot.com/2014/05/msvc-c99-mathh-header.html */
#define isnormal(x) ((_fpclass(x) == _FPCLASS_NN) || (_fpclass(x) == _FPCLASS_PN))
static __inline double rint(double x){
const double two_to_52 = 4.5035996273704960e+15;
double fa = fabs(x);
if(fa >= two_to_52){
return x;
} else{
return copysign(two_to_52 + fa - two_to_52, x);
}
}
#if _MSC_VER < 1928
static __inline long int lrint(double x){
return (long)rint(x);
}
#endif
static __inline double fmax(double x, double y){
return (x > y) ? x : y;
}
static __inline double fmin(double x, double y){
return (x < y) ? x : y;
}

/* adapted from http://www.johndcook.com/blog/cpp_erf/
code is under public domain license */

double erf(double x)
{
/* constants */
double a1 = 0.254829592;
double a2 = -0.284496736;
double a3 = 1.421413741;
double a4 = -1.453152027;
double a5 = 1.061405429;
double p = 0.3275911;
double t;
double y;

/* Save the sign of x */
int sign = 1;
if (x < 0)
sign = -1;
x = fabs(x);

/* A&S formula 7.1.26 */
t = 1.0/(1.0 + p*x);
y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);

return sign*y;
}
#include <stdint.h>
#elif defined(__FreeBSD__)
#include <stdint.h>
#include <stdlib.h>
Expand Down

0 comments on commit c9b12af

Please sign in to comment.