Skip to content

Commit

Permalink
* internal.h: Gather declarations in non-header files.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
akr committed Nov 18, 2014
1 parent cebd7ec commit 2b9191e
Show file tree
Hide file tree
Showing 20 changed files with 62 additions and 55 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Tue Nov 18 23:23:45 2014 Tanaka Akira <[email protected]>

* internal.h: Gather declarations in non-header files.

Tue Nov 18 23:45:52 2014 Tanaka Akira <[email protected]>

* debug.c (SET_WHEN): Don't declare debug variables here.
Expand Down
4 changes: 0 additions & 4 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
#include "vm_core.h"
#include <ctype.h>

int rb_vm_add_root_module(ID id, VALUE module);


#define id_attached id__attached__

void
Expand Down Expand Up @@ -939,7 +936,6 @@ move_refined_method(st_data_t key, st_data_t value, st_data_t data)
void
rb_prepend_module(VALUE klass, VALUE module)
{
void rb_vm_check_redefinition_by_prepend(VALUE klass);
VALUE origin;
int changed = 0;

Expand Down
2 changes: 0 additions & 2 deletions complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1633,8 +1633,6 @@ isimagunit(int c)
c == 'j' || c == 'J');
}

VALUE rb_cstr_to_rat(const char *, int);

static VALUE
str2num(char *s)
{
Expand Down
7 changes: 0 additions & 7 deletions enc/encdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
**********************************************************************/

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);
void rb_encdb_declare(const char *name);
void rb_enc_set_base(const char *name, const char *orig);
int rb_enc_set_dummy(int index);
void rb_encdb_set_unicode(int index);
#define ENC_REPLICATE(name, orig) rb_encdb_replicate((name), (orig))
#define ENC_ALIAS(name, orig) rb_encdb_alias((name), (orig))
#define ENC_DUMMY(name) rb_encdb_dummy(name)
Expand Down
5 changes: 0 additions & 5 deletions encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,6 @@ rb_encdb_set_unicode(int index)
((rb_raw_encoding *)rb_enc_from_index(index))->flags |= ONIGENC_FLAG_UNICODE;
}

extern rb_encoding OnigEncodingUTF_8;
extern rb_encoding OnigEncodingUS_ASCII;

void
rb_enc_init(void)
{
Expand Down Expand Up @@ -1334,8 +1331,6 @@ struct default_encoding {

static struct default_encoding default_external = {0};

extern int Init_enc_set_filesystem_encoding(void);

static int
enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const char *name)
{
Expand Down
2 changes: 0 additions & 2 deletions enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include "node.h"
#include "id.h"

VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);

VALUE rb_mEnumerable;

static ID id_next;
Expand Down
3 changes: 0 additions & 3 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
if (NIL_P(rb_attr_get(mesg, idBt))) {
at = rb_vm_backtrace_object();
if (mesg == sysstack_error) {
VALUE ruby_vm_sysstack_error_copy(void);
mesg = ruby_vm_sysstack_error_copy();
}
rb_ivar_set(mesg, idBt, at);
Expand Down Expand Up @@ -1264,8 +1263,6 @@ add_activated_refinement(VALUE activated_refinements,
rb_hash_aset(activated_refinements, klass, iclass);
}

VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);

/*
* call-seq:
* refine(klass) { block } -> module
Expand Down
4 changes: 0 additions & 4 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2803,10 +2803,6 @@ rb_obj_id(VALUE obj)
return nonspecial_obj_id(obj);
}

size_t rb_str_memsize(VALUE);
size_t rb_ary_memsize(VALUE);
size_t rb_io_memsize(const rb_io_t *);
size_t rb_generic_ivar_memsize(VALUE);
#include "regint.h"

static size_t
Expand Down
1 change: 0 additions & 1 deletion hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ static const struct st_hash_type objhash = {
rb_any_hash,
};

extern const struct st_hash_type st_hashtype_num;
#define identhash st_hashtype_num

typedef int st_foreach_func(st_data_t, st_data_t, st_data_t);
Expand Down
58 changes: 58 additions & 0 deletions internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "ruby.h"
#include "ruby/encoding.h"
#include "ruby/io.h"

#if defined(__cplusplus)
extern "C" {
Expand Down Expand Up @@ -516,6 +517,7 @@ VALUE rb_ary_last(int, const VALUE *, VALUE);
void rb_ary_set_len(VALUE, long);
void rb_ary_delete_same(VALUE, VALUE);
VALUE rb_ary_tmp_new_fill(long capa);
size_t rb_ary_memsize(VALUE);
#ifdef __GNUC__
#define rb_ary_new_from_args(n, ...) \
__extension__ ({ \
Expand All @@ -528,6 +530,7 @@ VALUE rb_ary_tmp_new_fill(long capa);
#endif

/* bignum.c */
extern const char ruby_digitmap[];
VALUE rb_big_fdiv(VALUE x, VALUE y);
VALUE rb_big_uminus(VALUE x);
VALUE rb_integer_float_cmp(VALUE x, VALUE y);
Expand Down Expand Up @@ -568,6 +571,7 @@ void ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(ANYARGS), VALUE
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);

