Commit Graph

1308 Commits

Author SHA1 Message Date
Andreas Kling
53d3b6b0a7 LibC: Make the syscall wrappers for stat/lstat/chdir return EFAULT
If we pass a null path to these syscall wrappers, just return EFAULT
directly from the wrapper instead of segfaulting by calling strlen().
This is a compromise, since we now have to pass the path length to the
kernel, so we can't rely on the kernel to tell us that the path is at
a bad memory address.
2020-01-06 11:15:49 +01:00
Andreas Kling
642137f014 Kernel: Make access() take path+length
Also, let's return EFAULT for nullptr at the LibC layer. We can't do
all bad addresses this way, but we can at least do null. :^)
2020-01-06 11:15:48 +01:00
Shannon Booth
47276a09dd LibC: Remove dubious String ends_with usage
As mentioned in #917, the String destructor could potentially be
clobbering the errno. Use memcpy so that we do not need String at all.
2020-01-06 10:43:00 +01:00
Shannon Booth
d4fa8e4b00 AK+Demos+Libraries: Remove executable permissions from {.cpp,.h} files 2020-01-06 10:43:00 +01:00
Andreas Kling
c5890afc8b Kernel: Make chdir() take path+length 2020-01-05 22:06:25 +01:00
Andreas Kling
f231e9ea76 Kernel: Pass path+length to the stat() and lstat() syscalls
It's not pleasant having to deal with null-terminated strings as input
to syscalls, so let's get rid of them one by one.
2020-01-05 22:02:54 +01:00
Andreas Kling
04b734501a LibCore: Oops, we were forgetting to destroy disconnected RPC clients 2020-01-05 17:54:48 +01:00
Andreas Kling
1d95e56700 LibHTML: Fix broken build after Element::computed_style() change 2020-01-05 17:38:52 +01:00
Matrix89
0d402a074b LibHTML: Make the Element::computed_style() return NonnullRefPtr
Because Element::computed_style() can never retrun null we can
return NonnullRefPtr instead of RefPtr.
2020-01-05 17:13:22 +01:00
Matrix89
99cf8e36b1 LibHTML: Add four missing border properties to the computed style 2020-01-05 17:13:22 +01:00
Matrix89
c2e1dd67c9 LibHTML: Replace StyleProperties::create(StyleProperties) with clone() 2020-01-05 17:13:22 +01:00
Matrix89
2dd35916e5 Browser+LibHTML: Change the way computed styles are queried 2020-01-05 17:13:22 +01:00
Matrix89
2ced4c4ec7 Browser+LibHTML: Deduplicate inspector code
The `DOMElementStyleModel` and `DOMComputedElementStyleModel` classes were
replaced by the `StylePropertiesModel`.
2020-01-05 17:13:22 +01:00
Matrix89
988d1deca8 Browser+LibHTML: Add "Computed" styles to the DOM inspector
I though it would be nice to also show the style that the browser uses
to display an element.

In order to do that, in place of the styles table I've put a tab widget,
with tabs for both element and computed element styles.
2020-01-05 17:13:22 +01:00
Andreas Kling
7ae7a60caa LibELF: Fix stack overflow in ELFImage::relocations()
Thanks to braindead for finding the bug! :^)
2020-01-05 10:37:54 +01:00
Sergey Bugaev
0f42908073 LibHTML: Respect the system theme
LibHTML will now use the palette colors for the default document background and
the text. As always, a page can override this default styling with CSS if it
really wants a specific color or style.

Fixes https://github.com/SerenityOS/serenity/issues/963
2020-01-05 10:21:15 +01:00
Shannon Booth
861f40f014 AK+LibCore: Add an IDAllocator and use to allocate timer ids 2020-01-05 09:00:05 +01:00
Andreas Kling
5a02a0d140 LibGUI: Refine the per-item rects in GItemView
Previously we would consider anything in the large padded area around
each item to also be part of the item for mouse event purposes.
This didn't feel right when rubberbanding, so this patch factors out
the per-item rect computation into a get_item_rects() helper which can
then be used by the various functions that need it.
2020-01-04 21:36:42 +01:00
Andreas Kling
6e21d5c432 LibGUI: Add basic rubber band selection in GItemView 2020-01-04 21:18:48 +01:00
Jami Kettunen
eab34a7de3 WindowServer+LibGUI: Implement minimizable property to windows 2020-01-04 14:58:50 +01:00
Andreas Kling
b4b8b8850a LibC: Fix broken setgroups() wrapper
This was invoking the wrong syscall (getgroups), oops! We had not been
using it yet, so it makes sense.
2020-01-04 13:01:14 +01:00
Andreas Kling
2d244a70a1 WindowServer+LibGUI: Simplify handling of paint event rects
Now that Vector<T> is convertible to Vector<T, n>, we don't have to
manually copy the paint event rectangles.
2020-01-04 11:03:37 +01:00
Andrew Kaster
767f4c7421 LibELF+LibC: Split ELFDynamicObject into a Loader + Object
Separate some responsibilities:

ELFDynamicLoader is responsible for loading elf binaries from disk and
performing relocations, calling init functions, and eventually calling
finalizer functions.

ELFDynamicObject is a helper class to parse the .dynamic section of an
elf binary, or the table of Elf32_Dyn entries at the _DYNAMIC symbol.
ELFDynamicObject now owns the helper classes for Relocations, Symbols,
Sections and the like that ELFDynamicLoader will use to perform
relocations and symbol lookup.

Because these new helpers are constructed from offsets into the .dynamic
section within the loaded .data section of the binary, we don't need the
ELFImage for nearly as much of the loading processes as we did before.
Therefore we can remove most of the extra DynamicXXX classes and just
keep the one that lets us find the location of _DYNAMIC in the new ELF.

And finally, since we changed the name of the class that dlopen/dlsym
care about, we need to compile/link and use the new ELFDynamicLoader
class in LibC.
2020-01-04 10:39:04 +01:00
Andreas Kling
70a41420a9 LibCore: Fix crash on RPC client disconnect
The RPC client management was not updated for the changes that made
CObject reference-counted it seems. :^)
2020-01-03 20:27:48 +01:00
Andreas Kling
e76e533a69 LibCore: Stop making the RPC sockets go=rw
Now that we can fchmod() on a pre-bind() socket, use that to lock down
the RPC sockets we publish in all CEventLoop-driven programs.
2020-01-03 20:21:39 +01:00
Andreas Kling
24cc67d199 Kernel: Remove read_tsc() syscall
Since nothing is using this, let's just remove it. That's one less
thing to worry about.
2020-01-03 09:27:09 +01:00
Andreas Kling
23e4e03233 Lib: Remove Stopwatch class
This was a hack used to profile things before we had a proper profiler.
Since RDTSC is not available in userspace, this is not useful anymore.
2020-01-03 09:10:55 +01:00
joshua stein
5e430e4eb4 Build: add support for building on OpenBSD
This requires gcc8 from ports to build the Toolchain.
2020-01-02 21:03:53 +01:00
joshua stein
d61131945d Build: HOST_CXX -> USE_HOST_CXX
Allow HOST_CXX to be passed to make which will be the actual host
C++ compiler used, such as 'make HOST_CXX=clang++'.
2020-01-02 21:03:53 +01:00
Andreas Kling
c6170070ed LibGUI: Clear out a GJsonArrayModel if it fails to open the JSON source
This fixes an issue in SystemMonitor where old data would linger in the
table views after selecting a process owned by another user.

