FreeBSD/usr.sbin/pmcstat/pmcpl_gprof.c
/*
 * Mmap in a gmon.out file for processing.
 */
Mmap in a gmon.out file for processing.
Mmap in a gmon . out file for processing .
static void
pmcstat_gmon_map_file(struct pmcstat_gmonfile *pgf)
{
	int fd;
	const char *pathname;
	pathname = pmcstat_string_unintern(pgf->pgf_name);
	if ((fd = open(pathname, O_RDWR | O_NOFOLLOW, 0)) < 0)
		err(EX_OSERR, "ERROR: cannot open \"%s\"", pathname);
	pgf->pgf_gmondata = mmap(NULL, pgf->pgf_ndatabytes,
	    PROT_READ|PROT_WRITE, MAP_NOSYNC|MAP_SHARED, fd, 0);
	if (pgf->pgf_gmondata == MAP_FAILED)
		err(EX_OSERR, "ERROR: cannot map \"%s\"", pathname);
	(void) close(fd);
}
static void pmcstat_gmon_map_file ( struct pmcstat_gmonfile * pgf ) { int fd ; const char * pathname ; pathname = pmcstat_string_unintern ( pgf -> pgf_name ) ; if ( ( fd = open ( pathname , O_RDWR | O_NOFOLLOW , 0 ) ) < 0 ) err ( EX_OSERR , " \" \" " , pathname ) ; pgf -> pgf_gmondata = mmap ( NULL , pgf -> pgf_ndatabytes , PROT_READ | PROT_WRITE , MAP_NOSYNC | MAP_SHARED , fd , 0 ) ; if ( pgf -> pgf_gmondata == MAP_FAILED ) err ( EX_OSERR , " \" \" " , pathname ) ; ( void ) close ( fd ) ; }
Mmap in a gmon.out file for processing.
Mmap in a gmon . out file for processing .
/* the gmon.out file must already exist */