Browse Source

Use configure to detect presence of roundl to avoid redefining an actual function (possibly inline)

Luke Dashjr 12 years ago
parent
commit
b81767d717
2 changed files with 15 additions and 4 deletions
  1. 15 0
      configure.ac
  2. 0 4
      miner.h

+ 15 - 0
configure.ac

@@ -557,6 +557,21 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([static int __attribute__((warn_unused_result)
 			  AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
 			  AC_DEFINE([HAVE_WARN_UNUSED_RESULT], [1],
                                     [Define if __attribute__((warn_unused_result))]))
                                     [Define if __attribute__((warn_unused_result))]))
 
 
+AC_MSG_CHECKING([for roundl function])
+save_LIBS="${LIBS}"
+LIBS="$LIBS -lm"
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+	#include <math.h>
+]], [[
+	return (roundl(0.5) == 1.0);
+]])], [
+	AC_MSG_RESULT([yes])
+], [
+	AC_MSG_RESULT([no])
+	AC_DEFINE_UNQUOTED([roundl(x)], [(long double)((long long)((x==0)?0.0:((x)+(((x)>0)?0.5:-0.5))))], [Round to nearest integer, away from zero])
+])
+LIBS="${save_LIBS}"
+
 
 
 # byteswap functions
 # byteswap functions
 AH_TEMPLATE([HAVE_BYTESWAP_H], [Define to use byteswap macros from byteswap.h])
 AH_TEMPLATE([HAVE_BYTESWAP_H], [Define to use byteswap macros from byteswap.h])

+ 0 - 4
miner.h

@@ -190,10 +190,6 @@ static inline int fsync (int fd)
 #	endif
 #	endif
 #endif
 #endif
 
 
-#ifndef roundl
-#define roundl(x)   (long double)((long long)((x==0)?0.0:((x)+(((x)>0)?0.5:-0.5))))
-#endif
-
 enum alive {
 enum alive {
 	LIFE_WELL,
 	LIFE_WELL,
 	LIFE_SICK,
 	LIFE_SICK,