aboutsummaryrefslogtreecommitdiff
path: root/lmathlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-05-26 10:45:24 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-05-26 10:45:24 -0300
commit1414b7123ca46f7e133ee71400e8ed7f95187c47 (patch)
tree88aac810cbc6dcf6d2a75bee191b920cba800dcd /lmathlib.c
parent3563b3f51942da0cc0360394476b3910b51ebdd9 (diff)
downloadlua-1414b7123ca46f7e133ee71400e8ed7f95187c47.tar.gz
lua-1414b7123ca46f7e133ee71400e8ed7f95187c47.tar.bz2
lua-1414b7123ca46f7e133ee71400e8ed7f95187c47.zip
support for the case when 'l_mathop' does not conform to lua_Number
(problem with pointers to lua_Number solved by a typedef selected automatically by 'l_mathop')
Diffstat (limited to 'lmathlib.c')
-rw-r--r--lmathlib.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lmathlib.c b/lmathlib.c
index 4eeaae9e..cc397fc2 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.84 2013/05/02 17:31:54 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.85 2013/05/06 17:22:55 roberto Exp $
3** Standard mathematical library 3** Standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -22,6 +22,11 @@
22#define RADIANS_PER_DEGREE ((lua_Number)(PI/180.0)) 22#define RADIANS_PER_DEGREE ((lua_Number)(PI/180.0))
23 23
24 24
25/* types for lua_Number pointers subject to 'l_mathop' changes */
26typedef float l_pnumf;
27typedef double l_pnum;
28typedef long double l_pnuml;
29
25 30
26static int math_abs (lua_State *L) { 31static int math_abs (lua_State *L) {
27 lua_pushnumber(L, l_mathop(fabs)(luaL_checknumber(L, 1))); 32 lua_pushnumber(L, l_mathop(fabs)(luaL_checknumber(L, 1)));
@@ -96,7 +101,7 @@ static int math_fmod (lua_State *L) {
96} 101}
97 102
98static int math_modf (lua_State *L) { 103static int math_modf (lua_State *L) {
99 lua_Number ip; 104 l_mathop(l_pnum) ip;
100 lua_Number fp = l_mathop(modf)(luaL_checknumber(L, 1), &ip); 105 lua_Number fp = l_mathop(modf)(luaL_checknumber(L, 1), &ip);
101 lua_pushnumber(L, ip); 106 lua_pushnumber(L, ip);
102 lua_pushnumber(L, fp); 107 lua_pushnumber(L, fp);