Fixes for cross-platform build.

This commit is contained in:
2019-06-26 13:02:45 +01:00
parent 605fa0b691
commit 06d7e8e9a8
11 changed files with 155 additions and 34 deletions

View File

@@ -1,9 +1,41 @@
#include "U2FDevice.hpp"
#include "Architecture.hpp"
#include <execinfo.h>
#include <iostream>
#ifdef DEBUG_MSGS
//Courtesy StackOverflow answer https://stackoverflow.com/a/3356421
void terminateHandler()
{
void *trace_elems[20];
int trace_elem_count(backtrace(trace_elems, 20));
char **stack_syms(backtrace_symbols(trace_elems, trace_elem_count));
for (int i = 0; i < trace_elem_count; ++i)
{
std::cout << stack_syms[i] << "\n";
}
free(stack_syms);
exit(1);
}
#endif
int main(int argc, char **argv) {
initialiseLights(argv[0]);
#ifdef DEBUG_MSGS
std::set_terminate(terminate_handler);
#endif
int retCode = handleTransactions(argv[0], argc == 2 ? argv[1] : STORAGE_PREFIX);
deinitialiseLights(argv[0]);
try
{
initialiseLights(argv[0]);
deinitialiseLights(argv[0]);
}
catch (std::exception &e)
{
std::cerr << "Exception in code: " << e.what() << std::endl;
throw;
}
return retCode;
}