From ac6467587e864d199377f14281da4641f979a68a Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 5 Jun 2014 02:10:49 +0000 Subject: Revert "Revert "Remove ftime from bionic LP64"" This reverts commit 0921204660b9597de795065d0350a787035ad589. Change-Id: I749af8d7d429cda9f9d09a75bd30df54e6b1dd65 --- libc/bionic/ndk_cruft.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'libc/bionic/ndk_cruft.cpp') 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 @@ extern "C" int getdtablesize() { 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 -- cgit v1.1