Remove to_string from JITInputFile.cpp

Follow the existing error reporting pattern
This commit is contained in:
Derek Bankieris 2019-09-03 11:08:38 -05:00
parent d3ca4c4781
commit 3a03f7af53

View File

@ -2,6 +2,7 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <cstring>
#include <string> #include <string>
#include <string.h> #include <string.h>
@ -157,7 +158,8 @@ int Trick::JITInputFile::compile(std::string file_name) {
// If the compilation was unsuccessful, exec_terminate // If the compilation was unsuccessful, exec_terminate
if ( ret != 0 ) { if ( ret != 0 ) {
std::string error_message = "JITInputfile shared library creation failed. ret:" + std::to_string(ret) + " errno:"+ strerror(errno); std::string error_message = std::string("JITInputFile shared library creation failed: ")
+ std::strerror(errno);
exec_terminate_with_return(-1 , __FILE__ , __LINE__ , error_message.c_str()); exec_terminate_with_return(-1 , __FILE__ , __LINE__ , error_message.c_str());
} }
@ -181,9 +183,6 @@ int Trick::JITInputFile::compile(std::string file_name) {
-# Call the function -# Call the function
*/ */
int Trick::JITInputFile::run(std::string file_name , std::string run_function ) { int Trick::JITInputFile::run(std::string file_name , std::string run_function ) {
int (*call_me)(void) = NULL ;
int ret = 0 ;
// Check if we have compiled this library yet. // Check if we have compiled this library yet.
if ( file_to_libinfo_map.find(file_name) == file_to_libinfo_map.end() ) { if ( file_to_libinfo_map.find(file_name) == file_to_libinfo_map.end() ) {
// If we have not compiled the library then exec_terminate // If we have not compiled the library then exec_terminate
@ -203,16 +202,13 @@ int Trick::JITInputFile::run(std::string file_name , std::string run_function )
} }
// Look up the symbol name // Look up the symbol name
call_me = (int (*)(void))dlsym( li.handle , run_function.c_str()) ; int (*call_me)(void) = (int (*)(void))dlsym( li.handle , run_function.c_str()) ;
if ( call_me == NULL ) { if ( call_me == NULL ) {
std::string error_message = "JITInputfile could not find function " + run_function ; std::string error_message = "JITInputfile could not find function " + run_function ;
exec_terminate_with_return(-1 , __FILE__ , __LINE__ , error_message.c_str() ) ; return exec_terminate_with_return(-1 , __FILE__ , __LINE__ , error_message.c_str() ) ;
} else { } else {
// We found the function, call it! // We found the function, call it!
ret = (*call_me)() ; return (*call_me)() ;
return ret ;
} }
} }