OSDN Git Service

Rename cygWFMO to cygwait throughout and use the magic of polymorphism to "wait
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / profil.h
1 /* profil.h: gprof profiling header file
2
3    Copyright 1998, 1999, 2000, 2001 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 /* profiling frequency.  (No larger than 1000) */
12 #define PROF_HZ                 100
13
14 /* convert an addr to an index */
15 #define PROFIDX(pc, base, scale)        \
16   ({                                                                    \
17     size_t i = (pc - base) / 2;                         \
18     if (sizeof (unsigned long long int) > sizeof (size_t))              \
19       i = (unsigned long long int) i * scale / 65536;                   \
20     else                                                                \
21       i = i / 65536 * scale + i % 65536 * scale / 65536;                \
22     i;                                                                  \
23   })
24
25 /* convert an index into an address */
26 #define PROFADDR(idx, base, scale)      \
27         ((base) + ((((unsigned long long)(idx) << 16) / (scale)) << 1))
28
29 /* convert a bin size into a scale */
30 #define PROFSCALE(range, bins)          (((bins) << 16) / ((range) >> 1))
31
32 typedef void *_WINHANDLE;
33
34 struct profinfo {
35     _WINHANDLE targthr;                 /* thread to profile */
36     _WINHANDLE profthr;                 /* profiling thread */
37     u_short *counter;                   /* profiling counters */
38     u_long lowpc, highpc;               /* range to be profiled */
39     u_int scale;                        /* scale value of bins */
40 };
41
42 int profile_ctl(struct profinfo *, char *, size_t, u_long, u_int);
43 int profil(char *, size_t, u_long, u_int);
44