Commit Graph

62 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen 9cf092d32e Use cross compiler in build system. 2012-12-14 14:13:33 +01:00
Jonas 'Sortie' Termansen 82035e87da Add makefile targets for installing sysroot base headers. 2012-09-10 21:45:38 +02:00
Jonas 'Sortie' Termansen bde41a37ec Implement crt1.o, crti.o, and crtn.o.
This helps running cross compiled programs as well as compiling programs
under Sortix with gcc. There is also support for global constructors.

Currently, cross-compiled executables uses these startup files. The current
build system continues to use start.o, which does not offer global
constructors and other useful features.

Note that these using the crtX.o files requires the crtbegin.o and crtend.o
files that ship with the cross compiler, but that should be no problem.
2012-09-08 18:45:53 +02:00
Jonas 'Sortie' Termansen 2158a16904 Add setlocale(3) and localeconv(3).
Ok, these are kinda hacky but they do implement a skeleton that a real
implementation can be based upon.
2012-09-08 18:45:53 +02:00
Jonas 'Sortie' Termansen bb3e590915 Add proper implementation of scanf family.
There are still a few non-standard quirks and things that needs to be
properly implemented but that shouldn't be too hard and the most important
features are now implemented.
2012-09-08 18:45:53 +02:00
Jonas 'Sortie' Termansen cd728c9af9 Add fabs{,f,l}(3). 2012-09-08 18:45:53 +02:00
Jonas 'Sortie' Termansen 6755318919 Add bsearch(3).
This is a rather stupid implementation as it does the search in linear
time. More importantly, it is correct and helps porting gcc. Besides, it
can easily be fixed in due time.
2012-09-08 18:45:53 +02:00
Jonas 'Sortie' Termansen b4192c10e9 Refactor libc process exit and abortion.
Removed Maxsi::Process:: functions as they suck and are barely used. Gave
the functions standard names and put them in their own source files.

The declarations now have nice noreturn attributes attached.
2012-09-08 18:45:52 +02:00
Jonas 'Sortie' Termansen 34970e63f3 Implement assert(3) properly. 2012-09-08 18:45:52 +02:00
Jonas 'Sortie' Termansen 8bac113573 Split libmaxsi/terminal.cpp into multiple files. 2012-09-08 18:45:52 +02:00
Jonas 'Sortie' Termansen 261c063f4f Refactored libmaxsi/file.c into a multiple files. 2012-07-31 14:35:54 +02:00
Jonas 'Sortie' Termansen 87c8120b95 Refactored libmaxsi/string.cpp into multiple files.
However, parts libmaxsi/string.cpp remains as the kernel and parts of the
standard library still rely on <libmaxsi/string.h>.
2012-07-26 14:17:56 +02:00
Jonas 'Sortie' Termansen 01df97080e Refactored libmaxsi/io.cpp into multiple files.
This creates more object files in the static library which reduces the size
of statically linked files as only the relevant object files are included.
In my experience, it reduced the size of the system initrd from 1.9 MiB to
1.6 MiB which is valuable.
2012-07-25 23:05:05 +02:00
Jonas 'Sortie' Termansen db5d216cbe Added ReadParamString to libmaxsi as a hack. 2012-07-24 21:26:09 +02:00
Jonas 'Sortie' Termansen 143120d160 Added tcgetwinsize(2) for determining terminal resolution.
Unfortunately this area is not standardized by POSIX. Linux uses an ioctl
which is not that bad, but I'd like to have a designated function. I'm not
sure if this facility is powerful enough and whether it should be improved.
Also note that I use a struct winsize as on Linux, but I use size_ts instead
for the heck of it. Perhaps I should use another name for the struct.
2012-07-24 18:43:34 +02:00
Jonas 'Sortie' Termansen 887abdfe87 Added a CRC32 function to libmaxsi. 2012-07-02 17:16:23 +02:00
Jonas 'Sortie' Termansen 0ab2bbbd1b Finally fixed the loaderbug!
Programs were crashing randomly at startup on the kthread branch. After some
investigation, it turned out that the programs weren't correctly loaded by
the program loader in rare cases. Although, all investigation showed that
the program loader was correct and so was the interrupt routines (well,
almost, but nothing that could really trigger this). Yada yada, a few months
later I discovered that memcpy(3) was being corrupted by an interrupt handler
(which was correct). Turns out memcpy used stack space it hadn't allocated.
This is a Linux optimization that I had forgotten to disable with
-mno-red-zone in libmaxsi and thus interrupts just overwrote the stack of
optimized functions. Eek!
2012-07-02 16:09:13 +02:00
Jonas 'Sortie' Termansen aac12add54 Added stubs for functions in dlfcn.h. 2012-05-30 23:58:04 +02:00
Jonas 'Sortie' Termansen 45981431de Added atexit(3) and on_exit(3). 2012-05-29 22:17:27 +02:00
Jonas 'Sortie' Termansen a75b215fe3 Added fpipe(3) providing pipe(2) through the FILE interface. 2012-05-21 12:52:27 +02:00
Jonas 'Sortie' Termansen 6367a2352e Added sforkr(2) that controls the child registers as well.
sfork(2) now calls sforkr(2) with the current registers.

This will prove useful in creating threads, where user-space now can fully
control what state the child will start in. This is unlike the Linux clone
system call that accepts a pointer to the child stack; this is more powerful
and somehow simpler. Note that this will create a rather raw thread; no
thread initization has been done by the standard thread API (when it is
implemented), so this feature shouldn't be used by programmers unless they
know what they are doing.

fork(2) now calls sfork(2) directly. Also removed fork(2) and sfork(2) from
the kernel as they are done using sforkr(2) now. So technically they aren't
system calls right now, but that could always change.
2012-04-05 23:00:47 +02:00
Jonas 'Sortie' Termansen dd5157da6a Implemented setenv(3), putenv(3), getenv(3), clearenv(3), sortix_getenv(3),
unsetenv(3), envlength(3), getenvindexed(3), and environ(7).

This provides the user-space foundation for environmental variables.

Note that this works over fork(2), but not execve(2) yet.
2012-04-03 20:23:28 +02:00
Jonas 'Sortie' Termansen cd0e402bbb Added {,l,ll,imax}abs(3). 2012-03-27 16:36:55 +02:00
Jonas 'Sortie' Termansen 9ab0bc5474 Added {,p}{read,write}{all,least}(3). 2012-03-24 15:34:30 +01:00
Jonas 'Sortie' Termansen db79994e64 Refactored all the sortix headers into a include directory.
Also got rid of trailing white space. That corrupted .git/.

Big ass-commit because of recovered .git directory.
2012-03-22 00:52:29 +01:00
Jonas 'Sortie' Termansen 8a9a0c58ea Added kernelinfo(2), which reads a kernel information string.
Currently it lets you query the name of the kernel, its version, and the
build timestamp of the kernelinfo.cpp file.
2012-03-07 18:04:59 +01:00
Jonas 'Sortie' Termansen 422d2fd579 Added qsort(3).
This is a rather slow implementation. Will be fixed soon.
2012-03-05 12:37:59 +01:00
Jonas 'Sortie' Termansen be98120b49 Added stubs for setjmp(3) and longjmp(3). 2012-03-04 23:15:32 +01:00
Jonas 'Sortie' Termansen 4804e60a8b Fixed race condition when building libmaxsi with -j.
The headers could end up being made before their dirs were ready.
2012-02-12 13:54:07 +01:00
Jonas 'Sortie' Termansen fec176fa15 Refactored the libmaxsi/ directory.
C and C++ files are now kept together and so are the mxmpp declarations.

Header files are now stored in include/ and mxmpp'd into preproc/.

All other code now -I ../libmaxsi/preproc.

And other stuff to make this happen, including refactoring Makefile.
2012-02-12 13:20:53 +01:00
Jonas 'Sortie' Termansen ed68db03fb Replaced SORTIX_EXTENSIONS macro with _SORTIX_SOURCE macro.
<features.h> declares _SORTIX_SOURCE if no conflicting macros are
declared, such as _GNU_SOURCE.

Fixed g++ automatically declaring _GNU_SOURCE, but Sortix isn't GNU.

Replaced SORTIX_UNIMPLEMENTED macro with __SORTIX_SHOW_UNIMPLEMENTED.
2012-02-11 18:51:55 +01:00
Jonas 'Sortie' Termansen 028867ab9d Removed the unused and deprecated old <libmaxsi/sortix-keyboard.h> API.
This has been entirely replaced by stdin and <sys/termmode.h>.
2012-02-10 13:46:26 +01:00
Jonas 'Sortie' Termansen ecc3114f2a Refactored the system to use the new Terminal interface.
This will allow development of a better terminal providing stdin.

Added new system calls settermmode(2) and gettermmode(2) declared in
<sys/termmode.h>. They allow querying and changing the current mode of
terminals (enabling raw keyboard data, signal handling, line buffering,
UTF-8 encoding stdin, and more). However, all that is unsupported by the
current terminal device driver.

Added KBKEY_ENCODE and KBKEY_DECODE macros to <sys/keycodes.h> which allows
encoding the kbkey format in UTF-32 characters.
2012-01-22 16:48:57 +01:00
Jonas 'Sortie' Termansen ead0e1523f Refactored the kernel keyboard API, but kept system calls compatible.
Caps lock now works as caps lock, not as shift lock.

