This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge the implementations of POSIX::{close,dup,tcdrain} using ALIAS.
authorNicholas Clark <nick@ccl4.org>
Fri, 9 Sep 2011 21:14:22 +0000 (23:14 +0200)
committerNicholas Clark <nick@ccl4.org>
Tue, 13 Sep 2011 09:28:09 +0000 (11:28 +0200)
On this platform, this reduces the shared object size by about .5K.

ext/POSIX/POSIX.xs

index afcfe44..e09454d 100644 (file)
@@ -1472,14 +1472,6 @@ _exit(status)
        int             status
 
 SysRet
-close(fd)
-       int             fd
-
-SysRet
-dup(fd)
-       int             fd
-
-SysRet
 dup2(fd1, fd2)
        int             fd1
        int             fd2
@@ -1721,6 +1713,14 @@ mkfifo(filename, mode)
 SysRet
 tcdrain(fd)
        int             fd
+    ALIAS:
+       close = 1
+       dup = 2
+    CODE:
+       RETVAL = ix == 1 ? close(fd)
+           : (ix < 1 ? tcdrain(fd) : dup(fd));
+    OUTPUT:
+       RETVAL
 
 
 SysRet