Commit graph

30065 commits

Author SHA1 Message Date
Andrew Kaster
22feb9d47b AK: Resolve clang-tidy readability-bool-conversion warnings
... In files included by Kernel/Process.cpp and Kernel/Thread.cpp
2021-11-14 22:52:35 +01:00
Andrew Kaster
10d0cac73c AK: Use capitalized literal suffixes for AK::abs() overloads
Using `l` for long double causes a clang-tidy warning, so use all caps
suffixes for all of the AK::abs() overloads for consistency. Also, avoid
leaking the internal __DEFINE_GENERIC_ABS macro.
2021-11-14 22:52:35 +01:00
Andrew Kaster
e982253c33 AK: Avoid else after return in files commonly included by the Kernel 2021-11-14 22:52:35 +01:00
Andrew Kaster
07f4e91b94 AK: Use proper type for bool NumericLimits::min and max specialization
We had these declared as returning char, which looks like a copy paste
error. Found by clang-tidy.
2021-11-14 22:52:35 +01:00
Andrew Kaster
7e2ee2e725 AK: Suppress false-positive clang-tidy warning in Assertions.h
The definition of VERIFY_NOT_REACHED() as `assert(false)` causes the
tool to suggest converting it to a static_assert. Which doesn't make
any sense in context for what the macro is trying to do: crash the
program at runtime.
2021-11-14 22:52:35 +01:00
Andrew Kaster
6f5b9cc031 Toolchain: Enable clang-tools-extra for LLVM
If we want to use clang-tidy on the codebase, we'll need to build
clang-tidy from an LLVM that has been patched and built with Serenity
cross-compilation support.
2021-11-14 22:52:35 +01:00
Andrew Kaster
3eeca784d2 Meta: Add basic clang-tidy configuration
Add a basic clang-tidy configuration that enables checks from the
following categories:

- bugprone
- cert
- clang-analyzer
- concurrency
- misc
- performance
- portability
- readability

The noisiest rules that have conflicts with the project style guide or
accepted practices have been turned off.

There's absolutely more work to be done here before we could consider
setting any of these warnings as errors and enforcing them in CI, but
committing a project clang-tidy configuration should help the rules
become more visible and let other contributors take a crack at tweaking
rules and/or finding possible bugs.

Sadly the cpp-core-guidelines and modernize categories are very, very
noisy. If we want to enable rules from these categories, they would need
to be on a rule by rule basis.
2021-11-14 22:52:35 +01:00
faxe1008
480903fe8a Taskbar: Make quicklaunch bar editable
This change adds a ConfigServer Listener to TaskbarWindow. Items in the
quicklaunch bar may be added or removed by editing the Taskbar config.
2021-11-14 22:42:52 +01:00
faxe1008
06cb526feb config: Add option to remove config key 2021-11-14 22:42:52 +01:00
Tim Schumacher
292398b585 Toolchain: Load x64 executables at a higher address
Serenity defines a protected range of memory that must not be mmapped,
and is apparently reserved for kernel tasks. In this case, the protected
range is anything below 0x800000.

However, in its default setting, binutils chooses the memory address
0x400000 as the mapping address for executables that do not have PIE
enabled, resulting in mmap being unable to map the file unless the load
address has been overwritten at link time or if it's a PIE.

To mitigate this, move the default base address somewhere outside of
that range (and preferably not anywhere close near the beginning of the
useable virtual memory space, to avoid running into it during sequential
allocations).
2021-11-14 22:25:15 +01:00
Timothy Flynn
4d79ab6866 LibJS: Implement engineering and scientific number formatting 2021-11-14 17:00:35 +00:00
Timothy Flynn
30fbb7d9cd LibUnicode: Parse and generate scientific formatting rules 2021-11-14 17:00:35 +00:00
Timothy Flynn
b019a7fe64 LibJS: Define the "name" property on the number format function
Also add a missing spec link.
2021-11-14 17:00:35 +00:00
Timothy Flynn
3645f6a0fc LibUnicode: Fix typo in percent format parser
Just by sheer luck this had no actual effect because the decimal format
prefix has the same length as the percent format prefix.
2021-11-14 17:00:35 +00:00
Daniel Bertalan
061fa8a1ca Toolchain: Add aligned allocation support to libc++
Now that we have `_aligned_malloc` and `_aligned_free`, we can finally
enable C++17 aligned allocation support.
2021-11-14 16:46:21 +00:00
Daniel Bertalan
40e7ac9967 LibC: Implement _aligned_malloc and _aligned_free
C++17 introduced aligned versions of `new` and `delete`, which are
automatically called by the compiler when allocating over-aligned
objects. As with the regular allocator functions, these are generally
thin wrappers around LibC.

