diff options
author | Derek Hower <drh5@cs.wisc.edu> | 2009-07-21 18:33:05 -0500 |
---|---|---|
committer | Derek Hower <drh5@cs.wisc.edu> | 2009-07-21 18:33:05 -0500 |
commit | 80544cda8ae97d3041dcc1e078e22c70aba3a9a7 (patch) | |
tree | 792bfaf3a41bbc7db6239e099ca62111a066546e /src/mem/ruby/libruby.cc | |
parent | 225de2eaff57bdf27d367531f25a654e4cd06fe6 (diff) | |
download | gem5-80544cda8ae97d3041dcc1e078e22c70aba3a9a7.tar.xz |
ruby: libruby_init now takes parsed Ruby-lang config text
libruby_init now expects to get a file that contains the output of
running a ruby-lang configuration, opposed to the ruby-lang
configuration itself.
Diffstat (limited to 'src/mem/ruby/libruby.cc')
-rw-r--r-- | src/mem/ruby/libruby.cc | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/src/mem/ruby/libruby.cc b/src/mem/ruby/libruby.cc index b867fec34..e4e302eba 100644 --- a/src/mem/ruby/libruby.cc +++ b/src/mem/ruby/libruby.cc @@ -88,58 +88,7 @@ vector<string> tokenizeString(string str, string delims) void libruby_init(const char* cfg_filename) { - stringstream cfg_output; - - // first we execute the Ruby-lang configuration script - int fd[2]; - int pid; - if (pipe(fd) == -1) { - perror("Error Creating Pipe"); - exit(EXIT_FAILURE); - } - - pid = fork(); - if (pid == -1){ - perror("Error forking"); - exit(EXIT_FAILURE); - } - - if (!pid) { - // child - close(fd[0]); // close the read end of the pipe - // replace stdout with the write pipe - if (dup2(fd[1], STDOUT_FILENO) == -1) { - perror("Error redirecting stdout"); - exit(EXIT_FAILURE); - } - if (execlp("ruby", "ruby", "-I", GEMS_ROOT "/ruby/config", - GEMS_ROOT "/ruby/config/print_cfg.rb", "-r", cfg_filename, NULL)) { - perror("execlp"); - exit(EXIT_FAILURE); - } - } else { - close(fd[1]); - - int child_status; - if (wait(&child_status) == -1) { - perror("wait"); - exit(EXIT_FAILURE); - } - if (child_status != EXIT_SUCCESS) { - exit(EXIT_FAILURE); - } - - char buf[100]; - int bytes_read; - while( (bytes_read = read(fd[0], buf, 100)) > 0 ) { - for (int i=0;i<bytes_read;i++) { - // cout << buf[i]; - cfg_output << buf[i]; - } - } - assert(bytes_read == 0); - close(fd[0]); - } + ifstream cfg_output(cfg_filename); vector<RubyObjConf> * sys_conf = new vector<RubyObjConf>; |