浏览代码

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

https://gitee.com/openLuat/LuatOS/issues/ID2GVD
Wendal Chen 3 月之前
父节点
当前提交
f00d0b2a3d
共有 1 个文件被更改,包括 6 次插入1 次删除
  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;
 }