minimal-bootstrap.mes: vendor ldexpl.c

This commit is contained in:
Sizhe Zhao
2026-02-27 20:24:32 +08:00
parent 56119b444e
commit df2326d689
2 changed files with 36 additions and 6 deletions
@@ -0,0 +1,35 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2025 Stefan <stefan-guix@vodafonemail.de>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <math.h>
long double
ldexpl (long double arg, int exp)
{
if (exp > 0)
do
arg *= 2;
while (--exp);
else if (exp < 0)
do
arg /= 2;
while (++exp);
return arg;
}
@@ -21,18 +21,13 @@ let
sources = (import ./sources.nix).${arch}.linux.gcc;
inherit (sources) libtcc1_SOURCES libc_gnu_SOURCES;
ldexpl = fetchurl {
url = "https://gitlab.com/janneke/mes/-/raw/c837abed8edb341d4e56913729fbe9803b4de47c/lib/math/ldexpl.c";
hash = "sha256-3QoFZZIqVmlMUosEqOdYIMEHzYgQ7GJ7Hz0Bf/1iIig=";
};
# Concatenate all source files into a convenient bundle
# "gcc" variants of source files (eg. "lib/linux/x86-mes-gcc") can also be
# compiled by tinycc
#
# Passing this many arguments is too much for kaem so we need to split
# the operation in two
firstLibc = (lib.take 100 libc_gnu_SOURCES) ++ [ ldexpl ];
firstLibc = (lib.take 100 libc_gnu_SOURCES) ++ [ ./ldexpl.c ];
lastLibc = lib.drop 100 libc_gnu_SOURCES;
in
kaem.runCommand "${pname}-${version}"