Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
circuitpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
circuitpython
Commits
a3c61004
Commit
a3c61004
authored
Dec 12, 2016
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py/binary: Do zero extension when storing a value larger than word size.
parent
aee13ef3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
py/binary.c
py/binary.c
+4
-3
No files found.
py/binary.c
View file @
a3c61004
...
...
@@ -294,9 +294,10 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
#endif
{
val
=
mp_obj_get_int
(
val_in
);
// sign extend if needed
if
(
BYTES_PER_WORD
<
8
&&
size
>
sizeof
(
val
)
&&
is_signed
(
val_type
)
&&
(
mp_int_t
)
val
<
0
)
{
memset
(
p
+
sizeof
(
val
),
0xff
,
size
-
sizeof
(
val
));
// zero/sign extend if needed
if
(
BYTES_PER_WORD
<
8
&&
size
>
sizeof
(
val
))
{
int
c
=
(
is_signed
(
val_type
)
&&
(
mp_int_t
)
val
<
0
)
?
0xff
:
0x00
;
memset
(
p
+
sizeof
(
val
),
c
,
size
-
sizeof
(
val
));
}
}
}
...
...
Write
Preview
Markdown
is supported
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