]> git.saurik.com Git - apple/libc.git/blame - gen/FreeBSD/termios.c.patch
Libc-763.12.tar.gz
[apple/libc.git] / gen / FreeBSD / termios.c.patch
CommitLineData
1f2f436a
A
1--- termios.c.orig 2009-11-08 16:27:01.000000000 -0800
2+++ termios.c 2009-11-08 16:28:15.000000000 -0800
3@@ -33,6 +33,14 @@ static char sccsid[] = "@(#)termios.c 8.
224c7076 4 #include <sys/cdefs.h>
1f2f436a 5 __FBSDID("$FreeBSD: src/lib/libc/gen/termios.c,v 1.16 2009/05/07 13:49:48 ed Exp $");
224c7076
A
6
7+#if __DARWIN_UNIX03
8+#ifdef VARIANT_CANCELABLE
9+#include <pthread.h>
10+
11+extern void _pthread_testcancel(pthread_t thread, int isconforming);
12+#endif /* VARIANT_CANCELABLE */
13+#endif /* __DARWIN_UNIX03 */
14+
15 #include "namespace.h"
16 #include <sys/types.h>
17 #include <sys/fcntl.h>
1f2f436a 18@@ -44,6 +52,7 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/ter
224c7076
A
19 #include <unistd.h>
20 #include "un-namespace.h"
21
22+#ifndef BUILDING_VARIANT
23 int
24 tcgetattr(fd, t)
25 int fd;
1f2f436a 26@@ -83,6 +92,9 @@ tcsetpgrp(int fd, pid_t pgrp)
224c7076
A
27 {
28 int s;
29
30+ if (isatty(fd) == 0)
31+ return (-1);
32+
33 s = pgrp;
34 return (_ioctl(fd, TIOCSPGRP, &s));
35 }
1f2f436a 36@@ -93,12 +105,16 @@ tcgetpgrp(fd)
224c7076
A
37 {
38 int s;
39
40+ if (isatty(fd) == 0)
41+ return ((pid_t)-1);
42+
43 if (_ioctl(fd, TIOCGPGRP, &s) < 0)
44 return ((pid_t)-1);
45
1f2f436a
A
46 return ((pid_t)s);
47 }
48
49+#if 0 // Needs API review first
50 pid_t
51 tcgetsid(int fd)
52 {
53@@ -121,6 +137,7 @@ tcsetsid(int fd, pid_t pid)
54
55 return (_ioctl(fd, TIOCSCTTY, NULL));
56 }
57+#endif
58
59 speed_t
60 cfgetospeed(t)
61@@ -202,17 +219,24 @@ tcsendbreak(fd, len)
224c7076
A
62 return (-1);
63 return (0);
64 }
65+#endif /* BUILDING_VARIANT */
66
67 int
68 __tcdrain(fd)
69 int fd;
70 {
71+#if __DARWIN_UNIX03
72+#ifdef VARIANT_CANCELABLE
73+ _pthread_testcancel(pthread_self(), 1);
74+#endif /* VARIANT_CANCELABLE */
75+#endif /* __DARWIN_UNIX03 */
76 return (_ioctl(fd, TIOCDRAIN, 0));
77 }
78
79 __weak_reference(__tcdrain, tcdrain);
80 __weak_reference(__tcdrain, _tcdrain);
81
82+#ifndef BUILDING_VARIANT
83 int
84 tcflush(fd, which)
85 int fd, which;
1f2f436a 86@@ -249,16 +273,13 @@ tcflow(fd, action)
224c7076
A
87 case TCOON:
88 return (_ioctl(fd, TIOCSTART, 0));
89 case TCION:
90+ return (_ioctl(fd, TIOCIXON, 0));
91 case TCIOFF:
92- if (tcgetattr(fd, &term) == -1)
93- return (-1);
94- c = term.c_cc[action == TCIOFF ? VSTOP : VSTART];
95- if (c != _POSIX_VDISABLE && _write(fd, &c, sizeof(c)) == -1)
96- return (-1);
97- return (0);
98+ return (_ioctl(fd, TIOCIXOFF, 0));
99 default:
100 errno = EINVAL;
101 return (-1);
102 }
103 /* NOTREACHED */
104 }
105+#endif /* BUILDING_VARIANT */