Since we can no longer read /proc/PID/* unless PID belongs to us,
we will now present empty views for these processes. :^)
2020-01-02 20:57:55 +01:00
Andreas Kling
7cdfb9c6b4 Browser+LibHTML: Add resolved element style to the DOM inspector
When selecting an element in the browser's DOM inspector, we now also
show the resolved CSS properties (and their values) for that element.

Since the inspector was growing a bit more complex, I moved it out of
the "show inspector" action callback and into its own class.

In the future, we will probably want to migrate the inspector down to
LibHTML to make it accessible to other clients of the library, but for
now we can keep working on it inside Browser. :^)
2020-01-02 14:55:19 +01:00
Andreas Kling
0ff07980ae LibHTML: Include element attributes in the DOMTreeModel
We simply expand the attributes inside the element item name, so they
look like natural "tags" :^)
2020-01-02 14:53:38 +01:00
Andreas Kling
ffcd395afc LibHTML: Have element keep a pointer to their resolved style
This will make it easy to implement a simple element style inspector.
2020-01-02 14:52:34 +01:00
Andreas Kling
907b090ddf LibC+Userland: Add a proper syscall wrapper for purge() 2020-01-02 13:37:02 +01:00
Andreas Kling
7f04334664 Kernel: Remove broken implementation of Unix SHM
This code never worked, as was never used for anything. We can build
a much better SHM implementation on top of TmpFS or similar when we
get to the point when we need one.
2020-01-02 12:44:21 +01:00
Andrew Kaster
2c4f837428 LibELF: Simplify R_386_32 relocations to ignore symbol bind value
For dynamic loading, the symbol bind of a symbol actually doesn't
matter. We could do what old glibc did and try to find a strong
symbol for any weak definitions, but the ELF spec doesn't require
it and they changed that a few years ago anyway. So, moot point. :)
2020-01-02 12:28:29 +01:00
joshua stein
288fa07d85 LibCore: CSocketAddress: pull in netinet/in.h 2020-01-02 04:09:56 +01:00
joshua stein
f22322a06c LibC: move in_addr and sockaddr_in to netinet/in.h 2020-01-02 04:09:56 +01:00
Andreas Kling
8c8118fbf8 WindowServer+LibGUI: Taskbar should show all windows from each process
We were not sending the ID of the window that was listening for window
management (WM) events along with the WM messages. They only included
the "target" window's ID.

Since the taskbar's single window had the first window ID for its own
connection to the WindowServer, it meant that it would only receive
WM events for the first window ID in other processes as well.

This broke when I ported WindowServer to LibIPC.

Fix this by including the WM listener ID in all WM messages, and since
we're here anyway, get rid of a bunch of unnecessary indirection where
we were passing WM events through the WindowServer event loop before
sending them to the listener.
2020-01-02 03:29:21 +01:00
Andreas Kling
9619dab727 LibGUI: Tweak GAboutDialog text 2020-01-02 02:55:10 +01:00
Andrew Kaster
331f37d1a8 LibELF: Re-organize ELFDynamicObject::load and add PLT trampoline
ELFDynamicObject::load looks a lot better with all the steps
re-organized into helpers.

Add plt_trampoline.S to handle PLT fixups for lazy loading.
Add the needed trampoline-trampolines in ELFDynamicObject to get to
the proper relocations and to return the symbol back to the assembly
method to call into from the PLT once we return back to user code.
2020-01-01 23:54:06 +01:00
Andrew Kaster
f23dc4ea69 LibELF: Call DT_INIT method now that startfiles are correct for DSOs
We weren't calling the method here before because it was ill-formed.
No start files meant that we got the front half of the init section but
not the back half (no 'ret' in _init!). Now that we have the proper
crtbeginS and crtendS files from libgcc to help us out, we can assume
that DSOs will have the proper _init method defined.
2020-01-01 23:05:17 +01:00
joshua stein
275bc0d587 LibVT: fix pixel size calculations in terminal_did_resize
The scrollbar width must be factored in, and one too many
m_line_spacing were being factored into the height.  These caused an
initial terminal opening in 80x25 to get resized right away and
shrunk down to 77x24.
2020-01-01 19:33:19 +01:00
Andreas Kling
fc86460134 AK: Move the userspace SharedBuffer from LibC to AK
This always felt out-of-place in LibC.
2020-01-01 18:53:34 +01:00
Andrew Kaster
58517bc068 LibC: Use LibELF in dlfcn.cpp to dynamically load libraries 2020-01-01 17:48:41 +01:00
Andrew Kaster
a18b37880e LibELF: Add ELFDynamicObject to dynamically load libaries
This patch also adds some missing relocation defines to exec_elf.h,
and a few helper classes/methods to ELFImage so that we can use it
for our dynamically loaded libs and not just main program images from
the kernel :)
2020-01-01 17:48:41 +01:00
Andrew Kaster
21161342ef LibELF: Replace kprintf's in ELFImage.cpp with dbgprintf
This lets us use the class in userspace
2020-01-01 17:48:41 +01:00
Andrew Kaster
96a86463dd LibC: Move __cxa_finalize and __cxa_atexit code to their own file
These guys aren't really related to initializing the C runtime,
so move them to a new fancy file named C++ abi. Or rather, cxxabi :)
2020-01-01 17:48:41 +01:00
Conrad Pankoff
3d59db4be4 LibGUI: Close and cancel GDialog on escape
This is a small usability enhancement. If you press escape with a GDialog
focused, it will now return its "Cancel" status.
2020-01-01 02:02:29 +01:00
Andreas Kling
a69734bf2e Kernel: Also add a process boosting mechanism
Let's also have set_process_boost() for giving all threads in a process
the same boost.
2019-12-30 20:10:00 +01:00
Andreas Kling
610f3ad12f Kernel: Add a basic thread boosting mechanism
This patch introduces a syscall:

    int set_thread_boost(int tid, int amount)

You can use this to add a permanent boost value to the effective thread
priority of any thread with your UID (or any thread in the system if
you are the superuser.)

This is quite crude, but opens up some interesting opportunities. :^)
2019-12-30 19:23:13 +01:00
Andreas Kling
50677bf806 Kernel: Refactor scheduler to use dynamic thread priorities
Threads now have numeric priorities with a base priority in the 1-99
range.

Whenever a runnable thread is *not* scheduled, its effective priority
is incremented by 1. This is tracked in Thread::m_extra_priority.
The effective priority of a thread is m_priority + m_extra_priority.

When a runnable thread *is* scheduled, its m_extra_priority is reset to
zero and the effective priority returns to base.

This means that lower-priority threads will always eventually get
scheduled to run, once its effective priority becomes high enough to
exceed the base priority of threads "above" it.

The previous values for ThreadPriority (Low, Normal and High) are now
replaced as follows:

    Low -> 10
    Normal -> 30
    High -> 50

In other words, it will take 20 ticks for a "Low" priority thread to
get to "Normal" effective priority, and another 20 to reach "High".

This is not perfect, and I've used some quite naive data structures,
but I think the mechanism will allow us to build various new and
interesting optimizations, and we can figure out better data structures
later on. :^)
2019-12-30 18:46:17 +01:00
Andreas Kling
816d3e6208 LibHTML: Ignore all CSS rules starting with "@" for now 2019-12-30 17:09:00 +01:00
Andreas Kling
1b2c6e8f41 LibCore: Use JsonObject::get_ptr() in CProcessStatisticsReader
This removes a bunch of JsonValue copying from the hot path in thread
statistics fetching.

Also pre-size the thread statistics vector since we know the final size
up front. :^)
2019-12-30 14:51:34 +01:00
Tibor Nagy
edc3580756 LibDraw: Store glyph spacing information in the fonts headers 2019-12-30 14:02:12 +01:00
Andreas Kling
ef658594e4 LibIPC: Let's start building custom message codecs for LibIPC
Instead of using ByteBuffer (which always malloc() their storage) for
IPC message encoding, we now use a Vector<u8, 1024>, which means that
messages smaller than 1 KB avoid heap allocation entirely.
2019-12-30 02:41:45 +01:00
Andreas Kling
57f55f297b LibGUI: Call GWidget::resize_event() before doing widget layout
The widget layout system currently works by having layouts size the
children of a widgets. The children then get resize events, giving them
a chance to lay out their own children, etc.

In keeping with this, we need to handle the resize event before calling
do_layout() in a widget, since the resize event handler may do things
that end up affecting the layout, but layout should not affect the
resize event since the event comes from the widget parent, not itself.
2019-12-30 00:26:19 +01:00
Andreas Kling
aaaf04f393 LibGUI: Relayout GTextEditor on font change
Fixes #941.
2019-12-29 23:03:41 +01:00
Andreas Kling
411d293961 LibCore+LibGUI: Don't fire timers in non-visible windows by default
LibCore timers now have a TimerShouldFireWhenNotVisible flag which is
set to "No" by default.

If "No", the timer will not be fired by the event loop if it's within
a CObject tree whose nearest GWindow ancestor is currently not visible
for timer purposes. (Specificially, this means that the window is
either minimized or fully occluded, and so does not want to fire timers
just to update the UI.)

This is another nice step towards a calm and serene operating system.
2019-12-29 16:03:36 +01:00
Andreas Kling
f8f2b8b520 LibDraw: Fix text rendering in progress bars 2019-12-29 15:53:28 +01:00
Andreas Kling
c74cde918a Kernel+SystemMonitor: Expose amount of per-process clean inode memory
This is memory that's loaded from an inode (file) but not modified in
memory, so still identical to what's on disk. This kind of memory can
be freed and reloaded transparently from disk if needed.
2019-12-29 12:45:58 +01:00
Andreas Kling
0d5e0e4cad Kernel+SystemMonitor: Expose amount of per-process dirty private memory
Dirty private memory is all memory in non-inode-backed mappings that's
process-private, meaning it's not shared with any other process.

This patch exposes that number via SystemMonitor, giving us an idea of
how much memory each process is responsible for all on its own.
2019-12-29 12:28:32 +01:00
Andreas Kling
ffbe975ffc LibHTML: RenderingContext should keep the Palette alive
We were lugging around a reference to a temporary here.
2019-12-29 12:01:24 +01:00
Andreas Kling
7b2dd7e116 LibDraw+LibGUI: Allow changing individual colors in a Palette
Palette is now a value wrapper around a NonnullRefPtr<PaletteImpl>.
A new function, set_color(ColorRole, Color) implements a simple
copy-on-write mechanism so that we're sharing the PaletteImpl in the
common case, but allowing you to create custom palettes if you like,
by getting a GWidget's palette, modifying it, and then assigning the
modified palette to the widget via GWidget::set_palette().

Use this to make PaintBrush show its palette colors once again.

Fixes #943.
2019-12-29 00:47:49 +01:00
Andreas Kling
19d4f4c7b5 LibHTML: Add missing flock to Makefile (thanks jcs) 2019-12-28 23:58:52 +01:00
Stefano Cristiano
fa8cec6627 Build: Fix missing IPC dependency for LibHTML 2019-12-28 21:43:56 +01:00
joshua stein
0b501335f5 Build: wrap make invocations with flock(1)
Lock each directory before entering it so when using -j, the same
dependency isn't built more than once at a time.

This doesn't get full -j parallelism though, since one make child
will be sitting idle waiting for flock to receive its lock and
continue making (which should then do nothing since it will have
been built already).  Unfortunately there's not much that can be
done to fix that since it can't proceed until its dependency is
built by another make process.
2019-12-28 21:09:33 +01:00
Paweł Cholewa
b5c3bc6a71 LibC: implement fgetpos and fsetpos
They're just "front ends" for ftell and fseek, but they do their
job.

Fixes #913
2019-12-27 23:09:08 +01:00
Andreas Kling
2cbc3c6ee5 LibC+ping: Let's use the traditional timersub() et al prototypes
This also fixes the build, since ping.cpp already had a timersub().
2019-12-27 23:07:28 +01:00
Hüseyin ASLITÜRK
71922ee6a5 GListView: Fix for theme support. We have to use theme colors. 2019-12-27 22:47:31 +01:00
Mauri de Souza Nunes
0e49c842de LibC: Add timeval operations
This commit add macros for the timeval operations timeradd, timersub,
timercmp, timerisset, timerclear.
2019-12-27 22:43:43 +01:00
Andreas Kling
4d997308c2 LibC: Remove some functions we had two of 2019-12-27 16:55:10 +01:00
Andreas Kling
cbdd65e4d9 LibDraw: Remove redundant Rect copy constructor 2019-12-27 16:55:10 +01:00
Valtteri Koskivuori
2b9c9bf663 LibPthread: Log debug info to debug console instead of stdout (#931) 2019-12-27 15:53:02 +01:00
Andreas Kling
159289af03 WindowServer: Use the system theme for the fallback window background
When filling in some missing part of a window (typically happens during
interactive window resize) we now use the ColorRole::Background from
the system theme palette instead of expecting the clients to send us
the same information when creating windows.
2019-12-27 13:28:55 +01:00
Andreas Kling
c7847d7c81 WindowServer+LibGUI: Mark window bitmaps volatile in occluded windows
WindowServer now tracks whether windows are occluded (meaning that
they are completely covered by one or more opaque windows sitting above
them.) This state is communicated to the windows via WindowStateChanged
messages, which then allow GWindow to mark its backing store volatile.

This reduces the effective memory impact of windows that are not at all
visible to the user. Very cool. :^)
2019-12-27 11:34:40 +01:00
Stefano Cristiano
1222b94ab8 LibCore: Allow LibCore to be compiled on macOS host
Compiling LibCore on macOS is needed if one wants to compile host tools
(like IPCCompiler) on a non Linux host.
These changes could be possibly reverted once "event loop" functionality
and "base library" (Vector, String etc.) will be split in two separate libraries,
updating all relevant projects.
2019-12-27 02:19:55 +01:00
Stefano Cristiano
aab412bd85 LibCore: Fix errors when compiling LibCore using clang instead of gcc 2019-12-27 02:19:55 +01:00
Andreas Kling
23e16a3e2e LibGUI: Remove bitrotted automatic keybinds feature
This feature hasn't been working at all for several months, so let's
just remove it and simplify GWindow event handling.
2019-12-27 00:52:30 +01:00
Shannon Booth
123b5c9d34 LibDraw: Add draw_ellipse_intersecting function
This functon will draw an ellipse which is intersecting the corners of
the rect given. It is a very naive implementation, taking 200 samples of
points around the ellipse, and drawing straight lines between each of
these points.

The ellipses look good enough to me though!
2019-12-27 00:52:17 +01:00
Andreas Kling
43da941de5 LibGUI: Use NeverDestroyed<T> for the global GWindow tables
We don't need these to be destroyed on exit, since that would race with
the destruction of static global RefPtr<GWindow>'s.

Fixes #900.
2019-12-26 22:13:50 +01:00
Shannon Booth
b830639912 PaintBrush: Add a "rectangle tool"
Fill, line, and gradient modes initially supported :^)
2019-12-26 21:22:29 +01:00
Shannon Booth
70a2355963 LibDraw: Add dx/dy_relative_to() helper functions for Points 2019-12-26 21:22:29 +01:00
Andreas Kling
519cb80a96 LibGUI+WindowServer: Mark minimized window backing stores as volatile
WindowServer will now send out a WindowStateChanged message to clients
when one of their windows is minimized.

This is then forwarded to the GWindow, which will try to mark its
underlying window backing store as volatile.

This allows the kernel to steal the memory used by minimized windows
in case it starts running low. Very cool! :^)
2019-12-26 12:06:07 +01:00
Andreas Kling
9d681beaf0 LibC: Oops x2, we can't use "bool" in stdlib.h either 2019-12-26 10:30:34 +01:00
Andreas Kling
b1fc5d9143 LibC: Oops, we can't use [[nodiscard]] when this is included from C 2019-12-26 10:24:37 +01:00
Shannon Booth
64842fd0ac LibHTML: Remove fixed FIXME 2019-12-26 10:05:59 +01:00
Shannon Booth
bbf878e987 LibC: Implement tmpfile() 2019-12-26 10:05:59 +01:00
Shannon Booth
f6bd4f8691 LibC: Use shared functon to generate unique filenames
Move some dupliated code into __generate_unique_filename()
2019-12-26 10:05:59 +01:00
Andreas Kling
5be6a43860 LibDraw: Add MenuBaseText and MenuSelectionText color roles
This allows the very aesthetic "Hotdog Stand" theme to have quite
reasonable looking menus.
2019-12-26 00:58:46 +01:00
Andreas Kling
4a8683ea68 Kernel+LibPthread+LibC: Add a naive futex and use it for pthread_cond_t
This patch implements a simple version of the futex (fast userspace
mutex) API in the kernel and uses it to make the pthread_cond_t API's
block instead of busily sched_yield().

An arbitrary userspace address is passed to the kernel as a "token"
that identifies the futex and you can then FUTEX_WAIT and FUTEX_WAKE
that specific userspace address.

FUTEX_WAIT corresponds to pthread_cond_wait() and FUTEX_WAKE is used
for pthread_cond_signal() and pthread_cond_broadcast().

I'm pretty sure I'm missing something in this implementation, but it's
hopefully okay for a start. :^)
2019-12-25 23:54:06 +01:00
Andreas Kling
b5bcecef09 LibDraw: Remove bogus LibC/ prefix on SharedBuffer.h include
This class really doesn't belong in LibC anyway, does it? Mehh.
2019-12-25 22:50:17 +01:00
Andreas Kling
9e55bcb7da Kernel: Make kernel memory regions be non-executable by default
From now on, you'll have to request executable memory specifically
if you want some.
2019-12-25 22:41:34 +01:00
Andreas Kling
d3b40547f7 LibDraw: Fix 1px wide glitch in progress bar painting at some widths
Make sure we always line up the "hole" in the progress bar with the
right side of the paint rect. This fixes a 1px wide glitch seen when
using a darker system theme.
2019-12-25 21:59:37 +01:00
Andreas Kling
69277f5538 LibGUI: Add space for sort order indicators in autosized table columns 2019-12-25 21:52:26 +01:00
Andreas Kling
1e419b482a LibProtocol: Make build depend on ProtocolServer for IPC endpoints 2019-12-25 14:15:28 +01:00
joshua stein
c127d16326 Build: support library and generator dependencies
Instead of directly manipulating LDFLAGS, set LIB_DEPS in each
subdirectory Makefile listing the libraries needed for
building/linking such as "LIB_DEPS = Core GUI Draw IPC Core".

This adds each library as an -L and -l argument in LDFLAGS, but
also adds the library.a file as a link dependency on the current
$(PROGRAM).  This causes the given library to be (re)built before
linking the current $(PROGRAM), but will also re-link any binaries
depending on that library when it is modified, when running make
from the root directory.

Also turn generator tools like IPCCompiler into dependencies on the
files they generate, so they are built on-demand when a particular
directory needs them.

This all allows the root Makefile to just list directories and not
care about the order, as all of the dependency tracking will figure
it out.
2019-12-25 10:11:09 +01:00
joshua stein
2aeae2aea9 LibCore: compile puff.c as a separate object 2019-12-25 10:11:09 +01:00
Andreas Kling
caa5191f74 LibGUI: Use ColorRole::BaseText for the GCheckBox checkmark 2019-12-24 22:33:11 +01:00
Andreas Kling
7ca7595012 LibDraw: Teach progress bar painting about palettes 2019-12-24 22:17:11 +01:00
Andreas Kling
aae54bdbde LibDraw: Add ColorRole::BaseText (to be painted on ColorRole::Base) 2019-12-24 22:01:32 +01:00
Andreas Kling
a79bac428b LibGUI+LibDraw: Add "Palette" concept for scoped color theming
GApplication now has a palette. This palette contains all the system
theme colors by default, and is inherited by a new top-level GWidget.
New child widgets inherit their parents palette.

It is possible to override the GApplication palette, and the palette
of any GWidget.

The Palette object contains a bunch of colors, each corresponding to
a ColorRole. Each role has a convenience getter as well.

Each GWidget now has a background_role() and foreground_role(), which
are then looked up in their current palette when painting. This means
that you no longer alter the background color of a widget by setting
it directly, rather you alter either its background role, or the
widget's palette.
2019-12-24 21:27:16 +01:00
Andreas Kling
b6eba388e3 LibDraw: Add Selection and SelectionText system theme colors 2019-12-24 12:13:49 +01:00
Andreas Kling
c1e8590a40 LibDraw: Use SystemColor::ThreedHighlight everywhere in StylePainter 2019-12-24 02:38:30 +01:00
Andreas Kling
b25600a7ef LibGUI: Respect more theme colors in GTextEditor 2019-12-24 02:38:18 +01:00
Andreas Kling
a3257a7c6c LibGUI: Respect more system theme colors in GToolBar 2019-12-24 02:37:56 +01:00
Andreas Kling
7b78f63f85 LibGUI: More system theme support in GTabWidget and GTableView 2019-12-24 02:25:50 +01:00
Andreas Kling
8ae826f5c3 LibDraw: Give Color::lightened() an amount argument 2019-12-24 02:25:50 +01:00
Andreas Kling
df3a2dba43 LibDraw: Add Button and ButtonText system theme colors
These are now separate from the Window and WindowText colors.
2019-12-24 02:25:50 +01:00
Andreas Kling
9171aef724 LibGUI: Use SystemColor::Text in more places 2019-12-24 02:25:50 +01:00
Andreas Kling
a3590ca602 LibGUI: Paint GResizeCorner with SystemColor::Window background 2019-12-24 00:21:09 +01:00
Andreas Kling
411058b2a3 WindowServer+LibGUI: Implement basic color theming
Color themes are loaded from .ini files in /res/themes/
The theme can be switched from the "Themes" section in the system menu.

The basic mechanism is that WindowServer broadcasts a SharedBuffer with
all of the color values of the current theme. Clients receive this with
the response to their initial WindowServer::Greet handshake.

When the theme is changed, WindowServer tells everyone by sending out
an UpdateSystemTheme message with a new SharedBuffer to use.

This does feel somewhat bloated somehow, but I'm sure we can iterate on
it over time and improve things.

To get one of the theme colors, use the Color(SystemColor) constructor:

    painter.fill_rect(rect, SystemColor::HoverHighlight);

Some things don't work 100% right without a reboot. Specifically, when
constructing a GWidget, it will set its own background and foreground
colors based on the current SystemColor::Window and SystemColor::Text.
The widget is then stuck with these values, and they don't update on
system theme change, only on app restart.

All in all though, this is pretty cool. Merry Christmas! :^)
2019-12-23 20:33:01 +01:00
Shannon Booth
456a4bc108 LibDraw: Parse all CSS standardised color keywords 2019-12-23 10:56:59 +01:00
Andreas Kling
c1b4e8aef0 LibGUI: Activate GTreeView indexes when double clicking leaf nodes
This seems pretty sensible to me. I'm unsure if we should activate
nodes that have children, or just toggle them.
2019-12-23 10:55:34 +01:00
Andreas Kling
a12c2df43f LibPthread: Okay I'm dumb, let's convert mutex locks into Atomic<u32>& 2019-12-22 20:25:09 +01:00
Andreas Kling
9e3e13e410 LibPthread: Fix typo in pthread_mutex_lock()
We were casting the pthread_mutex_t* instead of pthread_mutex_t::lock
to an Atomic<u32>. This still worked fine, since "lock" is the first
member of pthread_mutex_t.
2019-12-22 17:25:55 +01:00
Andreas Kling
0c97380ee6 LibPthread+LibC: Support PTHREAD_MUTEX_RECURSIVE
This allows SDL to build against our native recursive mutex instead
of providing its own. Also it's just a nice feature to have. :^)
2019-12-22 14:25:41 +01:00
Andrew Kaster
150837e7e8 LibC: Prevent assertions in malloc/free at exit time
This is a bit sad, but, with the Allocators as static globals their
destructors were running before some user code. Which doesn't really
make much sense, as none of the members of (at least the basic one) do
any real heavy lifting or have many resources to RAII.

To avoid the problem, just mmap the memory for the global arrays of
Allocators in __malloc_init and let the Kernel collect the memory when
we're done with the process.
2019-12-22 10:47:39 +01:00
Andrew Kaster
7edfdca4b2 LibGUI: Don't assert in ~GWidgetClassRegistration
These guys are all declared as globals, and their ASSERT_NOT_REACHED
in the destructor doesn't play nice with __cxa_atexit. As in, every
application will assert in __cxa_finalize if this assert isn't removed.
2019-12-22 10:47:39 +01:00
Andrew Kaster
824bbc7462 LibC: Support exit time destructors per the Itanium C++ ABI
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.
2019-12-22 10:47:39 +01:00
Andreas Kling
270beb5165 LibC: Always install as part of the default target
We always want to put crt0.o in the location where it can get picked
up by the i686-pc-serenity toolchain.

This feels a bit hackish but should get the build working again. :^)
2019-12-20 21:13:53 +01:00
Andreas Kling
842716a0b5 Kernel+LibC: Build with basic -fstack-protector support
Use simple stack cookies to try to provoke an assertion failure on
stack overflow.

This is far from perfect, since we use a constant cookie instead of
generating a random one on startup, but it can still help us catch
bugs, which is the primary concern right now. :^)
2019-12-20 21:03:32 +01:00
Andreas Kling
6ec46aad66 LibC: Make sure we build crt0.o 2019-12-20 20:36:53 +01:00
joshua stein
ac25438d54 Build: clean up build system, use one shared Makefile
Allow everything to be built from the top level directory with just
'make', cleaned with 'make clean', and installed with 'make
install'.  Also support these in any particular subdirectory.

Specifying 'make VERBOSE=1' will print each ld/g++/etc. command as
it runs.

Kernel and early host tools (IPCCompiler, etc.) are built as
object.host.o so that they don't conflict with other things built
with the cross-compiler.
2019-12-20 20:20:54 +01:00
Sergey Bugaev
d91c40de3b LibC: Make empty malloc blocks purgeable 2019-12-20 20:19:46 +01:00
Andreas Kling
cfcb38dff1 WindowServer+LibGUI: Add data_type and data fields to drag operations
These fields are intended to carry the real meat of a drag operation,
and the "text" is just for what we show on screen (alongside the cursor
during the actual drag.)

The data field is just a String for now, but in the future we should
make it something more flexible.
2019-12-20 20:07:10 +01:00
Andreas Kling
af7cb7ce1b LibGUI: GWidget::drop_event() should ignore the event by default
This will cause the event to bubble up the widget tree.
2019-12-20 20:07:10 +01:00
Andreas Kling
c0e81b26b6 LibHTML: Ignore layout repaints outside the visible viewport
Now that Frame knows the visible viewport rect, it can easily ignore
repaint requests from e.g <blink> elements that are not currently
scrolled into view. :^)
2019-12-18 22:16:27 +01:00
Andreas Kling
1aea8f116b LibHTML: Add TreeNode::for_each_in_subtree_of_type<T>()
This allows you to iterate a subtree and get a callback for every node
where is<T>(node) == true. This makes for quite pleasant DOM traversal.
2019-12-18 21:34:03 +01:00
Andreas Kling
54bd322881 LibHTML: Mark image bitmaps outside the visible viewport as volatile
When the visible viewport rect changes, we walk the layout tree and
check where each LayoutImage is in relation to the viewport rect.
Images outside have their bitmaps marked as volatile.

Note that the bitmaps are managed by ImageDecoder objects. If a bitmap
is purged by the kernel while volatile, we construct a new ImageDecoder
next time we need pixels for the image.
2019-12-18 21:19:04 +01:00
Andreas Kling
7e068565bc LibHTML: Push the visible viewport rect from HtmlView to Frame
This will allow various mechanisms and optimizations based on the
currently visible viewport rect.
2019-12-18 20:54:23 +01:00
Andreas Kling
85ac9705ba LibHTML: Add LayoutNode::is_image() and is<LayoutImage> helper 2019-12-18 20:52:36 +01:00
Andreas Kling
7cc4b90b16 LibDraw: Create purgeable GraphicsBitmap in the PNG decoder
Also add ImageDecoder APIs for controlling the volatile flag.
2019-12-18 20:50:58 +01:00
Andreas Kling
77ae98a9b6 LibDraw: Add GraphicsBitmap::create_purgeable()
This allows you to create a process-private purgeable GraphicsBitmap.
The volatile flag is controlled via set_volatile() / set_nonvolatile().
2019-12-18 20:50:05 +01:00
Andreas Kling
487f9b373b Kernel: Add MADV_GET_VOLATILE for checking the volatile flag
Sometimes you might want to know if a purgeable region is volatile.
2019-12-18 20:48:24 +01:00
Sergey Bugaev
1ad5568759 LibC: Store empty malloc blocks in an array instead of a linked list 2019-12-18 19:02:25 +01:00
Andreas Kling
0d6f186397 LibHTML: Insert a new linebox for every newline in "white-space: pre" 2019-12-18 12:44:16 +01:00
Andreas Kling
1fda417f4f LibHTML: Ignore case of presentation attribute names 2019-12-18 12:44:13 +01:00
Andreas Kling
4d81bc20d8 LibHTML: Don't insert line breaks between multiple <pre>'s on a line
When iterating lines for "white-space: pre", we should only break when
there is an actual line break character.
2019-12-18 12:44:09 +01:00
Andreas Kling
152c31c5c6 LibHTML: Let's display <basefont> as block-level elements for now 2019-12-18 12:44:06 +01:00
Andreas Kling
33daa80bf0 LibHTML: Use a fixed-width font for <pre> tags, duh! 2019-12-18 12:44:02 +01:00
Andreas Kling
7301db4f9a GTextEditor: Fix broken rendering of selection on wrapped lines
This logic broke when converting String::length() to return size_t.
2019-12-17 21:15:10 +01:00
Andreas Kling
91ba94fbd4 LibHTML: Support the :only-child pseudo class 2019-12-16 19:52:11 +01:00
Andreas Kling
085cafd80a LibHTML: Support the :empty pseudo class 2019-12-16 19:46:02 +01:00
Andreas Kling
a32cae4c3b LibDraw: Parse the color name "pink" to #ffc0cb 2019-12-16 19:45:21 +01:00
Andreas Kling
c1474e594e LibHTML: Support the :first-child and :last-child pseudo classes 2019-12-16 19:34:52 +01:00
Andreas Kling
870df4a8c6 LibGUI: Fix GTreeView crash on pressing Left/Right without selection 2019-12-16 18:26:26 +01:00
Andreas Kling
72bdf595cc LibIPC: Make sure we always process unhandled messages
A client that only ever does synchronous IPC calls from its side would
never actually process incoming asynchronous messages since they would
arrive while waiting for a synchronous response and then end up sitting
forever in the "unhandled messages" queue.

We now always handle unhandled messages using a deferred invocation.

This fixes the bug where Audio.MenuApplet didn't learn that the muted
state changed in response to its own request to change it. :^)
2019-12-16 17:45:57 +01:00
Andreas Kling
df129bbe0e WindowServer+CPUGraph: Make menu applets be "regular" windows
Instead of implementing menu applets as their own thing, they are now
WSWindows of WSWindowType::MenuApplet.

This makes it much easier to work with them on the client side, since
you can just create a GWindow with the right type and you're in the
menubar doing applet stuff :^)
2019-12-16 15:05:45 +01:00
Andreas Kling
77cf607cda Kernel+LibC: Publish a "kernel info page" and use it for gettimeofday()
This patch adds a single "kernel info page" that is mappable read-only
by any process and contains the current time of day.

This is then used to implement a version of gettimeofday() that doesn't
have to make a syscall.

To protect against race condition issues, the info page also has a
serial number which is incremented whenever the kernel updates the
contents of the page. Make sure to verify that the serial number is the
same before and after reading the information you want from the page.
2019-12-15 21:29:26 +01:00
Andreas Kling
5292f6e78f Kernel+FileManager: Disallow watch_file() in unsupported file systems
Currently only Ext2FS and TmpFS supports InodeWatchers. We now fail
with ENOTSUPP if watch_file() is called on e.g ProcFS.

This fixes an issue with FileManager chewing up all the CPU when /proc
was opened. Watchers don't keep the watched Inode open, and when they
close, the watcher FD will EOF.

Since nothing else kept /proc open in FileManager, the watchers created
for it would EOF immediately, causing a refresh over and over.

Fixes #879.
2019-12-15 19:33:39 +01:00
Andreas Kling
7fea25943d LibGUI: Fix GTreeView column headers incorrectly scrolling with content 2019-12-15 18:17:02 +01:00
Andreas Kling
d4a570d576 LibGUI: Fix GTreeView not showing the context menu
This logic is all taken care of by GAbstractColumnView now, so we can
simply delete GTreeView::context_menu_event(). :^)

Fixes an issue mentioned in #826
2019-12-15 17:02:44 +01:00
Andreas Kling
6b71250d1a LibCore: Silence some aggressive CSocket and CHttpJob debug spam 2019-12-14 11:30:18 +01:00
Andreas Kling
bcffe31d3a LibCore: Bump the CHttpJob receive buffer size from 4KB to 64KB
4KB gets pretty mmap/munmap heavy when downloading larger files,
so bump this a bit to reduce time spent in memory allocation.

This can be improved in various ways, but I'm not sure what the
best way forward is at the moment.
2019-12-14 10:01:20 +01:00
Andreas Kling
4d406d5c6d LibGUI: GAbstractColumnModel should never claim to hit a toggle box
Only GTreeView can hit a toggle box in index_at_event_position().
2019-12-14 00:21:51 +01:00
Andreas Kling
561718d88b LibGUI: Improve GTreeView column auto-sizing
Rerun the column auto-sizing algorithm when opening/closing nodes.
Also use the column name as the minimum column width for the tree
column as well.
2019-12-13 23:51:16 +01:00
Andreas Kling
0ac74d3778 LibGUI: Make GTreeView inherit from GAbstractColumnView
This makes GTreeView able to support multi-column models!

Only one column can be the "tree column", this is column 0 by default
but can be changed by overriding GModel::tree_column().
2019-12-13 23:36:36 +01:00
Andreas Kling
b909d991f1 LibDraw: Add a way to check for horizontal/vertical Rect intersections 2019-12-13 23:36:17 +01:00
Andreas Kling
2d39bce3f6 LibGUI: Add a GAbstractColumnView base class for GTableView
Almost everything in GTableView moves up to GAbstractColumnView.
This is in preparation for sharing a base class between GTableView
and GTreeView :^)
2019-12-13 20:54:40 +01:00
Tommy Nguyen
d8b7cd940f TreeView: Clear metadata after model update
When the filesystem model is updated, it is rebuilt. This means dangling
indexes inside the TreeView metadata table will have old information and random
directories will toggle open. Clearing the table alleviates this issue.
2019-12-12 22:41:28 +01:00
Tommy Nguyen
2bd640277e LibGUI: Add missing call to did_update() when updating GFileSystemModel 2019-12-12 22:41:28 +01:00
Andreas Kling
0f393148da Kernel: Separate out the symbol offsets in profile output
Instead of saying "main +39" and "main +57" etc, we now have a separate
field in /proc/profile for the offset-into-the-symbol.
2019-12-12 21:59:47 +01:00
Tommy Nguyen
f26548395e LibGUI: Add context_menu_event to GTreeView 2019-12-12 11:19:02 +01:00
Andreas Kling
b32e961a84 Kernel: Implement a simple process time profiler
The kernel now supports basic profiling of all the threads in a process
by calling profiling_enable(pid_t). You finish the profiling by calling
profiling_disable(pid_t).

This all works by recording thread stacks when the timer interrupt
fires and the current thread is in a process being profiled.
Note that symbolication is deferred until profiling_disable() to avoid
adding more noise than necessary to the profile.

A simple "/bin/profile" command is included here that can be used to
start/stop profiling like so:

    $ profile 10 on
    ... wait ...
    $ profile 10 off

After a profile has been recorded, it can be fetched in /proc/profile

There are various limits (or "bugs") on this mechanism at the moment:

- Only one process can be profiled at a time.
- We allocate 8MB for the samples, if you use more space, things will
  not work, and probably break a bit.
- Things will probably fall apart if the profiled process dies during
  profiling, or while extracing /proc/profile
2019-12-11 20:36:56 +01:00
Andreas Kling
adb1870628 LibHTML: Rename HTMLImageElement::m_image_data => m_encoded_data 2019-12-11 18:30:42 +01:00
Andreas Kling
150090c742 LibGUI: Add GTextDocument::range_for_entire_line() 2019-12-10 22:06:31 +01:00
Andreas Kling
40b7d814c3 LibCore: Make CHttpJob::response() return a CHttpResponse*
We know that the CNetworkResponse inside a CHttpJob is always going to
be a CHttpResponse, so we can return a casted pointer to be nice. :^)
2019-12-10 20:46:33 +01:00
Valtteri Koskivuori
fe1df9e9fb LibC: Implement strtod() 2019-12-10 16:24:47 +01:00
Valtteri Koskivuori
b8ac14a873 LibM: Implement pow() 2019-12-10 16:24:47 +01:00
remyabel
d8daa08359 GTreeView: Prevent doubleclick with right mouse button (#868)
This follows user expectations and prevents interference with context menu
handling.
2019-12-10 10:24:14 +01:00
Andreas Kling
f8ec8cc255 LibGUI: Mark the first GWindow back bitmap volatile immediately
We were previously waiting until the first bitmap buffer flip happened
before marking the back buffer volatile.
2019-12-09 21:33:39 +01:00
Andreas Kling
571c4d3fb8 LibGUI: Allow finding the source of a GAction activation
When a GAction is activated by a menu, or by a toolbar button, you can
now use GAction::activator() to get a pointer to whomever activated it.

This can be used to implement context-specific behaviors in situations
where the same action is exposed through multiple paths.

This addresses an issue that was brought up in #826.
2019-12-09 21:29:43 +01:00
Andreas Kling
fd5eb79d19 LibGUI: Make GMenu inherit from CObject
This is primarily to make it possible to pass a GMenu* where a CObject*
is expected.
2019-12-09 21:05:44 +01:00
Andreas Kling
dfd0daa157 LibGUI: Mark window back buffers as volatile while not painting
We now take advantage of SharedBuffers being purgeable memory by
setting the volatile flag on window back buffers while not painting
into them.

This means that one of the two backing stores used by each window
is purgeable+volatile most of the time, allowing the kernel to purge
it to recover memory if needed.

Note that this is only relevant when double-buffering is turned on,
but since that is the default, this does affect most apps. :^)
2019-12-09 20:08:44 +01:00
Andreas Kling
0317ca5ccc Kernel+LibC: Make all SharedBuffers purgeable (default: non-volatile)
This patch makes SharedBuffer use a PurgeableVMObject as its underlying
memory object.

A new syscall is added to control the volatile flag of a SharedBuffer.
2019-12-09 20:06:47 +01:00
Andreas Kling
92b46d9814 SystemMonitor: Show information about purgeable memory
This patch exposes some fields about purgeable memory regions.
We now also show total purgeable volatile and non-volatile memory in
the big process table.
2019-12-09 19:16:58 +01:00
Andreas Kling
dbb644f20c Kernel: Start implementing purgeable memory support
It's now possible to get purgeable memory by using mmap(MAP_PURGEABLE).
Purgeable memory has a "volatile" flag that can be set using madvise():

- madvise(..., MADV_SET_VOLATILE)
- madvise(..., MADV_SET_NONVOLATILE)

When in the "volatile" state, the kernel may take away the underlying
physical memory pages at any time, without notifying the owner.
This gives you a guilt discount when caching very large things. :^)

Setting a purgeable region to non-volatile will return whether or not
the memory has been taken away by the kernel while being volatile.
Basically, if madvise(..., MADV_SET_NONVOLATILE) returns 1, that means
the memory was purged while volatile, and whatever was in that piece
of memory needs to be reconstructed before use.
2019-12-09 19:12:38 +01:00
Andreas Kling
6f4c380d95 AK: Use size_t for the length of strings
Using int was a mistake. This patch changes String, StringImpl,
StringView and StringBuilder to use size_t instead of int for lengths.
Obviously a lot of code needs to change as a result of this.
2019-12-09 17:51:21 +01:00
Dan MacDonald
91fc6a056b LibC: Add PRIXPTR definition to inttypes.h 2019-12-09 16:33:14 +01:00
Andreas Kling
f5dfb29607 LibGUI+WindowServer: Allow specifying an optional drag bitmap
This bitmap is displayed alongside the dragged text underneath the
mouse cursor while dragging.

This will be a perfect fit for dragging e.g files around. :^)
2019-12-08 17:08:39 +01:00
Andreas Kling
183ee5847c LibDraw: Add GraphicsBitmap::to_shareable_bitmap()
This function returns the bitmap itself if it's already backed by a
SharedBuffer object, otherwise it creates a shareable copy of itself
and returns that.
2019-12-08 17:07:44 +01:00
Andreas Kling
a7f414bba7 LibGUI+WindowServer: Start fleshing out drag&drop functionality
This patch enables basic drag&drop between applications.
You initiate a drag by creating a GDragOperation object and calling
exec() on it. This creates a nested event loop in the calling program
that only returns once the drag operation has ended.

On the receiving side, you get a call to GWidget::drop_event() with
a GDropEvent containing information about the dropped data.

The only data passed right now is a piece of text that's also used
to visually indicate that a drag is happening (by showing the text in
a little box that follows the mouse cursor around.)

There are things to fix here, but we're off to a nice start. :^)
2019-12-08 16:50:23 +01:00
Andrew Kaster
e09a02ad3f SystemMonitor: Show thread name instead of process name
Add the thread name to CThreadStatistics and display it in the
system monitor's process model instead of the process name.
2019-12-08 14:09:29 +01:00
Andrew Kaster
0b38a553b1 LibThread: Allow setting thread name in constructor
Thread now has an optional thread_name parameter to the consturctor
that will call pthread_setname_np if given.
2019-12-08 14:09:29 +01:00
Andrew Kaster
baf7e247e3 LibPThread: Add pthread_set/getname_np
These wrappers call the set_thread_name and get_thread_name syscalls
respectively.
2019-12-08 14:09:29 +01:00
Andreas Kling
7c0fb91ca4 LibAudio: Install library and headers 2019-12-08 11:40:30 +01:00
Andreas Kling
1670ee5aba LibPthread: Condition variables should use CLOCK_MONOTONIC by default
It's the only clock we have at the moment, so it's a logical choice :^)
2019-12-07 16:07:48 +01:00
Andreas Kling
e7dfd40dc3 LibPthread: Mark the pthread_cond_t "waiting" flag as volatile
Oops, this is not gonna work if the compiler can optimize out all the
reads from this flag. :^)
2019-12-07 15:34:00 +01:00
Andreas Kling
96e8c8a4e5 LibPthread: Add stubs for pthread_{get,set}schedparam()
These should be the last thing needed to make SDL build with threads
support. I think we can survive just fine with stubs of these for now,
especially given that the kernel doesn't care super much about thread
priorities anyway.
2019-12-07 15:32:48 +01:00
Andreas Kling
615553be5f LibPthread: Implement simple thread-specific keys
This patch adds pthread_key_create() and pthread_{get,set}specific().
There's a maximum of 64 thread-specific keys for simplicity.

Key destructors are not invoked on thread exit.
2019-12-07 15:21:18 +01:00
Andreas Kling
2b45b7a45c LibPthread: Implement pthread_sigmask() 2019-12-07 14:52:27 +01:00
Andreas Kling
95b086f47f Kernel+LibPthread: Implement pthread_detach() 2019-12-07 14:52:27 +01:00
Andreas Kling
9ddfe694f2 LibPthread: Implement pthread_mutexattr_init() and _destroy() 2019-12-07 14:52:27 +01:00
Andreas Kling
eaab7f5672 LibPthread: Don't set errno in pthread functions
POSIX says that pthread API's don't set errno directly. If there is an
error, it should be the return value from the function instead.
2019-12-07 14:52:27 +01:00
Andreas Kling
babb726212 LibPthread: Implement pthread_mutex_trylock() 2019-12-07 14:52:27 +01:00
Andreas Kling
594c7f2d83 LibPthread: Implement pthread_self() 2019-12-07 14:52:27 +01:00
Andreas Kling
d08061103d LibPthread: Implement pthread_mutex_destroy() 2019-12-07 14:52:27 +01:00
Andreas Kling
cc1ef6dadb LibPthread: Implement condition variables
This feels like a pretty naive implementation, but I think it can work.
Basically each waiter creates an object on its stack that is then
added to a linked list inside by the pthread_cond_t.

Signalling is then done by walking the list and unsetting the "waiting"
flag on as many of the waiters as you like.
2019-12-07 14:52:27 +01:00
Andreas Kling
db2bfe14e9 LibIPC: Install libipc.a into /usr/lib 2019-12-07 14:52:27 +01:00