1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

other minior internal header tweaks

These headers need no rewrite.  Just add some minor tweaks, like
addition of #include lines.  Mainly cosmetic.

TIMET_MAX_PLUS_ONE was deleted because the macro was used from only
one place (directly write expression there).
This commit is contained in:
卜部昌平 2019-12-03 14:47:38 +09:00
parent 3ae09b30f8
commit bf53d6c7d1
Notes: git 2019-12-26 20:45:56 +09:00
25 changed files with 76 additions and 32 deletions

View file

@ -9,6 +9,8 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for RUBY_INTEGER_UNIFICATION */
#include "internal/vm.h" /* for rb_method_basic_definition_p */
#define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)

View file

@ -9,6 +9,7 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for struct RBasic */
struct RComplex {
struct RBasic basic;
@ -19,8 +20,8 @@ struct RComplex {
#define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
/* shortcut macro for internal only */
#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &RCOMPLEX(cmp)->real, (r))
#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &RCOMPLEX(cmp)->imag, (i))
/* complex.c */
VALUE rb_dbl_complex_new_polar_pi(double abs, double ang);

View file

@ -9,8 +9,10 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for VALUE */
struct rb_thread_struct; /* in vm_core.h */
struct rb_thread_struct;
/* cont.c */
VALUE rb_obj_is_fiber(VALUE);
void rb_fiber_reset_root_local_storage(struct rb_thread_struct *);

View file

@ -9,11 +9,19 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/config.h"
#include <stdio.h> /* for fprintf */
#include "ruby/ruby.h" /* for VALUE */
/* 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 */
void ruby_debug_breakpoint(void);
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
// show obj data structure without any side-effect
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, __func__)
@ -28,7 +36,4 @@ void ruby_debug_breakpoint(void);
// but breakpoint is set in run.gdb, so `make gdb` can stop here.
#define bp() ruby_debug_breakpoint()
/* debug.c */
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
#endif /* INTERNAL_DEBUG_H */

View file

@ -9,6 +9,7 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for VALUE */
/* dir.c */
VALUE rb_dir_getwd_ospath(void);

View file

@ -9,16 +9,12 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/encoding.h" /* for rb_encoding */
/* us_ascii.c */
#ifdef RUBY_ENCODING_H
extern rb_encoding OnigEncodingUS_ASCII;
#endif
/* utf_8.c */
#ifdef RUBY_ENCODING_H
extern rb_encoding OnigEncodingUTF_8;
#endif
#endif /* INTERNAL_ENC_H */

View file

@ -9,13 +9,13 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for ID */
#include "ruby/encoding.h" /* for rb_encoding */
/* encoding.c */
ID rb_id_encoding(void);
#ifdef RUBY_ENCODING_H
rb_encoding *rb_enc_get_from_index(int index);
rb_encoding *rb_enc_check_str(VALUE str1, VALUE str2);
#endif
int rb_encdb_replicate(const char *alias, const char *orig);
int rb_encdb_alias(const char *alias, const char *orig);
int rb_encdb_dummy(const char *name);

View file

@ -9,6 +9,7 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for VALUE */
/* enum.c */
extern VALUE rb_cArithSeq;

View file

@ -9,6 +9,8 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for VALUE */
#include "ruby/intern.h" /* for rb_enumerator_size_func */
RUBY_SYMBOL_EXPORT_BEGIN
/* enumerator.c (export) */

View file

@ -11,13 +11,16 @@
* @note There also is eval_intern.h, which is evaluator's internal
* header (related to this file, but not the same role).
*/
#include "ruby/ruby.h" /* for ID */
/* eval.c */
VALUE rb_refinement_module_get_refined_class(VALUE module);
extern ID ruby_static_id_signo, ruby_static_id_status;
void rb_class_modify_check(VALUE);
#define id_signo ruby_static_id_signo
#define id_status ruby_static_id_status
/* eval.c */
extern ID ruby_static_id_signo;
extern ID ruby_static_id_status;
VALUE rb_refinement_module_get_refined_class(VALUE module);
void rb_class_modify_check(VALUE);
NORETURN(VALUE rb_f_raise(int argc, VALUE *argv));
/* eval_error.c */

View file

@ -9,15 +9,15 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for VALUE */
#include "ruby/encoding.h" /* for rb_encodinng */
/* file.c */
extern const char ruby_null_device[];
VALUE rb_home_dir_of(VALUE user, VALUE result);
VALUE rb_default_home_dir(VALUE result);
VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict);
#ifdef RUBY_ENCODING_H
VALUE rb_check_realpath(VALUE basedir, VALUE path, rb_encoding *origenc);
#endif
void rb_file_const(const char*, VALUE);
int rb_file_load_ok(const char *);
VALUE rb_file_expand_path_fast(VALUE, VALUE);
@ -28,7 +28,7 @@ int ruby_is_fd_loadable(int fd);
RUBY_SYMBOL_EXPORT_BEGIN
/* file.c (export) */
#if defined HAVE_READLINK && defined RUBY_ENCODING_H
#ifdef HAVE_READLINK
VALUE rb_readlink(VALUE path, rb_encoding *enc);
#endif
#ifdef __APPLE__

View file

@ -9,14 +9,14 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for VALUE */
#include "ruby/io.h" /* for rb_io_t */
/* io.c */
void ruby_set_inplace_mode(const char *);
void rb_stdio_set_default_encoding(void);
VALUE rb_io_flush_raw(VALUE, int);
#ifdef RUBY_IO_H
size_t rb_io_memsize(const rb_io_t *);
#endif
int rb_stderr_tty_p(void);
void rb_io_fptr_finalize_internal(void *ptr);
#define rb_io_fptr_finalize rb_io_fptr_finalize_internal

