Commit graph

190 commits

Author SHA1 Message Date
Lephenixnoir
09610f59de
stdlib: fix atoi()/strto*() pulling in the entirety of scanf
This was due to the few base __scanf() functions, used by strto*() and
co. to share their framework with scanf() specifiers, being in the main
scanf() file. Not sure why it ended up pulling the entire file even with
LTO, but now that it's separate there's no issue anymore.

Pulling in the entirety of scanf() is mostly expensive because it
contains specifiers(), including strtod(), which itself computes on
floating point numbers, leading to many libm functions being linked in,
some of them with their internal data tables.

In the end you'd call atoi() and get a 24-kB size increase.
Which is not great :)
2024-11-19 12:33:26 +01:00
Lephenixnoir
c16a1a3be6
fix: strcasecmp() return value being case-sensitive 2024-10-22 16:00:54 +02:00
Lephenixnoir
8cedf411c4
gint: outline a Hardware Abstraction Layer (HAL) for use with gint
A standard libc would normally use the kernel's syscall interface to
connect with the lower level, and this interface would usually imitate
POSIX or a similar style. With the statically-linked unikernel design,
the syscalls would be functions, but the interface wouldn't change much.

However, there are some fundamental differences. For instance, in gint
there aren't separate kernel/userspace memory allocators, there's just a
unified allocator in the kernel. This makes malloc() conceptually a
direct syscall, which pushes the kernel/libc boundary at an unusual
location.

Having a clearly-marked HAL makes it easier to identify where the
boundary is. Code from <time.h> currently has an ad-hoc interface which
should be replaced with clock_gettime(2) in the future.

The HAL offers default implementations but these aren't used by gint
yet, because it's more practical to have undefined references than to
end up with the stubs in an executable. These are provided for future
completeness.

