Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
8827ef2b
Commit
8827ef2b
authored
Jan 06, 2009
by
mattijs
Browse files
sicortex unaligned access
parent
30b62fb3
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/db/IOstreams/Pstreams/IPread.C
View file @
8827ef2b
...
...
@@ -27,9 +27,8 @@ Description
\*---------------------------------------------------------------------------*/
#include
"error.H"
#include
"IPstream.H"
#include
"error.H"
#include
"int.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -51,17 +50,24 @@ inline void IPstream::checkEof()
template
<
class
T
>
inline
void
IPstream
::
readFromBuffer
(
T
&
t
)
{
const
size_t
align
=
sizeof
(
T
);
bufPosition_
=
align
+
((
bufPosition_
-
1
)
&
~
(
align
-
1
));
t
=
reinterpret_cast
<
T
&>
(
buf_
[
bufPosition_
]);
bufPosition_
+=
sizeof
(
T
);
checkEof
();
//readFromBuffer(&t, sizeof(T));
}
inline
void
IPstream
::
readFromBuffer
(
void
*
data
,
size_t
count
)
inline
void
IPstream
::
readFromBuffer
(
void
*
data
,
size_t
count
,
size_t
align
)
{
if
(
align
>
1
)
{
bufPosition_
=
align
+
((
bufPosition_
-
1
)
&
~
(
align
-
1
));
}
register
const
char
*
bufPtr
=
&
buf_
[
bufPosition_
];
register
char
*
dataPtr
=
reinterpret_cast
<
char
*>
(
data
);
register
size_t
i
=
count
;
while
(
i
--
)
*
dataPtr
++
=
*
bufPtr
++
;
...
...
@@ -137,7 +143,7 @@ Istream& IPstream::read(char* data, std::streamsize count)
<<
Foam
::
abort
(
FatalError
);
}
readFromBuffer
(
data
,
count
);
readFromBuffer
(
data
,
count
,
8
);
return
*
this
;
}
...
...
src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H
View file @
8827ef2b
...
...
@@ -71,7 +71,7 @@ class IPstream
inline
void
readFromBuffer
(
T
&
);
//- Read data from the transfer buffer
inline
void
readFromBuffer
(
void
*
data
,
size_t
count
);
inline
void
readFromBuffer
(
void
*
data
,
size_t
count
,
size_t
align
);
public:
...
...
src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H
View file @
8827ef2b
...
...
@@ -70,7 +70,7 @@ class OPstream
inline
void
writeToBuffer
(
const
char
&
);
//- Write data to the transfer buffer
inline
void
writeToBuffer
(
const
void
*
data
,
size_t
count
);
inline
void
writeToBuffer
(
const
void
*
data
,
size_t
count
,
size_t
align
);
public:
...
...
src/OpenFOAM/db/IOstreams/Pstreams/OPstreamI.H
View file @
8827ef2b
...
...
@@ -40,7 +40,7 @@ inline void OPstream::writeToBuffer(const T& t)
//(T&)(buf_[bufPosition_]) = t;
//bufPosition_ += sizeof(T);
writeToBuffer
(
&
t
,
sizeof
(
T
));
writeToBuffer
(
&
t
,
sizeof
(
T
),
sizeof
(
T
));
}
...
...
@@ -56,11 +56,24 @@ inline void OPstream::writeToBuffer(const char& c)
}
inline
void
OPstream
::
writeToBuffer
(
const
void
*
data
,
size_t
count
)
inline
void
OPstream
::
writeToBuffer
(
const
void
*
data
,
size_t
count
,
size_t
align
)
{
label
oldPos
=
bufPosition_
;
if
(
align
>
1
)
{
// Align bufPosition. Pads bufPosition_-oldPos characters.
bufPosition_
=
align
+
((
bufPosition_
-
1
)
&
~
(
align
-
1
));
}
if
(
size_t
(
buf_
.
size
())
<
bufPosition_
+
count
)
{
enlargeBuffer
(
count
);
enlargeBuffer
(
bufPosition_
-
oldPos
+
count
);
}
register
char
*
bufPtr
=
&
buf_
[
bufPosition_
];
...
...
src/OpenFOAM/db/IOstreams/Pstreams/OPwrite.C
View file @
8827ef2b
...
...
@@ -111,7 +111,7 @@ Ostream& OPstream::write(const word& w)
size_t
ws
=
w
.
size
();
writeToBuffer
(
ws
);
writeToBuffer
(
w
.
c_str
(),
ws
+
1
);
writeToBuffer
(
w
.
c_str
(),
ws
+
1
,
1
);
return
*
this
;
}
...
...
@@ -123,7 +123,7 @@ Ostream& OPstream::write(const string& s)
size_t
ss
=
s
.
size
();
writeToBuffer
(
ss
);
writeToBuffer
(
s
.
c_str
(),
ss
+
1
);
writeToBuffer
(
s
.
c_str
(),
ss
+
1
,
1
);
return
*
this
;
}
...
...
@@ -168,7 +168,7 @@ Ostream& OPstream::write(const char* data, std::streamsize count)
<<
Foam
::
abort
(
FatalError
);
}
writeToBuffer
(
data
,
count
);
writeToBuffer
(
data
,
count
,
8
);
return
*
this
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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