Skip to content

Commit c594b73

Browse files
committed
Prepare for new p/invoke code, step #3
1 parent 0c9fc06 commit c594b73

File tree

2 files changed

+101
-42
lines changed

2 files changed

+101
-42
lines changed

src/native/monodroid/pinvoke-override-api.cc

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "xxhash.hh"
1515
#include "startup-aware-lock.hh"
1616
#include "jni-remapping.hh"
17+
#include "internal-pinvokes.hh"
1718

1819
extern "C" {
1920
int _monodroid_getifaddrs (struct _monodroid_ifaddrs **ifap);
@@ -31,26 +32,26 @@ void* MonodroidRuntime::system_native_library_handle = nullptr;
3132
void* MonodroidRuntime::system_security_cryptography_native_android_library_handle = nullptr;
3233
void* MonodroidRuntime::system_io_compression_native_library_handle = nullptr;
3334

34-
static unsigned int
35+
unsigned int
3536
monodroid_get_log_categories ()
3637
{
3738
return log_categories;
3839
}
3940

40-
static int
41+
int
4142
monodroid_get_system_property (const char *name, char **value)
4243
{
4344
return AndroidSystem::monodroid_get_system_property (name, value);
4445
}
4546

46-
static int
47+
int
4748
monodroid_embedded_assemblies_set_assemblies_prefix (const char *prefix)
4849
{
4950
embeddedAssemblies.set_assemblies_prefix (prefix);
5051
return 0;
5152
}
5253

53-
static void
54+
void
5455
monodroid_log (LogLevel level, LogCategories category, const char *message)
5556
{
5657
switch (level) {
@@ -84,99 +85,99 @@ monodroid_log (LogLevel level, LogCategories category, const char *message)
8485
}
8586
}
8687

87-
static void
88+
void
8889
monodroid_free (void *ptr)
8990
{
9091
free (ptr);
9192
}
9293

93-
static int
94+
int
9495
_monodroid_max_gref_get ()
9596
{
9697
return static_cast<int>(AndroidSystem::get_max_gref_count ());
9798
}
9899

99-
static int
100+
int
100101
_monodroid_gref_get ()
101102
{
102103
return osBridge.get_gc_gref_count ();
103104
}
104105

105106

106-
static void
107+
void
107108
_monodroid_gref_log (const char *message)
108109
{
109110
osBridge._monodroid_gref_log (message);
110111
}
111112

112-
static int
113+
int
113114
_monodroid_gref_log_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable)
114115
{
115116
return osBridge._monodroid_gref_log_new (curHandle, curType, newHandle, newType, threadName, threadId, from, from_writable);
116117
}
117118

118-
static void
119+
void
119120
_monodroid_gref_log_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable)
120121
{
121122
osBridge._monodroid_gref_log_delete (handle, type, threadName, threadId, from, from_writable);
122123
}
123124

124-
static int
125+
int
125126
_monodroid_weak_gref_get ()
126127
{
127128
return osBridge.get_gc_weak_gref_count ();
128129
}
129130

130-
static void
131+
void
131132
_monodroid_weak_gref_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable)
132133
{
133134
osBridge._monodroid_weak_gref_new (curHandle, curType, newHandle, newType, threadName, threadId, from, from_writable);
134135
}
135136

136-
static void
137+
void
137138
_monodroid_weak_gref_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable)
138139
{
139140
osBridge._monodroid_weak_gref_delete (handle, type, threadName, threadId, from, from_writable);
140141
}
141142

142-
static void
143+
void
143144
_monodroid_lref_log_new (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable)
144145
{
145146
osBridge._monodroid_lref_log_new (lrefc, handle, type, threadName, threadId, from, from_writable);
146147
}
147148

148-
static void
149+
void
149150
_monodroid_lref_log_delete (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable)
150151
{
151152
osBridge._monodroid_lref_log_delete (lrefc, handle, type, threadName, threadId, from, from_writable);
152153
}
153154

154-
static void
155+
void
155156
_monodroid_gc_wait_for_bridge_processing ()
156157
{
157158
mono_gc_wait_for_bridge_processing ();
158159
}
159160

160-
static int
161+
int
161162
_monodroid_get_android_api_level ()
162163
{
163164
return monodroidRuntime.get_android_api_level ();
164165
}
165166

166-
static void
167+
void
167168
monodroid_clear_gdb_wait ()
168169
{
169170
monodroidRuntime.set_monodroid_gdb_wait (false);
170171
}
171172