This change does not lift the requirement to recursively link gint with
the libc and the libc with gint.
2024-08-06 18:55:01 +02:00
Lephenixnoir
e2f458fa3d
bump version to 1.5.1 2024-07-06 08:54:03 +02:00
Lephenixnoir
dd735428b0
fix: uppercase letters not recognized by strtol() etc. 2024-07-06 08:51:51 +02:00
Lephenixnoir
83d0ab858e
fix: mark _Exit noreturn to avoid a warning 2024-07-06 08:47:01 +02:00
Lephenixnoir
26cdf5f9d8
add more declarations for libstdc++
follow-up to 8231557ff5
2024-07-05 22:28:52 +02:00
Lephenixnoir
6b0ea3f33e
meta: enable LTO
Also set -Wa,--dsp also on C files because the fxSDK sets it globally
and LTO complains if -Wa/-Xassembler options are not uniform across all
compilation units.
2024-05-27 19:06:22 +02:00
Yann MAGNIN
d6f709f36e
hotfix compilation error for _exit() (again) 2024-05-27 19:06:22 +02:00
Yann MAGNIN
14e7e2364b
hotfix compilation error for _exit() 2024-05-27 19:06:22 +02:00
Yann MAGNIN
1a87c1eae2
exposes _exit() as an alias to _Exit() to support the libSSP with GGC 14.1 2024-05-27 19:06:22 +02:00
Lephenixnoir
46c73cbc87
stdio: fix %N.Ms miscalculating spacing if M > strlen(arg) 2024-02-04 20:13:25 +01:00
Lephenixnoir
05ff5e246d
bump version to 1.5.0 2024-01-14 23:02:59 +01:00
Lephenixnoir
1b87af5d83
stdio: mark *scanf() as TEST 2024-01-14 22:03:59 +01:00
Lephenixnoir
be4c2b8d33
stdio: fix bypassed __scanf_end at end of scanf 2024-01-14 22:02:53 +01:00
Lephenixnoir
0cef8ca891
stdio: slight cleanup and documentation 2024-01-14 21:58:03 +01:00
Lephenixnoir
177c4eea3f
stdio: more compact scanf format parsing 2024-01-14 21:34:46 +01:00
Lephenixnoir
527c2e48fc
stdio: more syntaxic refactoring of scanf 2024-01-14 21:27:48 +01:00
Lephenixnoir
9f6e0c8039
stdio: factor out format parsing in scanf 2024-01-14 21:20:40 +01:00
Lephenixnoir
1caaa8ff63
stdio: use compact storage for %[] set in scanf
256 bytes of globals is a *lot* on the G-III.
2024-01-14 20:36:09 +01:00
Lephenixnoir
5b85d53826
(formatting: case indent) 2024-01-14 20:23:55 +01:00
Lephenixnoir
55ae7df318
stdio: simplify output size management in scanf 2024-01-14 20:23:21 +01:00
Lephenixnoir
69eadb67d2
stdio: deduplicate scanf cases and remove most gotos 2024-01-14 20:07:24 +01:00
Lephenixnoir
b11c059c0f
stdio: start simplifying scanf limit tracking logic
Basically removing it from the __scanf_input structure and specializing
it at format sites. The reason is that pretending it's the end of the
stream after the limit is reached does not work because we have to
return EOF at end of stream but not when the limit is hit. So we have to
handle it explicitly, and since we do, no need to have it in the
structure too.
2024-01-14 19:28:36 +01:00
Lephenixnoir
2215b3c267
stdio: make all scanf tests pass
The tests are still far from exhaustive but that's a good start.
2024-01-14 17:31:21 +01:00
Lephenixnoir
b61cc096d9
stdio: fix scanf buffering so all tests pass
Code factoring and performance improvements will follow.
2024-01-14 17:31:19 +01:00
Lephenixnoir
c776336a0d
stdio: fix scanf bounds breaking strto*
Mostly an initialization problem. But I also optimized the check by
making the bound a maximal unsigned integer when there is no bound,
since __scanf_peek() is used a lot.
2024-01-14 17:31:15 +01:00
Lephenixnoir
d8a55b728d
stdlib: restore private headers 2024-01-14 13:48:41 +01:00
Slyvtt
09b33ca2fa
stdlib: scanf implementation by SlyVTT
Authored-By: Slyvtt <pillot.sylvain@gmail.com>
2023-05-26 21:04:37 +02:00
Lephenixnoir
031e0ccb65
bump version to 1.4.5 2023-04-01 20:30:30 +02:00
Lephenixnoir
74b805e8b5
stdlib: automatically seed PRNG with srand(1) 2023-04-01 20:30:30 +02:00
Yann MAGNIN
7eb2a6e8ab
add shared lib generation support for Vhex 2023-04-01 20:30:30 +02:00
Yann MAGNIN
c85182d07e
update vxSDK integration 2023-04-01 20:30:30 +02:00
Lephenixnoir
465655674b
dso: dynamically allocate destructor table
This saves static memory on mono targets where it's scarce.
2023-04-01 20:30:30 +02:00
Lephenixnoir
1da9d10226
alloca: provide <alloca.h> 2023-04-01 20:30:30 +02:00
Lephenixnoir
7c4de3e295
dso, stdlib: __cxa_atexit(), __dso_handle, atexit() (TEST) 2023-04-01 20:30:30 +02:00
Lephenixnoir
95e33092ec
stdlib: add fileno (DONE) 2023-04-01 20:30:29 +02:00
Lephenixnoir
26e54af8e0
stdlib: scanf-friendly strto* functions 2023-04-01 20:30:29 +02:00
Lephenixnoir
fda0d950ed
time: fix strftime being called strftime2 2023-04-01 20:30:29 +02:00
Lephenixnoir
eb83e7442f Merge pull request 'Fix signedness issues with strcmp and strncmp' (#4) from Heath123/fxlibc:heath123-patch-1 into master
Reviewed-on: https://gitea.planet-casio.com/Vhex-Kernel-Core/fxlibc/pulls/4
2022-11-24 14:23:21 +01:00
Heath Mitchell
aeeae3810d Update 'src/string/strcmp.c' 2022-11-24 13:36:02 +01:00
Heath Mitchell
ee42660ea5 Update 'src/string/strncmp.c' 2022-11-24 13:30:46 +01:00
Lephenixnoir
ddec761f61
bump version to 1.4.4 2022-08-21 20:09:54 +02:00
Lephenixnoir
ca6c39bf56
meta: update build instructions 2022-08-21 17:11:28 +02:00
Lephenixnoir
4b61daa602
stdio: use non-zero values for SEEK_*
libstdc++ uses 0, SEEK_CUR, SEEK_END in an internal enumeration. By
having SEEK_CUR=0 we would have a duplicate case.
2022-08-19 15:49:54 +02:00
Lephenixnoir
8231557ff5
add declarations for unsupported functions for libstdc++
So that it compiles - it won't link but we can leave that for later.
2022-08-19 15:49:52 +02:00
Lephenixnoir
714e1cf605
signal: make sig_atomic_t a normal int
Using the _Atomic types is technically more accurate, but equivalent in
practice (glibc uses a normal int) and a bit of a headache for C++
targets since _Atomic is replaced with std::atomic.
2022-08-12 22:46:56 +02:00
Lephenixnoir
ed52c1d7c2
sys/mman: fix missing include 2022-08-12 22:46:46 +02:00
Lephenixnoir
143029a837
stdint: do not rely on -ffreestanding
GCC's default stdint.h only defaults to stdint-gcc.h, which we want to
use, when using -ffreestanding. Make our wishes explicit to avoid
needing that flag.
2022-08-12 22:43:37 +02:00
Lephenixnoir
31ee6fdbee
cmake: remove the OpenLibm include path workaround
This is no longer needed when the fxSDK sysroot is in use; and anyway no
2022-08-12 22:40:20 +02:00