csrc/Therac.c

start_machine wrap_external_call request_state_info

1#include "Therac.h"2#include <Therac25_stub.h>3#include <stdlib.h>4HsStablePtr start_machine() {56#if defined(__wasm__)7  /* single-threaded RTS; when JSFFI is linked in, its constructor has already called hs_init */8  char * argv[] = {"therac25", NULL};9  int argc      = 1;10#else11  char * argv[] = {"therac25", "+RTS", "-N", "-RTS", NULL};12  int argc      = 4;13#endif14  char ** pargv = argv;15  hs_init(&argc, &pargv);16  return startMachine();17}18void kill_machine() { hs_exit(); }19void wrap_external_call(20    HsStablePtr wrapped_comms,21    ExtCallType ext_call_type,22    BeamType beam_type,23    CollimatorPosition collimator_position,24    HsInt beam_energy25) {2627  externalCallWrap(28      wrapped_comms,29      ext_call_type,30      beam_type,31      collimator_position,32      beam_energy33  );34}35HsPtr request_state_info(36    HsStablePtr wrapped_comms,37    StateInfoRequest state_info_request38) {39  return requestStateInfo(wrapped_comms, state_info_request);40}41/* newCString allocates with malloc; free it with the same C runtime that allocated it */42void free_state_info(HsPtr state_info) { free(state_info); }