summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2016-06-09 23:21:22 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-06-09 23:21:22 +0000
commitf3c39b26b5a152eb2f1713842d0346d53204894c (patch)
tree243a953b4f18b7c95707962f4be850936ffd164b
parent4bc95c0f302d7bab1cb1927cf696516debd853f1 (diff)
parent20788aec002ab3f6dea4e01665a439933161d11c (diff)
Merge "Add ctermid."
-rw-r--r--libc/include/stdio.h1
-rw-r--r--libc/libc.arm.brillo.map1
-rw-r--r--libc/libc.arm.map1
-rw-r--r--libc/libc.arm64.map1
-rw-r--r--libc/libc.map.txt1
-rw-r--r--libc/libc.mips.brillo.map1
-rw-r--r--libc/libc.mips.map1
-rw-r--r--libc/libc.mips64.map1
-rw-r--r--libc/libc.x86.brillo.map1
-rw-r--r--libc/libc.x86.map1
-rw-r--r--libc/libc.x86_64.map1
-rw-r--r--libc/stdio/stdio.cpp5
-rw-r--r--tests/stdio_test.cpp8
13 files changed, 24 insertions, 0 deletions
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 83ffc20ec..b92f5d5b3 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -226,6 +226,7 @@ int vsscanf(const char * __restrict, const char * __restrict, __va_list)
*/
#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */
+char* ctermid(char*);
FILE *fdopen(int, const char *);
int fileno(FILE *);
diff --git a/libc/libc.arm.brillo.map b/libc/libc.arm.brillo.map
index 3928cae69..9ea1d8b41 100644
--- a/libc/libc.arm.brillo.map
+++ b/libc/libc.arm.brillo.map
@@ -1271,6 +1271,7 @@ LIBC_O {
catclose;
catgets;
catopen;
+ ctermid;
endgrent;
endpwent;
futimes;
diff --git a/libc/libc.arm.map b/libc/libc.arm.map
index f6520b59a..0097c25c8 100644
--- a/libc/libc.arm.map
+++ b/libc/libc.arm.map
@@ -1271,6 +1271,7 @@ LIBC_O {
catclose;
catgets;
catopen;
+ ctermid;
endgrent;
endpwent;
futimes;
diff --git a/libc/libc.arm64.map b/libc/libc.arm64.map
index 603ac8651..cfa183810 100644
--- a/libc/libc.arm64.map
+++ b/libc/libc.arm64.map
@@ -1194,6 +1194,7 @@ LIBC_O {
catclose;
catgets;
catopen;
+ ctermid;
endgrent;
endpwent;
futimes;
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index d2ad2498e..aeb39d329 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1296,6 +1296,7 @@ LIBC_O {
catclose;
catgets;
catopen;
+ ctermid;
endgrent;
endpwent;
futimes;
diff --git a/libc/libc.mips.brillo.map b/libc/libc.mips.brillo.map
index 2cf5df0a4..ce4d4ad75 100644
--- a/libc/libc.mips.brillo.map
+++ b/libc/libc.mips.brillo.map
@@ -1255,6 +1255,7 @@ LIBC_O {
catclose;
catgets;
catopen;
+ ctermid;
endgrent;
endpwent;
futimes;
diff --git a/libc/libc.mips.map b/libc/libc.mips.map
index 6c5ba9cb1..172a2aec0 100644
--- a/libc/libc.mips.map
+++ b/libc/libc.mips.map
@@ -1255,6 +1255,7 @@ LIBC_O {
catclose;
catgets;
catopen;
+ ctermid;
endgrent;
endpwent;
futimes;
diff --git a/libc/libc.mips64.map b/libc/libc.mips64.map
index 603ac8651..cfa183810 100644
--- a/libc/libc.mips64.map
+++ b/libc/libc.mips64.map
@@ -1194,6 +1194,7 @@ LIBC_O {
catclose;
catgets;
catopen;
+ ctermid;
endgrent;
endpwent;
futimes;
diff --git a/libc/libc.x86.brillo.map b/libc/libc.x86.brillo.map
index 1a254ae9e..81b13d096 100644
--- a/libc/libc.x86.brillo.map
+++ b/libc/libc.x86.brillo.map
@@ -1253,6 +1253,7 @@ LIBC_O {
catclose;
catgets;
catopen;
+ ctermid;
endgrent;
endpwent;
futimes;
diff --git a/libc/libc.x86.map b/libc/libc.x86.map
index ca97c0389..3611e148c 100644
--- a/libc/libc.x86.map
+++ b/libc/libc.x86.map
@@ -1253,6 +1253,7 @@ LIBC_O {
catclose;
catgets;
catopen;
+ ctermid;
endgrent;
endpwent;
futimes;
diff --git a/libc/libc.x86_64.map b/libc/libc.x86_64.map
index 603ac8651..cfa183810 100644
--- a/libc/libc.x86_64.map
+++ b/libc/libc.x86_64.map
@@ -1194,6 +1194,7 @@ LIBC_O {
catclose;
catgets;
catopen;
+ ctermid;
endgrent;
endpwent;
futimes;
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index 5df1bb95d..3aabbe23c 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -36,6 +36,7 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <paths.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
@@ -598,3 +599,7 @@ FILE* funopen64(const void* cookie,
}
return fp;
}
+
+char* ctermid(char* s) {
+ return s ? strcpy(s, _PATH_TTY) : const_cast<char*>(_PATH_TTY);
+}
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 7e826124f..4db1f72dd 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -1297,3 +1297,11 @@ TEST(STDIO_TEST, fseek_fseeko_EINVAL) {
fclose(fp);
}
+
+TEST(STDIO_TEST, ctermid) {
+ ASSERT_STREQ("/dev/tty", ctermid(nullptr));
+
+ char buf[L_ctermid] = {};
+ ASSERT_EQ(buf, ctermid(buf));
+ ASSERT_STREQ("/dev/tty", buf);
+}