Improve TTY library detection
[sxemacs] / src / sysproc.h
1 /*
2    Copyright (C) 1995 Free Software Foundation, Inc.
3
4 This file is part of SXEmacs
5
6 SXEmacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 SXEmacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
18
19
20 /* Synched up with: Not really in FSF. */
21
22 #ifndef INCLUDED_sysproc_h_
23 #define INCLUDED_sysproc_h_
24
25 #ifdef HAVE_VFORK_H
26 # include <vfork.h>
27 #endif
28
29 #include "systime.h"            /* necessary for sys/resource.h; also gets the
30                                    FD_* defines on some systems. */
31 #include <sys/resource.h>
32
33 #if !defined (NO_SUBPROCESSES)
34
35 #ifdef HAVE_SOCKETS             /* TCP connection support, if kernel can do it */
36 # include <sys/types.h>         /* AJK */
37 #  include <sys/socket.h>
38 #  include <netdb.h>
39 #  include <netinet/in.h>
40 #  include <arpa/inet.h>
41 # ifdef NEED_NET_ERRNO_H
42 #  include <net/errno.h>
43 # endif                         /* NEED_NET_ERRNO_H */
44 #elif defined (SKTPAIR)
45 # include <sys/socket.h>
46 #endif                          /* HAVE_SOCKETS */
47
48
49 /* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */
50 #ifdef HAVE_BROKEN_INET_ADDR
51 # define IN_ADDR struct in_addr
52 # define NUMERIC_ADDR_ERROR (numeric_addr.s_addr == -1)
53 #else
54 # if (SXE_LONGBITS > 32)
55 #  define IN_ADDR unsigned int
56 # else
57 #  define IN_ADDR unsigned long
58 # endif
59 # define NUMERIC_ADDR_ERROR (numeric_addr == (IN_ADDR) -1)
60 #endif
61
62 /* Define first descriptor number available for subprocesses.  */
63 #define FIRST_PROC_DESC 3
64
65 #ifdef IRIS
66 # include <sys/sysmacros.h>     /* for "minor" */
67 #endif                          /* not IRIS */
68
69 #endif                          /* !NO_SUBPROCESSES */
70
71 #ifdef AIX
72 #include <sys/select.h>
73 #endif
74
75 #ifdef HAVE_STROPTS_H
76 #include <stropts.h>            /* isastream(), I_PUSH */
77 #endif
78
79 #ifdef HAVE_STRTIO_H
80 #include <strtio.h>             /* TIOCSIGNAL */
81 #endif
82
83 #ifdef HAVE_PTY_H
84 #include <pty.h>                /* openpty() on Tru64, Linux */
85 #endif
86
87 #ifdef HAVE_LIBUTIL_H
88 #include <libutil.h>            /* openpty() on FreeBSD */
89 #endif
90
91 #ifdef HAVE_UTIL_H
92 #include <util.h>               /* openpty() on NetBSD */
93 #endif
94
95 #ifdef FD_SET
96
97 /* We could get this from param.h, but better not to depend on finding that.
98    And better not to risk that it might define other symbols used in this
99    file.  */
100 # ifdef FD_SETSIZE
101 #  define MAXDESC FD_SETSIZE
102 # else
103 #  define MAXDESC 64
104 # endif                         /* FD_SETSIZE */
105 # define SELECT_TYPE fd_set
106
107 #else                           /* no FD_SET */
108
109 # define MAXDESC 32
110 # define SELECT_TYPE int
111
112 /* Define the macros to access a single-int bitmap of descriptors.  */
113 # define FD_SET(n, p) (*(p) |= (1 << (n)))
114 # define FD_CLR(n, p) (*(p) &= ~(1 << (n)))
115 # define FD_ISSET(n, p) (*(p) & (1 << (n)))
116 # define FD_ZERO(p) (*(p) = 0)
117
118 #endif                          /* no FD_SET */
119
120 int poll_fds_for_input(SELECT_TYPE mask);
121
122 #endif                          /* INCLUDED_sysproc_h_ */