mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
LibCore: Add support for compiling for Android with API Version >= 30
Most changes are around user and group management, which are exposed in the Android NDK differently than other Unices. We require version 30 for memfd_create, version 28 for posix_spawn, and so on. It's possible a shim for memfd_create could be used, but since Google is mandating new apps use API level 30 as of Nov 2022, this seems suitable.
This commit is contained in:
parent
3b15addbc8
commit
d84fc60f96
5 changed files with 16 additions and 10 deletions
|
@ -1,5 +1,4 @@
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
Account.cpp
|
|
||||||
AnonymousBuffer.cpp
|
AnonymousBuffer.cpp
|
||||||
ArgsParser.cpp
|
ArgsParser.cpp
|
||||||
ConfigFile.cpp
|
ConfigFile.cpp
|
||||||
|
@ -38,6 +37,9 @@ set(SOURCES
|
||||||
UDPServer.cpp
|
UDPServer.cpp
|
||||||
Version.cpp
|
Version.cpp
|
||||||
)
|
)
|
||||||
|
if (NOT ANDROID)
|
||||||
|
list(APPEND SOURCES Account.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
serenity_lib(LibCore core)
|
serenity_lib(LibCore core)
|
||||||
target_link_libraries(LibCore LibC LibCrypt)
|
target_link_libraries(LibCore LibC LibCrypt)
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
#ifndef AK_OS_BSD_GENERIC
|
#if !defined(AK_OS_BSD_GENERIC) && !defined(AK_OS_ANDROID)
|
||||||
ErrorOr<void> Group::add_group(Group& group)
|
ErrorOr<void> Group::add_group(Group& group)
|
||||||
{
|
{
|
||||||
if (group.name().is_empty())
|
if (group.name().is_empty())
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Core {
|
||||||
|
|
||||||
class Group {
|
class Group {
|
||||||
public:
|
public:
|
||||||
#ifndef AK_OS_BSD_GENERIC
|
#if !defined(AK_OS_BSD_GENERIC) && !defined(AK_OS_ANDROID)
|
||||||
static ErrorOr<void> add_group(Group& group);
|
static ErrorOr<void> add_group(Group& group);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibSystem/syscall.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -25,6 +24,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef __serenity__
|
#ifdef __serenity__
|
||||||
|
# include <LibSystem/syscall.h>
|
||||||
# include <serenity.h>
|
# include <serenity.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ ErrorOr<void> profiling_free_buffer(pid_t pid)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef AK_OS_BSD_GENERIC
|
#if !defined(AK_OS_BSD_GENERIC) && !defined(AK_OS_ANDROID)
|
||||||
ErrorOr<Optional<struct spwd>> getspent()
|
ErrorOr<Optional<struct spwd>> getspent()
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
@ -917,17 +917,19 @@ ErrorOr<struct utsname> uname()
|
||||||
return uts;
|
return uts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef AK_OS_ANDROID
|
||||||
ErrorOr<void> adjtime(const struct timeval* delta, struct timeval* old_delta)
|
ErrorOr<void> adjtime(const struct timeval* delta, struct timeval* old_delta)
|
||||||
{
|
{
|
||||||
#ifdef __serenity__
|
# ifdef __serenity__
|
||||||
int rc = syscall(SC_adjtime, delta, old_delta);
|
int rc = syscall(SC_adjtime, delta, old_delta);
|
||||||
HANDLE_SYSCALL_RETURN_VALUE("adjtime", rc, {});
|
HANDLE_SYSCALL_RETURN_VALUE("adjtime", rc, {});
|
||||||
#else
|
# else
|
||||||
if (::adjtime(delta, old_delta) < 0)
|
if (::adjtime(delta, old_delta) < 0)
|
||||||
return Error::from_syscall("adjtime"sv, -errno);
|
return Error::from_syscall("adjtime"sv, -errno);
|
||||||
return {};
|
return {};
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath search_in_path, Optional<Span<StringView>> environment)
|
ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath search_in_path, Optional<Span<StringView>> environment)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
|
|
||||||
#ifndef AK_OS_BSD_GENERIC
|
#if !defined(AK_OS_BSD_GENERIC) && !defined(AK_OS_ANDROID)
|
||||||
# include <shadow.h>
|
# include <shadow.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ ALWAYS_INLINE ErrorOr<void> unveil(std::nullptr_t, std::nullptr_t)
|
||||||
return unveil(StringView {}, StringView {});
|
return unveil(StringView {}, StringView {});
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef AK_OS_BSD_GENERIC
|
#if !defined(AK_OS_BSD_GENERIC) && !defined(AK_OS_ANDROID)
|
||||||
ErrorOr<Optional<struct spwd>> getspent();
|
ErrorOr<Optional<struct spwd>> getspent();
|
||||||
ErrorOr<Optional<struct spwd>> getspnam(StringView name);
|
ErrorOr<Optional<struct spwd>> getspnam(StringView name);
|
||||||
#endif
|
#endif
|
||||||
|
@ -157,7 +157,9 @@ ErrorOr<void> unlink(StringView path);
|
||||||
ErrorOr<void> utime(StringView path, Optional<struct utimbuf>);
|
ErrorOr<void> utime(StringView path, Optional<struct utimbuf>);
|
||||||
ErrorOr<struct utsname> uname();
|
ErrorOr<struct utsname> uname();
|
||||||
ErrorOr<Array<int, 2>> pipe2(int flags);
|
ErrorOr<Array<int, 2>> pipe2(int flags);
|
||||||
|
#ifndef AK_OS_ANDROID
|
||||||
ErrorOr<void> adjtime(const struct timeval* delta, struct timeval* old_delta);
|
ErrorOr<void> adjtime(const struct timeval* delta, struct timeval* old_delta);
|
||||||
|
#endif
|
||||||
enum class SearchInPath {
|
enum class SearchInPath {
|
||||||
No,
|
No,
|
||||||
Yes,
|
Yes,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue