Age | Commit message (Collapse) | Author |
|
This reverts commit 2c823473930121aecbacf0422c8372a0912e581b.
|
|
This reverts commit cdbbe14062ea49f9a9d9b0e5627aba9efd07659a.
|
|
This reverts commit c1eb744ff0a82cf6c8e3470ac10e2f417c7d9de2.
|
|
I've written a large part of the new stdio, so I'm (partly) to blame for it now.
|
|
I accidentally broke this in the recent rewrite. This reinstantiates the
behavior implemented in https://github.com/SerenityOS/serenity/commit/65714685259d1ea4ba9d32bc41aee6fc8c56a645.
|
|
Make sure that userspace is always referencing "system" headers in a way
that would build on target :). This means removing the explicit
include_directories of Libraries/LibC in favor of having it export its
headers as SYSTEM. Also remove a redundant include_directories of
Libraries in the 'serenity build' part of the build script. It's already
set at the top.
This causes issues for the Kernel, and for crt0.o. These special cases
are handled individually.
|
|
This is __cxa_guard_acquire, __cxa_guard_release, and __cxa_guard_abort.
We put these symbols in a 'fake' libstdc++ to trick gcc into thinking it
has libstdc++. These symbols are necessary for C++ programs and not C
programs, so, seems file. There's no way to tell gcc that, for example,
the standard lib it should use is libc++ or libc. So, this is what we
have for now.
When threaded code enters a block that is trying to call the constructor
for a block-scope static, the compiler will emit calls to these methods
to handle the "call_once" nature of block-scope statics.
The compiler creates a 64-bit guard variable, which it checks the first
byte of to determine if the variable should be intialized or not.
If the compiler-generated code reads that byte as a 0, it will call
__cxa_guard_acquire to try and be the thread to call the constructor for
the static variable. If the first byte is 1, it will assume that the
variable's constructor was called, and go on to access it.
__cxa_guard_acquire uses one of the 7 implementation defined bytes of
the guard variable as an atomic 8 bit variable. To control a state
machine that lets each entering thread know if they gained
'initialization rights', someone is working on the varaible, someone is
working on the varaible and there's at least one thread waiting for it
to be intialized, or if the variable was initialized and it's time to
access it. We only store a 1 to the byte the compiler looks at in
__cxa_guard_release, and use a futex to handle waiting.
|
|
This allows operator new and operator delete to be available to anyone
that links -lc (everyone) rather than just people that include
kmalloc.h (almost no one).
|
|
The new version uses buffering much more prominently, and hopefully performs
better. It also uses something resembling C++ rather than plain C.
|
|
We would want it to work with only stdio pledged.
|
|
|
|
|
|
This was supposed to be the foundation for some kind of pre-kernel
environment, but nobody is working on it right now, so let's move
everything back into the kernel and remove all the confusion.
|
|
|
|
I'm not sure why this was a syscall. If we need this we can add it in
LibC as a wrapper around sysconf(_SC_OPEN_MAX).
|
|
We stopped using gettimeofday() in Core::EventLoop a while back,
in favor of clock_gettime() for monotonic time.
Maintaining an optimization for a syscall we're not using doesn't make
a lot of sense, so let's go back to the old-style sys$gettimeofday().
|
|
Of course, using dbg() in the middle will change errno (most likely, reset
it to zero).
|
|
Closes https://github.com/SerenityOS/serenity/issues/2080
|
|
This patch makes strto{u,}l{l,}() behave more to-spec about endptr.
"If endptr is not NULL, strtoull stores the address of the first invalid
character in *endptr."
|
|
This fixes the behavior for several inputs:
- '-0' (shouldn't work but was accepted)
- '+3' (shouldn't work but was accepted)
- '13835058055282163712' (should work but returned 9223372036854775807 with errno=ERANGE)
|
|
|
|
This strtod implementation is not perfectly accurate, as evidenced by the test
(accuracy_strtod.cpp), but it is sufficiently close (up to 8 eps).
The main sources of inaccuracy are:
- Highly repeated division/multiplication by 'base'
(Each operation brings a multiplicative error of 1+2^-53.)
- Loss during the initial conversion from long long to double (most prominently,
69294956446009195 should first be rounded to 69294956446009200 and then
converted to 69294956446009200.0 and then divided by ten, yielding
6929495644600920.0. Currently, it converts first to double, can't represent
69294956446009195.0, and instead represents 69294956446009190, which
eventually yields 6929495644600919.0. Close, but technically wrong.)
I believe that these issues can be fixed by rewriting the part at and after
double value = digits.number();
and that the loss before that is acceptable.
Specifically, losing the exact exponent on overflow is obviously fine.
The only other loss occurs when the significant digits overflow a 'long long'.
But these store 64(-7ish) bits, and the mantissa of a double only stores 52 bits.
With a bit more thinking, one could probably get the error down to 1 or 2 eps.
(But not better.)
Fixes #1979.
|
|
It's based on <netinet/in.h> and more definitions might be required
here (e.g, IP header).
|
|
This file uses 'struct timeval' without including relevant header.
|
|
|
|
Will be updated as we add more protocols (e.g AF_INET6)
|
|
I had this assert trigger, I believe in a legitimate case.
This is the behavior glic and musl follow.
|
|
In f4302b58fb0, the kernel-side syscalls (e.g Process::sys$getsockname)
were updated to use SC_get{sock,peer}name_params, but the libc
functions were not updated.
|
|
|
|
|
|
The gcc port was hitting that assertion for some reason.
This patch fixes it.
|
|
|
|
It's tedious to write (and look at) [[gnu::always_inline]] etc. :^)
|
|
Also, rewrite the macro to expand to an if statement instead of
a weird ternary operator with a (void)0 banch.
|
|
This made it possible to map the E1000 MMIO range into userspace and
mess with the registers.
Thanks to @grigoritchy for finding this!
Fixes #2015.
|
|
|
|
Userland/hostname: Now takes parameter to set the hostname
LibC/unistd: Added sethostname function
|
|
This commit implements the getprotoent() family of functions, including
getprotoent()
getprotobyname()
getprotobynumber()
setprotoent()
endprotoent()
This implementation is very similar to the getservent family of functions,
which is what led to the discovery of a bug in the process of reading the aliases.
The ByteBuffer for the alias strings didn't include a null terminating character,
this was fixed for both the protoent and servent family of functions by appending a
null character to the end of them before adding them to the alias lists.
|
|
fix all requested changes including:
- remove explicit vector initialization
- change keep_service_file_open to boolean
- closing service file on seek error
- change C level char allocation to use ByteBuffer instead
- simplified getservby* loops to a single loop
- change fill_getserv_buffers return to early-return style
|
|
This commit implements the getservent family of functions:
getservent()
setservent()
endservent()
getservbyname()
getservbyport()
for accessing the /etc/services file.
This commit has addressed the issues identified by utilizing more C++ structures,
addressing unchecked error possibilities, strncpy bounds checking, and other issues
found in the initial pull request
|
|
|
|
|
|
|
|
|
|
Instead of pushing the message, file name, line# and function name
separately, we now mash the message, file name and line# into a string
constant and pass that.
This means that the failure path only has to push a single address onto
the stack, reducing the code size and causing the compiler to inline
many more functions containing an assertions (e.g RefPtr::operator*())
Obviously if you wanted minimal size, you could turn assertions off
entirely, but I really like running with assertions, so let's make
a little effort to reduce their impact. :^)
|
|
It's hilarious how much better this is.
Thanks to Sergey for suggesting it! :^)
|
|
The syscall wrapper for ptrace needs to return the peeked value when
using PT_PEEK.
Because of this, the user has to check errno to detect an error in
PT_PEEK.
This commit changes the actual syscall's interface (only for PT_PEEK) to
allow the syscall wrapper to detect an error and change errno.
|
|
PT_SETTREGS sets the regsiters of the traced thread. It can only be
used when the tracee is stopped.
Also, refactor ptrace.
The implementation was getting long and cluttered the alraedy large
Process.cpp file.
This commit moves the bulk of the implementation to Kernel/Ptrace.cpp,
and factors out peek & poke to separate methods of the Process class.
|
|
PT_POKE writes a single word to the tracee's address space.
Some caveats:
- If the user requests to write to an address in a read-only region, we
temporarily change the page's protections to allow it.
- If the user requests to write to a region that's backed by a
SharedInodeVMObject, we replace the vmobject with a PrivateIndoeVMObject.
|
|
PT_PEEK reads a single word from the tracee's address space and returns
it to the tracer.
|