Commit graph

14121 commits

Author SHA1 Message Date
Andreas Kling
23a5a484d5 ClipboardHistory: Bring window to front when applet is clicked
Fixes #4031.
2020-11-11 20:31:35 +01:00
Lenny Maiorani
5570b16f6f RefPtrTraits: struct/class mismatch in forward declaration
Problem:
- Building with clang is broken because of the `struct` vs `class`
  mismatch between the definition and declaration.

Solution:
- Change `class` to `struct` in the forward declaration.
2020-11-11 20:25:29 +01:00
AmusedNetwork
de6483bcdb LibGUI: Set vertical distance between icons relative to scroll value
When calculating the vertical distance between icons, we should take
into account the value of the vertical scrollbar.

Fixes #4040
2020-11-11 15:14:09 +01:00
Tom
dc9ddf8104 Kernel: Fix deadlock when unicasting/broadcasting SMP message
When two processors send each others a SMP message at the same time
they need to process messages while waiting for delivery of the
message they just sent, or they will deadlock.
2020-11-11 12:27:25 +01:00
Tom
3ee7c21fae Kernel: Implement capturing stack trace on a different CPU
When trying to get a stack trace of a thread on another CPU we send
a SMP message to that processor to capture the stack trace for us.
2020-11-11 12:27:25 +01:00
Tom
5b38132e3c Kernel: Protect the PageDirectory from concurrent access 2020-11-11 12:27:25 +01:00
Tom
2b25a89ab5 Kernel: Add locks around RangeAllocator
We need to keep multiple processors from changing it at the same time.
2020-11-11 12:27:25 +01:00
Tom
66f46d03e4 Kernel: Minor Lock optimization 2020-11-11 12:27:25 +01:00
Tom
b4c9e85056 Kernel: Minor SpinLock improvements 2020-11-11 12:27:25 +01:00
Tom
e26e0445b5 Kernel: Make m_halt_requested an atomic variable
We need to make sure the change to this variable is visible to all
processors instantly.
2020-11-11 12:27:25 +01:00
Tom
a14884dd33 Kernel: Lock needs to call Processor::wait_check while looping
We need to process SMP messages while looping.
2020-11-11 12:27:25 +01:00
Lenny Maiorani
72d019f4a4 IPv4Address: constexpr support
Problem:
- IPv4Address class cannot be used in a compile-time context.
- A union is used by initializing one of the members and reading the
  non-active member. This is undefined behavior and not permitted in a
  `constexpr` context.

Solution:
- Eliminate undefined behavior by changing to a simple `u32` for
  storage instead of the union and performing mask/shift calculations
  for obtaining the individual octets.
- Decorate functions with `constexpr` where possible. Currently string
  formatting and optionals are not `constexpr`-capable so functions
  using those are left out.
- Modify tests to validate functionality in a `constexpr` context in
  addition to the run-time tests already being run. This ensures that
  functionality is the same in both contexts.
2020-11-11 12:18:25 +01:00
Luke
62a74bf282 LibWeb: Advertise to servers that we support gzip encoding
We've had gzip support for a while now, but it never really got
used because we never advertised it.
2020-11-11 12:15:18 +01:00
Luke
397049aae8 LibWeb: Move innerText from DOM::Element to HTML::HTMLElement 2020-11-11 12:15:05 +01:00
Luke
bb22b04d44 LibWeb+LibJS: Add [LegacyNullToEmptyString] attribute
If specified, to_string() returns an empty string instead of "null" for
null values.
2020-11-11 12:15:05 +01:00
Andreas Kling
1745e503aa LibJS: Use a HashTable to identify potential cell pointers in GC scan
Previously we would iterate over all the live HeapBlocks in order to
learn if an arbitrary pointer-sized value was a pointer into a live
HeapBlock. This was quite time-consuming.