/* dmyext.c */
void Init_enc(void);
void Init_ext(void);

/* encoding.c */
Expand Down Expand Up @@ -597,8 +601,22 @@ enum ruby_preserved_encindex {
#define rb_usascii_encindex() ENCINDEX_US_ASCII
ID rb_id_encoding(void);
void rb_gc_mark_encodings(void);
rb_encoding *rb_enc_get_from_index(int index);
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);
void rb_encdb_declare(const char *name);
void rb_enc_set_base(const char *name, const char *orig);
int rb_enc_set_dummy(int index);
void rb_encdb_set_unicode(int index);

/* enum.c */
VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);

/* error.c */
extern VALUE rb_eEAGAIN;
extern VALUE rb_eEWOULDBLOCK;
extern VALUE rb_eEINPROGRESS;
NORETURN(PRINTF_ARGS(void rb_compile_bug(const char*, int, const char*, ...), 3, 4));
VALUE rb_check_backtrace(VALUE);
NORETURN(void rb_async_bug_errno(const char *,int));
Expand Down Expand Up @@ -646,6 +664,7 @@ NORETURN(void rb_syserr_fail_path_in(const char *func_name, int err, VALUE path)

/* gc.c */
extern VALUE *ruby_initial_gc_stress_ptr;
extern int ruby_disable_gc;
void Init_heap(void);
void *ruby_mimmalloc(size_t size);
void ruby_mimfree(void *ptr);
Expand All @@ -656,6 +675,7 @@ void rb_gc_writebarrier_remember(VALUE obj);
#define rb_gc_writebarrier_remember(obj) 0
#endif
void ruby_gc_set_params(int safe_level);
void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);

#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
#define ruby_sized_xrealloc(ptr, new_size, old_size) ruby_xrealloc(ptr, new_size)
Expand All @@ -675,6 +695,7 @@ void rb_gc_resurrect(VALUE ptr);
struct st_table *rb_hash_tbl_raw(VALUE hash);
VALUE rb_hash_has_key(VALUE hash, VALUE key);
VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
long rb_objid_hash(st_index_t index);

#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
VALUE rb_hash_keys(VALUE hash);
Expand All @@ -692,6 +713,7 @@ ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
void rb_stdio_set_default_encoding(void);
void rb_write_error_str(VALUE mesg);
VALUE rb_io_flush_raw(VALUE, int);
size_t rb_io_memsize(const rb_io_t *);

/* iseq.c */
VALUE rb_iseq_clone(VALUE iseqval, VALUE newcbase);
Expand All @@ -708,6 +730,13 @@ VALUE rb_get_load_path(void);
VALUE rb_get_expanded_load_path(void);
NORETURN(void rb_load_fail(VALUE, const char*));

/* loadpath.c */
extern const char ruby_exec_prefix[];
extern const char ruby_initial_load_paths[];

/* localeinit.c */
int Init_enc_set_filesystem_encoding(void);

/* math.c */
VALUE rb_math_atan2(VALUE, VALUE);
VALUE rb_math_cos(VALUE);
Expand Down Expand Up @@ -904,6 +933,7 @@ void rb_last_status_clear(void);
/* rational.c */
VALUE rb_lcm(VALUE x, VALUE y);
VALUE rb_rational_reciprocal(VALUE x);
VALUE rb_cstr_to_rat(const char *, int);

/* re.c */
VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
Expand All @@ -916,6 +946,9 @@ extern int ruby_enable_coredump;
int rb_get_next_signal(void);
int rb_sigaltstack_size(void);

/* st.c */
extern const struct st_hash_type st_hashtype_num;

/* strftime.c */
#ifdef RUBY_ENCODING_H
size_t rb_strftime_timespec(char *s, size_t maxsize, const char *format, rb_encoding *enc,
Expand Down Expand Up @@ -945,6 +978,7 @@ VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
#define STR_SHARED_P(s) FL_ALL((s), STR_NOEMBED|ELTS_SHARED)
#define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
#define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
size_t rb_str_memsize(VALUE);

/* struct.c */
VALUE rb_struct_init_copy(VALUE copy, VALUE s);
Expand All @@ -970,6 +1004,26 @@ void ruby_kill(rb_pid_t pid, int sig);
/* thread_pthread.c, thread_win32.c */
void Init_native_thread(void);

/* transcode.c */
extern VALUE rb_cEncodingConverter;
size_t rb_econv_memsize(rb_econv_t *);

/* us_ascii.c */
extern rb_encoding OnigEncodingUS_ASCII;

/* util.c */
char *ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve);
char *ruby_hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rve);

/* utf_8.c */
extern rb_encoding OnigEncodingUTF_8;

/* variable.c */
size_t rb_generic_ivar_memsize(VALUE);

/* version.c */
extern VALUE ruby_engine_name;

/* vm_insnhelper.h */
rb_serial_t rb_next_class_serial(void);

