changeset e4001326a5ba in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=e4001326a5ba
description:
        MAC: Make gem5 compile and run on MacOSX 10.7.2

        Adaptations to make gem5 compile and run on OSX 10.7.2, with a stock
        gcc 4.2.1 and the remaining dependencies from macports, i.e. python
        2.7,.2 swig 2.0.4, mercurial 2.0. The changes include an adaptation of
        the SConstruct to handle non-library linker flags, and Darwin-specific
        code to find the memory usage of gem5. A number of Ruby files relied
        on ambigious uint (without the 32 suffix) which caused compilation
        errors.

diffstat:

 SConstruct                                             |  12 ++++--
 ext/libelf/SConscript                                  |   2 +-
 src/base/hostinfo.cc                                   |  32 +++++++++++++++++-
 src/base/hostinfo.hh                                   |   8 +++-
 src/cpu/testers/directedtest/DirectedGenerator.hh      |   2 +-
 src/cpu/testers/directedtest/InvalidateGenerator.cc    |   2 +-
 src/cpu/testers/directedtest/InvalidateGenerator.hh    |   8 ++--
 src/cpu/testers/directedtest/RubyDirectedTester.hh     |   4 +-
 src/cpu/testers/directedtest/SeriesRequestGenerator.cc |   2 +-
 src/cpu/testers/directedtest/SeriesRequestGenerator.hh |   6 +-
 10 files changed, 58 insertions(+), 20 deletions(-)

diffs (195 lines):

diff -r 93c6317af258 -r e4001326a5ba SConstruct
--- a/SConstruct        Sat Jan 07 07:40:44 2012 -0600
+++ b/SConstruct        Mon Jan 09 18:08:20 2012 -0600
@@ -663,10 +663,14 @@
 
 py_libs = []
 for lib in py_getvar('LIBS').split() + py_getvar('SYSLIBS').split():
-    assert lib.startswith('-l')
-    lib = lib[2:]   
-    if lib not in py_libs:
-        py_libs.append(lib)
+    if not lib.startswith('-l'):
+        # Python requires some special flags to link (e.g. -framework
+        # common on OS X systems), assume appending preserves order
+        main.Append(LINKFLAGS=[lib])
+    else:
+        lib = lib[2:]
+        if lib not in py_libs:
+            py_libs.append(lib)
 py_libs.append(py_version)
 
 main.Append(CPPPATH=py_includes)
diff -r 93c6317af258 -r e4001326a5ba ext/libelf/SConscript
--- a/ext/libelf/SConscript     Sat Jan 07 07:40:44 2012 -0600
+++ b/ext/libelf/SConscript     Mon Jan 09 18:08:20 2012 -0600
@@ -91,7 +91,7 @@
 
 m4env = main.Clone()
 if m4env['GCC']:
-    major,minor,dot = [ int(x) for x in m4env['CXXVERSION'].split('.')]
+    major,minor,dot = [int(x) for x in m4env['GCC_VERSION'].split('.')]
     if major >= 4:
         m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
 m4env.Append(CCFLAGS=['-Wno-implicit'])
diff -r 93c6317af258 -r e4001326a5ba src/base/hostinfo.cc
--- a/src/base/hostinfo.cc      Sat Jan 07 07:40:44 2012 -0600
+++ b/src/base/hostinfo.cc      Mon Jan 09 18:08:20 2012 -0600
@@ -30,6 +30,12 @@
 
 #include <unistd.h>
 
+#ifdef __APPLE__
+#include <mach/mach_init.h>
+#include <mach/shared_region.h>
+#include <mach/task.h>
+#endif
+
 #include <cctype>
 #include <cerrno>
 #include <cmath>
@@ -82,7 +88,31 @@
     }
 
     if (fp)
-      fclose(fp);
+        fclose(fp);
 
     return 0;
 }
+
+uint64_t
+memUsage()
+{
+// For the Mach-based Darwin kernel, use the task_info of the self task
+#ifdef __APPLE__
+    struct task_basic_info t_info;
+    mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
+
+    if (KERN_SUCCESS != task_info(mach_task_self(),
+                                  TASK_BASIC_INFO, (task_info_t)&t_info,
+                                  &t_info_count)) {
+        return 0;
+    }
+
+    // Mimic Darwin's implementation of top and subtract
+    // SHARED_REGION_SIZE from the tasks virtual size to account for the
+    // shared memory submap that is incorporated into every process.
+    return (t_info.virtual_size - SHARED_REGION_SIZE) / 1024;
+#else
+    // Linux implementation
+    return procInfo("/proc/self/status", "VmSize:");
+#endif
+}
diff -r 93c6317af258 -r e4001326a5ba src/base/hostinfo.hh
--- a/src/base/hostinfo.hh      Sat Jan 07 07:40:44 2012 -0600
+++ b/src/base/hostinfo.hh      Mon Jan 09 18:08:20 2012 -0600
@@ -39,7 +39,11 @@
 
 uint64_t procInfo(const char *filename, const char *target);
 
