Skip to content

Commit d42cba0

Browse files
stinosdpgeorge
authored andcommitted
extmod/moduplatform: Improve implementation for PC ports.
Fix identification of 32/64 bit and of the Windows platform and add a platform string mimicking CPython for the latter.
1 parent ea880d5 commit d42cba0

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

extmod/moduplatform.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040

4141
#if defined(__ARM_ARCH)
4242
#define PLATFORM_ARCH "arm"
43-
#elif defined(__x86_64__)
43+
#elif defined(__x86_64__) || defined(_WIN64)
4444
#define PLATFORM_ARCH "x86_64"
45+
#elif defined(__i386__) || defined(_M_IX86)
46+
#define PLATFORM_ARCH "x86"
4547
#else
4648
#define PLATFORM_ARCH ""
4749
#endif
@@ -58,6 +60,16 @@
5860
MP_STRINGIFY((__ARMCC_VERSION / 1000000)) "." \
5961
MP_STRINGIFY((__ARMCC_VERSION / 10000 % 100)) "." \
6062
MP_STRINGIFY((__ARMCC_VERSION % 10000))
63+
#elif defined(_MSC_VER)
64+
#if defined(_WIN64)
65+
#define COMPILER_BITS "64 bit"
66+
#elif defined(_M_IX86)
67+
#define COMPILER_BITS "32 bit"
68+
#else
69+
#define COMPILER_BITS ""
70+
#endif
71+
#define PLATFORM_COMPILER \
72+
"MSC v." MP_STRINGIFY(_MSC_VER) " " COMPILER_BITS
6173
#else
6274
#define PLATFORM_COMPILER ""
6375
#endif
@@ -81,7 +93,7 @@
8193
#define PLATFORM_SYSTEM "Unix"
8294
#elif defined(__CYGWIN__)
8395
#define PLATFORM_SYSTEM "Cygwin"
84-
#elif defined(__WIN32__)
96+
#elif defined(_WIN32)
8597
#define PLATFORM_SYSTEM "Windows"
8698
#else
8799
#define PLATFORM_SYSTEM "MicroPython"
@@ -95,6 +107,10 @@
95107
#define MICROPY_HW_MCU_NAME ""
96108
#endif
97109

110+
#ifndef MICROPY_HAL_VERSION
111+
#define MICROPY_HAL_VERSION ""
112+
#endif
113+
98114
STATIC const MP_DEFINE_STR_OBJ(info_platform_obj, PLATFORM_SYSTEM "-" MICROPY_VERSION_STRING "-HAL" \
99115
MICROPY_HAL_VERSION "-" PLATFORM_ARCH "-with-" PLATFORM_LIBC_LIB "" PLATFORM_LIBC_VER);
100116
STATIC const MP_DEFINE_STR_OBJ(info_python_compiler_obj, PLATFORM_COMPILER);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy