sc-virt/src/projects/compiler-rt/lib/profile/InstrProfilingFile.c
static FILE *openFileForMerging(const char *ProfileFileName) {
  FILE *ProfileFile;
  int rc;

  ProfileFile = lprofOpenFileEx(ProfileFileName);
  if (!ProfileFile)
    return NULL;

  rc = doProfileMerging(ProfileFile);
  if (rc || COMPILER_RT_FTRUNCATE(ProfileFile, 0L) ||
      fseek(ProfileFile, 0L, SEEK_SET) == -1) {
    PROF_ERR("Profile Merging of file %s failed: %s\n", ProfileFileName,
             strerror(errno));
    fclose(ProfileFile);
    return NULL;
  }
  fseek(ProfileFile, 0L, SEEK_SET);
  return ProfileFile;
}
/* Open the profile data for merging. It opens the file in r+b mode with
 * file locking.  If the file has content which is compatible with the
 * current process, it also reads in the profile data in the file and merge
 * it with in-memory counters. After the profile data is merged in memory,
 * the original profile data is truncated and gets ready for the profile
 * dumper. With profile merging enabled, each executable as well as any of
 * its instrumented shared libraries dump profile data into their own data file.
*/
Open the profile data for merging. It opens the file in r+b mode with
file locking.  If the file has content which is compatible with the
current process, it also reads in the profile data in the file and merge
it with in-memory counters. After the profile data is merged in memory,
the original profile data is truncated and gets ready for the profile
dumper. With profile merging enabled, each executable as well as any of
its instrumented shared libraries dump profile data into their own data file.
Open the profile data for merging . It opens the file in r + b mode with file locking . If the file has content which is compatible with the current process it also reads in the profile data in the file and merge it with in - memory counters . After the profile data is merged in memory the original profile data is truncated and gets ready for the profile dumper . With profile merging enabled each executable as well as any of its instrumented shared libraries dump profile data into their own data file .
static FILE *openFileForMerging(const char *ProfileFileName) {
  FILE *ProfileFile;
  int rc;
  ProfileFile = lprofOpenFileEx(ProfileFileName);
  if (!ProfileFile)
    return NULL;
  rc = doProfileMerging(ProfileFile);
  if (rc || COMPILER_RT_FTRUNCATE(ProfileFile, 0L) ||
      fseek(ProfileFile, 0L, SEEK_SET) == -1) {
    PROF_ERR("Profile Merging of file %s failed: %s\n", ProfileFileName,
             strerror(errno));
    fclose(ProfileFile);
    return NULL;
  }
  fseek(ProfileFile, 0L, SEEK_SET);
  return ProfileFile;
}
static FILE * openFileForMerging ( const char * ProfileFileName ) { FILE * ProfileFile ; int rc ; ProfileFile = lprofOpenFileEx ( ProfileFileName ) ; if ( ! ProfileFile ) return NULL ; rc = doProfileMerging ( ProfileFile ) ; if ( rc || COMPILER_RT_FTRUNCATE ( ProfileFile , 0L ) || fseek ( ProfileFile , 0L , SEEK_SET ) == -1 ) { PROF_ERR ( " \n " , ProfileFileName , strerror ( errno ) ) ; fclose ( ProfileFile ) ; return NULL ; } fseek ( ProfileFile , 0L , SEEK_SET ) ; return ProfileFile ; }
Open the profile data for merging.
Open the profile data for merging .