From cc23cf46531c8e00cfd2d84f995b5def2ec10e00 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sat, 27 Jun 2009 02:19:37 +0400 Subject: [PATCH] [8080] Portability fixes for some Unix platforms. * Add #include to some fiels where related functions call. * Avoid template dependent lookup for fields in class LockedQueue. --- dep/src/sockets/SocketHandler.cpp | 1 + dep/src/sockets/StdoutLog.cpp | 2 + dep/src/sockets/TcpSocket.cpp | 1 + src/shared/LockedQueue.h | 53 ++++++++++----------------- src/shared/revision_nr.h | 2 +- src/shared/vmap/CoordModelMapping.cpp | 8 ++++ src/shared/vmap/CoordModelMapping.h | 7 +--- src/shared/vmap/DebugCmdLogger.cpp | 1 + 8 files changed, 34 insertions(+), 41 deletions(-) diff --git a/dep/src/sockets/SocketHandler.cpp b/dep/src/sockets/SocketHandler.cpp index 9ec5412af..f2a4f7c30 100644 --- a/dep/src/sockets/SocketHandler.cpp +++ b/dep/src/sockets/SocketHandler.cpp @@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #endif #include +#include #include #include "SocketHandler.h" diff --git a/dep/src/sockets/StdoutLog.cpp b/dep/src/sockets/StdoutLog.cpp index c01d8b8c2..f9251c326 100644 --- a/dep/src/sockets/StdoutLog.cpp +++ b/dep/src/sockets/StdoutLog.cpp @@ -27,6 +27,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #ifdef _MSC_VER #pragma warning(disable:4786) #endif diff --git a/dep/src/sockets/TcpSocket.cpp b/dep/src/sockets/TcpSocket.cpp index 36df37d58..64bb1009e 100644 --- a/dep/src/sockets/TcpSocket.cpp +++ b/dep/src/sockets/TcpSocket.cpp @@ -39,6 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #ifdef HAVE_OPENSSL #include #include diff --git a/src/shared/LockedQueue.h b/src/shared/LockedQueue.h index 5109b1716..4087ebff0 100644 --- a/src/shared/LockedQueue.h +++ b/src/shared/LockedQueue.h @@ -27,11 +27,9 @@ namespace ACE_Based { - template > class LockedQueue { - //! Serialize access to the Queue LockType _lock; @@ -54,14 +52,12 @@ namespace ACE_Based */ void add(const T& item) { + ACE_Guard g(this->_lock); - ACE_Guard g(_lock); - - ASSERT(!_canceled); + ASSERT(!this->_canceled); // throw Cancellation_Exception(); - _queue.push_back(item); - + this->_queue.push_back(item); } /** @@ -69,27 +65,25 @@ namespace ACE_Based */ T next() { + ACE_Guard g(this->_lock); - ACE_Guard g(_lock); - - ASSERT (!_queue.empty() || !_canceled); + ASSERT (!_queue.empty() || !this->_canceled); // throw Cancellation_Exception(); - T item = _queue.front(); - _queue.pop_front(); + T item = this->_queue.front(); + this->_queue.pop_front(); return item; - } T front() { - ACE_Guard g(_lock); + ACE_Guard g(this->_lock); - ASSERT (!_queue.empty()); + ASSERT (!this->_queue.empty()); // throw NoSuchElement_Exception(); - return _queue.front(); + return this->_queue.front(); } /** @@ -97,11 +91,9 @@ namespace ACE_Based */ void cancel() { + ACE_Guard g(this->_lock); - ACE_Guard g(_lock); - - _canceled = true; - + this->_canceled = true; } /** @@ -109,15 +101,13 @@ namespace ACE_Based */ bool isCanceled() { - // Faster check since the queue will not become un-canceled - if(_canceled) + if(this->_canceled) return true; - ACE_Guard g(_lock); - - return _canceled; + ACE_Guard g(this->_lock); + return this->_canceled; } /** @@ -125,20 +115,15 @@ namespace ACE_Based */ size_t size() { - - ACE_Guard g(_lock); - return _queue.size(); - + ACE_Guard g(this->_lock); + return this->_queue.size(); } bool empty() { - - ACE_Guard g(_lock); - return _queue.empty(); + ACE_Guard g(this->_lock); + return this->_queue.empty(); } - }; - } #endif diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a2a499339..ce69da771 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8079" + #define REVISION_NR "8080" #endif // __REVISION_NR_H__ diff --git a/src/shared/vmap/CoordModelMapping.cpp b/src/shared/vmap/CoordModelMapping.cpp index 23b89fefd..4b4dc50c9 100644 --- a/src/shared/vmap/CoordModelMapping.cpp +++ b/src/shared/vmap/CoordModelMapping.cpp @@ -19,6 +19,7 @@ #include "CoordModelMapping.h" #include +#include using namespace G3D; @@ -42,6 +43,13 @@ namespace VMAP return(CMappingEntry::getKeyString(iMapId,xPos, yPos)); } + const std::string CMappingEntry::getKeyString( unsigned int pMapId, int pXPos, int pYPos ) + { + char b[100]; + sprintf(b,"%03u_%d_%d", pMapId, pXPos, pYPos); + return(std::string(b)); + } + //============================================================ //============================================================ //============================================================ diff --git a/src/shared/vmap/CoordModelMapping.h b/src/shared/vmap/CoordModelMapping.h index 71b516311..0200caaa7 100644 --- a/src/shared/vmap/CoordModelMapping.h +++ b/src/shared/vmap/CoordModelMapping.h @@ -72,12 +72,7 @@ namespace VMAP const std::string getKeyString() const; inline const G3D::Array& getFilenames() const { return(iFilenames); } - static const std::string getKeyString(unsigned int pMapId, int pXPos, int pYPos) - { - char b[100]; - sprintf(b,"%03u_%d_%d", pMapId, pXPos, pYPos); - return(std::string(b)); - } + static const std::string getKeyString(unsigned int pMapId, int pXPos, int pYPos); }; diff --git a/src/shared/vmap/DebugCmdLogger.cpp b/src/shared/vmap/DebugCmdLogger.cpp index 080afa3fb..036149977 100644 --- a/src/shared/vmap/DebugCmdLogger.cpp +++ b/src/shared/vmap/DebugCmdLogger.cpp @@ -17,6 +17,7 @@ */ #include "DebugCmdLogger.h" +#include using namespace G3D;