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 2012/12/20 19:34:40 UTC

svn commit: r1424624 - in /incubator/mesos/trunk/src: linux/proc.hpp tests/cgroups_isolation_tests.cpp

Author: benh
Date: Thu Dec 20 18:34:40 2012
New Revision: 1424624

URL: http://svn.apache.org/viewvc?rev=1424624&view=rev
Log:
Fixed compilation issues with GCC 4.4.3.

From: Ben Mahler <be...@gmail.com>
Review: https://reviews.apache.org/r/8415

Modified:
    incubator/mesos/trunk/src/linux/proc.hpp
    incubator/mesos/trunk/src/tests/cgroups_isolation_tests.cpp

Modified: incubator/mesos/trunk/src/linux/proc.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/linux/proc.hpp?rev=1424624&r1=1424623&r2=1424624&view=diff
==============================================================================
--- incubator/mesos/trunk/src/linux/proc.hpp (original)
+++ incubator/mesos/trunk/src/linux/proc.hpp Thu Dec 20 18:34:40 2012
@@ -57,27 +57,6 @@ struct CPU
   CPU(unsigned int _id, unsigned int _core, unsigned int _socket)
     : id(_id), core(_core), socket(_socket) {}
 
-  bool operator == (const CPU& that) const
-  {
-    return (id == that.id) && (core == that.core) && (socket == that.socket);
-  }
-
-  bool operator < (const CPU& that) const
-  {
-    // Sort by (socket, core, id).
-    if (socket != that.socket) {
-      return socket < that.socket;
-    }
-
-    // On the same socket.
-    if (core != that.core) {
-      return core < that.core;
-    }
-
-    // On the same core.
-    return id < that.id;
-  }
-
   // These are non-const because we need the default assignment operator.
   unsigned int id; // "processor"
   unsigned int core; // "core id"
@@ -85,6 +64,30 @@ struct CPU
 };
 
 
+inline bool operator == (const CPU& lhs, const CPU& rhs)
+{
+  return (lhs.id == rhs.id) && (lhs.core == rhs.core) &&
+    (lhs.socket == rhs.socket);
+}
+
+
+inline bool operator < (const CPU& lhs, const CPU& rhs)
+{
+  // Sort by (socket, core, id).
+  if (lhs.socket != rhs.socket) {
+    return lhs.socket < rhs.socket;
+  }
+
+  // On the same socket.
+  if (lhs.core != rhs.core) {
+    return lhs.core < rhs.core;
+  }
+
+  // On the same core.
+  return lhs.id < rhs.id;
+}
+
+
 inline std::ostream& operator << (std::ostream& out, const CPU& cpu)
 {
   return out << "CPU (id:" << cpu.id << ", "

Modified: incubator/mesos/trunk/src/tests/cgroups_isolation_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/cgroups_isolation_tests.cpp?rev=1424624&r1=1424623&r2=1424624&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/cgroups_isolation_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/cgroups_isolation_tests.cpp Thu Dec 20 18:34:40 2012
@@ -17,6 +17,7 @@
  */
 
 #include <map>
+#include <utility>
 
 #include <gtest/gtest.h>
 
@@ -66,7 +67,8 @@ TEST(CgroupsCpusetTest, OneCPUOneCpuset)
   Cpuset cpuset;
 
   map<proc::CPU, double> usage;
-  usage[proc::CPU(0,0,0)] = 0.0;
+  // NOTE: Using the [] operator here led to a warning with gcc 4.4.3.
+  usage.insert(std::make_pair(proc::CPU(0, 0, 0), 0.0));
 
   // Saturate the CPU.
   GROW_USAGE(0.2, cpuset, usage);
@@ -97,7 +99,8 @@ TEST(CgroupsCpusetTest, OneCPUManyCpuset
   Cpuset cpuset1, cpuset2, cpuset3;
 
   map<proc::CPU, double> usage;
-  usage[proc::CPU(0,0,0)] = 0.0;
+  // NOTE: Using the [] operator here led to a warning with gcc 4.4.3.
+  usage.insert(std::make_pair(proc::CPU(0, 0, 0), 0.0));
 
   // Saturate the CPU.
   GROW_USAGE(0.2, cpuset1, usage);
@@ -136,9 +139,10 @@ TEST(CgroupsCpusetTest, ManyCPUOneCpuset
   Cpuset cpuset;
 
   map<proc::CPU, double> usage;
-  usage[proc::CPU(0,0,0)] = 0.0;
-  usage[proc::CPU(1,0,0)] = 0.0;
-  usage[proc::CPU(2,0,0)] = 0.0;
+  // NOTE: Using the [] operator here led to a warning with gcc 4.4.3.
+  usage.insert(std::make_pair(proc::CPU(0, 0, 0), 0.0));
+  usage.insert(std::make_pair(proc::CPU(1, 0, 0), 0.0));
+  usage.insert(std::make_pair(proc::CPU(2, 0, 0), 0.0));
 
   // Saturate the first CPU.
   GROW_USAGE(0.2, cpuset, usage);
@@ -190,9 +194,10 @@ TEST(CgroupsCpusetTest, ManyCPUManyCpuse
   Cpuset cpuset1, cpuset2, cpuset3;
 
   map<proc::CPU, double> usage;
-  usage[proc::CPU(0,0,0)] = 0.0;
-  usage[proc::CPU(1,0,0)] = 0.0;
-  usage[proc::CPU(2,0,0)] = 0.0;
+  // NOTE: Using the [] operator here led to a warning with gcc 4.4.3.
+  usage.insert(std::make_pair(proc::CPU(0, 0, 0), 0.0));
+  usage.insert(std::make_pair(proc::CPU(1, 0, 0), 0.0));
+  usage.insert(std::make_pair(proc::CPU(2, 0, 0), 0.0));
 
   // Saturate the first CPU.
   GROW_USAGE(0.2, cpuset1, usage);
@@ -258,10 +263,11 @@ TEST(CgroupsCpusetTest, IntegerAllocatio
   Cpuset cpuset1, cpuset2, cpuset3;
 
   map<proc::CPU, double> usage;
-  usage[proc::CPU(0,0,0)] = 0.0;
-  usage[proc::CPU(1,0,0)] = 0.0;
-  usage[proc::CPU(2,0,0)] = 0.0;
-  usage[proc::CPU(3,0,0)] = 0.0;
+  // NOTE: Using the [] operator here led to a warning with gcc 4.4.3.
+  usage.insert(std::make_pair(proc::CPU(0, 0, 0), 0.0));
+  usage.insert(std::make_pair(proc::CPU(1, 0, 0), 0.0));
+  usage.insert(std::make_pair(proc::CPU(2, 0, 0), 0.0));
+  usage.insert(std::make_pair(proc::CPU(3, 0, 0), 0.0));
 
   // Saturate the CPUs.
   GROW_USAGE(1.0, cpuset1, usage);