172-
static void*
173+
void*
173174
_monodroid_get_identity_hash_code (JNIEnv *env, void *v)
174175
{
175176
intptr_t rv = env->CallStaticIntMethod (monodroidRuntime.get_java_class_System (), monodroidRuntime.get_java_class_method_System_identityHashCode (), v);
176177
return (void*) rv;
177178
}
178179

179-
static void*
180+
void*
180181
_monodroid_timezone_get_default_id ()
181182
{
182183
JNIEnv *env = osBridge.ensure_jnienv ();
@@ -202,15 +203,15 @@ _monodroid_timezone_get_default_id ()
202203
return def_id;
203204
}
204205

205-
static void
206+
void
206207
_monodroid_counters_dump ([[maybe_unused]] const char *format, [[maybe_unused]] va_list args)
207208
{
208209
#if !defined (NET)
209210
monodroidRuntime.dump_counters_v (format, args);
210211
#endif // ndef NET
211212
}
212213

213-
static managed_timing_sequence*
214+
managed_timing_sequence*
214215
monodroid_timing_start (const char *message)
215216
{
216217
if (timing == nullptr)
@@ -225,7 +226,7 @@ monodroid_timing_start (const char *message)
225226
return ret;
226227
}
227228

228-
static void
229+
void
229230
monodroid_timing_stop (managed_timing_sequence *sequence, const char *message)
230231
{
231232
static constexpr const char DEFAULT_MESSAGE[] = "Managed Timing";
@@ -238,19 +239,19 @@ monodroid_timing_stop (managed_timing_sequence *sequence, const char *message)
238239
timing->release_sequence (sequence);
239240
}
240241

241-
static char**
242+
char**
242243
monodroid_strsplit (const char *str, const char *delimiter, size_t max_tokens)
243244
{
244245
return Util::monodroid_strsplit (str, delimiter, max_tokens);
245246
}
246247

247-
static void
248+
void
248249
monodroid_strfreev (char **str_array)
249250
{
250251
Util::monodroid_strfreev (str_array);
251252
}
252253

253-
static char*
254+
char*
254255
monodroid_strdup_printf (const char *format, ...)
255256
{
256257
va_list args;
@@ -262,65 +263,65 @@ monodroid_strdup_printf (const char *format, ...)
262263
return ret;
263264
}
264265

265-
static char*
266+
char*
266267
monodroid_TypeManager_get_java_class_name (jclass klass)
267268
{
268269
return monodroidRuntime.get_java_class_name_for_TypeManager (klass);
269270
}
270271

271-
static int
272+
int
272273
monodroid_get_namespaced_system_property (const char *name, char **value)
273274
{
274275
return static_cast<int>(AndroidSystem::monodroid_get_system_property (name, value));
275276
}
276277

277-
static FILE*
278+
FILE*
278279
monodroid_fopen (const char* filename, const char* mode)
279280
{
280281
return Util::monodroid_fopen (filename, mode);
281282
}
282283

283-
static int
284+
int
284285
send_uninterrupted (int fd, void *buf, int len)
285286
{
286287
if (len < 0)
287288
len = 0;
288289
return Util::send_uninterrupted (fd, buf, static_cast<size_t>(len));
289290
}
290291

291-
static int
292+
int
292293
recv_uninterrupted (int fd, void *buf, int len)
293294
{
294295
if (len < 0)
295296
len = 0;
296297
return static_cast<int>(Util::recv_uninterrupted (fd, buf, static_cast<size_t>(len)));
297298
}
298299

299-
static void
300+
void
300301
set_world_accessable (const char *path)
301302
{
302303
Util::set_world_accessable (path);
303304
}
304305

305-
static void
306+
void
306307
create_public_directory (const char *dir)
307308
{
308309
Util::create_public_directory (dir);
309310
}
310311

311-
static char*
312+
char*
312313
path_combine (const char *path1, const char *path2)
313314
{
314315
return Util::path_combine (path1, path2);
315316
}
316317

317-
static void*
318+
void*
318319
monodroid_dylib_mono_new ([[maybe_unused]] const char *libmono_path)
319320
{
320321
return nullptr;
321322
}
322323

