From b4b10fd350852e321624d74983cca286091b55a1 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 1 Jan 2015 23:30:53 +0000 Subject: py: Put all global state together in state structures. This patch consolidates all global variables in py/ core into one place, in a global structure. Root pointers are all located together to make GC tracing easier and more efficient. --- py/runtime.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'py/runtime.h') diff --git a/py/runtime.h b/py/runtime.h index 711b15f0d..7a9c6eefa 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -26,6 +26,7 @@ #ifndef __MICROPY_INCLUDED_PY_RUNTIME_H__ #define __MICROPY_INCLUDED_PY_RUNTIME_H__ +#include "py/mpstate.h" #include "py/obj.h" typedef enum { @@ -64,10 +65,10 @@ void mp_arg_parse_all_kw_array(mp_uint_t n_pos, mp_uint_t n_kw, const mp_obj_t * NORETURN void mp_arg_error_terse_mismatch(void); NORETURN void mp_arg_error_unimpl_kw(void); -mp_obj_dict_t *mp_locals_get(void); -void mp_locals_set(mp_obj_dict_t *d); -mp_obj_dict_t *mp_globals_get(void); -void mp_globals_set(mp_obj_dict_t *d); +static inline mp_obj_dict_t *mp_locals_get(void) { return MP_STATE_CTX(dict_locals); } +static inline void mp_locals_set(mp_obj_dict_t *d) { MP_STATE_CTX(dict_locals) = d; } +static inline mp_obj_dict_t *mp_globals_get(void) { return MP_STATE_CTX(dict_globals); } +static inline void mp_globals_set(mp_obj_dict_t *d) { MP_STATE_CTX(dict_globals) = d; } mp_obj_t mp_load_name(qstr qstr); mp_obj_t mp_load_global(qstr qstr); @@ -120,7 +121,6 @@ mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type); mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, mp_uint_t n_args_kw, const mp_obj_t *args); NORETURN void mp_native_raise(mp_obj_t o); -extern mp_obj_t mp_pending_exception; extern struct _mp_obj_list_t mp_sys_path_obj; extern struct _mp_obj_list_t mp_sys_argv_obj; #define mp_sys_path ((mp_obj_t)&mp_sys_path_obj) -- cgit v1.2.3