~steve-sk2/mingw-w64/oneiric

« back to all changes in this revision

Viewing changes to mingw-w64-crt/profile/profil.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-11-18 00:04:46 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101118000446-xe24b423su55onyl
Tags: 1.0+20101003-1
* New maintainer. (Closes: #594371.)
* New upstream snapshot:
  - Includes getopt.h. (Closes: #569914.)
* Build g++ for Win64. (Closes: #600451.)
* Standards-Version 3.9.1 (new packaging).
* Include patch from
  http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64?view=revision&revision=3715
  as suggested by Rafaël Carré.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
/* Everytime we wake up use the main thread pc to hash into the cell in the
69
69
   profile buffer ARG. */
70
70
 
71
 
static void CALLBACK profthr_func (LPVOID) __MINGW_ATTRIB_NORETURN;
 
71
static void CALLBACK profthr_func (LPVOID);
72
72
 
73
73
static void CALLBACK
74
74
profthr_func (LPVOID arg)
87
87
#if 0
88
88
      print_prof (p);
89
89
#endif
90
 
      Sleep (SLEEPTIME);
 
90
      /* Check quit condition, WAIT_OBJECT_0 or WAIT_TIMEOUT */
 
91
      if (WaitForSingleObject (p->quitevt, SLEEPTIME) == WAIT_OBJECT_0)
 
92
        return;
91
93
    }
92
94
}
93
95
 
98
100
{
99
101
  if (p->profthr)
100
102
    {
101
 
      TerminateThread (p->profthr, 0);
 
103
      SignalObjectAndWait (p->quitevt, p->profthr, INFINITE, FALSE);
 
104
      CloseHandle (p->quitevt);
102
105
      CloseHandle (p->profthr);
103
106
    }
104
107
  if (p->targthr)
122
125
      return -1;
123
126
    }
124
127
 
 
128
  p->quitevt = CreateEvent (NULL, TRUE, FALSE, NULL);
 
129
 
 
130
  if (!p->quitevt)
 
131
    {
 
132
      CloseHandle (p->quitevt);
 
133
      p->targthr = 0;
 
134
      errno = EAGAIN;
 
135
      return -1;
 
136
    }
 
137
 
125
138
  p->profthr = CreateThread (0, 0, (DWORD (WINAPI *)(LPVOID)) profthr_func,
126
139
                             (void *) p, 0, &thrid);
127
140
 
 
141
  if (!p->profthr)
 
142
    {
 
143
      CloseHandle (p->targthr);
 
144
      CloseHandle (p->quitevt);
 
145
      p->targthr = 0;
 
146
      errno = EAGAIN;
 
147
      return -1;
 
148
    }
 
149
 
128
150
  /* Set profiler thread priority to highest to be sure that it gets the
129
151
     processor as soon it request it (i.e. when the Sleep terminate) to get
130
152
     the next data out of the profile. */
131
153
 
132
154
  SetThreadPriority (p->profthr, THREAD_PRIORITY_TIME_CRITICAL);
133
155
 
134
 
  if (!p->profthr)
135
 
    {
136
 
      CloseHandle (p->targthr);
137
 
      p->targthr = 0;
138
 
      errno = EAGAIN;
139
 
      return -1;
140
 
    }
141
156
  return 0;
142
157
}
143
158