summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/cygwait.h
blob: 7c1e59c005343682370abbe96c8a0a1d56b8a752 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* cygwait.h

   Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
   Red Hat, Inc.

   This file is part of Cygwin.

   This software is a copyrighted work licensed under the terms of the
   Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
   details.  */

#pragma once

#define WAIT_CANCELED   (WAIT_OBJECT_0 + 2)
#define WAIT_SIGNALED  (WAIT_OBJECT_0 + 1)

enum cw_wait_mask
{
  cw_cancel =		0x0001,
  cw_cancel_self =	0x0002,
  cw_sig =		0x0004,
  cw_sig_eintr =	0x0008
};

extern LARGE_INTEGER cw_nowait_storage;
#define cw_nowait (&cw_nowait_storage)
#define cw_infinite ((PLARGE_INTEGER) NULL)

const unsigned cw_std_mask = cw_cancel | cw_cancel_self | cw_sig;

DWORD cygwait (HANDLE, PLARGE_INTEGER timeout,
		       unsigned = cw_std_mask)
  __attribute__ ((regparm (3)));

extern inline DWORD __attribute__ ((always_inline))
cygwait (HANDLE h, DWORD howlong, unsigned mask)
{
  LARGE_INTEGER li_howlong;
  PLARGE_INTEGER pli_howlong;
  if (howlong == INFINITE)
    pli_howlong = NULL;
  else
    {
      li_howlong.QuadPart = -(10000ULL * howlong);
      pli_howlong = &li_howlong;
    }
  return cygwait (h, pli_howlong, mask);
}

static inline DWORD __attribute__ ((always_inline))
cygwait (HANDLE h, DWORD howlong = INFINITE)
{
  return cygwait (h, howlong, cw_cancel | cw_sig);
}

static inline DWORD __attribute__ ((always_inline))
cygwait (DWORD howlong)
{
  return cygwait (NULL, howlong);
}