diff options
author | Steve Reinhardt <stever@eecs.umich.edu> | 2004-08-05 02:03:47 -0700 |
---|---|---|
committer | Steve Reinhardt <stever@eecs.umich.edu> | 2004-08-05 02:03:47 -0700 |
commit | d7dfe51faed84ba2b06c32a302597c0226ea239c (patch) | |
tree | 52898afd02df6502cc35b75510eb48930df277fb /base | |
parent | 1939370c96b48a1f635799b6017d5f5f11799353 (diff) | |
download | gem5-d7dfe51faed84ba2b06c32a302597c0226ea239c.tar.xz |
Integrate Python configuration script parsing into m5 itself.
SConscript:
Add pyconfig/{pyconfig,code}.cc
Add list of object description (.od) files.
Include pyconfig/SConscript.
base/inifile.cc:
Get rid of CPP_PIPE... it never really worked anyway.
base/inifile.hh:
Make load(ifstream&) method public so pyconfig
code can call it.
sim/main.cc:
Handle Python config scripts (end in '.py' instead of '.ini').
sim/pyconfig/m5configbase.py:
Add license.
Fix minor __setattr__ problem (2.3 related?)
--HG--
rename : util/config/m5configbase.py => sim/pyconfig/m5configbase.py
extra : convert_revision : 5e004922f950bfdefced333285584b80ad7ffb83
Diffstat (limited to 'base')
-rw-r--r-- | base/inifile.cc | 42 | ||||
-rw-r--r-- | base/inifile.hh | 12 |
2 files changed, 11 insertions, 43 deletions
diff --git a/base/inifile.cc b/base/inifile.cc index 10836baea..94b17966a 100644 --- a/base/inifile.cc +++ b/base/inifile.cc @@ -27,8 +27,6 @@ */ #define USE_CPP -// #define CPP_PIPE - #ifdef USE_CPP #include <sys/signal.h> @@ -43,9 +41,6 @@ #include <fstream> #include <iostream> -#if __GNUC__ >= 3 -#include <ext/stdio_filebuf.h> -#endif #include <vector> #include <string> @@ -74,8 +69,6 @@ IniFile::~IniFile() bool IniFile::loadCPP(const string &file, vector<char *> &cppArgs) { - int fd[2]; - // Open the file just to verify that we can. Otherwise if the // file doesn't exist or has bad permissions the user will get // confusing errors from cpp/g++. @@ -99,18 +92,13 @@ IniFile::loadCPP(const string &file, vector<char *> &cppArgs) delete [] cfile; -#ifdef CPP_PIPE - if (pipe(fd) == -1) - return false; -#else char tempfile[] = "/tmp/configXXXXXX"; - fd[0] = fd[1] = mkstemp(tempfile); -#endif + int tmp_fd = mkstemp(tempfile); int pid = fork(); if (pid == -1) - return 1; + return false; if (pid == 0) { char filename[FILENAME_MAX]; @@ -141,7 +129,7 @@ IniFile::loadCPP(const string &file, vector<char *> &cppArgs) args[nextArg++] = NULL; close(STDOUT_FILENO); - if (dup2(fd[1], STDOUT_FILENO) == -1) + if (dup2(tmp_fd, STDOUT_FILENO) == -1) exit(1); execvp("g++", args); @@ -158,33 +146,13 @@ IniFile::loadCPP(const string &file, vector<char *> &cppArgs) if (!WIFEXITED(retval) || WEXITSTATUS(retval) != 0) return false; -#ifdef CPP_PIPE - close(fd[1]); -#else - lseek(fd[0], 0, SEEK_SET); -#endif + close(tmp_fd); bool status = false; -#if __GNUC__ >= 3 - using namespace __gnu_cxx; - stdio_filebuf<char> fbuf(fd[0], ios_base::in, true, - static_cast<stdio_filebuf<char>::int_type>(BUFSIZ)); - - if (fbuf.is_open()) { - istream f(&fbuf); - status = load(f); - } - -#else - ifstream f(fd[0]); - if (f.is_open()) - status = load(f); -#endif + status = load(tempfile); -#ifndef CPP_PIPE unlink(tempfile); -#endif return status; } diff --git a/base/inifile.hh b/base/inifile.hh index 01e4e6c17..58a657db4 100644 --- a/base/inifile.hh +++ b/base/inifile.hh @@ -151,12 +151,6 @@ class IniFile /// @retval Pointer to section object, or NULL if not found. Section *findSection(const std::string §ionName) const; - /// Load parameter settings from given istream. This is a helper - /// function for load(string) and loadCPP(), which open a file - /// and then pass it here. - /// @retval True if successful, false if errors were encountered. - bool load(std::istream &f); - public: /// Constructor. IniFile(); @@ -164,6 +158,12 @@ class IniFile /// Destructor. ~IniFile(); + /// Load parameter settings from given istream. This is a helper + /// function for load(string) and loadCPP(), which open a file + /// and then pass it here. + /// @retval True if successful, false if errors were encountered. + bool load(std::istream &f); + /// Load the specified file, passing it through the C preprocessor. /// Parameter settings found in the file will be merged with any /// already defined in this object. |