]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
removed semaphores from TRB3 design, not needed anymore
authorhadaq <hadaq>
Fri, 20 Jul 2012 15:50:45 +0000 (15:50 +0000)
committerhadaq <hadaq>
Fri, 20 Jul 2012 15:50:45 +0000 (15:50 +0000)
libtrbnet/trbnet.c

index bf05befd884f5cd09130d1b088d5c021fc5b5e36..83fa01704f5d0c28fea2f0ba8470caaa85b0a331 100644 (file)
@@ -1,11 +1,11 @@
 #ifdef ETRAX
-const char trbnet_version[] = "$Revision: 4.39 $  Local Etrax";
+const char trbnet_version[] = "$Revision: 4.40 $  Local Etrax";
 #elif defined PEXOR
-const char trbnet_version[] = "$Revision: 4.39 $  Local Pexor";
+const char trbnet_version[] = "$Revision: 4.40 $  Local Pexor";
 #elif defined TRB3
-const char trbnet_version[] = "$Revision: 4.39 $  Local TRB3";
+const char trbnet_version[] = "$Revision: 4.40 $  Local TRB3";
 #else
-const char trbnet_version[] = "$Revision: 4.39 $  UNKNOWN, i.e. ERROR";
+const char trbnet_version[] = "$Revision: 4.40 $  UNKNOWN, i.e. ERROR";
 #endif
 
 #include <stdlib.h>
@@ -181,9 +181,7 @@ static sigset_t blockSetOld;
 
 /* Semaphore handling */
 static int semid = -1;
-#if defined TRB3 
-static const key_t sem_key = 0x747262;
-#else
+#ifndef TRB3 
 static const key_t sem_key = 0x545242;
 #endif
 
@@ -1381,6 +1379,7 @@ static int master_lock = 0;
 
 static int lockPorts(int masterLock)
 {
+#ifndef TRB3
   struct sembuf sops = {
     0,           /* sem_num: We only use one track                        */
     -1,          /* sem_op: decrement semaphore by 1, i.e. lock it        */
@@ -1390,6 +1389,7 @@ static int lockPorts(int masterLock)
   if ((master_lock == 1) && (masterLock == 0)) {
     return 0;
   }
+#endif
 
   /* Block Signals */
   if (sigprocmask(SIG_BLOCK, &blockSet, &blockSetOld) == -1) {
@@ -1397,6 +1397,7 @@ static int lockPorts(int masterLock)
     return -1;
   }
 
+#ifndef TRB3
   /* Wait for semaphore and lock it */
   if (semop(semid, &sops, 1) == -1) {
     /* Unblock signals */
@@ -1408,6 +1409,7 @@ static int lockPorts(int masterLock)
 #ifdef ETRAX
   /* Get FifoToggleBit-Status, needed by read32_from_FPGA ... */
   fifoToggleBit = readPC() & FIFO_TOGGLE_BIT;
+#endif
 #endif
 
   if (masterLock != 0) master_lock = 1;
@@ -1417,11 +1419,13 @@ static int lockPorts(int masterLock)
 
 static int unlockPorts(int masterLock)
 {
+#ifndef TRB3
   struct sembuf sops = {
     0,              /* sem_num: We only use one track                    */
     1,              /* sem_op: increment semaphore by 1, i.e. unlock it  */
     SEM_UNDO        /* sem_flg: remove lock if process gets killed       */
   };
+#endif
 
   if ((master_lock == 1) && (masterLock == 0)) {
     return 0;
@@ -1429,11 +1433,13 @@ static int unlockPorts(int masterLock)
 
   if (masterLock != 0) master_lock = 0;
 
+#ifndef TRB3
   /* Release semaphore */
   if (semop(semid, &sops, 1) == -1) {
     trb_errno = TRB_SEMAPHORE;
     return -1;
   }
+#endif
 
   /* Unblock Signals */
   if (sigprocmask(SIG_SETMASK, &blockSetOld, NULL) == -1) {
@@ -1450,6 +1456,10 @@ static int init_semaphore()
   /* Set signal mask to block ALL signals */
   sigfillset(&blockSet);
   sigemptyset(&blockSetOld);
+  
+#ifdef TRB3
+  return 0;
+#else
 
   /* Get / Create semaphore */
   if ((semid = semget(sem_key, 1,
@@ -1477,6 +1487,7 @@ static int init_semaphore()
   }
 
   return 0;
+#endif
 }
 
 /* ----- Global Functions ----------------------------------------------- */