2008-05-29 Guillaume SADEGH <sadegh@lrde.epita.fr> * iface/nips/nips.cc, iface/nips/nips.hh, iface/nips/common.cc, iface/nips/common.hh, iface/nips/Makefile.am: TGBA implementation with the NIPS library. * iface/nips/emptiness_check.cc: Emptiness check on a Promela interface. * iface/nips/dottynips.cc: Dot printer on the NIPS interface. * iface/nips/compile.sh: Add. Wrapper around nips compiler to compile Promela to NIPS bytecode. * iface/nips/nips_vm,iface/nips/nips_vm/bytecode.h, iface/nips/nips_vm/ChangeLog, iface/nips/nips_vm/COPYING, iface/nips/nips_vm/hashtab.c, iface/nips/nips_vm/hashtab.h, iface/nips/nips_vm/INSTALL, iface/nips/nips_vm/instr.c, iface/nips/nips_vm/instr.h, iface/nips/nips_vm/instr_step.c, iface/nips/nips_vm/instr_step.h, iface/nips/nips_vm/instr_tools.c, iface/nips/nips_vm/instr_tools.h, iface/nips/nips_vm/instr_wrap.c, iface/nips/nips_vm/instr_wrap.h, iface/nips/nips_vm/interactive.c, iface/nips/nips_vm/interactive.h, iface/nips/nips_vm/main.c, iface/nips/nips_vm/Makefile, iface/nips/nips_vm/Makefile.am, iface/nips/nips_vm/nips_asm_help.pl, iface/nips/nips_vm/nips_asm_instr.pl, iface/nips/nips_vm/nips_asm.pl, iface/nips/nips_vm/nips_disasm.pl, iface/nips/nips_vm/nipsvm.c, iface/nips/nips_vm/nipsvm.h, iface/nips/nips_vm/README, iface/nips/nips_vm/rt_err.c, iface/nips/nips_vm/rt_err.h, iface/nips/nips_vm/search.c, iface/nips/nips_vm/search.h, iface/nips/nips_vm/split.c, iface/nips/nips_vm/split.h, iface/nips/nips_vm/state.c, iface/nips/nips_vm/state.h, iface/nips/nips_vm/state_inline.h, iface/nips/nips_vm/state_parts.c, iface/nips/nips_vm/state_parts.h, iface/nips/nips_vm/timeval.h, iface/nips/nips_vm/tools.h: NIPS VM added to the SPOT distribution. * configure.ac, iface/Makefile.am: Build system updated for the NIPS front-end.
124 lines
3.5 KiB
C
124 lines
3.5 KiB
C
#ifndef NIPSVM_H
|
|
#define NIPSVM_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include <stddef.h>
|
|
|
|
#include "state.h"
|
|
#include "instr.h"
|
|
|
|
typedef struct nipsvm_t nipsvm_t;
|
|
//typedef st_global_state_header nipsvm_state_t; // state.h
|
|
typedef struct nipsvm_transition_information_t nipsvm_transition_information_t;
|
|
typedef st_bytecode nipsvm_bytecode_t;
|
|
typedef et_ic_status nipsvm_status_t;
|
|
typedef et_instr_err nipsvm_errorcode_t;
|
|
typedef t_pid nipsvm_pid_t;
|
|
typedef t_pc nipsvm_pc_t;
|
|
|
|
typedef nipsvm_status_t (nipsvm_scheduler_callback_t)(size_t, nipsvm_state_t *,
|
|
nipsvm_transition_information_t *,
|
|
void *context);
|
|
typedef nipsvm_status_t (nipsvm_error_callback_t)(nipsvm_errorcode_t, nipsvm_pid_t,
|
|
nipsvm_pc_t, void *context);
|
|
|
|
/* must be called once before using any other function of this
|
|
* module.
|
|
* Idempotent.
|
|
*/
|
|
extern int
|
|
nipsvm_module_init();
|
|
|
|
/* Initialize given VM structure (allocated elsewhere).
|
|
* Returns 0 on success.
|
|
*
|
|
* Usage pattern:
|
|
* { nipsvm_t vm;
|
|
* if (nipsvm_init (&vm, ...) != 0) error();
|
|
* ...
|
|
* nipsvm_finalize (&vm); }
|
|
*/
|
|
extern int
|
|
nipsvm_init (nipsvm_t *, nipsvm_bytecode_t *,
|
|
nipsvm_scheduler_callback_t *, nipsvm_error_callback_t *);
|
|
extern void *
|
|
nipsvm_finalize (nipsvm_t *);
|
|
|
|
|
|
/* returned initial state is transient, must be copied by caller */
|
|
extern nipsvm_state_t *
|
|
nipsvm_initial_state (nipsvm_t *);
|
|
|
|
/* calculates successor states of ``state'' and calls callback
|
|
* previously registered in ``vm'' for each.
|
|
* ``context'' is given to the callback verbatim.
|
|
*/
|
|
extern unsigned int
|
|
nipsvm_scheduler_iter (nipsvm_t *vm, nipsvm_state_t *state, void *context);
|
|
|
|
static inline size_t
|
|
nipsvm_state_size (nipsvm_state_t *state) { return global_state_size (state); }
|
|
|
|
// Copy VM state into given buffer
|
|
// *pp_buf points to memory area of length *p_len to use for new state
|
|
// Returns NULL in case of error
|
|
extern nipsvm_state_t *
|
|
nipsvm_state_copy (size_t sz, nipsvm_state_t *p_glob, char **pp_buf,
|
|
unsigned long *p_buf_len);
|
|
|
|
// Compare two states
|
|
// Returns 0 if equal, -1 or 1 if not equal
|
|
static inline int
|
|
nipsvm_state_compare (nipsvm_state_t *p_glob1, nipsvm_state_t *p_glob2, size_t size)
|
|
{
|
|
return memcmp (p_glob1, p_glob2, size);
|
|
}
|
|
|
|
// Check if the monitor process is in an accepting state
|
|
// Returns 0 if no monitor exists or it is not in an accepting state
|
|
// Returns 1 if a monitor exists and is in an accpeting state
|
|
extern int
|
|
nipsvm_state_monitor_accepting (nipsvm_state_t *);
|
|
|
|
|
|
// Check if the monitor process is terminated
|
|
// Returns 0 if no monitor exists or it is not terminated
|
|
// Returns 1 if a monitor exists and is in terminated
|
|
extern int
|
|
nipsvm_state_monitor_terminated (nipsvm_state_t *);
|
|
|
|
|
|
// Check if the monitor process is in an accepting state or terminated
|
|
// (This is the equivalent function of SPIN's accepting states in the never claim.)
|
|
// Returns 0 if no monitor exists or it is not in an accepting state and not terminated
|
|
// Returns 1 if a monitor exists and is in an accpeting state or terminated
|
|
extern int
|
|
nipsvm_state_monitor_acc_or_term (nipsvm_state_t *state);
|
|
|
|
|
|
extern int
|
|
nipsvm_errorstring (char *str, size_t size, nipsvm_errorcode_t err,
|
|
nipsvm_pid_t pid, nipsvm_pc_t pc);
|
|
|
|
extern nipsvm_error_callback_t nipsvm_default_error_cb;
|
|
|
|
/* Internal */
|
|
struct nipsvm_t {
|
|
nipsvm_scheduler_callback_t *callback;
|
|
nipsvm_error_callback_t *error_callback;
|
|
void *callback_context;
|
|
st_instr_succ_context insn_context;
|
|
};
|
|
|
|
static inline size_t
|
|
sizeof_nipsvm_t() { return sizeof (nipsvm_t); }
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
#endif
|
|
|
|
#endif
|