Commit graph

16 commits

Author SHA1 Message Date
circl
c169e43e13 Userland: Remove some SerenityOS checks 2024-06-10 13:53:01 +02:00
Timothy Flynn
4c08a1e0c0 Meta: Remove serenity_lib_static() CMake helper function
Its one user (LibMain) can now just specify a STATIC library type in an
invocation of serenity_lib().
2024-03-26 12:25:21 -04:00
Tim Schumacher
7834e26ddb Everywhere: Explicitly link all binaries against the LibC target
Even though the toolchain implicitly links against -lc, it does not know
where it should get LibC from except for the sysroot. In the case of
Clang this causes it to pick up the LibC stub instead, which might be
slightly outdated and feature missing symbols.

This is currently not an issue that manifests because we pass through
the dependency on LibC and other libraries by accident, which causes
CMake to link against the LibC target (instead of just the library),
and thus points the linker at the build output directory.

Since we are looking to fix that in the upcoming commits, let's make
sure that everything will still be able to find the proper LibC first.
2022-11-01 14:49:09 +00:00
Andrew Kaster
828441852f Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY
Now that we have OS macros for essentially every supported OS, let's try
to use them everywhere.
2022-10-10 12:23:12 +02:00
sin-ack
c70f45ff44 Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
2022-07-12 23:11:35 +02:00
Lenny Maiorani
f7f0195fae LibMain: Statically link LibMain
LibMain is dynamically linked in every binary. This results in a
slightly slower load time. In the past people have pegged this at 0.7
ms on some hardware.

This change makes it statically linked and eliminates 0.6 ms of
run-time on my machine. This is tested by running a script which just
executed `/bin/true` in a loop 10,000 times. Before this patch it
reliably executed in ~90,000 ms. After this patch it is ~84,000
ms. This is a speed up of 6,000 ms over 10,000 executions, or 0.6 ms
per execution.
2022-03-24 03:04:57 +01:00
Sam Atkins
25c2a76d10 LibMain: Add the ability to configure the exit code on error
Some POSIX utilities are specified to return a specific value on error,
which is not 1. `Main::set_return_code_for_errors()` lets you set it to
that value.
2022-03-19 11:01:49 -07:00
Lenny Maiorani
4e6898c5cc LibMain: Update header includes 2022-02-26 17:49:58 +00:00
Timothy Flynn
6838333f76 LibMain: Invoke tzset in LibMain so all apps can have time zone info
Rather than finding apps that benefit from time zone awareness one-by-
one, and calling tzset in their serenity_main, let's do it in LibMain.
2022-01-28 15:13:35 +00:00
James Puleo
bf714efa41 LibMain: Make "Runtime error" warnln red
Stealing what Andreas did for the `dbgln` output, I think it also looks
nice inside of Terminal :^)
2021-12-23 12:41:13 -08:00
James Puleo
b19efc4db6 LibMain: Don't dbgln runtime errors if not on Serenity
When on Lagom, `warnln` and `dbgln` both output to `stderr`. This makes
runtime errors duplicated and more verbose than necessary.
2021-12-21 22:50:12 -08:00
Andreas Kling
db766d0972 LibMain: Print serenity_main() errors to the debug log
And let's make them red too, to help us notice them. :^)
2021-12-20 22:16:05 +01:00
Andreas Kling
452a5531be AK+LibMain: Improve formatter for AK::Error in userspace
Print the full associated string metadata by default (if available.)
2021-12-20 21:13:42 +01:00
Pedro Pereira
a436f0c668 LibMain: Rename .arguments to .strings :^)
Before this change, we would need to write arguments.arguments to access
the Span<>, which doesn't feel too pretty.
2021-11-22 22:13:22 +01:00
Andreas Kling
4e530135d5 AK+LibSystem+LibMain: Add Error::from_syscall() for syscall failures
This creates an error that contains the name of the syscall that failed.
This allows error handlers to print out the name of the call if they
want to. :^)
2021-11-22 19:28:31 +01:00
Andreas Kling
d3cf68a540 LibMain: Add a new library for more ergonomic userspace entry functions
By linking with LibMain, your program no longer needs to provide main().
Instead, execution begins in this function:

    ErrorOr<int> serenity_main(Main::Arguments);

This allows programs that link with LibMain to use TRY() already in
their entry function, without having to do manual ErrorOr unwrapping.

This is very experimental, but it seems like a nice idea so let's try it
out. :^)
2021-11-22 19:28:31 +01:00