2424 * THE SOFTWARE.
2525 */
2626
27+ #include <stdint.h>
28+ #include <limits.h>
2729#include "mpconfig.h"
2830#include "misc.h"
2931#include "qstr.h"
3335#include "objlist.h"
3436#include "objtuple.h"
3537#include "objstr.h"
38+ #include "mpz.h"
39+ #include "objint.h"
3640
3741#if MICROPY_PY_SYS
3842
@@ -44,6 +48,8 @@ extern struct _dummy_t mp_sys_stdin_obj;
4448extern struct _dummy_t mp_sys_stdout_obj ;
4549extern struct _dummy_t mp_sys_stderr_obj ;
4650
51+ extern mp_obj_int_t mp_maxsize_obj ;
52+
4753mp_obj_list_t mp_sys_path_obj ;
4854mp_obj_list_t mp_sys_argv_obj ;
4955#define I (n ) MP_OBJ_NEW_SMALL_INT(n)
@@ -70,6 +76,19 @@ STATIC const mp_map_elem_t mp_module_sys_globals_table[] = {
7076#else
7177 { MP_OBJ_NEW_QSTR (MP_QSTR_byteorder ), MP_OBJ_NEW_QSTR (MP_QSTR_big ) },
7278#endif
79+ #if MICROPY_PY_SYS_MAXSIZE
80+ #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE
81+ // INT_MAX is not representable as small int, as we know that small int
82+ // takes one bit for tag. So, we have little choice but to provide this
83+ // value. Apps also should be careful to not try to compare sys.maxsize
84+ // with some number (which may not fit in available int size), but instead
85+ // count number of significant bits in sys.maxsize.
86+ { MP_OBJ_NEW_QSTR (MP_QSTR_maxsize ), MP_OBJ_NEW_SMALL_INT (INT_MAX >> 1 ) },
87+ #else
88+ { MP_OBJ_NEW_QSTR (MP_QSTR_maxsize ), (mp_obj_t )& mp_maxsize_obj },
89+ #endif
90+ #endif
91+
7392
7493#if MICROPY_PY_SYS_EXIT
7594 { MP_OBJ_NEW_QSTR (MP_QSTR_exit ), (mp_obj_t )& mp_sys_exit_obj },
0 commit comments