Commit graph

42375 commits

Author SHA1 Message Date
davidot
6fd8e96d53 AK: Add to_{double, float} convenience functions to all string types
These are guarded with #ifndef KERNEL, since doubles (and floats) are
not allowed in KERNEL mode.
In StringUtils there is convert_to_floating_point which does have a
template parameter incase you have a templated type.
2022-10-23 15:48:45 +02:00
davidot
2334cd85a2 AK: Add an exact and fast hex float parsing algorithm
Similar to decimal floating point parsing the current strtod hex float
parsing gives a lot of incorrect results. We can use a similar technique
as with decimal parsing however hex floats are much simpler as we don't
need to scale with a power of 5.

For hex floats we just provide the parse_first_hexfloat API as there is
currently no need for a parse_hexfloat_completely API.

Again the accepted input for parse_first_hexfloat is very lenient and
any validation should be done before calling this method.
2022-10-23 15:48:45 +02:00
davidot
53b7f5e6a1 AK: Add an exact and fast floating point parsing algorithm
This is based on the paper by Daniel Lemire called
"Number parsing at a Gigabyte per second", currently available at
https://arxiv.org/abs/2101.11408
An implementation can be found at
https://github.com/fastfloat/fast_float

To support both strtod like methods and String::to_double we have two
different APIs. The parse_first_floating_point gives back both the
result, next character to read and the error/out of range status.
Out of range here means we rounded to infinity 0.

The other API, parse_floating_point_completely, will return a floating
point only if the given character range contains just the floating point
and nothing else. This can be much faster as we can skip actually
computing the value if we notice we did not parse the whole range.

Both of these APIs support a very lenient format to be usable in as many
places as possible. Also it does not check for "named" values like
"nan", "inf", "NAN" etc. Because this can be different for every usage.

For integers and small values this new method is not faster and often
even a tiny bit slower than the current strtod implementation. However
the strtod implementation is wrong for a lot of values and has a much
less predictable running time.

For correctness this method was tested against known string -> double
datasets from https://github.com/nigeltao/parse-number-fxx-test-data
This method gives 100% accuracy.
The old strtod gave an incorrect value in over 50% of the numbers
tested.
2022-10-23 15:48:45 +02:00
davidot
bf6d4a5cbf AK: Make truncating UFixedBigInts constexpr
Also add some tests and shift tests while we're at it.
2022-10-23 15:48:45 +02:00
davidot
66d07a452f LibJS: Make a TypedArray test actually run on all different types 2022-10-23 15:48:45 +02:00
davidot
80f23abd0a LibJS: Add descriptive output to test-commons expect().toThrow()
This (and still some other methods) just say Expectation error leaving
the user completely in the dark whether the method threw at all.
And since we have nice function printing now we can just toString the
function since most are lambda's.
2022-10-23 15:48:45 +02:00
Liav A
e3de568a45 Kernel/Graphics: Handle correctly unknown ioctls on a DisplayConnector
In such case, we should not assert but instead just return EINVAL.
2022-10-23 14:59:57 +02:00
electrikmilk
e2ebc8826f Base: Add 25 emojis
🫁 - U+1FAC1 LUNGS
🧟 - U+1F9DF ZOMBIE
🪷 - U+1FAB7 LOTUS
🫙 - U+1FAD9 JAR
🚖 - U+1F696 ONCOMING TAXI
🚢 - U+1F6A2 SHIP
🧸 - U+1F9F8 TEDDY BEAR
🪗 - U+1FA97 ACCORDION
↗️ - U+2197 UP-RIGHT ARROW
↘️ - U+2198 DOWN-RIGHT ARROW
↙️ - U+2199 DOWN-LEFT ARROW
↖️ - U+2196 UP-LEFT ARROW
↕️ - U+2195 UP-DOWN ARROW
↔️ - U+2194 LEFT-RIGHT ARROW
🪯 - U+1FAAF KHANDA
 - U+2B55 HOLLOW RED CIRCLE
 - U+27B0 CURLY LOOP
✳️ - U+2733 EIGHT-SPOKED ASTERISK
Ⓜ️ - U+24C2 CIRCLED M
◼️ - U+25FC BLACK MEDIUM SQUARE
◻️ - U+25FB WHITE MEDIUM SQUARE
 - U+25FE BLACK MEDIUM-SMALL SQUARE
 - U+25FD WHITE MEDIUM-SMALL SQUARE
