Browse Source

new macro 'l_floor' (allows 'floorf' even when other math operations
do not have an 'f' variant)

Roberto Ierusalimschy 12 years ago
parent
commit
453450d687
4 changed files with 10 additions and 9 deletions
  1. 2 2
      lapi.c
  2. 2 2
      ltable.c
  3. 4 3
      luaconf.h
  4. 2 2
      lvm.c

+ 2 - 2
lapi.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.c,v 2.181 2013/06/04 19:34:51 roberto Exp roberto $
+** $Id: lapi.c,v 2.182 2013/06/14 18:32:45 roberto Exp roberto $
 ** Lua API
 ** See Copyright Notice in lua.h
 */
@@ -390,7 +390,7 @@ LUA_API lua_Unsigned lua_tounsignedx (lua_State *L, int idx, int *pisnum) {
       const lua_Number twop = (~(lua_Unsigned)0) + cast_num(1);
       lua_Number n = fltvalue(o);
       int neg = 0;
-      n = l_mathop(floor)(n);
+      n = l_floor(n);
       if (n < 0) {
         neg = 1;
         n = -n;

+ 2 - 2
ltable.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltable.c,v 2.76 2013/05/27 12:43:37 roberto Exp roberto $
+** $Id: ltable.c,v 2.77 2013/05/29 14:05:03 roberto Exp roberto $
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 */
@@ -70,7 +70,7 @@
 /* checks whether a float has a value representable as a lua_Integer
    (and does the conversion if so) */
 #define numisinteger(x,i) \
-	(((x) == l_mathop(floor)(x)) && luaV_numtointeger(x, i))
+	(((x) == l_floor(x)) && luaV_numtointeger(x, i))
 
 
 #define dummynode		(&dummynode_)

+ 4 - 3
luaconf.h

@@ -1,5 +1,5 @@
 /*
-** $Id: luaconf.h,v 1.181 2013/05/26 13:35:52 roberto Exp roberto $
+** $Id: luaconf.h,v 1.182 2013/06/13 19:35:08 roberto Exp roberto $
 ** Configuration file for Lua
 ** See Copyright Notice in lua.h
 */
@@ -423,6 +423,7 @@
 #define LUA_NUMBER_FMT		"%.7g"
 
 #define l_mathop(op)		op##f
+#define l_floor(x)		(floorf(x))
 
 #define lua_str2number(s,p)	strtof((s), (p))
 
@@ -438,6 +439,7 @@
 #define LUA_NUMBER_FMT		"%.14g"
 
 #define l_mathop(op)		op
+#define l_floor(x)		(floor(x))
 
 #define lua_str2number(s,p)	strtod((s), (p))
 
@@ -452,7 +454,6 @@
 #define lua_number2str(s,n)	sprintf((s), LUA_NUMBER_FMT, (n))
 
 
-
 /*
 @@ The luai_num* macros define the primitive operations over numbers.
 @* They should work for any size of floating numbers.
@@ -461,7 +462,7 @@
 /* the following operations need the math library */
 #if defined(lobject_c) || defined(lvm_c)
 #include <math.h>
-#define luai_nummod(L,a,b)	((a) - l_mathop(floor)((a)/(b))*(b))
+#define luai_nummod(L,a,b)	((a) - l_floor((a)/(b))*(b))
 #define luai_numpow(L,a,b)	(l_mathop(pow)(a,b))
 #endif
 

+ 2 - 2
lvm.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.c,v 2.173 2013/06/07 19:02:05 roberto Exp roberto $
+** $Id: lvm.c,v 2.174 2013/06/19 14:27:00 roberto Exp roberto $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -92,7 +92,7 @@ int luaV_tointeger_ (const TValue *obj, lua_Integer *p) {
   lua_Number n;
   lua_assert(!ttisinteger(obj));
   if (tonumber(obj, &n)) {
-    n = l_mathop(floor)(n);
+    n = l_floor(n);
     return luaV_numtointeger(n, p);
   }
   else return 0;