From 6bc4446f02fdc34ee5c1391fb53c4c62e271d257 Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Thu, 3 Nov 2011 11:49:42 -0200 Subject: [PATCH] Implement the icalls needed by the new mobile mmap code. --- mono/metadata/file-io.c | 32 ++++++++++++++++++++++++++++++++ mono/metadata/file-io.h | 6 ++++++ mono/metadata/icall-def.h | 7 +++++++ 3 files changed, 45 insertions(+) diff --git a/mono/metadata/file-io.c b/mono/metadata/file-io.c index b33d57508ec..6f1f3c3da50 100644 --- a/mono/metadata/file-io.c +++ b/mono/metadata/file-io.c @@ -1223,3 +1223,35 @@ void ves_icall_System_IO_MonoIO_Unlock (HANDLE handle, gint64 position, } } +//Support for io-layer free mmap'd files. + +#if (defined (__MACH__) && defined (TARGET_ARM)) || defined (TARGET_ANDROID) + +gint64 +mono_filesize_from_path (MonoString *string) +{ + struct stat buf; + gint64 res; + char *path = mono_string_to_utf8 (string); + + if (stat (path, &buf) == -1) + res = -1; + else + res = (gint64)buf.st_size; + + g_free (path); + return res; +} + +gint64 +mono_filesize_from_fd (int fd) +{ + struct stat buf; + + if (fstat (fd, &buf) == -1) + return (gint64)-1; + + return (gint64)buf.st_size; +} + +#endif diff --git a/mono/metadata/file-io.h b/mono/metadata/file-io.h index 1ad78f60c36..f1951da2e44 100644 --- a/mono/metadata/file-io.h +++ b/mono/metadata/file-io.h @@ -251,6 +251,12 @@ ves_icall_System_IO_MonoIO_ReplaceFile (MonoString *sourceFileName, MonoString * MonoString *destinationBackupFileName, MonoBoolean ignoreMetadataErrors, gint32 *error) MONO_INTERNAL; +extern gint64 +mono_filesize_from_path (MonoString *path); + +extern gint64 +mono_filesize_from_fd (int fd); + G_END_DECLS #endif /* _MONO_METADATA_FILEIO_H_ */ diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index 8d750e0e41f..5f2ade762eb 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -312,6 +312,13 @@ ICALL(INOW_1, "AddWatch", ves_icall_System_IO_InotifyWatcher_AddWatch) ICALL(INOW_2, "GetInotifyInstance", ves_icall_System_IO_InotifyWatcher_GetInotifyInstance) ICALL(INOW_3, "RemoveWatch", ves_icall_System_IO_InotifyWatcher_RemoveWatch) +#if (defined (__MACH__) && defined (TARGET_ARM)) || defined (TARGET_ANDROID) +ICALL_TYPE(MMAPIMPL, "System.IO.MemoryMappedFiles.MemoryMapImpl", MMAPIMPL_1) +ICALL(MMAPIMPL_1, "mono_filesize_from_fd", mono_filesize_from_fd) +ICALL(MMAPIMPL_2, "mono_filesize_from_path", mono_filesize_from_path) +#endif + + ICALL_TYPE(MONOIO, "System.IO.MonoIO", MONOIO_1) ICALL(MONOIO_1, "Close(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Close) #ifndef PLATFORM_RO_FS -- 2.11.4.GIT