equal
deleted
inserted
replaced
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
2 <CodeFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="codefile.xsd"> |
2 <CFile> |
3 <includes> |
3 <includes> |
4 <![CDATA[#include "stdio.h"]]> |
4 <![CDATA[ |
|
5 ]]> |
5 </includes> |
6 </includes> |
6 <variables> |
7 <variables> |
7 <variable name="TestInput" type="SINT" initial="0"/> |
8 <variable name="TestInput" type="SINT" initial="0"/> |
8 <variable name="TestOutput" type="SINT"/> |
9 <variable name="TestOutput" type="SINT"/> |
9 </variables> |
10 </variables> |
10 <globals> |
11 <globals> |
11 <![CDATA[volatile long Lock=0; |
12 <![CDATA[ |
|
13 volatile long Lock=0; |
12 volatile char PtoC=1,CtoP=2; |
14 volatile char PtoC=1,CtoP=2; |
13 |
15 |
14 extern long AtomicCompareExchange(long*,long, long); |
16 extern long AtomicCompareExchange(long*,long, long); |
15 |
17 |
16 int Simple_C_Call(int val){ |
18 int Simple_C_Call(int val){ |
43 *toPLC = PtoC; |
45 *toPLC = PtoC; |
44 AtomicCompareExchange((long*)&Lock, 1, 0); |
46 AtomicCompareExchange((long*)&Lock, 1, 0); |
45 return 1; |
47 return 1; |
46 } |
48 } |
47 return 0; |
49 return 0; |
48 }]]> |
50 } |
|
51 ]]> |
49 </globals> |
52 </globals> |
50 <initFunction> |
53 <initFunction> |
51 <![CDATA[]]> |
54 <![CDATA[ |
|
55 ]]> |
52 </initFunction> |
56 </initFunction> |
53 <cleanUpFunction> |
57 <cleanUpFunction> |
54 <![CDATA[]]> |
58 <![CDATA[ |
|
59 ]]> |
55 </cleanUpFunction> |
60 </cleanUpFunction> |
56 <retrieveFunction> |
61 <retrieveFunction> |
57 <![CDATA[]]> |
62 <![CDATA[ |
|
63 ]]> |
58 </retrieveFunction> |
64 </retrieveFunction> |
59 <publishFunction> |
65 <publishFunction> |
60 <![CDATA[if(!AtomicCompareExchange((long*)&Lock, 0, 1)){ |
66 <![CDATA[ |
|
67 if(!AtomicCompareExchange((long*)&Lock, 0, 1)){ |
61 TestInput = CtoP + PtoC + TestOutput; |
68 TestInput = CtoP + PtoC + TestOutput; |
62 AtomicCompareExchange((long*)&Lock, 1, 0); |
69 AtomicCompareExchange((long*)&Lock, 1, 0); |
63 }]]> |
70 } |
|
71 ]]> |
64 </publishFunction> |
72 </publishFunction> |
65 </CodeFile> |
73 </CFile> |