▪️ - U+25AA BLACK SMALL SQUARE
▫️ - U+25AB WHITE SMALL SQUARE
2022-10-23 00:44:06 +02:00
Liav A
fea3cb5ff9 Kernel/FileSystem: Discard safely filesystems when unmounted last time
This commit reached that goal of "safely discarding" a filesystem by
doing the following:
1. Stop using the s_file_system_map HashMap as it was an unsafe measure
to access pointers of FileSystems. Instead, make sure to register all
FileSystems at the VFS layer, with an IntrusiveList, to avoid problems
related to OOM conditions.
2. Make sure to cleanly remove the DiskCache object from a BlockBased
filesystem, so the destructor of such object will not need to do that in
the destruction point.
3. For ext2 filesystems, don't cache the root inode at m_inode_cache
HashMap. The reason for this is that when unmounting an ext2 filesystem,
we lookup at the cache to see if there's a reference to a cached inode
and if that's the case, we fail with EBUSY. If we keep the m_root_inode
also being referenced at the m_inode_cache map, we have 2 references to
that object, which will lead to fail with EBUSY. Also, it's much simpler
to always ask for a root inode and get it immediately from m_root_inode,
instead of looking up the cache for that inode.
2022-10-22 16:57:52 -04:00
Liav A
24977996a6 Kernel: Append root filesystem to the VFS FileBackedFileSystem list 2022-10-22 16:57:52 -04:00
Liav A
0fd7b688af Kernel: Introduce support for using FileSystem object in multiple mounts
The idea is to enable mounting FileSystem objects across multiple mounts
in contrast to what happened until now - each mount has its own unique
FileSystem object being attached to it.

Considering a situation of mounting a block device at 2 different mount
points at in system, there were a couple of critical flaws due to how
the previous "design" worked:
1. BlockBasedFileSystem(s) that pointed to the same actual device had a
separate DiskCache object being attached to them. Because both instances
were not synchronized by any means, corruption of the filesystem is most
likely achieveable by a simple cache flush of either of the instances.
2. For superblock-oriented filesystems (such as the ext2 filesystem),
lack of synchronization between both instances can lead to severe
corruption in the superblock, which could render the entire filesystem
unusable.
3. Flags of a specific filesystem implementation (for example, with xfs
on Linux, one can instruct to mount it with the discard option) must be
honored across multiple mounts, to ensure expected behavior against a
particular filesystem.

This patch put the foundations to start fix the issues mentioned above.
However, there are still major issues to solve, so this is only a start.
2022-10-22 16:57:52 -04:00
Liav A
965afba320 Kernel/FileSystem: Add a few missing includes
In preparation to future commits, we need to ensure that
OpenFileDescription.h doesn't include the VirtualFileSystem.h file to
avoid include loops.
2022-10-22 16:57:52 -04:00
Jesse Buhagiar
2c16532159 Kernel+USB: Move descriptor bookkeeping into seperate structure(s)
We now have a seperately allocated structure for the bookkeeping
information in the QueueHead and TransferDescriptor UHCI strucutres.
This way, we can support 64-bit pointers in UHCI, fixing a problem where
32-bit pointers would truncate the upper 32-bits of the (virtual)
address of the descriptor, causing a crash.

Co-authored-by: b14ckcat <b14ckcat@protonmail.com>
2022-10-22 15:54:55 -04:00
Gunnar Beutner
5f38f5500e SystemServer: Fix race condition in Service::determine_account()
In theory our peer process could die between the call to getsockopt()
and Core::system::stat() and another process could end up with the same
PID which would result in us incorrectly launching the service as
another user (e.g. root).
2022-10-22 19:59:36 +02:00
Liav A
5b3980b040 Userland: Utilize MS_NOREGULAR mount flag
For SystemServer, we simply ensure that the /dev mount is now mounted
with MS_NOREGULAR flag to ensure only non-regular files are created,
thus, achieving what DevTmpFS provided in its implementation, but in a
much more sane and clean way than how DevTmpFS did that.

