Age | Commit message (Collapse) | Author |
|
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.
|
|
Before this fix negative exponents were interpreted as positive.
|
|
This makes getting a pseudoterminal pair a little bit more portable.
Note that grantpt() and unlockpt() are currently no-ops, since we've
already granted the pseudoterminal slave to the calling user.
We also accept O_CLOEXEC to posix_openpt(), unlike some systems. :^)
|
|
|
|
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.
For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.
Going forward, all new source files should include a license header.
|
|
While I was updating syscalls to stop passing null-terminated strings,
I added some helpful struct types:
- StringArgument { const char*; size_t; }
- ImmutableBuffer<Data, Size> { const Data*; Size; }
- MutableBuffer<Data, Size> { Data*; Size; }
The Process class has some convenience functions for validating and
optionally extracting the contents from these structs:
- get_syscall_path_argument(StringArgument)
- validate_and_copy_string_from_user(StringArgument)
- validate(ImmutableBuffer)
- validate(MutableBuffer)
There's still so much code around this and I'm wondering if we should
generate most of it instead. Possible nice little project.
|
|
|
|
As mentioned in #917, the String destructor could potentially be
clobbering the errno. Use memcpy so that we do not need String at all.
|
|
|
|
Move some dupliated code into __generate_unique_filename()
|
|
Implement __cxa_atexit and __cxa_finalize per the Itanium spec,
and convert stdlib's atexit and exit() to to call them instead of
a custom 'C-only' atexit implementation.
|
|
|
|
Nothing fancy, just a simple implementation of bsearch(3).
|
|
|
|
Implemented mkstemp method in stdlib.
|
|
|
|
This just copies the short char into the wide char without any decoding
whatsoever. A proper implementation should look at the current LC_CTYPE
and implement multi-byte decoding.
|
|
`atof()` has now been implemented as part of the standard C library.
It supports scientific notation such as `1.2e-3` etc, ala the version
found as part of `glibc`.
It's a bit chunky, so there's probably room for optimisations here
and there, however, for now it works as intended (and allows Quake
to run).
|
|
|
|
Serenity is really not production ready; I shouldn't have to warn
you not to trust the RNG here. This is for compatibility with
software expecting the interface.
arc4random does expose an annoying flaw with the syscall I want
to discuss with Kling though.
|
|
These are basically copy and pasted from the regular string version.
Also add some more multi-byte/wide conversion stub.
libarchive wanted these. There's a lot more, but we can add them
one at a time.
|
|
|
|
|
|
- system(nullptr) returns non-zero to indicate the presence of a shell
- Failure to fork() returns -1
- Failure to exec() in the child returns 127
|
|
|
|
This was a workaround to be able to build on case-insensitive file
systems where it might get confused about <string.h> vs <String.h>.
Let's just not support building that way, so String.h can have an
objectively nicer name. :^)
|
|
Rewrite this function to go from left-to-right instead of right-to-left
since this allows us to accumulate valid characters before encountering
any invalid ones.
This fixes parsing of strings emitted by GCC, like "1, %0|%0, %1}". :^)
|
|
We were not writing anything out to the `endptr` pointer if a number
was successfully parsed from the input string.
Fixes #460.
|
|
Things were getting a little crowded in the project root, so this patch
moves the Lib*/ directories into Libraries/.
|