Project

General

Profile

Bug #19425

Updated by eightbitraptor (Matthew Valentine-House) over 1 year ago

Github PR: [7273](https://github.com/ruby/ruby/pull/7273) 

 Currently we have 4 headers named `gc.h` 

 * `gc.h` 
 * `internal/gc.h` 
 * `include/ruby/internal/gc.h` 
 * `include/ruby/internal/intern/gc.h` 

 The first two are private and internal to the CRuby codebase, the latter 2 are visible to C extensions. [This PR](https://github.com/ruby/ruby/pull/7273) attempts to merge the two internal headers `gc.h` and `internal/gc.h` internal/gc.h` into a single header `internal/gc.h` in order to simplify the codebase and put all the gc related interface in a single place. 

 Here is the history of the 2 internal only `gc.h` headers as I've been able to understand from the commit logs: 

 * `gc.h` was created as part of the YARV merge in 2006, it contained only some `defines` for debug related macros. 
 * In 2010 some function declarations were added to it to expose some functionality (`rb_objspace_each_objects`) to the `objspace` extension 
 * In May 2011 `internal.h` was created as a place to put shared, but internal only declarations. 
 * In June 2011 GC related functions started being committed to `internal.h` 
 * In 2019 `internal.h` was refactored and `internal/gc.h` was created 

 As of 2023 internally used code continues to be added to both `gc.h` and `internal/gc.h`, which one is chosen in any particular circumstance seems to be whichever header is already being included for legacy reasons in the `.c` file being edited. 

 I'd like to merge these two files together in order to reduce the cognitive overhead of working on the GC. Am I missing something - are there good reasons why these files should remain separate?

Back