Bug 933257 - Part 1: Add a script to import and update fdlibm from FreeBSD. r=jwalden
☠☠ backed out by c877b27955a3 ☠ ☠
authorTooru Fujisawa <arai_a@mac.com>
Thu, 07 Jan 2016 12:30:26 +0900
changeset 339771 ec80e2d4cccea6eaaabbd081ca7ba1116632039b
parent 339770 17eabd8512ffecbb895e5366771e84e5035fd312
child 339772 3025ae7a344558e29c6348d8ea2325e7858c032a
push id12803
push userjbeich@FreeBSD.org
push dateSun, 13 Mar 2016 09:48:54 +0000
reviewersjwalden
bugs933257
milestone48.0a1
Bug 933257 - Part 1: Add a script to import and update fdlibm from FreeBSD. r=jwalden
modules/fdlibm/README.mozilla
modules/fdlibm/import.sh
modules/fdlibm/update.sh
new file mode 100644
--- /dev/null
+++ b/modules/fdlibm/README.mozilla
@@ -0,0 +1,17 @@
+This is the fdlibm library imported from
+https://github.com/freebsd/freebsd
+
+Upstream code can be viewed at
+  https://github.com/freebsd/freebsd/tree/master/lib/msun/src
+
+Each file is downloaded separately, as cloning whole repository takes so much
+resources.
+
+The in-tree copy is updated by running
+  sh update.sh
+from within the modules/fdlibm directory.
+
+Current version: [commit 0000000000000000000000000000000000000000].
+
+patches 01-16 fixes files to be usable within mozilla-central tree.
+See https://bugzilla.mozilla.org/show_bug.cgi?id=933257
new file mode 100644
--- /dev/null
+++ b/modules/fdlibm/import.sh
@@ -0,0 +1,111 @@
+#!/bin/sh
+
+set -e
+
+BASE_URL=https://raw.githubusercontent.com/freebsd/freebsd/master/lib/msun/src
+
+function download_source() {
+    REMOTE_FILENAME=$1
+    LOCAL_FILENAME=$2
+    curl -o "src/${LOCAL_FILENAME}" "${BASE_URL}/${REMOTE_FILENAME}"
+}
+
+mkdir -p src
+
+# headers
+download_source math.h fdlibm.h
+download_source math_private.h math_private.h
+
+# Math.acos
+download_source e_acos.c e_acos.cpp
+
+# Math.acosh
+download_source e_acosh.c e_acosh.cpp
+
+# Math.asin
+download_source e_asin.c e_asin.cpp
+
+# Math.asinh
+download_source s_asinh.c s_asinh.cpp
+
+# Math.atan
+download_source s_atan.c s_atan.cpp
+
+# Math.atanh
+download_source e_atanh.c e_atanh.cpp
+
+# Math.atan2
+download_source e_atan2.c e_atan2.cpp
+
+# Math.cbrt
+download_source s_cbrt.c s_cbrt.cpp
+
+# Math.ceil
+download_source s_ceil.c s_ceil.cpp
+download_source s_ceilf.c s_ceilf.cpp
+
+# Math.cos
+download_source k_cos.c k_cos.cpp
+download_source s_cos.c s_cos.cpp
+
+# Math.cosh
+download_source e_cosh.c e_cosh.cpp
+
+# Math.exp
+download_source e_exp.c e_exp.cpp
+
+# Math.expm1
+download_source s_expm1.c s_expm1.cpp
+
+# Math.floor and Math.round
+download_source s_floor.c s_floor.cpp
+
+# Math.fround
+download_source s_floorf.c s_floorf.cpp
+
+# Math.hypot
+download_source e_hypot.c e_hypot.cpp
+
+# Math.log
+download_source e_log.c e_log.cpp
+
+# Math.log1p
+download_source s_log1p.c s_log1p.cpp
+
+# Math.log10
+download_source e_log10.c e_log10.cpp
+download_source k_log.h k_log.h
+
+# Math.log2
+download_source e_log2.c e_log2.cpp
+
+# Math.pow
+download_source e_pow.c e_pow.cpp
+
+# Math.sin
+download_source k_sin.c k_sin.cpp
+download_source s_sin.c s_sin.cpp
+
+# Math.sinh
+download_source e_sinh.c e_sinh.cpp
+
+# Math.sqrt
+download_source e_sqrt.c e_sqrt.cpp
+
+# Math.tan
+download_source k_tan.c k_tan.cpp
+download_source s_tan.c s_tan.cpp
+
+# Math.tanh
+download_source s_tanh.c s_tanh.cpp
+
+# Math.trunc
+download_source s_trunc.c s_trunc.cpp
+
+# dependencies
+download_source e_rem_pio2.c e_rem_pio2.cpp
+download_source k_exp.c k_exp.cpp
+download_source k_rem_pio2.c k_rem_pio2.cpp
+download_source s_copysign.c s_copysign.cpp
+download_source s_fabs.c s_fabs.cpp
+download_source s_scalbn.c s_scalbn.cpp
new file mode 100644
--- /dev/null
+++ b/modules/fdlibm/update.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Script to update the mozilla in-tree copy of the fdlibm library.
+# Run this within the /modules/fdlibm directory of the source tree.
+
+set -e
+
+API_BASE_URL=https://api.github.com/repos/freebsd/freebsd
+
+function get_commit {
+    curl -s "${API_BASE_URL}/commits?path=lib/msun/src&per_page=1" \
+        | python -c 'import json, sys; print(json.loads(sys.stdin.read())[0]["sha"])'
+}
+
+rm -rf src
+BEFORE_COMMIT=$(get_commit)
+sh ./import.sh
+COMMIT=$(get_commit)
+if [ ${BEFORE_COMMIT} != ${COMMIT} ]; then
+    echo "Latest commit is changed during import.  Please run again."
+    exit 1
+fi
+for FILE in $(ls patches/*.patch | sort); do
+    patch -p3 < ${FILE}
+done
+hg add src
+
+perl -p -i -e "s/\[commit [0-9a-f]{40}\]/[commit ${COMMIT}]/" README.mozilla
+
+echo "###"
+echo "### Updated fdlibm/src to ${COMMIT}."
+echo "### Remember to verify and commit the changes to source control!"
+echo "###"