fix(sdk): 时钟 ABI 根因修复 — meow_ui_time 按 o32 time32 取时并链接期接管
真机 meow_ui_time_ms() 返回「低 32=秒×1000、高 32 随机」的根因不是 SDK 写法,
而是 zig 0.17 自带 musl 在 mipsel 上的 time64 ABI 自相矛盾:
- zig 头(mips-linux-musl/bits/alltypes.h)无条件 64 位 time_t、struct timespec 16 字节;
- zig 的 clang 给 32 位 mips 预定义 __ILP32__,musl 的 time64 回退分支
`#if defined(SYS_x_time64) && !defined(__ILP32__)`(本意只排除 x32)被编译掉;
- 于是 libc 的 __clock_gettime64 实为 o32 time32 实现(SYS_clock_gettime 4263),
只写 8 字节 {int32 sec; int32 nsec},与头的 16 字节布局错配。
修复(patch_v2/sdk/meow_ui_time.c):
- meow_ui_time_ms() 直接按内核 o32 ABI 取 8 字节 time32,再升 64 位毫秒;
- 同 TU 强定义 __clock_gettime/__clock_gettime64(归档先于 -lc,链接期接管,
time()/gettimeofday()/pthread 定时等待的内部取时随之修正);
- 同源缺陷一并修:__nanosleep_time64/__clock_nanosleep(_time64) 转换 time32 后重发
(修复前 usleep(16000) 等亚秒睡眠立即返回、变忙等空转);
- gfx/sys/input/cachegov 四处重复 now_ms 收敛到 meow_ui_time_ms;
- build_sdk.sh OBJS 增加 meow_ui_time;新增 test_meow_time 宿主单测、
tools/clock_abi_probe.c 探针、CLOCK_ABI.md 根因/验证/影响面文档;
- 26 个宿主测试的编译注释补 meow_ui_time.c(cachegov 测试补时钟源)。
验证:宿主单测 PASS;anim(32)/view_event 宿主用例全过;build_sdk_host.sh --verify
76 成员全 MIPS32r2、0 warning;探针链接后无 libc cgt_init/__vdsosym,
__time64/__timedwait_cp 的取时指向本 TU,睡眠走 4166/4265 且用本地 8 字节结构。
This commit is contained in:
1 parent
8a115f6583
commit
38be5e78bc
37 files changed
+577
-75
No files matched your search
@@ -122,13 +122,6 @@ static uint64_t last_tick_ms = 0;
|
||||
static uint64_t startup_cooldown_until = 0;
|
||||
#define STARTUP_COOLDOWN_MS 500
|
||||
|
||||
static uint64_t now_ms(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (uint64_t)ts.tv_sec * 1000u + (uint64_t)ts.tv_nsec / 1000000u;
|
||||
}
|
||||
|
||||
/* settings.conf 路径(可被 env MEOW_SETTINGS_FILE 覆盖,宿主测试用;设备默认同 meow_ui_sys.c)。 */
|
||||
static const char *meow_settings_path(void)
|
||||
{
|
||||
@@ -294,7 +287,7 @@ static void touch_press(int x, int y)
|
||||
t_origin_valid = 0;
|
||||
t_cx = -1; t_cy = -1;
|
||||
t_dx = 0; t_dy = 0;
|
||||
t_down_ms = now_ms(); /* 记按下时刻:供实时按住时长/按住视觉 */
|
||||
t_down_ms = meow_ui_time_ms(); /* 记按下时刻:供实时按住时长/按住视觉 */
|
||||
t_mv_x = -1; t_mv_y = -1; /* M2.71:拖动过程起点未定 */
|
||||
t_long_fired = 0; /* §6.3:每次新按压复位长按触发标记 */
|
||||
}
|
||||
@@ -392,7 +385,7 @@ int meow_input_touch_y(void) { return t_cy; }
|
||||
unsigned int meow_input_touch_hold_ms(void)
|
||||
{
|
||||
if (!t_down) return 0;
|
||||
uint64_t e = now_ms() - t_down_ms;
|
||||
uint64_t e = meow_ui_time_ms() - t_down_ms;
|
||||
if (e > 0xFFFFFFFFu) e = 0xFFFFFFFFu;
|
||||
return (unsigned int)e;
|
||||
}
|
||||
@@ -403,7 +396,7 @@ void meow_input_touch_set(int down, int x, int y, unsigned hold_ms)
|
||||
if (down) {
|
||||
t_down = 1; t_press_valid = 1; t_origin_valid = 1; t_long_fired = 0;
|
||||
t_cx = x; t_cy = y; t_dx = x; t_dy = y;
|
||||
uint64_t now = now_ms();
|
||||
uint64_t now = meow_ui_time_ms();
|
||||
t_down_ms = (now > (uint64_t)hold_ms) ? (now - (uint64_t)hold_ms) : 0;
|
||||
} else {
|
||||
t_down = 0; t_press_valid = 0; t_origin_valid = 0; t_long_fired = 0;
|
||||
@@ -544,7 +537,7 @@ static uint64_t g_sys_press_ms = 0;
|
||||
|
||||
static void sys_key_press(int code)
|
||||
{
|
||||
uint64_t now = now_ms();
|
||||
uint64_t now = meow_ui_time_ms();
|
||||
if (code == g_sys_press_code && now - g_sys_press_ms < SYS_KEY_DEDUP_MS)
|
||||
return; /* 事件流 + EVIOCGKEY 双源去重:同码窗口内只消化一次 */
|
||||
g_sys_press_code = code;
|
||||
@@ -702,7 +695,7 @@ void meow_ui_request_exit(void) { g_exit = 1; }
|
||||
static uint64_t g_activity_last_ms = 0;
|
||||
void meow_ui_activity_ping(void)
|
||||
{
|
||||
uint64_t now = now_ms();
|
||||
uint64_t now = meow_ui_time_ms();
|
||||
if (now - g_activity_last_ms < 500) return; /* 节流:任意交互连续触摸也只 ~2 次/s */
|
||||
g_activity_last_ms = now;
|
||||
if (!meow_gfx_is_device()) return; /* 离屏/宿主:无 launcher 消费 */
|
||||
@@ -715,8 +708,8 @@ void meow_ui_run(const meow_ui_events *ev)
|
||||
if (ev) { g_events = *ev; g_events_set = 1; }
|
||||
g_exit = 0;
|
||||
meow_input_start();
|
||||
last_tick_ms = now_ms();
|
||||
startup_cooldown_until = now_ms() + STARTUP_COOLDOWN_MS; /* M2.22(C):启动窗口丢弃 SWIPE */
|
||||
last_tick_ms = meow_ui_time_ms();
|
||||
startup_cooldown_until = meow_ui_time_ms() + STARTUP_COOLDOWN_MS; /* M2.22(C):启动窗口丢弃 SWIPE */
|
||||
|
||||
while (!g_exit) {
|
||||
/* agent-119:实时触摸按压/按住/释放 → 即时重绘命中按钮区(不等 app 重绘)。
|
||||
@@ -724,10 +717,10 @@ void meow_ui_run(const meow_ui_events *ev)
|
||||
* §6.3 通用长按:每帧检测「按下 ≥ 阈值且位移 ≤ 容忍」跨越(IME 打开不驱动;启动窗口不触发)。 */
|
||||
if (!meow_ime_active()) {
|
||||
meow_widget_touch_refresh();
|
||||
if (now_ms() >= startup_cooldown_until) meow_input_long_press_poll();
|
||||
if (meow_ui_time_ms() >= startup_cooldown_until) meow_input_long_press_poll();
|
||||
} else if (meow_ime_mode_pinyin()) {
|
||||
/* 拼音 IME 打开:喂长按轮询(长按退格清空字段)。英文模式不喂(保持既有行为)。 */
|
||||
if (now_ms() >= startup_cooldown_until) meow_input_long_press_poll();
|
||||
if (meow_ui_time_ms() >= startup_cooldown_until) meow_input_long_press_poll();
|
||||
}
|
||||
|
||||
meow_input_ev e;
|
||||
@@ -736,7 +729,7 @@ void meow_ui_run(const meow_ui_events *ev)
|
||||
if (g_exit) break; /* 已请求退出:不再分发剩余事件,杜绝「退出后又触发」的偶发再进/退 */
|
||||
got = 1;
|
||||
meow_ui_activity_ping(); /* M2.71-bug5:任意交互事件都喂 launcher 重置息屏计时(节流) */
|
||||
int in_startup = (now_ms() < startup_cooldown_until); /* M2.22(C) */
|
||||
int in_startup = (meow_ui_time_ms() < startup_cooldown_until); /* M2.22(C) */
|
||||
if (e.type == MEOW_EV_TAP) {
|
||||
if (in_startup) continue; /* 启动窗口也吞 TAP:旧手势残留点按(如上一次左滑抬起)
|
||||
* 在进入瞬间命中 UI 按钮(如全屏按钮)会误触发——丢弃。 */
|
||||
@@ -851,7 +844,7 @@ void meow_ui_run(const meow_ui_events *ev)
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t now = now_ms();
|
||||
uint64_t now = meow_ui_time_ms();
|
||||
if (g_events_set && g_events.on_tick) {
|
||||
if (now - last_tick_ms >= 16) {
|
||||
last_tick_ms = now;
|
||||
@@ -877,7 +870,7 @@ void meow_ui_run(const meow_ui_events *ev)
|
||||
|
||||
if (meow_ime_active()) { /* 软键盘覆盖层随帧绘制(30fps 节流,省 CPU) */
|
||||
static uint64_t last_ime_ms = 0;
|
||||
uint64_t n = now_ms();
|
||||
uint64_t n = meow_ui_time_ms();
|
||||
if (n - last_ime_ms >= 33) {
|
||||
last_ime_ms = n;
|
||||
meow_ime_draw();
|
||||
@@ -897,7 +890,7 @@ void meow_ui_run(const meow_ui_events *ev)
|
||||
void meow_ui_feed_tick(void)
|
||||
{
|
||||
if (!(g_events_set && g_events.on_tick)) return;
|
||||
uint64_t now = now_ms();
|
||||
uint64_t now = meow_ui_time_ms();
|
||||
if (now - last_tick_ms < 16) return;
|
||||
last_tick_ms = now;
|
||||
g_events.on_tick();
|
||||
|
||||
Reference in new issue
Block a user