]> git.cworth.org Git - apitrace/blobdiff - common/os_posix.cpp
Add support for android logging to logcat
[apitrace] / common / os_posix.cpp
index e6af7383f35b6a78b4efad1fcf1339bb8a3f5531..ebd59a097076d05fe6b3eadf4c2ffae57a78547d 100644 (file)
@@ -30,7 +30,6 @@
 #include <stdlib.h>
 
 #include <unistd.h>
-#include <sys/time.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <mach-o/dyld.h>
 #endif
 
+#ifdef ANDROID
+#include <android/log.h>
+#endif
+
 #ifndef PATH_MAX
 #warning PATH_MAX undefined
 #define PATH_MAX 4096
@@ -154,18 +157,18 @@ log(const char *format, ...)
     va_list ap;
     va_start(ap, format);
     fflush(stdout);
+#ifdef ANDROID
+    __android_log_vprint(ANDROID_LOG_DEBUG, "apitrace", format, ap);
+#else
     vfprintf(stderr, format, ap);
+#endif
     va_end(ap);
     logging = false;
 }
 
-long long
-getTime(void)
-{
-    struct timeval tv;
-    gettimeofday(&tv, NULL);
-    return tv.tv_usec + tv.tv_sec*1000000LL;
-}
+#if defined(__APPLE__)
+long long timeFrequency = 0LL;
+#endif
 
 void
 abort(void)