Make rb_gc_impl_stat return a VALUE instead of size_t

This commit is contained in:
Peter Zhu 2024-10-22 10:46:46 -04:00
Родитель c2af84b244
Коммит 9dea0fae25
3 изменённых файлов: 6 добавлений и 13 удалений

11
gc.c
Просмотреть файл

@ -634,7 +634,7 @@ typedef struct gc_function_map {
unsigned long long (*get_total_time)(void *objspace_ptr);
size_t (*gc_count)(void *objspace_ptr);
VALUE (*latest_gc_info)(void *objspace_ptr, VALUE key);
size_t (*stat)(void *objspace_ptr, VALUE hash_or_sym);
VALUE (*stat)(void *objspace_ptr, VALUE hash_or_sym);
size_t (*stat_heap)(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym);
// Miscellaneous
size_t (*obj_flags)(void *objspace_ptr, VALUE obj, ID* flags, size_t max);
@ -3417,14 +3417,7 @@ gc_stat(rb_execution_context_t *ec, VALUE self, VALUE arg) // arg is (nil || has
arg = rb_hash_new();
}
size_t val = rb_gc_impl_stat(rb_gc_get_objspace(), arg);
if (SYMBOL_P(arg)) {
return SIZET2NUM(val);
}
else {
return arg;
}
return rb_gc_impl_stat(rb_gc_get_objspace(), arg);
}
size_t

Просмотреть файл

@ -7497,7 +7497,7 @@ ns_to_ms(uint64_t ns)
return ns / (1000 * 1000);
}
size_t
VALUE
rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym)
{
rb_objspace_t *objspace = objspace_ptr;
@ -7517,7 +7517,7 @@ rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym)
#define SET(name, attr) \
if (key == gc_stat_symbols[gc_stat_sym_##name]) \
return attr; \
return SIZET2NUM(attr); \
else if (hash != Qnil) \
rb_hash_aset(hash, gc_stat_symbols[gc_stat_sym_##name], SIZET2NUM(attr));
@ -7581,7 +7581,7 @@ rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym)
}
#endif
return 0;
return hash;
}
enum gc_stat_heap_sym {

Просмотреть файл

@ -89,7 +89,7 @@ GC_IMPL_FN bool rb_gc_impl_get_measure_total_time(void *objspace_ptr);
GC_IMPL_FN unsigned long long rb_gc_impl_get_total_time(void *objspace_ptr);
GC_IMPL_FN size_t rb_gc_impl_gc_count(void *objspace_ptr);
GC_IMPL_FN VALUE rb_gc_impl_latest_gc_info(void *objspace_ptr, VALUE key);
GC_IMPL_FN size_t rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym);
GC_IMPL_FN VALUE rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym);
GC_IMPL_FN size_t rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym);
// Miscellaneous
GC_IMPL_FN size_t rb_gc_impl_obj_flags(void *objspace_ptr, VALUE obj, ID* flags, size_t max);