author | Sergey Surkov <surkovsv93@gmail.com> |
Thu, 17 Nov 2016 14:04:44 +0300 | |
changeset 1567 | a4bf874e4949 |
parent 1457 | ff7cfce737ca |
child 1903 | 084256be3658 |
permissions | -rw-r--r-- |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
1 |
/** |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
2 |
* Linux specific code |
329 | 3 |
**/ |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
4 |
|
205 | 5 |
#include <stdio.h> |
6 |
#include <string.h> |
|
7 |
#include <time.h> |
|
8 |
#include <signal.h> |
|
9 |
#include <stdlib.h> |
|
329 | 10 |
#include <pthread.h> |
568 | 11 |
#include <locale.h> |
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
12 |
#include <semaphore.h> |
205 | 13 |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
14 |
static sem_t Run_PLC; |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
15 |
|
236 | 16 |
long AtomicCompareExchange(long* atomicvar,long compared, long exchange) |
205 | 17 |
{ |
18 |
return __sync_val_compare_and_swap(atomicvar, compared, exchange); |
|
19 |
} |
|
954 | 20 |
long long AtomicCompareExchange64(long long* atomicvar, long long compared, long long exchange) |
21 |
{ |
|
22 |
return __sync_val_compare_and_swap(atomicvar, compared, exchange); |
|
23 |
} |
|
205 | 24 |
|
25 |
void PLC_GetTime(IEC_TIME *CURRENT_TIME) |
|
26 |
{ |
|
592 | 27 |
struct timespec tmp; |
28 |
clock_gettime(CLOCK_REALTIME, &tmp); |
|
29 |
CURRENT_TIME->tv_sec = tmp.tv_sec; |
|
30 |
CURRENT_TIME->tv_nsec = tmp.tv_nsec; |
|
205 | 31 |
} |
32 |
||
33 |
void PLC_timer_notify(sigval_t val) |
|
34 |
{ |
|
35 |
PLC_GetTime(&__CURRENT_TIME); |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
36 |
sem_post(&Run_PLC); |
205 | 37 |
} |
38 |
||
39 |
timer_t PLC_timer; |
|
40 |
||
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
485
diff
changeset
|
41 |
void PLC_SetTimer(unsigned long long next, unsigned long long period) |
205 | 42 |
{ |
43 |
struct itimerspec timerValues; |
|
44 |
/* |
|
45 |
printf("SetTimer(%lld,%lld)\n",next, period); |
|
46 |
*/ |
|
47 |
memset (&timerValues, 0, sizeof (struct itimerspec)); |
|
48 |
{ |
|
49 |
#ifdef __lldiv_t_defined |
|
50 |
lldiv_t nxt_div = lldiv(next, 1000000000); |
|
51 |
lldiv_t period_div = lldiv(period, 1000000000); |
|
52 |
timerValues.it_value.tv_sec = nxt_div.quot; |
|
53 |
timerValues.it_value.tv_nsec = nxt_div.rem; |
|
54 |
timerValues.it_interval.tv_sec = period_div.quot; |
|
55 |
timerValues.it_interval.tv_nsec = period_div.rem; |
|
56 |
#else |
|
57 |
timerValues.it_value.tv_sec = next / 1000000000; |
|
58 |
timerValues.it_value.tv_nsec = next % 1000000000; |
|
59 |
timerValues.it_interval.tv_sec = period / 1000000000; |
|
60 |
timerValues.it_interval.tv_nsec = period % 1000000000; |
|
61 |
#endif |
|
329 | 62 |
} |
205 | 63 |
timer_settime (PLC_timer, 0, &timerValues, NULL); |
64 |
} |
|
65 |
// |
|
66 |
void catch_signal(int sig) |
|
67 |
{ |
|
68 |
// signal(SIGTERM, catch_signal); |
|
69 |
signal(SIGINT, catch_signal); |
|
70 |
printf("Got Signal %d\n",sig); |
|
71 |
exit(0); |
|
72 |
} |
|
73 |
||
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
74 |
|
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
75 |
static unsigned long __debug_tick; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
76 |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
77 |
pthread_t PLC_thread; |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
78 |
static pthread_mutex_t python_wait_mutex = PTHREAD_MUTEX_INITIALIZER; |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
79 |
static pthread_mutex_t python_mutex = PTHREAD_MUTEX_INITIALIZER; |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
80 |
static pthread_mutex_t debug_wait_mutex = PTHREAD_MUTEX_INITIALIZER; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
81 |
static pthread_mutex_t debug_mutex = PTHREAD_MUTEX_INITIALIZER; |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
82 |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
83 |
int PLC_shutdown = 0; |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
84 |
|
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
85 |
void PLC_thread_proc(void *arg) |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
86 |
{ |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
87 |
while (!PLC_shutdown) { |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
88 |
sem_wait(&Run_PLC); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
89 |
__run(); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
90 |
} |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
91 |
pthread_exit(0); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
92 |
} |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
93 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
94 |
#define maxval(a,b) ((a>b)?a:b) |
205 | 95 |
int startPLC(int argc,char **argv) |
96 |
{ |
|
97 |
struct sigevent sigev; |
|
568 | 98 |
setlocale(LC_NUMERIC, "C"); |
329 | 99 |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
100 |
PLC_shutdown = 0; |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
101 |
|
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
102 |
sem_init(&Run_PLC, 0, 0); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
103 |
|
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
104 |
pthread_create(&PLC_thread, NULL, (void*) &PLC_thread_proc, NULL); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
105 |
|
205 | 106 |
memset (&sigev, 0, sizeof (struct sigevent)); |
107 |
sigev.sigev_value.sival_int = 0; |
|
108 |
sigev.sigev_notify = SIGEV_THREAD; |
|
109 |
sigev.sigev_notify_attributes = NULL; |
|
110 |
sigev.sigev_notify_function = PLC_timer_notify; |
|
111 |
||
333 | 112 |
pthread_mutex_init(&debug_wait_mutex, NULL); |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
113 |
pthread_mutex_init(&debug_mutex, NULL); |
333 | 114 |
pthread_mutex_init(&python_wait_mutex, NULL); |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
115 |
pthread_mutex_init(&python_mutex, NULL); |
329 | 116 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
117 |
pthread_mutex_lock(&debug_wait_mutex); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
118 |
pthread_mutex_lock(&python_wait_mutex); |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
119 |
|
205 | 120 |
timer_create (CLOCK_REALTIME, &sigev, &PLC_timer); |
121 |
if( __init(argc,argv) == 0 ){ |
|
1428
e14003eb4d42
Simplified use of runtime's global variable __common_ticktime accross extensions.
Edouard Tisserant
parents:
985
diff
changeset
|
122 |
PLC_SetTimer(common_ticktime__,common_ticktime__); |
329 | 123 |
|
205 | 124 |
/* install signal handler for manual break */ |
125 |
signal(SIGINT, catch_signal); |
|
126 |
}else{ |
|
127 |
return 1; |
|
128 |
} |
|
129 |
return 0; |
|
130 |
} |
|
131 |
||
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
132 |
int TryEnterDebugSection(void) |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
133 |
{ |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
134 |
if (pthread_mutex_trylock(&debug_mutex) == 0){ |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
135 |
/* Only enter if debug active */ |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
136 |
if(__DEBUG){ |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
137 |
return 1; |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
138 |
} |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
139 |
pthread_mutex_unlock(&debug_mutex); |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
140 |
} |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
141 |
return 0; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
142 |
} |
235 | 143 |
|
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
144 |
void LeaveDebugSection(void) |
235 | 145 |
{ |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
146 |
pthread_mutex_unlock(&debug_mutex); |
235 | 147 |
} |
148 |
||
205 | 149 |
int stopPLC() |
150 |
{ |
|
151 |
/* Stop the PLC */ |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
152 |
PLC_shutdown = 1; |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
153 |
sem_post(&Run_PLC); |
205 | 154 |
PLC_SetTimer(0,0); |
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
155 |
pthread_join(PLC_thread, NULL); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
156 |
sem_destroy(&Run_PLC); |
205 | 157 |
timer_delete (PLC_timer); |
158 |
__cleanup(); |
|
329 | 159 |
pthread_mutex_destroy(&debug_wait_mutex); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
160 |
pthread_mutex_destroy(&debug_mutex); |
329 | 161 |
pthread_mutex_destroy(&python_wait_mutex); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
162 |
pthread_mutex_destroy(&python_mutex); |
386 | 163 |
return 0; |
205 | 164 |
} |
165 |
||
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
166 |
extern unsigned long __tick; |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
167 |
|
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
168 |
int WaitDebugData(unsigned long *tick) |
205 | 169 |
{ |
617
7c23fac40a2a
fixed debug with xenomai, fixed unprotected access to ___debug_tick
Edouard Tisserant
parents:
614
diff
changeset
|
170 |
int res; |
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
171 |
if (PLC_shutdown) return 1; |
617
7c23fac40a2a
fixed debug with xenomai, fixed unprotected access to ___debug_tick
Edouard Tisserant
parents:
614
diff
changeset
|
172 |
/* Wait signal from PLC thread */ |
7c23fac40a2a
fixed debug with xenomai, fixed unprotected access to ___debug_tick
Edouard Tisserant
parents:
614
diff
changeset
|
173 |
res = pthread_mutex_lock(&debug_wait_mutex); |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
174 |
*tick = __debug_tick; |
617
7c23fac40a2a
fixed debug with xenomai, fixed unprotected access to ___debug_tick
Edouard Tisserant
parents:
614
diff
changeset
|
175 |
return res; |
205 | 176 |
} |
329 | 177 |
|
205 | 178 |
/* Called by PLC thread when debug_publish finished |
179 |
* This is supposed to unlock debugger thread in WaitDebugData*/ |
|
180 |
void InitiateDebugTransfer() |
|
181 |
{ |
|
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
182 |
/* remember tick */ |
227
48c13b84505c
- Some improovements in debug data feedback data
etisserant
parents:
205
diff
changeset
|
183 |
__debug_tick = __tick; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
184 |
/* signal debugger thread it can read data */ |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
185 |
pthread_mutex_unlock(&debug_wait_mutex); |
205 | 186 |
} |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
187 |
|
614 | 188 |
int suspendDebug(int disable) |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
189 |
{ |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
190 |
/* Prevent PLC to enter debug code */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
191 |
pthread_mutex_lock(&debug_mutex); |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
192 |
/*__DEBUG is protected by this mutex */ |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
193 |
__DEBUG = !disable; |
485 | 194 |
if (disable) |
195 |
pthread_mutex_unlock(&debug_mutex); |
|
614 | 196 |
return 0; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
197 |
} |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
198 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
199 |
void resumeDebug(void) |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
200 |
{ |
290
3bd617ae7a05
Local Runtime (LOCAL://) now launched "on demand"
etisserant
parents:
280
diff
changeset
|
201 |
__DEBUG = 1; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
202 |
/* Let PLC enter debug code */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
203 |
pthread_mutex_unlock(&debug_mutex); |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
204 |
} |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
205 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
206 |
/* from plc_python.c */ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
207 |
int WaitPythonCommands(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
208 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
209 |
/* Wait signal from PLC thread */ |
329 | 210 |
return pthread_mutex_lock(&python_wait_mutex); |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
211 |
} |
329 | 212 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
213 |
/* Called by PLC thread on each new python command*/ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
214 |
void UnBlockPythonCommands(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
215 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
216 |
/* signal debugger thread it can read data */ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
217 |
pthread_mutex_unlock(&python_wait_mutex); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
218 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
219 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
220 |
int TryLockPython(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
221 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
222 |
return pthread_mutex_trylock(&python_mutex) == 0; |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
223 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
224 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
225 |
void UnLockPython(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
226 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
227 |
pthread_mutex_unlock(&python_mutex); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
228 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
229 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
230 |
void LockPython(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
231 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
232 |
pthread_mutex_lock(&python_mutex); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
233 |
} |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
234 |
|
1457
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
235 |
void InitRetain(void) |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
236 |
{ |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
237 |
} |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
238 |
|
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
239 |
void CleanupRetain(void) |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
240 |
{ |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
241 |
} |
ff7cfce737ca
Added PLCID variable accessible from C side, set with binarie's MD5. Added retain init and cleanup calls. Extended tests/python to test PLCID
Edouard Tisserant
parents:
1428
diff
changeset
|
242 |
|
522 | 243 |
int CheckRetainBuffer(void) |
244 |
{ |
|
245 |
return 1; |
|
246 |
} |
|
247 |
||
580 | 248 |
void ValidateRetainBuffer(void) |
249 |
{ |
|
250 |
} |
|
251 |
||
252 |
void InValidateRetainBuffer(void) |
|
253 |
{ |
|
254 |
} |
|
255 |
||
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
256 |
void Retain(unsigned int offset, unsigned int count, void *p) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
257 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
258 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
259 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
260 |
void Remind(unsigned int offset, unsigned int count, void *p) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
261 |
{ |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
262 |
} |