-inline uint64_t memUsage()
-{ return procInfo("/proc/self/status", "VmSize:"); }
+/**
+ * Determine the simulator process' total virtual memory usage.
+ *
+ * @return virtual memory usage in kilobytes
+ */
+uint64_t memUsage();
 
 #endif // __HOSTINFO_HH__
diff -r 93c6317af258 -r e4001326a5ba 
src/cpu/testers/directedtest/DirectedGenerator.hh
--- a/src/cpu/testers/directedtest/DirectedGenerator.hh Sat Jan 07 07:40:44 
2012 -0600
+++ b/src/cpu/testers/directedtest/DirectedGenerator.hh Mon Jan 09 18:08:20 
2012 -0600
@@ -43,7 +43,7 @@
     virtual ~DirectedGenerator() {}
     
     virtual bool initiate() = 0;
-    virtual void performCallback(uint proc, Addr address) = 0;
+    virtual void performCallback(uint32_t proc, Addr address) = 0;
     
     void setDirectedTester(RubyDirectedTester* directed_tester);
     
diff -r 93c6317af258 -r e4001326a5ba 
src/cpu/testers/directedtest/InvalidateGenerator.cc
--- a/src/cpu/testers/directedtest/InvalidateGenerator.cc       Sat Jan 07 
07:40:44 2012 -0600
+++ b/src/cpu/testers/directedtest/InvalidateGenerator.cc       Mon Jan 09 
18:08:20 2012 -0600
@@ -103,7 +103,7 @@
 }
 
 void 
-InvalidateGenerator::performCallback(uint proc, Addr address)
+InvalidateGenerator::performCallback(uint32_t proc, Addr address)
 {
     assert(m_address == address);  
 
diff -r 93c6317af258 -r e4001326a5ba 
src/cpu/testers/directedtest/InvalidateGenerator.hh
--- a/src/cpu/testers/directedtest/InvalidateGenerator.hh       Sat Jan 07 
07:40:44 2012 -0600
+++ b/src/cpu/testers/directedtest/InvalidateGenerator.hh       Mon Jan 09 
18:08:20 2012 -0600
@@ -49,14 +49,14 @@
     ~InvalidateGenerator();
     
     bool initiate();
-    void performCallback(uint proc, Addr address);
+    void performCallback(uint32_t proc, Addr address);
     
   private:
     InvalidateGeneratorStatus m_status;
     Addr m_address;
-    uint m_active_read_node;
-    uint m_active_inv_node;
-    uint m_addr_increment_size;
+    uint32_t m_active_read_node;
+    uint32_t m_active_inv_node;
+    uint32_t m_addr_increment_size;
 };
 
 #endif //__CPU_DIRECTEDTEST_INVALIDATEGENERATOR_HH__
diff -r 93c6317af258 -r e4001326a5ba 
src/cpu/testers/directedtest/RubyDirectedTester.hh
--- a/src/cpu/testers/directedtest/RubyDirectedTester.hh        Sat Jan 07 
07:40:44 2012 -0600
+++ b/src/cpu/testers/directedtest/RubyDirectedTester.hh        Mon Jan 09 
18:08:20 2012 -0600
@@ -53,11 +53,11 @@
         RubyDirectedTester *tester;
 
       public:
-        CpuPort(const std::string &_name, RubyDirectedTester *_tester, uint 
_idx)
+        CpuPort(const std::string &_name, RubyDirectedTester *_tester, 
uint32_t _idx)
             : SimpleTimingPort(_name, _tester), tester(_tester), idx(_idx)
         {}
 
-        uint idx;
+        uint32_t idx;
 
       protected:
         virtual bool recvTiming(PacketPtr pkt);
diff -r 93c6317af258 -r e4001326a5ba 
src/cpu/testers/directedtest/SeriesRequestGenerator.cc
--- a/src/cpu/testers/directedtest/SeriesRequestGenerator.cc    Sat Jan 07 
07:40:44 2012 -0600
+++ b/src/cpu/testers/directedtest/SeriesRequestGenerator.cc    Mon Jan 09 
18:08:20 2012 -0600
@@ -89,7 +89,7 @@
 }
 
 void 
-SeriesRequestGenerator::performCallback(uint proc, Addr address)
+SeriesRequestGenerator::performCallback(uint32_t proc, Addr address)
 {
     assert(m_active_node == proc);
     assert(m_address == address);  
diff -r 93c6317af258 -r e4001326a5ba 
src/cpu/testers/directedtest/SeriesRequestGenerator.hh
--- a/src/cpu/testers/directedtest/SeriesRequestGenerator.hh    Sat Jan 07 
07:40:44 2012 -0600
+++ b/src/cpu/testers/directedtest/SeriesRequestGenerator.hh    Mon Jan 09 
18:08:20 2012 -0600
@@ -49,13 +49,13 @@
     ~SeriesRequestGenerator();
     
     bool initiate();
-    void performCallback(uint proc, Addr address);
+    void performCallback(uint32_t proc, Addr address);
     
   private:
     SeriesRequestGeneratorStatus m_status;
     Addr m_address;
-    uint m_active_node;
-    uint m_addr_increment_size;
+    uint32_t m_active_node;
+    uint32_t m_addr_increment_size;
     bool m_issue_writes;
 };
 
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to