Commit Graph

931 Commits

Author SHA1 Message Date
nipos
0dfd6994e3 LibCore: Use BSD implementation of anon_create() on Haiku 2023-09-17 13:38:12 -06:00
nipos
0fa00a1b1e LibCore: Don't implement adjtime on Haiku 2023-09-17 13:38:12 -06:00
nipos
1e25ab956c LibCore: Use void* instead of FlatPtr for ioctl() arg on Haiku 2023-09-17 13:38:12 -06:00
nipos
a1572555c2 LibCore: Implement current_executable_path() on Haiku 2023-09-17 13:38:12 -06:00
nipos
ae34c35d64 LibCore: Add standard paths for Haiku 2023-09-17 13:38:12 -06:00
nipos
e028d43c67 LibCore: Enable receive_fd and send_fd on Haiku 2023-09-17 13:38:12 -06:00
nipos
cecedc57eb LibCore: Use BSD implementation of Process::get_name() on Haiku 2023-09-17 13:38:12 -06:00
nipos
0816bbe727 LibCore: Use accept instead of accept4 on Haiku 2023-09-17 13:38:12 -06:00
nipos
ee5b851f70 LibCore: Make Group::add_group() unavailable on Haiku 2023-09-17 13:38:12 -06:00
nipos
cf6781cdee LibCore: Use DirectoryEntry::from_stat on Haiku 2023-09-17 13:38:12 -06:00
nipos
1d475e9312 LibCore: Don't include crypt.h and shadow.h in Account.cpp on Haiku 2023-09-17 13:38:12 -06:00
Andrew Kaster
0c5a546dca AK: Send dbgln/outln/warnln to the NDK logger on Android
The embedding application is responsible for setting the android log
tag. If it doesn't a default of "Serenity" will be used for any Lagom
code.
2023-09-15 14:18:52 -06:00
nipos
b258450fa6 LibCore: Implement waiting for the debugger on FreeBSD 2023-09-07 14:30:11 -06:00
Liav A
41db527369 LibCore: Add helpers to create block and character device files 2023-09-07 11:50:50 -06:00
Sergey Bugaev
29da1d7c23 LibCore: Implement readlink() and current_executable_path() on GNU/Hurd
Without using PATH_MAX :^)

To read a symlink, we can just open its file with O_NOLINK and read its
contents. To get the executable path, we could read the /proc/self/exe
link like the Linux version does; but that relies on procfs being
mounted. Instead, we could do what procfs itself does to get the path:
ask the proc server about it.
2023-09-06 11:41:16 -06:00
Sergey Bugaev
cee38cf1e5 LibCore: Use SHM_ANON for anon_create() when available
On FreeBSD and GNU/Hurd, SHM_ANON is a nice way to create anonymous
files using the usual shm_open() API. This is a lot like the fallback
shm_open() branch that follows, except we don't have to fool around
with choosing a unique name (with retrying) and unlinking the file
afterwards; it just does the right thing. Isn't this nice?
2023-09-06 11:41:16 -06:00
Sergey Bugaev
ec68979483 LibCore: Implement Process::is_being_debugged() on GNU/Hurd
This checks for the PI_TRACED bit being set in the info returned by
proc_getprocinfo().
2023-09-06 11:41:16 -06:00
Sergey Bugaev
f31df017f9 LibCore: Port Socket to GNU Hurd
The Hurd supports sending file descriptors over local sockets using
the SCM_RIGHTS / cmsg mechanism just like the other systems. It doesn't
have anything like ucred/PEERCRED, though.
2023-09-06 11:41:16 -06:00
Sergey Bugaev
4825919bcf AK, LibCore: Enable misc things on glibc
program_invocation_name, pthread_getattr_np(), EXECINFO_BACKTRACE are
all glibc specifics (that other libcs may also have).
2023-09-06 07:14:35 -06:00
Alexander Bosu-Kellett
13d1c37ea0 LibCore: Recognize .xht as an HTML document
This allows opening the WPT .xht files directly with ladybird.
2023-09-03 12:33:34 +02:00
Andrew Kaster
6e8f1549a3 AK+LibCore: Don't use unsupported features on Android 2023-09-03 11:38:51 +02:00
Andrew Kaster
1cd3826ad6 Userland+Tests: Don't use MAP_FILE when mmap-ing
MAP_FILE is not in POSIX, and is simply in most LibCs as a "default"
mode. Our own LibC defines it as 0, meaning "no flags". It is also not
defined in some OS's, such as Haiku. Let's be more portable and not use
the unnecessary flag.
2023-09-01 19:50:35 +02:00
Andrew Kaster
e6b8c2bd59 LibCore: Don't print class_name() from EventReceiver::stop_timer()
If stop_timer() is called from ~EventReceiver(), then the virtual
functions will end up calling the overload from the base class. As
EventReceiver::class_name() is pure virtual, this calls
__cxa_pure_virtual and crashes. We should not be calling virtual
functions from the destructor, and especially not pure virtual ones.

