forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extmod/moductypes: Fix bigint handling for 32-bit ports.
- Loading branch information
Showing
4 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# This test checks previously known problem values for 32-bit ports. | ||
# It's less useful for 64-bit ports. | ||
try: | ||
import uctypes | ||
except ImportError: | ||
import sys | ||
print("SKIP") | ||
sys.exit() | ||
|
||
buf = b"12345678abcd" | ||
struct = uctypes.struct( | ||
uctypes.addressof(buf), | ||
{"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4}, | ||
uctypes.LITTLE_ENDIAN | ||
) | ||
|
||
struct.f32 = 0x7fffffff | ||
print(buf) | ||
|
||
struct.f32 = 0x80000000 | ||
print(buf) | ||
|
||
struct.f32 = 0xff010203 | ||
print(buf) | ||
|
||
struct.f64 = 0x80000000 | ||
print(buf) | ||
|
||
struct.f64 = 0x80000000 * 2 | ||
print(buf) | ||
|
||
print("=") | ||
|
||
buf = b"12345678abcd" | ||
struct = uctypes.struct( | ||
uctypes.addressof(buf), | ||
{"f32": uctypes.UINT32 | 0, "f64": uctypes.UINT64 | 4}, | ||
uctypes.BIG_ENDIAN | ||
) | ||
|
||
struct.f32 = 0x7fffffff | ||
print(buf) | ||
|
||
struct.f32 = 0x80000000 | ||
print(buf) | ||
|
||
struct.f32 = 0xff010203 | ||
print(buf) | ||
|
||
struct.f64 = 0x80000000 | ||
print(buf) | ||
|
||
struct.f64 = 0x80000000 * 2 | ||
print(buf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
b'\xff\xff\xff\x7f5678abcd' | ||
b'\x00\x00\x00\x805678abcd' | ||
b'\x03\x02\x01\xff5678abcd' | ||
b'\x03\x02\x01\xff\x00\x00\x00\x80\x00\x00\x00\x00' | ||
b'\x03\x02\x01\xff\x00\x00\x00\x00\x01\x00\x00\x00' | ||
= | ||
b'\x7f\xff\xff\xff5678abcd' | ||
b'\x80\x00\x00\x005678abcd' | ||
b'\xff\x01\x02\x035678abcd' | ||
b'\xff\x01\x02\x03\x00\x00\x00\x00\x80\x00\x00\x00' | ||
b'\xff\x01\x02\x03\x00\x00\x00\x01\x00\x00\x00\x00' |