Ver código fonte

[osx] Don't use deprecated Microseconds().

woollybah 10 anos atrás
pai
commit
065ddd13e4
1 arquivos alterados com 10 adições e 6 exclusões
  1. 10 6
      blitz.mod/blitz_app.c

+ 10 - 6
blitz.mod/blitz_app.c

@@ -65,6 +65,8 @@ BBString *bbReadStdin(){
 
 #include <CoreFoundation/CoreFoundation.h>
 
+#include <mach/mach_time.h>
+
 #include <limits.h>
 #include <unistd.h>
 #include <pthread.h>
@@ -81,14 +83,16 @@ void bbDelay( int millis ){
 }
 
 int bbMilliSecs(){
-	double t;
-	UnsignedWide uw;
-	Microseconds( &uw );
-	t=(uw.hi<<(32-9))|(uw.lo>>9);	//divide by 512...!
-	
-	return (int) (long long) ( t/(1000.0/512.0) );
+	static mach_timebase_info_data_t info;
+
+	if (info.denom == 0) {
+		mach_timebase_info(&info);
+	}
+
+	return (int)((mach_absolute_time() * info.numer) / ((1000 * 1000) * info.denom));
 }
 
+
 int bbIsMainThread(){
 	return pthread_self()==_mainThread;
 }