Debian Codegraph @

sysport/sysport.h

raw symbols SCIP
1 #if !defined(H_SYSPOR)
2 #define H_SYSPOR
3
4 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
5
6 /*
7 | Define
8 | MONOTHREAD: if SMP functions are not going to be used nor linked with -lpthread
9 |
10 */
11
12 #if defined(MINGW)
13 #include <windows.h>
14 #if !defined(MVSC)
15 #define MVSC
16 #endif
17 #endif
18
19 #ifdef _MSC_VER
20 #include <windows.h>
21 #if !defined(MVSC)
22 #define MVSC
23 #endif
24 #else
25 #include <unistd.h>
26 #endif
27
28
29 #if defined(__linux__) || defined(__GNUC__)
30 #if !defined(GCCLINUX)
31 #define GCCLINUX
32 #endif
33 #endif
34
35 #if defined(MINGW)
36 #undef GCCLINUX
37 #endif
38
39 /*
40 |
41 | To allow multithreaded functions, MULTI_THREADED_INTERFACE should be defined
42 |
43 \*--------------------------------------------------------------------------------*/
44
45
46 #if defined(CYGWIN)
47 #define USECLOCK
48 #define MULTI_THREADED_INTERFACE
49 #undef NT_THREADS
50 #define POSIX_THREADS
51 #define GCCLINUX_INTEGERS
52 #elif defined(MINGW)
53 #define USEWINCLOCK
54 #define MULTI_THREADED_INTERFACE
55 #define NT_THREADS
56 #undef POSIX_THREADS
57 #define MSWINDOWS_INTEGERS
58 #elif defined(GCCLINUX)
59 #define USELINCLOCK
60 #define MULTI_THREADED_INTERFACE
61 #undef NT_THREADS
62 #define POSIX_THREADS
63 #define GCCLINUX_INTEGERS
64 #elif defined(MVSC)
65 #define USEWINCLOCK
66 #define MULTI_THREADED_INTERFACE
67 #define NT_THREADS
68 #undef POSIX_THREADS
69 #define MSWINDOWS_INTEGERS
70 #else
71 #error COMPILER NOT DEFINED
72 #endif
73
74 #if defined(MONOTHREAD)
75 #undef MULTI_THREADED_INTERFACE
76 #endif
77
78
79 #if defined(GCCLINUX) || defined(MINGW)
80 #define U64(x) (x##ull)
81 #elif defined(MVSC)
82 #define U64(x) (x##ui64)
83 #else
84 #error OS not defined properly
85 #endif
86
87
88 #if defined(GCCLINUX) || defined(MINGW)
89 /*
90 typedef unsigned long long int uint64_t;
91 typedef long long int int64_t;
92 typedef unsigned char uint8_t;
93 typedef unsigned short int uint16_t;
94 typedef unsigned int uint32_t;
95 */
96
97 #include <stdint.h>
98
99 #elif defined(MVSC)
100
101 typedef unsigned char uint8_t;
102 typedef unsigned short int uint16_t;
103 typedef unsigned int uint32_t;
104 typedef unsigned __int64 uint64_t;
105
106 typedef signed char int8_t;
107 typedef short int int16_t;
108 typedef int int32_t;
109 typedef __int64 int64_t;
110
111 #else
112 #error OS not defined properly for 64 bit integers
113 #endif
114
115
116 /*-----------------
117 PATH NAMES
118 ------------------*/
119
120 #if defined(GCCLINUX)
121 #define FOLDERSEP "/"
122 #elif defined(MVSC)
123 #define FOLDERSEP "\\"
124 #else
125 #define FOLDERSEP "/"
126 #endif
127
128 /* path names */
129 extern int isfoldersep (int x);
130
131 /*-----------------
132 FOPEN MAX
133 ------------------*/
134
135 extern int mysys_fopen_max (void);
136
137 /*------------
138 TIMER
139 -------------*/
140
141 typedef int64_t myclock_t;
142
143 extern myclock_t myclock(void);
144 extern myclock_t ticks_per_sec (void);
145
146 #define MYCLOCKS_PER_SEC (ticks_per_sec())
147 #define GET_TICK (myclock())
148
149
150 /*********************************************************************/
151 #if defined(MULTI_THREADED_INTERFACE)
152
153 /*------------
154 THREADS
155 -------------*/
156
157 #if defined (POSIX_THREADS)
158
159 #include <pthread.h>
160 #include <semaphore.h>
161
162 #define THREAD_CALL
163
164 typedef void * thread_return_t;
165 typedef pthread_t mythread_t;
166 typedef thread_return_t (THREAD_CALL *routine_t) (void *);
167 typedef pthread_mutex_t mythread_mutex_t;
168
169 #ifdef SPINLOCKS
170 typedef pthread_spinlock_t mythread_spinx_t;
171 #else
172 typedef pthread_mutex_t mythread_spinx_t;
173 #endif
174
175 typedef sem_t mysem_t;
176
177
178 #elif defined(NT_THREADS)
179
180 #define WIN32_LEAN_AND_MEAN
181
182 #include <windows.h>
183 #include <process.h>
184
185 #define THREAD_CALL __stdcall
186
187 typedef unsigned thread_return_t;
188 typedef HANDLE mythread_t;
189 typedef thread_return_t (THREAD_CALL *routine_t) (void *);
190 typedef HANDLE mythread_mutex_t;
191
192 #define SPINLOCKS
193
194 #ifdef SPINLOCKS
195 typedef CRITICAL_SECTION mythread_spinx_t;
196 #else
197 typedef HANDLE mythread_spinx_t;
198 #endif
199
200 typedef HANDLE mysem_t;
201
202 #else
203 #error Definition of threads not present
204 #endif
205
206
207
208 extern int /*boolean*/ mythread_create (/*@out@*/ mythread_t *thread, routine_t start_routine, void *arg, /*@out@*/ int *ret_error);
209 extern int /*boolean*/ mythread_join (mythread_t thread);
210 extern void mythread_exit (void);
211 extern const char * mythread_create_error (int err);
212
213 extern void mythread_mutex_init (mythread_mutex_t *m);
214 extern void mythread_mutex_destroy (mythread_mutex_t *m);
215 extern void mythread_mutex_lock (mythread_mutex_t *m);
216 extern void mythread_mutex_unlock (mythread_mutex_t *m);
217
218 extern void mythread_spinx_init (mythread_spinx_t *m); /**/
219 extern void mythread_spinx_destroy (mythread_spinx_t *m); /**/
220 extern void mythread_spinx_lock (mythread_spinx_t *m); /**/
221 extern void mythread_spinx_unlock (mythread_spinx_t *m); /**/
222
223 /* semaphores*/
224 extern int /*boolean*/ mysem_init (mysem_t *sem, unsigned int value);
225 extern int /*boolean*/ mysem_wait (mysem_t *sem);
226 extern int /*boolean*/ mysem_post (mysem_t *sem);
227 extern int /*boolean*/ mysem_destroy (mysem_t *sem);
228 #endif
229
230
231
232
233
234 /* end MULTI_THREADED_INTERFACE*/
235 #endif
236
237 /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/