This new design will allow implementing a working tty, such that stdin is
the only way to access the keyboard, instead of the current hacky way of
using a special system call to read from the keyboard.

Added a new system header file <sys/keycodes.h> defining the constants for
every key on the keyboard. This will be used in future APIs.

The main change is to split the keyboard driver into a class that reads
from the keyboard, while another class handles the translation into
printable characters (if possible). This allows a terminal driver based
on logical key presses and printable characters, instead of a terminal
driver based only on unicode-ish codes.
2012-01-22 15:53:50 +01:00
Jonas 'Sortie' Termansen d2c4b1d6ac Added readdir(3), closedir(3), rewinddir(3), dirfd(3), fdopendir(3),
opendir(3).

Also added non-standard dregister(3), dunregister(3), dclearerr(3),
derror(3), deof(3), dnewdir(3), dcloseall(3).
2012-01-15 00:51:27 +01:00
Jonas 'Sortie' Termansen 46e717e30f Revert ".so's are no longer installed into sysroot as there are no kernel support."
This reverts commit e6db1874e7ed16a6987d5a86d7f6c10cd8b0ffff.

These dummy .so's are actually OK.
2012-01-08 15:53:10 +01:00
Jonas 'Sortie' Termansen 7cd5363af8 Disabled shared libaries in libmaxsi by default. 2012-01-08 15:49:33 +01:00
Jonas 'Sortie' Termansen 145da20c04 Added a libg (symlink to libc) and symlinks are now copied to sysroot. 2012-01-08 15:45:13 +01:00
Jonas 'Sortie' Termansen d3c16470e3 .so's are no longer installed into sysroot as there are no kernel support. 2012-01-08 15:39:40 +01:00
Jonas 'Sortie' Termansen 954fd11703 Added isalnum(3), isalpha(3), isblank(3), iscntrl(3), isdigit(3),
isgraph(3), islower(3), isprint(3), ispunct(3), isspace(3), isupper(3),
isxdigit(3), tolower(3), and toupper(3).
2012-01-08 15:35:35 +01:00
Jonas 'Sortie' Termansen 25d8551b26 Moved _start into crtbegin.o as that's where the cross compiler wants it. 2012-01-08 14:30:50 +01:00
Jonas 'Sortie' Termansen fdbd4ca90d Implemented large parts of the stdio(3), including fprintf.
Made FILE an interface to various backends. This allows application writers
to override the standard FILE API functions with their own backends. This
is highly unportable - it'd be nice if a real standard existed for this.
glibc already does something like this internally, but AFAIK you can't hook
into it.

Added fdopen(3), fopen(3), fregister(3), funregister(3), fread(3),
fwrite(3), fseek(3), clearerr(3), ferror(3), feof(3), rewind(3), ftell(3),
fflush(3), fclose(3), fileno(3), fnewline(3), fcloseall(3), memset(3),
stdio(3), vfprintf(3), fprintf(3), and vprintf(3).

Added a file-descriptor backend to the FILE API.

fd's {0, 1, 2} are now initialized as stdin, stdout, and stderr when the
standard library initializes.

fcloseall(3) is now called on exit(3).

decl/intn_t_.h now @include(size_t.h) instead of declaring it itself.

Added <stdint.h>.

The following programs now flush stdout: cat(1), clear(1), editor(1),
init(1), mxsh(1).

printf(3) is now hooked up against vprintf(3), while Maxsi::PrintF
remains using the system call, for now.
2011-12-24 04:28:34 +01:00
Jonas 'Sortie' Termansen bf6a4c1861 Added strto{u,}{l,}l(3). 2011-12-16 16:49:27 +01:00
Jonas 'Sortie' Termansen 8c146f14c0 Added uptime(1). 2011-11-28 16:29:53 +01:00
Jonas 'Sortie' Termansen 6781308360 Rewrote the memory allocation functions.
free(3) can now unify unused neighbor blocks, reducing mem usage.
2011-11-27 22:53:05 +01:00
Jonas 'Sortie' Termansen d4231b2027 Added program_invocation_name(3), error(3), and perror(3) and used them. 2011-11-26 11:00:45 +01:00
Jonas 'Sortie' Termansen b6a0fd0374 Removed deprecated VGA API and moved it to /dev/vga. 2011-11-25 13:38:31 +01:00
Jonas 'Sortie' Termansen 2b032b0414 Initial signal support. Please squash improvements into this commit. 2011-11-23 00:19:09 +01:00
Jonas 'Sortie' Termansen 9f35df813e Implemented errno(3), added support in both kernel and utils. 2011-11-22 17:26:47 +01:00
Jonas 'Sortie' Termansen 23fde42249 Added readdirents(2), which ls(1) now uses, and added dir devices.
The initfs and ramfs are now able to list their contents.
2011-11-21 00:02:53 +01:00