Skip to content

Commit e859ddf

Browse files
committed
cc3200: Enable uerrno module with short, custom list of error codes.
Since we recently replaced the OSError string messages with simple error codes, having the uerrno module gets back some user friendly error messages. The total code size (after removing strings, replacing with uerrno module) is decreased.
1 parent b1b0902 commit e859ddf

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

cc3200/mpconfigport.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@
107107
#define MICROPY_PY_CMATH (0)
108108
#define MICROPY_PY_IO (1)
109109
#define MICROPY_PY_IO_FILEIO (1)
110+
#define MICROPY_PY_UERRNO (1)
111+
#define MICROPY_PY_UERRNO_ERRORCODE (0)
110112
#define MICROPY_PY_THREAD (1)
111113
#define MICROPY_PY_THREAD_GIL (1)
112114
#define MICROPY_PY_UBINASCII (0)
@@ -122,6 +124,14 @@
122124
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
123125
#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)
124126

127+
// We define our own list of errno constants to include in uerrno module
128+
#define MICROPY_PY_UERRNO_LIST \
129+
X(EPERM) \
130+
X(EIO) \
131+
X(ENODEV) \
132+
X(EINVAL) \
133+
X(ETIMEDOUT) \
134+
125135
// TODO these should be generic, not bound to fatfs
126136
#define mp_type_fileio fatfs_type_fileio
127137
#define mp_type_textio fatfs_type_textio
@@ -161,6 +171,7 @@ extern const struct _mp_obj_module_t mp_module_ussl;
161171
{ MP_OBJ_NEW_QSTR(MP_QSTR_ussl), (mp_obj_t)&mp_module_ussl }, \
162172

163173
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
174+
{ MP_OBJ_NEW_QSTR(MP_QSTR_errno), (mp_obj_t)&mp_module_uerrno }, \
164175
{ MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&mp_module_ustruct }, \
165176
{ MP_OBJ_NEW_QSTR(MP_QSTR_re), (mp_obj_t)&mp_module_ure }, \
166177
{ MP_OBJ_NEW_QSTR(MP_QSTR_json), (mp_obj_t)&mp_module_ujson }, \

0 commit comments

Comments
 (0)