This should just about remove most of the old and deprecated (and now
obsolete) Maxsi:: API. Of course, large parts of libc still suffer from
its poor design, but I'll get around to fix that eventually.
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.
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.
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.
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.
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.
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.
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!
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.
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.
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.
<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.