323-
static void
324+
void
324325
monodroid_dylib_mono_free ([[maybe_unused]] void *mono_imports)
325326
{
326327
// no-op
@@ -332,33 +333,33 @@ monodroid_dylib_mono_free ([[maybe_unused]] void *mono_imports)
332333
333334
it should also accept libmono_path = nullptr parameter
334335
*/
335-
static int
336+
int
336337
monodroid_dylib_mono_init (void *mono_imports, [[maybe_unused]] const char *libmono_path)
337338
{
338339
if (mono_imports == nullptr)
339340
return FALSE;
340341
return TRUE;
341342
}
342343

343-
static void*
344-
monodroid_get_dylib (void)
344+
void*
345+
monodroid_get_dylib ()
345346
{
346347
return nullptr;
347348
}
348349

349-
static const char*
350+
const char*
350351
_monodroid_lookup_replacement_type (const char *jniSimpleReference)
351352
{
352353
return JniRemapping::lookup_replacement_type (jniSimpleReference);
353354
}
354355

355-
static const JniRemappingReplacementMethod*
356+
const JniRemappingReplacementMethod*
356357
_monodroid_lookup_replacement_method_info (const char *jniSourceType, const char *jniMethodName, const char *jniMethodSignature)
357358
{
358359
return JniRemapping::lookup_replacement_method_info (jniSourceType, jniMethodName, jniMethodSignature);
359360
}
360361

361-
static void
362+
void
362363
monodroid_log_traces (uint32_t kind, const char *first_line)
363364
{
364365
JNIEnv *env = osBridge.ensure_jnienv ();
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#pragma once
2+
3+
#include <cstdio>
4+
5+
#include <mono/utils/mono-publib.h>
6+
#include <java-interop-logger.h>
7+
#include <jni.h>
8+
9+
#include "log_types.hh"
10+
11+
// int _monodroid_getifaddrs (struct _monodroid_ifaddrs **ifap);
12+
// void _monodroid_freeifaddrs (struct _monodroid_ifaddrs *ifa);
13+
14+
mono_bool _monodroid_get_network_interface_up_state (const char *ifname, mono_bool *is_up);
15+
mono_bool _monodroid_get_network_interface_supports_multicast (const char *ifname, mono_bool *supports_multicast);
16+
int _monodroid_get_dns_servers (void **dns_servers_array);
17+
18+
unsigned int monodroid_get_log_categories ();
19+
int monodroid_get_system_property (const char *name, char **value);
20+
int monodroid_embedded_assemblies_set_assemblies_prefix (const char *prefix);
21+
void monodroid_log (xamarin::android::LogLevel level, LogCategories category, const char *message);
22+
void monodroid_free (void *ptr);
23+
int _monodroid_max_gref_get ();
24+
int _monodroid_gref_get ();
25+
void _monodroid_gref_log (const char *message);
26+
int _monodroid_gref_log_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable);
27+
void _monodroid_gref_log_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable);
28+
int _monodroid_weak_gref_get ();
29+
void _monodroid_weak_gref_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable);
30+
void _monodroid_weak_gref_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable);
31+
void _monodroid_lref_log_new (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable);
32+
void _monodroid_lref_log_delete (int lrefc, jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable);
33+
void _monodroid_gc_wait_for_bridge_processing ();
34+
int _monodroid_get_android_api_level ();
35+
void monodroid_clear_gdb_wait ();
36+
void* _monodroid_get_identity_hash_code (JNIEnv *env, void *v);
37+
void* _monodroid_timezone_get_default_id ();
38+
void _monodroid_counters_dump ([[maybe_unused]] const char *format, [[maybe_unused]] va_list args);
39+
//managed_timing_sequence* monodroid_timing_start (const char *message);
40+
//void monodroid_timing_stop (managed_timing_sequence *sequence, const char *message)
41+
char** monodroid_strsplit (const char *str, const char *delimiter, size_t max_tokens);
42+
void monodroid_strfreev (char **str_array);
43+
char* monodroid_strdup_printf (const char *format, ...);
44+
char* monodroid_TypeManager_get_java_class_name (jclass klass);
45+
int monodroid_get_namespaced_system_property (const char *name, char **value);
46+
FILE* monodroid_fopen (const char* filename, const char* mode);
47+
int send_uninterrupted (int fd, void *buf, int len);
48+
int recv_uninterrupted (int fd, void *buf, int len);
49+
void set_world_accessable (const char *path);
50+
void create_public_directory (const char *dir);
51+
char* path_combine (const char *path1, const char *path2);
52+
void* monodroid_dylib_mono_new ([[maybe_unused]] const char *libmono_path);
53+
void monodroid_dylib_mono_free ([[maybe_unused]] void *mono_imports);
54+
int monodroid_dylib_mono_init (void *mono_imports, [[maybe_unused]] const char *libmono_path);
55+
void* monodroid_get_dylib ();
56+
const char* _monodroid_lookup_replacement_type (const char *jniSimpleReference);
57+
// const JniRemappingReplacementMethod* _monodroid_lookup_replacement_method_info (const char *jniSourceType, const char *jniMethodName, const char *jniMethodSignature);
58+
void monodroid_log_traces (uint32_t kind, const char *first_line);

0 commit comments

Comments
 (0)