diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-09-08 12:41:10 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-09-13 11:28:07 +0200 |
commit | 2a59a32c567e75f15784d3cfd9afe9861f38dd15 (patch) | |
tree | 7ee719b168b579d9963b0f4417f5d7fe2476b05c /ext/POSIX/POSIX.xs | |
parent | df6c2df286c51c732d4257e80455c256e49cff3a (diff) | |
download | perl-2a59a32c567e75f15784d3cfd9afe9861f38dd15.tar.gz |
Merge the implementations of 4 sets of POSIX::Termios methods.
Using ALIAS to merge cfget[io]speed(), get[cloi]flag(), cfset[io]speed()
and set[cloi]flag() reduces the size of POSIX.so by almost 2K on this
platform.
Diffstat (limited to 'ext/POSIX/POSIX.xs')
-rw-r--r-- | ext/POSIX/POSIX.xs | 140 |
1 files changed, 53 insertions, 87 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 1b7333e6a1..764a9e53f9 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -760,61 +760,41 @@ setattr(termios_ref, fd = 0, optional_actions = 0) RETVAL speed_t -cfgetispeed(termios_ref) - POSIX::Termios termios_ref - -speed_t -cfgetospeed(termios_ref) - POSIX::Termios termios_ref - -tcflag_t -getiflag(termios_ref) - POSIX::Termios termios_ref - CODE: -#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */ - RETVAL = termios_ref->c_iflag; -#else - not_here("getiflag"); - RETVAL = 0; -#endif - OUTPUT: - RETVAL - -tcflag_t -getoflag(termios_ref) - POSIX::Termios termios_ref - CODE: -#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */ - RETVAL = termios_ref->c_oflag; -#else - not_here("getoflag"); - RETVAL = 0; -#endif - OUTPUT: - RETVAL - -tcflag_t -getcflag(termios_ref) +getispeed(termios_ref) POSIX::Termios termios_ref + ALIAS: + getospeed = 1 CODE: -#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */ - RETVAL = termios_ref->c_cflag; -#else - not_here("getcflag"); - RETVAL = 0; -#endif + RETVAL = ix ? cfgetospeed(termios_ref) : cfgetispeed(termios_ref); OUTPUT: RETVAL tcflag_t -getlflag(termios_ref) +getiflag(termios_ref) POSIX::Termios termios_ref + ALIAS: + getoflag = 1 + getcflag = 2 + getlflag = 3 CODE: #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */ - RETVAL = termios_ref->c_lflag; + switch(ix) { + case 0: + RETVAL = termios_ref->c_iflag; + break; + case 1: + RETVAL = termios_ref->c_oflag; + break; + case 2: + RETVAL = termios_ref->c_cflag; + break; + case 3: + RETVAL = termios_ref->c_lflag; + break; + } #else - not_here("getlflag"); - RETVAL = 0; + not_here(GvNAME(CvGV(cv))); + RETVAL = 0; #endif OUTPUT: RETVAL @@ -836,57 +816,43 @@ getcc(termios_ref, ccix) RETVAL SysRet -cfsetispeed(termios_ref, speed) +setispeed(termios_ref, speed) POSIX::Termios termios_ref speed_t speed - -SysRet -cfsetospeed(termios_ref, speed) - POSIX::Termios termios_ref - speed_t speed - -void -setiflag(termios_ref, iflag) - POSIX::Termios termios_ref - tcflag_t iflag - CODE: -#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */ - termios_ref->c_iflag = iflag; -#else - not_here("setiflag"); -#endif - -void -setoflag(termios_ref, oflag) - POSIX::Termios termios_ref - tcflag_t oflag - CODE: -#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */ - termios_ref->c_oflag = oflag; -#else - not_here("setoflag"); -#endif - -void -setcflag(termios_ref, cflag) - POSIX::Termios termios_ref - tcflag_t cflag + ALIAS: + setospeed = 1 CODE: -#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */ - termios_ref->c_cflag = cflag; -#else - not_here("setcflag"); -#endif + RETVAL = ix + ? cfsetospeed(termios_ref, speed) : cfsetispeed(termios_ref, speed); + OUTPUT: + RETVAL void -setlflag(termios_ref, lflag) +setiflag(termios_ref, flag) POSIX::Termios termios_ref - tcflag_t lflag + tcflag_t flag + ALIAS: + setoflag = 1 + setcflag = 2 + setlflag = 3 CODE: #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */ - termios_ref->c_lflag = lflag; + switch(ix) { + case 0: + termios_ref->c_iflag = flag; + break; + case 1: + termios_ref->c_oflag = flag; + break; + case 2: + termios_ref->c_cflag = flag; + break; + case 3: + termios_ref->c_lflag = flag; + break; + } #else - not_here("setlflag"); + not_here(GvNAME(CvGV(cv))); #endif void |