Skip to content

Commit b9b9354

Browse files
committed
modsys: Add optional support for sys.platform.
Ports which wants to have it, should define MICROPY_PY_SYS_PLATFORM to a string value they need.
1 parent 7e4a2b0 commit b9b9354

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

py/modsys.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ mp_obj_list_t mp_sys_argv_obj;
5151
STATIC const mp_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {I(3), I(4), I(0)}};
5252
#undef I
5353
STATIC const MP_DEFINE_STR_OBJ(version_obj, "3.4.0");
54+
#ifdef MICROPY_PY_SYS_PLATFORM
55+
STATIC const MP_DEFINE_STR_OBJ(platform_obj, MICROPY_PY_SYS_PLATFORM);
56+
#endif
5457

5558
STATIC const mp_map_elem_t mp_module_sys_globals_table[] = {
5659
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_sys) },
@@ -59,6 +62,9 @@ STATIC const mp_map_elem_t mp_module_sys_globals_table[] = {
5962
{ MP_OBJ_NEW_QSTR(MP_QSTR_argv), (mp_obj_t)&mp_sys_argv_obj },
6063
{ MP_OBJ_NEW_QSTR(MP_QSTR_version), (mp_obj_t)&version_obj },
6164
{ MP_OBJ_NEW_QSTR(MP_QSTR_version_info), (mp_obj_t)&mp_sys_version_info_obj },
65+
#ifdef MICROPY_PY_SYS_PLATFORM
66+
{ MP_OBJ_NEW_QSTR(MP_QSTR_platform), (mp_obj_t)&platform_obj },
67+
#endif
6268
#if MP_ENDIANNESS_LITTLE
6369
{ MP_OBJ_NEW_QSTR(MP_QSTR_byteorder), MP_OBJ_NEW_QSTR(MP_QSTR_little) },
6470
#else

py/qstrdefs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ Q(byteorder)
343343
Q(big)
344344
Q(exit)
345345
Q(little)
346+
#ifdef MICROPY_PY_SYS_PLATFORM
347+
Q(platform)
348+
#endif
346349
Q(stdin)
347350
Q(stdout)
348351
Q(stderr)

unix/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#define MICROPY_OPT_COMPUTED_GOTO (1)
4444
#define MICROPY_PY_BUILTINS_FROZENSET (1)
4545
#define MICROPY_PY_SYS_EXIT (1)
46+
#define MICROPY_PY_SYS_PLATFORM "linux"
4647
#define MICROPY_PY_SYS_STDFILES (1)
4748
#define MICROPY_PY_CMATH (1)
4849
#define MICROPY_PY_IO_FILEIO (1)

0 commit comments

Comments
 (0)