sc_main.cc (12862:df3aaa5bda42) sc_main.cc (12949:7014101fea10)
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
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 default version of this function in case one isn't otherwise defined.
42// This ensures everything will link properly whether or not the user defined
43// a custom sc_main function. If they didn't but still try to call it, throw
44// an error and die.
45[[gnu::weak]] int
46sc_main(int argc, char *argv[])
47{
48 // If python attempts to call sc_main but no sc_main was defined...
49 fatal("sc_main called but not defined.\n");
50}
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[]);
51
52namespace sc_core
53{
54
55namespace
56{
57
58bool scMainCalled = false;
59
60int _argc = 0;
61char **_argv = NULL;
62
63class ScMainFiber : public Fiber
64{
65 void
66 main()
67 {
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 {
68 ::sc_main(_argc, _argv);
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 }
69 }
70};
71
72ScMainFiber scMainFiber;
73
74// This wrapper adapts the python version of sc_main to the c++ version.
75void
76sc_main(pybind11::args args)

--- 173 unchanged lines hidden ---
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 ---