You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2014/01/17 02:37:54 UTC

[2/2] git commit: Added UNREACHABLE to stout.

Added UNREACHABLE to stout.

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


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

Branch: refs/heads/master
Commit: 2a04b9226eb858371bb8273918db6c2dac06dcd6
Parents: 420e30b
Author: Benjamin Hindman <be...@gmail.com>
Authored: Wed Jan 15 17:22:30 2014 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Thu Jan 16 17:32:34 2014 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/stout/Makefile.am  |  1 +
 .../stout/include/stout/unreachable.hpp         | 44 ++++++++++++++++++++
 2 files changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2a04b922/3rdparty/libprocess/3rdparty/stout/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/Makefile.am b/3rdparty/libprocess/3rdparty/stout/Makefile.am
index 0725722..d83ad25 100644
--- a/3rdparty/libprocess/3rdparty/stout/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/Makefile.am
@@ -61,6 +61,7 @@ EXTRA_DIST =					\
   include/stout/strings.hpp			\
   include/stout/thread.hpp			\
   include/stout/try.hpp				\
+  include/stout/unreachable.hpp			\
   include/stout/utils.hpp			\
   include/stout/uuid.hpp			\
   tests/bytes_tests.cpp				\

http://git-wip-us.apache.org/repos/asf/mesos/blob/2a04b922/3rdparty/libprocess/3rdparty/stout/include/stout/unreachable.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/unreachable.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/unreachable.hpp
new file mode 100644
index 0000000..3568886
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/unreachable.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_UNREACHABLE_HPP__
+#define __STOUT_UNREACHABLE_HPP__
+
+#include <iostream>
+
+#define UNREACHABLE() Unreachable(__FILE__, __LINE__)
+
+struct Unreachable
+{
+  Unreachable(const std::string& _file, int _line)
+    : file(_file), line(_line) {}
+
+  template <typename T>
+  operator T () const
+  {
+    // TODO(benh): Print stack trace too.
+    std::cerr << "Reached unreachable statement at "
+              << file << ":" << line << std::endl;
+    abort();
+
+    // Note that dereference a T* since T might not be default
+    // constructable and can't just 'return T()'.
+    return *((T*) NULL);
+  }
+
+private:
+  const std::string file;
+  const int line;
+};
+
+#endif // __STOUT_UNREACHABLE_HPP__