For other userland applications, we simply make them being aware of this
flag so they can show an indication about this flag being used to the
user.
2022-10-22 19:18:15 +02:00
Liav A
07387ec19a Kernel+Base: Introduce MS_NOREGULAR mount flag
This flag doesn't conform to any POSIX standard nor is found in any OS
out there. The idea behind this mount flag is to ensure that only
non-regular files will be placed in a filesystem, which includes device
nodes, symbolic links, directories, FIFOs and sockets. Currently, the
only valid case for using this mount flag is for TmpFS instances, where
we want to mount a TmpFS but disallow any kind of regular file and only
allow other types of files on the filesystem.
2022-10-22 19:18:15 +02:00
Liav A
97f8927da6 Kernel: Remove the DevTmpFS class
Although this code worked quite well, it is considered to be a code
duplication with the TmpFS code which is more tested and works quite
well for a variety of cases. The only valid reason to keep this
filesystem was that it enforces that no regular files will be created at
all in the filesystem. Later on, we will re-introduce this feature in a
sane manner. Therefore, this can be safely removed after SystemServer no
longer uses this filesystem type anymore.
2022-10-22 19:18:15 +02:00
Liav A
4c15915e40 SystemServer: Mount TmpFS on /dev instead of DevTmpFS
In the next commit, we will drop the DevTmpFS code for good, so we need
to mount a TmpFS instance on /dev instead of DevTmpFS.
2022-10-22 19:18:15 +02:00
Liav A
c2b5c5bac5 Kernel: Add support for device nodes in TmpFS
Later on we will remove the DevTmpFS code, so in order to support
mounting TmpFS instead, we need to be able to create device nodes on
the filesystem.
2022-10-22 19:18:15 +02:00
Moustafa Raafat
5edd4bd512 LibJS: Require NanosecondsToDays remainder less than dayLength
This is an normative change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/ac69b63
2022-10-22 19:14:14 +02:00
Moustafa Raafat
b1c8029c2b LibJS: Require that NanosecondsToDays doesn't flip sign
This is an normative change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/e13c52d
2022-10-22 19:14:14 +02:00
Moustafa Raafat
cfd684dc2f LibCrypto: Add SignedBigInteger::is_positive() 2022-10-22 19:14:14 +02:00
Sam Atkins
e5a25171fe LibGfx: Mark AffineTransform<T>::map() as only working for numeric T
The implementations for these methods is manually defined in the .cpp
file for `int` and `float`, meaning that other `T` values would fail -
but only once we got to the linking stage. This patch makes the error
happen much earlier, so it's more obvious.
2022-10-22 18:17:58 +02:00
Sam Atkins
732aa2c5c7 LibGfx: Make Rect<T> methods work when T is not int or float
Putting the implementations in the .cpp file meant that they only
existed for `IntRect` and `FloatRect`, since those were instantiated at
the bottom of the file. Now they work for other types. :^)

A couple of places in WindowServer had to be modified to disambiguate
between the two `Rect::intersected()` overloads.

Co-authored-by: davidot <davidot@serenityos.org>
2022-10-22 18:17:58 +02:00
Smrtnyk
ae950816b5 Base: Add SameSite cookie test cases 2022-10-22 18:17:01 +02:00
Smrtnyk
cb480fa3dc Browser: Show SameSite attribute in cookie storage inspector 2022-10-22 18:17:01 +02:00
Smrtnyk
b08ae57b23 LibWeb: Parse SameSite cookie attribute 2022-10-22 18:17:01 +02:00
Tobias Christiansen
a534e61b44 WebDriver: Implement GET /session/{id}/element/{id}/name endpoint 2022-10-22 13:44:49 +02:00
Tobias Christiansen
be6bbdaa3b WebContent+Friends: Add get_element_tag_name IPC and plumbing 2022-10-22 13:44:49 +02:00
Daniel Bertalan
f1f6c4c0b6 Meta: Detect Homebrew clang-format
Homebrew does not add upstream LLVM's install location to $PATH so as
not to conflict with XCode tools, so we need to run `brew --prefix llvm`
to figure out its install path.
2022-10-22 12:53:03 +02:00
Liav A
e52f0a991b Base: Rename jp(1) manual page to json(1) 2022-10-22 10:39:05 +02:00
Maxwell Trussell
b80c24f57f Utilities: Rename jp to json
With the scope of `jp` expanding beyond just printing JSON (e.g.
querying JSON), `json` seems to be a more fitting name.
2022-10-22 00:47:05 +02:00
Maxwell Trussell
424033be44 Utilities: Add jq-like json query functionality to jp 2022-10-22 00:47:05 +02:00
Xexxa
d80472b8f4 Snake: Add more emoji as in-game food graphics 2022-10-21 23:50:50 +02:00
Tim Schumacher
335fd20c34 Toolchain: Keep LLVM from using shm_open and friends
I originally missed this while handling the upgrade to LLVM 15 (as it
only affects the on-serenity port), so the patch gets to be here with a
bit of a delay.

