1570af302Sopenharmony_ci#include <math.h> 2570af302Sopenharmony_ci#include <float.h> 3570af302Sopenharmony_ci 4570af302Sopenharmony_ci#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 5570af302Sopenharmony_cilong double fmaxl(long double x, long double y) 6570af302Sopenharmony_ci{ 7570af302Sopenharmony_ci return fmax(x, y); 8570af302Sopenharmony_ci} 9570af302Sopenharmony_ci#else 10570af302Sopenharmony_cilong double fmaxl(long double x, long double y) 11570af302Sopenharmony_ci{ 12570af302Sopenharmony_ci if (isnan(x)) 13570af302Sopenharmony_ci return y; 14570af302Sopenharmony_ci if (isnan(y)) 15570af302Sopenharmony_ci return x; 16570af302Sopenharmony_ci /* handle signed zeros, see C99 Annex F.9.9.2 */ 17570af302Sopenharmony_ci if (signbit(x) != signbit(y)) 18570af302Sopenharmony_ci return signbit(x) ? y : x; 19570af302Sopenharmony_ci return x < y ? y : x; 20570af302Sopenharmony_ci} 21570af302Sopenharmony_ci#endif 22