diff --git a/check-linuxcnc-tooldata-source-map.sh b/check-linuxcnc-tooldata-source-map.sh index 656dc85..d782782 100755 --- a/check-linuxcnc-tooldata-source-map.sh +++ b/check-linuxcnc-tooldata-source-map.sh @@ -28,6 +28,14 @@ grep -F 'int tool_nml_register(CANON_TOOL_TABLE *tblptr)' \ "$linuxcnc_root/src/emc/tooldata/tooldata_nml.cc" >/dev/null grep -F 'int tooldata_db_init(char progname_plus_args[]' \ "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null +grep -F 'int tooldata_db_getall() {' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null +grep -F 'if (!db_live) {return -1;}' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null +grep -F 'int tooldata_db_notify(tool_notify_t ntype,' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null +grep -F 'if (!db_live) return 0;' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null grep -F 'int tooldata_read_entry(const char *input_line)' \ "$linuxcnc_root/src/emc/tooldata/tooldata_common.cc" >/dev/null @@ -64,10 +72,13 @@ grep -F 'LinuxCNC source basis: src/emc/tooldata/tooldata_mmap.cc provides these core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null grep -F 'LinuxCNC source basis: src/emc/tooldata/tooldata_nml.cc and tooldata_db.cc' \ core/wasm_shims/tooldata/tooldata_runtime_stubs.cc >/dev/null +grep -F 'returns 0 when' core/wasm_shims/tooldata/tooldata_runtime_stubs.cc >/dev/null grep -F 'LinuxCNC source basis: src/emc/tooldata/tooldata_common.cc provides' \ core/wasm_shims/tooldata/tooldata_common_probe_main.cc >/dev/null grep -F 'LinuxCNC source basis: src/emc/tooldata/tooldata_mmap.cc, tooldata_nml.cc,' \ core/wasm_shims/tooldata/tooldata_probe_main.cc >/dev/null +grep -F 'tooldata_db_notify() returns 0 without side effects while db_live is' \ + core/wasm_shims/tooldata/tooldata_probe_main.cc >/dev/null grep -F 'core/wasm_shims/tooldata/tooldata_mmap_backend.cc' docs/linuxcnc-wasm-shims-source-map.md >/dev/null grep -F 'core/wasm_shims/tooldata/tooldata_runtime_stubs.cc' docs/linuxcnc-wasm-shims-source-map.md >/dev/null @@ -129,6 +140,7 @@ for phrase in [ "source coverage only", "must not become browser API fields", "WASM-safe tooldata shims must preserve the LinuxCNC export surface", + "inactive-DB return values", "./check-linuxcnc-tooldata-source-map.sh", ]: if phrase not in doc: diff --git a/check-linuxcnc-wasm-shims-source-map.sh b/check-linuxcnc-wasm-shims-source-map.sh index 67ad9a1..dfdacc1 100755 --- a/check-linuxcnc-wasm-shims-source-map.sh +++ b/check-linuxcnc-wasm-shims-source-map.sh @@ -36,6 +36,8 @@ grep -F 'PythonPlugin::instantiate' "$linuxcnc_root/src/emc/pythonplugin/python_ grep -F '#define TOOL_MMAP_FILENAME ".tool.mmap"' "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null grep -F 'int tool_nml_register(CANON_TOOL_TABLE *tblptr)' "$linuxcnc_root/src/emc/tooldata/tooldata_nml.cc" >/dev/null grep -F 'int tooldata_db_init(char progname_plus_args[]' "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null +grep -F 'if (!db_live) {return -1;}' "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null +grep -F 'if (!db_live) return 0;' "$linuxcnc_root/src/emc/tooldata/tooldata_db.cc" >/dev/null python3 - "$manifest" <<'PY' from pathlib import Path @@ -115,6 +117,7 @@ for phrase in [ "CMake `linuxcnc_wasm_safe_probe_shims` set", "RS274/WASM manifest", "browser-safe LinuxCNC adaptations", + "inactive-DB return values", ]: if phrase not in source_map: raise SystemExit(f"docs/linuxcnc-wasm-shims-source-map.md missing boundary phrase: {phrase}") diff --git a/core/wasm_shims/tooldata/tooldata_probe_main.cc b/core/wasm_shims/tooldata/tooldata_probe_main.cc index 77497e9..e524516 100644 --- a/core/wasm_shims/tooldata/tooldata_probe_main.cc +++ b/core/wasm_shims/tooldata/tooldata_probe_main.cc @@ -113,6 +113,18 @@ int main() { if (tooldata_db_getall() != -1) { return 28; } + // LinuxCNC source basis: src/emc/tooldata/tooldata_db.cc + // tooldata_db_notify() returns 0 without side effects while db_live is + // false, which is the browser-safe shim state for external DB services. + if (tooldata_db_notify(SPINDLE_LOAD, 7, 12, uncreated_tool) != 0) { + return 57; + } + if (tooldata_db_notify(SPINDLE_UNLOAD, 7, 12, uncreated_tool) != 0) { + return 58; + } + if (tooldata_db_notify(TOOL_OFFSET, 7, 12, uncreated_tool) != 0) { + return 59; + } std::string missing_db_program_with_arg_string = make_temp_path("cnc_tooldata_probe_missing_db_program arg"); std::vector missing_db_program_with_arg( diff --git a/core/wasm_shims/tooldata/tooldata_runtime_stubs.cc b/core/wasm_shims/tooldata/tooldata_runtime_stubs.cc index 04223e7..b66dd4c 100644 --- a/core/wasm_shims/tooldata/tooldata_runtime_stubs.cc +++ b/core/wasm_shims/tooldata/tooldata_runtime_stubs.cc @@ -48,6 +48,8 @@ int tooldata_db_init(char progname_plus_args[], int) { } int tooldata_db_notify(tool_notify_t, int, int, CANON_TOOL_TABLE) { + // LinuxCNC source basis: src/emc/tooldata/tooldata_db.cc returns 0 when + // db_live is false, before formatting or sending any DB notification. return 0; } diff --git a/docs/linuxcnc-tooldata-source-map.md b/docs/linuxcnc-tooldata-source-map.md index c5b21c3..20f36d1 100644 --- a/docs/linuxcnc-tooldata-source-map.md +++ b/docs/linuxcnc-tooldata-source-map.md @@ -15,6 +15,9 @@ source-link/shim guard only; it must not add CNC behavior and must not expand th - `src/emc/tooldata/tooldata_nml.cc` provides the NML tool table registration backend selected by `TOOL_NML_FLAG`. - `src/emc/tooldata/tooldata_db.cc` provides external database entry points. +- `src/emc/tooldata/tooldata_db.cc` returns `-1` from + `tooldata_db_getall()` when the external DB is not live, and returns `0` + from `tooldata_db_notify()` without side effects in that same state. - `src/emc/tooldata/tool_mmap_read.cc` and `src/emc/tooldata/tool_watch.cc` are utility sources from the same LinuxCNC tooldata build metadata. - `src/emc/tooldata/tooldata.hh` declares the tooldata API used by RS274 and @@ -40,6 +43,8 @@ source-link/shim guard only; it must not add CNC behavior and must not expand th they must not become browser API fields or generated switchkins aliases. - WASM-safe tooldata shims must preserve the LinuxCNC export surface checked by symbol probes. +- WASM-safe tooldata runtime stubs must keep external database services + unavailable while preserving LinuxCNC inactive-DB return values. - Native and source-link paths must keep the full LinuxCNC `src/emc/tooldata` source directory tracked in the native RS274 manifest. - `build-wasm.sh` must run tooldata link and symbol probes before copying diff --git a/docs/linuxcnc-wasm-shims-source-map.md b/docs/linuxcnc-wasm-shims-source-map.md index 9378008..d7fbcb4 100644 --- a/docs/linuxcnc-wasm-shims-source-map.md +++ b/docs/linuxcnc-wasm-shims-source-map.md @@ -23,7 +23,7 @@ only; it must not add CNC behavior and must not expand the temporary smoke parse | `core/wasm_shims/rcs_print_shim.cc` | `src/libnml/rcs/rcs_print.cc` | Provides LinuxCNC RCS print diagnostics used by NML validation. | | `core/wasm_shims/rtapi_compat.cc` | `src/rtapi/uspace_common.h`, `src/rtapi/rtapi.h` | Provides userspace RTAPI formatting declarations used by RS274/NML code. | | `core/wasm_shims/tooldata/tooldata_mmap_backend.cc` | `src/emc/tooldata/tooldata_mmap.cc` | Replaces native mmap storage with an in-memory WASM-safe backend for probes. | -| `core/wasm_shims/tooldata/tooldata_runtime_stubs.cc` | `src/emc/tooldata/tooldata_nml.cc`, `src/emc/tooldata/tooldata_db.cc` | Satisfies NML and external tool database entry points without native services. | +| `core/wasm_shims/tooldata/tooldata_runtime_stubs.cc` | `src/emc/tooldata/tooldata_nml.cc`, `src/emc/tooldata/tooldata_db.cc` | Satisfies NML and external tool database entry points without native services, preserving inactive-DB return values. | | `core/wasm_shims/pythonplugin/python_plugin.cc` | `src/emc/pythonplugin/python_plugin.cc`, `src/emc/pythonplugin/python_plugin.hh` | Keeps LinuxCNC PythonPlugin API available while Python execution is disabled for browser-safe probes. | ## Boundaries