tests/python/c_code@c_ext/cfile.xml
changeset 862 bb59865db6e6
parent 860 8a51046010d7
child 953 1fb6cf5a4c4d
equal deleted inserted replaced
861:980800a5aad0 862:bb59865db6e6
    13 
    13 
    14 int Simple_C_Call(int val){
    14 int Simple_C_Call(int val){
    15   return val+1;
    15   return val+1;
    16 }
    16 }
    17 
    17 
    18 int Python_to_C_Call(int toC, int *fromC){
    18 int Python_to_C_Call(char toC, char *fromC){
    19   /* Code called by python should never touch to 
    19   /* Code called by python should never touch to 
    20      variables modified by PLC thread directly
    20      variables modified by PLC thread directly
    21 
    21 
    22      AtomicCompareExchange comes from 
    22      AtomicCompareExchange comes from 
    23      beremiz' runtime implementation */
    23      beremiz' runtime implementation */
    31   }
    31   }
    32   printf("C code called by Python: toC %d fromC %d\n",toC,*fromC);
    32   printf("C code called by Python: toC %d fromC %d\n",toC,*fromC);
    33   return res;
    33   return res;
    34 }
    34 }
    35 
    35 
    36 int PLC_C_Call(int fromPLC, int *toPLC){
    36 int PLC_C_Call(char fromPLC, char *toPLC){
    37   /* PLC also have to be realy carefull not to 
    37   /* PLC also have to be realy carefull not to 
    38      conflict with asynchronous python access */
    38      conflict with asynchronous python access */
    39   int res;
    39   int res;
    40   if(!AtomicCompareExchange(&Lock, 0, 1)){
    40   if(!AtomicCompareExchange(&Lock, 0, 1)){
    41       CtoP = fromPLC;
    41       CtoP = fromPLC;