Browse Source

Added a precise and consistent tick() function for freebsd (see bugreport:240)
(TODO: apply it to multiple platforms using an appropriate configure script)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11912 54d463be-8e91-2dee-dedb-b68131a5f0ec

ultramage 17 years ago
parent
commit
a772e3699d
2 changed files with 6 additions and 1 deletions
  1. 1 0
      Changelog-Trunk.txt
  2. 5 1
      src/common/timer.c

+ 1 - 0
Changelog-Trunk.txt

@@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
 2007/12/14
 2007/12/14
+	* Added a precise and consistent tick() function for freebsd [ultramage]
 	* Wand of Hermode now dispells buffs only of allies.
 	* Wand of Hermode now dispells buffs only of allies.
 	* Fixed some null pointer checks in status_change_end.
 	* Fixed some null pointer checks in status_change_end.
 	* Corrected a crashy Warning message. [Skotlex]
 	* Corrected a crashy Warning message. [Skotlex]

+ 5 - 1
src/common/timer.c

@@ -91,8 +91,12 @@ char* search_timer_func_list(TimerFunc func)
 /// platform-abstracted tick retrieval
 /// platform-abstracted tick retrieval
 static unsigned int tick(void)
 static unsigned int tick(void)
 {
 {
-#ifdef WIN32
+#if defined(WIN32)
 	return GetTickCount();
 	return GetTickCount();
+#elif defined(__FREEBSD__)
+	struct timespec tval;
+	clock_gettime(CLOCK_MONOTONIC, &tval);
+	return tval.tv_sec * 1000 + tval.tv_nsec / 1000000;
 #else
 #else
 	struct timeval tval;
 	struct timeval tval;
 	gettimeofday(&tval, NULL);
 	gettimeofday(&tval, NULL);