errno-h: document Haiku errors can’t be -1
[gnulib.git] / lib / pty.in.h
blobc224c3fd2a1b9380d7c72e73fe7c370ffd7282ab
1 /* Substitute for and wrapper around <pty.h>.
2 Copyright (C) 2010-2025 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 #ifndef _@GUARD_PREFIX@_PTY_H
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
22 @PRAGMA_COLUMNS@
24 /* The include_next requires a split double-inclusion guard. */
25 #if @HAVE_PTY_H@
26 # @INCLUDE_NEXT@ @NEXT_PTY_H@
27 #endif
29 #ifndef _@GUARD_PREFIX@_PTY_H
30 #define _@GUARD_PREFIX@_PTY_H
32 /* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
33 #if !_GL_CONFIG_H_INCLUDED
34 #error "Please include config.h first."
35 #endif
37 /* Some platforms declare this in a different header than glibc. */
38 #if @HAVE_UTIL_H@
39 # include <util.h>
40 #endif
41 #if @HAVE_LIBUTIL_H@
42 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
43 # include <sys/types.h>
44 # include <libutil.h>
45 #endif
47 /* Get 'struct termios', if available, and 'struct winsize'. */
48 #include <termios.h>
49 #if defined _AIX
50 # include <sys/ioctl.h>
51 #endif
52 /* Mingw lacks 'struct termios', but a forward declaration of an opaque type is
53 sufficient to allow compilation of a stub openpty(). */
54 struct termios;
56 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
58 /* The definition of _GL_WARN_ON_USE is copied here. */
61 /* Declare overridden functions. */
63 #if @GNULIB_FORKPTY@
64 /* Create pseudo tty master slave pair and set terminal attributes
65 according to TERMP and WINP. Fork a child process attached to the
66 slave end. Return a handle for the master end in *AMASTER, and
67 return the name of the slave end in NAME. */
68 # if @REPLACE_FORKPTY@
69 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
70 # undef forkpty
71 # define forkpty rpl_forkpty
72 # endif
73 _GL_FUNCDECL_RPL (forkpty, int,
74 (int *amaster, char *name,
75 struct termios const *termp, struct winsize const *winp), );
76 _GL_CXXALIAS_RPL (forkpty, int,
77 (int *amaster, char *name,
78 struct termios const *termp, struct winsize const *winp));
79 # else
80 # if !@HAVE_FORKPTY@
81 _GL_FUNCDECL_SYS (forkpty, int,
82 (int *amaster, char *name,
83 struct termios const *termp, struct winsize const *winp), );
84 # endif
85 _GL_CXXALIAS_SYS (forkpty, int,
86 (int *amaster, char *name,
87 struct termios const *termp, struct winsize const *winp));
88 # endif
89 _GL_CXXALIASWARN (forkpty);
90 #elif defined GNULIB_POSIXCHECK
91 # undef forkpty
92 # if HAVE_RAW_DECL_FORKPTY
93 _GL_WARN_ON_USE (forkpty, "forkpty is not declared consistently - "
94 "use gnulib module forkpty for portability");
95 # endif
96 #endif
98 #if @GNULIB_OPENPTY@
99 /* Create pseudo tty master slave pair and set terminal attributes
100 according to TERMP and WINP. Return handles for both ends in
101 *AMASTER and *ASLAVE, and return the name of the slave end in NAME. */
102 # if @REPLACE_OPENPTY@
103 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
104 # undef openpty
105 # define openpty rpl_openpty
106 # endif
107 _GL_FUNCDECL_RPL (openpty, int,
108 (int *amaster, int *aslave, char *name,
109 struct termios const *termp, struct winsize const *winp), );
110 _GL_CXXALIAS_RPL (openpty, int,
111 (int *amaster, int *aslave, char *name,
112 struct termios const *termp, struct winsize const *winp));
113 # else
114 # if !@HAVE_OPENPTY@
115 _GL_FUNCDECL_SYS (openpty, int,
116 (int *amaster, int *aslave, char *name,
117 struct termios const *termp, struct winsize const *winp), );
118 # endif
119 _GL_CXXALIAS_SYS (openpty, int,
120 (int *amaster, int *aslave, char *name,
121 struct termios const *termp, struct winsize const *winp));
122 # endif
123 _GL_CXXALIASWARN (openpty);
124 #elif defined GNULIB_POSIXCHECK
125 # undef openpty
126 # if HAVE_RAW_DECL_OPENPTY
127 _GL_WARN_ON_USE (openpty, "openpty is not declared consistently - "
128 "use gnulib module openpty for portability");
129 # endif
130 #endif
133 #endif /* _@GUARD_PREFIX@_PTY_H */
134 #endif /* _@GUARD_PREFIX@_PTY_H */