1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 00:57:44 +00:00

LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore

With this change, System::foo() becomes Core::System::foo().

Since LibCore builds on other systems than SerenityOS, we now have to
make sure that wrappers work with just a standard C library underneath.
This commit is contained in:
Andreas Kling 2021-11-23 10:59:50 +01:00
parent acc2eccede
commit 21a5fb0fa2
32 changed files with 165 additions and 173 deletions

View file

@ -8,6 +8,7 @@
#include "Game.h"
#include "GameSizeDialog.h"
#include <LibConfig/Client.h>
#include <LibCore/System.h>
#include <LibGUI/Action.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
@ -20,13 +21,12 @@
#include <LibGUI/Window.h>
#include <LibGfx/Painter.h>
#include <LibMain/Main.h>
#include <LibSystem/Wrappers.h>
#include <stdio.h>
#include <time.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(System::pledge("stdio rpath recvfd sendfd unix", nullptr));
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr));
srand(time(nullptr));
@ -37,10 +37,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Config::pledge_domains("2048");
TRY(System::pledge("stdio rpath recvfd sendfd", nullptr));
TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr));
TRY(System::unveil("/res", "r"));
TRY(System::unveil(nullptr, nullptr));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
size_t board_size = Config::read_i32("2048", "", "board_size", 4);
u32 target_tile = Config::read_i32("2048", "", "target_tile", 2048);

View file

@ -5,6 +5,7 @@
*/
#include "Game.h"
#include <LibCore/System.h>
#include <LibGUI/Application.h>
#include <LibGUI/Icon.h>
#include <LibGUI/Menu.h>
@ -12,18 +13,17 @@
#include <LibGUI/Window.h>
#include <LibGfx/Bitmap.h>
#include <LibMain/Main.h>
#include <LibSystem/Wrappers.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(System::pledge("stdio recvfd sendfd rpath unix", nullptr));
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix", nullptr));
auto app = GUI::Application::construct(arguments);
TRY(System::pledge("stdio recvfd sendfd rpath", nullptr));
TRY(Core::System::pledge("stdio recvfd sendfd rpath", nullptr));
TRY(System::unveil("/res", "r"));
TRY(System::unveil(nullptr, nullptr));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto window = GUI::Window::construct();
window->resize(Breakout::Game::game_width, Breakout::Game::game_height);

View file

@ -7,6 +7,7 @@
#include "ChessWidget.h"
#include <LibConfig/Client.h>
#include <LibCore/DirIterator.h>
#include <LibCore/System.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Application.h>
#include <LibGUI/Clipboard.h>
@ -17,28 +18,27 @@
#include <LibGUI/MessageBox.h>
#include <LibGUI/Window.h>
#include <LibMain/Main.h>
#include <LibSystem/Wrappers.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(System::pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec unix", nullptr));
TRY(Core::System::pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec unix", nullptr));
auto app = GUI::Application::construct(arguments);
Config::pledge_domains("Chess");
TRY(System::pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec", nullptr));
TRY(Core::System::pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec", nullptr));
auto app_icon = GUI::Icon::default_icon("app-chess");
auto window = GUI::Window::construct();
auto& widget = window->set_main_widget<ChessWidget>();
TRY(System::unveil("/res", "r"));
TRY(System::unveil("/bin/ChessEngine", "x"));
TRY(System::unveil("/etc/passwd", "r"));
TRY(System::unveil(Core::StandardPaths::home_directory().characters(), "wcbr"));
TRY(System::unveil(nullptr, nullptr));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/bin/ChessEngine", "x"));
TRY(Core::System::unveil("/etc/passwd", "r"));
TRY(Core::System::unveil(Core::StandardPaths::home_directory().characters(), "wcbr"));
TRY(Core::System::unveil(nullptr, nullptr));
auto size = Config::read_i32("Chess", "Display", "size", 512);
window->set_title("Chess");

View file

@ -6,6 +6,7 @@
#include "Game.h"
#include <LibConfig/Client.h>
#include <LibCore/System.h>
#include <LibGUI/Application.h>
#include <LibGUI/Icon.h>
#include <LibGUI/Menu.h>
@ -13,20 +14,19 @@
#include <LibGUI/MessageBox.h>
#include <LibGUI/Window.h>
#include <LibMain/Main.h>
#include <LibSystem/Wrappers.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(System::pledge("stdio rpath recvfd sendfd unix", nullptr));
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr));
auto app = GUI::Application::construct(arguments.argc, arguments.argv);
Config::pledge_domains("FlappyBug");
TRY(System::pledge("stdio rpath recvfd sendfd", nullptr));
TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr));
TRY(System::unveil("/res", "r"));
TRY(System::unveil(nullptr, nullptr));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
u32 high_score = Config::read_i32("FlappyBug", "Game", "HighScore", 0);

View file

@ -7,6 +7,7 @@
#include "CustomGameDialog.h"
#include "Field.h"
#include <LibConfig/Client.h>
#include <LibCore/System.h>
#include <LibGUI/Action.h>
#include <LibGUI/ActionGroup.h>
#include <LibGUI/Application.h>
@ -19,21 +20,20 @@
#include <LibGUI/SeparatorWidget.h>
#include <LibGUI/Window.h>
#include <LibMain/Main.h>
#include <LibSystem/Wrappers.h>
#include <stdio.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(System::pledge("stdio rpath recvfd sendfd unix", nullptr));
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr));
auto app = GUI::Application::construct(arguments);
Config::pledge_domains("Minesweeper");
TRY(System::pledge("stdio rpath recvfd sendfd", nullptr));
TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr));
TRY(System::unveil("/res", "r"));
TRY(System::unveil(nullptr, nullptr));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-minesweeper");

View file

@ -8,6 +8,7 @@
#include "Game.h"
#include <Games/Spider/SpiderGML.h>
#include <LibConfig/Client.h>
#include <LibCore/System.h>
#include <LibCore/Timer.h>
#include <LibGUI/Action.h>
#include <LibGUI/ActionGroup.h>
@ -19,7 +20,6 @@
#include <LibGUI/Statusbar.h>
#include <LibGUI/Window.h>
#include <LibMain/Main.h>
#include <LibSystem/Wrappers.h>
#include <stdio.h>
enum class StatisticDisplay : u8 {
@ -39,17 +39,17 @@ static String format_seconds(uint64_t seconds_elapsed)
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(System::pledge("stdio recvfd sendfd rpath unix", nullptr));
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix", nullptr));
auto app = GUI::Application::construct(arguments.argc, arguments.argv);
auto app_icon = GUI::Icon::default_icon("app-spider");
Config::pledge_domains("Spider");
TRY(System::pledge("stdio recvfd sendfd rpath", nullptr));
TRY(Core::System::pledge("stdio recvfd sendfd rpath", nullptr));
TRY(System::unveil("/res", "r"));
TRY(System::unveil(nullptr, nullptr));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto window = GUI::Window::construct();
window->set_title("Spider");