Skip to content

Commit b4060af

Browse files
committed
Prepare for new p/invoke code, step #1
1 parent 290b84d commit b4060af

File tree

7 files changed

+33
-14
lines changed

7 files changed

+33
-14
lines changed

Diff for: src/native/monodroid/embedded-assemblies.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "xamarin-app.hh"
3434
#include "cpp-util.hh"
3535
#include "monodroid-glue-internal.hh"
36+
#include "monodroid-state.hh"
3637
#include "startup-aware-lock.hh"
3738
#include "timing-internal.hh"
3839
#include "search.hh"
@@ -179,7 +180,7 @@ EmbeddedAssemblies::map_runtime_file (XamarinAndroidBundledAssembly& file) noexc
179180
close (fd);
180181
}
181182

182-
if (MonodroidRuntime::is_startup_in_progress ()) {
183+
if (MonodroidState::is_startup_in_progress ()) {
183184
file.data = static_cast<uint8_t*>(map_info.area);
184185
} else {
185186
uint8_t *expected_null = nullptr;

Diff for: src/native/monodroid/monodroid-glue-internal.hh

-6
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,6 @@ namespace xamarin::android::internal
170170

171171
jint Java_JNI_OnLoad (JavaVM *vm, void *reserved);
172172

173-
static bool is_startup_in_progress () noexcept
174-
{
175-
return startup_in_progress;
176-
}
177-
178173
int get_android_api_level () const
179174
{
180175
return android_api_level;
@@ -341,7 +336,6 @@ namespace xamarin::android::internal
341336
* able to switch our different contexts from different threads.
342337
*/
343338
int current_context_id = -1;
344-
static bool startup_in_progress;
345339

346340
jnienv_register_jni_natives_fn jnienv_register_jni_natives = nullptr;
347341
MonoAssemblyLoadContextGCHandle default_alc = nullptr;

Diff for: src/native/monodroid/monodroid-glue.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include "timing-internal.hh"
6666
#include "search.hh"
6767
#include "runtime-util.hh"
68+
#include "monodroid-state.hh"
6869

6970
//#include "xamarin_getifaddrs.h"
7071

@@ -87,7 +88,6 @@ MonoCoreRuntimeProperties MonodroidRuntime::monovm_core_properties = {
8788
};
8889

8990
std::mutex MonodroidRuntime::dso_handle_write_lock;
90-
bool MonodroidRuntime::startup_in_progress = true;
9191

9292
void
9393
MonodroidRuntime::thread_start ([[maybe_unused]] MonoProfiler *prof, [[maybe_unused]] uintptr_t tid)
@@ -1046,7 +1046,7 @@ MonodroidRuntime::monodroid_dlopen_log_and_return (void *handle, char **err, con
10461046
force_inline void*
10471047
MonodroidRuntime::monodroid_dlopen_ignore_component_or_load ([[maybe_unused]] hash_t name_hash, const char *name, int flags, char **err) noexcept
10481048
{
1049-
if (startup_in_progress) {
1049+
if (MonodroidState::is_startup_in_progress ()) {
10501050
auto ignore_component = [&](const char *label, MonoComponent component) -> bool {
10511051
if ((application_config.mono_components_mask & component) != component) {
10521052
log_info (LOG_ASSEMBLY, "Mono '%s' component requested but not packaged, ignoring", label);
@@ -1731,7 +1731,7 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl
17311731
xamarin_app_init (env, get_function_pointer_at_runtime);
17321732
}
17331733
#endif // def RELEASE && def ANDROID && def NET
1734-
startup_in_progress = false;
1734+
MonodroidState::mark_startup_done ();
17351735
}
17361736

17371737
JNIEXPORT jint JNICALL

Diff for: src/native/monodroid/timing-internal.hh

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "strings.hh"
1313
#include "util.hh"
1414
#include "shared-constants.hh"
15+
#include "monodroid-state.hh"
1516

1617
namespace xamarin::android::internal
1718
{
@@ -150,7 +151,7 @@ namespace xamarin::android::internal
150151
TimingEvent &ev = events[index];
151152
mark (ev.start);
152153
ev.kind = kind;
153-
ev.before_managed = MonodroidRuntime::is_startup_in_progress ();
154+
ev.before_managed = MonodroidState::is_startup_in_progress ();
154155
ev.more_info = nullptr;
155156

156157
return index;

Diff for: src/native/monodroid/timing.cc

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "timing.hh"
12
#include "timing-internal.hh"
23

34
using namespace xamarin::android;

Diff for: src/native/runtime-base/monodroid-state.hh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
3+
namespace xamarin::android::internal
4+
{
5+
class MonodroidState
6+
{
7+
public:
8+
static bool is_startup_in_progress () noexcept
9+
{
10+
return startup_in_progress;
11+
}
12+
13+
static void mark_startup_done ()
14+
{
15+
startup_in_progress = false;
16+
}
17+
18+
private:
19+
inline static bool startup_in_progress = true;
20+
};
21+
}

Diff for: src/native/monodroid/startup-aware-lock.hh renamed to src/native/runtime-base/startup-aware-lock.hh

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#ifndef __STARTUP_AWARE_LOCK_HH
22
#define __STARTUP_AWARE_LOCK_HH
33

4-
#include "globals.hh"
4+
#include "cppcompat.hh"
5+
#include "monodroid-state.hh"
56

67
namespace xamarin::android::internal
78
{
@@ -11,7 +12,7 @@ namespace xamarin::android::internal
1112
explicit StartupAwareLock (std::mutex &m)
1213
: lock (m)
1314
{
14-
if (MonodroidRuntime::is_startup_in_progress ()) {
15+
if (MonodroidState::is_startup_in_progress ()) {
1516
// During startup we run without threads, do nothing
1617
return;
1718
}
@@ -21,7 +22,7 @@ namespace xamarin::android::internal
2122

2223
~StartupAwareLock ()
2324
{
24-
if (MonodroidRuntime::is_startup_in_progress ()) {
25+
if (MonodroidState::is_startup_in_progress ()) {
2526
return;
2627
}
2728

0 commit comments

Comments
 (0)