1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

Userland: Remove unecessary uses of __serenity__ macro

This commit is contained in:
Andrew Kaster 2022-10-09 15:38:06 -06:00 committed by Linus Groh
parent 828441852f
commit 539fb08551
10 changed files with 4 additions and 51 deletions

View file

@ -665,7 +665,7 @@ if (BUILD_LAGOM)
add_executable(ntpquery_lagom ../../Userland/Utilities/ntpquery.cpp) add_executable(ntpquery_lagom ../../Userland/Utilities/ntpquery.cpp)
set_target_properties(ntpquery_lagom PROPERTIES OUTPUT_NAME ntpquery) set_target_properties(ntpquery_lagom PROPERTIES OUTPUT_NAME ntpquery)
target_link_libraries(ntpquery_lagom LibCore) target_link_libraries(ntpquery_lagom LibCore LibMain)
add_executable(shell_lagom ../../Userland/Shell/main.cpp) add_executable(shell_lagom ../../Userland/Shell/main.cpp)
set_target_properties(shell_lagom PROPERTIES OUTPUT_NAME shell) set_target_properties(shell_lagom PROPERTIES OUTPUT_NAME shell)

View file

@ -6,11 +6,7 @@
#pragma once #pragma once
#ifndef __serenity__ #include <elf.h>
# include <LibC/elf.h>
#else
# include <elf.h>
#endif
#include <limits.h> #include <limits.h>
#include <sys/cdefs.h> #include <sys/cdefs.h>

View file

