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/Android.mk b/libc/Android.mk
index 0487a8f..15a68b9 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -45,7 +45,6 @@
     bionic/fts.c \
     bionic/gethostname.c \
     bionic/getpriority.c \
-    bionic/getpt.c \
     bionic/if_indextoname.c \
     bionic/if_nametoindex.c \
     bionic/initgroups.c \
@@ -53,8 +52,6 @@
     bionic/isatty.c \
     bionic/memmem.c \
     bionic/pathconf.c \
-    bionic/ptsname.c \
-    bionic/ptsname_r.c \
     bionic/pututline.c \
     bionic/sched_cpualloc.c \
     bionic/sched_cpucount.c \
@@ -63,7 +60,6 @@
     bionic/siginterrupt.c \
     bionic/sigsetmask.c \
     bionic/system_properties_compat.c \
-    bionic/unlockpt.c \
     stdio/snprintf.c\
     stdio/sprintf.c \
 
@@ -175,6 +171,7 @@
     bionic/pthread_setschedparam.cpp \
     bionic/pthread_sigmask.cpp \
     bionic/ptrace.cpp \
+    bionic/pty.cpp \
     bionic/raise.cpp \
     bionic/rand.cpp \
     bionic/readlink.cpp \