Austin Schuh | 9049e20 | 2022-02-20 17:34:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Interface for OSQP signal handling. |
| 3 | */ |
| 4 | |
| 5 | #ifndef CTRLC_H |
| 6 | # define CTRLC_H |
| 7 | |
| 8 | # ifdef __cplusplus |
| 9 | extern "C" { |
| 10 | # endif // ifdef __cplusplus |
| 11 | |
| 12 | # include "glob_opts.h" |
| 13 | |
| 14 | # if defined MATLAB |
| 15 | |
| 16 | /* No header file available here; define the prototypes ourselves */ |
| 17 | bool utIsInterruptPending(void); |
| 18 | bool utSetInterruptEnabled(bool); |
| 19 | |
| 20 | # elif defined IS_WINDOWS |
| 21 | |
| 22 | /* Use Windows SetConsoleCtrlHandler for signal handling */ |
| 23 | # include <windows.h> |
| 24 | |
| 25 | # else // if defined MATLAB |
| 26 | |
| 27 | /* Use sigaction for signal handling on non-Windows machines */ |
| 28 | # include <signal.h> |
| 29 | |
| 30 | # endif // if defined MATLAB |
| 31 | |
| 32 | /* METHODS are the same for both */ |
| 33 | |
| 34 | /** |
| 35 | * Start listener for ctrl-c interrupts |
| 36 | */ |
| 37 | void osqp_start_interrupt_listener(void); |
| 38 | |
| 39 | /** |
| 40 | * End listener for ctrl-c interrupts |
| 41 | */ |
| 42 | void osqp_end_interrupt_listener(void); |
| 43 | |
| 44 | /** |
| 45 | * Check if the solver has been interrupted |
| 46 | * @return Boolean indicating if the solver has been interrupted |
| 47 | */ |
| 48 | int osqp_is_interrupted(void); |
| 49 | |
| 50 | |
| 51 | # ifdef __cplusplus |
| 52 | } |
| 53 | # endif // ifdef __cplusplus |
| 54 | |
| 55 | |
| 56 | #endif /* END IFDEF CTRLC */ |