Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
dmt
Commits
16aa0061
Commit
16aa0061
authored
May 06, 2017
by
Thanassis Tsiodras
Browse files
Properly shield against using missing functions in non-UNIXy embedded systems
parent
3240e549
Changes
2
Hide whitespace changes
Inline
Side-by-side
dmt/B_mappers/c_B_mapper.py
View file @
16aa0061
...
...
@@ -306,8 +306,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self
.
C_SourceFile
.
write
(
" if (ossEncode(g_world, OSS_%s_PDU, &var_%s, &strm) != 0) {
\n
"
%
(
self
.
CleanNameAsToolWants
(
nodeTypename
),
self
.
CleanNameAsToolWants
(
nodeTypename
)))
self
.
C_SourceFile
.
write
(
"#ifdef __unix__
\n
"
)
self
.
C_SourceFile
.
write
(
'
\t
fprintf(stderr, "Could not encode %s (at %%s, %%d), errorMessage was %%s
\\
n", __FILE__, __LINE__, ossGetErrMsg(g_world));
\n
'
%
nodeTypename
)
self
.
C_SourceFile
.
write
(
"#endif
\n
"
)
self
.
C_SourceFile
.
write
(
" return -1;
\n
"
)
self
.
C_SourceFile
.
write
(
" } else {
\n
"
)
self
.
C_SourceFile
.
write
(
" assert(strm.length <= iMaxBufferSize);
\n
"
)
...
...
@@ -321,8 +323,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self
.
C_SourceFile
.
write
(
" if (asn1Scc%s_%sEncode(pSrc, &strm, &errorCode, TRUE) == FALSE) {
\n
"
%
(
self
.
CleanNameAsToolWants
(
nodeTypename
),
(
"ACN_"
if
encoding
.
lower
()
==
"acn"
else
""
)))
self
.
C_SourceFile
.
write
(
"#ifdef __unix__
\n
"
)
self
.
C_SourceFile
.
write
(
'
\t
fprintf(stderr, "Could not encode %s (at %%s, %%d), errorCode was %%d
\\
n", __FILE__, __LINE__, errorCode);
\n
'
%
nodeTypename
)
self
.
C_SourceFile
.
write
(
"#endif
\n
"
)
self
.
C_SourceFile
.
write
(
" return -1;
\n
"
)
self
.
C_SourceFile
.
write
(
" } else {
\n
"
)
self
.
C_SourceFile
.
write
(
" return BitStream_GetLength(&strm);
\n
"
)
...
...
@@ -399,8 +403,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self
.
CleanNameAsToolWants
(
nodeTypename
))
self
.
C_SourceFile
.
write
(
" return 0;
\n
"
)
self
.
C_SourceFile
.
write
(
" } else {
\n
"
)
self
.
C_SourceFile
.
write
(
"#ifdef __unix__
\n
"
)
self
.
C_SourceFile
.
write
(
'
\t
fprintf(stderr, "Could not decode %s (at %%s, %%d), error message was %%s
\\
n", __FILE__, __LINE__, ossGetErrMsg(g_world));
\n
'
%
nodeTypename
)
self
.
C_SourceFile
.
write
(
"#endif
\n
"
)
self
.
C_SourceFile
.
write
(
" return -1;
\n
"
)
self
.
C_SourceFile
.
write
(
" }
\n
"
)
self
.
C_SourceFile
.
write
(
"}
\n
"
)
...
...
@@ -408,8 +414,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
elif
encoding
.
lower
()
in
[
"uper"
,
"acn"
]:
self
.
C_SourceFile
.
write
(
" return 0;
\n
"
)
self
.
C_SourceFile
.
write
(
" } else {
\n
"
)
self
.
C_SourceFile
.
write
(
"#ifdef __unix__
\n
"
)
self
.
C_SourceFile
.
write
(
'
\t
fprintf(stderr, "Could not decode %s (at %%s, %%d), error code was %%d
\\
n", __FILE__, __LINE__, errorCode);
\n
'
%
nodeTypename
)
self
.
C_SourceFile
.
write
(
"#endif
\n
"
)
self
.
C_SourceFile
.
write
(
" return -1;
\n
"
)
self
.
C_SourceFile
.
write
(
" }
\n
"
)
self
.
C_SourceFile
.
write
(
"}
\n
"
)
...
...
dmt/B_mappers/synchronousTool.py
View file @
16aa0061
...
...
@@ -296,8 +296,10 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
self
.
C_SourceFile
.
write
(
" if (ossEncode(g_world, OSS_%s_PDU, &var_%s, &strm) != 0) {
\n
"
%
(
self
.
CleanNameAsToolWants
(
nodeTypename
),
self
.
CleanNameAsToolWants
(
nodeTypename
)))
self
.
C_SourceFile
.
write
(
"#ifdef __unix__
\n
"
)
self
.
C_SourceFile
.
write
(
' fprintf(stderr, "Could not encode %s (at %%s, %%d), errorMessage was %%s
\\
n", __FILE__, __LINE__, ossGetErrMsg(g_world));
\n
'
%
nodeTypename
)
self
.
C_SourceFile
.
write
(
"#endif
\n
"
)
self
.
C_SourceFile
.
write
(
" return -1;
\n
"
)
self
.
C_SourceFile
.
write
(
" } else {
\n
"
)
self
.
C_SourceFile
.
write
(
" assert(strm.length <= iMaxBufferSize);
\n
"
)
...
...
@@ -312,8 +314,10 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
(
self
.
CleanNameAsToolWants
(
nodeTypename
),
"ACN_"
if
encoding
.
lower
()
==
"acn"
else
""
,
self
.
CleanNameAsToolWants
(
nodeTypename
)))
self
.
C_SourceFile
.
write
(
"#ifdef __unix__
\n
"
)
self
.
C_SourceFile
.
write
(
' fprintf(stderr, "Could not encode %s (at %%s, %%d), errorCode was %%d
\\
n", __FILE__, __LINE__, errorCode);
\n
'
%
nodeTypename
)
self
.
C_SourceFile
.
write
(
"#endif
\n
"
)
self
.
C_SourceFile
.
write
(
" return -1;
\n
"
)
self
.
C_SourceFile
.
write
(
" } else {
\n
"
)
self
.
C_SourceFile
.
write
(
" return BitStream_GetLength(&strm);
\n
"
)
...
...
@@ -440,16 +444,20 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
self
.
C_SourceFile
.
write
(
" ossFreeBuf(g_world, pVar_%s);
\n
"
%
self
.
CleanNameAsToolWants
(
nodeTypename
))
self
.
C_SourceFile
.
write
(
" return 0;
\n
"
)
self
.
C_SourceFile
.
write
(
" } else {
\n
"
)
self
.
C_SourceFile
.
write
(
"#ifdef __unix__
\n
"
)
self
.
C_SourceFile
.
write
(
' fprintf(stderr, "Could not decode %s (at %%s, %%d), error message was %%s
\\
n", __FILE__, __LINE__, ossGetErrMsg(g_world));
\n
'
%
nodeTypename
)
self
.
C_SourceFile
.
write
(
"#endif
\n
"
)
self
.
C_SourceFile
.
write
(
" return -1;
\n
"
)
self
.
C_SourceFile
.
write
(
" }
\n
"
)
self
.
C_SourceFile
.
write
(
"}
\n\n
"
)
elif
encoding
.
lower
()
in
[
"uper"
,
"acn"
]:
self
.
C_SourceFile
.
write
(
" return 0;
\n
"
)
self
.
C_SourceFile
.
write
(
" } else {
\n
"
)
self
.
C_SourceFile
.
write
(
"#ifdef __unix__
\n
"
)
self
.
C_SourceFile
.
write
(
' fprintf(stderr, "Could not decode %s (at %%s, %%d), error code was %%d
\\
n", __FILE__, __LINE__, errorCode);
\n
'
%
nodeTypename
)
self
.
C_SourceFile
.
write
(
"#endif
\n
"
)
self
.
C_SourceFile
.
write
(
" return -1;
\n
"
)
self
.
C_SourceFile
.
write
(
" }
\n
"
)
self
.
C_SourceFile
.
write
(
"}
\n\n
"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment