Commit Graph

17 Commits

Author SHA1 Message Date
Lephenixnoir df4c13b007
stdlib: fix bad memset in calloc() 2021-09-25 15:16:24 +02:00
Lephenixnoir ea35c18c41
stdlib: add qsort (TEST) 2021-06-28 23:54:43 +02:00
Lephenixnoir 009a2eef6e
stdlib: add TinyMT-based rand, and malloc/etc for gint 2021-06-07 22:00:41 +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 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 3a9a60db78
stdlib: formatting on the strto* functions
* Name the private function __strto_{int,fp} (with leading double
  underscores) to avoid name conflicts
* Fix comments of the wrong style
* Fix missing leading double underscores in stdlib_p.h
2021-05-24 10:07:48 +02:00
Lephenixnoir f5cca84ae8
stdlib: add and test strtod, strtof and atof (DONE)
This uses a generic function strto_fp similar to strto_int that is used
for strtol and its derivatives.
2021-05-21 23:56:35 +02:00
Lephenixnoir efb37cf783
stdlib: add and test strtold (DONE)
The method is rather naive - digits read as an integer, then multipled
by a power of 10 or 2. This does not always give exact results, but it's
close enough for now. A stub support for long double larger than 64 bits
is provided.
2021-05-21 22:49:55 +02:00
Lephenixnoir bc53e756a8
stdlib: fix saturation in strtol, strtoul, strtoll, strtoull 2021-05-20 15:38:37 +02:00
Lephenixnoir ade01b532e
stdlib: add atoi, atol and atoll 2021-05-20 11:35:14 +02:00
Lephenixnoir 06f975f75c
stdlib: add a test strtol, strtoul, strtoll (DONE)
The presumed bug where the value computed without the sign overflows
even though the negative result can be represented is not actually a
problem, because this only happens with signed results and the temporary
value is computed as unsigned (thus with extra range).
2021-05-20 11:03:19 +02:00
Lephenixnoir 5042236392
stdlib: reword strtoull into a generic strto_int
This new function will support strtol, strtoul, and strtoll as well.
2021-05-20 09:23:06 +02:00
Lephenixnoir b1dc3e77de
stdlib: add and test strtoull (DONE) 2021-05-19 21:50:08 +02:00
Lephenixnoir 73b536bbb6
stdlib: add abs, labs, llabs, div, ldiv, lldiv (TEST) 2021-05-18 21:25:45 +02:00
Lephenixnoir f58187c55e
remove unneeded __SUPPORT macros 2021-05-09 22:11:49 +02:00
Lephenixnoir e719af2f63
update include hierarchy 2021-05-09 17:59:07 +02:00
Lephenixnoir ad9f92873b
new build system and source file hierarchy 2021-05-09 14:56:08 +02:00