Fix linkage of grantpt(3).
Also clean up the implementation of all the pty functions, add tests,
and fix the stub implementations of ttyname(3) and ttyname_r(3).
Bug: https://code.google.com/p/android/issues/detail?id=58888
(cherry picked from commit 4916706cfe590eb06c9b5bd4bd402ce056034d51)
Change-Id: I5cb7a1c17b156456e4c4818e65f256eb8d045424
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 195765a..857d631 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -120,18 +120,12 @@
char* setstate(char*);
void srandom(unsigned int);
-/* Basic PTY functions. These only work if devpts is mounted! */
-
-extern int unlockpt(int);
-extern char* ptsname(int);
-extern int ptsname_r(int, char*, size_t);
-extern int getpt(void);
-
-static __inline__ int grantpt(int __fd __attribute((unused)))
-{
- (void)__fd;
- return 0; /* devpts does this all for us! */
-}
+int getpt(void);
+int grantpt(int);
+int posix_openpt(int);
+char* ptsname(int) __warnattr("ptsname is not thread-safe; use ptsname_r instead");
+int ptsname_r(int, char*, size_t);
+int unlockpt(int);
typedef struct {
int quot;