py: Abstract no-return attribute for functions a bit.

This commit is contained in:
Paul Sokolovsky 2014-04-30 05:35:18 +03:00
parent b1ce37d32e
commit e908591baa
3 changed files with 7 additions and 3 deletions

View File

@ -230,3 +230,6 @@ typedef double mp_float_t;
#define INT_FMT "%d" #define INT_FMT "%d"
#endif #endif
#endif //INT_FMT #endif //INT_FMT
// Modifier for function which doesn't return
#define NORETURN __attribute__((noreturn))

View File

@ -3,6 +3,7 @@
#include <limits.h> #include <limits.h>
#include <setjmp.h> #include <setjmp.h>
#include "mpconfig.h"
typedef struct _nlr_buf_t nlr_buf_t; typedef struct _nlr_buf_t nlr_buf_t;
struct _nlr_buf_t { struct _nlr_buf_t {
@ -33,7 +34,7 @@ struct _nlr_buf_t {
#if MICROPY_NLR_SETJMP #if MICROPY_NLR_SETJMP
extern nlr_buf_t *nlr_setjmp_top; extern nlr_buf_t *nlr_setjmp_top;
void nlr_setjmp_jump(void *val) __attribute__((noreturn)); NORETURN void nlr_setjmp_jump(void *val);
// nlr_push() must be defined as a macro, because "The stack context will be // nlr_push() must be defined as a macro, because "The stack context will be
// invalidated if the function which called setjmp() returns." // invalidated if the function which called setjmp() returns."
#define nlr_push(buf) ((buf)->prev = nlr_setjmp_top, nlr_setjmp_top = (buf), setjmp((buf)->jmpbuf)) #define nlr_push(buf) ((buf)->prev = nlr_setjmp_top, nlr_setjmp_top = (buf), setjmp((buf)->jmpbuf))
@ -42,7 +43,7 @@ void nlr_setjmp_jump(void *val) __attribute__((noreturn));
#else #else
unsigned int nlr_push(nlr_buf_t *); unsigned int nlr_push(nlr_buf_t *);
void nlr_pop(void); void nlr_pop(void);
void nlr_jump(void *val) __attribute__((noreturn)); NORETURN void nlr_jump(void *val);
#endif #endif
// This must be implemented by a port. It's called by nlr_jump // This must be implemented by a port. It's called by nlr_jump

View File

@ -27,7 +27,7 @@ const mp_obj_t mp_const_empty_bytes;
STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str); STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str);
STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str); STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str);
STATIC mp_obj_t str_new(const mp_obj_type_t *type, const byte* data, uint len); STATIC mp_obj_t str_new(const mp_obj_type_t *type, const byte* data, uint len);
STATIC void bad_implicit_conversion(mp_obj_t self_in) __attribute__((noreturn)); STATIC NORETURN void bad_implicit_conversion(mp_obj_t self_in);
/******************************************************************************/ /******************************************************************************/
/* str */ /* str */