summaryrefslogtreecommitdiff
path: root/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'internal.h')
-rw-r--r--internal.h158
1 files changed, 87 insertions, 71 deletions
diff --git a/internal.h b/internal.h
index fa6f78b52f..002044cfa1 100644
--- a/internal.h
+++ b/internal.h
@@ -1,34 +1,23 @@
-/**********************************************************************
-
- internal.h -
-
- $Author$
- created at: Tue May 17 11:42:20 JST 2011
-
- Copyright (C) 2011 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#ifndef RUBY_INTERNAL_H
+#ifndef RUBY_INTERNAL_H /*-*-C-*-vi:se ft=c:*/
#define RUBY_INTERNAL_H 1
-
-#include "ruby/config.h"
+/**
+ * @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.
+ */
+#include "ruby/internal/config.h"
#ifdef __cplusplus
# error not for C++
#endif
-#include "ruby/encoding.h"
-#include "ruby/io.h"
-#include "internal/stdbool.h"
-#include "internal/bits.h"
-
#define LIKELY(x) RB_LIKELY(x)
#define UNLIKELY(x) RB_UNLIKELY(x)
-#include "internal/compilers.h"
-#include "internal/sanitizers.h"
-
#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
#define roomof(x, y) (((x) + (y) - 1) / (y))
#define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
@@ -36,54 +25,81 @@
/* Prevent compiler from reordering access */
#define ACCESS_ONCE(type,x) (*((volatile type *)&(x)))
-#include "internal/serial.h"
-#include "internal/static_assert.h"
-#include "internal/time.h"
-#include "internal/fixnum.h"
-#include "internal/bignum.h"
-#include "internal/rational.h"
-#include "internal/numeric.h"
-#include "internal/complex.h"
-#include "internal/hash.h"
-#include "internal/missing.h"
-#include "internal/struct.h"
-#include "internal/class.h"
-#include "internal/imemo.h"
-#include "internal/compar.h"
-#include "internal/variable.h"
-#include "internal/array.h"
-#include "internal/debug.h"
-#include "internal/compile.h"
-#include "internal/cont.h"
-#include "internal/dir.h"
-#include "internal/encoding.h"
-#include "internal/enum.h"
-#include "internal/eval.h"
-#include "internal/error.h"
-#include "internal/file.h"
-#include "internal/gc.h"
-#include "internal/io.h"
-#include "internal/load.h"
-#include "internal/loadpath.h"
-#include "internal/math.h"
-#include "internal/mjit.h"
-#include "internal/object.h"
-#include "internal/parse.h"
-#include "internal/proc.h"
-#include "internal/process.h"
-#include "internal/range.h"
-#include "internal/re.h"
-#include "internal/signal.h"
-#include "internal/string.h"
-#include "internal/symbol.h"
-#include "internal/thread.h"
-#include "internal/transcode.h"
-#include "internal/enc.h"
-#include "internal/util.h"
-#include "internal/vm.h"
-#include "internal/enumerator.h"
-#include "internal/random.h"
-#include "internal/inits.h"
-#include "internal/warnings.h"
+#define UNDEF_P RB_UNDEF_P
+#define NIL_OR_UNDEF_P RB_NIL_OR_UNDEF_P
+
+#include "ruby/ruby.h"
+
+/* Following macros were formerly defined in this header but moved to somewhere
+ * else. In order to detect them we undef here. */
+
+/* internal/array.h */
+#undef RARRAY_AREF
+
+/* internal/class.h */
+#undef RClass
+#undef RCLASS_SUPER
+
+/* internal/hash.h */
+#undef RHASH_IFNONE
+#undef RHASH_SIZE
+#undef RHASH_TBL
+#undef RHASH_EMPTY_P
+
+/* 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/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__)
+
+
+/* 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 */
+
+RUBY_SYMBOL_EXPORT_BEGIN
+void ruby_debug_breakpoint(void);
+PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
+RUBY_SYMBOL_EXPORT_END
+
+// show obj data structure without any side-effect
+#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
+
+// same as rp, but add message header
+#define rp_m(msg, obj) do { \
+ fputs((msg), stderr); \
+ rb_obj_info_dump((VALUE)(obj)); \
+} 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()
+
+#define RBOOL(v) ((v) ? Qtrue : Qfalse)
+#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
+
+#ifndef __MINGW32__
+#undef memcpy
+#define memcpy ruby_nonempty_memcpy
+#endif
#endif /* RUBY_INTERNAL_H */