main.cc (4941:595b53060bc1) main.cc (5202:ff56fa8c2091)
1/*
2 * Copyright (c) 2000-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 68 unchanged lines hidden (view full) ---

77
78int
79python_main()
80{
81 PyObject *module;
82 PyObject *dict;
83 PyObject *result;
84
1/*
2 * Copyright (c) 2000-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 68 unchanged lines hidden (view full) ---

77
78int
79python_main()
80{
81 PyObject *module;
82 PyObject *dict;
83 PyObject *result;
84
85 module = PyImport_AddModule("__main__");
85 module = PyImport_AddModule(const_cast<char*>("__main__"));
86 if (module == NULL)
87 fatal("Could not import __main__");
88
89 dict = PyModule_GetDict(module);
90
91 result = PyRun_String("import m5.main", Py_file_input, dict, dict);
92 if (!result) {
93 PyErr_Print();

--- 36 unchanged lines hidden (view full) ---

130 if (oldpath != NULL) {
131 pythonpath += ":";
132 pythonpath += oldpath;
133 }
134
135 if (setenv("PYTHONPATH", pythonpath.c_str(), true) == -1)
136 fatal("setenv: %s\n", strerror(errno));
137
86 if (module == NULL)
87 fatal("Could not import __main__");
88
89 dict = PyModule_GetDict(module);
90
91 result = PyRun_String("import m5.main", Py_file_input, dict, dict);
92 if (!result) {
93 PyErr_Print();

--- 36 unchanged lines hidden (view full) ---

130 if (oldpath != NULL) {
131 pythonpath += ":";
132 pythonpath += oldpath;
133 }
134
135 if (setenv("PYTHONPATH", pythonpath.c_str(), true) == -1)
136 fatal("setenv: %s\n", strerror(errno));
137
138 char *python_home = getenv("PYTHONHOME");
138 const char *python_home = getenv("PYTHONHOME");
139 if (!python_home)
140 python_home = PYTHONHOME;
139 if (!python_home)
140 python_home = PYTHONHOME;
141 Py_SetPythonHome(python_home);
141 Py_SetPythonHome(const_cast<char*>(python_home));
142
143 // initialize embedded Python interpreter
144 Py_Initialize();
145 PySys_SetArgv(argc, argv);
146
147 // initialize SWIG modules
148 init_swig();
149
150 int ret = python_main();
151
152 // clean up Python intepreter.
153 Py_Finalize();
154
155 return ret;
156}
142
143 // initialize embedded Python interpreter
144 Py_Initialize();
145 PySys_SetArgv(argc, argv);
146
147 // initialize SWIG modules
148 init_swig();
149
150 int ret = python_main();
151
152 // clean up Python intepreter.
153 Py_Finalize();
154
155 return ret;
156}