From 7ec97697924240262432e8ff0a1822b1034b1dc9 Mon Sep 17 00:00:00 2001 From: hadaq Date: Fri, 20 Jul 2012 15:50:45 +0000 Subject: [PATCH] removed semaphores from TRB3 design, not needed anymore --- libtrbnet/trbnet.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/libtrbnet/trbnet.c b/libtrbnet/trbnet.c index bf05bef..83fa017 100644 --- a/libtrbnet/trbnet.c +++ b/libtrbnet/trbnet.c @@ -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 @@ -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 ----------------------------------------------- */ -- 2.43.0