On Sat, Jun 07, 2014 at 09:06:41PM +0200, Stephen Kitt wrote:
> On Sat, 7 Jun 2014 20:55:04 +0200, Bill Allombert <[email protected]> wrote:
> > On Sat, Jun 07, 2014 at 02:41:23PM +0200, Stephen Kitt wrote:
> > Hello Stephen, thanks again for your answer.
> > 
> > Is there a clear documentation of the mingw API ? (at least the difference 
> > between mingw and POSIX) Then I would not need to bother you.  
> 
> The API is "documented" on
> https://sourceforge.net/apps/trac/mingw-w64/wiki/Mingw-w64%20API%20documentation
> but very little of the API is described.
> 
> > > I'll forward your request upstream!
> > 
> > Thanks, though I understand win32 signal model might not make it easy.
> 
> Yes, I imagine it would have to be emulated using SetTimer but even then
> producing a signal from the timer function might be difficult...

Well I came with the code below.
This works, but of course it should do raise(SIGALRM), but
mingw does not support catching SIGALRM.

static HANDLE hTimerQueue = NULL;

static void CALLBACK
win32_cb_alarm(void *lpParam, BOOLEAN TimerOrWaitFired)
{
  raise(SIGINT);
}

void
win32_alarm(unsigned int s)
{
  if (hTimerQueue)
  {
    HANDLE oldhTimerQueue = hTimerQueue;
    hTimerQueue = NULL;
    DeleteTimerQueue(oldhTimerQueue);
  }
  if (s)
  {
    void *arg = NULL;
    HANDLE hTimer = NULL;
    hTimerQueue = CreateTimerQueue();
    CreateTimerQueueTimer( &hTimer, hTimerQueue,
        (WAITORTIMERCALLBACK)win32_cb_alarm, &arg , s*1000, 0, 0);
  }
}

Cheers,
-- 
Bill. <[email protected]>

Imagine a large red swirl here. 


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to