We did not have support for aligned allocations in LibC, so this was not
possible. While libstdc++ has a fallback implementation, libc++ does
not, so the aligned allocation function was disabled internally. This
made building the LLVM port with Clang impossible.

Note that while the Microsoft docs say that aligned_malloc and
_aligned_free are declared in `malloc.h`, libc++ doesn't #include that
file, but instead relies on the definition coming from `stdlib.h`.
Therefore, I chose to declare it in that file instead of creating a new
LibC header.

I chose not to implement the more Unix-y `memalign`, `posix_memalign`,
or the C11 `aligned_alloc`, because that would require us to
significantly alter the memory allocator's internals. See the comment in
malloc.cpp.
2021-11-14 16:46:21 +00:00
EWouters
069e64efd1 Ports/libuv: Update libuv to version 1.42.0 and fix cmake argument
Add CMAKE_BUILD_WITH_INSTALL_RPATH=true to the cmake arguments as it
wouldn't compile on MacOS without this argument
2021-11-14 16:20:55 +00:00
Brian Gianforcaro
2c4db837e7 Ports: Add initial Pipe Viewer (pv) 1.6.20 port 2021-11-14 16:18:45 +00:00
Brian Gianforcaro
d1806d44fa AK: Swallow 'L' format specifier until it is properly implemented
Previously if code attempted to use the format specifier somewhere
(Ex: "%#4.3Lg"), the specifier would get dropped and we would just
print "g" instead of any value. Now at least we print a value.
2021-11-14 16:18:45 +00:00
Lady Gegga
0ddb877f87 Base: Add Chorasmian characters to font Katica Regular 10
10FB0-10FCB https://www.unicode.org/charts/PDF/U10FB0.pdf
2021-11-14 16:16:19 +00:00
Linus Groh
27d84bebd4 LibJS: Remove redundant exception checks from initialize_constructor()
define_direct_property() simply wraps storage_set(), which cannot throw.
2021-11-14 16:14:38 +00:00
Linus Groh
57de5056b6 LibJS: Convert push_execution_context() to ThrowCompletionOr 2021-11-14 16:14:38 +00:00
Linus Groh
7cdca08090 LibJS: Convert prepare_for_ordinary_call() to ThrowCompletionOr 2021-11-14 16:14:38 +00:00
Linus Groh
33ed87d642 LibJS: Convert TypedArray create() functions to ThrowCompletionOr 2021-11-14 16:14:38 +00:00
Linus Groh
878668efc9 LibJS: Call [[Reject]] in PromiseResolveThenableJob after abrupt then() 2021-11-14 15:27:46 +00:00
Linus Groh
194d90dc72 LibJS: Don't coerce this value to object in Promise.prototype.finally() 2021-11-14 15:27:46 +00:00
Linus Groh
53ec432e8d LibJS: Don't coerce this value to object in Promise.resolve() 2021-11-14 15:27:46 +00:00
Linus Groh
cd391aa8ef LibJS: Convert call_job_callback() to ThrowCompletionOr 2021-11-14 15:27:46 +00:00
Linus Groh
68ac13a192 LibJS: Add a Completion(ThrowCompletionOr<Value> const&) constructor 2021-11-14 15:27:46 +00:00
Linus Groh
01c2570678 LibJS: Annotate Promise implementation with spec comments
I wanted to do this for a long time. The guts of Promise are pretty
complex, and it's easier to understand with the spec right next to it.
Also found a couple of issues along the way :^)
2021-11-14 15:27:46 +00:00
Daniel Bertalan
df06552b48 Ports: Fix building zlib with Clang
Even though Clang generates PIC objects by default, an R_386_PC32
relocation still slips into libz.a if we don't set -fPIC explicitly.
2021-11-14 11:38:40 +00:00
Andreas Kling
7e5b22333e WindowServer: Make window switcher look more like other overlays
Render the window switcher with the same background and shadow as other
WindowServer overlays.

