2020-04-10 01:11:40 -04:00
|
|
|
#ifndef RUBY_INTERNAL_H /*-*-C-*-vi:se ft=c:*/
|
2011-05-18 09:41:54 -04:00
|
|
|
#define RUBY_INTERNAL_H 1
|
2020-04-10 01:11:40 -04:00
|
|
|
/**
|
|
|
|
* @author $Author$
|
|
|
|
* @date Tue May 17 11:42:20 JST 2011
|
|
|
|
* @copyright Copyright (C) 2011 Yukihiro Matsumoto
|
|
|
|
* @copyright This file is a part of the programming language Ruby.
|
|
|
|
* Permission is hereby granted, to either redistribute and/or
|
|
|
|
* modify this file, provided that the conditions mentioned in the
|
|
|
|
* file COPYING are met. Consult the file for details.
|
|
|
|
*/
|
2020-05-08 05:31:09 -04:00
|
|
|
#include "ruby/internal/config.h"
|
2014-11-15 06:49:06 -05:00
|
|
|
|
2019-12-02 00:48:42 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
# error not for C++
|
2011-05-18 09:41:54 -04:00
|
|
|
#endif
|
|
|
|
|
2016-04-23 03:15:25 -04:00
|
|
|
#define LIKELY(x) RB_LIKELY(x)
|
|
|
|
#define UNLIKELY(x) RB_UNLIKELY(x)
|
|
|
|
|
* internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
error.c, ruby.c: Remove the definitions of numberof.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 06:01:19 -04:00
|
|
|
#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
|
2019-12-03 00:42:53 -05:00
|
|
|
#define roomof(x, y) (((x) + (y) - 1) / (y))
|
|
|
|
#define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
|
* internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
error.c, ruby.c: Remove the definitions of numberof.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 06:01:19 -04:00
|
|
|
|
2018-08-13 17:34:20 -04:00
|
|
|
/* Prevent compiler from reordering access */
|
|
|
|
#define ACCESS_ONCE(type,x) (*((volatile type *)&(x)))
|
|
|
|
|
2019-12-04 03:16:30 -05:00
|
|
|
#include "ruby/ruby.h"
|
|
|
|
|
2020-03-19 05:11:57 -04:00
|
|
|
/* Following macros were formerly defined in this header but moved to somewhere
|
2019-12-04 03:16:30 -05:00
|
|
|
* else. In order to detect them we undef here. */
|
|
|
|
|
2020-08-14 01:45:23 -04:00
|
|
|
/* internal/array.h */
|
|
|
|
#undef RARRAY_AREF
|
|
|
|
|
2019-12-04 03:16:30 -05:00
|
|
|
/* internal/class.h */
|
|
|
|
#undef RClass
|
|
|
|
#undef RCLASS_SUPER
|
|
|
|
|
|
|
|
/* internal/gc.h */
|
|
|
|
#undef NEWOBJ_OF
|
|
|
|
#undef RB_NEWOBJ_OF
|
|
|
|
#undef RB_OBJ_WRITE
|
|
|
|
|
|
|
|
/* internal/hash.h */
|
|
|
|
#undef RHASH_IFNONE
|
|
|
|
#undef RHASH_SIZE
|
2020-08-16 22:12:23 -04:00
|
|
|
#undef RHASH_TBL
|
2020-08-16 22:54:12 -04:00
|
|
|
#undef RHASH_EMPTY_P
|
2019-12-04 03:16:30 -05:00
|
|
|
|
2020-08-17 00:51:23 -04:00
|
|
|
/* internal/object.h */
|
|
|
|
#undef ROBJECT_IV_INDEX_TBL
|
|
|
|
|
2019-12-04 03:16:30 -05:00
|
|
|
/* internal/struct.h */
|
|
|
|
#undef RSTRUCT_LEN
|
|
|
|
#undef RSTRUCT_PTR
|
|
|
|
#undef RSTRUCT_SET
|
|
|
|
#undef RSTRUCT_GET
|
|
|
|
|
|
|
|
/* Also, we keep the following macros here. They are expected to be
|
|
|
|
* overridden in each headers. */
|
|
|
|
|
|
|
|
/* internal/array.h */
|
|
|
|
#define rb_ary_new_from_args(...) rb_nonexistent_symbol(__VA_ARGS__)
|
|
|
|
|
|
|
|
/* internal/io.h */
|
|
|
|
#define rb_io_fptr_finalize(...) rb_nonexistent_symbol(__VA_ARGS__)
|
|
|
|
|
|
|
|
/* internal/string.h */
|
|
|
|
#define rb_fstring_cstr(...) rb_nonexistent_symbol(__VA_ARGS__)
|
|
|
|
|
|
|
|
/* internal/symbol.h */
|
|
|
|
#define rb_sym_intern_ascii_cstr(...) rb_nonexistent_symbol(__VA_ARGS__)
|
|
|
|
|
|
|
|
/* internal/vm.h */
|
|
|
|
#define rb_funcallv(...) rb_nonexistent_symbol(__VA_ARGS__)
|
|
|
|
#define rb_method_basic_definition_p(...) rb_nonexistent_symbol(__VA_ARGS__)
|
2019-05-31 02:58:50 -04:00
|
|
|
|
2020-01-02 14:46:51 -05:00
|
|
|
|
|
|
|
/* MRI debug support */
|
|
|
|
|
|
|
|
/* gc.c */
|
|
|
|
void rb_obj_info_dump(VALUE obj);
|
|
|
|
void rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func);
|
|
|
|
|
|
|
|
/* debug.c */
|
2020-05-28 22:19:44 -04:00
|
|
|
|
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2020-01-02 14:46:51 -05:00
|
|
|
void ruby_debug_breakpoint(void);
|
|
|
|
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
|
2020-05-28 22:19:44 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2020-01-02 14:46:51 -05:00
|
|
|
|
|
|
|
// show obj data structure without any side-effect
|
2020-02-21 12:59:46 -05:00
|
|
|
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
|
2020-01-02 14:46:51 -05:00
|
|
|
|
|
|
|
// same as rp, but add message header
|
|
|
|
#define rp_m(msg, obj) do { \
|
2021-09-09 10:21:06 -04:00
|
|
|
fputs((msg), stderr); \
|
|
|
|
rb_obj_info_dump((VALUE)(obj)); \
|
2020-01-02 14:46:51 -05:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
// `ruby_debug_breakpoint()` does nothing,
|
|
|
|
// but breakpoint is set in run.gdb, so `make gdb` can stop here.
|
|
|
|
#define bp() ruby_debug_breakpoint()
|
|
|
|
|
2021-08-01 23:06:44 -04:00
|
|
|
#define RBOOL(v) ((v) ? Qtrue : Qfalse)
|
2021-09-03 07:50:12 -04:00
|
|
|
#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
|
2021-08-01 23:06:44 -04:00
|
|
|
|
2022-07-05 20:18:28 -04:00
|
|
|
#ifndef __MINGW32__
|
2022-07-07 10:48:22 -04:00
|
|
|
#undef memcpy
|
2022-07-05 20:18:28 -04:00
|
|
|
#define memcpy ruby_nonempty_memcpy
|
|
|
|
#endif
|
2011-05-18 09:41:54 -04:00
|
|
|
#endif /* RUBY_INTERNAL_H */
|