Instead of that, just put all the live HeapBlock*'s in a HashTable
and identify pointers by doing a bit-masked lookup into the table.
2020-11-10 20:28:53 +01:00
Andreas Kling
50aa726db7 LibGUI: Ignore application-global shortcuts in modal windows
This is making me question the usefulness of application-global
shortcuts, but for now let's just prevent them from triggering while
you're looking at a modal message box..
2020-11-10 19:41:03 +01:00
Andreas Kling
ebaf20547c WindowServer: Show modal window's cursor over blocked windows
When a window is blocked by a modal window from the same application,
we now prefer the modal window's cursor instead of the hovered window.
2020-11-10 19:30:22 +01:00
Tom
75f61fe3d9 AK: Make RefPtr, NonnullRefPtr, WeakPtr thread safe
This makes most operations thread safe, especially so that they
can safely be used in the Kernel. This includes obtaining a strong
reference from a weak reference, which now requires an explicit
call to WeakPtr::strong_ref(). Another major change is that
Weakable::make_weak_ref() may require the explicit target type.
Previously we used reinterpret_cast in WeakPtr, assuming that it
can be properly converted. But WeakPtr does not necessarily have
the knowledge to be able to do this. Instead, we now ask the class
itself to deliver a WeakPtr to the type that we want.

Also, WeakLink is no longer specific to a target type. The reason
for this is that we want to be able to safely convert e.g. WeakPtr<T>
to WeakPtr<U>, and before this we just reinterpret_cast the internal
WeakLink<T> to WeakLink<U>, which is a bold assumption that it would
actually produce the correct code. Instead, WeakLink now operates
on just a raw pointer and we only make those constructors/operators
available if we can verify that it can be safely cast.

In order to guarantee thread safety, we now use the least significant
bit in the pointer for locking purposes. This also means that only
properly aligned pointers can be used.
2020-11-10 19:11:52 +01:00
Tom
3c1ef744f6 AK: Add RefPtrTraits to allow implementing custom null pointers
This adds the ability to implement custom null states that allow
storing state in null pointers.
2020-11-10 19:11:52 +01:00
Brendan Coles
4dd104607d LaunchServer: Add hsp=/bin/HackStudio file association to config 2020-11-10 19:04:24 +01:00
Brendan Coles
e62b604ec5 Base: remove unnecessary Game config files from /home/anon/.config/ 2020-11-10 19:03:59 +01:00
Nico Weber
8d9d3c9425 ntpquery: Add a '-a' flag that makes it use adjtime
With this, `ntpquery` can adjust the system time without
making it jump.

A fun activity with this in:

0. Boot
1. Run `su`
2. Run `ntpquery -a` to adjust the time offset after boot
   (usually around a second)
3. Keep running `ntpquery ; adjtime` to see how the offset
   behind NTP and the remaining adjtime both shrink.
   adjtime adjustment is large enough to make the time offset
   go down by a bit, but we currently lose time quickly enough
   that by the time adjtime is done, we've only corrected the
   clock about halfway, and not all the way to zero. Goto 2.

So this isn't all that great yet, but I think it's good enough
to think about turning this into a permanently running service next.
2020-11-10 19:03:08 +01:00
Nico Weber
5fcd34b810 Userland: Add an "adjtime" utility
It's a thin userland wrapper around adjtime(2). It can be used
to view current pending time adjustments, and root can use it to
smoothly adjust the system time.

As far as I can tell, other systems don't have a userland utility
for this, but it seems useful. Useful enough that I'm adding it to
the lagom build so I can use it on my linux box too :)
2020-11-10 19:03:08 +01:00
Nico Weber
323e727a4c Kernel+LibC: Add adjtime(2)
Most systems (Linux, OpenBSD) adjust 0.5 ms per second, or 0.5 us per
1 ms tick. That is, the clock is sped up or slowed down by at most
0.05%.  This means adjusting the clock by 1 s takes 2000 s, and the
clock an be adjusted by at most 1.8 s per hour.

FreeBSD adjusts 5 ms per second if the remaining time adjustment is
>= 1 s (0.5%) , else it adjusts by 0.5 ms as well. This allows adjusting
by (almost) 18 s per hour.

