1 /* profil.h: gprof profiling header file 2 3 Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. 4 5 This file is part of Cygwin. 6 7 This software is a copyrighted work licensed under the terms of the 8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for 9 details. */ 10 11 /* 12 * This file is taken from Cygwin distribution. Please keep it in sync. 13 * The differences should be within __MINGW32__ guard. 14 */ 15 16 /* profiling frequency. (No larger than 1000) */ 17 #define PROF_HZ 100 18 19 /* convert an addr to an index */ 20 #define PROFIDX(pc, base, scale) \ 21 ({ \ 22 size_t i = (pc - base) / 2; \ 23 if (sizeof (unsigned long long int) > sizeof (size_t)) \ 24 i = (unsigned long long int) i * scale / 65536; \ 25 else \ 26 i = i / 65536 * scale + i % 65536 * scale / 65536; \ 27 i; \ 28 }) 29 30 /* convert an index into an address */ 31 #define PROFADDR(idx, base, scale) \ 32 ((base) \ 33 + ((((unsigned long long)(idx) << 16) \ 34 / (unsigned long long)(scale)) << 1)) 35 36 /* convert a bin size into a scale */ 37 #define PROFSCALE(range, bins) (((bins) << 16) / ((range) >> 1)) 38 39 typedef void *_WINHANDLE; 40 #ifdef __MINGW32__ 41 #include <_bsd_types.h> 42 #endif /* __MINGW32__*/ 43 44 struct profinfo { 45 _WINHANDLE targthr; /* thread to profile */ 46 _WINHANDLE profthr; /* profiling thread */ 47 _WINHANDLE quitevt; /* quit event */ 48 u_short *counter; /* profiling counters */ 49 size_t lowpc, highpc; /* range to be profiled */ 50 u_int scale; /* scale value of bins */ 51 }; 52 53 int profile_ctl(struct profinfo *, char *, size_t, size_t, u_int); 54 int profil(char *, size_t, size_t, u_int); 55 56