(gp)
| 311 | */ |
| 312 | |
| 313 | void |
| 314 | startguprof(gp) |
| 315 | struct gmonparam *gp; |
| 316 | { |
| 317 | #if defined(I586_CPU) || defined(I686_CPU) |
| 318 | uint64_t freq; |
| 319 | |
| 320 | freq = atomic_load_acq_64(&tsc_freq); |
| 321 | if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) { |
| 322 | if (freq != 0 && mp_ncpus == 1) |
| 323 | cputime_clock = CPUTIME_CLOCK_TSC; |
| 324 | else |
| 325 | cputime_clock = CPUTIME_CLOCK_I8254; |
| 326 | } |
| 327 | if (cputime_clock == CPUTIME_CLOCK_TSC) { |
| 328 | gp->profrate = freq >> 1; |
| 329 | cputime_prof_active = 1; |
| 330 | } else |
| 331 | gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT; |
| 332 | #if defined(PERFMON) && defined(I586_PMC_GUPROF) |
| 333 | if (cputime_clock == CPUTIME_CLOCK_I586_PMC) { |
| 334 | if (perfmon_avail() && |
| 335 | perfmon_setup(0, cputime_clock_pmc_conf) == 0) { |
| 336 | if (perfmon_start(0) != 0) |
| 337 | perfmon_fini(0); |
| 338 | else { |
| 339 | /* XXX 1 event == 1 us. */ |
| 340 | gp->profrate = 1000000; |
| 341 | |
| 342 | saved_gmp = *gp; |
| 343 | |
| 344 | /* Zap overheads. They are invalid. */ |
| 345 | gp->cputime_overhead = 0; |
| 346 | gp->mcount_overhead = 0; |
| 347 | gp->mcount_post_overhead = 0; |
| 348 | gp->mcount_pre_overhead = 0; |
| 349 | gp->mexitcount_overhead = 0; |
| 350 | gp->mexitcount_post_overhead = 0; |
| 351 | gp->mexitcount_pre_overhead = 0; |
| 352 | |
| 353 | cputime_clock_pmc_init = TRUE; |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | #endif /* PERFMON && I586_PMC_GUPROF */ |
| 358 | #else /* !(I586_CPU || I686_CPU) */ |
| 359 | if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) |
| 360 | cputime_clock = CPUTIME_CLOCK_I8254; |
| 361 | gp->profrate = i8254_freq << CPUTIME_CLOCK_I8254_SHIFT; |
| 362 | #endif /* I586_CPU || I686_CPU */ |
| 363 | cputime_bias = 0; |
| 364 | cputime(); |
| 365 | } |
| 366 | |
| 367 | void |
| 368 | stopguprof(gp) |
no test coverage detected