diff --git a/src/include/os/Linux/osiSock.h b/src/include/os/Linux/osiSock.h index 85d44bd78..538d25346 100644 --- a/src/include/os/Linux/osiSock.h +++ b/src/include/os/Linux/osiSock.h @@ -43,7 +43,7 @@ extern "C" { #endif typedef int SOCKET; -#define INVALID_SOCKET (-1) +#define INVALID_SOCKET (-1) #define SOCKERRNO errno #define socket_close(S) close(S) #define socket_ioctl(A,B,C) ioctl(A,B,C) @@ -51,7 +51,7 @@ typedef int osiSockIoctl_t; #define FD_IN_FDSET(FD) ((FD) #include -#include - -#define DEBUG_OSIMUTEX - -#ifdef DEBUG_OSIMUTEX -#include -#endif - -#ifdef DEBUG_OSIMUTEX -#define osiLock() osiLockI (__FILE__, __LINE__) -#define osiUnlock() osiUnlockI (__FILE__, __LINE__) -#endif class osiMutex { public: + class osiMutexNoMemory {} + osiMutex() - { - mutex = NULL; - } - // - // constructor that returns status - // (since g++ does not have exceptions) - // - int init () { this->mutex = semMCreate(SEM_Q_PRIORITY|SEM_INVERSION_SAFE|SEM_DELETE_SAFE); if (this->mutex==NULL) { - return -1; + throw osiMutexNoMemory(); } -# ifdef DEBUG_OSIMUTEX - epicsPrintf("created mutex at %lx\n", - (unsigned long) this->mutex); -# endif - return 0; } ~osiMutex() @@ -54,73 +25,27 @@ public: STATUS s; s = semDelete (this->mutex); assert (s==OK); -# ifdef DEBUG_OSIMUTEX - epicsPrintf("destroyed mutex at %lx\n", - (unsigned long) this->mutex); -# endif } -#ifdef DEBUG_OSIMUTEX - void osiLockI(const char *pFN, unsigned ln) -#else - void osiLock() -#endif + void lock () const { STATUS s; - if (!this->mutex) { -# ifdef DEBUG_OSIMUTEX - epicsPrintf( - "osiMutex: lock request before init was ignored from %s at %u\n", - pFN, ln); -# else - epicsPrintf( - "osiMutex: lock request before init was ignored\n"); -# endif - return; - } - assert(this->mutex); s = semTake (this->mutex, WAIT_FOREVER); assert (s==OK); -# ifdef DEBUG_OSIMUTEX - epicsPrintf("L%lx in %s at %u\n", - (unsigned long) this->mutex, - pFN, ln); -# endif } -#ifdef DEBUG_OSIMUTEX - void osiUnlockI(const char *pFN, unsigned ln) -#else - void osiUnlock() -#endif + void unlock() const { STATUS s; - - if (!this->mutex) { -# ifdef DEBUG_OSIMUTEX - epicsPrintf( - "osiMutex: unlock request before init was ignored from %s at %u\n", - pFN, ln); -# else - epicsPrintf( - "osiMutex: unlock request before init was ignored\n"); -# endif - return; - } s = semGive (this->mutex); assert (s==OK); -# ifdef DEBUG_OSIMUTEX - epicsPrintf("U%lx in %s at %d\n", - (unsigned long) this->mutex, - pFN, ln); -# endif } - void show(unsigned level) const + void show (unsigned level) const { - semShow(this->mutex, (int) level); + semShow (this->mutex, (int) level); } private: - SEM_ID mutex; + mutable SEM_ID mutex; }; diff --git a/src/include/os/vxWorks/osiSock.h b/src/include/os/vxWorks/osiSock.h index 196f93d50..352895c27 100644 --- a/src/include/os/vxWorks/osiSock.h +++ b/src/include/os/vxWorks/osiSock.h @@ -28,7 +28,7 @@ extern "C" { typedef int SOCKET; #define INVALID_SOCKET (-1) #define SOCKERRNO errno -#define SOCKERRSTR (strerror(SOCKERRNO)) +#define SOCKERRSTR(ERRNO_IN) (strerror(ERRNO_IN)) #define socket_close(S) close(S) /* * it is quite lame on WRS's part to assume that diff --git a/src/include/osiMutexNOOP.h b/src/include/osiMutexNOOP.h index a4dc92826..3c87e03a0 100644 --- a/src/include/osiMutexNOOP.h +++ b/src/include/osiMutexNOOP.h @@ -13,14 +13,10 @@ // class osiMutex { public: - // - // constructor that returns status - // (since g++ does not have exceptions) - // - int init() {return 0;} - void osiLock() const {} - void osiUnlock() const {} - void show (unsigned) const {} + class osiMutexNoMemory {}; + void lock () const {} + void unlock () const {} + void show (unsigned) const {} private: }; diff --git a/src/libCom/osi/os/Linux/osdSock.h b/src/libCom/osi/os/Linux/osdSock.h index 85d44bd78..538d25346 100644 --- a/src/libCom/osi/os/Linux/osdSock.h +++ b/src/libCom/osi/os/Linux/osdSock.h @@ -43,7 +43,7 @@ extern "C" { #endif typedef int SOCKET; -#define INVALID_SOCKET (-1) +#define INVALID_SOCKET (-1) #define SOCKERRNO errno #define socket_close(S) close(S) #define socket_ioctl(A,B,C) ioctl(A,B,C) @@ -51,7 +51,7 @@ typedef int osiSockIoctl_t; #define FD_IN_FDSET(FD) ((FD)