[8080] Portability fixes for some Unix platforms.

* Add #include <stdio.h> to some fiels where related functions call.
* Avoid template dependent lookup for fields in class LockedQueue.
This commit is contained in:
VladimirMangos 2009-06-27 02:19:37 +04:00 committed by tomrus88
parent 0a8f9ac6e9
commit cc23cf4653
8 changed files with 34 additions and 41 deletions

View file

@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif #endif
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <errno.h> #include <errno.h>
#include "SocketHandler.h" #include "SocketHandler.h"

View file

@ -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 along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <stdio.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4786) #pragma warning(disable:4786)
#endif #endif

View file

@ -39,6 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <fcntl.h> #include <fcntl.h>
#include <assert.h> #include <assert.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/err.h> #include <openssl/err.h>

View file

@ -27,11 +27,9 @@
namespace ACE_Based namespace ACE_Based
{ {
template <class T, class LockType, typename StorageType=std::deque<T> > template <class T, class LockType, typename StorageType=std::deque<T> >
class LockedQueue class LockedQueue
{ {
//! Serialize access to the Queue //! Serialize access to the Queue
LockType _lock; LockType _lock;
@ -54,14 +52,12 @@ namespace ACE_Based
*/ */
void add(const T& item) void add(const T& item)
{ {
ACE_Guard<LockType> g(this->_lock);
ACE_Guard<LockType> g(_lock); ASSERT(!this->_canceled);
ASSERT(!_canceled);
// throw Cancellation_Exception(); // throw Cancellation_Exception();
_queue.push_back(item); this->_queue.push_back(item);
} }
/** /**
@ -69,27 +65,25 @@ namespace ACE_Based
*/ */
T next() T next()
{ {
ACE_Guard<LockType> g(this->_lock);
ACE_Guard<LockType> g(_lock); ASSERT (!_queue.empty() || !this->_canceled);
ASSERT (!_queue.empty() || !_canceled);
// throw Cancellation_Exception(); // throw Cancellation_Exception();
T item = _queue.front(); T item = this->_queue.front();
_queue.pop_front(); this->_queue.pop_front();
return item; return item;
} }
T front() T front()
{ {
ACE_Guard<LockType> g(_lock); ACE_Guard<LockType> g(this->_lock);
ASSERT (!_queue.empty()); ASSERT (!this->_queue.empty());
// throw NoSuchElement_Exception(); // throw NoSuchElement_Exception();
return _queue.front(); return this->_queue.front();
} }
/** /**
@ -97,11 +91,9 @@ namespace ACE_Based
*/ */
void cancel() void cancel()
{ {
ACE_Guard<LockType> g(this->_lock);
ACE_Guard<LockType> g(_lock); this->_canceled = true;
_canceled = true;
} }
/** /**
@ -109,15 +101,13 @@ namespace ACE_Based
*/ */
bool isCanceled() bool isCanceled()
{ {
// Faster check since the queue will not become un-canceled // Faster check since the queue will not become un-canceled
if(_canceled) if(this->_canceled)
return true; return true;
ACE_Guard<LockType> g(_lock); ACE_Guard<LockType> g(this->_lock);
return _canceled;
return this->_canceled;
} }
/** /**
@ -125,20 +115,15 @@ namespace ACE_Based
*/ */
size_t size() size_t size()
{ {
ACE_Guard<LockType> g(this->_lock);
ACE_Guard<LockType> g(_lock); return this->_queue.size();
return _queue.size();
} }
bool empty() bool empty()
{ {
ACE_Guard<LockType> g(this->_lock);
ACE_Guard<LockType> g(_lock); return this->_queue.empty();
return _queue.empty();
} }
}; };
} }
#endif #endif

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8079" #define REVISION_NR "8080"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__

View file

@ -19,6 +19,7 @@
#include "CoordModelMapping.h" #include "CoordModelMapping.h"
#include <string.h> #include <string.h>
#include <stdio.h>
using namespace G3D; using namespace G3D;
@ -42,6 +43,13 @@ namespace VMAP
return(CMappingEntry::getKeyString(iMapId,xPos, yPos)); 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));
}
//============================================================ //============================================================
//============================================================ //============================================================
//============================================================ //============================================================

View file

@ -72,12 +72,7 @@ namespace VMAP
const std::string getKeyString() const; const std::string getKeyString() const;
inline const G3D::Array<std::string>& getFilenames() const { return(iFilenames); } inline const G3D::Array<std::string>& getFilenames() const { return(iFilenames); }
static const std::string getKeyString(unsigned int pMapId, int pXPos, int pYPos) 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));
}
}; };

View file

@ -17,6 +17,7 @@
*/ */
#include "DebugCmdLogger.h" #include "DebugCmdLogger.h"
#include <stdio.h>
using namespace G3D; using namespace G3D;