diff --git a/Online/OnlineBase/main/checkpoint.cpp b/Online/OnlineBase/main/checkpoint.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a9d494bd53f4c52e415a52cfb6a410595e3c0eaa --- /dev/null +++ b/Online/OnlineBase/main/checkpoint.cpp @@ -0,0 +1,21 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +//-------------------------------------------------------------------------- +// +// Author : Markus Frank +//========================================================================== +#define main checkpointing_main +#include "gentest.cpp" +#undef main +extern void CheckpointRestoreWrapper__init_instance(int argc, char** argv); + +int main (int argc, char** argv) { + CheckpointRestoreWrapper__init_instance(argc, argv); + return checkpointing_main(argc,argv); +} diff --git a/Online/OnlineBase/main/genPython.cpp b/Online/OnlineBase/main/genPython.cpp new file mode 100644 index 0000000000000000000000000000000000000000..59bde542cddaca8bd1b330cf9dff2e282d4b27b0 --- /dev/null +++ b/Online/OnlineBase/main/genPython.cpp @@ -0,0 +1,75 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +//-------------------------------------------------------------------------- +// +// Author : Markus Frank +//========================================================================== +#if defined(__clang__) || defined(__CLING__) +#pragma clang diagnostic ignored "-Wregister" +#elif defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wregister" +#endif + +/// Framework include files +#include "../src/LOG/FifoLog.cpp" + +/// C/C++ include files +#include <iostream> +#include <cerrno> + +// Iniitalize the logger unit +__attribute__((constructor)) void s__fifolog_initialize_logger() { + fifolog_initialize_logger(); +} + +/// Shutdown the loggetr unit +__attribute__((destructor)) void s__fifolog_finalize_logger() { + ::usleep(3000); + fifolog_finalize_logger(); +} + +/// Framework include files +#include <RTL/DllAccess.h> + +// ----------------------------------------------------------------------------- +// Python hacks to avoid warnings if outside dictionaries ..... +// ----------------------------------------------------------------------------- +// --> /usr/include/python2.7/pyconfig.h:1161:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default] +#ifdef _POSIX_C_SOURCE +#undef _POSIX_C_SOURCE +#endif /* _POSIX_C_SOURCE */ +// --> /usr/include/python2.7/pyconfig.h:1183:0: warning: "_XOPEN_SOURCE" redefined [enabled by default] +#ifdef _XOPEN_SOURCE +#undef _XOPEN_SOURCE +#endif /* _XOPEN_SOURCE */ +#include "Python.h" + +/// Start the interpreter in normal mode without hacks like 'python.exe' does. +int main( int argc, char** argv ) { +#if PY_VERSION_HEX < 0x03000000 + return ::Py_Main(argc, argv); +#else + std::vector<wstring> wargs; + std::vector<const wchar_t*> wargv; + for(int i=0; i<argc;++i) { + std::wstring wstr; + if ( argv[i] ) { + const size_t size = ::strlen(argv[i]); + if (size > 0) { + wstr.resize(size+1); + std::mbstowcs(&wstr[0], argv[i], size); + wstr[size] = 0; + } + } + wargs.push_back(wstr); + } + for( auto& s : wargs ) wargv.push_back(s.c_str()); + return ::Py_Main(argc, (wchar_t**)&wargv[0]); +#endif +} diff --git a/Online/OnlineBase/main/genRunner.cpp b/Online/OnlineBase/main/genRunner.cpp new file mode 100644 index 0000000000000000000000000000000000000000..99ff457b6edca69f749f915da2db37e9afb72316 --- /dev/null +++ b/Online/OnlineBase/main/genRunner.cpp @@ -0,0 +1,72 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +//-------------------------------------------------------------------------- +// +// Author : Markus Frank +//========================================================================== + +/// Framework include files +#include "../src/LOG/FifoLog.cpp" + +/// C/C++ include files +#include <unistd.h> +#include <iostream> +#include <cerrno> + +// Iniitalize the logger unit +__attribute__((constructor)) void s__fifolog_initialize_logger() { + fifolog_initialize_logger(); +} + +/// Shutdown the loggetr unit +__attribute__((destructor)) void s__fifolog_finalize_logger() { + ::usleep(3000); + fifolog_finalize_logger(); +} + + +/// Framework include files +#include <RTL/DllAccess.h> + +/// Generic main program to start any process +/** + * Generic main program to start any process + * by loading a library and executing a + * function within + * + * \author M.Frank + * \version 1.0 + */ +int main (int argc, char** argv) { + if ( argc >= 3 ) { + void* handle = LOAD_LIB( argv[1] ); + if ( handle ) { + Function fun(GETPROC(handle, argv[2])); + if ( fun.function ) { + return (*fun.function)(argc-2, &argv[2]); + } + // The required function is not in the loaded image. + // Try to load it directly from the executable + Function f1(GETPROC(0, argv[2])); + if ( f1.function ) { + std::cout << "[WARNING] Executing function " << argv[2] + << " from exe rather than image " << std::endl; + return (*f1.function)(argc-2, &argv[2]); + } + std::cout << "[ERROR] Failed to access test procedure: '" << argv[2] << "'" << std::endl; + std::cout << "[ERROR] Error: " << DLERROR << std::endl; + return EINVAL; + } + std::cout << "[ERROR] Failed to load test library: '" << argv[1] << "'" << std::endl; + std::cout << "[ERROR] Error: " << DLERROR << std::endl; + return EINVAL; + } + std::cout << "[ERROR] usage: gentest.exe <library-name> <function-name> -arg [-arg]" << std::endl; + return EINVAL; +} diff --git a/Online/OnlineBase/main/gentest.cpp b/Online/OnlineBase/main/gentest.cpp new file mode 100755 index 0000000000000000000000000000000000000000..99988aab40f4811f94e6c065584aefa00413f5ee --- /dev/null +++ b/Online/OnlineBase/main/gentest.cpp @@ -0,0 +1,52 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +//-------------------------------------------------------------------------- +// +// Author : Markus Frank +//========================================================================== +#include "RTL/DllAccess.h" +#include <iostream> +#include <cerrno> + +/// Generic main program to start any process +/** + * Generic main program to start any process + * by loading a library and executing a + * function within + * + * \author M.Frank + * \version 1.0 + */ +int main (int argc, char** argv) { + if ( argc >= 3 ) { + void* handle = LOAD_LIB( argv[1] ); + if ( handle ) { + Function fun(GETPROC(handle, argv[2])); + if ( fun.function ) { + return (*fun.function)(argc-2, &argv[2]); + } + // The required function is not in the loaded image. + // Try to load it directly from the executable + Function f1(GETPROC(0, argv[2])); + if ( f1.function ) { + std::cout << "[WARNING] Executing function " << argv[2] + << " from exe rather than image " << std::endl; + return (*f1.function)(argc-2, &argv[2]); + } + std::cout << "[ERROR] Failed to access test procedure: '" << argv[2] << "'" << std::endl; + std::cout << "[ERROR] Error: " << DLERROR << std::endl; + return EINVAL; + } + std::cout << "[ERROR] Failed to load test library: '" << argv[1] << "'" << std::endl; + std::cout << "[ERROR] Error: " << DLERROR << std::endl; + return EINVAL; + } + std::cout << "[ERROR] usage: gentest.exe <library-name> <function-name> -arg [-arg]" << std::endl; + return EINVAL; +} diff --git a/Online/OnlineBase/main/mbm_remove.cpp b/Online/OnlineBase/main/mbm_remove.cpp new file mode 100755 index 0000000000000000000000000000000000000000..bbc209c556ec9f3b49bff5aca0b38a5351238270 --- /dev/null +++ b/Online/OnlineBase/main/mbm_remove.cpp @@ -0,0 +1,28 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +//-------------------------------------------------------------------------- +// +// Author : Markus Frank +//========================================================================== +#include "RTL/DllAccess.h" +#include <iostream> + +int main (int argc, char** argv) { + void* handle = LOAD_LIB2( "OnlineKernel" ); + if ( 0 != handle ) { + Function fun(GETPROC(handle,"mbm_remove")); + if ( fun.function ) { + return (*fun.function)(argc, argv); + } + std::cout << "Failed to access test procedure!" << std::endl; + } + std::cout << "Failed to load test library!" << std::endl; + std::cout << "Error: " << DLERROR << std::endl; + return 0; +} diff --git a/Online/OnlineBase/main/wt.cpp b/Online/OnlineBase/main/wt.cpp new file mode 100755 index 0000000000000000000000000000000000000000..e6a77bf309e926bb8106f0d9f2503975bc2dbc69 --- /dev/null +++ b/Online/OnlineBase/main/wt.cpp @@ -0,0 +1,31 @@ +//========================================================================== +// LHCb Online software suite +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see OnlineSys/LICENSE. +// +//-------------------------------------------------------------------------- +// +// Author : Markus Frank +//========================================================================== +#include "RTL/DllAccess.h" +#include <iostream> + +using OnlineBase::FuncPtrCast; + +int main (int argc, char** argv) { + void* handle = LOAD_LIB2("OnlineKernel"); + if ( 0 != handle ) { + typedef int (*func_t)(int, char**); + func_t fun = FuncPtrCast<func_t>(GETPROC(handle, argv[1])); + if ( fun ) { + return (*fun)(argc-1, &argv[1]); + } + std::cout << "Failed to access test procedure!" << std::endl; + } + std::cout << "Failed to load test library!" << std::endl; + std::cout << "Error: " << DLERROR << std::endl; + return 0; +}