]> git.saurik.com Git - apple/libc.git/blob - gen/FreeBSD/termios.c.patch
Libc-583.tar.gz
[apple/libc.git] / gen / FreeBSD / termios.c.patch
1 --- termios.c.orig 2007-03-16 00:36:09.000000000 -0700
2 +++ termios.c 2007-03-16 00:45:15.000000000 -0700
3 @@ -37,6 +37,14 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/gen/termios.c,v 1.13 2002/05/28 16:59:39 alfred Exp $");
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>
18 @@ -48,6 +56,7 @@
19 #include <unistd.h>
20 #include "un-namespace.h"
21
22 +#ifndef BUILDING_VARIANT
23 int
24 tcgetattr(fd, t)
25 int fd;
26 @@ -87,6 +96,9 @@
27 {
28 int s;
29
30 + if (isatty(fd) == 0)
31 + return (-1);
32 +
33 s = pgrp;
34 return (_ioctl(fd, TIOCSPGRP, &s));
35 }
36 @@ -97,6 +109,9 @@
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
46 @@ -183,17 +198,24 @@
47 return (-1);
48 return (0);
49 }
50 +#endif /* BUILDING_VARIANT */
51
52 int
53 __tcdrain(fd)
54 int fd;
55 {
56 +#if __DARWIN_UNIX03
57 +#ifdef VARIANT_CANCELABLE
58 + _pthread_testcancel(pthread_self(), 1);
59 +#endif /* VARIANT_CANCELABLE */
60 +#endif /* __DARWIN_UNIX03 */
61 return (_ioctl(fd, TIOCDRAIN, 0));
62 }
63
64 __weak_reference(__tcdrain, tcdrain);
65 __weak_reference(__tcdrain, _tcdrain);
66
67 +#ifndef BUILDING_VARIANT
68 int
69 tcflush(fd, which)
70 int fd, which;
71 @@ -230,16 +252,13 @@
72 case TCOON:
73 return (_ioctl(fd, TIOCSTART, 0));
74 case TCION:
75 + return (_ioctl(fd, TIOCIXON, 0));
76 case TCIOFF:
77 - if (tcgetattr(fd, &term) == -1)
78 - return (-1);
79 - c = term.c_cc[action == TCIOFF ? VSTOP : VSTART];
80 - if (c != _POSIX_VDISABLE && _write(fd, &c, sizeof(c)) == -1)
81 - return (-1);
82 - return (0);
83 + return (_ioctl(fd, TIOCIXOFF, 0));
84 default:
85 errno = EINVAL;
86 return (-1);
87 }
88 /* NOTREACHED */
89 }
90 +#endif /* BUILDING_VARIANT */