Note that we don't actually render it as a WindowServer::Overlay, as the
window switcher uses mouse and keyboard events, and there's currently
no way for an overlay to receive events.
2021-11-14 12:23:04 +01:00
Andreas Kling
7fb2540ffe WindowServer: Clear window switcher's hovered item when cursor leaves
When the mouse cursor leaves the switcher window, we'll want to clear
the hovered item index so it stops showing as hovered. :^)
2021-11-14 12:23:04 +01:00
Andreas Kling
6f80d91850 WindowServer: Reset the window switcher's hovered item between uses
Before this, the last hovered item would still appear hovered when
bringing up the window switcher after having dismissed it.
2021-11-14 12:23:04 +01:00
Andreas Kling
9f7f7e69bb WindowServer: Allow server-internal windows with alpha channel
We were not creating backing stores with alpha for server-internal
windows. There was no reason for this limitation.
2021-11-14 12:23:04 +01:00
Andreas Kling
583fbf7111 WindowServer: Make WindowFrame::shadow_bitmap() const
There is no reason for callers to mutate the shadow bitmaps returned by
this function.
2021-11-14 12:23:04 +01:00
Lady Gegga
530360ce77 Base: Add Mende Kikakui characters to font Katica Regular 10
U1E800-1E8DF https://www.unicode.org/charts/PDF/U1E800.pdf
2021-11-14 11:11:01 +00:00
Timothy Flynn
15c5fbd9e9 LibJS: Implement number grouping for Intl.NumberFormat
For example, in en-US, the number 123456 should be formatted as the
string "123,456". In en-IN, it should be formatted as "1,23,456".
2021-11-14 10:35:19 +00:00
Timothy Flynn
3b7f5af042 LibUnicode: Generate primary and secondary number grouping sizes
Most locales have a single grouping size (the number of integer digits
to be written before inserting a grouping separator). However some have
a primary and secondary size. We parse the primary size as the size used
for the least significant integer digits, and the secondary size for the
most significant.
2021-11-14 10:35:19 +00:00
Liav A
0e5983e603 Kernel/AHCI: Simplify wait and timeout pattern significantly
Instead of repeating ourselves with the pattern of waiting for some
condition to be met, we can have a general method for this task,
and then we can provide the retry count, the required delay and a lambda
function for the checked condition.
2021-11-13 23:35:27 +01:00
Liav A
557351724a Kernel/AHCI: Remove unnecessary AHCIPort class member 2021-11-13 23:35:27 +01:00
Tim Schumacher
2e8330f78c Utilities/tr: Rework squeezing to be supported during more operations 2021-11-13 23:34:49 +01:00
David Lindbom
3c98a9430b LibVT: Show action of double click in tooltip
When hovering an item in Terminal we now show what application will
handle it, e.g "Open app-catdog.png in ImageViewer".

If the file is its own handler, i.e an executable, it will show
"Execute myscript.sh"
2021-11-13 23:33:46 +01:00
Luke Wilde
f6ab63993a LibJS: Implement Temporal.ZonedDateTime.prototype.round 2021-11-13 19:48:54 +00:00
Timothy Flynn
3450def494 LibJS: Implement Intl.NumberFormat.prototype.formatToParts 2021-11-13 19:01:25 +00:00
Timothy Flynn
40973814e9 LibJS: Throw an exception in NumberFormat.prototype.format for BigInts
Rather than crashing in the call to as_double(), throw an exception for
now.
2021-11-13 19:01:25 +00:00
Timothy Flynn
c65dea64bd LibJS+LibUnicode: Don't remove {currency} keys in GetNumberFormatPattern
In order to implement Intl.NumberFormat.prototype.formatToParts, do not
replace {currency} keys in the format pattern before ECMA-402 tells us
to. Otherwise, the array return by formatToParts will not contain the
expected currency key.

Early replacement was done to avoid resolving the currency display more
than once, as it involves a couple of round trips to search through
LibUnicode data. So this adds a non-standard method to NumberFormat to
do this resolution and cache the result.

Another side effect of this change is that LibUnicode must replace unit
format patterns of the form "{0} {1}" during code generation. These were
previously skipped during code generation because LibJS would just
replace the keys with the currency display at runtime. But now that the
currency display injection is delayed, any {0} or {1} keys in the format
pattern will cause PartitionNumberPattern to abort.
2021-11-13 19:01:25 +00:00
Timothy Flynn
d872d030f1 LibJS: Avoid potential for dangling string views in partition patterns
There aren't any dangling views in as of yet, but a subsequent commit
will cause the "part" variable to be a view into an internally generated
string. Therefore, after returning from PartitionNumberPattern, that
view will be pointed at freed memory.

This commit is to set the precendence of not returning a view to "part".
2021-11-13 19:01:25 +00:00
Timothy Flynn
0c9711efba LibUnicode: Handle all space code points when creating currency patterns
Previously, we were checking if the code point immediately before/after
the {currency} key was U+00A0 (non-breaking space). Instead, to handle
other spacing code points, we must check if the surrounding code point
has the separator general category.
2021-11-13 19:01:25 +00:00
Timothy Flynn
ada4bab405 LibUnicode: Remove GeneralCategory::Symbol string lookup
When I originally wrote this method, I had it in LibJS, where we can't
refer to the GeneralCategory enumeration directly. This is a big TODO,
anyone outside of LibUnicode can't assume the generated enumerations
exist and must get these values by string lookup. But this function
ended up living in LibUnicode, who can reference the enumeration.
2021-11-13 19:01:25 +00:00