Commit graph

88 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
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
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
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
05ff5e246d
bump version to 1.5.0 2024-01-14 23:02:59 +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
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
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
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
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
Lephenixnoir
b38dd3f894
cmake: use *dynamic* fxSDK compiler path as default for gint
Previously FXSDK_COMPILER_INSTALL would be stored as the install prefix.
However, this prefix is subject to unannounced changes when the compiler
version is upgraded without reconfiguring the fxlibc, which happens in
the GiteaPC workflow.

This commit avoids the use of CMAKE_INSTALL_PREFIX when using gint with
no specified prefix, and instead uses another cached variable which
leaves the prefix to be dynamically resolved based on the uncached
variable FXSDK_COMPILER_INSTALL, like most repositories do (eg. gint).
We need the cached indicator because we frequently reconfigure and
CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT is not persistent.
2022-08-12 22:39:53 +02:00
Yann MAGNIN
e8779145c2 fix vhex target folders 2022-07-30 18:55:40 +02: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
Alice Rozengarden
3f5989ceab Add getline(3) & getdelim(3) 2022-03-30 23:49:44 +02:00
Lephenixnoir
4d464bde01
bump version to 1.4.0 2022-03-19 19:29:17 +00:00
Yann MAGNIN
fa4adc5620 add PIC option + vxsdk support 2022-01-26 16:34:16 +01: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
0c2f81e5bb
string: add and test a naive memrchr (DONE) 2022-01-10 21:21:03 +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
bd0dd3a8d2
bump version to 1.3.0 2021-12-31 10:42:44 +01:00
Lephenixnoir
92ccd8b1db
time: add support for C99 <time.h> (DONE) 2021-12-04 22:02:23 +01:00
Lephenixnoir
e71f9867e2
support for shared libgcc in vhex 2021-11-07 18:05:33 +01:00
Lephenixnoir
164b33b26d
cmake: initial support for shared vhex library
Using the previously-tested trick with `ld -shared`.
2021-10-10 19:34:46 +02:00
Lephenixnoir
ea35c18c41
stdlib: add qsort (TEST) 2021-06-28 23:54:43 +02:00
Lephenixnoir
6be2a3d52e
bump version to 1.2.0 2021-06-08 10:57:34 +02:00
Lephenixnoir
dcaf203f46
stdio: improve printf extension API and type size support 2021-06-08 10:32:08 +02:00
Lephenixnoir
009a2eef6e
stdlib: add TinyMT-based rand, and malloc/etc for gint 2021-06-07 22:00:41 +02:00
Lephenixnoir
625a6af459
stdio: add asprintf and vasprintf 2021-06-07 19:09:55 +02:00
Lephenixnoir
f52e0923bc
stdio: move the printf implementation from gint 2021-06-07 18:57:11 +02:00
Lephenixnoir
cd7fe7a329
signal: simple implementation (DONE)
This version of signal (which does not rely on a notion of userland
processes and is thus excluded from Vhex) follows C99 semantics but does
not generate any signals by default.

Basically, the signal function sets up function pointers and the signal
function calls them. Termination signals call exit() while other signals
call _Exit(), which is a quicker program termination similar to abort().

C99 allows programs to long jump out of signal handlers (!) which is
unbelievably scary because it would bypass stack switching code in Vhex
as well as normal interrupt handler termination in gint.
2021-05-30 15:09:33 +02:00
Lephenixnoir
04e910441a
cmake: fix install dirs reversing at second build 2021-05-30 00:03:21 +02:00
Lephenixnoir
4b90740d3b
stdlib: add exit() based on target-provided _Exit()
This is implemented for gint only currently; on Vhex, _Exit() is likely
just going to be a syscall. For CASIOWIN, this is slightly more
difficult, as there is no native exit syscall.
2021-05-29 16:45:35 +02:00
Lephenixnoir
e6d2aa0638
cmake: default to compiler install with gint, and GiteaPC support 2021-05-25 21:55:51 +02:00
Lephenixnoir
412d0f5623
cmake: set minimum version to 3.15 2021-05-25 21:31:50 +02:00
Lephenixnoir
1e7e2c656b
string: add and test strtok (DONE) 2021-05-24 10:25:32 +02:00
Lephenixnoir
df9073e6ff
string: add and test str[n]casecmp and KMP str[case]str (DONE) 2021-05-24 10:04:54 +02:00