This "fixes" a crash in Piano, but the root cause of the problem is
still unfixed.
2023-09-01 11:19:18 +02:00
Karol Kosek
51fefb57fc LibCore: Check if a promise is already resolved in Promise::map() 2023-08-31 11:10:09 +02:00
Andrew Kaster
b7f9634f6c LibCore: Add default version for Lagom applications
Instead of grabbing `uname -vr` on non-Serenity platforms, let's just
hardcode a version. This prevents Lagom builds of applications like
Shell or Ladybird from reporting their version as that of the host OS.
2023-08-27 19:01:32 -04:00
Liav A
1c0aa51684 Kernel+Userland: Remove the {get,set}_thread_name syscalls
These syscalls are not necessary on their own, and they give the false
impression that a caller could set or get the thread name of any process
in the system, which is not true.

Therefore, move the functionality of these syscalls to be options in the
prctl syscall, which makes it abundantly clear that these operations
could only occur from a running thread in a process that sees other
threads in that process only.
2023-08-25 11:51:52 +02:00
Niklas Poslovski
ebc5b33b77 LibCore: Don't include sys/sysctl.h on Solaris 2023-08-24 22:07:28 +01:00
nipos
abf7941bb9 LibCore: Change Errno to Error in FreeBSD and NetBSD-specific functions 2023-08-20 12:48:37 -06:00
Sam Atkins
dfb5ba0e2c LibCore: Prevent duplicate ArgsParser option names
Inspired by #20641, detect when adding an option that its long and short
names are both unique. If they are not, print a warning and crash.
2023-08-19 16:27:53 +02:00
Nicolas Ramz
fda5590313 LibGfx/ILBM: Add an IFF-ILBM decoder :)
IFF was a generic container fileformat that was popular on the Amiga
since it was the only file format supported by Deluxe Paint.

ILBM is an image format popular in the late eighties/nineties
that uses the IFF container.

This is a very first version of the decoder that only supports
(byterun) compressed files with bpp <= 8.

Only the minimal chunks are decoded: CMAP, BODY, BMHD.

I am planning to add support for the following variants:

- EHB (32 colours + lighter 32 colours)
- HAM6 / HAM8 (special mode that allowed to display the whole Amiga
4096 colours / 262 144 colours palette)
- TrueColor (24bit)

Things that could be fun to do:

- Still images could be animated using color cycle information
2023-08-15 18:36:11 +01:00
kleines Filmröllchen
001ea22917 AK+LibCore: Make output buffered stream seekable
Just like with input buffered streams, we don't currently have a use
case for output buffered streams which aren't seekable, since the main
application are files.
2023-08-12 12:25:26 -06:00
Lucas CHOLLET
3f35ffb648 Userland: Prefer _string over _short_string
As `_string` can't fail anymore (since 3434412), there are no real
benefits to use the short variant in most cases.
2023-08-08 07:37:21 +02:00
Sebastian Zaha
fc71403842 LibCore: Implement Process::is_being_debugged for macOS
The wait_for_debugger_and_break helper now works on macOS with this
change, tested on lldb 14.
2023-08-07 13:16:28 -06:00
Sebastian Zaha
35c45a94d3 LibCore: Implement a helper that waits for a debugger then breaks
This method can be used to force the current process to sleep, waiting
for a debugger to attach. On attach, the debugger breaks at the callsite
 directly.

This is tested on Linux and macOS, in Clion and also terminal gdb and
lldb.
2023-08-07 13:16:28 -06:00
Sebastian Zaha
216667368d LibCore+Ladybird: Extract helper into generic Process::is_being_debugged 2023-08-07 13:16:28 -06:00
Sebastian Zaha
002e206af0 LibCore: Implement Process::get_name for linux and macos 2023-08-07 13:16:28 -06:00
Andreas Kling
34344120f2 AK: Make "foo"_string infallible
Stop worrying about tiny OOMs.

