From b256643b00db727f2db85a7a7211dc0e9e0bf8d7 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Fri, 9 Sep 2011 12:39:13 +0200 Subject: [PATCH] Merge the implementations of 10 maths functions in POSIX using ALIAS. 10 functions take a single NV argument and return an NV result. Merging them reduces the shared object size by over 2K on this platform. (Argument marshalling code in XS is not free.) --- ext/POSIX/POSIX.xs | 80 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 8b1a41b..8151d79 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -1252,26 +1252,50 @@ setlocale(category, locale = 0) NV acos(x) NV x - -NV -asin(x) - NV x - -NV -atan(x) - NV x - -NV -ceil(x) - NV x - -NV -cosh(x) - NV x - -NV -floor(x) - NV x + ALIAS: + asin = 1 + atan = 2 + ceil = 3 + cosh = 4 + floor = 5 + log10 = 6 + sinh = 7 + tan = 8 + tanh = 9 + CODE: + switch (ix) { + case 0: + RETVAL = acos(x); + break; + case 1: + RETVAL = asin(x); + break; + case 2: + RETVAL = atan(x); + break; + case 3: + RETVAL = ceil(x); + break; + case 4: + RETVAL = cosh(x); + break; + case 5: + RETVAL = floor(x); + break; + case 6: + RETVAL = log10(x); + break; + case 7: + RETVAL = sinh(x); + break; + case 8: + RETVAL = tan(x); + break; + default: + RETVAL = tanh(x); + } + OUTPUT: + RETVAL NV fmod(x,y) @@ -1292,10 +1316,6 @@ ldexp(x,exp) NV x int exp -NV -log10(x) - NV x - void modf(x) NV x @@ -1305,18 +1325,6 @@ modf(x) PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar)))); PUSHs(sv_2mortal(newSVnv(intvar))); -NV -sinh(x) - NV x - -NV -tan(x) - NV x - -NV -tanh(x) - NV x - SysRet sigaction(sig, optaction, oldaction = 0) int sig -- 1.8.3.1