Revert "Revert "Remove ftime from bionic LP64""

This reverts commit 0921204660b9597de795065d0350a787035ad589.

Change-Id: I749af8d7d429cda9f9d09a75bd30df54e6b1dd65
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index 43078fd..1ae388b 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -266,4 +266,34 @@
   return r.rlim_cur;
 }
 
+// Only used by ftime, which was removed from POSIX.
+struct timeb {
+  time_t          time;
+  unsigned short  millitm;
+  short           timezone;
+  short           dstflag;
+};
+
+// This was removed from POSIX 2008.
+extern "C" int ftime(struct timeb* tb) {
+  struct timeval  tv;
+  struct timezone tz;
+
+  if (gettimeofday(&tv, &tz) < 0)
+    return -1;
+
+  tb->time    = tv.tv_sec;
+  tb->millitm = (tv.tv_usec + 500) / 1000;
+
+  if (tb->millitm == 1000) {
+    ++tb->time;
+    tb->millitm = 0;
+  }
+
+  tb->timezone = tz.tz_minuteswest;
+  tb->dstflag  = tz.tz_dsttime;
+
+  return 0;
+}
+
 #endif