Commit Graph

27 Commits

Author SHA1 Message Date
a3896c2546 libc: Define MB_CUR_MAX 2022-11-12 13:24:04 +01:00
d3030d2111 libc: Stub out strtod() 2022-11-09 11:37:52 +01:00
c6ce7a5358 libc: Add bsearch (with a test!!) 2022-11-06 17:34:35 +01:00
1025248cc7 libc: Add qsort (with a test!!) 2022-11-06 17:16:08 +01:00
da182f1c2f libc: Add mktemp() and mkdtemp(), along with a test for mktemp 2022-11-05 18:07:45 +01:00
534500cda0 Implement enough runtime for binutils to compile 2022-10-31 12:29:53 +01:00
7bd1cba1e3 libc: Stub out bsearch() 2022-10-30 20:02:03 +01:00
0d443385e9 libc: Add system() 2022-10-30 19:43:37 +01:00
32e09d3417 libc: Stub out more functionality so part of binutils builds 2022-10-29 09:39:12 +02:00
13fce2c4b3 libc: Update headers with more comments 2022-10-25 19:27:24 +02:00
35616993f8 libc: Add div(), ldiv(), and lldiv() 2022-10-23 12:26:48 +02:00
43180b777e libc: Stub out qsort() 2022-10-23 11:19:08 +02:00
51580bb846 libc: Add abs(), labs() and llabs()
Just needed to alias them to GCC builtins.
2022-10-23 11:10:26 +02:00
06f9ffc184 libc: Add EXIT_SUCCESS, EXIT_FAILURE, RAND_MAX and BUFSIZ 2022-10-22 21:39:51 +02:00
91969d4d48 libc: strtoul's endptr must not be const 2022-10-22 12:12:52 +02:00
6d7a8a0d0b libc: Add very basic strtoul()
As well as returning NULL in getenv() instead of aborting.
2022-10-21 18:32:46 +02:00
45afd3e243 Replace the rand() which reads from /dev/random with a Mersenne PRNG.
Much better now.

Also, it is seeded by reading from /dev/random at startup. Not sure if that's the best idea, but we'll see.
2022-10-15 16:46:54 +02:00
18f1f8b7ca Add VERY HACKY rand() implementation. 2022-10-15 16:31:08 +02:00
f50017912d libc: Implement atoi(), atol() and atoll() 2022-10-15 14:02:24 +02:00
2395c7a871 libc: Implement _Exit
Exactly the same as _exit, but in stdlib.h instead of unistd.h
2022-10-15 14:02:10 +02:00
b0e071e964 libc: Make functions with no arguments be defined as type function(void)
Instead of type function().
2022-10-15 11:39:13 +02:00
8398b2e2e4 libc: Change bits/macros.h to use a __lc_ prefix for internal macros
That way, we don't pollute user programs with our own 'noreturn' and 'deprecated' macros
2022-10-15 09:52:37 +02:00
743aedcd49 libc: Implement atexit() and _exit()
exit() now calls registered handlers before calling _exit().

And initialize_libc() can now register a handler to close stdout and stderr on program termination!! :)
2022-10-12 20:41:55 +02:00
ffc223c2cf libc: Document functions in stdlib.h
Also, add prototypes for calloc() and realloc(), which were already implemented but not in the header.
2022-10-12 11:30:21 +02:00
560b0a1705 libc: Rename the _ folder to bits, as used internally by libraries 2022-10-04 19:11:54 +02:00
a050ed9133 libc: add an internal macros.h header with headers to make attributes less verbose 2022-10-04 19:06:56 +02:00
fcf5923cc0 WIP: Add a C Library, let's try to compile a Hosted GCC cross-compiler using this! 2022-10-01 20:59:22 +02:00