@ -19,10 +19,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#ifdef __serenity__
# include <serenity.h>
#endif
namespace Gfx { namespace Gfx {
struct DDSLoadingContext { struct DDSLoadingContext {

View file

@ -14,10 +14,6 @@
#include <LibGfx/PNGShared.h> #include <LibGfx/PNGShared.h>
#include <string.h> #include <string.h>
#ifdef __serenity__
# include <LibCompress/Deflate.h>
#endif
namespace Gfx { namespace Gfx {
struct PNG_IHDR { struct PNG_IHDR {

View file

@ -877,13 +877,11 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command)
void Shell::execute_process(Vector<char const*>&& argv) void Shell::execute_process(Vector<char const*>&& argv)
{ {
#ifdef __serenity__
for (auto& promise : m_active_promises) { for (auto& promise : m_active_promises) {
pledge("stdio rpath exec", promise.data.exec_promises.characters()); MUST(Core::System::pledge("stdio rpath exec"sv, promise.data.exec_promises));
for (auto& item : promise.data.unveils) for (auto& item : promise.data.unveils)
unveil(item.path.characters(), item.access.characters()); MUST(Core::System::unveil(item.path, item.access));
} }
#endif
int rc = execvp(argv[0], const_cast<char* const*>(argv.data())); int rc = execvp(argv[0], const_cast<char* const*>(argv.data()));
if (rc < 0) { if (rc < 0) {

View file

@ -41,9 +41,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
s_shell->editor()->save_history(s_shell->get_history_path()); s_shell->editor()->save_history(s_shell->get_history_path());
}); });
#ifdef __serenity__
TRY(Core::System::pledge("stdio rpath wpath cpath proc exec tty sigaction unix fattr")); TRY(Core::System::pledge("stdio rpath wpath cpath proc exec tty sigaction unix fattr"));
#endif
RefPtr<::Shell::Shell> shell; RefPtr<::Shell::Shell> shell;
bool attempt_interactive = false; bool attempt_interactive = false;
@ -57,13 +55,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
s_shell->setup_signals(); s_shell->setup_signals();
#ifndef __serenity__
sigset_t blocked;
sigemptyset(&blocked);
sigaddset(&blocked, SIGTTOU);
sigaddset(&blocked, SIGTTIN);
pthread_sigmask(SIG_BLOCK, &blocked, nullptr);
#endif
shell->termios = editor->termios(); shell->termios = editor->termios();
shell->default_termios = editor->default_termios(); shell->default_termios = editor->default_termios();

View file

@ -13,9 +13,7 @@
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> serenity_main(Main::Arguments arguments)
{ {
#ifdef __serenity__
TRY(Core::System::pledge("stdio settime")); TRY(Core::System::pledge("stdio settime"));
#endif
Core::ArgsParser args_parser; Core::ArgsParser args_parser;
Optional<double> delta; Optional<double> delta;
@ -34,9 +32,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::adjtime(&delta_timeval, nullptr)); TRY(Core::System::adjtime(&delta_timeval, nullptr));
} }
#ifdef __serenity__
TRY(Core::System::pledge("stdio")); TRY(Core::System::pledge("stdio"));
#endif
timeval remaining_delta_timeval; timeval remaining_delta_timeval;
TRY(Core::System::adjtime(nullptr, &remaining_delta_timeval)); TRY(Core::System::adjtime(nullptr, &remaining_delta_timeval));

View file

@ -48,9 +48,7 @@ ErrorOr<bool> format_file(StringView path, bool inplace)
ErrorOr<int> serenity_main(Main::Arguments args) ErrorOr<int> serenity_main(Main::Arguments args)
{ {
#ifdef __serenity__
TRY(Core::System::pledge("stdio rpath wpath cpath")); TRY(Core::System::pledge("stdio rpath wpath cpath"));
#endif
bool inplace = false; bool inplace = false;
Vector<String> files; Vector<String> files;
@ -61,10 +59,8 @@ ErrorOr<int> serenity_main(Main::Arguments args)
args_parser.add_positional_argument(files, "File(s) to process", "path", Core::ArgsParser::Required::No); args_parser.add_positional_argument(files, "File(s) to process", "path", Core::ArgsParser::Required::No);
args_parser.parse(args); args_parser.parse(args);
#ifdef __serenity__
if (!inplace) if (!inplace)
TRY(Core::System::pledge("stdio rpath")); TRY(Core::System::pledge("stdio rpath"));
#endif
if (files.is_empty()) if (files.is_empty())
files.append("-"); files.append("-");

View file

@ -1505,9 +1505,7 @@ private:
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> serenity_main(Main::Arguments arguments)
{ {
#ifdef __serenity__
TRY(Core::System::pledge("stdio rpath wpath cpath tty sigaction")); TRY(Core::System::pledge("stdio rpath wpath cpath tty sigaction"));
#endif
bool gc_on_every_allocation = false; bool gc_on_every_allocation = false;
bool disable_syntax_highlight = false; bool disable_syntax_highlight = false;

View file

@ -90,15 +90,9 @@ static String format_ntp_timestamp(NtpTimestamp ntp_timestamp)
buffer[written] = '\0'; buffer[written] = '\0';
return buffer; return buffer;
} }
#ifdef __serenity__
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> serenity_main(Main::Arguments arguments)
#else
int main(int argc, char** argv)
#endif
{ {
#ifdef __serenity__
TRY(Core::System::pledge("stdio inet unix settime")); TRY(Core::System::pledge("stdio inet unix settime"));
#endif
bool adjust_time = false; bool adjust_time = false;
bool set_time = false; bool set_time = false;
@ -119,22 +113,16 @@ int main(int argc, char** argv)
args_parser.add_option(set_time, "Immediately set system time (requires root)", "set", 's'); args_parser.add_option(set_time, "Immediately set system time (requires root)", "set", 's');
args_parser.add_option(verbose, "Verbose output", "verbose", 'v'); args_parser.add_option(verbose, "Verbose output", "verbose", 'v');
args_parser.add_positional_argument(host, "NTP server", "host", Core::ArgsParser::Required::No); args_parser.add_positional_argument(host, "NTP server", "host", Core::ArgsParser::Required::No);
#ifdef __serenity__
args_parser.parse(arguments); args_parser.parse(arguments);
#else
args_parser.parse(argc, argv);
#endif
if (adjust_time && set_time) { if (adjust_time && set_time) {
warnln("-a and -s are mutually exclusive"); warnln("-a and -s are mutually exclusive");
return 1; return 1;
} }
#ifdef __serenity__
if (!adjust_time && !set_time) { if (!adjust_time && !set_time) {
TRY(Core::System::pledge("stdio inet unix")); TRY(Core::System::pledge("stdio inet unix"));
} }
#endif
auto* hostent = gethostbyname(host); auto* hostent = gethostbyname(host);
if (!hostent) { if (!hostent) {
@ -142,10 +130,8 @@ int main(int argc, char** argv)
return 1; return 1;
} }
#ifdef __serenity__
TRY(Core::System::pledge((adjust_time || set_time) ? "stdio inet settime"sv : "stdio inet"sv)); TRY(Core::System::pledge((adjust_time || set_time) ? "stdio inet settime"sv : "stdio inet"sv));
TRY(Core::System::unveil(nullptr, nullptr)); TRY(Core::System::unveil(nullptr, nullptr));
#endif
int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (fd < 0) { if (fd < 0) {