-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include <jni.h> | ||
|
||
#include "../runtime-base/timing.hh" | ||
#include "../shared/log_types.hh" | ||
|
||
namespace xamarin::android { | ||
class Host | ||
{ | ||
public: | ||
static auto Java_JNI_OnLoad (JavaVM *vm, void *reserved) noexcept -> jint; | ||
static void Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass klass, jstring lang, jobjectArray runtimeApksJava, | ||
jstring runtimeNativeLibDir, jobjectArray appDirs, jint localDateTimeOffset, jobject loader, | ||
jobjectArray assembliesJava, jboolean isEmulator, jboolean haveSplitApks); | ||
|
||
static auto get_timing () -> Timing* | ||
{ | ||
return _timing.get (); | ||
} | ||
|
||
private: | ||
static inline std::unique_ptr<Timing> _timing{}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#pragma once | ||
|
||
#include <cstdio> | ||
|
||
#include <string_view> | ||
|
||
#include <shared/log_types.hh> | ||
#include "strings.hh" | ||
|
||
namespace xamarin::android { | ||
class Logger | ||
{ | ||
public: | ||
static void init_logging_categories () noexcept; | ||
static void init_reference_logging (std::string_view const& override_dir) noexcept; | ||
|
||
static auto log_timing_categories () noexcept -> LogTimingCategories | ||
{ | ||
return _log_timing_categories; | ||
} | ||
|
||
static void set_gc_spew_enabled (bool yesno) noexcept | ||
{ | ||
_gc_spew_enabled = yesno; | ||
} | ||
|
||
static auto gc_spew_enabled () noexcept -> bool | ||
{ | ||
return _gc_spew_enabled; | ||
} | ||
|
||
static auto gref_log () -> FILE* | ||
{ | ||
return _gref_log; | ||
} | ||
|
||
static auto lref_log () -> FILE* | ||
{ | ||
return _lref_log; | ||
} | ||
|
||
static auto gref_to_logcat () -> bool | ||
{ | ||
return _gref_to_logcat; | ||
} | ||
|
||
static auto lref_to_logcat () -> bool | ||
{ | ||
return _lref_to_logcat; | ||
} | ||
|
||
private: | ||
static bool set_category (std::string_view const& name, string_segment& arg, unsigned int entry, bool arg_starts_with_name = false) noexcept; | ||
|
||
private: | ||
static inline LogTimingCategories _log_timing_categories; | ||
static inline bool _gc_spew_enabled = false; | ||
static inline FILE *_gref_log = nullptr; | ||
static inline FILE *_lref_log = nullptr; | ||
static inline bool _gref_to_logcat = false; | ||
static inline bool _lref_to_logcat = false; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
namespace xamarin::android | ||
{ | ||
class MonodroidState | ||
{ | ||
public: | ||
static auto is_startup_in_progress () noexcept -> bool | ||
{ | ||
return startup_in_progress; | ||
} | ||
|
||
static void mark_startup_done () noexcept | ||
{ | ||
startup_in_progress = false; | ||
} | ||
|
||
private: | ||
inline static bool startup_in_progress = true; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include <mutex> | ||
|
||
#include "monodroid-state.hh" | ||
|
||
namespace xamarin::android | ||
{ | ||
class StartupAwareLock final | ||
{ | ||
public: | ||
explicit StartupAwareLock (std::mutex &m) | ||
: lock (m) | ||
{ | ||
if (MonodroidState::is_startup_in_progress ()) { | ||
// During startup we run without threads, do nothing | ||
return; | ||
} | ||
|
||
lock.lock (); | ||
} | ||
|
||
~StartupAwareLock () | ||
{ | ||
if (MonodroidState::is_startup_in_progress ()) { | ||
return; | ||
} | ||
|
||
lock.unlock (); | ||
} | ||
|
||
StartupAwareLock (StartupAwareLock const&) = delete; | ||
StartupAwareLock (StartupAwareLock const&&) = delete; | ||
|
||
StartupAwareLock& operator= (StartupAwareLock const&) = delete; | ||
|
||
private: | ||
std::mutex& lock; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.