SuperSCS  1.3.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ctrlc.h
Go to the documentation of this file.
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2017 Pantelis Sopasakis (https://alphaville.github.io),
5  * Krina Menounou (https://www.linkedin.com/in/krinamenounou),
6  * Panagiotis Patrinos (http://homes.esat.kuleuven.be/~ppatrino)
7  * Copyright (c) 2012 Brendan O'Donoghue (bodonoghue85@gmail.com)
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this software and associated documentation files (the "Software"), to deal
11  * in the Software without restriction, including without limitation the rights
12  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  * copies of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in all
17  * copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25  * SOFTWARE.
26  *
27  */
28 
29 /*
30  * Interface for SCS signal handling.
31  */
32 
33 #ifndef CTRLC_H_GUARD
34 #define CTRLC_H_GUARD
35 
36 #if !(defined _WIN32 || defined _WIN64 || defined _WINDLL || defined __APPLE__)
37 #ifdef _POSIX_C_SOURCE
38 #undef _POSIX_C_SOURCE
39 #endif
40 #define _POSIX_C_SOURCE 199309L
41 #endif
42 
43 #if CTRLC > 0
44 
45 #if defined MATLAB_MEX_FILE
46 
47 /* No header file available here; define the prototypes ourselves */
48 extern int utIsInterruptPending();
49 extern int utSetInterruptEnabled(int);
50 
51 #elif(defined _WIN32 || defined _WIN64 || defined _WINDLL)
52 
53 /* Use Windows SetConsoleCtrlHandler for signal handling */
54 #include <windows.h>
55 
56 #else
57 
58 /* Use POSIX clocl_gettime() for timing on non-Windows machines */
59 #include <signal.h>
60 
61 #endif
62 
63 /* METHODS are the same for both */
64 void startInterruptListener(void);
65 void endInterruptListener(void);
66 int isInterrupted(void);
67 
68 #else /* CTRLC = 0 */
69 
70 /* No signal handling. */
71 #define startInterruptListener()
72 #define endInterruptListener()
73 #define isInterrupted() 0
74 
75 #endif /* END IF CTRLC > 0 */
76 
77 #endif /* END IFDEF __TIMER_H__ */
#define endInterruptListener()
Definition: ctrlc.h:72
#define startInterruptListener()
Definition: ctrlc.h:71
#define isInterrupted()
Definition: ctrlc.h:73