diff options
author | Dan Albert <danalbert@google.com> | 2014-06-05 02:10:49 +0000 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2014-06-16 12:32:38 -0700 |
commit | ac6467587e864d199377f14281da4641f979a68a (patch) | |
tree | 138acbcc6c8d89da231342e9698de1a0b08580cd /libc/bionic/ndk_cruft.cpp | |
parent | 9a3ad98fd69a276f7c5fca0489d5657be75fcf69 (diff) | |
download | bionic-ac6467587e864d199377f14281da4641f979a68a.zip bionic-ac6467587e864d199377f14281da4641f979a68a.tar.gz bionic-ac6467587e864d199377f14281da4641f979a68a.tar.bz2 |
Revert "Revert "Remove ftime from bionic LP64""
This reverts commit 0921204660b9597de795065d0350a787035ad589.
Change-Id: I749af8d7d429cda9f9d09a75bd30df54e6b1dd65
Diffstat (limited to 'libc/bionic/ndk_cruft.cpp')
-rw-r--r-- | libc/bionic/ndk_cruft.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
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 |