Index: libgfortran/intrinsics/c99_functions.c =================================================================== --- libgfortran/intrinsics/c99_functions.c (revision 119576) +++ libgfortran/intrinsics/c99_functions.c (working copy) @@ -176,6 +176,15 @@ } #endif +#ifndef HAVE_FMODF +#define HAVE_FMODF 1 +float +fmodf (float x, float y) +{ + return (float) fmod (x, y); +} +#endif + #ifndef HAVE_FREXPF #define HAVE_FREXPF 1 float @@ -474,6 +483,47 @@ #endif +#ifndef HAVE_FLOORL +#define HAVE_FLOORL 1 +long double +floorl (long double x) +{ + /* Zero, possibly signed. */ + if (x == 0) + return x; + + /* Large magnitude. */ + if (x > DBL_MAX || x < (-DBL_MAX)) + return x; + + /* Small positive values. */ + if (x >= 0 && x < DBL_MIN) + return 0; + + /* Small negative values. */ + if (x < 0 && x > (-DBL_MIN)) + return -1; + + return floor (x); +} +#endif + + +#ifndef HAVE_FMODL +#define HAVE_FMODL 1 +long double +fmodl (long double x, long double y) +{ + if (y == 0.0L) + return 0.0L; + + /* Need to check that the result has the same sign as x and magnitude + less than the magnitude of y. */ + return x - floorl (x / y) * y; +} +#endif + + #if !defined(HAVE_CABSF) #define HAVE_CABSF 1 float Index: libgfortran/c99_protos.h =================================================================== --- libgfortran/c99_protos.h (revision 119576) +++ libgfortran/c99_protos.h (working copy) @@ -100,6 +100,21 @@ extern float floorf(float); #endif +#ifndef HAVE_FLOORL +#define HAVE_FLOORL 1 +extern long double floorl (long double x); +#endif + +#ifndef HAVE_FMODF +#define HAVE_FMODF 1 +extern float fmodf (float x, float y); +#endif + +#ifndef HAVE_FMODL +#define HAVE_FMODL 1 +extern long double fmodl (long double x, long double y); +#endif + #ifndef HAVE_FREXPF #define HAVE_FREXPF 1 extern float frexpf(float, int *); Index: libgfortran/configure.ac =================================================================== --- libgfortran/configure.ac (revision 119576) +++ libgfortran/configure.ac (working copy) @@ -238,6 +238,9 @@ AC_CHECK_LIB([m],[floorf],[AC_DEFINE([HAVE_FLOORF],[1],[libm includes floorf])]) AC_CHECK_LIB([m],[floor],[AC_DEFINE([HAVE_FLOOR],[1],[libm includes floor])]) AC_CHECK_LIB([m],[floorl],[AC_DEFINE([HAVE_FLOORL],[1],[libm includes floorl])]) +AC_CHECK_LIB([m],[fmodf],[AC_DEFINE([HAVE_FMODF],[1],[libm includes fmodf])]) +AC_CHECK_LIB([m],[fmod],[AC_DEFINE([HAVE_FMOD],[1],[libm includes fmod])]) +AC_CHECK_LIB([m],[fmodl],[AC_DEFINE([HAVE_FMODL],[1],[libm includes fmodl])]) AC_CHECK_LIB([m],[frexpf],[AC_DEFINE([HAVE_FREXPF],[1],[libm includes frexpf])]) AC_CHECK_LIB([m],[frexp],[AC_DEFINE([HAVE_FREXP],[1],[libm includes frexp])]) AC_CHECK_LIB([m],[frexpl],[AC_DEFINE([HAVE_FREXPL],[1],[libm includes frexpl])])