From f41935fef73f977cd0761c721b28969de5d44920 Mon Sep 17 00:00:00 2001 From: diviocity Date: Sun, 29 Nov 2026 23:52:15 +0100 Subject: [PATCH] mpfr and mpc: build and exercise the GNU arithmetic libraries --- mpc/PKGBUILD.vile | 23 +++++++++++++++++++++++ mpfr/PKGBUILD.vile | 23 +++++++++++++++++++++++ tests/toolchain/arithmetic.c | 26 ++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 mpc/PKGBUILD.vile create mode 100644 mpfr/PKGBUILD.vile create mode 100644 tests/toolchain/arithmetic.c diff --git a/mpc/PKGBUILD.vile b/mpc/PKGBUILD.vile new file mode 100644 index 0000000..b89ba3e --- /dev/null +++ b/mpc/PKGBUILD.vile @@ -0,0 +1,23 @@ +defpkgbuild(mpc, + #:pkgname, "mpc", + #:pkgver, "1.3.1", + #:pkgrel, 1, + #:pkgdesc, "Multiple precision complex arithmetic", + #:arch, [#:x86-64], + #:url, "https://www.multiprecision.org/mpc/", + #:license, "LGPL-3.0-or-later", + #:depends, ["musl", "gmp", "mpfr"], + #:source, ["https://distfiles.alpinelinux.org/distfiles/v3.21/mpc-1.3.1.tar.gz"], + #:sha256sums, ["ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8"], + #:build, fn() { + run("env", "CC=vinix-cc", "CFLAGS=-O2 -std=gnu17", "CC_FOR_BUILD=gcc", "mpc-1.3.1/configure", "--prefix=/usr", + "--build=x86_64-pc-linux-gnu", "--host=x86_64-linux-musl", "--enable-shared", "--enable-static") + run("make") + }, + #:package, fn() { + run("make", string-append("DESTDIR=", pkgdir()), "install") + run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir")) + run("test", "-f", string-append(pkgdir(), "/usr/lib/libmpc.so")) + run("rm", string-append(pkgdir(), "/usr/lib/libmpc.la")) + run("install", "-Dm644", "mpc-1.3.1/COPYING.LESSER", string-append(pkgdir(), "/usr/share/licenses/mpc/COPYING")) + }) diff --git a/mpfr/PKGBUILD.vile b/mpfr/PKGBUILD.vile new file mode 100644 index 0000000..ba2336e --- /dev/null +++ b/mpfr/PKGBUILD.vile @@ -0,0 +1,23 @@ +defpkgbuild(mpfr, + #:pkgname, "mpfr", + #:pkgver, "4.2.1", + #:pkgrel, 1, + #:pkgdesc, "Multiple precision floating-point arithmetic with correct rounding", + #:arch, [#:x86-64], + #:url, "https://www.mpfr.org/", + #:license, "LGPL-3.0-or-later", + #:depends, ["musl", "gmp"], + #:source, ["https://distfiles.alpinelinux.org/distfiles/v3.21/mpfr-4.2.1.tar.xz"], + #:sha256sums, ["277807353a6726978996945af13e52829e3abd7a9a5b7fb2793894e18f1fcbb2"], + #:build, fn() { + run("env", "CC=vinix-cc", "CFLAGS=-O2 -std=gnu17", "CC_FOR_BUILD=gcc", "mpfr-4.2.1/configure", "--prefix=/usr", + "--build=x86_64-pc-linux-gnu", "--host=x86_64-linux-musl", "--enable-shared", "--enable-static") + run("make") + }, + #:package, fn() { + run("make", string-append("DESTDIR=", pkgdir()), "install") + run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir")) + run("test", "-f", string-append(pkgdir(), "/usr/lib/libmpfr.so")) + run("rm", string-append(pkgdir(), "/usr/lib/libmpfr.la")) + run("install", "-Dm644", "mpfr-4.2.1/COPYING.LESSER", string-append(pkgdir(), "/usr/share/licenses/mpfr/COPYING")) + }) diff --git a/tests/toolchain/arithmetic.c b/tests/toolchain/arithmetic.c new file mode 100644 index 0000000..6ad544c --- /dev/null +++ b/tests/toolchain/arithmetic.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +int main(void) +{ + mpz_t integer; + mpfr_t real; + mpc_t number; + mpz_init_set_ui(integer, 27); + mpz_mul_ui(integer, integer, 11); + mpfr_init2(real, 128); + mpfr_set_z(real, integer, MPFR_RNDN); + mpc_init2(number, 128); + mpc_set_fr(number, real, MPC_RNDNN); + mpc_sqr(number, number, MPC_RNDNN); + int ok = mpfr_cmp_ui(mpc_realref(number), 88209) == 0 + && mpfr_zero_p(mpc_imagref(number)); + mpc_clear(number); + mpfr_clear(real); + mpz_clear(integer); + if (ok) + puts("Vinix C, GMP, MPFR and MPC passed"); + return ok ? 0 : 1; +} -- 2.56.1