1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 24 unchanged lines hidden (view full) --- 33#include "base/logging.hh" 34#include "base/types.hh" 35#include "python/pybind11/pybind.hh" 36#include "sim/eventq.hh" 37#include "sim/init.hh" 38#include "systemc/ext/core/sc_main.hh" 39#include "systemc/ext/utils/sc_report_handler.hh" 40 |
41// A weak symbol to detect if sc_main has been defined, and if so where it is. 42[[gnu::weak]] int sc_main(int argc, char *argv[]); |
43 44namespace sc_core 45{ 46 47namespace 48{ 49 50bool scMainCalled = false; 51 52int _argc = 0; 53char **_argv = NULL; 54 55class ScMainFiber : public Fiber 56{ 57 void 58 main() 59 { |
60 if (::sc_main) { 61 ::sc_main(_argc, _argv); 62 } else { 63 // If python tries to call sc_main but no sc_main was defined... 64 fatal("sc_main called but not defined.\n"); 65 } |
66 } 67}; 68 69ScMainFiber scMainFiber; 70 71// This wrapper adapts the python version of sc_main to the c++ version. 72void 73sc_main(pybind11::args args) --- 173 unchanged lines hidden --- |