Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/native/clr/host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ set(XAMARIN_MONODROID_SOURCES
coreclr-bootstrap.cc
host-jni.cc
host-shared.cc
host-util.cc
gc-bridge.cc
os-bridge.cc
runtime-environment.cc
Expand Down
19 changes: 0 additions & 19 deletions src/native/clr/host/host-util.cc

This file was deleted.

1 change: 0 additions & 1 deletion src/native/clr/host/host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <host/host-common.hh>
#include <host/host-environment-clr.hh>
#include <host/host-jni.hh>
#include <host/host-util.hh>
#include <host/os-bridge.hh>
#include <host/runtime-util.hh>
#include <runtime-base/android-system.hh>
Expand Down
11 changes: 0 additions & 11 deletions src/native/clr/include/host/host-util.hh

This file was deleted.

84 changes: 0 additions & 84 deletions src/native/clr/include/runtime-base/util.hh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once

#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>

#include <cerrno>
#include <cstdint>
Expand All @@ -20,21 +18,8 @@
#include <shared/log_types.hh>

namespace xamarin::android {
namespace detail {
struct mmap_info
{
void *area;
size_t size;
};
}

class Util
{
static constexpr inline char hex_map [16] {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
};

public:
static constexpr size_t LocalPathBufferSize = Constants::SENSIBLE_PATH_MAX;

Expand All @@ -61,22 +46,6 @@ namespace xamarin::android {
}

static void create_public_directory (const char *dir);
static auto monodroid_fopen (const char *filename, const char *mode) noexcept -> FILE*;
static void set_world_accessable (const char *path);
static auto set_world_accessible (int fd) noexcept -> bool;

// Puts higher half of the `value` byte as a hexadecimal character in `high_half` and
// the lower half in `low_half`
static void to_hex (uint8_t value, char &high_half, char &low_half) noexcept
{
high_half = hex_map[(value & 0xf0) >> 4];
low_half = hex_map[value & 0x0f];
}

static auto should_log (LogCategories category) noexcept -> bool
{
return (log_categories & category) != 0;
}

private:
static auto fs_entry_is_mode (struct stat const& s, mode_t mode) noexcept -> bool
Expand Down Expand Up @@ -215,56 +184,6 @@ namespace xamarin::android {
set_environment_variable_for_directory (name, value, true, Constants::DEFAULT_DIRECTORY_MODE);
}

static int monodroid_getpagesize () noexcept
{
return page_size;
}

static detail::mmap_info mmap_file (int fd, uint32_t offset, size_t size, std::string_view const& filename) noexcept
{
detail::mmap_info file_info;
detail::mmap_info mmap_info;

size_t pageSize = static_cast<size_t>(Util::monodroid_getpagesize ());
size_t offsetFromPage = offset % pageSize;
size_t offsetPage = offset - offsetFromPage;
size_t offsetSize = size + offsetFromPage;

mmap_info.area = mmap (nullptr, offsetSize, PROT_READ, MAP_PRIVATE, fd, static_cast<off_t>(offsetPage));

if (mmap_info.area == MAP_FAILED) {
Helpers::abort_applicationf (
LOG_ASSEMBLY,
std::source_location::current (),
"Could not mmap APK fd %d: %s; File=%.*s",
fd,
strerror (errno),
static_cast<int>(filename.length ()),
filename.data ()
);
}

mmap_info.size = offsetSize;
file_info.area = pointer_add (mmap_info.area, offsetFromPage);
file_info.size = size;

log_infof (
LOG_ASSEMBLY,
" mmap_start: %-8p; mmap_end: %-8p\t mmap_len: %-12zu file_start: %-8p file_end: %-8p\t file_len: %-12zu\t apk descriptor: %d file: %.*s",
mmap_info.area,
pointer_add (mmap_info.area, mmap_info.size),
mmap_info.size,
file_info.area,
pointer_add (file_info.area, file_info.size),
file_info.size,
fd,
static_cast<int>(filename.length ()),
filename.data ()
);

return file_info;
}

static auto is_path_rooted (const char *path) noexcept -> bool
{
if (path == nullptr) {
Expand Down Expand Up @@ -434,8 +353,5 @@ namespace xamarin::android {
abort_unless (result >= 0, "Failed to format DSO name using the required capacity");
return heap_buffer;
}

private:
static inline int page_size = getpagesize ();
};
}
42 changes: 0 additions & 42 deletions src/native/clr/runtime-base/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,45 +76,3 @@ Util::create_public_directory (const char *dir)
}
umask (m);
}

auto
Util::monodroid_fopen (const char *filename, const char *mode) noexcept -> FILE*
{
/* On Unix, both path and system calls are all assumed
* to be UTF-8 compliant.
*/
FILE *ret = fopen (filename, mode);
if (ret == nullptr) {
log_errorf (LOG_DEFAULT, "fopen failed for file %s: %s", filename, strerror (errno));
return nullptr;
}

return ret;
}

void Util::set_world_accessable (const char *path)
{
int r;
do {
r = chmod (path, 0664);
} while (r == -1 && errno == EINTR);

if (r == -1) {
log_errorf (LOG_DEFAULT, "chmod(\"%s\", 0664) failed: %s", path, strerror (errno));
}
}

auto Util::set_world_accessible (int fd) noexcept -> bool
{
int r;
do {
r = fchmod (fd, 0664);
} while (r == -1 && errno == EINTR);

if (r == -1) {
log_errorf (LOG_DEFAULT, "fchmod() failed: %s", strerror (errno));
return false;
}

return true;
}
19 changes: 0 additions & 19 deletions src/native/common/include/runtime-base/dso-loader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <dlfcn.h>
#include <unistd.h>

#include <android/dlext.h>
#include <android/looper.h>

#include <string_view>
Expand Down Expand Up @@ -52,24 +51,6 @@ namespace xamarin::android {
return log_and_return (dlopen (path.data (), flags), path);
}

// Overload used to load libraries from the APK.
[[gnu::always_inline, gnu::flatten]]
static auto load (int fd, off64_t offset, std::string_view const& name, int flags, bool is_jni) -> void*
{
if (is_jni) {
return load_jni (name, true /* name_is_path */);
}

log_infof (LOG_ASSEMBLY, "[apk] Trying to load shared library '%.*s', offset in the apk == %lld", static_cast<int>(name.length ()), name.data (), static_cast<long long>(offset));

android_dlextinfo dli;
dli.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET;
dli.library_fd = fd;
dli.library_fd_offset = offset;

return log_and_return (android_dlopen_ext (name.data (), flags, &dli), name);
}

private:
[[gnu::always_inline]]
static auto log_and_return (void *handle, std::string_view const& full_name) -> void*
Expand Down
5 changes: 0 additions & 5 deletions src/native/common/include/runtime-base/jni-wrappers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ namespace xamarin::android

jstring_wrapper& operator=(const jstring_wrapper&) = delete;

bool hasValue () noexcept
{
return jstr != nullptr;
}

private:
[[gnu::always_inline]]
void ensure_cstr () noexcept
Expand Down
42 changes: 0 additions & 42 deletions src/native/common/include/runtime-base/search.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,11 @@
#pragma once

#include <cstddef>
#include <sys/types.h>

namespace xamarin::android {
class Search final
{
public:
template<class T, typename TKey, typename TState, bool (*less_than) (T const&, TKey, TState const&)>
[[gnu::always_inline, gnu::flatten]]
static size_t lower_bound (const TState& state, TKey key, const T *arr, size_t n) noexcept
{
static_assert (less_than != nullptr, "less_than is a required template parameter");

size_t left = 0;
size_t right = n;

while (left < right) {
size_t middle = (left + right) >> 1u;
if (less_than (arr[middle], key, state)) {
left = middle + 1;
} else {
right = middle;
}
}

return left;
}

template<class T, typename TKey, bool (*less_than) (T const&, TKey)>
[[gnu::always_inline, gnu::flatten]]
static size_t lower_bound (TKey key, const T *arr, size_t n) noexcept
Expand All @@ -49,25 +27,5 @@ namespace xamarin::android {

return left;
}

template<class T, typename TKey, typename TState, bool (*equal) (T const&, TKey, TState const&), bool (*less_than) (T const&, TKey, TState const&)>
[[gnu::always_inline, gnu::flatten]]
static ssize_t binary_search (const TState& state, TKey key, const T *arr, size_t n) noexcept
{
static_assert (equal != nullptr, "equal is a required template parameter");

size_t idx = lower_bound<T, TKey, TState, less_than> (state, key, arr, n);
return idx < n && equal (arr[idx], key, state) ? static_cast<ssize_t>(idx) : -1z;
}

template<class T, typename TKey, bool (*equal) (T const&, TKey), bool (*less_than) (T const&, TKey)>
[[gnu::always_inline, gnu::flatten]]
static ssize_t binary_search (TKey key, const T *arr, size_t n) noexcept
{
static_assert (equal != nullptr, "equal is a required template parameter");

size_t idx = lower_bound<T, TKey, less_than> (key, arr, n);
return idx < n && equal (arr[idx], key) ? static_cast<ssize_t>(idx) : -1z;
}
};
}
Loading
Loading