Compare commits
4 Commits
8c13513bf4
...
8748364b7e
Author | SHA1 | Date | |
---|---|---|---|
8748364b7e | |||
49662b6069 | |||
d96ff92461 | |||
bfb76b5625 |
@ -70,6 +70,7 @@ namespace TmpFS
|
|||||||
inode->set_device_id(luna_dev_makedev(major, minor), {});
|
inode->set_device_id(luna_dev_makedev(major, minor), {});
|
||||||
inode->m_metadata.mode = mode;
|
inode->m_metadata.mode = mode;
|
||||||
inode->m_metadata.atime = inode->m_metadata.ctime = inode->m_metadata.mtime = *Timer::realtime_clock();
|
inode->m_metadata.atime = inode->m_metadata.ctime = inode->m_metadata.mtime = *Timer::realtime_clock();
|
||||||
|
inode->m_metadata.size = device->size();
|
||||||
|
|
||||||
return (SharedPtr<VFS::Inode>)inode;
|
return (SharedPtr<VFS::Inode>)inode;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ set(SOURCES
|
|||||||
src/signal.cpp
|
src/signal.cpp
|
||||||
src/termios.cpp
|
src/termios.cpp
|
||||||
src/utime.cpp
|
src/utime.cpp
|
||||||
|
src/strtod.cpp
|
||||||
src/sys/stat.cpp
|
src/sys/stat.cpp
|
||||||
src/sys/mman.cpp
|
src/sys/mman.cpp
|
||||||
src/sys/wait.cpp
|
src/sys/wait.cpp
|
||||||
|
@ -84,9 +84,11 @@ extern "C"
|
|||||||
/* Parse a decimal integer from a string. */
|
/* Parse a decimal integer from a string. */
|
||||||
long long atoll(const char* s);
|
long long atoll(const char* s);
|
||||||
|
|
||||||
double atof(const char*);
|
/* Parse a floating-point number from a string. */
|
||||||
|
double atof(const char* str);
|
||||||
|
|
||||||
double strtod(const char*, char**);
|
/* Parse a floating-point number from a string. */
|
||||||
|
double strtod(const char* str, char** endptr);
|
||||||
|
|
||||||
/* Parse an integer of the specified base from a string, storing the first non-number character in endptr if
|
/* Parse an integer of the specified base from a string, storing the first non-number character in endptr if
|
||||||
* nonnull. */
|
* nonnull. */
|
||||||
|
@ -297,4 +297,9 @@ extern "C"
|
|||||||
if (errno != EEXIST) return -1;
|
if (errno != EEXIST) return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double atof(const char* str)
|
||||||
|
{
|
||||||
|
return strtod(str, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
141
libc/src/strtod.cpp
Normal file
141
libc/src/strtod.cpp
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
/* vi:set ts=8 sts=4 sw=4: */
|
||||||
|
/*
|
||||||
|
* strtod implementation.
|
||||||
|
* author: Yasuhiro Matsumoto
|
||||||
|
* license: public domain
|
||||||
|
*
|
||||||
|
* source from https://gist.github.com/mattn/1890186
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static const char* skipwhite(const char* q)
|
||||||
|
{
|
||||||
|
const char* p = q;
|
||||||
|
while (isspace(*p)) ++p;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
double strtod(const char* str, char** end)
|
||||||
|
{
|
||||||
|
double d = 0.0;
|
||||||
|
int sign;
|
||||||
|
int n = 0;
|
||||||
|
const char *p, *a;
|
||||||
|
|
||||||
|
a = p = str;
|
||||||
|
p = skipwhite(p);
|
||||||
|
|
||||||
|
/* decimal part */
|
||||||
|
sign = 1;
|
||||||
|
if (*p == '-')
|
||||||
|
{
|
||||||
|
sign = -1;
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
else if (*p == '+')
|
||||||
|
++p;
|
||||||
|
if (isdigit(*p))
|
||||||
|
{
|
||||||
|
d = (double)(*p++ - '0');
|
||||||
|
while (*p && isdigit(*p))
|
||||||
|
{
|
||||||
|
d = d * 10.0 + (double)(*p - '0');
|
||||||
|
++p;
|
||||||
|
++n;
|
||||||
|
}
|
||||||
|
a = p;
|
||||||
|
}
|
||||||
|
else if (*p != '.')
|
||||||
|
goto done;
|
||||||
|
d *= sign;
|
||||||
|
|
||||||
|
/* fraction part */
|
||||||
|
if (*p == '.')
|
||||||
|
{
|
||||||
|
double f = 0.0;
|
||||||
|
double base = 0.1;
|
||||||
|
++p;
|
||||||
|
|
||||||
|
if (isdigit(*p))
|
||||||
|
{
|
||||||
|
while (*p && isdigit(*p))
|
||||||
|
{
|
||||||
|
f += base * (*p - '0');
|
||||||
|
base /= 10.0;
|
||||||
|
++p;
|
||||||
|
++n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d += f * sign;
|
||||||
|
a = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* exponential part */
|
||||||
|
if ((*p == 'E') || (*p == 'e'))
|
||||||
|
{
|
||||||
|
int e = 0;
|
||||||
|
++p;
|
||||||
|
|
||||||
|
sign = 1;
|
||||||
|
if (*p == '-')
|
||||||
|
{
|
||||||
|
sign = -1;
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
else if (*p == '+')
|
||||||
|
++p;
|
||||||
|
|
||||||
|
if (isdigit(*p))
|
||||||
|
{
|
||||||
|
while (*p == '0') ++p;
|
||||||
|
if (*p == '\0') --p;
|
||||||
|
e = (int)(*p++ - '0');
|
||||||
|
while (*p && isdigit(*p))
|
||||||
|
{
|
||||||
|
e = e * 10 + (int)(*p - '0');
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
e *= sign;
|
||||||
|
}
|
||||||
|
else if (!isdigit(*(a - 1)))
|
||||||
|
{
|
||||||
|
a = str;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
else if (*p == 0)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
if (d == 2.2250738585072011 && e == -308)
|
||||||
|
{
|
||||||
|
d = 0.0;
|
||||||
|
a = p;
|
||||||
|
errno = ERANGE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (d == 2.2250738585072012 && e <= -308)
|
||||||
|
{
|
||||||
|
d *= 1.0e-308;
|
||||||
|
a = p;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
d *= __builtin_powi(10.0, e);
|
||||||
|
a = p;
|
||||||
|
}
|
||||||
|
else if (p > str && !isdigit(*(p - 1)))
|
||||||
|
{
|
||||||
|
a = str;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (end) *end = const_cast<char*>(a);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ Try to keep this list in alphabetical order.
|
|||||||
Name | Version | Description | URL
|
Name | Version | Description | URL
|
||||||
---|---|--- | ---
|
---|---|--- | ---
|
||||||
bc | 6.6.0 | An implementation of the POSIX bc calculator | https://github.com/gavinhoward/bc
|
bc | 6.6.0 | An implementation of the POSIX bc calculator | https://github.com/gavinhoward/bc
|
||||||
|
binutils | 2.39 | The GNU suite of binary utilities | https://www.gnu.org/software/binutils
|
||||||
minitar | 1.7.5 | Tiny and easy-to-use C library to read/write tar archives | https://git.cloudapio.eu/apio/minitar
|
minitar | 1.7.5 | Tiny and easy-to-use C library to read/write tar archives | https://git.cloudapio.eu/apio/minitar
|
||||||
nasm | 2.16.01 | An assembler for the x86 CPU architecture | https://nasm.us
|
nasm | 2.16.01 | An assembler for the x86 CPU architecture | https://nasm.us
|
||||||
|
|
||||||
|
30
ports/binutils/PACKAGE
Normal file
30
ports/binutils/PACKAGE
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Basic information
|
||||||
|
name="binutils"
|
||||||
|
version="2.39"
|
||||||
|
|
||||||
|
# Download options
|
||||||
|
format="tar"
|
||||||
|
url="https://ftp.gnu.org/gnu/binutils/binutils-$version.tar.gz"
|
||||||
|
output="binutils-$version.tar.gz"
|
||||||
|
sha256sum="d12ea6f239f1ffe3533ea11ad6e224ffcb89eb5d01bbea589e9158780fa11f10"
|
||||||
|
|
||||||
|
# Build instructions
|
||||||
|
default_build_make=true
|
||||||
|
|
||||||
|
do_patch()
|
||||||
|
{
|
||||||
|
patch -ui $portdir/binutils.patch -p 1 -d $srcdir/..
|
||||||
|
}
|
||||||
|
|
||||||
|
do_configure()
|
||||||
|
{
|
||||||
|
$srcdir/configure --host=$LUNA_ARCH-luna --disable-nls --disable-werror --enable-warn-rwx-segments=no --prefix=/usr --enable-gold=no --enable-ld=yes --enable-gprofng=no
|
||||||
|
}
|
||||||
|
|
||||||
|
do_install()
|
||||||
|
{
|
||||||
|
make install
|
||||||
|
|
||||||
|
cd $installdir/usr/bin
|
||||||
|
$LUNA_ARCH-luna-strip size objdump ar strings ranlib objcopy addr2line readelf elfedit nm strip c++filt as gprof ld.bfd ld
|
||||||
|
}
|
117
ports/binutils/binutils.patch
Normal file
117
ports/binutils/binutils.patch
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
diff --color -rN -u binutils-2.39/bfd/config.bfd build/binutils-2.39/bfd/config.bfd
|
||||||
|
--- a/binutils-2.39/bfd/config.bfd 2022-01-22 13:14:07.000000000 +0100
|
||||||
|
+++ b/binutils-2.39/bfd/config.bfd 2022-10-01 22:12:16.914033792 +0200
|
||||||
|
@@ -651,6 +651,11 @@
|
||||||
|
targ_selvecs="iamcu_elf32_vec i386_pei_vec"
|
||||||
|
targ64_selvecs="x86_64_elf64_vec x86_64_elf32_vec x86_64_pe_vec x86_64_pei_vec l1om_elf64_vec k1om_elf64_vec"
|
||||||
|
;;
|
||||||
|
+ i[3-7]86-*-luna*)
|
||||||
|
+ targ_defvec=i386_elf32_vec
|
||||||
|
+ targ_selvecs=
|
||||||
|
+ targ64_selvecs=x86_64_elf64_vec
|
||||||
|
+ ;;
|
||||||
|
i[3-7]86-*-redox*)
|
||||||
|
targ_defvec=i386_elf32_vec
|
||||||
|
targ_selvecs=
|
||||||
|
@@ -706,6 +711,11 @@
|
||||||
|
targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec i386_pei_vec x86_64_pe_vec x86_64_pei_vec l1om_elf64_vec k1om_elf64_vec"
|
||||||
|
want64=true
|
||||||
|
;;
|
||||||
|
+ x86_64-*-luna*)
|
||||||
|
+ targ_defvec=x86_64_elf64_vec
|
||||||
|
+ targ_selvecs=i386_elf32_vec
|
||||||
|
+ want64=true
|
||||||
|
+ ;;
|
||||||
|
x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin)
|
||||||
|
targ_defvec=x86_64_pe_vec
|
||||||
|
targ_selvecs="x86_64_pe_vec x86_64_pei_vec x86_64_pe_big_vec x86_64_elf64_vec l1om_elf64_vec k1om_elf64_vec i386_pe_vec i386_pei_vec i386_elf32_vec iamcu_elf32_vec"
|
||||||
|
diff --color -rN -u binutils-2.39/gas/configure.tgt build/binutils-2.39/gas/configure.tgt
|
||||||
|
--- a/binutils-2.39/gas/configure.tgt 2022-01-22 13:14:08.000000000 +0100
|
||||||
|
+++ b/binutils-2.39/gas/configure.tgt 2022-10-01 22:12.39.115093972 +0200
|
||||||
|
@@ -238,6 +238,7 @@
|
||||||
|
x86_64*-linux-gnux32) arch=x86_64:32 ;;
|
||||||
|
esac ;;
|
||||||
|
i386-*-lynxos*) fmt=elf em=lynx ;;
|
||||||
|
+ i386-*-luna*) fmt=elf em=gnu ;;
|
||||||
|
i386-*-redox*) fmt=elf ;;
|
||||||
|
i386-*-solaris*) fmt=elf em=solaris ;;
|
||||||
|
i386-*-freebsd* \
|
||||||
|
diff --color -rN -u binutils-2.39/ld/configure.tgt build/binutils-2.39/ld/configure.tgt
|
||||||
|
--- a/binutils-2.39/ld/configure.tgt 2022-01-22 15:19:36.000000000 +0100
|
||||||
|
+++ b/binutils-2.39/ld/configure.tgt 2022-10-01 22:15:04.853571062 +0200
|
||||||
|
@@ -329,6 +329,11 @@
|
||||||
|
targ64_extra_emuls="elf_x86_64 elf32_x86_64 elf_l1om elf_k1om"
|
||||||
|
targ64_extra_libpath="elf_x86_64 elf32_x86_64"
|
||||||
|
;;
|
||||||
|
+i[3-7]86-*-luna*)
|
||||||
|
+ targ_emul=elf_i386_luna
|
||||||
|
+ targ_extra_emuls=elf_i386
|
||||||
|
+ targ64_extra_emuls="elf_x86_64_luna elf_x86_64"
|
||||||
|
+ ;;
|
||||||
|
i[3-7]86-*-redox*) targ_emul=elf_i386
|
||||||
|
targ_extra_emuls=elf_x86_64
|
||||||
|
;;
|
||||||
|
@@ -967,6 +972,10 @@
|
||||||
|
targ_extra_libpath="elf_i386 elf32_x86_64 elf_l1om elf_k1om"
|
||||||
|
tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
|
||||||
|
;;
|
||||||
|
+x86_64-*-luna*)
|
||||||
|
+ targ_emul=elf_x86_64_luna
|
||||||
|
+ targ_extra_emuls="elf_i386_luna elf_x86_64 elf_i386"
|
||||||
|
+ ;;
|
||||||
|
x86_64-*-redox*) targ_emul=elf_x86_64
|
||||||
|
targ_extra_emuls=elf_i386
|
||||||
|
;;
|
||||||
|
diff --color -rN -u binutils-2.39/ld/emulparams/elf_i386_luna.sh build/binutils-2.39/ld/emulparams/elf_i386_luna.sh
|
||||||
|
--- a/dev/null 1970-01-01 01:00:00.000000000 +0100
|
||||||
|
+++ b/binutils-2.39/ld/emulparams/elf_i386_luna.sh 2022-10-01 21:52:12.394068335 +0200
|
||||||
|
@@ -0,0 +1,3 @@
|
||||||
|
+source_sh ${srcdir}/emulparams/elf_i386.sh
|
||||||
|
+TEXT_START_ADDR=0x08000000
|
||||||
|
+MAXPAGESIZE=0x1000
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --color -rN -u binutils-2.39/ld/emulparams/elf_x86_64_luna.sh build/binutils-2.39/ld/emulparams/elf_x86_64_luna.sh
|
||||||
|
--- a/dev/null 1970-01-01 01:00:00.000000000 +0100
|
||||||
|
+++ b/binutils-2.39/ld/emulparams/elf_x86_64_luna.sh 2022-10-01 21:53:00.411200592 +0200
|
||||||
|
@@ -0,0 +1,2 @@
|
||||||
|
+source_sh ${srcdir}/emulparams/elf_x86_64.sh
|
||||||
|
+MAXPAGESIZE=0x1000
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --color -rN -u binutils-2.39/ld/Makefile.am build/binutils-2.39/ld/Makefile.am
|
||||||
|
--- a/binutils-2.39/ld/Makefile.am 2022-01-22 13:14:09.000000000 +0100
|
||||||
|
+++ b/binutils-2.39/ld/Makefile.am 2022-10-01 22:18:02.660263017 +0200
|
||||||
|
@@ -278,6 +278,7 @@
|
||||||
|
eelf32xtensa.c \
|
||||||
|
eelf32z80.c \
|
||||||
|
eelf_i386.c \
|
||||||
|
+ eelf_i386_luna.c \
|
||||||
|
eelf_i386_be.c \
|
||||||
|
eelf_i386_fbsd.c \
|
||||||
|
eelf_i386_haiku.c \
|
||||||
|
@@ -464,6 +465,7 @@
|
||||||
|
eelf_x86_64_fbsd.c \
|
||||||
|
eelf_x86_64_haiku.c \
|
||||||
|
eelf_x86_64_sol2.c \
|
||||||
|
+ eelf_x86_64_luna.c \
|
||||||
|
ehppa64linux.c \
|
||||||
|
ei386pep.c \
|
||||||
|
emmo.c
|
||||||
|
diff --color -rN -u binutils-2.39/ld/Makefile.in build/binutils-2.39/ld/Makefile.in
|
||||||
|
--- a/binutils-2.39/ld/Makefile.in 2022-02-09 12:49:03.000000000 +0100
|
||||||
|
+++ b/binutils-2.39/ld/Makefile.in 2022-10-01 22:17:46.740196925 +0200
|
||||||
|
@@ -769,6 +769,7 @@
|
||||||
|
eelf32xtensa.c \
|
||||||
|
eelf32z80.c \
|
||||||
|
eelf_i386.c \
|
||||||
|
+ eelf_i386_luna.c \
|
||||||
|
eelf_i386_be.c \
|
||||||
|
eelf_i386_fbsd.c \
|
||||||
|
eelf_i386_haiku.c \
|
||||||
|
@@ -954,6 +955,7 @@
|
||||||
|
eelf_x86_64_fbsd.c \
|
||||||
|
eelf_x86_64_haiku.c \
|
||||||
|
eelf_x86_64_sol2.c \
|
||||||
|
+ eelf_x86_64_luna.c \
|
||||||
|
ehppa64linux.c \
|
||||||
|
ei386pep.c \
|
||||||
|
emmo.c
|
@ -7,6 +7,10 @@ cd $LUNA_ROOT
|
|||||||
|
|
||||||
fakeroot -u -s $LUNA_ROOT/.fakeroot -- tools/install.sh
|
fakeroot -u -s $LUNA_ROOT/.fakeroot -- tools/install.sh
|
||||||
|
|
||||||
fakeroot -u -i $LUNA_ROOT/.fakeroot -- genext2fs -d base -B 4096 -b 8192 -L luna-rootfs -N 2048 build/ext2fs.bin
|
disk_space=$(du -s base | awk '{ print $1 }')
|
||||||
|
min_blocks=$(($disk_space / 4)) # This is just the blocks needed for all the files in the file system: this excludes space for the inode table, block group descriptors, etc.
|
||||||
|
blocks=$(($min_blocks + 1024)) # This is the actual number of blocks we're using.
|
||||||
|
|
||||||
|
fakeroot -u -i $LUNA_ROOT/.fakeroot -- genext2fs -d base -B 4096 -b $blocks -L luna-rootfs -N 1024 build/ext2fs.bin
|
||||||
|
|
||||||
mkbootimg luna.json Luna.iso
|
mkbootimg luna.json Luna.iso
|
||||||
|
Loading…
Reference in New Issue
Block a user