Since Serenity OS can lose more than 22 s per hour (#3429), this
picks an adjustment rate up to 1% for now. This allows us to
adjust up to 36s per hour, which should be sufficient to adjust
the clock fast enough to keep up with how much time the clock
currently loses. Once we have a fancier NTP implementation that can
adjust tick rate in addition to offset, we can think about reducing
this.

adjtime is a bit old-school and most current POSIX-y OSs instead
implement adjtimex/ntp_adjtime, but a) we have to start somewhere
b) ntp_adjtime() is a fairly gnarly API. OpenBSD's adjfreq looks
like it might provide similar functionality with a nicer API. But
before worrying about all this, it's probably a good idea to get
to a place where the kernel APIs are (barely) good enough so that
we can write an ntp service, and once we have that we should write
a way to automatically evaluate how well it keeps the time adjusted,
and only then should we add improvements ot the adjustment mechanism.
2020-11-10 19:03:08 +01:00
Brendan Coles
28abfd6290 Userland: ls: Add -d / --directory flag 2020-11-10 18:56:27 +01:00
Brendan Coles
9b79ea78d3 LibC: Add POSIX1 minimum limits to limits.h 2020-11-10 14:39:38 +01:00
Linus Groh
518481086b js: Use new string formatting functions 2020-11-10 14:33:48 +01:00
Andreas Kling
626c17d284 Breakout: Add simple menu and about dialog :^) 2020-11-10 14:32:45 +01:00
Andreas Kling
51e7c6e348 Breakout: Set the window icon 2020-11-10 14:32:45 +01:00
Andreas Kling
8c88bf31ed Breakout: Turn off double-buffering 2020-11-10 14:32:45 +01:00
Andreas Kling
959038d410 Breakout: Change ball x velocity depending on where it hits paddle
This makes the game less deterministic and more fun. The "physics"
definitely feel a little goofy, and I'm sure they can be greatly
improved, but still it's already better. :^)
2020-11-10 14:32:45 +01:00
Andreas Kling
844c2e1f3b Breakout: Stop paddle movement when resetting it 2020-11-10 14:32:45 +01:00
Andreas Kling
d05d519b0d Breakout: Use floating point coordinates 2020-11-10 14:32:45 +01:00
Brendan Coles
3f7b2c83d3 Tests: Add Kernel tests for unveil system call 2020-11-10 14:23:19 +01:00
Brendan Coles
7e0204fb41 Userland: ls: Add -o and -B / --ignore-backups flags
* `-B`, --ignore-backups`: Do not list implied entries ending with ~
* `-o`, In long format, do not show group information
2020-11-10 14:22:49 +01:00
marprok
5fae567008 Userland: Basic statistics for ping
After ping is terminated, the min/avg/max time
as well as information about the number of successful
packets received are printed on the screen.
2020-11-10 12:06:04 +01:00
Brendan Coles
0058d28a73 Base: Add ls man page documentation 2020-11-10 12:04:26 +01:00
Brendan Coles
51f49ec73f ls: Add -A flag to show dot files excluding implied . and .. directories 2020-11-10 12:04:12 +01:00
Andreas Kling
07a2d22c33 HackStudio: Scroll embedded terminals to bottom upon command execution
It was kinda annoying that you had to scroll down manually every time
you started a new build while looking at some error in the scrollback.
2020-11-10 11:55:18 +01:00
Andreas Kling
9475427d5d LibVT: Add TerminalWidget::scroll_to_bottom() API
(And use this internally when scrolling to bottom on non-modifier
keydown events.)
2020-11-10 11:55:12 +01:00
AmusedNetwork
eac0344ef0 LibGUI: Limit the height of item text in IconView
Set the max height of the text_rect to be the height difference
between two icons. Calculate the number of text lines that can be
displayed in this height, and display only that many.
2020-11-10 09:54:18 +01:00
Jack Byrne
1041ab88ca
TextEditor: Go-to-line now shows line in middle of view (#4008) 2020-11-10 09:53:50 +01:00
Jesse Buhagiar
940380c986 Kernel: Prevent unveil returning ENOENT with cpath permissions
This addresses the issue first enountered in #3644. If a path is
first unveiled with "c" permissions, we should NOT return ENOENT
if the node does not exist on the disk, as the program will most
likely be creating it at a later time.
2020-11-10 09:53:18 +01:00
Lenny Maiorani
c5b26a0df8 IPv4Address: Unit tests
Problem:
- There is no direct unit testing of the IPv4Address functionality
  which makes refactoring difficult.

Solution:
- Add unit tests to cover the current functionality of
  IPv4Address. This will allow future refactorings with confidence.
2020-11-10 09:30:39 +01:00
Brendan Coles
7fbf890717 Ports: Add GNU indent 2020-11-09 16:22:52 +01:00
asynts
32957745fb AK: Add formatters for floating point numbers. 2020-11-09 16:21:29 +01:00
asynts
3b3edbc4d2 AK: Rename new_out to out and new_warn to warn. 2020-11-09 16:21:29 +01:00
asynts
74438e6fdc AK: Remove out() and warn(). 2020-11-09 16:21:29 +01:00
bcoles
74d9616bec
Base: Add Breakout game to system menu (#4006) 2020-11-09 16:21:05 +01:00