Some libraries like x265 fmpeg codec is linked
to reference libc aliases of some math functions like
log*, exp and pow ones. Unfortunately because our
versions of these funcions are provided by musl
and we do not modify musl code we cannot
add aliases by simple weak_alias construct.

Therefore we add simple stub files in libc
where we define functions with alias names that delegate
to corresponding functions provided by musl.

Another alternative would be to copy corresponding
files from musl to libc directory and add weak_alias there.
This would be slightly more performant as we would avoid
unnecessary instructions involved in calling a function.

Signed-off-by: Waldemar Kozaczuk <[email protected]>
---
 Makefile          | 5 +++++
 libc/math/exp.c   | 6 ++++++
 libc/math/log.c   | 6 ++++++
 libc/math/log10.c | 6 ++++++
 libc/math/log2.c  | 6 ++++++
 libc/math/pow.c   | 6 ++++++
 6 files changed, 35 insertions(+)
 create mode 100644 libc/math/exp.c
 create mode 100644 libc/math/log.c
 create mode 100644 libc/math/log10.c
 create mode 100644 libc/math/log2.c
 create mode 100644 libc/math/pow.c

diff --git a/Makefile b/Makefile
index 2270206b..c475f311 100644
--- a/Makefile
+++ b/Makefile
@@ -1145,6 +1145,7 @@ musl += math/erf.o
 musl += math/erff.o
 musl += math/erfl.o
 musl += math/exp.o
+libc += math/exp.o
 musl += math/exp10.o
 musl += math/exp10f.o
 musl += math/exp10l.o
@@ -1214,13 +1215,16 @@ musl += math/llround.o
 musl += math/llroundf.o
 musl += math/llroundl.o
 musl += math/log.o
+libc += math/log.o
 musl += math/log10.o
+libc += math/log10.o
 musl += math/log10f.o
 musl += math/log10l.o
 musl += math/log1p.o
 musl += math/log1pf.o
 musl += math/log1pl.o
 musl += math/log2.o
+libc += math/log2.o
 musl += math/log2f.o
 musl += math/log2l.o
 musl += math/logb.o
@@ -1253,6 +1257,7 @@ musl += math/nexttoward.o
 musl += math/nexttowardf.o
 musl += math/nexttowardl.o
 musl += math/pow.o
+libc += math/pow.o
 musl += math/powf.o
 musl += math/powl.o
 musl += math/remainder.o
diff --git a/libc/math/exp.c b/libc/math/exp.c
new file mode 100644
index 00000000..cba01a32
--- /dev/null
+++ b/libc/math/exp.c
@@ -0,0 +1,6 @@
+#include "libm.h"
+
+double __exp_finite(double x)
+{
+       return exp(x);
+}
diff --git a/libc/math/log.c b/libc/math/log.c
new file mode 100644
index 00000000..50709e09
--- /dev/null
+++ b/libc/math/log.c
@@ -0,0 +1,6 @@
+#include "libm.h"
+
+double __log_finite(double x)
+{
+       return log(x);
+}
diff --git a/libc/math/log10.c b/libc/math/log10.c
new file mode 100644
index 00000000..39201935
--- /dev/null
+++ b/libc/math/log10.c
@@ -0,0 +1,6 @@
+#include "libm.h"
+
+double __log10_finite(double x)
+{
+       return log10(x);
+}
diff --git a/libc/math/log2.c b/libc/math/log2.c
new file mode 100644
index 00000000..4167230a
--- /dev/null
+++ b/libc/math/log2.c
@@ -0,0 +1,6 @@
+#include "libm.h"
+
+double __log2_finite(double x)
+{
+       return log2(x);
+}
diff --git a/libc/math/pow.c b/libc/math/pow.c
new file mode 100644
index 00000000..28ba1d5d
--- /dev/null
+++ b/libc/math/pow.c
@@ -0,0 +1,6 @@
+#include "libm.h"
+
+double __pow_finite(double x, double y)
+{
+       return pow(x, y);
+}
-- 
2.19.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to