mirror of
https://github.com/nasa/trick.git
synced 2024-12-25 15:51:05 +00:00
19025d77ad
Reorganized. Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory. Created a libexec directory that holds all of the executables that users don't need to execute directly. Changed all of the executables remaining in bin to start with "trick-". In the sim_services directories changed all source files to find the Trick headers in their new location. Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level. Moved the makefiles, docs, man, and other architecture independent files into a top level share directory. Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on. refs #63
227 lines
6.0 KiB
C++
227 lines
6.0 KiB
C++
|
|
#include <stdlib.h>
|
|
|
|
#include "trick/CheckPointRestart.hh"
|
|
#include "trick/CheckPointRestart_c_intf.hh"
|
|
#include "trick/memorymanager_c_intf.h"
|
|
#include "trick/message_proto.h"
|
|
#include "trick/message_type.h"
|
|
|
|
/** Global singleton pointer to the CheckPointRestart. */
|
|
extern Trick::CheckPointRestart * the_cpr ;
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::set_pre_init_checkpoint
|
|
*/
|
|
extern "C" int checkpoint_pre_init( int yes_no ) {
|
|
the_cpr->set_pre_init_checkpoint(bool(yes_no)) ;
|
|
return(0) ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::set_post_init_checkpoint
|
|
*/
|
|
extern "C" int checkpoint_post_init( int yes_no ) {
|
|
the_cpr->set_post_init_checkpoint(bool(yes_no)) ;
|
|
return(0) ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::set_end_checkpoint
|
|
*/
|
|
extern "C" int checkpoint_end( int yes_no ) {
|
|
the_cpr->set_end_checkpoint(bool(yes_no)) ;
|
|
return(0) ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::set_pre_init_checkpoint
|
|
*/
|
|
extern "C" int get_checkpoint_pre_init() {
|
|
return (int)the_cpr->pre_init_checkpoint ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::set_post_init_checkpoint
|
|
*/
|
|
extern "C" int get_checkpoint_post_init() {
|
|
return (int)the_cpr->post_init_checkpoint ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::set_end_checkpoint
|
|
*/
|
|
extern "C" int get_checkpoint_end() {
|
|
return (int)the_cpr->end_checkpoint ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::set_safestore_enabled
|
|
*/
|
|
extern "C" int checkpoint_safestore_set_enabled( int yes_no ) {
|
|
the_cpr->set_safestore_enabled(bool(yes_no)) ;
|
|
return(0) ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::dmtcp_set_safestore_enabled
|
|
*/
|
|
extern "C" int dmtcp_checkpoint_safestore_set_enabled( int yes_no ) {
|
|
the_cpr->dmtcp_set_safestore_enabled(bool(yes_no)) ;
|
|
return(0) ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::set_safestore_time
|
|
*/
|
|
extern "C" int checkpoint_safestore( double in_time ) {
|
|
the_cpr->set_safestore_time(in_time) ;
|
|
return(0) ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::dmtcp_set_safestore_time
|
|
*/
|
|
extern "C" int dmtcp_checkpoint_safestore( double in_time ) {
|
|
the_cpr->dmtcp_set_safestore_time(in_time) ;
|
|
return(0) ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::set_cpu_num
|
|
*/
|
|
extern "C" int checkpoint_cpu( int in_cpu_num ) {
|
|
the_cpr->set_cpu_num(in_cpu_num) ;
|
|
#if __APPLE__
|
|
message_publish(MSG_WARNING, "Warning: (Setting checkpoint cpu) Trick on Darwin does not yet support processor assignment.\n");
|
|
#endif
|
|
return(0) ;
|
|
}
|
|
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::get_output_file
|
|
*/
|
|
extern "C" const char * checkpoint_get_output_file() {
|
|
|
|
return the_cpr->get_output_file() ;
|
|
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::get_load_file
|
|
*/
|
|
extern "C" const char * checkpoint_get_load_file() {
|
|
|
|
return the_cpr->get_load_file() ;
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
@brief @userdesc Command to dump a checkpoint now to the specified file.
|
|
This is invoked when the user clicks the "Dump DMTCP Chkpnt" button on the sim control panel.
|
|
@par Python Usage:
|
|
@code trick.dmtcp_checkpoint("<file_name>") @endcode
|
|
@param file_name - name of checkpoint file to dump (leave blank and Trick will use filename "dmtcp_chkpnt_<simtime>"
|
|
@return always 0
|
|
*/
|
|
extern "C" int dmtcp_checkpoint( const char * file_name __attribute__((unused))) {
|
|
the_cpr->dmtcp_checkpoint( std::string(file_name) );
|
|
return(0) ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
@brief @userdesc Command to dump a checkpoint now to the specified file.
|
|
This is invoked when the user clicks the "Dump ASCII Chkpnt" button on the sim control panel.
|
|
@par Python Usage:
|
|
@code trick.checkpoint("<file_name>") @endcode
|
|
@param file_name - name of checkpoint file to dump (leave blank and Trick will use filename "chkpnt_<simtime>"
|
|
@return always 0
|
|
*/
|
|
extern "C" int checkpoint( const char * file_name ) {
|
|
|
|
the_cpr->checkpoint(std::string(file_name)) ;
|
|
|
|
return(0) ;
|
|
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
@brief @userdesc Command to dump a checkpoint now to the specified file, only dumping the specified sim objects.
|
|
This is invoked when the user clicks the "Dump ASCII Chkpnt" button on the sim control panel after having set "Checkpoint Objects" under the "Actions" menu.
|
|
@par Python Usage:
|
|
@code trick.checkpoint_objects("<file_name>", "<object>[,<object>,...]") @endcode
|
|
@param file_name - name of checkpoint file to dump (leave blank and Trick will use filename "chkpnt_<simtime>"
|
|
@param objects - string of comma separated sim object names to dump
|
|
@return always 0
|
|
*/
|
|
extern "C" int checkpoint_objects( const char * file_name , const char * objects ) {
|
|
|
|
the_cpr->checkpoint(std::string(file_name), true, std::string(objects)) ;
|
|
|
|
return(0) ;
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::load_checkpoint
|
|
*/
|
|
extern "C" int load_checkpoint( const char * file_name ) {
|
|
|
|
the_cpr->load_checkpoint(std::string(file_name)) ;
|
|
|
|
return(0) ;
|
|
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* @copydoc Trick::CheckPointRestart::load_checkpoint_job
|
|
*/
|
|
extern "C" int load_checkpoint_job() {
|
|
|
|
the_cpr->load_checkpoint_job() ;
|
|
|
|
return(0) ;
|
|
|
|
}
|
|
|
|
/**
|
|
* @relates Trick::CheckPointRestart
|
|
* This get_address has C bindings and is callable from regular C code.
|
|
* @param var_name - name of variable
|
|
*/
|
|
extern "C" void * get_address( const char * var_name ) {
|
|
|
|
REF2 * new_ref ;
|
|
new_ref = ref_attributes((char *)var_name) ;
|
|
void * address ;
|
|
|
|
if ( new_ref != NULL ) {
|
|
address = new_ref->address ;
|
|
ref_free(new_ref) ;
|
|
free(new_ref) ;
|
|
return(address) ;
|
|
}
|
|
|
|
return(NULL) ;
|
|
|
|
}
|