[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lmathx missing nexttoward in cygwin
- From: David Manura <dm.lua@...>
- Date: Tue, 4 Aug 2009 21:50:35 -0400
lmathx [1] fails compilation under Cygwin:
lmathx.o:lmathx.c:(.text+0x85c): undefined reference to `_nexttoward'
Cygwin uses the newlib [2-3] C standard library, which lacks
nexttoward [4]. This is preventing LuaRocks and LuaDist from
installing lmathx cleanly under Cygwin.
The following patch will allow it to work:
--- lmathx.c~
+++ lmathx.c
@@ -186,11 +186,13 @@
return 1;
}
+#ifdef HAVE_NEXTTOWARD
static int Lnexttoward(lua_State *L)
{
lua_pushnumber(L,nexttoward(A(1),A(2)));
return 1;
}
+#endif
static int Lremainder(lua_State *L)
{
@@ -263,7 +265,9 @@
{ "logb", Llogb },
{ "nearbyint", Lnearbyint },
{ "nextafter", Lnextafter },
+#ifdef HAVE_NEXTTOWARD
{ "nexttoward", Lnexttoward },
+#endif
{ "remainder", Lremainder },
{ "rint", Lrint },
{ "round", Lround },
BTW, it's not clear to me when nexttoward is useful over nextafter.
Moreover, nexttoward has a signature using "long double", but lmathx
treats double and long double both as a lua_Number.
[1] http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lmathx
[2] http://en.wikipedia.org/wiki/Newlib
[3] http://sourceware.org/newlib/libm.html
[4] http://www.cygwin.com/ml/cygwin/2009-07/msg00919.html