You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2017/02/06 20:07:18 UTC

[5/7] mesos git commit: Introduced an `os::lseek` abstraction in stout.

Introduced an `os::lseek` abstraction in stout.

Review: https://reviews.apache.org/r/54592


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e0a2b0bc
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e0a2b0bc
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e0a2b0bc

Branch: refs/heads/master
Commit: e0a2b0bc36b5f6aae77dc570470d2d4291569ded
Parents: 4ebff5c
Author: Michael Park <mp...@apache.org>
Authored: Thu Dec 8 11:02:39 2016 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Mon Feb 6 11:54:51 2017 -0800

----------------------------------------------------------------------
 3rdparty/stout/include/Makefile.am        |  1 +
 3rdparty/stout/include/stout/os.hpp       |  1 +
 3rdparty/stout/include/stout/os/lseek.hpp | 44 ++++++++++++++++++++++++++
 3 files changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e0a2b0bc/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/Makefile.am b/3rdparty/stout/include/Makefile.am
index b9bf4eb..18f4cd1 100644
--- a/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/stout/include/Makefile.am
@@ -81,6 +81,7 @@ nobase_include_HEADERS =			\
   stout/os/killtree.hpp				\
   stout/os/linux.hpp				\
   stout/os/ls.hpp				\
+  stout/os/lseek.hpp				\
   stout/os/mkdir.hpp				\
   stout/os/mkdtemp.hpp				\
   stout/os/mktemp.hpp				\

http://git-wip-us.apache.org/repos/asf/mesos/blob/e0a2b0bc/3rdparty/stout/include/stout/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os.hpp b/3rdparty/stout/include/stout/os.hpp
index acacaed..fd2db09 100644
--- a/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/stout/include/stout/os.hpp
@@ -53,6 +53,7 @@
 #include <stout/os/getenv.hpp>
 #include <stout/os/kill.hpp>
 #include <stout/os/ls.hpp>
+#include <stout/os/lseek.hpp>
 #include <stout/os/mkdir.hpp>
 #include <stout/os/mkdtemp.hpp>
 #include <stout/os/mktemp.hpp>

http://git-wip-us.apache.org/repos/asf/mesos/blob/e0a2b0bc/3rdparty/stout/include/stout/os/lseek.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/lseek.hpp b/3rdparty/stout/include/stout/os/lseek.hpp
new file mode 100644
index 0000000..77fe272
--- /dev/null
+++ b/3rdparty/stout/include/stout/os/lseek.hpp
@@ -0,0 +1,44 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_LSEEK_HPP__
+#define __STOUT_OS_LSEEK_HPP__
+
+#ifdef __WINDOWS__
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+#include <stout/error.hpp>
+#include <stout/try.hpp>
+
+#include <stout/os/int_fd.hpp>
+
+namespace os {
+
+inline Try<off_t> lseek(int_fd fd, off_t offset, int whence)
+{
+#ifdef __WINDOWS__
+  off_t result = ::_lseek(fd.crt(), offset, whence);
+#else
+  off_t result = ::lseek(fd, offset, whence);
+#endif
+  if (result < 0) {
+    return ErrnoError();
+  }
+  return result;
+}
+
+} // namespace os {
+
+#endif // __STOUT_OS_LSEEK_HPP__