Commit Graph

104 Commits

Author SHA1 Message Date
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 df4c13b007
stdlib: fix bad memset in calloc() 2021-09-25 15:16:24 +02:00
Lephenixnoir a0ceeefaf4
string: fix strtok detecting NUL only after separators 2021-08-17 17:30:21 +02:00
Lephenixnoir ea35c18c41
stdlib: add qsort (TEST) 2021-06-28 23:54:43 +02:00
Lephenixnoir a6dbcfb227
add C++ header guards 2021-06-28 15:49:05 +02:00
Lephenixnoir f5571e2b3d
time: add general definitions 2021-06-13 18:26:04 +02:00
Lephenixnoir 6e42995388
stdio: add general file management definitions 2021-06-13 18:18:32 +02:00
Lephenixnoir 518a866750
use __restrict__ in headers for g++ compatibility 2021-06-13 18:17:40 +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 ed8134970b
add nonstandard GNU endian.h 2021-06-08 10:05:00 +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 66463bfe17
assert: fix silly mistake 2021-05-30 23:16:09 +02:00
Lephenixnoir d261db447b
add some function attributes 2021-05-30 15:09:33 +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 73d6b2eb7c
setjmp: do not disable interrupts (#1) (DONE)
SR.BL=1 could cause problems if setjmp or longjmp is loader over a page
boundary and the second page is not loaded when interrupts are masked.

SR.IMASK=15 is another option, but it seems unnecessary per #1.

Blocking interrupts in longjmp did not make too much sense because the
blocked SR was immediately replaced by the restored one.
2021-05-29 11:18:02 +02:00
Lephenixnoir 13c3390b22
setjmp: expose setjmp and longjmp to sh-generic
... instead of vhex-generic, where it doesn't really belong because Vhex
might run on other architectures.
2021-05-29 09:56:47 +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 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 df9073e6ff
string: add and test str[n]casecmp and KMP str[case]str (DONE) 2021-05-24 10:04:54 +02:00
Lephenixnoir 8ffc104798
string: add and test strpbrk (DONE) 2021-05-23 18:11:12 +02:00
Lephenixnoir d105b1d60a
string: add stubs for strcoll and strxfrm (TEST)
These extend the stub locale; strcoll is simply strcmp and strxfrm is
simply strncpy.
2021-05-23 18:07:36 +02:00
Lephenixnoir cda27ac2db
string: add and test strspn and strcspn (DONE) 2021-05-23 18:02:38 +02:00
Lephenixnoir 8368ba70fd
string: split and fix strdup and strndup (DONE) 2021-05-23 17:58:04 +02:00
Lephenixnoir b78cec4f6d
string: add and test strerror (DONE) 2021-05-23 17:44:37 +02:00
Lephenixnoir 2a78c17597
string: strchr*, strmp*, strcpy*, strcat* are now tested (DONE) 2021-05-23 17:44:03 +02:00
Lephenixnoir 3792bbd9d1
string: split strcat and strncat (DONE) 2021-05-23 17:28:48 +02:00
Lephenixnoir 5d345b8da2
string: split and fix strcpy and strncpy (DONE) 2021-05-23 17:28:20 +02:00
Lephenixnoir d5ef8298ae
string: split strcmp and strncmp (DONE) 2021-05-23 17:27:58 +02:00
Lephenixnoir ab8bcc6928
string: use gint's (not-so-optimized-yet) memmove (DONE) 2021-05-23 16:52:39 +02:00
Lephenixnoir fd0d67191c
string: add memchr, memcmp, memmove for non-SuperH (TEST) 2021-05-23 16:52:39 +02:00
Lephenixnoir 5cfd2a7d85
string: use gint's optimized memcmp (DONE) 2021-05-23 16:52:35 +02:00
Lephenixnoir a354e38ccf
string: use gint's optimized memcpy (DONE) 2021-05-23 16:52:33 +02:00
Lephenixnoir b69e0fd299
string: use gint's optimized memset (DONE) 2021-05-23 16:52:29 +02:00
Lephenixnoir bd344d5bb2
string: split strchr, strchrnul and strrchr (TEST) 2021-05-23 16:07:01 +02:00
Lephenixnoir 6021c536f7
string: split strnlen, optimize strlen in assembler (DONE)
This change provides an optimized hand-written strlen function for
SuperH targets. The original plan was to declare the C-based naive
version weak and just let the linker figure out the proper one to use,
but unfortunately static libraries don't work like that; ld
intentionally stops at the first version even if it's weak. Instead,
some #ifdef's are used in the C-based strlen to not compile it when
unneeded.

The optimized strlen uses 4-byte accesses and cmp/str.
2021-05-23 16:00:12 +02:00
Lephenixnoir a48c163e55
string: add SH4AL-DSP optimizations for memchr (DONE) 2021-05-23 15:51:09 +02:00
Lephenixnoir 591e453717
sh-generic: add CPU capabilities for optimized SH4 code
On sh-generic targets, the headers <bits/cpucap.h> (in C) and
<bits/asm/cpucap.h> (in assembler) provide definitions to acces the
__cpucap symbol which provides information on the CPU.

Currently, a single capability __CPUCAP_SH4ALDSP is defined; it
represents the SH4 extended instructions together with the integrated
DSP instructions. The main uses of this capability are [movua.l]
(unaligned reads) and [ldrc] (built-in tight loops).

Capabilities are initialized to 0 (their safest default) and the runtime
can enable them based on what hardware is running.
2021-05-23 15:31:01 +02:00
Lephenixnoir 53751aa9a1
string: fill all prototypes in <string.h> 2021-05-23 15:29:37 +02:00
Lephenixnoir 24c6873429
cmake: fix include bits/ not being installed
The file(EXISTS) command needs absolute paths.
2021-05-23 15:27:10 +02:00
Lephenixnoir d6f606fa5c
string: add and test an optimized memchr (DONE)
This version works on both SH3 and SH4.
2021-05-23 14:30:35 +02:00
Lephenixnoir b96970e26d
string: memcmp is now tested (DONE) 2021-05-22 09:10:30 +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