View file

@ -9,6 +9,7 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for VALUE */
/* load.c */
VALUE rb_get_expanded_load_path(void);

View file

@ -9,6 +9,7 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for VALUE */
/* math.c */
VALUE rb_math_atan2(VALUE, VALUE);

View file

@ -9,6 +9,7 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/config.h" /* for HAVE_SETPROCTITLE */
/* missing/setproctitle.c */
#ifndef HAVE_SETPROCTITLE

View file

@ -9,6 +9,8 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "internal/stdbool.h" /* for bool */
#include "ruby/ruby.h" /* for VALUE */
/* mjit.c */

View file

@ -9,15 +9,20 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/ruby.h" /* for VALUE */
#ifndef USE_SYMBOL_GC
# define USE_SYMBOL_GC 1
#endif
struct rb_iseq_struct; /* in vm_core.h */
/* parse.y */
#ifndef USE_SYMBOL_GC
#define USE_SYMBOL_GC 1
#endif
VALUE rb_parser_set_yydebug(VALUE, VALUE);
void *rb_parser_load_file(VALUE parser, VALUE name);
RUBY_SYMBOL_EXPORT_BEGIN
VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
RUBY_SYMBOL_EXPORT_END
void *rb_parser_load_file(VALUE parser, VALUE name);
#endif /* INTERNAL_PARSE_H */

View file

@ -9,6 +9,7 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include <stddef.h> /* for size_t */
/* random.c */
int ruby_fill_random_bytes(void *, size_t, int);

View file

@ -9,6 +9,8 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/config.h" /* for HAVE_LIBGMP */
#include "ruby/ruby.h" /* for struct RBasic */
struct RRational {
struct RBasic basic;
@ -17,8 +19,8 @@ struct RRational {
};
#define RRATIONAL(obj) (R_CAST(RRational)(obj))
#define RRATIONAL_SET_NUM(rat, n) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->num,(n))
#define RRATIONAL_SET_DEN(rat, d) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->den,(d))
#define RRATIONAL_SET_NUM(rat, n) RB_OBJ_WRITE((rat), &RRATIONAL(rat)->num, (n))
#define RRATIONAL_SET_DEN(rat, d) RB_OBJ_WRITE((rat), &RRATIONAL(rat)->den, (d))
/* rational.c */
VALUE rb_rational_canonicalize(VALUE x);

View file

@ -9,6 +9,8 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "internal/stdbool.h" /* for bool */
#include "ruby/ruby.h" /* for VALUE */
/* re.c */
VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
@ -20,6 +22,8 @@ void rb_backref_set_string(VALUE string, long pos, long len);
void rb_match_unbusy(VALUE);
int rb_match_count(VALUE match);
int rb_match_nth_defined(int nth, VALUE match);
MJIT_SYMBOL_EXPORT_BEGIN
VALUE rb_reg_new_ary(VALUE ary, int options);
MJIT_SYMBOL_EXPORT_END
#endif /* INTERNAL_RE_H */

View file

@ -9,6 +9,8 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/config.h" /* for HAVE_LONG_LONG */
#include "ruby/defines.h" /* for LONG_LONG */
#ifndef HAVE_LONG_LONG
# error need C99+

View file

@ -9,6 +9,9 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/config.h" /* for SIGNEDNESS_OF_TIME_T */
#include "internal/bits.h" /* for SIGNED_INTEGER_MAX */
#include "ruby/ruby.h" /* for VALUE */
#if SIGNEDNESS_OF_TIME_T < 0 /* signed */
# define TIMET_MAX SIGNED_INTEGER_MAX(time_t)
@ -17,7 +20,8 @@
# define TIMET_MAX UNSIGNED_INTEGER_MAX(time_t)
# define TIMET_MIN ((time_t)0)
#endif
#define TIMET_MAX_PLUS_ONE (2*(double)(TIMET_MAX/2+1))
struct timeval; /* <- in <sys/time.h> or <winsock2.h> */
/* time.c */
struct timeval rb_time_timeval(VALUE);

View file

@ -9,11 +9,13 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
#include "ruby/config.h"
#include <stddef.h> /* for size_t */
#include "ruby/ruby.h" /* for VALUE */
#include "ruby/encoding.h" /* for rb_econv_t */
/* transcode.c */
extern VALUE rb_cEncodingConverter;
#ifdef RUBY_ENCODING_H
size_t rb_econv_memsize(rb_econv_t *);
#endif
#endif /* INTERNAL_TRANSCODE_H */

View file

@ -10,6 +10,12 @@
* file COPYING are met. Consult the file for details.
* @warning DO NOT ADD RANDOM GARBAGE HERE THIS FILE IS FOR util.c
*/
#include "ruby/config.h"
#include <stddef.h> /* for size_t */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h> /* for ssize_t (note: on Windows ssize_t is */
#endif /* `#define`d in ruby/config.h) */
/* util.c */
char *ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve);

View file

@ -1196,7 +1196,7 @@ static rb_hrtime_t *
double2hrtime(rb_hrtime_t *hrt, double d)
{
/* assume timespec.tv_sec has same signedness as time_t */
const double TIMESPEC_SEC_MAX_PLUS_ONE = TIMET_MAX_PLUS_ONE;
const double TIMESPEC_SEC_MAX_PLUS_ONE = 2.0 * (TIMESPEC_SEC_MAX / 2 + 1.0);
if (TIMESPEC_SEC_MAX_PLUS_ONE <= d) {
return NULL;