mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[10694] Use portable ACE way msecs time value calculation
Avoid use unsafe code for non-Windows platforms Thanks to Marik for research the problem and Ambal for helping me with this patch
This commit is contained in:
parent
e9869e7470
commit
bb3663d94f
2 changed files with 5 additions and 22 deletions
|
|
@ -19,31 +19,14 @@
|
||||||
#ifndef MANGOS_TIMER_H
|
#ifndef MANGOS_TIMER_H
|
||||||
#define MANGOS_TIMER_H
|
#define MANGOS_TIMER_H
|
||||||
|
|
||||||
#include "Platform/CompilerDefs.h"
|
#include "Common.h"
|
||||||
|
#include <ace/OS_NS_sys_time.h>
|
||||||
|
|
||||||
#if PLATFORM == PLATFORM_WINDOWS
|
|
||||||
# include <ace/config-all.h>
|
|
||||||
# include <mmsystem.h>
|
|
||||||
# include <time.h>
|
|
||||||
#else
|
|
||||||
# if defined(__APPLE_CC__)
|
|
||||||
# include <time.h>
|
|
||||||
# endif
|
|
||||||
# include <sys/time.h>
|
|
||||||
# include <sys/timeb.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if PLATFORM == PLATFORM_WINDOWS
|
|
||||||
inline uint32 getMSTime() { return GetTickCount(); }
|
|
||||||
#else
|
|
||||||
inline uint32 getMSTime()
|
inline uint32 getMSTime()
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
static const ACE_Time_Value ApplicationStartTime = ACE_OS::gettimeofday();
|
||||||
struct timezone tz;
|
return (ACE_OS::gettimeofday() - ApplicationStartTime).msec();
|
||||||
gettimeofday( &tv, &tz );
|
|
||||||
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
|
inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10693"
|
#define REVISION_NR "10694"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue