diff --git a/check-linuxcnc-tooldata-source-map.sh b/check-linuxcnc-tooldata-source-map.sh index d182e41..298592e 100755 --- a/check-linuxcnc-tooldata-source-map.sh +++ b/check-linuxcnc-tooldata-source-map.sh @@ -40,6 +40,38 @@ grep -F 'emcStatus->io.tool.pocketPrepped' \ "$linuxcnc_root/src/emc/tooldata/tool_watch.cc" >/dev/null grep -F '#define TOOL_MMAP_FILENAME ".tool.mmap"' \ "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'bool tool_mmap_is_random_toolchanger(void)' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'ans = hptr->is_random_toolchanger;' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'int tool_mmap_creator(EMC_TOOL_STAT const * ptr,int random_toolchanger)' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'static int inited=0;' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'hptr->is_random_toolchanger = random_toolchanger;' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'hptr->last_index = 0;' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'int tool_mmap_user()' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'fprintf(stderr,"tool_mmap_user(): tool mmap not available\n");' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'return(-1);' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'void tool_mmap_close()' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'if (!tool_mmap_base) { return; }' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'int tooldata_last_index_get(void)' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'tool_mmap_mutex_give(); return -1;' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'int tooldata_find_index_for_tool(int toolno)' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'if (toolno == -1) {tool_mmap_mutex_give(); return -1;}' \ + "$linuxcnc_root/src/emc/tooldata/tooldata_mmap.cc" >/dev/null +grep -F 'if (!hptr->is_random_toolchanger && toolno == 0)' \ + "$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[]' \ @@ -102,6 +134,38 @@ grep -F 'metadata:src/emc/tooldata/tooldata_nml.cc:source basis for wasm-safe to 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 'bool mmap_created = false;' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'bool mmap_random_toolchanger = false;' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'bool mmap_creator_called = false;' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'int tool_mmap_creator(EMC_TOOL_STAT const *ptr, int random_toolchanger)' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'Error: tool_mmap_creator already called BYE' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'mmap_created = true;' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'mmap_random_toolchanger = random_toolchanger;' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'last_index = 0;' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'int tool_mmap_user(void)' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'tool_mmap_user(): tool mmap not available' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'void tool_mmap_close(void)' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'mmap_created = false;' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'bool tool_mmap_is_random_toolchanger(void)' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'return mmap_random_toolchanger;' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'int tooldata_last_index_get(void)' \ + core/wasm_shims/tooldata/tooldata_mmap_backend.cc >/dev/null +grep -F 'return -1;' \ + 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 'constexpr int MAX_DB_PROGRAM_ARGS = 10;' \ @@ -235,6 +299,10 @@ for phrase in [ "access(..., X_OK)", "mmap tool table reader utility", "NML/mmap tool table watcher utility", + "mmap creator/user/close lifecycle", + "random-toolchanger flag", + "last-index unavailable return", + "in-memory replacement for native mmap", "inactive-DB return values", "./check-linuxcnc-tooldata-source-map.sh", "does not interpret G-code", diff --git a/docs/linuxcnc-tooldata-source-map.md b/docs/linuxcnc-tooldata-source-map.md index 077fa08..a11bd57 100644 --- a/docs/linuxcnc-tooldata-source-map.md +++ b/docs/linuxcnc-tooldata-source-map.md @@ -51,6 +51,17 @@ source-link/shim guard only; it must not add CNC behavior and must not expand th `tooldata_db_notify()` must return `0` without side effects while `db_live` is false. +## Mmap Backend Boundaries + +- `core/wasm_shims/tooldata/tooldata_mmap_backend.cc` must preserve the + LinuxCNC `tooldata_mmap.cc` export surface for the mmap creator/user/close lifecycle while using an in-memory replacement for native mmap. +- The mmap backend must keep the LinuxCNC random-toolchanger flag and + `last_index` initialization edges from `tool_mmap_creator()`, and + `tooldata_last_index_get()` must preserve the last-index unavailable return. +- `tool_mmap_user()` must keep LinuxCNC's unavailable mmap failure boundary, + and `tool_mmap_close()` must clear the browser-safe in-memory state without + adding filesystem mmap behavior. + ## Boundaries - Tool table files referenced by switchkins INI files are source coverage only;