Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1732)

Unified Diff: native_client_sdk/src/libraries/nacl_io/event_listener.cc

Issue 73083005: [NaCl SDK] Enable linux host build for nacl_io and nacl_io_tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/nacl_io/event_listener.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/event_listener.cc b/native_client_sdk/src/libraries/nacl_io/event_listener.cc
index 8ad13bd5b31fcb976e5be223756c89bb5d19d407..ea8712897ada1148ee8cd0af1d0634a45b3c0f19 100644
--- a/native_client_sdk/src/libraries/nacl_io/event_listener.cc
+++ b/native_client_sdk/src/libraries/nacl_io/event_listener.cc
@@ -1,21 +1,46 @@
-/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#include <errno.h>
#include <poll.h>
#include <pthread.h>
#include <stdio.h>
+#include <sys/time.h>
#include "nacl_io/error.h"
#include "nacl_io/event_listener.h"
#include "nacl_io/kernel_wrap.h"
#include "nacl_io/osstat.h"
+#include "nacl_io/ostime.h"
#include "nacl_io/osunistd.h"
#include "sdk_util/auto_lock.h"
+#if defined(WIN32)
+
+#define USECS_FROM_WIN_TO_TO_UNIX_EPOCH 11644473600000LL
+static uint64_t usec_since_epoch() {
+ FILETIME ft;
+ ULARGE_INTEGER ularge;
+ GetSystemTimeAsFileTime(&ft);
+
+ ularge.LowPart = ft.dwLowDateTime;
+ ularge.HighPart = ft.dwHighDateTime;
+
+ // Truncate to usec resolution.
+ return ularge.QuadPart / 10;
+}
+
+#else
+
+static uint64_t usec_since_epoch() {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return tv.tv_usec + (tv.tv_sec * 1000000);
+}
+
+#endif
namespace nacl_io {
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/event_emitter.cc ('k') | native_client_sdk/src/libraries/nacl_io/fifo_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698