参考所有分组,完成尽量多的内容。禁止顺手扩功能 smoke
结论:补强 WASM runtime shim 的 LinuxCNC HAL source-map 与 probe,确认 HAL lookup 在浏览器安全 shim 中保持不可用边界,不扩展 smoke 行为。
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "cnc_sim_api.h"
|
||||
#include "hal.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
@@ -9,6 +10,8 @@
|
||||
|
||||
// LinuxCNC source basis: src/emc/rs274ngc/rs274ngc_pre.cc provides read(),
|
||||
// execute(), and wordexp() paths; interp_convert.cc converts G0, G2, and M30.
|
||||
// src/emc/rs274ngc/interp_namedparams.cc calls the HAL lookup functions
|
||||
// declared in include/hal.h and implemented by src/hal/hal_lib.c.
|
||||
namespace {
|
||||
|
||||
int collect_event(const CncSimEvent *event, void *user_data) {
|
||||
@@ -57,6 +60,46 @@ bool wordexp_expands_environment_variables() {
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool hal_lookup_is_unavailable() {
|
||||
if (hal_init("cnc_sim_wasm_runtime_probe") != 1) {
|
||||
return false;
|
||||
}
|
||||
if (hal_ready(1) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
hal_data_u dummy{};
|
||||
hal_data_u *data = &dummy;
|
||||
hal_type_t type = HAL_FLOAT;
|
||||
bool connected = true;
|
||||
if (hal_get_pin_value_by_name("cnc-sim.missing-pin", &type, &data, &connected) != -1 ||
|
||||
type != HAL_TYPE_UNINITIALIZED ||
|
||||
data != nullptr ||
|
||||
connected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data = &dummy;
|
||||
type = HAL_FLOAT;
|
||||
bool has_writers = true;
|
||||
if (hal_get_signal_value_by_name("cnc-sim.missing-signal", &type, &data, &has_writers) != -1 ||
|
||||
type != HAL_TYPE_UNINITIALIZED ||
|
||||
data != nullptr ||
|
||||
has_writers) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data = &dummy;
|
||||
type = HAL_FLOAT;
|
||||
if (hal_get_param_value_by_name("cnc-sim.missing-param", &type, &data) != -1 ||
|
||||
type != HAL_TYPE_UNINITIALIZED ||
|
||||
data != nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main() {
|
||||
@@ -66,6 +109,9 @@ int main() {
|
||||
if (!wordexp_expands_environment_variables()) {
|
||||
return 6;
|
||||
}
|
||||
if (!hal_lookup_is_unavailable()) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
std::vector<CncSimEvent> events;
|
||||
CncSimHandle *sim = cnc_sim_create();
|
||||
|
||||
Reference in New Issue
Block a user