Work towards #20405.
2023-08-07 16:03:27 +02:00
Zaggy1024
db2a8725c6 LibCore: Only use coarse time in the Unix event loop wait_for_events()
A typo in the changes to our userland timekeeping classes caused us to
make a syscall every time we want to check whether a timer is ready to
fire in `EventLoopManagerUnix::wait_for_events()`. Instead, only use
coarse time, and get it immediately before it is used in both cases.

This reduces CPU usage by an (eyeballed) 20-30% while playing back
video with VideoPlayer.
2023-08-07 13:38:20 +02:00
Andreas Kling
ddbe6bd7b4 Userland: Rename Core::Object to Core::EventReceiver
This is a more precise description of what this class actually does.
2023-08-06 20:39:51 +02:00
Andreas Kling
bdf696e488 LibCore: Remove unused Core::Object::dump_tree() 2023-08-06 18:09:25 +02:00
Andreas Kling
887dfd72b9 LibCore+LibGUI: Remove leftover gunk after Inspector removal
Just some functions in Core::Object and GUI::Widget that aren't called
from anywhere anymore.
2023-08-06 18:09:25 +02:00
Andreas Kling
26647f2b10 LibCore: Remove the Core::Objects::all_objects() list
Nobody actually used the list of all Core::Objects anyway.
2023-08-06 18:09:25 +02:00
Andreas Kling
405187993a LibGUI+LibCore: Move GML property system from LibCore to LibGUI
Since Core::Object properties are really only used by GML now that the
Inspector is long gone, there's no need for these to pollute
Core::Object.

This patch adds a new GUI::Object class to hold properties, and makes
it the new base class of GUI::Window, GUI::Widget and GUI::Layout.
The "instantiate an object by name" mechanism that GML uses is also
hoisted into GUI::Object as well.
2023-08-06 18:09:25 +02:00
Liav A
93ef955597 LibCore: Keep the raw inode number value in DirectoryEntry
This will be used later on by other userspace programs that need it.
2023-08-05 18:41:01 +02:00
Zaggy1024
fe672989a9 LibCore: Add a class for thread-safe promises
Since the existing Promise class is designed with deferred tasks on the
main thread only, we need a new class that will ensure we can handle
promises that are resolved/rejected off the main thread.

This new class ensures that the callbacks are only called on the same
thread that the promise is fulfilled from. If the callbacks are not set
before the thread tries to fulfill the promise, it will spin until they
are so that they will run on that thread.
2023-08-04 13:49:36 -06:00
Zaggy1024
8626404ddb LibCore: Store the event loop stack as a function-scope thread_local
By allocating the event loop stack onto the heap, we were leaking it
when exiting. This way, we should avoid ASAN being unhappy with us.
2023-08-04 13:49:36 -06:00
Niklas Poslovski
6ea4be36b5 LibCore: Fallback to fstat() on systems without d_type support 2023-08-03 12:25:07 +01:00
Andrew Kaster
bb831a27dd LibCore: Add Core::System::current_executable_path()
This is based on Jakt::File::current_executable_path() and all the other
sources I looked at to figure out the per-platform way to do this. My
goodness, every platform has its own bespoke way.
2023-08-03 09:55:20 +02:00
Shannon Booth
8751be09f9 AK: Serialize URL hosts with 'concept-host-serializer'
In order to follow spec text to achieve this, we need to change the
underlying representation of a host in AK::URL to deserialized format.
Before this, we were parsing the host and then immediately serializing
it again.

Making that change resulted in a whole bunch of fallout.

After this change, callers can access the serialized data through
this concept-host-serializer. The functional end result of this
change is that IPv6 hosts are now correctly serialized to be
surrounded with '[' and ']'.
2023-07-31 05:18:51 +02:00
Ali Mohammad Pur
9f4feb7315 LibCore: Move the Promise::await() result instead of returning a ref
Returning a reference resulted in Mail's use of Promise causing a crash.
Also, awaiting an already-awaited promise is an odd thing to do anyway,
so let's just make it release the resolved/rejected value instead of
returning a reference to it.

Co-Authored-By: Valtteri Koskivuori <vkoskiv@gmail.com>
2023-07-24 16:42:15 +03:30