summaryrefslogtreecommitdiff
path: root/mcon/U/d_kqueue.U
blob: a69cf0b2f4d7f9807e1d886bfbe063e9d4254a8e (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
?RCS: $Id: d_kqueue.U 167 2013-05-08 17:58:00Z rmanfredi $
?RCS:
?RCS: Copyright (c) 2006, Christian Biere
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?MAKE:d_kqueue: Trylink cat
?MAKE:	-pick add $@ %<
?S:d_kqueue:
?S:	This variable conditionally defines the HAS_KQUEUE symbol, which
?S:	indicates to the C program that kqueue() support is available.
?S:.
?C:HAS_KQUEUE:
?C:	This symbol is defined when kqueue() can be used.
?C:.
?H:#$d_kqueue HAS_KQUEUE
?H:.
?LINT: set d_kqueue
: can we use kqueue?
$cat >try.c <<'EOC'
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
int main(void)
{
  static struct kevent changes, events;
  static struct timespec ts;
  static unsigned long filter;
  static int kq, fd;
  static unsigned long flags;
  filter |= EVFILT_READ;
  filter |= EVFILT_WRITE;
  filter |= EVFILT_SIGNAL;
  filter |= EVFILT_VNODE;
  filter |= EVFILT_PROC;
  flags |= EV_ADD;
  flags |= EV_ENABLE;
  flags |= EV_ONESHOT;
  flags |= EV_CLEAR;
  flags |= EV_EOF;
  flags |= EV_ERROR;
  flags |= EV_DISABLE;
  flags |= EV_DELETE;
  EV_SET(&changes, fd, filter, flags, 0, 0, 0);
  kq |= kqueue();
  kevent(kq, &changes, 1, &events, 1, &ts);
  return 0;
}
EOC
cyn=kqueue
set d_kqueue
eval $trylink