ns-3 Direct Code Execution
Home
Tutorials ▼
Docs ▼
Wiki
Manual
Develop ▼
API
Bugs
API
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
dce-cxa.cc
Go to the documentation of this file.
1
#include "
dce-cxa.h
"
2
#include "
utils.h
"
3
#include "
process.h
"
4
#include "ns3/assert.h"
5
#include "ns3/log.h"
6
7
NS_LOG_COMPONENT_DEFINE
(
"SimuCxa"
);
8
9
using namespace
ns3;
10
11
int
12
dce___cxa_atexit
(
void
(*func)(
void
*),
void
*arg,
void
*d)
13
{
14
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
() << func << arg << d);
15
NS_ASSERT (
Current
() != 0);
16
Thread
*current =
Current
();
17
struct
AtExitHandler
handler;
18
handler.
type
=
AtExitHandler::CXA
;
19
handler.
value
.
cxa
.fn = func;
20
handler.
value
.
cxa
.arg = arg;
21
handler.
value
.
cxa
.d = d;
22
current->
process
->
atExitHandlers
.push_back (handler);
23
return
0;
24
}
25
void
dce___cxa_finalize
(
void
*d)
26
{
27
NS_LOG_FUNCTION (
Current
() <<
UtilsGetNodeId
() << d);
28
NS_ASSERT (
Current
() != 0);
29
Thread
*current =
Current
();
30
// from back to front to ensure that we process all this in the right order
31
// which is from last registered to first registered.
32
// and that we handle the case where one of the atexit handlers
33
// recursively calls atexit or __cxa_atexit.
34
while
(!current->
process
->
atExitHandlers
.empty ())
35
{
36
struct
AtExitHandler
handler = current->
process
->
atExitHandlers
.back ();
37
current->
process
->
atExitHandlers
.pop_back ();
38
switch
(handler.
type
)
39
{
40
case
AtExitHandler::CXA
:
41
if
(d == 0 || handler.
value
.
cxa
.d == d)
42
{
43
handler.
value
.
cxa
.fn (handler.
value
.
cxa
.arg);
44
}
45
break
;
46
case
AtExitHandler::NORMAL
:
47
if
(d == 0)
48
{
49
handler.
value
.
normal
();
50
}
51
break
;
52
}
53
}
54
}
model
dce-cxa.cc
Generated on Fri Aug 30 2013 13:57:55 for ns-3-dce by
1.8.1.2