Co-Authored-By: sin-ack <sin-ack@users.noreply.github.com>
2022-10-21 20:15:34 +02:00
Tim Schumacher
ed5996184b Ports/llvm: Add a dependency on zstd 2022-10-21 20:15:34 +02:00
Mykola
dcfaee8d6c Base: Add cool emoji
Added:
	1F32B      # 🌫 E0.7 fog
	1F361      # 🍡 E0.6 dango
	1F3A3      # 🎣 E0.6 fishing pole
	1F3B4      # 🎴 E0.6 flower playing cards
	1F413      # 🐓 E1.0 rooster
	1F456      # 👖 E0.6 jeans
	1F45C      # 👜 E0.6 handbag
	1F5EF      # 🗯 E0.7 right anger bubble
	1F6B0      # 🚰 E1.0 potable water
	1F6B1      # 🚱 E1.0 non-potable water
	1F6FB      # 🛻 E13.0 pickup truck
	1F9C6      # 🧆 E12.0 falafel
	1F9F4      # 🧴 E11.0 lotion bottle
	1FAB0      # 🪰 E13.0 fly
	1FAB1      # 🪱 E13.0 worm
	1FAD4      # 🫔 E13.0 tamale
	2618       # ☘ E1.0 shamrock
	1F684      # 🚄 E0.6 high-speed train
	1F685      # 🚅 E0.6 bullet train
	1F686      # 🚆 E1.0 train
2022-10-21 20:02:17 +02:00
Jelle Besseling
5de4507b6f Base: Add WC emoji and other blue block ones
Added:
    1F6BE   # 🚾 E1.0 Water closet
    1F6C2   # 🛂 E1.0 Passport control
    1F6C3   # 🛃 E1.0 Customs
    1F6C4   # 🛄 E1.0 Baggage claim
    1F6C5   # 🛅 E1.0 Left luggage
    1F6B9   # 🚹 E1.0 Men's room
    1F6D7   # 🛗 E13.0 Elevator
2022-10-21 20:01:31 +02:00
Jelle Besseling
1fa8aaca83 Base: Add some clock emoji
Added:
    23F0    #  E1.0 Alarm Clock
    23F1    # ⏱️ E1.0 Stopwatch
    23F2    # ⏲️ E1.0 Timer Clock
2022-10-21 20:01:20 +02:00
Sam Atkins
607767fd10 WebDriver: Extract repeated "check for window or return error" code
If `TRY()` doesn't solve your problems, you're not using enough of it.
2022-10-21 19:59:03 +02:00
Sam Atkins
851bece9fc Browser: Hide WebDriver debug messages behind WEBDRIVER_DEBUG 2022-10-21 19:59:03 +02:00
Sam Atkins
3232622255 WebDriver: Use WebDriverError::from_code() for all error creation 2022-10-21 19:59:03 +02:00
Sam Atkins
9393904073 WebDriver: Introduce WebDriver::ErrorCode enum
To avoid having to duplicate error text and http codes over and over,
and potentially make mistakes, let's put them all in one place.
2022-10-21 19:59:03 +02:00
Sam Atkins
89c3e0b567 WebDriver: Rename HttpError -> WebDriverError 2022-10-21 19:59:03 +02:00
crpz1
87a9462b7f Magnifier: Increase window size
The help menu was not visible prior to this.
2022-10-21 17:16:01 +01:00
crpz1
466e0c4846 Magnifier: Add Always on Top 2022-10-21 17:16:01 +01:00
Jelle Raaijmakers
e47ca2db0a Ports: Update Composer to 2.4.3 2022-10-21 14:31:32 +02:00
Jelle Raaijmakers
e70e4c132b Ports: Support Serenity install root in PHP's libtool
PHP's libtool does not have sysroot support; this is the minimum change
to get PHP to build.
2022-10-21 14:31:32 +02:00
Jelle Raaijmakers
684c038af0 Ports: Update PHP to 8.1.11 2022-10-21 14:31:32 +02:00
Andreas Kling
8ebbb6a2f3 Revert "LibWeb: Prevent world leak when activating event handler"
This reverts commit 8875cd0c83.

It broke Twitter (tweets would no longer load). Reverting until we can
understand why. :^(
2022-10-21 13:32:13 +02:00