# HG changeset patch # User jbe # Date 1427331370 -3600 # Node ID 34bf5f7abe0d03b6059848bdafa447b6c062c970 # Parent 061ee100f1c1db606af2dca704a7d0550e5c09cf Code cleanup in extos.c: use 1.0e9 instead of 0.000000001 to avoid floating-point inaccuracies, added "const" qualifiers to avoid two compiler warnings diff -r 061ee100f1c1 -r 34bf5f7abe0d libraries/extos/extos.c --- a/libraries/extos/extos.c Tue Mar 24 23:54:14 2015 +0100 +++ b/libraries/extos/extos.c Thu Mar 26 01:56:10 2015 +0100 @@ -296,8 +296,8 @@ } static int extos_crypt(lua_State *L) { - char *key; - char *salt; + const char *key; + const char *salt; char *result; key = luaL_checkstring(L, 1); salt = luaL_checkstring(L, 2); @@ -312,7 +312,7 @@ if (clock_gettime(CLOCK_REALTIME, &tp)) { return luaL_error(L, "Could not access CLOCK_REALTIME."); } - lua_pushnumber(L, tp.tv_sec + 0.000000001 * tp.tv_nsec); + lua_pushnumber(L, tp.tv_sec + tp.tv_nsec / 1.0e9); return 1; } @@ -323,7 +323,7 @@ return luaL_error(L, "Could not access CLOCK_MONOTONIC."); } lua_pushnumber(L, - tp.tv_sec + 0.000000001 * tp.tv_nsec - extos_monotonic_start_time + tp.tv_sec + tp.tv_nsec / 1.0e9 - extos_monotonic_start_time ); return 1; } @@ -343,7 +343,7 @@ if (clock_gettime(CLOCK_MONOTONIC, &tp)) { return luaL_error(L, "Could not access monotonic hires time."); } - extos_monotonic_start_time = tp.tv_sec + 0.000000001 * tp.tv_nsec; + extos_monotonic_start_time = tp.tv_sec + tp.tv_nsec / 1.0e9; } #if LUA_VERSION_NUM >= 502 lua_newtable(L);