1 /* sigio.c -- Support for SIGIO handler -*- linux-c -*-
2 * Created: Thu Jun 3 15:39:18 1999 by faith@precisioninsight.com
3 * Revised: Thu Jun 3 16:16:35 1999 by faith@precisioninsight.com
5 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
27 * $PI: xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c,v 1.2 1999/06/14 21:11:29 faith Exp $
28 * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c,v 1.2 1999/06/14 12:02:11 dawes Exp $
37 # include "xf86_OSlib.h"
46 * Linux libc5 defines FASYNC, but not O_ASYNC. Don't know if it is
49 #if defined(FASYNC) && !defined(O_ASYNC)
50 # define O_ASYNC FASYNC
54 xf86InstallSIGIOHandler(int fd
, void (*f
)(int))
59 sigemptyset(&sa
.sa_mask
);
60 sigaddset(&sa
.sa_mask
, SIGIO
);
63 sigaction(SIGIO
, &sa
, &osa
);
64 fcntl(fd
, F_SETOWN
, getpid());
65 fcntl(fd
, F_SETFL
, fcntl(fd
, F_GETFL
) | O_ASYNC
);
70 xf86RemoveSIGIOHandler(int fd
)
75 sigemptyset(&sa
.sa_mask
);
76 sigaddset(&sa
.sa_mask
, SIGIO
);
78 sa
.sa_handler
= SIG_DFL
;
79 fcntl(fd
, F_SETFL
, fcntl(fd
, F_GETFL
) & ~O_ASYNC
);
80 sigaction(SIGIO
, &sa
, &osa
);