Expand All @@ -986,6 +1040,10 @@ void rb_thread_mark(void *th);
const void **rb_vm_get_insns_address_table(void);
VALUE rb_sourcefilename(void);
void rb_vm_pop_cfunc_frame(void);
int rb_vm_add_root_module(ID id, VALUE module);
void rb_vm_check_redefinition_by_prepend(VALUE klass);
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
VALUE ruby_vm_sysstack_error_copy(void);

/* vm_dump.c */
void rb_print_backtrace(void);
Expand Down
5 changes: 0 additions & 5 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ VALUE rb_eEOFError;
VALUE rb_eIOError;
VALUE rb_mWaitReadable;
VALUE rb_mWaitWritable;
extern VALUE rb_eEAGAIN;
extern VALUE rb_eEWOULDBLOCK;
extern VALUE rb_eEINPROGRESS;

static VALUE rb_eEAGAINWaitReadable;
static VALUE rb_eEAGAINWaitWritable;
Expand Down Expand Up @@ -4361,8 +4358,6 @@ rb_io_fptr_finalize(rb_io_t *fptr)
return 1;
}

size_t rb_econv_memsize(rb_econv_t *);

RUBY_FUNC_EXPORTED size_t
rb_io_memsize(const rb_io_t *fptr)
{
Expand Down
1 change: 0 additions & 1 deletion marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ load_mantissa(double d, const char *buf, long len)
static void
w_float(double d, struct dump_arg *arg)
{
char *ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve);
char buf[FLOAT_DIG + (DECIMAL_MANT + 7) / 8 + 10];

if (isinf(d)) {
Expand Down
2 changes: 0 additions & 2 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ rb_float_new_in_heap(double d)
static VALUE
flo_to_s(VALUE flt)
{
char *ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve);
enum {decimal_mant = DBL_MANT_DIG-DBL_DIG};
enum {float_dig = DBL_DIG+1};
char buf[float_dig + (decimal_mant + CHAR_BIT - 1) / CHAR_BIT + 10];
Expand Down Expand Up @@ -2776,7 +2775,6 @@ fix_uminus(VALUE num)
VALUE
rb_fix2str(VALUE x, int base)
{
extern const char ruby_digitmap[];
char buf[SIZEOF_VALUE*CHAR_BIT + 2], *b = buf + sizeof buf;
long val = FIX2LONG(x);
int neg = 0;
Expand Down
3 changes: 0 additions & 3 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ rb_obj_equal(VALUE obj1, VALUE obj2)
VALUE
rb_obj_hash(VALUE obj)
{
long rb_objid_hash(st_index_t index);
VALUE oid = rb_obj_id(obj);
#if SIZEOF_LONG == SIZEOF_VOIDP
st_index_t index = NUM2LONG(oid);
Expand Down Expand Up @@ -279,8 +278,6 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
}
}

void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);

static void
init_copy(VALUE dest, VALUE obj)
{
Expand Down
5 changes: 0 additions & 5 deletions ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ ruby_init_loadpath_safe(int safe_level)
{
VALUE load_path;
ID id_initial_load_path_mark;
extern const char ruby_initial_load_paths[];
const char *paths = ruby_initial_load_paths;
#if defined LOAD_RELATIVE
# if defined HAVE_DLADDR || defined __CYGWIN__ || defined _WIN32
Expand Down Expand Up @@ -453,7 +452,6 @@ ruby_init_loadpath_safe(int safe_level)

#define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), (path), (len))
#else
extern const char ruby_exec_prefix[];
const size_t exec_prefix_len = strlen(ruby_exec_prefix);
#define RUBY_RELATIVE(path, len) rubylib_path_new((path), (len))
#define PREFIX_PATH() RUBY_RELATIVE(ruby_exec_prefix, exec_prefix_len)
Expand Down Expand Up @@ -1249,9 +1247,6 @@ rb_f_chomp(int argc, VALUE *argv)
return str;
}

/* blank function in dmyext.c or generated by enc/make_encmake.rb */
extern void Init_enc(void);

static VALUE
process_options(int argc, char **argv, struct cmdline_options *opt)
{
Expand Down
2 changes: 0 additions & 2 deletions signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,6 @@ ruby_abort(void)

}

extern int ruby_disable_gc;

#ifdef SIGSEGV
static RETSIGTYPE
sigsegv(int sig SIGINFO_ARG)
Expand Down
2 changes: 0 additions & 2 deletions sprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */

extern const char ruby_digitmap[];

static void fmt_setup(char*,size_t,int,int,int,int);

static char
Expand Down
3 changes: 0 additions & 3 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ VALUE rb_cSymbol;
#define SHARABLE_SUBSTRING_P(beg, len, end) 1
#endif

rb_encoding *rb_enc_get_from_index(int index);

static rb_encoding *
get_actual_encoding(const int encidx, VALUE str)
{
Expand Down Expand Up @@ -720,7 +718,6 @@ rb_tainted_str_new_cstr(const char *ptr)
VALUE
rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
{
extern VALUE rb_cEncodingConverter;
rb_econv_t *ec;
rb_econv_result_t ret;
long len, olen;
Expand Down
Loading

0 comments on commit 2b9191e

Please sign in to comment.