Commit graph

119 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
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
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
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
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
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
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
89c6c39405
stdio: support for UTF-8 %lc in printf() 2022-08-01 11:27:24 +01:00
Yann MAGNIN
bdf9566723 fxlibc - v1.4.3 : fix vhex missing headers
@update
> CMakeLists.txt
 | remove the generation of the shared version of the fxlibc (deprecated, unused)
> include/errno
 | add some error macros needed in vhex
> src/string/strerror
 | add EINTR support
 | add EAGAIN support
 | add ENOMEDIUM support
 | add EMEDIUMTYPE support

@fix
> include/target/vhex
 | add missing headers
2022-07-30 17:57:08 +02:00
Yann MAGNIN
619afe25da fxlibc - v1.4.2 : fix reallocarray() + remove old Vhex/Casiowin sources
@update
> CMakeLists.txt
  | remove casiowin-* target (unused)
  | remove x86-generic target (unused)
  | update files location
  | remove old vhex sources files (deprecated, unused)
> src/posix
  | remove this folder
> src/libc
  | move its content to src/
  | remove thread module
> src/stdlib/reallocarray
  | check if the multiplication overflow failed
  | set appropriate errno value if multiplication failed
2022-06-03 16:25:31 +02:00
Yann MAGNIN
996b2b8ded fxlibc - v1.4.1 : update Vhex stdlib
@update
> malloc  : do not use syscall, involve kmalloc
> realloc : do not use syscall, involve krealloc
> free    : do not use syscall, involve kfree

@fix
> _Exit : remove syscall
2022-05-14 11:49:08 +02:00
Lephenixnoir
d50e44c563
C++ __restrict__, update STATUS, minor formatting 2022-03-31 10:12:01 +01:00
Alice Rozengarden
3f5989ceab Add getline(3) & getdelim(3) 2022-03-30 23:49:44 +02:00
Lephenixnoir
3c29639988
string: fix a bug in SuperH memset 2022-03-26 15:19:15 +00:00
Lephenixnoir
71866ed769
stdio: stdin/stdout/stderr, perror, final adjustments
Support for <stdio.h> will stop here for now.
2022-01-14 18:38:48 +01:00
Lephenixnoir
ed873a652e
stdio: fgetc(), fgets(), tests for fputc() and fputs() (DONE) 2022-01-14 17:16:04 +01:00
Lephenixnoir
f1512125d0
stdio: initial versions of fputc() and fputs() (TEST) 2022-01-13 21:21:23 +01:00
Lephenixnoir
6ec0c24e2d
stdio: ungetc(), update (+) and append (a) modes (DONE) 2022-01-12 10:20:30 +01:00
Lephenixnoir
06b66252c9
stdio: line buffering, test fgetpos and fsetpos (DONE) 2022-01-10 21:32:24 +01:00
Lephenixnoir
0c2f81e5bb
string: add and test a naive memrchr (DONE) 2022-01-10 21:21:03 +01:00
Lephenixnoir
909c7df815
stdio: fixes for initial fread() et fwrite() (TEST) 2022-01-10 17:10:49 +01:00
Lephenixnoir
4461bdb96a
stdio: basic fread/fwrite (WIP) 2022-01-05 21:26:06 +01:00
Lephenixnoir
b6dbdf321d
stdio: error handling and positioning functions (WIP) 2022-01-02 22:09:06 +01:00
Lephenixnoir
a12b84f1ef
stdio: opening primitives for FILE (WIP) 2022-01-02 19:22:43 +01:00
Lephenixnoir
51528170bb
stdio: FILE barebones with buffering model (WIP) 2022-01-02 19:22:42 +01:00
Lephenixnoir
b53078776d
stdio: enable dprintf() and vdprintf() 2022-01-02 19:22:42 +01:00