From e8fe2d48cca626e39bc170e845cf3d9ecf036f19 Mon Sep 17 00:00:00 2001 From: stpohle Date: Sun, 9 Nov 2003 16:35:08 +0000 Subject: [PATCH] fix for windows, because floorf and rintf didn't work there --- configure.in | 106 ++++++++++++++++++++++++++++++---------------- include/sysfunc.h | 18 +++++++- src/sysfunc.c | 11 ++++- 3 files changed, 96 insertions(+), 39 deletions(-) diff --git a/configure.in b/configure.in index 64fe415..cf8fcc1 100644 --- a/configure.in +++ b/configure.in @@ -42,14 +42,11 @@ dnl Checks for typedefs, structures, and compiler characteristics. case "$target" in *cygwin* | *mingw32* | *mingw32msvc* ) CFLAGS="$CFLAGS" - LIBS="$LIBS -liberty -lwsock32" - MATHLIB="" - SYS_GL_LIBS="-lopengl32 -lglu32" + LIBS="$LIBS -liberty -lwsock32 -lm" ;; *solaris* ) CFLAGS="$CFLAGS" LIBS="$LIBS -lsocket -lnsl -lm" - MATHLIB="-lm" AC_PATH_X AC_PATH_XTRA if test x$have_x = xyes; then @@ -60,49 +57,16 @@ case "$target" in fi ;; *) - MATHLIB="-lm" AC_PATH_X AC_PATH_XTRA if test x$have_x = xyes; then CFLAGS="$CFLAGS $X_CFLAGS" - SYS_GL_LIBS="$X_LIBS -lGL -lGLU" - else - SYS_GL_LIBS="-lGL -lGLU" fi ;; esac CFLAGS="$CFLAGS -Wall" -AC_SUBST(MATHLIB) - - - -dnl Check for OpenGL ***********************+ -dnl AC_MSG_CHECKING(for OpenGL support) -dnl have_opengl=no -dnl AC_TRY_COMPILE([ -dnl #if defined(__APPLE__) && defined(__MACH__) -dnl #include -dnl #include -dnl #else -dnl #include -dnl #include -dnl #endif -dnl ],[ -dnl ],[ -dnl have_opengl=yes -dnl ]) -dnl AC_MSG_RESULT($have_opengl) -dnl if test x$have_opengl = xyes; then -dnl CFLAGS="$CFLAGS" -dnl LIBS="$LIBS $SYS_GL_LIBS" -dnl AC_DEFINE(HAVE_OPENGL, [1], [OpenGL Headers found]) -dnl else -dnl AC_MSG_WARN(Unable to find OpenGL headers and libraries) -dnl fi - - dnl SDL_mixer ********************************** AC_ARG_WITH(sdlmixer-prefix, [ --with-sdlmixer-prefix=PFX prefix where SDL_mixer library is installed], sdlmixer_prefix="$withval", sdlmixer_prefix="") @@ -126,6 +90,74 @@ fi dnl Checks for library functions. +dnl Check for rintf and functions like that +AC_MSG_CHECKING(for rintf) +have_rintf=no +AC_TRY_COMPILE([ +],[ +int i; float f; i = rintf (f); +],[ +have_rintf=yes +]) +AC_MSG_RESULT($have_rintf) +if test x$have_rintf = xyes; then + AC_CHECK_LIB(m, rintf, have_rintf=yes, have_rintf=no , ) + if test x$have_rintf = xyes; then + AC_DEFINE(HAVE_RINTF, [1], [if rintf is working here]) + fi +fi + + +dnl Check for rintf and functions like that +AC_MSG_CHECKING(for rint) +have_rint=no +AC_TRY_COMPILE([ +],[ +int i; double f; i = rint (f); +],[ +have_rint=yes +]) +AC_MSG_RESULT($have_rint) +if test x$have_rint = xyes; then + AC_CHECK_LIB(m, rint, have_rint=yes, have_rint=no , ) + if test x$have_rint = xyes; then + AC_DEFINE(HAVE_RINT, [1], [if rint is working here]) + fi +fi + +dnl Check for floorf and functions like that +AC_MSG_CHECKING(for floorf) +have_floorf=no +AC_TRY_COMPILE([ +],[ +int i; float f; i = floorf (f); +],[ +have_floorf=yes +]) +AC_MSG_RESULT($have_floorf) +if test x$have_floorf = xyes; then + AC_CHECK_LIB(m, floorf, have_floorf=yes, have_floorf=no , ) + if test x$have_floorf = xyes; then + AC_DEFINE(HAVE_FLOORF, [1], [if floorf is working here]) + fi +fi + +dnl Check for floorf and functions like that +AC_MSG_CHECKING(for floor) +have_floor=no +AC_TRY_COMPILE([ +],[ +int i; double f; i = floor (f); +],[ +have_floor=yes +]) +AC_MSG_RESULT($have_floor) +if test x$have_floor = xyes; then + AC_CHECK_LIB(m, floor, have_floor=yes, have_floor=no , ) + if test x$have_floor = xyes; then + AC_DEFINE(HAVE_FLOOR, [1], [if floor is working here]) + fi +fi dnl Checks for Additional stuffs. diff --git a/include/sysfunc.h b/include/sysfunc.h index 1cb6c0f..6954450 100644 --- a/include/sysfunc.h +++ b/include/sysfunc.h @@ -1,4 +1,4 @@ -/* $Id: sysfunc.h,v 1.3 2003/09/23 20:28:24 stpohle Exp $ */ +/* $Id: sysfunc.h,v 1.4 2003/11/09 16:35:10 stpohle Exp $ */ /* include some system near functions */ #ifndef _SYSFUNC_H_ @@ -29,4 +29,20 @@ extern inline Sint32 s_swap32 (Sint32 i); extern _direntry *s_getdir (char *path); extern _direntry *s_dirfilter (_direntry *dirstart, signed char dirflags); +#ifndef HAVE_RINTF + #ifndef HAVE_RINT + extern inline float rintf (float f); + #else + #define rintf(__x) ((float)rint(double)__x) + #endif +#endif + +#ifndef HAVE_FLOORF + #ifndef HAVE_FLOOR + #define floorf(__x) ((float)((int)__x)) + #else + #define floorf(__x) ((float)floor((double)__x)) + #endif +#endif + #endif diff --git a/src/sysfunc.c b/src/sysfunc.c index 988c1a0..0113819 100644 --- a/src/sysfunc.c +++ b/src/sysfunc.c @@ -1,4 +1,4 @@ -/* $Id: sysfunc.c,v 1.19 2003/09/11 19:44:32 stpohle Exp $ +/* $Id: sysfunc.c,v 1.20 2003/11/09 16:35:10 stpohle Exp $ sysfunc.c - this file hold some routines for the system functions.. like d_delay */ @@ -222,3 +222,12 @@ inline Sint32 s_swap32 (Sint32 i) { return r; }; + +#if !defined(HAVE_RINTF) && !defined(HAVE_RINT) +inline float rintf (float f) { + if (CUTINT (f) < 0.5f) + return (floorf (f)); + else + return (floorf (f + 1.0f)); +}; +#endif