Browse Source

fix: os,修改clock实现,改为使用mcu的64bit计数器

https://gitee.com/openLuat/LuatOS/issues/ID2GVD
Wendal Chen 3 tháng trước cách đây
mục cha
commit
f00d0b2a3d
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 6 1
      lua/src/loslib.c

+ 6 - 1
lua/src/loslib.c

@@ -215,7 +215,12 @@ static int os_getenv (lua_State *L) {
 #endif
 
 static int os_clock (lua_State *L) {
-  lua_pushinteger(L, ((lua_Integer)clock())/(lua_Integer)CLOCKS_PER_SEC);
+  #ifdef LUAT_USE_MCU
+  extern uint64_t luat_mcu_tick64(void);
+  lua_pushinteger(L, (lua_Integer)luat_mcu_tick64());
+  #else
+  lua_pushinteger(L, 0);
+  #endif
   return 1;
 }