1#ifndef INTERNAL_ERROR_H                                  
    2#define INTERNAL_ERROR_H 
   11#include "ruby/internal/config.h" 
   13#include "internal/string.h"     
   24# undef rb_raise_static 
   25# undef rb_sys_fail_path 
   26# undef rb_syserr_fail_path 
   29#define rb_raise_static(e, m) \ 
   30    rb_raise_cstr_i((e), rb_str_new_static((m), rb_strlen_lit(m))) 
   31#ifdef RUBY_FUNCTION_NAME_STRING 
   32# define rb_syserr_fail_path(err, path) rb_syserr_fail_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path)) 
   33# define rb_syserr_new_path(err, path) rb_syserr_new_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path)) 
   35# define rb_syserr_fail_path(err, path) rb_syserr_fail_str((err), (path)) 
   36# define rb_syserr_new_path(err, path) rb_syserr_new_str((err), (path)) 
   39#define rb_sys_fail(mesg) \ 
   41    int errno_to_fail = errno; \ 
   42    rb_syserr_fail(errno_to_fail, (mesg)); \ 
   45#define rb_sys_fail_str(mesg) \ 
   47    int errno_to_fail = errno; \ 
   48    rb_syserr_fail_str(errno_to_fail, (mesg)); \ 
   51#define rb_sys_fail_path(path) \ 
   53    int errno_to_fail = errno; \ 
   54    rb_syserr_fail_path(errno_to_fail, (path)); \ 
   57#define rb_sys_fail_sprintf(...) \ 
   59    int errno_to_fail = errno; \ 
   60    rb_syserr_fail_str(errno_to_fail, rb_sprintf("" __VA_ARGS__)); \ 
   64extern long rb_backtrace_length_limit;
 
   65extern VALUE rb_eEAGAIN;
 
   66extern VALUE rb_eEWOULDBLOCK;
 
   67extern VALUE rb_eEINPROGRESS;
 
   69void rb_report_bug_valist(
VALUE file, 
int line, const 
char *fmt, va_list args);
 
   70NORETURN(
void rb_async_bug_errno(const 
char *,
int));
 
   71const 
char *rb_builtin_type_name(
int t);
 
   72const 
