summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-09-09 12:39:13 +0200
committerNicholas Clark <nick@ccl4.org>2011-09-13 11:28:08 +0200
commitb256643b00db727f2db85a7a7211dc0e9e0bf8d7 (patch)
treedf4dd2d029d939655acaeed67e1f8bfa90c00763 /ext
parent1a77755a54cd3bc9bb415dbea8e75d39cb394968 (diff)
downloadperl-b256643b00db727f2db85a7a7211dc0e9e0bf8d7.tar.gz
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.)
Diffstat (limited to 'ext')
-rw-r--r--ext/POSIX/POSIX.xs80
1 files changed, 44 insertions, 36 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 8b1a41b0bc..8151d799ce 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