Merge pull request #11163 from NixOS/rejiggle-getGCCyles-buildNoGc

Rejiggle getGCCycles() for buildNoGc
This commit is contained in:
Eelco Dolstra 2024-07-23 17:17:47 +02:00 committed by GitHub
commit fb450de20e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 9 deletions

View file

@ -206,10 +206,17 @@ static inline void initGCReal()
} }
} }
static size_t gcCyclesAfterInit = 0;
size_t getGCCycles()
{
assertGCInitialized();
return static_cast<size_t>(GC_get_gc_no()) - gcCyclesAfterInit;
}
#endif #endif
static bool gcInitialised = false; static bool gcInitialised = false;
static GC_word gcCyclesAfterInit = 0;
void initGC() void initGC()
{ {
@ -218,10 +225,11 @@ void initGC()
#if HAVE_BOEHMGC #if HAVE_BOEHMGC
initGCReal(); initGCReal();
gcCyclesAfterInit = GC_get_gc_no();
#endif #endif
gcInitialised = true; gcInitialised = true;
gcCyclesAfterInit = GC_get_gc_no();
} }
void assertGCInitialized() void assertGCInitialized()
@ -229,10 +237,4 @@ void assertGCInitialized()
assert(gcInitialised); assert(gcInitialised);
} }
size_t getGCCycles()
{
assertGCInitialized();
return GC_get_gc_no() - gcCyclesAfterInit;
}
} // namespace nix } // namespace nix

View file

@ -15,9 +15,11 @@ void initGC();
*/ */
void assertGCInitialized(); void assertGCInitialized();
#ifdef HAVE_BOEHMGC
/** /**
* The number of GC cycles since initGC(). * The number of GC cycles since initGC().
*/ */
size_t getGCCycles(); size_t getGCCycles();
#endif
} } // namespace nix