Merge the implementations of 2 sets of POSIX functions.
authorNicholas Clark <nick@ccl4.org>
Thu, 8 Sep 2011 11:05:05 +0000 (13:05 +0200)
committerNicholas Clark <nick@ccl4.org>
Tue, 13 Sep 2011 09:28:08 +0000 (11:28 +0200)
Using ALIAS to merge POSIX::sig{pending,suspend} and
POSIX::tc{flow,flush,sendbreak} reduces the size of POSIX.so by about 2K
on this platform.

ext/POSIX/POSIX.xs

index 764a9e5..50498ea 100644 (file)
@@ -1515,6 +1515,12 @@ sigaction(sig, optaction, oldaction = 0)
 SysRet
 sigpending(sigset)
        POSIX::SigSet           sigset
+    ALIAS:
+       sigsuspend = 1
+    CODE:
+       RETVAL = ix ? sigsuspend(sigset) : sigpending(sigset);
+    OUTPUT:
+       RETVAL
 
 SysRet
 sigprocmask(how, sigset, oldsigset = 0)
@@ -1538,10 +1544,6 @@ INIT:
            croak("oldsigset is not of type POSIX::SigSet");
        }
 
-SysRet
-sigsuspend(signal_mask)
-       POSIX::SigSet           signal_mask
-
 void
 _exit(status)
        int             status
@@ -1802,17 +1804,14 @@ SysRet
 tcflow(fd, action)
        int             fd
        int             action
-
-
-SysRet
-tcflush(fd, queue_selector)
-       int             fd
-       int             queue_selector
-
-SysRet
-tcsendbreak(fd, duration)
-       int             fd
-       int             duration
+    ALIAS:
+       tcflush = 1
+       tcsendbreak = 2
+    CODE:
+       RETVAL = ix == 1 ? tcflush(fd, action)
+           : (ix < 1 ? tcflow(fd, action) : tcsendbreak(fd, action));
+    OUTPUT:
+       RETVAL
 
 char *
 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = -1)