blueloveTH 1 tahun lalu
induk
melakukan
3d5a59bd15
2 mengubah file dengan 6 tambahan dan 4 penghapusan
  1. 1 1
      cmake_build.py
  2. 5 3
      src/modules/time.c

+ 1 - 1
cmake_build.py

@@ -31,4 +31,4 @@ elif sys.platform == "darwin":
     shutil.copy("libpocketpy.dylib", "../libpocketpy.dylib")
 else:
     shutil.copy("main", "../main")
-    # shutil.copy("libpocketpy.so", "../libpocketpy.so")
+    shutil.copy("libpocketpy.so", "../libpocketpy.so")

+ 5 - 3
src/modules/time.c

@@ -6,10 +6,12 @@
 
 static bool get_ns(int64_t* out) {
     struct timespec tms;
+#ifdef __ANDROID__
+    clock_gettime(CLOCK_REALTIME, &tms);
+#else
     /* The C11 way */
-    if(!timespec_get(&tms, TIME_UTC)) {
-        return py_exception(tp_OSError, "%s", "timespec_get() failed");
-    }
+    timespec_get(&tms, TIME_UTC);
+#endif
     /* seconds, multiplied with 1 billion */
     int64_t nanos = tms.tv_sec * NANOS_PER_SEC;
     /* Add full nanoseconds */