[klibc] [klibc:master] Make posix_openpt() an inline

klibc-bot for H. Peter Anvin hpa at zytor.com
Tue Jan 26 16:00:02 PST 2016


Commit-ID:  b4babe7a3618705a283fc9458de19aba1d12401d
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=b4babe7a3618705a283fc9458de19aba1d12401d
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Tue, 26 Jan 2016 15:58:49 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Tue, 26 Jan 2016 15:58:49 -0800

[klibc] Make posix_openpt() an inline

This function is so trivial that there is no reason to not make it an
inline.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>

---
 usr/include/stdlib.h     |  9 ++++++++-
 usr/klibc/Kbuild         |  2 +-
 usr/klibc/posix_openpt.c | 14 --------------
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/usr/include/stdlib.h b/usr/include/stdlib.h
index c2d6264..250755f 100644
--- a/usr/include/stdlib.h
+++ b/usr/include/stdlib.h
@@ -83,7 +83,14 @@ static __inline__ void srandom(unsigned int __s)
 
 __extern int unlockpt(int);
 __extern char *ptsname(int);
-__extern int posix_openpt(int);
+
+static __inline__ int posix_openpt(int __mode)
+{
+	__extern int open(const char *, int, ...);
+
+	__mode &= ~(O_CREAT | O_TMPFILE);
+	return open("/dev/ptmx", __mode);
+}
 
 static __inline__ int grantpt(int __fd)
 {
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index a0e440d..eba6add 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -52,7 +52,7 @@ klib-y += vsnprintf.o snprintf.o vsprintf.o sprintf.o \
 	  getenv.o setenv.o putenv.o __put_env.o unsetenv.o \
 	  clearenv.o nullenv.o \
 	  getopt.o getopt_long.o readdir.o scandir.o alphasort.o remove.o \
-	  syslog.o closelog.o pty.o posix_openpt.o isatty.o reboot.o \
+	  syslog.o closelog.o pty.o isatty.o reboot.o \
 	  time.o utime.o lseek.o nice.o getpriority.o \
 	  qsort.o bsearch.o \
 	  lrand48.o jrand48.o mrand48.o nrand48.o srand48.o seed48.o \
diff --git a/usr/klibc/posix_openpt.c b/usr/klibc/posix_openpt.c
deleted file mode 100644
index 794ca46..0000000
--- a/usr/klibc/posix_openpt.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * posix_openpt.c
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <termios.h>
-#include <fcntl.h>
-
-int posix_openpt(int oflag)
-{
-	return open("/dev/ptmx", oflag);
-}


More information about the klibc mailing list