Skip to content

Commit 2fe8498

Browse files
committed
mmapForContinuousMode: Redo #95702: Align Linux's impl to __APPLE__'s a little.
I've made this small cosmetic changes, `s/CountersOffsetInBiasMode/FileOffsetToCounters/`
1 parent aafa0ef commit 2fe8498

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

compiler-rt/lib/profile/InstrProfilingFile.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,20 @@ static int mmapForContinuousMode(uint64_t CurrentFileOffset, FILE *File) {
243243
if (getProfileFileSizeForMerging(File, &FileSize))
244244
return 1;
245245

246+
int Fileno = fileno(File);
247+
uint64_t FileOffsetToCounters =
248+
sizeof(__llvm_profile_header) + __llvm_write_binary_ids(NULL) + DataSize;
249+
246250
/* Map the profile. */
247251
char *Profile = (char *)mmap(NULL, FileSize, PROT_READ | PROT_WRITE,
248-
MAP_SHARED, fileno(File), 0);
252+
MAP_SHARED, Fileno, 0);
249253
if (Profile == MAP_FAILED) {
250254
PROF_ERR("Unable to mmap profile: %s\n", strerror(errno));
251255
return 1;
252256
}
253-
const uint64_t CountersOffsetInBiasMode =
254-
sizeof(__llvm_profile_header) + __llvm_write_binary_ids(NULL) + DataSize;
255257
/* Update the profile fields based on the current mapping. */
256258
INSTR_PROF_PROFILE_COUNTER_BIAS_VAR =
257-
(intptr_t)Profile - (uintptr_t)CountersBegin + CountersOffsetInBiasMode;
259+
(intptr_t)Profile - (uintptr_t)CountersBegin + FileOffsetToCounters;
258260

259261
/* Return the memory allocated for counters to OS. */
260262
lprofReleaseMemoryPagesToOS((uintptr_t)CountersBegin, (uintptr_t)CountersEnd);

0 commit comments

Comments
 (0)