char *rb_builtin_class_name(
VALUE x);
 
   73PRINTF_ARGS(
void rb_warn_deprecated(const 
char *fmt, const 
char *suggest, ...), 1, 3);
 
   74PRINTF_ARGS(
void rb_warn_deprecated_to_remove(const 
char *removal, const 
char *fmt, const 
char *suggest, ...), 2, 4);
 
   75PRINTF_ARGS(
void rb_warn_reserved_name(const 
char *removal, const 
char *fmt, ...), 2, 3);
 
   78# define RUBY_VERSION_SINCE(major, minor) (RUBY_API_VERSION_CODE >= (major * 10000) + (minor) * 100) 
   79# define RUBY_VERSION_BEFORE(major, minor) (RUBY_API_VERSION_CODE < (major * 10000) + (minor) * 100) 
   80# if defined(RBIMPL_WARNING_PRAGMA0) 
   81#   define RBIMPL_TODO0(x) RBIMPL_WARNING_PRAGMA0(message(x)) 
   82# elif RBIMPL_COMPILER_SINCE(MSVC, 12, 0, 0) 
   83#   define RBIMPL_TODO0(x) __pragma(message(x)) 
   86# if RBIMPL_HAS_ATTRIBUTE(diagnose_if) || defined(__OPTIMIZE__) 
   88#define RUBY_VERSION_isdigit(c) ('0'<=(c)&&(c)<='9') 
   90#define RUBY_VERSION__number_len(v, ofs) \ 
   91    (!RUBY_VERSION_isdigit((v)[ofs]) ? \ 
   92     0 : !RUBY_VERSION_isdigit((v)[(ofs) + 1]) ? 1 : 2) 
   93#define RUBY_VERSION__to_number(v, ofs) \ 
   94    (!RUBY_VERSION_isdigit((v)[ofs]) ? \ 
   95     0 : !RUBY_VERSION_isdigit((v)[(ofs) + 1]) ? \ 
   97     (((v)[ofs]-'0')*10+(v)[(ofs)+1]-'0')) 
   99#define RUBY_VERSION_CODE_FROM_MAJOR_MINOR_STRING(v) \ 
  100    (RUBY_VERSION__to_number(v, 0) * 10000 + \ 
  101     ((v)[RUBY_VERSION__number_len(v, 0)] == '.' ? \ 
  102      RUBY_VERSION__to_number(v, RUBY_VERSION__number_len(v, 0)+1) * 100 : 0)) 
  103#define RUBY_VERSION_STRING_SINCE(v) (RUBY_API_VERSION_CODE >= RUBY_VERSION_CODE_FROM_MAJOR_MINOR_STRING(v)) 
  104#define RUBY_VERSION_STRING_BEFORE(v) (RUBY_API_VERSION_CODE < RUBY_VERSION_CODE_FROM_MAJOR_MINOR_STRING(v)) 
  106# if RBIMPL_HAS_ATTRIBUTE(diagnose_if) 
  109rb_deprecated_method_to_be_removed(const 
char *removal)
 
  117rb_diagnose_reserved_name_at(const 
char *coming)
 
  124void rb_deprecated_method_to_be_removed(const 
char *);
 
  125#   define rb_deprecated_method_to_be_removed(removal) \ 
  126    (sizeof(char[1-2*(!RUBY_VERSION_isdigit(removal[0]) || RUBY_VERSION_STRING_SINCE(removal))])!=1 ? \ 
  127     rb_deprecated_method_to_be_removed(removal) : \ 
  128     RBIMPL_ASSERT_NOTHING) 
  131void rb_diagnose_reserved_name_at(const 
char *);
 
  132#   define rb_diagnose_reserved_name_at(coming) \ 
  133    (sizeof(char[1-2*(!RUBY_VERSION_isdigit(coming[0]) || RUBY_VERSION_STRING_SINCE(coming))])!=1 ? \ 
  134     rb_diagnose_reserved_name_at(coming) : \ 
  135     RBIMPL_ASSERT_NOTHING) 
  138# define rb_warn_deprecated_to_remove_at(removal, ...) \ 
  139    (rb_deprecated_method_to_be_removed(#removal), \ 
  140     rb_warn_deprecated_to_remove(#removal, __VA_ARGS__)) 
  142# define rb_warn_reserved_name_at(coming, ...) \ 
  143    (rb_diagnose_reserved_name_at(#coming), \ 
  144     rb_warn_reserved_name(#coming, __VA_ARGS__)) 
  147#ifndef rb_warn_deprecated_to_remove_at 
  148# define rb_warn_deprecated_to_remove_at(removal, ...) \ 
  149        rb_warn_deprecated_to_remove(#removal, __VA_ARGS__) 
  151#ifndef rb_warn_reserved_name_at 
  152# define rb_warn_reserved_name_at(removal, ...) \ 
  153        rb_warn_reserved_name(#removal, __VA_ARGS__) 
  155#ifndef RUBY_VERSION_SINCE 
  156# define RUBY_VERSION_SINCE(major, minor) 0 
  158#ifndef RUBY_VERSION_BEFORE 
  159# define RUBY_VERSION_BEFORE(major, minor) 0 
  162# define RBIMPL_TODO0(x) 
  164#define RBIMPL_TODO(message) RBIMPL_TODO0("TODO: " message) 
  167PRINTF_ARGS(
void rb_enc_warn(
rb_encoding *enc, const 
char *fmt, ...), 2, 3);
 
  168PRINTF_ARGS(
void rb_sys_enc_warning(
rb_encoding *enc, const 
char *fmt, ...), 2, 3);
 
  169PRINTF_ARGS(
void rb_syserr_enc_warning(
int err, 
rb_encoding *enc, const 
char *fmt, ...), 3, 4);
 
  170PRINTF_ARGS(
void rb_enc_compile_warning(
rb_encoding *enc, const 
char *file, 
int line, const 
char *fmt, ...), 4, 5);
 
  171PRINTF_ARGS(
void rb_enc_compile_warn(
rb_encoding *enc, const 
char *file, 
int line, const 
char *fmt, ...), 4, 5);
 
  177PRINTF_ARGS(
VALUE rb_warning_string(const 
char *fmt, ...), 1, 2);
 
  179NORETURN(
void rb_vraise(
VALUE, const 
char *, va_list));
 
  180NORETURN(static 
inline void rb_raise_cstr(
VALUE etype, const 
char *mesg));
 
  183NORETURN(static 
inline void rb_name_err_raise(const 
char *mesg, 
VALUE recv, 
VALUE name));
 
  187#define rb_typeddata_is_instance_of rb_typeddata_is_instance_of_inline 
  188void rb_bug_without_die(
const char *fmt, ...);
 
  190RUBY_SYMBOL_EXPORT_BEGIN
 
  192int rb_bug_reporter_add(
void (*func)(
FILE *, 
void *), 
void *data);
 
  193#ifdef RUBY_FUNCTION_NAME_STRING 
  194NORETURN(
void rb_sys_fail_path_in(
const char *func_name, 
VALUE path));
 
  195NORETURN(
void rb_syserr_fail_path_in(
const char *func_name, 
int err, 
VALUE path));
 
  196VALUE rb_syserr_new_path_in(
const char *func_name, 
int n, 
VALUE path);
 
  198RUBY_SYMBOL_EXPORT_END
 
  201void rb_free_warning(
void);
 
  211rb_raise_cstr(
VALUE etype, 
const char *mesg)
 
  214    rb_raise_cstr_i(etype, str);
 
  220    VALUE exc = rb_name_err_new(mesg, recv, name);
 
  225rb_name_err_raise(
const char *mesg, 
VALUE recv, 
VALUE name)
 
  227    VALUE str = rb_fstring_cstr(mesg);
 
  228    rb_name_err_raise_str(str, recv, name);
 
  234    VALUE exc = rb_key_err_new(mesg, recv, name);
 
  245    rb_stack_overflow_prevention = 0, 
 
  246    rb_stack_overflow_signal = 1, 
 
  247    rb_stack_overflow_fatal = 2, 
 
  248} ruby_stack_overflow_critical_level;
 
#define RBIMPL_ATTR_DIAGNOSE_IF(_, __, ___)
Wraps (or simulates) __attribute__((diagnose_if))
#define RBIMPL_ATTR_FORCEINLINE()
Wraps (or simulates) __forceinline.
#define T_DATA
Old name of RUBY_T_DATA.
rb_warning_category_t
Warning categories.
void rb_exc_raise(VALUE mesg)
Raises an exception in the current thread.
VALUE rb_exc_new_str(VALUE etype, VALUE str)
Identical to rb_exc_new_cstr(), except it takes a Ruby's string instead of C's.
#define RBIMPL_ATTR_ERROR(msg)
Wraps (or simulates) __attribute__((error))
#define rb_str_new_cstr(str)
Identical to rb_str_new, except it assumes the passed pointer is a pointer to a C string.
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
static bool RTYPEDDATA_P(VALUE obj)
Checks whether the passed object is RTypedData or RData.
static const struct rb_data_type_struct * RTYPEDDATA_TYPE(VALUE obj)
Queries for the type of given object.
This is the struct that holds necessary info for a struct.
uintptr_t VALUE
Type that represents a Ruby object.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.
ruby_value_type
C-level type of an object.