aboutsummaryrefslogtreecommitdiff
path: root/extmod/moduplatform.c
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2021-09-21 12:42:39 +0200
committerDamien George <damien@micropython.org>2021-09-24 13:51:39 +1000
commitd42cba0d22cac812cc5a12f4670010b45932eafa (patch)
treec0815caa7d2de70a90056b8916ded63a5000f6b5 /extmod/moduplatform.c
parentea880d5674b987aa3d3b196d2e6baadcb69c4c06 (diff)
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.
Diffstat (limited to 'extmod/moduplatform.c')
-rw-r--r--extmod/moduplatform.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/extmod/moduplatform.c b/extmod/moduplatform.c
index 06bb9d5ce..149df7c56 100644
--- a/extmod/moduplatform.c
+++ b/extmod/moduplatform.c
@@ -40,8 +40,10 @@
#if defined(__ARM_ARCH)
#define PLATFORM_ARCH "arm"
-#elif defined(__x86_64__)
+#elif defined(__x86_64__) || defined(_WIN64)
#define PLATFORM_ARCH "x86_64"
+#elif defined(__i386__) || defined(_M_IX86)
+#define PLATFORM_ARCH "x86"
#else
#define PLATFORM_ARCH ""
#endif
@@ -58,6 +60,16 @@
MP_STRINGIFY((__ARMCC_VERSION / 1000000)) "." \
MP_STRINGIFY((__ARMCC_VERSION / 10000 % 100)) "." \
MP_STRINGIFY((__ARMCC_VERSION % 10000))
+#elif defined(_MSC_VER)
+#if defined(_WIN64)
+#define COMPILER_BITS "64 bit"
+#elif defined(_M_IX86)
+#define COMPILER_BITS "32 bit"
+#else
+#define COMPILER_BITS ""
+#endif
+#define PLATFORM_COMPILER \
+ "MSC v." MP_STRINGIFY(_MSC_VER) " " COMPILER_BITS
#else
#define PLATFORM_COMPILER ""
#endif
@@ -81,7 +93,7 @@
#define PLATFORM_SYSTEM "Unix"
#elif defined(__CYGWIN__)
#define PLATFORM_SYSTEM "Cygwin"
-#elif defined(__WIN32__)
+#elif defined(_WIN32)
#define PLATFORM_SYSTEM "Windows"
#else
#define PLATFORM_SYSTEM "MicroPython"
@@ -95,6 +107,10 @@
#define MICROPY_HW_MCU_NAME ""
#endif
+#ifndef MICROPY_HAL_VERSION
+#define MICROPY_HAL_VERSION ""
+#endif
+
STATIC const MP_DEFINE_STR_OBJ(info_platform_obj, PLATFORM_SYSTEM "-" MICROPY_VERSION_STRING "-HAL" \
MICROPY_HAL_VERSION "-" PLATFORM_ARCH "-with-" PLATFORM_LIBC_LIB "" PLATFORM_LIBC_VER);
STATIC const MP_DEFINE_STR_OBJ(info_python_compiler_obj, PLATFORM_COMPILER);