ctrlc.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Interface for OSQP signal handling.
  3. */
  4. #ifndef CTRLC_H
  5. # define CTRLC_H
  6. # ifdef __cplusplus
  7. extern "C" {
  8. # endif // ifdef __cplusplus
  9. # include "glob_opts.h"
  10. # if defined MATLAB
  11. /* No header file available here; define the prototypes ourselves */
  12. bool utIsInterruptPending(void);
  13. bool utSetInterruptEnabled(bool);
  14. # elif defined IS_WINDOWS
  15. /* Use Windows SetConsoleCtrlHandler for signal handling */
  16. # include <windows.h>
  17. # else // if defined MATLAB
  18. /* Use sigaction for signal handling on non-Windows machines */
  19. # include <signal.h>
  20. # endif // if defined MATLAB
  21. /* METHODS are the same for both */
  22. /**
  23. * Start listener for ctrl-c interrupts
  24. */
  25. void osqp_start_interrupt_listener(void);
  26. /**
  27. * End listener for ctrl-c interrupts
  28. */
  29. void osqp_end_interrupt_listener(void);
  30. /**
  31. * Check if the solver has been interrupted
  32. * @return Boolean indicating if the solver has been interrupted
  33. */
  34. int osqp_is_interrupted(void);
  35. # ifdef __cplusplus
  36. }
  37. # endif // ifdef __cplusplus
  38. #endif /* END IFDEF CTRLC */