Merge remote-tracking branch 'mfoliveira/ppc64el-v2'
[mono.git] / mono / metadata / marshal.h
1
2 /*
3  * marshal.h: Routines for marshaling complex types in P/Invoke methods.
4  * 
5  * Author:
6  *   Paolo Molaro (lupus@ximian.com)
7  *
8  * (C) 2002 Ximian, Inc.  http://www.ximian.com
9  *
10  */
11
12 #ifndef __MONO_MARSHAL_H__
13 #define __MONO_MARSHAL_H__
14
15 #include <mono/metadata/class.h>
16 #include <mono/metadata/object-internals.h>
17 #include <mono/metadata/class-internals.h>
18 #include <mono/metadata/opcodes.h>
19 #include <mono/metadata/reflection.h>
20 #include <mono/metadata/method-builder.h>
21 #include <mono/metadata/remoting.h>
22
23 #define mono_marshal_find_bitfield_offset(type, elem, byte_offset, bitmask) \
24         do { \
25                 type tmp; \
26                 memset (&tmp, 0, sizeof (tmp)); \
27                 tmp.elem = 1; \
28                 mono_marshal_find_nonzero_bit_offset ((guint8*)&tmp, sizeof (tmp), (byte_offset), (bitmask)); \
29         } while (0)
30
31 /*
32  * This structure holds the state kept by the emit_ marshalling functions.
33  * This is exported so it can be used by cominterop.c.
34  */
35 typedef struct {
36         MonoMethodBuilder *mb;
37         MonoMethodSignature *sig;
38         MonoMethodPInvoke *piinfo;
39         int *orig_conv_args; /* Locals containing the original values of byref args */
40         int retobj_var;
41         MonoClass *retobj_class;
42         MonoMethodSignature *csig; /* Might need to be changed due to MarshalAs directives */
43         MonoImage *image; /* The image to use for looking up custom marshallers */
44 } EmitMarshalContext;
45
46 typedef enum {
47         /*
48          * This is invoked to convert arguments from the current types to
49          * the underlying types expected by the platform routine.  If required,
50          * the methods create a temporary variable with the proper type, and return
51          * the location for it (either the passed argument, or the newly allocated
52          * local slot).
53          */
54         MARSHAL_ACTION_CONV_IN,
55
56         /*
57          * This operation is called to push the actual value that was optionally
58          * converted on the first stage
59          */
60         MARSHAL_ACTION_PUSH,
61
62         /*
63          * Convert byref arguments back or free resources allocated during the
64          * CONV_IN stage
65          */
66         MARSHAL_ACTION_CONV_OUT,
67
68         /*
69          * The result from the unmanaged call is at the top of the stack when
70          * this action is invoked.    The result should be stored in the
71          * third local variable slot. 
72          */
73         MARSHAL_ACTION_CONV_RESULT,
74
75         MARSHAL_ACTION_MANAGED_CONV_IN,
76         MARSHAL_ACTION_MANAGED_CONV_OUT,
77         MARSHAL_ACTION_MANAGED_CONV_RESULT
78 } MarshalAction;
79
80 /*
81  * This is an extension of the MONO_WRAPPER_ enum to avoid adding more elements to that
82  * enum.
83  */
84 typedef enum {
85         WRAPPER_SUBTYPE_NONE,
86         /* Subtypes of MONO_WRAPPER_MANAGED_TO_MANAGED */
87         WRAPPER_SUBTYPE_ELEMENT_ADDR,
88         WRAPPER_SUBTYPE_STRING_CTOR,
89         /* Subtypes of MONO_WRAPPER_STELEMREF */
90         WRAPPER_SUBTYPE_VIRTUAL_STELEMREF,
91         /* Subtypes of MONO_WRAPPER_UNKNOWN */
92         WRAPPER_SUBTYPE_FAST_MONITOR_ENTER,
93         WRAPPER_SUBTYPE_FAST_MONITOR_ENTER_V4,
94         WRAPPER_SUBTYPE_FAST_MONITOR_EXIT,
95         WRAPPER_SUBTYPE_PTR_TO_STRUCTURE,
96         WRAPPER_SUBTYPE_STRUCTURE_TO_PTR,
97         /* Subtypes of MONO_WRAPPER_CASTCLASS */
98         WRAPPER_SUBTYPE_CASTCLASS_WITH_CACHE,
99         WRAPPER_SUBTYPE_ISINST_WITH_CACHE,
100         /* Subtypes of MONO_WRAPPER_RUNTIME_INVOKE */
101         WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL,
102         WRAPPER_SUBTYPE_RUNTIME_INVOKE_DYNAMIC,
103         WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT,
104         WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL,
105         /* Subtypes of MONO_WRAPPER_MANAGED_TO_NATIVE */
106         WRAPPER_SUBTYPE_ICALL_WRAPPER,
107         WRAPPER_SUBTYPE_NATIVE_FUNC_AOT,
108         WRAPPER_SUBTYPE_PINVOKE,
109         /* Subtypes of MONO_WRAPPER_UNKNOWN */
110         WRAPPER_SUBTYPE_SYNCHRONIZED_INNER,
111         WRAPPER_SUBTYPE_GSHAREDVT_IN,
112         WRAPPER_SUBTYPE_GSHAREDVT_OUT,
113         WRAPPER_SUBTYPE_ARRAY_ACCESSOR,
114         /* Subtypes of MONO_WRAPPER_MANAGED_TO_MANAGED */
115         WRAPPER_SUBTYPE_GENERIC_ARRAY_HELPER,
116         /* Subtypes of MONO_WRAPPER_DELEGATE_INVOKE */
117         WRAPPER_SUBTYPE_DELEGATE_INVOKE_VIRTUAL,
118         WRAPPER_SUBTYPE_DELEGATE_INVOKE_BOUND
119 } WrapperSubtype;
120
121 typedef struct {
122         MonoMethod *method;
123         MonoClass *klass;
124 } NativeToManagedWrapperInfo;
125
126 typedef struct {
127         MonoMethod *method;
128 } StringCtorWrapperInfo;
129
130 typedef struct {
131         int kind;
132 } VirtualStelemrefWrapperInfo;
133
134 typedef struct {
135         guint32 rank, elem_size;
136 } ElementAddrWrapperInfo;
137
138 typedef struct {
139         MonoMethod *method;
140         /* For WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL */
141         MonoMethodSignature *sig;
142 } RuntimeInvokeWrapperInfo;
143
144 typedef struct {
145         MonoMethod *method;
146 } ManagedToNativeWrapperInfo;
147
148 typedef struct {
149         MonoMethod *method;
150 } SynchronizedInnerWrapperInfo;
151
152 typedef struct {
153         MonoMethod *method;
154 } GenericArrayHelperWrapperInfo;
155
156 typedef struct {
157         gpointer func;
158 } ICallWrapperInfo;
159
160 typedef struct {
161         MonoMethod *method;
162 } ArrayAccessorWrapperInfo;
163
164 typedef struct {
165         MonoClass *klass;
166 } ProxyWrapperInfo;
167
168 /*
169  * This structure contains additional information to uniquely identify a given wrapper
170  * method. It can be retrieved by mono_marshal_get_wrapper_info () for certain types
171  * of wrappers, i.e. ones which do not have a 1-1 association with a method/class.
172  */
173 typedef struct {
174         WrapperSubtype subtype;
175         union {
176                 /* RUNTIME_INVOKE_... */
177                 RuntimeInvokeWrapperInfo runtime_invoke;
178                 /* STRING_CTOR */
179                 StringCtorWrapperInfo string_ctor;
180                 /* ELEMENT_ADDR */
181                 ElementAddrWrapperInfo element_addr;
182                 /* VIRTUAL_STELEMREF */
183                 VirtualStelemrefWrapperInfo virtual_stelemref;
184                 /* MONO_WRAPPER_NATIVE_TO_MANAGED */
185                 NativeToManagedWrapperInfo native_to_managed;
186                 /* MONO_WRAPPER_MANAGED_TO_NATIVE */
187                 ManagedToNativeWrapperInfo managed_to_native;
188                 /* SYNCHRONIZED_INNER */
189                 SynchronizedInnerWrapperInfo synchronized_inner;
190                 /* GENERIC_ARRAY_HELPER */
191                 GenericArrayHelperWrapperInfo generic_array_helper;
192                 /* ICALL_WRAPPER */
193                 ICallWrapperInfo icall;
194                 /* ARRAY_ACCESSOR */
195                 ArrayAccessorWrapperInfo array_accessor;
196                 /* PROXY_ISINST etc. */
197                 ProxyWrapperInfo proxy;
198         } d;
199 } WrapperInfo;
200
201 G_BEGIN_DECLS
202
203 /*type of the function pointer of methods returned by mono_marshal_get_runtime_invoke*/
204 typedef MonoObject *(*RuntimeInvokeFunction) (MonoObject *this_obj, void **params, MonoObject **exc, void* compiled_method);
205
206 typedef void (*RuntimeInvokeDynamicFunction) (void *args, MonoObject **exc, void* compiled_method);
207
208 /* marshaling helper functions */
209
210 void
211 mono_marshal_init (void) MONO_INTERNAL;
212
213 void
214 mono_marshal_init_tls (void) MONO_INTERNAL;
215
216 void
217 mono_marshal_cleanup (void) MONO_INTERNAL;
218
219 gint32
220 mono_class_native_size (MonoClass *klass, guint32 *align) MONO_INTERNAL;
221
222 MonoMarshalType *
223 mono_marshal_load_type_info (MonoClass* klass) MONO_INTERNAL;
224
225 gint32
226 mono_marshal_type_size (MonoType *type, MonoMarshalSpec *mspec, guint32 *align,
227                         gboolean as_field, gboolean unicode) MONO_INTERNAL;
228
229 int            
230 mono_type_native_stack_size (MonoType *type, guint32 *alignment) MONO_INTERNAL;
231
232 gpointer
233 mono_array_to_savearray (MonoArray *array) MONO_INTERNAL;
234
235 gpointer
236 mono_array_to_lparray (MonoArray *array) MONO_INTERNAL;
237
238 void
239 mono_free_lparray (MonoArray *array, gpointer* nativeArray) MONO_INTERNAL;
240
241 void
242 mono_string_utf8_to_builder (MonoStringBuilder *sb, char *text) MONO_INTERNAL;
243
244 void
245 mono_string_utf16_to_builder (MonoStringBuilder *sb, gunichar2 *text) MONO_INTERNAL;
246
247 gpointer
248 mono_string_builder_to_utf8 (MonoStringBuilder *sb) MONO_INTERNAL;
249
250 gpointer
251 mono_string_builder_to_utf16 (MonoStringBuilder *sb) MONO_INTERNAL;
252
253 gpointer
254 mono_string_to_ansibstr (MonoString *string_obj) MONO_INTERNAL;
255
256 gpointer
257 mono_string_to_bstr (MonoString *string_obj) MONO_INTERNAL;
258
259 void
260 mono_string_to_byvalstr (gpointer dst, MonoString *src, int size) MONO_INTERNAL;
261
262 void
263 mono_string_to_byvalwstr (gpointer dst, MonoString *src, int size) MONO_INTERNAL;
264
265 gpointer
266 mono_delegate_to_ftnptr (MonoDelegate *delegate) MONO_INTERNAL;
267
268 MonoDelegate*
269 mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn) MONO_INTERNAL;
270
271 void mono_delegate_free_ftnptr (MonoDelegate *delegate) MONO_INTERNAL;
272
273 void
274 mono_marshal_set_last_error (void) MONO_INTERNAL;
275
276 gpointer
277 mono_marshal_asany (MonoObject *obj, MonoMarshalNative string_encoding, int param_attrs) MONO_INTERNAL;
278
279 void
280 mono_marshal_free_asany (MonoObject *o, gpointer ptr, MonoMarshalNative string_encoding, int param_attrs) MONO_INTERNAL;
281
282 guint
283 mono_type_to_ldind (MonoType *type) MONO_INTERNAL;
284
285 guint
286 mono_type_to_stind (MonoType *type) MONO_INTERNAL;
287
288 /* functions to create various architecture independent helper functions */
289
290 MonoMethod *
291 mono_marshal_method_from_wrapper (MonoMethod *wrapper) MONO_INTERNAL;
292
293 WrapperInfo*
294 mono_wrapper_info_create (MonoMethodBuilder *mb, WrapperSubtype subtype) MONO_INTERNAL;
295
296 void
297 mono_marshal_set_wrapper_info (MonoMethod *method, gpointer data) MONO_INTERNAL;
298
299 gpointer
300 mono_marshal_get_wrapper_info (MonoMethod *wrapper) MONO_INTERNAL;
301
302 MonoMethod *
303 mono_marshal_get_delegate_begin_invoke (MonoMethod *method) MONO_INTERNAL;
304
305 MonoMethod *
306 mono_marshal_get_delegate_end_invoke (MonoMethod *method) MONO_INTERNAL;
307
308 MonoMethod *
309 mono_marshal_get_delegate_invoke (MonoMethod *method, MonoDelegate *del) MONO_INTERNAL;
310
311 MonoMethod *
312 mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean is_virtual) MONO_INTERNAL;
313
314 MonoMethod*
315 mono_marshal_get_runtime_invoke_dynamic (void) MONO_INTERNAL;
316
317 MonoMethodSignature*
318 mono_marshal_get_string_ctor_signature (MonoMethod *method) MONO_INTERNAL;
319
320 MonoMethod *
321 mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, uint32_t this_loc) MONO_INTERNAL;
322
323 gpointer
324 mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type) MONO_INTERNAL;
325
326 MonoMethod *
327 mono_marshal_get_icall_wrapper (MonoMethodSignature *sig, const char *name, gconstpointer func, gboolean check_exceptions) MONO_INTERNAL;
328
329 MonoMethod *
330 mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, gboolean aot) MONO_INTERNAL;
331
332 MonoMethod *
333 mono_marshal_get_native_func_wrapper (MonoImage *image, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func) MONO_INTERNAL;
334
335 MonoMethod*
336 mono_marshal_get_native_func_wrapper_aot (MonoClass *klass) MONO_INTERNAL;
337
338 MonoMethod *
339 mono_marshal_get_struct_to_ptr (MonoClass *klass) MONO_INTERNAL;
340
341 MonoMethod *
342 mono_marshal_get_ptr_to_struct (MonoClass *klass) MONO_INTERNAL;
343
344 MonoMethod *
345 mono_marshal_get_synchronized_wrapper (MonoMethod *method) MONO_INTERNAL;
346
347 MonoMethod *
348 mono_marshal_get_synchronized_inner_wrapper (MonoMethod *method) MONO_INTERNAL;
349
350 MonoMethod *
351 mono_marshal_get_unbox_wrapper (MonoMethod *method) MONO_INTERNAL;
352
353 MonoMethod *
354 mono_marshal_get_castclass_with_cache (void) MONO_INTERNAL;
355
356 MonoMethod *
357 mono_marshal_get_isinst_with_cache (void) MONO_INTERNAL;
358
359 MonoMethod *
360 mono_marshal_get_isinst (MonoClass *klass) MONO_INTERNAL;
361
362 MonoMethod *
363 mono_marshal_get_castclass (MonoClass *klass) MONO_INTERNAL;
364
365 MonoMethod *
366 mono_marshal_get_stelemref (void) MONO_INTERNAL;
367
368 MonoMethod*
369 mono_marshal_get_virtual_stelemref (MonoClass *array_class) MONO_INTERNAL;
370
371 MonoMethod**
372 mono_marshal_get_virtual_stelemref_wrappers (int *nwrappers) MONO_INTERNAL;
373
374 MonoMethod*
375 mono_marshal_get_array_address (int rank, int elem_size) MONO_INTERNAL;
376
377 MonoMethod *
378 mono_marshal_get_array_accessor_wrapper (MonoMethod *method) MONO_INTERNAL;
379
380 MonoMethod *
381 mono_marshal_get_generic_array_helper (MonoClass *klass, MonoClass *iface,
382                                        gchar *name, MonoMethod *method) MONO_INTERNAL;
383
384 MonoMethod *
385 mono_marshal_get_thunk_invoke_wrapper (MonoMethod *method) MONO_INTERNAL;
386
387 MonoMethod*
388 mono_marshal_get_gsharedvt_in_wrapper (void) MONO_INTERNAL;
389
390 MonoMethod*
391 mono_marshal_get_gsharedvt_out_wrapper (void) MONO_INTERNAL;
392
393 void
394 mono_marshal_free_dynamic_wrappers (MonoMethod *method) MONO_INTERNAL;
395
396 void
397 mono_marshal_free_inflated_wrappers (MonoMethod *method) MONO_INTERNAL;
398
399 void
400 mono_marshal_lock_internal (void) MONO_INTERNAL;
401
402 void
403 mono_marshal_unlock_internal (void) MONO_INTERNAL;
404
405 /* marshaling internal calls */
406
407 void * 
408 mono_marshal_alloc (gulong size) MONO_INTERNAL;
409
410 void 
411 mono_marshal_free (gpointer ptr) MONO_INTERNAL;
412
413 void
414 mono_marshal_free_array (gpointer *ptr, int size) MONO_INTERNAL;
415
416 gboolean 
417 mono_marshal_free_ccw (MonoObject* obj) MONO_INTERNAL;
418
419 void
420 cominterop_release_all_rcws (void) MONO_INTERNAL; 
421
422 void
423 ves_icall_System_Runtime_InteropServices_Marshal_copy_to_unmanaged (MonoArray *src, gint32 start_index,
424                                                                     gpointer dest, gint32 length) MONO_INTERNAL;
425
426 void
427 ves_icall_System_Runtime_InteropServices_Marshal_copy_from_unmanaged (gpointer src, gint32 start_index,
428                                                                       MonoArray *dest, gint32 length) MONO_INTERNAL;
429
430 MonoString *
431 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi (char *ptr) MONO_INTERNAL;
432
433 MonoString *
434 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len (char *ptr, gint32 len) MONO_INTERNAL;
435
436 MonoString *
437 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni (guint16 *ptr) MONO_INTERNAL;
438
439 MonoString *
440 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni_len (guint16 *ptr, gint32 len) MONO_INTERNAL;
441
442 MonoString *
443 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR (gpointer ptr) MONO_INTERNAL;
444
445 guint32
446 ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal (MonoReflectionMethod *m) MONO_INTERNAL;
447
448 guint32 
449 ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error (void) MONO_INTERNAL;
450
451 guint32 
452 ves_icall_System_Runtime_InteropServices_Marshal_SizeOf (MonoReflectionType *rtype) MONO_INTERNAL;
453
454 void
455 ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr (MonoObject *obj, gpointer dst, MonoBoolean delete_old) MONO_INTERNAL;
456
457 void
458 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure (gpointer src, MonoObject *dst) MONO_INTERNAL;
459
460 MonoObject *
461 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type (gpointer src, MonoReflectionType *type) MONO_INTERNAL;
462
463 int
464 ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf (MonoReflectionType *type, MonoString *field_name) MONO_INTERNAL;
465
466 gpointer
467 ves_icall_System_Runtime_InteropServices_Marshal_StringToBSTR (MonoString *string) MONO_INTERNAL;
468
469 gpointer
470 ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi (MonoString *string) MONO_INTERNAL;
471
472 gpointer
473 ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni (MonoString *string) MONO_INTERNAL;
474
475 void
476 ves_icall_System_Runtime_InteropServices_Marshal_DestroyStructure (gpointer src, MonoReflectionType *type) MONO_INTERNAL;
477
478 void*
479 ves_icall_System_Runtime_InteropServices_Marshal_AllocCoTaskMem (int size) MONO_INTERNAL;
480
481 void
482 ves_icall_System_Runtime_InteropServices_Marshal_FreeCoTaskMem (void *ptr) MONO_INTERNAL;
483
484 gpointer 
485 ves_icall_System_Runtime_InteropServices_Marshal_ReAllocCoTaskMem (gpointer ptr, int size) MONO_INTERNAL;
486
487 void*
488 ves_icall_System_Runtime_InteropServices_Marshal_AllocHGlobal (int size) MONO_INTERNAL;
489
490 gpointer 
491 ves_icall_System_Runtime_InteropServices_Marshal_ReAllocHGlobal (gpointer ptr, int size) MONO_INTERNAL;
492
493 void
494 ves_icall_System_Runtime_InteropServices_Marshal_FreeHGlobal (void *ptr) MONO_INTERNAL;
495
496 void
497 ves_icall_System_Runtime_InteropServices_Marshal_FreeBSTR (void *ptr) MONO_INTERNAL;
498
499 void*
500 ves_icall_System_Runtime_InteropServices_Marshal_UnsafeAddrOfPinnedArrayElement (MonoArray *arrayobj, int index) MONO_INTERNAL;
501
502 MonoDelegate*
503 ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal (void *ftn, MonoReflectionType *type) MONO_INTERNAL;
504
505 int
506 ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (gpointer pUnk) MONO_INTERNAL;
507
508 int
509 ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (gpointer pUnk, gpointer riid, gpointer* ppv) MONO_INTERNAL;
510
511 int
512 ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (gpointer pUnk) MONO_INTERNAL;
513
514 void*
515 ves_icall_System_Runtime_InteropServices_Marshal_GetIUnknownForObjectInternal (MonoObject* object) MONO_INTERNAL;
516
517 MonoObject*
518 ves_icall_System_Runtime_InteropServices_Marshal_GetObjectForCCW (void* pUnk) MONO_INTERNAL;
519
520 void*
521 ves_icall_System_Runtime_InteropServices_Marshal_GetIDispatchForObjectInternal (MonoObject* object) MONO_INTERNAL;
522
523 void*
524 ves_icall_System_Runtime_InteropServices_Marshal_GetCCW (MonoObject* object, MonoReflectionType* type) MONO_INTERNAL;
525
526 MonoBoolean
527 ves_icall_System_Runtime_InteropServices_Marshal_IsComObject (MonoObject* object) MONO_INTERNAL;
528
529 gint32
530 ves_icall_System_Runtime_InteropServices_Marshal_ReleaseComObjectInternal (MonoObject* object) MONO_INTERNAL;
531
532 MonoObject *
533 ves_icall_System_ComObject_CreateRCW (MonoReflectionType *type) MONO_INTERNAL;
534
535 void
536 ves_icall_System_ComObject_ReleaseInterfaces(MonoComObject* obj) MONO_INTERNAL;
537
538 gpointer
539 ves_icall_System_ComObject_GetInterfaceInternal (MonoComObject* obj, MonoReflectionType* type, MonoBoolean throw_exception) MONO_INTERNAL;
540
541 void
542 ves_icall_Mono_Interop_ComInteropProxy_AddProxy (gpointer pUnk, MonoComInteropProxy* proxy) MONO_INTERNAL;
543
544 MonoComInteropProxy*
545 ves_icall_Mono_Interop_ComInteropProxy_FindProxy (gpointer pUnk) MONO_INTERNAL;
546
547 MONO_API void
548 mono_win32_compat_CopyMemory (gpointer dest, gconstpointer source, gsize length);
549
550 MONO_API void
551 mono_win32_compat_FillMemory (gpointer dest, gsize length, guchar fill);
552
553 MONO_API void
554 mono_win32_compat_MoveMemory (gpointer dest, gconstpointer source, gsize length);
555
556 MONO_API void
557 mono_win32_compat_ZeroMemory (gpointer dest, gsize length);
558
559 void
560 mono_marshal_find_nonzero_bit_offset (guint8 *buf, int len, int *byte_offset, guint8 *bitmask) MONO_INTERNAL;
561
562 MonoMethodSignature*
563 mono_signature_no_pinvoke (MonoMethod *method) MONO_INTERNAL;
564
565 /* Called from cominterop.c/remoting.c */
566
567 void
568 mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func, gboolean aot, gboolean check_exceptions, gboolean func_param) MONO_INTERNAL;
569
570 void
571 mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle) MONO_INTERNAL;
572
573 GHashTable*
574 mono_marshal_get_cache (GHashTable **var, GHashFunc hash_func, GCompareFunc equal_func) MONO_INTERNAL;
575
576 MonoMethod*
577 mono_marshal_find_in_cache (GHashTable *cache, gpointer key) MONO_INTERNAL;
578
579 MonoMethod*
580 mono_mb_create_and_cache (GHashTable *cache, gpointer key,
581                                                   MonoMethodBuilder *mb, MonoMethodSignature *sig,
582                                                   int max_stack) MONO_INTERNAL;
583 void
584 mono_marshal_emit_thread_interrupt_checkpoint (MonoMethodBuilder *mb) MONO_INTERNAL;
585
586 void
587 mono_marshal_emit_thread_force_interrupt_checkpoint (MonoMethodBuilder *mb) MONO_INTERNAL;
588
589 void
590 mono_marshal_use_aot_wrappers (gboolean use) MONO_INTERNAL;
591
592 MonoObject *
593 mono_marshal_xdomain_copy_value (MonoObject *val) MONO_INTERNAL;
594
595 int
596 mono_mb_emit_save_args (MonoMethodBuilder *mb, MonoMethodSignature *sig, gboolean save_this) MONO_INTERNAL;
597
598 void
599 mono_mb_emit_restore_result (MonoMethodBuilder *mb, MonoType *return_type) MONO_INTERNAL;
600
601 MonoMethod*
602 mono_mb_create (MonoMethodBuilder *mb, MonoMethodSignature *sig,
603                                 int max_stack, WrapperInfo *info) MONO_INTERNAL;
604
605 MonoMethod*
606 mono_mb_create_and_cache_full (GHashTable *cache, gpointer key,
607                                                            MonoMethodBuilder *mb, MonoMethodSignature *sig,
608                                                            int max_stack, WrapperInfo *info, gboolean *out_found) MONO_INTERNAL;
609
610 G_END_DECLS
611
612 #endif /* __MONO_MARSHAL_H__ */
613
614