mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 11:21:39 -10:00
Compare commits
40
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f540f8ac33 | ||
|
|
c46cf0e459 | ||
|
|
5ff701f7b7 | ||
|
|
0d48422feb | ||
|
|
c54d3cbde6 | ||
|
|
cbadc822b3 | ||
|
|
1322bea50c | ||
|
|
f2fea6a2b1 | ||
|
|
3cdb3499ec | ||
|
|
c0ba6235a1 | ||
|
|
22cadb5847 | ||
|
|
855e6ee345 | ||
|
|
c250fb2dff | ||
|
|
010aa30045 | ||
|
|
621de8fd33 | ||
|
|
f6bdaab646 | ||
|
|
cafd4cd3b8 | ||
|
|
a6536943e3 | ||
|
|
287a876e74 | ||
|
|
622c84562c | ||
|
|
4939dbf6f5 | ||
|
|
d9eb9b62e9 | ||
|
|
bb4e61780a | ||
|
|
06485ceb88 | ||
|
|
da25056ced | ||
|
|
cd2d70011a | ||
|
|
77a1112f69 | ||
|
|
f6ef3e78b9 | ||
|
|
8dcee6cb00 | ||
|
|
c7f1b4e25e | ||
|
|
3be5ad84e1 | ||
|
|
00f7577ec5 | ||
|
|
bc6320345d | ||
|
|
ba81fe3dee | ||
|
|
ecc52a6222 | ||
|
|
36fafaa4f9 | ||
|
|
a520ae1ce9 | ||
|
|
fd261a3f9d | ||
|
|
851abd6a8e | ||
|
|
d75ca33779 |
No files matched your search
@@ -49,6 +49,8 @@ dist-hook:
|
||||
test -d $(distdir)/mcs || mkdir $(distdir)/mcs
|
||||
d=`cd $(distdir)/mcs && pwd`; cd $(mcs_topdir) && $(MAKE) distdir=$$d dist-recursive
|
||||
rm -rf `find $(top_distdir)/external -path '*\.git' -and -type d`
|
||||
cp mcs/class/lib/basic/System.Configuration.dll mcs/class/lib/monolite/
|
||||
cp mcs/class/lib/basic/System.Security.dll mcs/class/lib/monolite/
|
||||
# Disable this for now because it is very slow and causes wrench to timeout:
|
||||
# test ! -d $(GIT_DIR) || ./scripts/commits-to-changelog.py --root=$(distdir) last-commit-with-compulsory-changelog-entry
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
#AC_PREREQ([2.62])
|
||||
|
||||
AC_INIT(mono, [3.4.1],
|
||||
AC_INIT(mono, [3.6.0],
|
||||
[http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
|
||||
|
||||
AC_CONFIG_SRCDIR([README.md])
|
||||
|
||||
@@ -8,7 +8,7 @@ monotouch_SUBDIRS = System.Collections.Concurrent System.Collections System.Comp
|
||||
System.Reflection.Extensions System.Reflection.Primitives System.Reflection System.Resources.ResourceManager System.Runtime.Extensions \
|
||||
System.Runtime.InteropServices System.Runtime.InteropServices.WindowsRuntime System.Runtime.Numerics System.Runtime.Serialization.Json \
|
||||
System.Runtime.Serialization.Primitives System.Runtime.Serialization.Xml System.Runtime System.Security.Principal System.ServiceModel.Http \
|
||||
System.ServiceModel.Primitives System.Text.Encoding.Extensions System.Text.Encoding System.Text.RegularExpressions System.Threading.Tasks.Parallel \
|
||||
System.ServiceModel.Primitives System.ServiceModel.Security System.Text.Encoding.Extensions System.Text.Encoding System.Text.RegularExpressions System.Threading.Tasks.Parallel \
|
||||
System.Threading.Tasks System.Threading.Timer System.Threading System.Xml.ReaderWriter System.Xml.XDocument System.Xml.XmlSerializer
|
||||
|
||||
mobile_static_SUBDIRS = $(monotouch_SUBDIRS)
|
||||
@@ -45,6 +45,7 @@ include $(MCS_BUILD_DIR)/rules.make
|
||||
|
||||
dist-local: dist-default
|
||||
|
||||
SUBDIRS = $(net_4_5_SUBDIRS)
|
||||
|
||||
doc-update-local:
|
||||
@echo "not doing docs"
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyTitle ("System.ServiceModel.Security.dll")]
|
||||
[assembly: AssemblyDescription ("System.ServiceModel.Security.dll")]
|
||||
[assembly: AssemblyDefaultAlias ("System.ServiceModel.Security.dll")]
|
||||
[assembly: AssemblyCompany ("Xamarin, Inc.")]
|
||||
[assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
|
||||
[assembly: AssemblyCopyright ("Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)")]
|
||||
[assembly: AssemblyVersion ("4.0.0.0")]
|
||||
[assembly: AssemblyInformationalVersion ("4.0.0.0")]
|
||||
[assembly: AssemblyFileVersion ("4.0.0.0")]
|
||||
[assembly: AssemblyDelaySign (true)]
|
||||
[assembly: AssemblyKeyFile ("../../msfinal.pub")]
|
||||
|
||||
[assembly: ReferenceAssembly]
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
MCS_BUILD_DIR = ../../../build
|
||||
|
||||
thisdir = class/Facades/System.ServiceModel.Security
|
||||
SUBDIRS =
|
||||
include $(MCS_BUILD_DIR)/rules.make
|
||||
|
||||
LIBRARY_SUBDIR = Facades
|
||||
LIBRARY_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)/Facades
|
||||
|
||||
LIBRARY = System.ServiceModel.Security.dll
|
||||
|
||||
KEY_FILE = ../../msfinal.pub
|
||||
SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
|
||||
LIB_MCS_FLAGS = $(SIGN_FLAGS) /r:mscorlib /r:System.ServiceModel
|
||||
|
||||
PLATFORM_DEBUG_FLAGS =
|
||||
|
||||
NO_TEST = yes
|
||||
|
||||
include $(MCS_BUILD_DIR)/library.make
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
TypeForwarders.cs
|
||||
AssemblyInfo.cs
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Channels.LocalClientSecuritySettings))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Channels.SecurityBindingElement))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Channels.SecurityHeaderLayout))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Channels.TransportSecurityBindingElement))]
|
||||
#if !MOBILE
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.DnsEndpointIdentity))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.MessageSecurityVersion))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Security.BasicSecurityProfileVersion))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Security.SecureConversationVersion))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Security.SecurityPolicyVersion))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Security.SecurityVersion))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Security.Tokens.SecureConversationSecurityTokenParameters))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Security.Tokens.SecurityTokenParameters))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Security.Tokens.SupportingTokenParameters))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Security.Tokens.UserNameSecurityTokenParameters))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.Security.TrustVersion))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.SpnEndpointIdentity))]
|
||||
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.ServiceModel.UpnEndpointIdentity))]
|
||||
#endif
|
||||
+1
-1
@@ -285,7 +285,7 @@ all-local $(STD_TARGETS:=-local):
|
||||
@:
|
||||
|
||||
# Files needed to bootstrap C# compiler
|
||||
basic_files = basic.exe mscorlib.dll System.dll System.Xml.dll Mono.Security.dll System.Core.dll
|
||||
basic_files = basic.exe mscorlib.dll System.dll System.Xml.dll Mono.Security.dll System.Core.dll System.Security.dll System.Configuration.dll
|
||||
monolite_files = $(basic_files:%=lib/monolite/%)
|
||||
|
||||
lib/monolite:
|
||||
|
||||
@@ -528,6 +528,23 @@ namespace Microsoft.Build.BuildEngine {
|
||||
throw new InvalidProjectFileException (string.Format ("Invalid static method invocation syntax '{0}'", text.Substring (p)));
|
||||
|
||||
name = text.Substring (p, end - p);
|
||||
|
||||
//
|
||||
// It can be instance member on static property
|
||||
//
|
||||
if (name.IndexOf ('.') > 0) {
|
||||
var names = name.Split ('.');
|
||||
int i;
|
||||
for (i = 0; i < names.Length - 1; ++i) {
|
||||
instance = new MemberInvocationReference (type, names [i]) {
|
||||
Instance = instance
|
||||
};
|
||||
}
|
||||
|
||||
type = null;
|
||||
name = names [i];
|
||||
}
|
||||
|
||||
args = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -160,6 +160,21 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
|
||||
Assert.AreEqual (DateTime.Now.ToString ("yyyy.MM.dd"), proj.GetEvaluatedProperty ("Prop1"), "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InstanceMemberOnStaticProperty ()
|
||||
{
|
||||
string documentString = @"
|
||||
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
|
||||
<PropertyGroup>
|
||||
<Prop1>$([System.DateTime]::Now.Year)</Prop1>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
";
|
||||
|
||||
proj.LoadXml (documentString);
|
||||
Assert.AreEqual (DateTime.Now.Year.ToString (), proj.GetEvaluatedProperty ("Prop1"), "#1");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MSBuildPropertyFunctions ()
|
||||
{
|
||||
|
||||
@@ -37,14 +37,17 @@ using Microsoft.Win32.SafeHandles;
|
||||
namespace Microsoft.Win32.SafeHandles
|
||||
{
|
||||
public sealed class SafeMemoryMappedViewHandle : SafeBuffer {
|
||||
internal SafeMemoryMappedViewHandle (IntPtr handle, long size) : base (true) {
|
||||
this.handle = handle;
|
||||
IntPtr mmap_handle;
|
||||
|
||||
internal SafeMemoryMappedViewHandle (IntPtr mmap_handle, IntPtr base_address, long size) : base (true) {
|
||||
this.mmap_handle = mmap_handle;
|
||||
this.handle = base_address;
|
||||
Initialize ((ulong)size);
|
||||
}
|
||||
|
||||
protected override bool ReleaseHandle () {
|
||||
if (this.handle != (IntPtr) (-1))
|
||||
return MemoryMapImpl.Unmap (this.handle, ByteLength);
|
||||
return MemoryMapImpl.Unmap (this.mmap_handle);
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if NET_4_0
|
||||
|
||||
using System;
|
||||
@@ -33,425 +32,84 @@ using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
#if !MOBILE
|
||||
using Mono.Unix.Native;
|
||||
using Mono.Unix;
|
||||
#else
|
||||
using System.Runtime.CompilerServices;
|
||||
#endif
|
||||
|
||||
|
||||
namespace System.IO.MemoryMappedFiles
|
||||
{
|
||||
#if !MOBILE
|
||||
internal static class MemoryMapImpl {
|
||||
//
|
||||
// Turns the FileMode into the first half of open(2) flags
|
||||
//
|
||||
static OpenFlags ToUnixMode (FileMode mode)
|
||||
{
|
||||
switch (mode){
|
||||
case FileMode.CreateNew:
|
||||
return OpenFlags.O_CREAT | OpenFlags.O_EXCL;
|
||||
|
||||
case FileMode.Create:
|
||||
return OpenFlags.O_CREAT | OpenFlags.O_TRUNC;
|
||||
|
||||
case FileMode.OpenOrCreate:
|
||||
return OpenFlags.O_CREAT;
|
||||
|
||||
case FileMode.Truncate:
|
||||
return OpenFlags.O_TRUNC;
|
||||
|
||||
case FileMode.Append:
|
||||
return OpenFlags.O_APPEND;
|
||||
default:
|
||||
case FileMode.Open:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Turns the MemoryMappedFileAccess into the second half of open(2) flags
|
||||
//
|
||||
static OpenFlags ToUnixMode (MemoryMappedFileAccess access)
|
||||
{
|
||||
switch (access){
|
||||
case MemoryMappedFileAccess.CopyOnWrite:
|
||||
case MemoryMappedFileAccess.ReadWriteExecute:
|
||||
case MemoryMappedFileAccess.ReadWrite:
|
||||
return OpenFlags.O_RDWR;
|
||||
|
||||
case MemoryMappedFileAccess.Write:
|
||||
return OpenFlags.O_WRONLY;
|
||||
|
||||
case MemoryMappedFileAccess.ReadExecute:
|
||||
case MemoryMappedFileAccess.Read:
|
||||
default:
|
||||
return OpenFlags.O_RDONLY;
|
||||
}
|
||||
}
|
||||
|
||||
static MmapProts ToUnixProts (MemoryMappedFileAccess access)
|
||||
{
|
||||
switch (access){
|
||||
case MemoryMappedFileAccess.ReadWrite:
|
||||
return MmapProts.PROT_WRITE | MmapProts.PROT_READ;
|
||||
|
||||
case MemoryMappedFileAccess.Write:
|
||||
return MmapProts.PROT_WRITE;
|
||||
|
||||
case MemoryMappedFileAccess.CopyOnWrite:
|
||||
return MmapProts.PROT_WRITE | MmapProts.PROT_READ;
|
||||
|
||||
case MemoryMappedFileAccess.ReadExecute:
|
||||
return MmapProts.PROT_EXEC;
|
||||
|
||||
case MemoryMappedFileAccess.ReadWriteExecute:
|
||||
return MmapProts.PROT_WRITE | MmapProts.PROT_READ | MmapProts.PROT_EXEC;
|
||||
|
||||
case MemoryMappedFileAccess.Read:
|
||||
default:
|
||||
return MmapProts.PROT_READ;
|
||||
}
|
||||
}
|
||||
|
||||
internal static int Open (string path, FileMode mode, ref long capacity, MemoryMappedFileAccess access)
|
||||
{
|
||||
if (MonoUtil.IsUnix){
|
||||
Stat buf;
|
||||
if (Syscall.stat (path, out buf) == -1)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
|
||||
if (capacity == 0) {
|
||||
// Special files such as FIFOs, sockets, and devices can
|
||||
// have a size of 0. Specifying a capacity for these
|
||||
// also makes little sense, so don't do the check if the
|
||||
// file is one of these.
|
||||
if (buf.st_size == 0 &&
|
||||
(buf.st_mode & (FilePermissions.S_IFCHR |
|
||||
FilePermissions.S_IFBLK |
|
||||
FilePermissions.S_IFIFO |
|
||||
FilePermissions.S_IFSOCK)) == 0) {
|
||||
throw new ArgumentException ("A positive capacity must be specified for a Memory Mapped File backed by an empty file.");
|
||||
}
|
||||
|
||||
capacity = buf.st_size;
|
||||
} else if (capacity < buf.st_size) {
|
||||
throw new ArgumentException ("The capacity may not be smaller than the file size.");
|
||||
}
|
||||
|
||||
int fd = Syscall.open (path, ToUnixMode (mode) | ToUnixMode (access), FilePermissions.DEFFILEMODE);
|
||||
|
||||
if (fd == -1)
|
||||
UnixMarshal.ThrowExceptionForLastError ();
|
||||
return fd;
|
||||
}
|
||||
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
internal static void CloseFD (int fd) {
|
||||
Syscall.close (fd);
|
||||
}
|
||||
|
||||
internal static void Flush (int fd) {
|
||||
if (MonoUtil.IsUnix)
|
||||
Syscall.fsync (fd);
|
||||
else
|
||||
throw new NotImplementedException ("Not implemented on Windows");
|
||||
|
||||
}
|
||||
|
||||
static int pagesize;
|
||||
|
||||
internal static unsafe void Map (int file_handle, long offset, ref long size, MemoryMappedFileAccess access, out IntPtr map_addr, out int offset_diff)
|
||||
{
|
||||
if (!MonoUtil.IsUnix)
|
||||
throw new NotImplementedException ("Not implemented on windows.");
|
||||
|
||||
if (pagesize == 0)
|
||||
pagesize = Syscall.getpagesize ();
|
||||
|
||||
Stat buf;
|
||||
Syscall.fstat (file_handle, out buf);
|
||||
long fsize = buf.st_size;
|
||||
|
||||
if (size == 0 || size > fsize)
|
||||
size = fsize;
|
||||
|
||||
// Align offset
|
||||
long real_offset = offset & ~(pagesize - 1);
|
||||
|
||||
offset_diff = (int)(offset - real_offset);
|
||||
|
||||
// FIXME: Need to determine the unix fd for the file, Handle is only
|
||||
// equal to it by accident
|
||||
//
|
||||
// The new API no longer uses FileStream everywhere, but exposes instead
|
||||
// the filename (with one exception), we could move this API to use
|
||||
// file descriptors instead of the FileStream plus its Handle.
|
||||
//
|
||||
map_addr = Syscall.mmap (IntPtr.Zero, (ulong) size,
|
||||
ToUnixProts (access),
|
||||
access == MemoryMappedFileAccess.CopyOnWrite ? MmapFlags.MAP_PRIVATE : MmapFlags.MAP_SHARED,
|
||||
file_handle, real_offset);
|
||||
|
||||
if (map_addr == (IntPtr)(-1))
|
||||
throw new IOException ("mmap failed for fd#" + file_handle + "(" + offset + ", " + size + ")");
|
||||
}
|
||||
|
||||
internal static bool Unmap (IntPtr map_addr, ulong map_size)
|
||||
{
|
||||
if (!MonoUtil.IsUnix)
|
||||
return false;
|
||||
return Syscall.munmap (map_addr, map_size) == 0;
|
||||
}
|
||||
|
||||
static void ConfigureUnixFD (IntPtr handle, HandleInheritability h)
|
||||
{
|
||||
// TODO: Mono.Posix is lacking O_CLOEXEC definitions for fcntl.
|
||||
}
|
||||
|
||||
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
static extern bool SetHandleInformation (IntPtr hObject, int dwMask, int dwFlags);
|
||||
static void ConfigureWindowsFD (IntPtr handle, HandleInheritability h)
|
||||
{
|
||||
SetHandleInformation (handle, 1 /* FLAG_INHERIT */, h == HandleInheritability.None ? 0 : 1);
|
||||
}
|
||||
|
||||
internal static void ConfigureFD (IntPtr handle, HandleInheritability inheritability)
|
||||
{
|
||||
if (MonoUtil.IsUnix)
|
||||
ConfigureUnixFD (handle, inheritability);
|
||||
else
|
||||
ConfigureWindowsFD (handle, inheritability);
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
internal static class MemoryMapImpl {
|
||||
[DllImport ("libc")]
|
||||
static extern int fsync (int fd);
|
||||
|
||||
[DllImport ("libc")]
|
||||
static extern int close (int fd);
|
||||
|
||||
[DllImport ("libc")]
|
||||
static extern int fcntl (int fd, int cmd, int arg0);
|
||||
|
||||
//XXX check if android off_t is 64bits or not. on iOS / darwin it is.
|
||||
[DllImport ("libc")]
|
||||
static extern IntPtr mmap (IntPtr addr, IntPtr len, int prot, int flags, int fd, long offset);
|
||||
|
||||
[DllImport ("libc")]
|
||||
static extern int munmap (IntPtr addr, IntPtr size);
|
||||
|
||||
[DllImport ("libc", SetLastError=true)]
|
||||
static extern int open (string path, int flags, int access);
|
||||
|
||||
#if MONODROID
|
||||
[DllImport ("__Internal")]
|
||||
static extern int monodroid_getpagesize ();
|
||||
|
||||
static int getpagesize ()
|
||||
{
|
||||
return monodroid_getpagesize ();
|
||||
}
|
||||
#else
|
||||
[DllImport ("libc")]
|
||||
static extern int getpagesize ();
|
||||
#endif
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
static extern IntPtr OpenFileInternal (string path, FileMode mode, string mapName, out long capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, out int error);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
static extern long mono_filesize_from_path (string str);
|
||||
static extern IntPtr OpenHandleInternal (IntPtr handle, string mapName, out long capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, out int error);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
static extern long mono_filesize_from_fd (int fd);
|
||||
internal extern static void CloseMapping (IntPtr handle);
|
||||
|
||||
//Values valid on iOS/OSX and android ndk r6
|
||||
const int F_GETFD = 1;
|
||||
const int F_SETFD = 2;
|
||||
const int FD_CLOEXEC = 1;
|
||||
const int DEFFILEMODE = 0x666;
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
internal extern static void Flush (IntPtr file_handle);
|
||||
|
||||
const int O_RDONLY = 0x0;
|
||||
const int O_WRONLY = 0x1;
|
||||
const int O_RDWR = 0x2;
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
internal extern static void ConfigureHandleInheritability (IntPtr handle, HandleInheritability inheritability);
|
||||
|
||||
const int PROT_READ = 0x1;
|
||||
const int PROT_WRITE = 0x2;
|
||||
const int PROT_EXEC = 0x4;
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
internal extern static bool Unmap (IntPtr mmap_handle);
|
||||
|
||||
const int MAP_PRIVATE = 0x2;
|
||||
const int MAP_SHARED = 0x1;
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
extern static int MapInternal (IntPtr handle, long offset, ref long size, MemoryMappedFileAccess access, out IntPtr mmap_handle, out IntPtr base_address);
|
||||
|
||||
const int EINVAL = 22;
|
||||
|
||||
#if MONODROID
|
||||
const int O_CREAT = 0x040;
|
||||
const int O_TRUNC = 0x080;
|
||||
const int O_EXCL = 0x200;
|
||||
|
||||
const int ENAMETOOLONG = 63;
|
||||
#else
|
||||
/* MONOTOUCH - usr/include/sys/fcntl.h */
|
||||
const int O_CREAT = 0x0200;
|
||||
const int O_TRUNC = 0x0400;
|
||||
const int O_EXCL = 0x0800;
|
||||
|
||||
// usr/include/sys/errno.h
|
||||
const int ENAMETOOLONG = 63;
|
||||
#endif
|
||||
|
||||
static int ToUnixMode (FileMode mode)
|
||||
internal static void Map (IntPtr handle, long offset, ref long size, MemoryMappedFileAccess access, out IntPtr mmap_handle, out IntPtr base_address)
|
||||
{
|
||||
switch (mode) {
|
||||
case FileMode.CreateNew:
|
||||
return O_CREAT | O_EXCL;
|
||||
|
||||
case FileMode.Create:
|
||||
return O_CREAT | O_TRUNC;
|
||||
|
||||
case FileMode.OpenOrCreate:
|
||||
return O_CREAT;
|
||||
|
||||
case FileMode.Truncate:
|
||||
return O_TRUNC;
|
||||
int error = MapInternal (handle, offset, ref size, access, out mmap_handle, out base_address);
|
||||
if (error != 0)
|
||||
throw CreateException (error, "<none>");
|
||||
}
|
||||
|
||||
static Exception CreateException (int error, string path) {
|
||||
switch (error){
|
||||
case 1:
|
||||
return new ArgumentException ("A positive capacity must be specified for a Memory Mapped File backed by an empty file.");
|
||||
case 2:
|
||||
return new ArgumentOutOfRangeException ("The capacity may not be smaller than the file size.");
|
||||
case 3:
|
||||
return new FileNotFoundException (path);
|
||||
case 4:
|
||||
return new IOException ("The file already exists");
|
||||
case 5:
|
||||
return new PathTooLongException ();
|
||||
case 6:
|
||||
return new IOException ("Could not open file");
|
||||
case 7:
|
||||
return new ArgumentException ("Capacity must be bigger than zero for non-file mappings");
|
||||
case 8:
|
||||
return new ArgumentException ("Invalid FileMode value.");
|
||||
case 9:
|
||||
return new IOException ("Could not map file");
|
||||
default:
|
||||
case FileMode.Open:
|
||||
return 0;
|
||||
return new IOException ("Failed with unknown error code " + error);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Turns the MemoryMappedFileAccess into the second half of open(2) flags
|
||||
//
|
||||
static int ToUnixMode (MemoryMappedFileAccess access)
|
||||
internal static IntPtr OpenFile (string path, FileMode mode, string mapName, out long capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options)
|
||||
{
|
||||
switch (access) {
|
||||
case MemoryMappedFileAccess.CopyOnWrite:
|
||||
case MemoryMappedFileAccess.ReadWriteExecute:
|
||||
case MemoryMappedFileAccess.ReadWrite:
|
||||
return O_RDWR;
|
||||
|
||||
case MemoryMappedFileAccess.Write:
|
||||
return O_WRONLY;
|
||||
|
||||
case MemoryMappedFileAccess.ReadExecute:
|
||||
case MemoryMappedFileAccess.Read:
|
||||
default:
|
||||
return O_RDONLY;
|
||||
}
|
||||
int error = 0;
|
||||
IntPtr res = OpenFileInternal (path, mode, mapName, out capacity, access, options, out error);
|
||||
if (error != 0)
|
||||
throw CreateException (error, path);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int ToUnixProts (MemoryMappedFileAccess access)
|
||||
internal static IntPtr OpenHandle (IntPtr handle, string mapName, out long capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options)
|
||||
{
|
||||
switch (access){
|
||||
case MemoryMappedFileAccess.ReadWrite:
|
||||
return PROT_WRITE | PROT_READ;
|
||||
|
||||
case MemoryMappedFileAccess.Write:
|
||||
return PROT_WRITE;
|
||||
|
||||
case MemoryMappedFileAccess.CopyOnWrite:
|
||||
return PROT_WRITE | PROT_READ;
|
||||
|
||||
case MemoryMappedFileAccess.ReadExecute:
|
||||
return PROT_EXEC;
|
||||
|
||||
case MemoryMappedFileAccess.ReadWriteExecute:
|
||||
return PROT_WRITE | PROT_READ | PROT_EXEC;
|
||||
|
||||
case MemoryMappedFileAccess.Read:
|
||||
default:
|
||||
return PROT_READ;
|
||||
}
|
||||
int error = 0;
|
||||
IntPtr res = OpenHandleInternal (handle, mapName, out capacity, access, options, out error);
|
||||
if (error != 0)
|
||||
throw CreateException (error, "<none>");
|
||||
return res;
|
||||
}
|
||||
|
||||
static void ThrowErrorFromErrno (int errno)
|
||||
{
|
||||
switch (errno) {
|
||||
case EINVAL: throw new ArgumentException ();
|
||||
case ENAMETOOLONG: throw new PathTooLongException ();
|
||||
default: throw new IOException ("Failed with errno " + errno);
|
||||
}
|
||||
}
|
||||
|
||||
internal static int Open (string path, FileMode mode, ref long capacity, MemoryMappedFileAccess access)
|
||||
{
|
||||
long file_size = mono_filesize_from_path (path);
|
||||
if (file_size < 0)
|
||||
throw new FileNotFoundException (path);
|
||||
|
||||
if (capacity > file_size)
|
||||
throw new ArgumentException ("capacity");
|
||||
|
||||
int fd = open (path, ToUnixMode (mode) | ToUnixMode (access), DEFFILEMODE);
|
||||
|
||||
if (fd == -1)
|
||||
ThrowErrorFromErrno (Marshal.GetLastWin32Error ());
|
||||
return fd;
|
||||
}
|
||||
|
||||
internal static void CloseFD (int fd)
|
||||
{
|
||||
close (fd);
|
||||
}
|
||||
|
||||
internal static void Flush (int fd)
|
||||
{
|
||||
fsync (fd);
|
||||
}
|
||||
|
||||
internal static bool Unmap (IntPtr map_addr, ulong map_size)
|
||||
{
|
||||
return munmap (map_addr, (IntPtr)map_size) == 0;
|
||||
}
|
||||
|
||||
static int pagesize;
|
||||
|
||||
internal static unsafe void Map (int file_handle, long offset, ref long size, MemoryMappedFileAccess access, out IntPtr map_addr, out int offset_diff)
|
||||
{
|
||||
if (pagesize == 0)
|
||||
pagesize = getpagesize ();
|
||||
|
||||
long fsize = mono_filesize_from_fd (file_handle);
|
||||
if (fsize < 0)
|
||||
throw new FileNotFoundException ();
|
||||
|
||||
if (size == 0 || size > fsize)
|
||||
size = fsize;
|
||||
|
||||
// Align offset
|
||||
long real_offset = offset & ~(pagesize - 1);
|
||||
|
||||
offset_diff = (int)(offset - real_offset);
|
||||
|
||||
map_addr = mmap (IntPtr.Zero, (IntPtr) size,
|
||||
ToUnixProts (access),
|
||||
access == MemoryMappedFileAccess.CopyOnWrite ? MAP_PRIVATE : MAP_SHARED,
|
||||
file_handle, real_offset);
|
||||
|
||||
if (map_addr == (IntPtr)(-1))
|
||||
throw new IOException ("mmap failed for fd#" + file_handle + "(" + offset + ", " + size + ")");
|
||||
}
|
||||
|
||||
internal static void ConfigureFD (IntPtr handle, HandleInheritability inheritability)
|
||||
{
|
||||
int fd = (int)handle;
|
||||
int flags = fcntl (fd, F_GETFD, 0);
|
||||
if (inheritability == HandleInheritability.None)
|
||||
flags &= ~FD_CLOEXEC;
|
||||
else
|
||||
flags |= FD_CLOEXEC;
|
||||
fcntl (fd, F_SETFD, flags);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
public class MemoryMappedFile : IDisposable {
|
||||
MemoryMappedFileAccess fileAccess;
|
||||
@@ -466,7 +124,7 @@ namespace System.IO.MemoryMappedFiles
|
||||
//
|
||||
FileStream stream;
|
||||
bool keepOpen;
|
||||
int unix_fd;
|
||||
IntPtr handle;
|
||||
|
||||
public static MemoryMappedFile CreateFromFile (string path)
|
||||
{
|
||||
@@ -475,7 +133,21 @@ namespace System.IO.MemoryMappedFiles
|
||||
|
||||
public static MemoryMappedFile CreateFromFile (string path, FileMode mode)
|
||||
{
|
||||
return CreateFromFile (path, mode, null, 0, MemoryMappedFileAccess.ReadWrite);
|
||||
long capacity = 0;
|
||||
if (path == null)
|
||||
throw new ArgumentNullException ("path");
|
||||
if (path.Length == 0)
|
||||
throw new ArgumentException ("path");
|
||||
if (mode == FileMode.Append)
|
||||
throw new ArgumentException ("mode");
|
||||
|
||||
IntPtr handle = MemoryMapImpl.OpenFile (path, mode, null, out capacity, MemoryMappedFileAccess.ReadWrite, MemoryMappedFileOptions.DelayAllocatePages);
|
||||
|
||||
return new MemoryMappedFile () {
|
||||
handle = handle,
|
||||
fileAccess = MemoryMappedFileAccess.ReadWrite,
|
||||
fileCapacity = capacity
|
||||
};
|
||||
}
|
||||
|
||||
public static MemoryMappedFile CreateFromFile (string path, FileMode mode, string mapName)
|
||||
@@ -501,26 +173,21 @@ namespace System.IO.MemoryMappedFiles
|
||||
if (capacity < 0)
|
||||
throw new ArgumentOutOfRangeException ("capacity");
|
||||
|
||||
int fd = MemoryMapImpl.Open (path, mode, ref capacity, access);
|
||||
IntPtr handle = MemoryMapImpl.OpenFile (path, mode, mapName, out capacity, access, MemoryMappedFileOptions.DelayAllocatePages);
|
||||
|
||||
return new MemoryMappedFile () {
|
||||
unix_fd = fd,
|
||||
handle = handle,
|
||||
fileAccess = access,
|
||||
name = mapName,
|
||||
fileCapacity = capacity
|
||||
};
|
||||
}
|
||||
|
||||
#if MOBILE
|
||||
public static MemoryMappedFile CreateFromFile (FileStream fileStream, string mapName, long capacity, MemoryMappedFileAccess access,
|
||||
HandleInheritability inheritability,
|
||||
bool leaveOpen)
|
||||
#else
|
||||
|
||||
[MonoLimitation ("memoryMappedFileSecurity is currently ignored")]
|
||||
public static MemoryMappedFile CreateFromFile (FileStream fileStream, string mapName, long capacity, MemoryMappedFileAccess access,
|
||||
MemoryMappedFileSecurity memoryMappedFileSecurity, HandleInheritability inheritability,
|
||||
bool leaveOpen)
|
||||
#endif
|
||||
{
|
||||
if (fileStream == null)
|
||||
throw new ArgumentNullException ("fileStream");
|
||||
@@ -529,86 +196,92 @@ namespace System.IO.MemoryMappedFiles
|
||||
if ((!MonoUtil.IsUnix && capacity == 0 && fileStream.Length == 0) || (capacity > fileStream.Length))
|
||||
throw new ArgumentException ("capacity");
|
||||
|
||||
MemoryMapImpl.ConfigureFD (fileStream.Handle, inheritability);
|
||||
IntPtr handle = MemoryMapImpl.OpenHandle (fileStream.Handle, mapName, out capacity, access, MemoryMappedFileOptions.DelayAllocatePages);
|
||||
|
||||
MemoryMapImpl.ConfigureHandleInheritability (handle, inheritability);
|
||||
|
||||
return new MemoryMappedFile () {
|
||||
stream = fileStream,
|
||||
handle = handle,
|
||||
fileAccess = access,
|
||||
name = mapName,
|
||||
fileCapacity = capacity,
|
||||
|
||||
stream = fileStream,
|
||||
keepOpen = leaveOpen
|
||||
};
|
||||
}
|
||||
|
||||
[MonoLimitation ("CreateNew requires that mapName be a file name on Unix")]
|
||||
|
||||
static MemoryMappedFile CoreShmCreate (string mapName, long capacity, MemoryMappedFileAccess access,
|
||||
MemoryMappedFileOptions options, MemoryMappedFileSecurity memoryMappedFileSecurity,
|
||||
HandleInheritability inheritability, FileMode mode)
|
||||
{
|
||||
if (mapName != null && mapName.Length == 0)
|
||||
throw new ArgumentException ("mapName");
|
||||
if (capacity < 0)
|
||||
throw new ArgumentOutOfRangeException ("capacity");
|
||||
|
||||
IntPtr handle = MemoryMapImpl.OpenFile (null, mode, mapName, out capacity, access, options);
|
||||
|
||||
return new MemoryMappedFile () {
|
||||
handle = handle,
|
||||
fileAccess = access,
|
||||
name = mapName,
|
||||
fileCapacity = capacity
|
||||
};
|
||||
}
|
||||
|
||||
[MonoLimitation ("Named mappings scope is process local")]
|
||||
public static MemoryMappedFile CreateNew (string mapName, long capacity)
|
||||
{
|
||||
#if MOBILE
|
||||
return CreateNew (mapName, capacity, MemoryMappedFileAccess.ReadWrite, MemoryMappedFileOptions.DelayAllocatePages, 0);
|
||||
#else
|
||||
return CreateNew (mapName, capacity, MemoryMappedFileAccess.ReadWrite, MemoryMappedFileOptions.DelayAllocatePages, null, 0);
|
||||
#endif
|
||||
return CreateNew (mapName, capacity, MemoryMappedFileAccess.ReadWrite, MemoryMappedFileOptions.DelayAllocatePages, null, HandleInheritability.None);
|
||||
}
|
||||
|
||||
[MonoLimitation ("CreateNew requires that mapName be a file name on Unix")]
|
||||
[MonoLimitation ("Named mappings scope is process local")]
|
||||
public static MemoryMappedFile CreateNew (string mapName, long capacity, MemoryMappedFileAccess access)
|
||||
{
|
||||
#if MOBILE
|
||||
return CreateNew (mapName, capacity, access, MemoryMappedFileOptions.DelayAllocatePages, 0);
|
||||
#else
|
||||
return CreateNew (mapName, capacity, access, MemoryMappedFileOptions.DelayAllocatePages, null, 0);
|
||||
#endif
|
||||
return CreateNew (mapName, capacity, access, MemoryMappedFileOptions.DelayAllocatePages, null, HandleInheritability.None);
|
||||
}
|
||||
|
||||
#if MOBILE
|
||||
public static MemoryMappedFile CreateNew (string mapName, long capacity, MemoryMappedFileAccess access,
|
||||
MemoryMappedFileOptions options,
|
||||
HandleInheritability handleInheritability)
|
||||
#else
|
||||
[MonoLimitation ("CreateNew requires that mapName be a file name on Unix; options and memoryMappedFileSecurity are ignored")]
|
||||
[MonoLimitation ("Named mappings scope is process local; options and memoryMappedFileSecurity are ignored")]
|
||||
public static MemoryMappedFile CreateNew (string mapName, long capacity, MemoryMappedFileAccess access,
|
||||
MemoryMappedFileOptions options, MemoryMappedFileSecurity memoryMappedFileSecurity,
|
||||
HandleInheritability inheritability)
|
||||
#endif
|
||||
{
|
||||
return CreateFromFile (mapName, FileMode.CreateNew, mapName, capacity, access);
|
||||
return CoreShmCreate (mapName, capacity, access, options, memoryMappedFileSecurity, inheritability, FileMode.CreateNew);
|
||||
}
|
||||
|
||||
[MonoLimitation ("CreateOrOpen requires that mapName be a file name on Unix")]
|
||||
[MonoLimitation ("Named mappings scope is process local")]
|
||||
public static MemoryMappedFile CreateOrOpen (string mapName, long capacity)
|
||||
{
|
||||
return CreateOrOpen (mapName, capacity, MemoryMappedFileAccess.ReadWrite);
|
||||
}
|
||||
|
||||
[MonoLimitation ("CreateOrOpen requires that mapName be a file name on Unix")]
|
||||
[MonoLimitation ("Named mappings scope is process local")]
|
||||
public static MemoryMappedFile CreateOrOpen (string mapName, long capacity, MemoryMappedFileAccess access)
|
||||
{
|
||||
return CreateFromFile (mapName, FileMode.OpenOrCreate, mapName, capacity, access);
|
||||
return CreateOrOpen (mapName, capacity, access, MemoryMappedFileOptions.DelayAllocatePages, null, HandleInheritability.None);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
#if MOBILE
|
||||
public static MemoryMappedFile CreateOrOpen (string mapName, long capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, HandleInheritability inheritability)
|
||||
#else
|
||||
[MonoLimitation ("Named mappings scope is process local")]
|
||||
public static MemoryMappedFile CreateOrOpen (string mapName, long capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, MemoryMappedFileSecurity memoryMappedFileSecurity, HandleInheritability inheritability)
|
||||
#endif
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return CoreShmCreate (mapName, capacity, access, options, memoryMappedFileSecurity, inheritability, FileMode.OpenOrCreate);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
[MonoLimitation ("Named mappings scope is process local")]
|
||||
public static MemoryMappedFile OpenExisting (string mapName)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
[MonoLimitation ("Named mappings scope is process local")]
|
||||
public static MemoryMappedFile OpenExisting (string mapName, MemoryMappedFileRights desiredAccessRights)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
[MonoLimitation ("Named mappings scope is process local")]
|
||||
public static MemoryMappedFile OpenExisting (string mapName, MemoryMappedFileRights desiredAccessRights, HandleInheritability inheritability)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
@@ -616,7 +289,7 @@ namespace System.IO.MemoryMappedFiles
|
||||
|
||||
public MemoryMappedViewStream CreateViewStream ()
|
||||
{
|
||||
return CreateViewStream (0, 0);
|
||||
return CreateViewStream (0, 0);//FIXME this is wrong
|
||||
}
|
||||
|
||||
public MemoryMappedViewStream CreateViewStream (long offset, long size)
|
||||
@@ -626,7 +299,7 @@ namespace System.IO.MemoryMappedFiles
|
||||
|
||||
public MemoryMappedViewStream CreateViewStream (long offset, long size, MemoryMappedFileAccess access)
|
||||
{
|
||||
return new MemoryMappedViewStream (stream != null ? (int)stream.Handle : unix_fd, offset, size, access);
|
||||
return new MemoryMappedViewStream (handle, offset, size, access);
|
||||
}
|
||||
|
||||
public MemoryMappedViewAccessor CreateViewAccessor ()
|
||||
@@ -641,9 +314,7 @@ namespace System.IO.MemoryMappedFiles
|
||||
|
||||
public MemoryMappedViewAccessor CreateViewAccessor (long offset, long size, MemoryMappedFileAccess access)
|
||||
{
|
||||
int file_handle = stream != null ? (int) stream.Handle : unix_fd;
|
||||
|
||||
return new MemoryMappedViewAccessor (file_handle, offset, size, access);
|
||||
return new MemoryMappedViewAccessor (handle, offset, size, access);
|
||||
}
|
||||
|
||||
MemoryMappedFile ()
|
||||
@@ -661,17 +332,15 @@ namespace System.IO.MemoryMappedFiles
|
||||
if (stream != null){
|
||||
if (keepOpen == false)
|
||||
stream.Close ();
|
||||
unix_fd = -1;
|
||||
stream = null;
|
||||
}
|
||||
if (unix_fd != -1) {
|
||||
MemoryMapImpl.CloseFD (unix_fd);
|
||||
unix_fd = -1;
|
||||
if (handle != IntPtr.Zero) {
|
||||
MemoryMapImpl.CloseMapping (handle);
|
||||
handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
[MonoTODO]
|
||||
public MemoryMappedFileSecurity GetAccessControl ()
|
||||
{
|
||||
@@ -683,7 +352,6 @@ namespace System.IO.MemoryMappedFiles
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
#endif
|
||||
|
||||
[MonoTODO]
|
||||
public SafeMemoryMappedFileHandle SafeMemoryMappedFileHandle {
|
||||
|
||||
@@ -36,14 +36,12 @@ using Microsoft.Win32.SafeHandles;
|
||||
namespace System.IO.MemoryMappedFiles
|
||||
{
|
||||
public sealed class MemoryMappedViewAccessor : UnmanagedMemoryAccessor, IDisposable {
|
||||
int file_handle;
|
||||
IntPtr mmap_addr;
|
||||
SafeMemoryMappedViewHandle handle;
|
||||
IntPtr mmap_handle;
|
||||
SafeMemoryMappedViewHandle safe_handle;
|
||||
|
||||
internal MemoryMappedViewAccessor (int file_handle, long offset, long size, MemoryMappedFileAccess access)
|
||||
internal MemoryMappedViewAccessor (IntPtr handle, long offset, long size, MemoryMappedFileAccess access)
|
||||
{
|
||||
this.file_handle = file_handle;
|
||||
Create (offset, size, access);
|
||||
Create (handle, offset, size, access);
|
||||
}
|
||||
|
||||
static FileAccess ToFileAccess (MemoryMappedFileAccess access)
|
||||
@@ -64,19 +62,19 @@ namespace System.IO.MemoryMappedFiles
|
||||
}
|
||||
}
|
||||
|
||||
unsafe void Create (long offset, long size, MemoryMappedFileAccess access)
|
||||
unsafe void Create (IntPtr handle, long offset, long size, MemoryMappedFileAccess access)
|
||||
{
|
||||
int offset_diff;
|
||||
IntPtr base_address;
|
||||
|
||||
MemoryMapImpl.Map (file_handle, offset, ref size, access, out mmap_addr, out offset_diff);
|
||||
MemoryMapImpl.Map (handle, offset, ref size, access, out mmap_handle, out base_address);
|
||||
safe_handle = new SafeMemoryMappedViewHandle (mmap_handle, base_address, size);
|
||||
|
||||
handle = new SafeMemoryMappedViewHandle ((IntPtr)((long)mmap_addr + offset_diff), size);
|
||||
Initialize (handle, 0, size, ToFileAccess (access));
|
||||
Initialize (safe_handle, 0, size, ToFileAccess (access));
|
||||
}
|
||||
|
||||
public SafeMemoryMappedViewHandle SafeMemoryMappedViewHandle {
|
||||
get {
|
||||
return handle;
|
||||
return safe_handle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +89,7 @@ namespace System.IO.MemoryMappedFiles
|
||||
|
||||
public void Flush ()
|
||||
{
|
||||
MemoryMapImpl.Flush (file_handle);
|
||||
MemoryMapImpl.Flush (mmap_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +35,12 @@ using Microsoft.Win32.SafeHandles;
|
||||
namespace System.IO.MemoryMappedFiles
|
||||
{
|
||||
public sealed class MemoryMappedViewStream : UnmanagedMemoryStream {
|
||||
IntPtr mmap_addr;
|
||||
ulong mmap_size;
|
||||
IntPtr mmap_handle;
|
||||
object monitor;
|
||||
int fd;
|
||||
|
||||
internal MemoryMappedViewStream (int fd, long offset, long size, MemoryMappedFileAccess access) {
|
||||
this.fd = fd;
|
||||
internal MemoryMappedViewStream (IntPtr handle, long offset, long size, MemoryMappedFileAccess access) {
|
||||
monitor = new Object ();
|
||||
CreateStream (fd, offset, size, access);
|
||||
CreateStream (handle, offset, size, access);
|
||||
}
|
||||
|
||||
public SafeMemoryMappedViewHandle SafeMemoryMappedViewHandle {
|
||||
@@ -52,13 +49,13 @@ namespace System.IO.MemoryMappedFiles
|
||||
}
|
||||
}
|
||||
|
||||
unsafe void CreateStream (int fd, long offset, long size, MemoryMappedFileAccess access)
|
||||
unsafe void CreateStream (IntPtr handle, long offset, long size, MemoryMappedFileAccess access)
|
||||
{
|
||||
int offset_diff;
|
||||
mmap_size = (ulong) size;
|
||||
MemoryMapImpl.Map (fd, offset, ref size, access, out mmap_addr, out offset_diff);
|
||||
FileAccess faccess;
|
||||
IntPtr base_address;
|
||||
|
||||
MemoryMapImpl.Map (handle, offset, ref size, access, out mmap_handle, out base_address);
|
||||
|
||||
FileAccess faccess;
|
||||
switch (access) {
|
||||
case MemoryMappedFileAccess.ReadWrite:
|
||||
faccess = FileAccess.ReadWrite;
|
||||
@@ -72,23 +69,23 @@ namespace System.IO.MemoryMappedFiles
|
||||
default:
|
||||
throw new NotImplementedException ("access mode " + access + " not supported.");
|
||||
}
|
||||
Initialize ((byte*)mmap_addr + offset_diff, size, size, faccess);
|
||||
Initialize ((byte*)base_address, size, size, faccess);
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
base.Dispose (disposing);
|
||||
lock (monitor) {
|
||||
if (mmap_addr != (IntPtr)(-1)) {
|
||||
MemoryMapImpl.Unmap (mmap_addr, mmap_size);
|
||||
mmap_addr = (IntPtr)(-1);
|
||||
if (mmap_handle != (IntPtr)(-1)) {
|
||||
MemoryMapImpl.Unmap (mmap_handle);
|
||||
mmap_handle = (IntPtr)(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Flush ()
|
||||
{
|
||||
MemoryMapImpl.Flush (fd);
|
||||
MemoryMapImpl.Flush (mmap_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,13 @@ namespace MonoTests.System.IO.MemoryMappedFiles {
|
||||
Assert.IsTrue (thrown);
|
||||
}
|
||||
|
||||
static int named_index;
|
||||
static String MkNamedMapping ()
|
||||
{
|
||||
return "test-" + named_index++;
|
||||
}
|
||||
|
||||
|
||||
static string tempDir = Path.Combine (Path.GetTempPath (), typeof (MemoryMappedFileTest).FullName);
|
||||
|
||||
string fname;
|
||||
@@ -92,6 +99,43 @@ namespace MonoTests.System.IO.MemoryMappedFiles {
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateNew ()
|
||||
{
|
||||
// This must succeed
|
||||
MemoryMappedFile.CreateNew (Path.Combine (tempDir, "createNew.test"), 8192);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (IOException))]
|
||||
public void CreateNew_OnExistingFile ()
|
||||
{
|
||||
// This must succeed
|
||||
MemoryMappedFile.CreateNew (Path.Combine (tempDir, "createNew.test"), 8192);
|
||||
|
||||
// This should fail, the file exists
|
||||
MemoryMappedFile.CreateNew (Path.Combine (tempDir, "createNew.test"), 8192);
|
||||
}
|
||||
|
||||
// Call this twice, it should always work
|
||||
[Test]
|
||||
public void CreateOrOpen_Multiple ()
|
||||
{
|
||||
MemoryMappedFile.CreateOrOpen (Path.Combine (tempDir, "createOrOpen.test"), 8192);
|
||||
MemoryMappedFile.CreateOrOpen (Path.Combine (tempDir, "createOrOpen.test"), 8192);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void CreateFromFileWithSmallerCapacityThanFile ()
|
||||
{
|
||||
var f = Path.Combine (tempDir, "8192-file");
|
||||
File.WriteAllBytes (f, new byte [8192]);
|
||||
|
||||
// We are requesting fewer bytes to map.
|
||||
MemoryMappedFile.CreateFromFile (f, FileMode.Open, "myMap", 4192);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateFromFile_Null () {
|
||||
AssertThrows<ArgumentNullException> (delegate () {
|
||||
@@ -169,6 +213,109 @@ namespace MonoTests.System.IO.MemoryMappedFiles {
|
||||
Assert.AreEqual ("Hello", s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void NamedMappingToInvalidFile ()
|
||||
{
|
||||
var fileName = Path.Combine (tempDir, "temp_file_123");
|
||||
if (File.Exists (fileName))
|
||||
File.Delete (fileName);
|
||||
var memoryMappedFile90 = MemoryMappedFile.CreateNew (fileName, 4194304, MemoryMappedFileAccess.ReadWrite);
|
||||
memoryMappedFile90.CreateViewStream (4186112, 3222, MemoryMappedFileAccess.Write);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateTheSameAreaTwiceShouldFail ()
|
||||
{
|
||||
var name = MkNamedMapping ();
|
||||
using (var m0 = MemoryMappedFile.CreateNew(name, 4096, MemoryMappedFileAccess.ReadWrite)) {
|
||||
try {
|
||||
using (var m1 = MemoryMappedFile.CreateNew (name, 4096, MemoryMappedFileAccess.ReadWrite)) {
|
||||
Assert.Fail ("Must fail");
|
||||
}
|
||||
} catch (IOException) {}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MapAFileToAMemoryAreaShouldFail ()
|
||||
{
|
||||
var name = MkNamedMapping ();
|
||||
using (var m0 = MemoryMappedFile.CreateNew(name, 4096, MemoryMappedFileAccess.ReadWrite)) {
|
||||
try {
|
||||
using (var m1 = MemoryMappedFile.CreateFromFile (fname, FileMode.OpenOrCreate, name)) {
|
||||
Assert.Fail ("Must fail");
|
||||
}
|
||||
} catch (IOException) {}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NamedMappingsShareMemoryArea ()
|
||||
{
|
||||
var name = MkNamedMapping ();
|
||||
using (var m0 = MemoryMappedFile.CreateNew(name, 4096, MemoryMappedFileAccess.ReadWrite)) {
|
||||
using (var m1 = MemoryMappedFile.CreateOrOpen (name, 4096, MemoryMappedFileAccess.ReadWrite)) {
|
||||
using (MemoryMappedViewAccessor v0 = m0.CreateViewAccessor (), v1 = m1.CreateViewAccessor ()) {
|
||||
v0.Write (10, 0x12345);
|
||||
Assert.AreEqual (0x12345, v1.ReadInt32 (10));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NamedFileCanBeOpen ()
|
||||
{
|
||||
var name = MkNamedMapping ();
|
||||
using (var sw = new FileStream (fname, FileMode.Open)) {
|
||||
byte[] b = new byte[20];
|
||||
for (int i = 0; i < 20; ++i)
|
||||
b[i] = 0xFF;
|
||||
sw.Write (b, 0, 20);
|
||||
}
|
||||
|
||||
using (var m0 = MemoryMappedFile.CreateFromFile (fname, FileMode.Open, name)) {
|
||||
using (var m1 = MemoryMappedFile.CreateOrOpen (name, 4096)) {
|
||||
using (MemoryMappedViewAccessor v0 = m0.CreateViewAccessor (), v1 = m1.CreateViewAccessor ()) {
|
||||
v0.Write (10, 0x11223344);
|
||||
Assert.AreEqual (0x11223344, v1.ReadInt32 (10));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MapAtEdgeOfPage ()
|
||||
{
|
||||
using (var f = new FileStream (fname, FileMode.Open)) {
|
||||
var b = new byte [4096];
|
||||
for (int i = 0; i < 4096; ++i)
|
||||
b[i] = 0xAA;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
f.Write (b, 0, 4096);
|
||||
}
|
||||
var m0 = MemoryMappedFile.CreateFromFile (fname, FileMode.Open);
|
||||
var v0 = m0.CreateViewAccessor (500, 4096);
|
||||
var v1 = m0.CreateViewAccessor (0, 4096 * 2);
|
||||
for (int i = 0; i < 4096; ++i) {
|
||||
Assert.AreEqual (0xAA, v1.ReadByte (i + 500));
|
||||
v0.Write (i, (byte)0xFF);
|
||||
Assert.AreEqual (0xFF, v1.ReadByte (i + 500));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DoubleAccountingInOffsetCalculation ()
|
||||
{
|
||||
var memoryMappedFile90 = MemoryMappedFile.CreateNew (MkNamedMapping (), 4194304, MemoryMappedFileAccess.ReadWrite);
|
||||
var stream = memoryMappedFile90.CreateViewStream (4186112, 3222, MemoryMappedFileAccess.Write);
|
||||
using (var tw = new StreamWriter(stream))
|
||||
{
|
||||
tw.WriteLine ("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ System.IO.MemoryMappedFiles/MemoryMappedFile.cs
|
||||
System.IO.MemoryMappedFiles/MemoryMappedFileAccess.cs
|
||||
System.IO.MemoryMappedFiles/MemoryMappedFileOptions.cs
|
||||
System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs
|
||||
System.IO.MemoryMappedFiles/MemoryMappedFileSecurity.cs
|
||||
System.IO.MemoryMappedFiles/MemoryMappedViewStream.cs
|
||||
System.IO.MemoryMappedFiles/MemoryMappedViewAccessor.cs
|
||||
Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs
|
||||
|
||||
@@ -327,6 +327,11 @@ namespace System.Net.Http
|
||||
|
||||
var stream = await wrequest.GetRequestStreamAsync ().ConfigureAwait (false);
|
||||
await request.Content.CopyToAsync (stream).ConfigureAwait (false);
|
||||
} else if (HttpMethod.Post.Equals (request.Method) || HttpMethod.Put.Equals (request.Method) || HttpMethod.Delete.Equals (request.Method)) {
|
||||
// Explicitly set this to make sure we're sending a "Content-Length: 0" header.
|
||||
// This fixes the issue that's been reported on the forums:
|
||||
// http://forums.xamarin.com/discussion/17770/length-required-error-in-http-post-since-latest-release
|
||||
wrequest.ContentLength = 0;
|
||||
}
|
||||
|
||||
HttpWebResponse wresponse = null;
|
||||
|
||||
@@ -533,6 +533,38 @@ namespace MonoTests.System.Net.Http
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Send_Complete_NoContent ()
|
||||
{
|
||||
foreach (var method in new HttpMethod[] { HttpMethod.Post, HttpMethod.Put, HttpMethod.Delete }) {
|
||||
bool? failed = null;
|
||||
var listener = CreateListener (l => {
|
||||
try {
|
||||
var request = l.Request;
|
||||
|
||||
Assert.AreEqual (2, request.Headers.Count, "#1");
|
||||
Assert.AreEqual ("0", request.Headers ["Content-Length"], "#1b");
|
||||
Assert.AreEqual (method.Method, request.HttpMethod, "#2");
|
||||
failed = false;
|
||||
} catch {
|
||||
failed = true;
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
var client = new HttpClient ();
|
||||
var request = new HttpRequestMessage (method, LocalServer);
|
||||
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
|
||||
|
||||
Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
|
||||
Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#101");
|
||||
Assert.AreEqual (false, failed, "#102");
|
||||
} finally {
|
||||
listener.Close ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Send_Complete_Error ()
|
||||
{
|
||||
|
||||
@@ -248,7 +248,14 @@ namespace System.ComponentModel {
|
||||
|
||||
void Item_PropertyChanged (object item, PropertyChangedEventArgs args)
|
||||
{
|
||||
OnListChanged (new ListChangedEventArgs (ListChangedType.ItemChanged, base.IndexOf ((T) item)) );
|
||||
var property_info = item.GetType ().GetProperty (args.PropertyName);
|
||||
|
||||
if (property_info != null) {
|
||||
OnListChanged (new ListChangedEventArgs (ListChangedType.ItemChanged, base.IndexOf ((T) item),
|
||||
new ReflectionPropertyDescriptor (property_info)) );
|
||||
} else {
|
||||
OnListChanged (new ListChangedEventArgs (ListChangedType.ItemChanged, base.IndexOf ((T) item)) );
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnAddingNew (AddingNewEventArgs e)
|
||||
|
||||
@@ -264,7 +264,6 @@ namespace System.Net
|
||||
throw new ArgumentException ("value");
|
||||
|
||||
maxServicePoints = value;
|
||||
RecycleServicePoints ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,9 +328,6 @@ namespace System.Net
|
||||
if (address == null)
|
||||
throw new ArgumentNullException ("address");
|
||||
|
||||
if ((servicePoints.Count % 4) == 0)
|
||||
RecycleServicePoints ();
|
||||
|
||||
var origAddress = new Uri (address.Scheme + "://" + address.Authority);
|
||||
|
||||
bool usesProxy = false;
|
||||
@@ -378,41 +374,6 @@ namespace System.Net
|
||||
return sp;
|
||||
}
|
||||
|
||||
// Internal Methods
|
||||
|
||||
static void RecycleServicePoints ()
|
||||
{
|
||||
lock (servicePoints) {
|
||||
var toRemove = new ArrayList ();
|
||||
var idleList = new SortedDictionary<DateTime, ServicePoint> ();
|
||||
IDictionaryEnumerator e = servicePoints.GetEnumerator ();
|
||||
while (e.MoveNext ()) {
|
||||
ServicePoint sp = (ServicePoint) e.Value;
|
||||
DateTime idleSince;
|
||||
if (sp.CheckAvailableForRecycling (out idleSince)) {
|
||||
toRemove.Add (e.Key);
|
||||
continue;
|
||||
}
|
||||
|
||||
while (idleList.ContainsKey (idleSince))
|
||||
idleSince = idleSince.AddMilliseconds (1);
|
||||
idleList.Add (idleSince, sp);
|
||||
}
|
||||
|
||||
for (int i = 0; i < toRemove.Count; i++)
|
||||
servicePoints.Remove (toRemove [i]);
|
||||
|
||||
if (maxServicePoints == 0 || servicePoints.Count <= maxServicePoints)
|
||||
return;
|
||||
|
||||
// get rid of the ones with the longest idle time
|
||||
foreach (var sp in idleList.Values) {
|
||||
if (servicePoints.Count <= maxServicePoints)
|
||||
break;
|
||||
servicePoints.Remove (sp);
|
||||
}
|
||||
}
|
||||
}
|
||||
#if SECURITY_DEP
|
||||
internal class ChainValidationHelper {
|
||||
object sender;
|
||||
|
||||
@@ -159,18 +159,10 @@ namespace System.Net
|
||||
{
|
||||
if (!callbackDone && cb != null) {
|
||||
callbackDone = true;
|
||||
// if (true || synch)
|
||||
cb (this);
|
||||
// else
|
||||
// ThreadPool.QueueUserWorkItem (CB, null);
|
||||
cb (this);
|
||||
}
|
||||
}
|
||||
|
||||
void CB (object unused)
|
||||
{
|
||||
cb (this);
|
||||
}
|
||||
|
||||
internal void WaitUntilComplete ()
|
||||
{
|
||||
if (IsCompleted)
|
||||
|
||||
@@ -70,14 +70,16 @@ namespace System.Net
|
||||
//TODO: abort requests or wait for them to finish
|
||||
lock (sPoint) {
|
||||
closing = true;
|
||||
foreach (var cnc in connections) {
|
||||
if (cnc.Connection == null)
|
||||
continue;
|
||||
cnc.Connection.Close (false);
|
||||
cnc.Connection = null;
|
||||
var iter = connections.First;
|
||||
while (iter != null) {
|
||||
var cnc = iter.Value.Connection;
|
||||
var node = iter;
|
||||
iter = iter.Next;
|
||||
|
||||
connections.Remove (node);
|
||||
cnc.Close (false);
|
||||
OnConnectionClosed ();
|
||||
}
|
||||
connections.Clear ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +122,7 @@ namespace System.Net
|
||||
ConnectionState FindIdleConnection ()
|
||||
{
|
||||
foreach (var cnc in connections) {
|
||||
if (cnc.Busy || cnc.Connection == null)
|
||||
if (cnc.Busy)
|
||||
continue;
|
||||
|
||||
connections.Remove (cnc);
|
||||
@@ -140,7 +142,7 @@ namespace System.Net
|
||||
return cnc.Connection;
|
||||
}
|
||||
|
||||
if (sPoint.ConnectionLimit > connections.Count) {
|
||||
if (sPoint.ConnectionLimit > connections.Count || connections.Count == 0) {
|
||||
created = true;
|
||||
cnc = new ConnectionState (this);
|
||||
connections.AddFirst (cnc);
|
||||
@@ -177,14 +179,11 @@ namespace System.Net
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (var node = connections.First; node != null; node = node.Next) {
|
||||
var cnc = node.Value;
|
||||
|
||||
if (cnc.Connection == null) {
|
||||
connections.Remove (node);
|
||||
OnConnectionClosed ();
|
||||
continue;
|
||||
}
|
||||
var iter = connections.First;
|
||||
while (iter != null) {
|
||||
var cnc = iter.Value;
|
||||
var node = iter;
|
||||
iter = iter.Next;
|
||||
|
||||
++count;
|
||||
if (cnc.Busy)
|
||||
@@ -205,7 +204,7 @@ namespace System.Net
|
||||
if (connectionsToClose == null)
|
||||
connectionsToClose = new List<WebConnection> ();
|
||||
connectionsToClose.Add (cnc.Connection);
|
||||
cnc.Connection = null;
|
||||
connections.Remove (node);
|
||||
}
|
||||
|
||||
recycled = connections.Count == 0;
|
||||
@@ -224,7 +223,10 @@ namespace System.Net
|
||||
}
|
||||
|
||||
class ConnectionState : IWebConnectionState {
|
||||
public WebConnection Connection;
|
||||
public WebConnection Connection {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public WebConnectionGroup Group {
|
||||
get;
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace System.Security.Claims {
|
||||
|
||||
List<Claim> claims;
|
||||
ClaimsIdentity actor;
|
||||
string auth_type;
|
||||
|
||||
public ClaimsIdentity ()
|
||||
: this (claims: null, authenticationType: null, nameType: null, roleType: null)
|
||||
@@ -69,12 +70,12 @@ namespace System.Security.Claims {
|
||||
{
|
||||
claims = claims == null ? new List<Claim> (): new List<Claim> (claims);
|
||||
|
||||
AuthenticationType = authenticationType;
|
||||
|
||||
// Special case: if empty, set to null.
|
||||
if (authenticationType == "")
|
||||
AuthenticationType = null;
|
||||
|
||||
auth_type = null;
|
||||
else
|
||||
auth_type = authenticationType;
|
||||
|
||||
NameClaimType = nameType == null ? DefaultNameClaimType : nameType;
|
||||
RoleClaimType = roleType == null ? DefaultRoleClaimType : roleType;
|
||||
}
|
||||
@@ -101,7 +102,7 @@ namespace System.Security.Claims {
|
||||
Label = ci.Label;
|
||||
NameClaimType = ci.NameClaimType;
|
||||
RoleClaimType = ci.RoleClaimType;
|
||||
AuthenticationType = ci.AuthenticationType;
|
||||
auth_type = ci.AuthenticationType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +131,11 @@ namespace System.Security.Claims {
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string AuthenticationType { get; private set; }
|
||||
public virtual string AuthenticationType {
|
||||
get {
|
||||
return auth_type;
|
||||
}
|
||||
}
|
||||
public object BootstrapContext { get; set; }
|
||||
public string Label { get; set; }
|
||||
public virtual string Name {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// CS0545: `B.Prop': cannot override because `A.Prop' does not have accessible get accessor
|
||||
// Line: 13
|
||||
|
||||
public class A
|
||||
{
|
||||
public virtual string Prop {
|
||||
set; private get;
|
||||
}
|
||||
}
|
||||
|
||||
public class B : A
|
||||
{
|
||||
sealed override public string Prop {
|
||||
set { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// CS0546: `B.Prop': cannot override because `A.Prop' does not have accessible set accessor
|
||||
// Line: 13
|
||||
|
||||
public class A
|
||||
{
|
||||
public virtual string Prop {
|
||||
get; private set;
|
||||
}
|
||||
}
|
||||
|
||||
public class B : A
|
||||
{
|
||||
sealed override public string Prop {
|
||||
get { return ""; }
|
||||
}
|
||||
}
|
||||
+14
-13
@@ -2610,14 +2610,10 @@ namespace Mono.CSharp
|
||||
public override void FlowAnalysis (FlowAnalysisContext fc)
|
||||
{
|
||||
if ((oper & Operator.LogicalMask) == 0) {
|
||||
var fc_ontrue = fc.DefiniteAssignmentOnTrue;
|
||||
var fc_onfalse = fc.DefiniteAssignmentOnFalse;
|
||||
fc.DefiniteAssignmentOnTrue = fc.DefiniteAssignmentOnFalse = fc.DefiniteAssignment;
|
||||
left.FlowAnalysis (fc);
|
||||
fc.DefiniteAssignmentOnTrue = fc.DefiniteAssignmentOnFalse = fc.DefiniteAssignment;
|
||||
right.FlowAnalysis (fc);
|
||||
fc.DefiniteAssignmentOnTrue = fc_ontrue;
|
||||
fc.DefiniteAssignmentOnFalse = fc_onfalse;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3163,11 +3159,21 @@ namespace Mono.CSharp
|
||||
}
|
||||
public static PredefinedOperator[] CreateStandardLiftedOperatorsTable (ModuleContainer module)
|
||||
{
|
||||
var types = module.Compiler.BuiltinTypes;
|
||||
|
||||
//
|
||||
// Not strictly lifted but need to be in second group otherwise expressions like
|
||||
// int + null would resolve to +(object, string) instead of +(int?, int?)
|
||||
//
|
||||
var string_operators = new [] {
|
||||
new PredefinedStringOperator (types.String, types.Object, Operator.AdditionMask, types.String),
|
||||
new PredefinedStringOperator (types.Object, types.String, Operator.AdditionMask, types.String),
|
||||
};
|
||||
|
||||
var nullable = module.PredefinedTypes.Nullable.TypeSpec;
|
||||
if (nullable == null)
|
||||
return new PredefinedOperator [0];
|
||||
return string_operators;
|
||||
|
||||
var types = module.Compiler.BuiltinTypes;
|
||||
var bool_type = types.Bool;
|
||||
|
||||
var nullable_bool = nullable.MakeGenericType (module, new[] { bool_type });
|
||||
@@ -3202,13 +3208,8 @@ namespace Mono.CSharp
|
||||
new PredefinedOperator (nullable_long, nullable_int, Operator.NullableMask | Operator.ShiftMask),
|
||||
new PredefinedOperator (nullable_ulong, nullable_int, Operator.NullableMask | Operator.ShiftMask),
|
||||
|
||||
//
|
||||
// Not strictly lifted but need to be in second group otherwise expressions like
|
||||
// int + null would resolve to +(object, string) instead of +(int?, int?)
|
||||
//
|
||||
new PredefinedStringOperator (types.String, types.Object, Operator.AdditionMask, types.String),
|
||||
new PredefinedStringOperator (types.Object, types.String, Operator.AdditionMask, types.String),
|
||||
|
||||
string_operators [0],
|
||||
string_operators [1]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+11
-6
@@ -1457,13 +1457,18 @@ namespace Mono.CSharp {
|
||||
if (tp != null)
|
||||
return Inflate (tp);
|
||||
|
||||
var ac = type as ArrayContainer;
|
||||
if (ac != null) {
|
||||
var et = Inflate (ac.Element);
|
||||
if (et != ac.Element)
|
||||
return ArrayContainer.MakeType (context.Module, et, ac.Rank);
|
||||
var ec = type as ElementTypeSpec;
|
||||
if (ec != null) {
|
||||
var et = Inflate (ec.Element);
|
||||
if (et != ec.Element) {
|
||||
var ac = ec as ArrayContainer;
|
||||
if (ac != null)
|
||||
return ArrayContainer.MakeType (context.Module, et, ac.Rank);
|
||||
|
||||
return ac;
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
return ec;
|
||||
}
|
||||
|
||||
if (type.Kind == MemberKind.MissingType)
|
||||
|
||||
+20
-2
@@ -512,7 +512,16 @@ namespace Mono.CSharp
|
||||
// Check base property accessors conflict
|
||||
//
|
||||
var base_prop = (PropertySpec) base_member;
|
||||
if (Get != null) {
|
||||
if (Get == null) {
|
||||
if ((ModFlags & Modifiers.SEALED) != 0 && base_prop.HasGet && !base_prop.Get.IsAccessible (this)) {
|
||||
// TODO: Should be different error code but csc uses for some reason same
|
||||
Report.SymbolRelatedToPreviousError (base_prop);
|
||||
Report.Error (545, Location,
|
||||
"`{0}': cannot override because `{1}' does not have accessible get accessor",
|
||||
GetSignatureForError (), base_prop.GetSignatureForError ());
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
if (!base_prop.HasGet) {
|
||||
if (ok) {
|
||||
Report.SymbolRelatedToPreviousError (base_prop);
|
||||
@@ -529,7 +538,16 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
if (Set != null) {
|
||||
if (Set == null) {
|
||||
if ((ModFlags & Modifiers.SEALED) != 0 && base_prop.HasSet && !base_prop.Set.IsAccessible (this)) {
|
||||
// TODO: Should be different error code but csc uses for some reason same
|
||||
Report.SymbolRelatedToPreviousError (base_prop);
|
||||
Report.Error (546, Location,
|
||||
"`{0}': cannot override because `{1}' does not have accessible set accessor",
|
||||
GetSignatureForError (), base_prop.GetSignatureForError ());
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
if (!base_prop.HasSet) {
|
||||
if (ok) {
|
||||
Report.SymbolRelatedToPreviousError (base_prop);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// Compiler options: -unsafe
|
||||
|
||||
unsafe class X
|
||||
{
|
||||
struct S
|
||||
{
|
||||
}
|
||||
|
||||
public class N<T>
|
||||
{
|
||||
S* s;
|
||||
}
|
||||
}
|
||||
|
||||
public class C
|
||||
{
|
||||
public static void Main ()
|
||||
{
|
||||
new X.N<int> ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
|
||||
class X
|
||||
{
|
||||
public void Test (int g, out int results)
|
||||
{
|
||||
if ((results = Foo (g > 0 ? 1 : 2)) != 4)
|
||||
{
|
||||
Console.WriteLine (results);
|
||||
}
|
||||
}
|
||||
|
||||
int Foo (object o)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public static void Main ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -19137,6 +19137,44 @@
|
||||
</method>
|
||||
</type>
|
||||
</test>
|
||||
<test name="gtest-614.cs">
|
||||
<type name="S">
|
||||
<method name="System.Nullable`1[System.Int32] op_Explicit(System.Nullable`1[S])" attrs="2198">
|
||||
<size>7</size>
|
||||
</method>
|
||||
<method name="Int32 op_Implicit(System.Nullable`1[S])" attrs="2198">
|
||||
<size>10</size>
|
||||
</method>
|
||||
</type>
|
||||
<type name="C">
|
||||
<method name="Int32 Main()" attrs="150">
|
||||
<size>100</size>
|
||||
</method>
|
||||
<method name="Void .ctor()" attrs="6278">
|
||||
<size>7</size>
|
||||
</method>
|
||||
</type>
|
||||
</test>
|
||||
<test name="gtest-615.cs">
|
||||
<type name="X">
|
||||
<method name="Void .ctor()" attrs="6278">
|
||||
<size>7</size>
|
||||
</method>
|
||||
</type>
|
||||
<type name="X+N`1[T]">
|
||||
<method name="Void .ctor()" attrs="6278">
|
||||
<size>7</size>
|
||||
</method>
|
||||
</type>
|
||||
<type name="C">
|
||||
<method name="Void Main()" attrs="150">
|
||||
<size>8</size>
|
||||
</method>
|
||||
<method name="Void .ctor()" attrs="6278">
|
||||
<size>7</size>
|
||||
</method>
|
||||
</type>
|
||||
</test>
|
||||
<test name="gtest-anontype-01.cs">
|
||||
<type name="Test">
|
||||
<method name="Int32 Main()" attrs="150">
|
||||
@@ -49903,6 +49941,42 @@
|
||||
</method>
|
||||
</type>
|
||||
</test>
|
||||
<test name="test-894.cs">
|
||||
<type name="A1Attribute">
|
||||
<method name="Void .ctor()" attrs="6278">
|
||||
<size>7</size>
|
||||
</method>
|
||||
</type>
|
||||
<type name="A2Attribute">
|
||||
<method name="Void .ctor()" attrs="6278">
|
||||
<size>7</size>
|
||||
</method>
|
||||
</type>
|
||||
<type name="Test">
|
||||
<method name="Void Main()" attrs="150">
|
||||
<size>2</size>
|
||||
</method>
|
||||
<method name="Void .ctor()" attrs="6278">
|
||||
<size>7</size>
|
||||
</method>
|
||||
</type>
|
||||
</test>
|
||||
<test name="test-895.cs">
|
||||
<type name="X">
|
||||
<method name="Void Test(Int32, Int32 ByRef)" attrs="134">
|
||||
<size>47</size>
|
||||
</method>
|
||||
<method name="Int32 Foo(System.Object)" attrs="129">
|
||||
<size>10</size>
|
||||
</method>
|
||||
<method name="Void Main()" attrs="150">
|
||||
<size>2</size>
|
||||
</method>
|
||||
<method name="Void .ctor()" attrs="6278">
|
||||
<size>7</size>
|
||||
</method>
|
||||
</type>
|
||||
</test>
|
||||
<test name="test-9.cs">
|
||||
<type name="X">
|
||||
<method name="Int32 Main(System.String[])" attrs="150">
|
||||
|
||||
@@ -191,7 +191,11 @@ common_sources = \
|
||||
verify.c \
|
||||
verify-internals.h \
|
||||
wrapper-types.h \
|
||||
reflection-internals.h
|
||||
reflection-internals.h \
|
||||
file-mmap-posix.c \
|
||||
file-mmap-windows.c \
|
||||
file-mmap.h
|
||||
|
||||
|
||||
# These source files have compile time dependencies on GC code
|
||||
gc_dependent_sources = \
|
||||
|
||||
@@ -375,7 +375,8 @@ boehm_thread_unregister (MonoThreadInfo *p)
|
||||
|
||||
tid = mono_thread_info_get_tid (p);
|
||||
|
||||
mono_threads_add_joinable_thread ((gpointer)tid);
|
||||
if (p->runtime_thread)
|
||||
mono_threads_add_joinable_thread ((gpointer)tid);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
||||
+12
-2
@@ -985,6 +985,16 @@ mono_jit_info_get_try_block_hole_table_info (MonoJitInfo *ji)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
try_block_hole_table_size (MonoJitInfo *ji)
|
||||
{
|
||||
MonoTryBlockHoleTableJitInfo *table;
|
||||
|
||||
table = mono_jit_info_get_try_block_hole_table_info (ji);
|
||||
g_assert (table);
|
||||
return sizeof (MonoTryBlockHoleTableJitInfo) + table->num_holes * sizeof (MonoTryBlockHoleJitInfo);
|
||||
}
|
||||
|
||||
MonoArchEHJitInfo*
|
||||
mono_jit_info_get_arch_eh_info (MonoJitInfo *ji)
|
||||
{
|
||||
@@ -993,7 +1003,7 @@ mono_jit_info_get_arch_eh_info (MonoJitInfo *ji)
|
||||
if (ji->has_generic_jit_info)
|
||||
ptr += sizeof (MonoGenericJitInfo);
|
||||
if (ji->has_try_block_holes)
|
||||
ptr += sizeof (MonoTryBlockHoleTableJitInfo);
|
||||
ptr += try_block_hole_table_size (ji);
|
||||
return (MonoArchEHJitInfo*)ptr;
|
||||
} else {
|
||||
return NULL;
|
||||
@@ -1008,7 +1018,7 @@ mono_jit_info_get_cas_info (MonoJitInfo *ji)
|
||||
if (ji->has_generic_jit_info)
|
||||
ptr += sizeof (MonoGenericJitInfo);
|
||||
if (ji->has_try_block_holes)
|
||||
ptr += sizeof (MonoTryBlockHoleTableJitInfo);
|
||||
ptr += try_block_hole_table_size (ji);
|
||||
if (ji->has_arch_eh_info)
|
||||
ptr += sizeof (MonoArchEHJitInfo);
|
||||
return (MonoMethodCasInfo*)ptr;
|
||||
|
||||
@@ -0,0 +1,511 @@
|
||||
/*
|
||||
* file-mmap-posix.c: File mmap internal calls
|
||||
*
|
||||
* Author:
|
||||
* Rodrigo Kumpera
|
||||
*
|
||||
* Copyright 2014 Xamarin Inc (http://www.xamarin.com)
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifndef TARGET_WIN32
|
||||
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#if HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
#include <mono/metadata/object.h>
|
||||
#include <mono/metadata/file-io.h>
|
||||
#include <mono/metadata/file-mmap.h>
|
||||
#include <mono/utils/atomic.h>
|
||||
#include <mono/utils/mono-memory-model.h>
|
||||
#include <mono/utils/mono-mmap.h>
|
||||
|
||||
typedef struct {
|
||||
int kind;
|
||||
int ref_count;
|
||||
size_t capacity;
|
||||
char *name;
|
||||
int fd;
|
||||
} MmapHandle;
|
||||
|
||||
typedef struct {
|
||||
void *address;
|
||||
void *free_handle;
|
||||
size_t length;
|
||||
} MmapInstance;
|
||||
|
||||
enum {
|
||||
BAD_CAPACITY_FOR_FILE_BACKED = 1,
|
||||
CAPACITY_SMALLER_THAN_FILE_SIZE,
|
||||
FILE_NOT_FOUND,
|
||||
FILE_ALREADY_EXISTS,
|
||||
PATH_TOO_LONG,
|
||||
COULD_NOT_OPEN,
|
||||
CAPACITY_MUST_BE_POSITIVE,
|
||||
INVALID_FILE_MODE,
|
||||
COULD_NOT_MAP_MEMORY
|
||||
};
|
||||
|
||||
enum {
|
||||
FILE_MODE_CREATE_NEW = 1,
|
||||
FILE_MODE_CREATE = 2,
|
||||
FILE_MODE_OPEN = 3,
|
||||
FILE_MODE_OPEN_OR_CREATE = 4,
|
||||
FILE_MODE_TRUNCATE = 5,
|
||||
FILE_MODE_APPEND = 6,
|
||||
};
|
||||
|
||||
enum {
|
||||
MMAP_FILE_ACCESS_READ_WRITE = 0,
|
||||
MMAP_FILE_ACCESS_READ = 1,
|
||||
MMAP_FILE_ACCESS_WRITE = 2,
|
||||
MMAP_FILE_ACCESS_COPY_ON_WRITE = 3,
|
||||
MMAP_FILE_ACCESS_READ_EXECUTE = 4,
|
||||
MMAP_FILE_ACCESS_READ_WRITE_EXECUTE = 5,
|
||||
};
|
||||
|
||||
#ifdef PLATFORM_ANDROID
|
||||
#define DEFAULT_FILEMODE 0666
|
||||
#else
|
||||
#define DEFAULT_FILEMODE DEFFILEMODE
|
||||
#endif
|
||||
|
||||
static int mmap_init_state;
|
||||
static mono_mutex_t named_regions_mutex;
|
||||
static GHashTable *named_regions;
|
||||
|
||||
|
||||
static gint64
|
||||
align_up_to_page_size (gint64 size)
|
||||
{
|
||||
gint64 page_size = mono_pagesize ();
|
||||
return (size + page_size - 1) & ~(page_size - 1);
|
||||
}
|
||||
|
||||
static gint64
|
||||
align_down_to_page_size (gint64 size)
|
||||
{
|
||||
gint64 page_size = mono_pagesize ();
|
||||
return size & ~(page_size - 1);
|
||||
}
|
||||
|
||||
static void
|
||||
file_mmap_init (void)
|
||||
{
|
||||
retry:
|
||||
switch (mmap_init_state) {
|
||||
case 0:
|
||||
if (InterlockedCompareExchange (&mmap_init_state, 1, 0) != 0)
|
||||
goto retry;
|
||||
named_regions = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
|
||||
mono_mutex_init (&named_regions_mutex);
|
||||
|
||||
mono_atomic_store_release (&mmap_init_state, 2);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
do {
|
||||
g_usleep (1000); /* Been init'd by other threads, this is very rare. */
|
||||
} while (mmap_init_state != 2);
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
default:
|
||||
g_error ("Invalid init state %d", mmap_init_state);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
named_regions_lock (void)
|
||||
{
|
||||
file_mmap_init ();
|
||||
mono_mutex_lock (&named_regions_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
named_regions_unlock (void)
|
||||
{
|
||||
mono_mutex_unlock (&named_regions_mutex);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
file_mode_to_unix (int mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case FILE_MODE_CREATE_NEW:
|
||||
return O_CREAT | O_EXCL;
|
||||
case FILE_MODE_CREATE:
|
||||
return O_CREAT | O_TRUNC;
|
||||
case FILE_MODE_OPEN:
|
||||
return 0;
|
||||
case FILE_MODE_OPEN_OR_CREATE:
|
||||
return O_CREAT;
|
||||
case FILE_MODE_TRUNCATE:
|
||||
return O_TRUNC;
|
||||
case FILE_MODE_APPEND:
|
||||
return O_APPEND;
|
||||
default:
|
||||
g_error ("unknown FileMode %d", mode);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
access_mode_to_unix (int access)
|
||||
{
|
||||
switch (access) {
|
||||
case MMAP_FILE_ACCESS_READ_WRITE:
|
||||
case MMAP_FILE_ACCESS_COPY_ON_WRITE:
|
||||
case MMAP_FILE_ACCESS_READ_WRITE_EXECUTE:
|
||||
return O_RDWR;
|
||||
case MMAP_FILE_ACCESS_READ:
|
||||
case MMAP_FILE_ACCESS_READ_EXECUTE:
|
||||
return O_RDONLY;
|
||||
case MMAP_FILE_ACCESS_WRITE:
|
||||
return O_WRONLY;
|
||||
default:
|
||||
g_error ("unknown MemoryMappedFileAccess %d", access);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
acess_to_mmap_flags (int access)
|
||||
{
|
||||
switch (access) {
|
||||
case MMAP_FILE_ACCESS_READ_WRITE:
|
||||
return MONO_MMAP_WRITE | MONO_MMAP_READ | MONO_MMAP_SHARED;
|
||||
|
||||
case MMAP_FILE_ACCESS_WRITE:
|
||||
return MONO_MMAP_WRITE | MONO_MMAP_SHARED;
|
||||
|
||||
case MMAP_FILE_ACCESS_COPY_ON_WRITE:
|
||||
return MONO_MMAP_WRITE | MONO_MMAP_READ | MONO_MMAP_PRIVATE;
|
||||
|
||||
case MMAP_FILE_ACCESS_READ_EXECUTE:
|
||||
return MONO_MMAP_EXEC | MONO_MMAP_PRIVATE | MONO_MMAP_SHARED;
|
||||
|
||||
case MMAP_FILE_ACCESS_READ_WRITE_EXECUTE:
|
||||
return MONO_MMAP_WRITE | MONO_MMAP_READ | MONO_MMAP_EXEC | MONO_MMAP_SHARED;
|
||||
|
||||
case MMAP_FILE_ACCESS_READ:
|
||||
return MONO_MMAP_READ | MONO_MMAP_SHARED;
|
||||
default:
|
||||
g_error ("unknown MemoryMappedFileAccess %d", access);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
This allow us to special case zero size files that can be arbitrarily mapped.
|
||||
*/
|
||||
static gboolean
|
||||
is_special_zero_size_file (struct stat *buf)
|
||||
{
|
||||
return buf->st_size == 0 && (buf->st_mode & (S_IFCHR | S_IFBLK | S_IFIFO | S_IFSOCK)) != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
XXX implement options
|
||||
*/
|
||||
static void*
|
||||
open_file_map (MonoString *path, int input_fd, int mode, gint64 *capacity, int access, int options, int *error)
|
||||
{
|
||||
struct stat buf;
|
||||
char *c_path = path ? mono_string_to_utf8 (path) : NULL;
|
||||
MmapHandle *handle = NULL;
|
||||
int result, fd;
|
||||
|
||||
if (path)
|
||||
result = stat (c_path, &buf);
|
||||
else
|
||||
result = fstat (input_fd, &buf);
|
||||
|
||||
if (mode == FILE_MODE_TRUNCATE || mode == FILE_MODE_APPEND || mode == FILE_MODE_OPEN) {
|
||||
if (result == -1) { //XXX translate errno?
|
||||
*error = FILE_NOT_FOUND;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == FILE_MODE_CREATE_NEW && result == 0) {
|
||||
*error = FILE_ALREADY_EXISTS;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (result == 0) {
|
||||
if (*capacity == 0) {
|
||||
/**
|
||||
* Special files such as FIFOs, sockets, and devices can have a size of 0. Specifying a capacity for these
|
||||
* also makes little sense, so don't do the check if th file is one of these.
|
||||
*/
|
||||
if (buf.st_size == 0 && !is_special_zero_size_file (&buf)) {
|
||||
*error = CAPACITY_SMALLER_THAN_FILE_SIZE;
|
||||
goto done;
|
||||
}
|
||||
*capacity = buf.st_size;
|
||||
} else if (*capacity < buf.st_size) {
|
||||
*error = CAPACITY_SMALLER_THAN_FILE_SIZE;
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
if (mode == FILE_MODE_CREATE_NEW && *capacity == 0) {
|
||||
*error = CAPACITY_SMALLER_THAN_FILE_SIZE;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (path) //FIXME use io portability?
|
||||
fd = open (c_path, file_mode_to_unix (mode) | access_mode_to_unix (access), DEFAULT_FILEMODE);
|
||||
else
|
||||
fd = dup (input_fd);
|
||||
|
||||
if (fd == -1) { //XXX translate errno?
|
||||
*error = COULD_NOT_OPEN;
|
||||
goto done;
|
||||
}
|
||||
|
||||
*capacity = align_up_to_page_size ((size_t)*capacity);
|
||||
|
||||
if (*capacity > buf.st_size) {
|
||||
int unused G_GNUC_UNUSED = ftruncate (fd, (off_t)*capacity);
|
||||
}
|
||||
|
||||
handle = g_new0 (MmapHandle, 1);
|
||||
handle->ref_count = 1;
|
||||
handle->capacity = *capacity;
|
||||
handle->fd = fd;
|
||||
|
||||
done:
|
||||
g_free (c_path);
|
||||
return (void*)handle;
|
||||
}
|
||||
|
||||
#define MONO_ANON_FILE_TEMPLATE "/tmp/mono.anonmap.XXXXXXXXX"
|
||||
static void*
|
||||
open_memory_map (MonoString *mapName, int mode, gint64 *capacity, int access, int options, int *error)
|
||||
{
|
||||
char *c_mapName;
|
||||
MmapHandle *handle;
|
||||
if (*capacity <= 1) {
|
||||
*error = CAPACITY_MUST_BE_POSITIVE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(mode == FILE_MODE_CREATE_NEW || mode == FILE_MODE_OPEN_OR_CREATE || mode == FILE_MODE_OPEN)) {
|
||||
*error = INVALID_FILE_MODE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
c_mapName = mono_string_to_utf8 (mapName);
|
||||
|
||||
named_regions_lock ();
|
||||
handle = (MmapHandle*)g_hash_table_lookup (named_regions, c_mapName);
|
||||
if (handle) {
|
||||
if (mode == FILE_MODE_CREATE_NEW) {
|
||||
*error = FILE_ALREADY_EXISTS;
|
||||
goto done;
|
||||
}
|
||||
|
||||
handle->ref_count++;
|
||||
//XXX should we ftruncate if the file is smaller than capacity?
|
||||
} else {
|
||||
int fd;
|
||||
char file_name [sizeof (MONO_ANON_FILE_TEMPLATE) + 1];
|
||||
|
||||
if (mode == FILE_MODE_OPEN) {
|
||||
*error = FILE_NOT_FOUND;
|
||||
goto done;
|
||||
}
|
||||
*capacity = align_up_to_page_size (*capacity);
|
||||
|
||||
strcpy (file_name, MONO_ANON_FILE_TEMPLATE);
|
||||
fd = mkstemp (file_name);
|
||||
if (fd == -1) {
|
||||
*error = COULD_NOT_MAP_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
|
||||
unlink (file_name);
|
||||
int unused G_GNUC_UNUSED = ftruncate (fd, (off_t)*capacity);
|
||||
|
||||
handle = g_new0 (MmapHandle, 1);
|
||||
handle->ref_count = 1;
|
||||
handle->capacity = *capacity;
|
||||
handle->fd = fd;
|
||||
handle->name = g_strdup (c_mapName);
|
||||
|
||||
g_hash_table_insert (named_regions, handle->name, handle);
|
||||
|
||||
}
|
||||
|
||||
done:
|
||||
named_regions_unlock ();
|
||||
|
||||
g_free (c_mapName);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
mono_mmap_open_file (MonoString *path, int mode, MonoString *mapName, gint64 *capacity, int access, int options, int *error)
|
||||
{
|
||||
g_assert (path || mapName);
|
||||
|
||||
if (!mapName)
|
||||
return open_file_map (path, -1, mode, capacity, access, options, error);
|
||||
|
||||
if (path) {
|
||||
MmapHandle *handle;
|
||||
char *c_mapName = mono_string_to_utf8 (mapName);
|
||||
|
||||
named_regions_lock ();
|
||||
handle = (MmapHandle*)g_hash_table_lookup (named_regions, c_mapName);
|
||||
if (handle) {
|
||||
*error = FILE_ALREADY_EXISTS;
|
||||
handle = NULL;
|
||||
} else {
|
||||
handle = open_file_map (path, -1, mode, capacity, access, options, error);
|
||||
if (handle) {
|
||||
handle->name = g_strdup (c_mapName);
|
||||
g_hash_table_insert (named_regions, handle->name, handle);
|
||||
}
|
||||
}
|
||||
named_regions_unlock ();
|
||||
|
||||
g_free (c_mapName);
|
||||
return handle;
|
||||
}
|
||||
|
||||
return open_memory_map (mapName, mode, capacity, access, options, error);
|
||||
}
|
||||
|
||||
void *
|
||||
mono_mmap_open_handle (void *input_fd, MonoString *mapName, gint64 *capacity, int access, int options, int *error)
|
||||
{
|
||||
MmapHandle *handle;
|
||||
char *c_mapName = mono_string_to_utf8 (mapName);
|
||||
|
||||
named_regions_lock ();
|
||||
handle = (MmapHandle*)g_hash_table_lookup (named_regions, c_mapName);
|
||||
if (handle) {
|
||||
*error = FILE_ALREADY_EXISTS;
|
||||
handle = NULL;
|
||||
} else {
|
||||
//XXX we're exploiting wapi HANDLE == FD equivalence. THIS IS FRAGILE, create a _wapi_handle_to_fd call
|
||||
handle = open_file_map (NULL, GPOINTER_TO_INT (input_fd), FILE_MODE_OPEN, capacity, access, options, error);
|
||||
handle->name = g_strdup (c_mapName);
|
||||
g_hash_table_insert (named_regions, handle->name, handle);
|
||||
}
|
||||
named_regions_unlock ();
|
||||
|
||||
g_free (c_mapName);
|
||||
return handle;
|
||||
}
|
||||
|
||||
void
|
||||
mono_mmap_close (void *mmap_handle)
|
||||
{
|
||||
MmapHandle *handle = mmap_handle;
|
||||
|
||||
named_regions_lock ();
|
||||
--handle->ref_count;
|
||||
if (handle->ref_count == 0) {
|
||||
if (handle->name)
|
||||
g_hash_table_remove (named_regions, handle->name);
|
||||
|
||||
g_free (handle->name);
|
||||
close (handle->fd);
|
||||
g_free (handle);
|
||||
}
|
||||
named_regions_unlock ();
|
||||
}
|
||||
|
||||
void
|
||||
mono_mmap_configure_inheritability (void *mmap_handle, gboolean inheritability)
|
||||
{
|
||||
MmapHandle *h = mmap_handle;
|
||||
int fd, flags;
|
||||
|
||||
fd = h->fd;
|
||||
flags = fcntl (fd, F_GETFD, 0);
|
||||
if (inheritability)
|
||||
flags &= ~FD_CLOEXEC;
|
||||
else
|
||||
flags |= FD_CLOEXEC;
|
||||
fcntl (fd, F_SETFD, flags);
|
||||
}
|
||||
|
||||
void
|
||||
mono_mmap_flush (void *mmap_handle)
|
||||
{
|
||||
MmapInstance *h = mmap_handle;
|
||||
|
||||
if (h)
|
||||
msync (h->address, h->length, MS_SYNC);
|
||||
}
|
||||
|
||||
int
|
||||
mono_mmap_map (void *handle, gint64 offset, gint64 *size, int access, void **mmap_handle, void **base_address)
|
||||
{
|
||||
gint64 mmap_offset = 0;
|
||||
MmapHandle *fh = handle;
|
||||
MmapInstance res = { 0 };
|
||||
size_t eff_size = *size;
|
||||
struct stat buf = { 0 };
|
||||
fstat (fh->fd, &buf); //FIXME error handling
|
||||
|
||||
/**
|
||||
* We use the file size if one of the following conditions is true:
|
||||
* -input size is zero
|
||||
* -input size is bigger than the file and the file is not a magical zero size file such as /dev/mem.
|
||||
*/
|
||||
if (eff_size == 0 || (eff_size > buf.st_size && !is_special_zero_size_file (&buf)))
|
||||
eff_size = buf.st_size;
|
||||
*size = eff_size;
|
||||
|
||||
mmap_offset = align_down_to_page_size (offset);
|
||||
eff_size += (offset - mmap_offset);
|
||||
//FIXME translate some interesting errno values
|
||||
res.address = mono_file_map ((size_t)eff_size, acess_to_mmap_flags (access), fh->fd, mmap_offset, &res.free_handle);
|
||||
res.length = eff_size;
|
||||
|
||||
if (res.address) {
|
||||
*mmap_handle = g_memdup (&res, sizeof (MmapInstance));
|
||||
*base_address = (char*)res.address + (offset - mmap_offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*mmap_handle = NULL;
|
||||
*base_address = NULL;
|
||||
return COULD_NOT_MAP_MEMORY;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mono_mmap_unmap (void *mmap_handle)
|
||||
{
|
||||
int res = 0;
|
||||
MmapInstance *h = mmap_handle;
|
||||
|
||||
res = mono_file_unmap (h->address, h->free_handle);
|
||||
|
||||
g_free (h);
|
||||
return res == 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* file-mmap-posix.c: File mmap internal calls
|
||||
*
|
||||
* Author:
|
||||
* Rodrigo Kumpera
|
||||
*
|
||||
* Copyright 2014 Xamarin Inc (http://www.xamarin.com)
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef TARGET_WIN32
|
||||
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
#include <mono/metadata/object.h>
|
||||
#include <mono/metadata/file-mmap.h>
|
||||
|
||||
void *
|
||||
mono_mmap_open_file (MonoString *path, int mode, MonoString *mapName, gint64 *capacity, int access, int options, int *error)
|
||||
{
|
||||
g_error ("No windows backend");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
mono_mmap_open_handle (void *handle, MonoString *mapName, gint64 *capacity, int access, int options, int *error)
|
||||
{
|
||||
g_error ("No windows backend");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
mono_mmap_close (void *mmap_handle)
|
||||
{
|
||||
g_error ("No windows backend");
|
||||
}
|
||||
|
||||
void
|
||||
mono_mmap_configure_inheritability (void *mmap_handle, gboolean inheritability)
|
||||
{
|
||||
g_error ("No windows backend");
|
||||
}
|
||||
|
||||
void
|
||||
mono_mmap_flush (void *mmap_handle)
|
||||
{
|
||||
g_error ("No windows backend");
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
mono_mmap_map (void *handle, gint64 offset, gint64 *size, int access, void **mmap_handle, void **base_address)
|
||||
{
|
||||
g_error ("No windows backend");
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mono_mmap_unmap (void *mmap_handle)
|
||||
{
|
||||
g_error ("No windows backend");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* file-mmap.h: Managed mmap wrappers.
|
||||
*
|
||||
* Authors:
|
||||
* Rodrigo Kumpera
|
||||
*
|
||||
* Copyright 2014 Xamarin Inc (http://www.xamarin.com)
|
||||
*/
|
||||
|
||||
#ifndef _MONO_METADATA_FILE_MMAP_H_
|
||||
#define _MONO_METADATA_FILE_MMAP_H_
|
||||
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <mono/metadata/object-internals.h>
|
||||
#include <mono/io-layer/io-layer.h>
|
||||
#include <mono/utils/mono-compiler.h>
|
||||
|
||||
extern void mono_mmap_close (void *mmap_handle) MONO_INTERNAL;
|
||||
|
||||
extern void mono_mmap_configure_inheritability (void *mmap_handle, gboolean inheritability) MONO_INTERNAL;
|
||||
|
||||
extern void mono_mmap_flush (void *mmap_handle) MONO_INTERNAL;
|
||||
|
||||
extern void *mono_mmap_open_file (MonoString *string, int mode, MonoString *mapName, gint64 *capacity, int access, int options, int *error) MONO_INTERNAL;
|
||||
|
||||
extern void *mono_mmap_open_handle (void *handle, MonoString *mapName, gint64 *capacity, int access, int options, int *error) MONO_INTERNAL;
|
||||
|
||||
extern int mono_mmap_map (void *handle, gint64 offset, gint64 *size, int access, void **mmap_handle, void **base_address) MONO_INTERNAL;
|
||||
|
||||
extern gboolean mono_mmap_unmap (void *base_address) MONO_INTERNAL;
|
||||
|
||||
#endif /* _MONO_METADATA_FILE_MMAP_H_ */
|
||||
@@ -315,12 +315,14 @@ 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 (TARGET_IOS) || 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(MMAPIMPL_1, "CloseMapping", mono_mmap_close)
|
||||
ICALL(MMAPIMPL_2, "ConfigureHandleInheritability", mono_mmap_configure_inheritability)
|
||||
ICALL(MMAPIMPL_3, "Flush", mono_mmap_flush)
|
||||
ICALL(MMAPIMPL_4, "MapInternal", mono_mmap_map)
|
||||
ICALL(MMAPIMPL_5, "OpenFileInternal", mono_mmap_open_file)
|
||||
ICALL(MMAPIMPL_6, "OpenHandleInternal", mono_mmap_open_handle)
|
||||
ICALL(MMAPIMPL_7, "Unmap", mono_mmap_unmap)
|
||||
|
||||
ICALL_TYPE(MONOIO, "System.IO.MonoIO", MONOIO_1)
|
||||
ICALL(MONOIO_1, "Close(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Close)
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
#include <mono/metadata/mono-ptr-array.h>
|
||||
#include <mono/metadata/verify-internals.h>
|
||||
#include <mono/metadata/runtime.h>
|
||||
#include <mono/metadata/file-mmap.h>
|
||||
#include <mono/io-layer/io-layer.h>
|
||||
#include <mono/utils/strtod.h>
|
||||
#include <mono/utils/monobitset.h>
|
||||
|
||||
@@ -3851,7 +3851,8 @@ sgen_thread_unregister (SgenThreadInfo *p)
|
||||
binary_protocol_thread_unregister ((gpointer)tid);
|
||||
SGEN_LOG (3, "unregister thread %p (%p)", p, (gpointer)tid);
|
||||
|
||||
mono_threads_add_joinable_thread ((gpointer)tid);
|
||||
if (p->info.runtime_thread)
|
||||
mono_threads_add_joinable_thread ((gpointer)tid);
|
||||
|
||||
if (gc_callbacks.thread_detach_func) {
|
||||
gc_callbacks.thread_detach_func (p->runtime_data);
|
||||
|
||||
+14
-3
@@ -2505,10 +2505,21 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
|
||||
jinfo->from_aot = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set all the 'has' flags, the mono_jit_info_get () functions depends on this to
|
||||
* compute the addresses of data blocks.
|
||||
*/
|
||||
if (has_generic_jit_info)
|
||||
jinfo->has_generic_jit_info = 1;
|
||||
if (has_arch_eh_jit_info)
|
||||
jinfo->has_arch_eh_info = 1;
|
||||
if (has_try_block_holes)
|
||||
jinfo->has_try_block_holes = 1;
|
||||
|
||||
if (has_try_block_holes) {
|
||||
MonoTryBlockHoleTableJitInfo *table;
|
||||
|
||||
jinfo->has_try_block_holes = 1;
|
||||
g_assert (jinfo->has_try_block_holes);
|
||||
|
||||
table = mono_jit_info_get_try_block_hole_table_info (jinfo);
|
||||
g_assert (table);
|
||||
@@ -2525,7 +2536,7 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
|
||||
if (has_arch_eh_jit_info) {
|
||||
MonoArchEHJitInfo *eh_info;
|
||||
|
||||
jinfo->has_arch_eh_info = 1;
|
||||
g_assert (jinfo->has_arch_eh_info);
|
||||
|
||||
eh_info = mono_jit_info_get_arch_eh_info (jinfo);
|
||||
eh_info->stack_size = decode_value (p, &p);
|
||||
@@ -2543,7 +2554,7 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
|
||||
MonoGenericJitInfo *gi;
|
||||
int len;
|
||||
|
||||
jinfo->has_generic_jit_info = 1;
|
||||
g_assert (jinfo->has_generic_jit_info);
|
||||
|
||||
gi = mono_jit_info_get_generic_jit_info (jinfo);
|
||||
g_assert (gi);
|
||||
|
||||
+64
-19
@@ -356,7 +356,8 @@ typedef enum {
|
||||
MOD_KIND_STEP = 10,
|
||||
MOD_KIND_ASSEMBLY_ONLY = 11,
|
||||
MOD_KIND_SOURCE_FILE_ONLY = 12,
|
||||
MOD_KIND_TYPE_NAME_ONLY = 13
|
||||
MOD_KIND_TYPE_NAME_ONLY = 13,
|
||||
MOD_KIND_NONE = 14
|
||||
} ModifierKind;
|
||||
|
||||
typedef enum {
|
||||
@@ -4326,7 +4327,7 @@ insert_breakpoint (MonoSeqPointInfo *seq_points, MonoDomain *domain, MonoJitInfo
|
||||
#endif
|
||||
}
|
||||
|
||||
DEBUG(1, fprintf (log_file, "[dbg] Inserted breakpoint at %s:0x%x.\n", mono_method_full_name (jinfo_get_method (ji), TRUE), (int)sp->il_offset));
|
||||
DEBUG(1, fprintf (log_file, "[dbg] Inserted breakpoint at %s:0x%x [%p](%d).\n", mono_method_full_name (jinfo_get_method (ji), TRUE), (int)sp->il_offset, inst->ip, count));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -4346,6 +4347,7 @@ remove_breakpoint (BreakpointInstance *inst)
|
||||
|
||||
if (count == 1 && inst->native_offset != SEQ_POINT_NATIVE_OFFSET_DEAD_CODE) {
|
||||
mono_arch_clear_breakpoint (ji, ip);
|
||||
DEBUG(1, fprintf (log_file, "[dbg] Clear breakpoint at %s [%p].\n", mono_method_full_name (jinfo_get_method (ji), TRUE), ip));
|
||||
}
|
||||
#else
|
||||
NOT_IMPLEMENTED;
|
||||
@@ -5412,6 +5414,25 @@ ss_destroy (SingleStepReq *req)
|
||||
ss_req = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
ss_clear_for_assembly (SingleStepReq *req, MonoAssembly *assembly)
|
||||
{
|
||||
GSList *l;
|
||||
gboolean found = TRUE;
|
||||
|
||||
while (found) {
|
||||
found = FALSE;
|
||||
for (l = ss_req->bps; l; l = l->next) {
|
||||
if (breakpoint_matches_assembly (l->data, assembly)) {
|
||||
clear_breakpoint (l->data);
|
||||
ss_req->bps = g_slist_delete_link (ss_req->bps, l);
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called from metadata by the icall for System.Diagnostics.Debugger:Log ().
|
||||
*/
|
||||
@@ -6311,28 +6332,47 @@ clear_event_request (int req_id, int etype)
|
||||
mono_loader_unlock ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
event_req_matches_assembly (EventRequest *req, MonoAssembly *assembly)
|
||||
static void
|
||||
clear_assembly_from_modifier (EventRequest *req, Modifier *m, MonoAssembly *assembly)
|
||||
{
|
||||
if (req->event_kind == EVENT_KIND_BREAKPOINT)
|
||||
return breakpoint_matches_assembly (req->info, assembly);
|
||||
else {
|
||||
int i, j;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < req->nmodifiers; ++i) {
|
||||
Modifier *m = &req->modifiers [i];
|
||||
if (m->kind == MOD_KIND_EXCEPTION_ONLY && m->data.exc_class && m->data.exc_class->image->assembly == assembly)
|
||||
m->kind = MOD_KIND_NONE;
|
||||
if (m->kind == MOD_KIND_ASSEMBLY_ONLY && m->data.assemblies) {
|
||||
int count = 0, match_count = 0, pos;
|
||||
MonoAssembly **newassemblies;
|
||||
|
||||
if (m->kind == MOD_KIND_EXCEPTION_ONLY && m->data.exc_class && m->data.exc_class->image->assembly == assembly)
|
||||
return TRUE;
|
||||
if (m->kind == MOD_KIND_ASSEMBLY_ONLY && m->data.assemblies) {
|
||||
for (j = 0; m->data.assemblies [j]; ++j)
|
||||
if (m->data.assemblies [j] == assembly)
|
||||
return TRUE;
|
||||
}
|
||||
for (i = 0; m->data.assemblies [i]; ++i) {
|
||||
count ++;
|
||||
if (m->data.assemblies [i] == assembly)
|
||||
match_count ++;
|
||||
}
|
||||
|
||||
if (match_count) {
|
||||
newassemblies = g_new0 (MonoAssembly*, count - match_count);
|
||||
|
||||
pos = 0;
|
||||
for (i = 0; i < count; ++i)
|
||||
if (m->data.assemblies [i] != assembly)
|
||||
newassemblies [pos ++] = m->data.assemblies [i];
|
||||
g_assert (pos == count - match_count);
|
||||
g_free (m->data.assemblies);
|
||||
m->data.assemblies = newassemblies;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
static void
|
||||
clear_assembly_from_modifiers (EventRequest *req, MonoAssembly *assembly)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < req->nmodifiers; ++i) {
|
||||
Modifier *m = &req->modifiers [i];
|
||||
|
||||
clear_assembly_from_modifier (req, m, assembly);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6353,11 +6393,16 @@ clear_event_requests_for_assembly (MonoAssembly *assembly)
|
||||
for (i = 0; i < event_requests->len; ++i) {
|
||||
EventRequest *req = g_ptr_array_index (event_requests, i);
|
||||
|
||||
if (event_req_matches_assembly (req, assembly)) {
|
||||
clear_assembly_from_modifiers (req, assembly);
|
||||
|
||||
if (req->event_kind == EVENT_KIND_BREAKPOINT && breakpoint_matches_assembly (req->info, assembly)) {
|
||||
clear_event_request (req->id, req->event_kind);
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (req->event_kind == EVENT_KIND_STEP)
|
||||
ss_clear_for_assembly (req->info, assembly);
|
||||
}
|
||||
}
|
||||
mono_loader_unlock ();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <glib.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_UCONTEXT_H
|
||||
#include <ucontext.h>
|
||||
#endif
|
||||
@@ -876,11 +877,11 @@ prepare_for_guard_pages (MonoContext *mctx)
|
||||
}
|
||||
|
||||
static void
|
||||
altstack_handle_and_restore (void *sigctx, gpointer obj, gboolean stack_ovf)
|
||||
altstack_handle_and_restore (MonoContext *ctx, gpointer obj, gboolean stack_ovf)
|
||||
{
|
||||
MonoContext mctx;
|
||||
|
||||
mono_arch_sigctx_to_monoctx (sigctx, &mctx);
|
||||
mctx = *ctx;
|
||||
|
||||
mono_handle_exception (&mctx, obj);
|
||||
if (stack_ovf)
|
||||
@@ -893,11 +894,10 @@ mono_arch_handle_altstack_exception (void *sigctx, gpointer fault_addr, gboolean
|
||||
{
|
||||
#if defined(MONO_ARCH_USE_SIGACTION)
|
||||
MonoException *exc = NULL;
|
||||
ucontext_t *ctx = (ucontext_t*)sigctx;
|
||||
MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), (gpointer)UCONTEXT_REG_RIP (sigctx), NULL);
|
||||
gpointer *sp;
|
||||
int frame_size;
|
||||
ucontext_t *copied_ctx;
|
||||
MonoContext *copied_ctx;
|
||||
|
||||
if (stack_ovf)
|
||||
exc = mono_domain_get ()->stack_overflow_ex;
|
||||
@@ -912,27 +912,15 @@ mono_arch_handle_altstack_exception (void *sigctx, gpointer fault_addr, gboolean
|
||||
* return ip
|
||||
* 128 is the size of the red zone
|
||||
*/
|
||||
frame_size = sizeof (ucontext_t) + sizeof (gpointer) * 4 + 128;
|
||||
#ifdef __APPLE__
|
||||
frame_size += sizeof (*ctx->uc_mcontext);
|
||||
#endif
|
||||
frame_size = sizeof (MonoContext) + sizeof (gpointer) * 4 + 128;
|
||||
frame_size += 15;
|
||||
frame_size &= ~15;
|
||||
sp = (gpointer)(UCONTEXT_REG_RSP (sigctx) & ~15);
|
||||
sp = (gpointer)((char*)sp - frame_size);
|
||||
copied_ctx = (ucontext_t*)(sp + 4);
|
||||
copied_ctx = (MonoContext*)(sp + 4);
|
||||
/* the arguments must be aligned */
|
||||
sp [-1] = (gpointer)UCONTEXT_REG_RIP (sigctx);
|
||||
/* may need to adjust pointers in the new struct copy, depending on the OS */
|
||||
memcpy (copied_ctx, ctx, sizeof (ucontext_t));
|
||||
#ifdef __APPLE__
|
||||
{
|
||||
guint8 * copied_mcontext = (guint8*)copied_ctx + sizeof (ucontext_t);
|
||||
/* uc_mcontext is a pointer, so make a copy which is stored after the ctx */
|
||||
memcpy (copied_mcontext, ctx->uc_mcontext, sizeof (*ctx->uc_mcontext));
|
||||
copied_ctx->uc_mcontext = (void*)copied_mcontext;
|
||||
}
|
||||
#endif
|
||||
mono_sigctx_to_monoctx (sigctx, copied_ctx);
|
||||
/* at the return form the signal handler execution starts in altstack_handle_and_restore() */
|
||||
UCONTEXT_REG_RIP (sigctx) = (unsigned long)altstack_handle_and_restore;
|
||||
UCONTEXT_REG_RSP (sigctx) = (unsigned long)(sp - 1);
|
||||
|
||||
@@ -4206,7 +4206,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
|
||||
ARM_CMP_REG_IMM (code, tmpreg, 0, 0);
|
||||
buf [2] = code;
|
||||
ARM_B_COND (code, ARMCOND_NE, 0);
|
||||
arm_patch (buf [2], buf [1]);
|
||||
arm_patch (buf [2], buf [0]);
|
||||
arm_patch (buf [1], code);
|
||||
break;
|
||||
case OP_ATOMIC_ADD_NEW_I4:
|
||||
|
||||
@@ -551,7 +551,8 @@ DISABLED_TESTS= \
|
||||
bug-348522.2.exe \
|
||||
bug-459094.exe \
|
||||
delegate-invoke.exe \
|
||||
$(PLATFORM_DISABLED_TESTS)
|
||||
$(PLATFORM_DISABLED_TESTS) \
|
||||
$(EXTRA_DISABLED_TESTS)
|
||||
|
||||
DISABLED_TESTS_WRENCH= \
|
||||
$(DISABLED_TESTS) \
|
||||
|
||||
@@ -9,6 +9,12 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if defined(TARGET_OSX)
|
||||
/* For pthread_main_np () */
|
||||
#define _DARWIN_C_SOURCE 1
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
#include <pthread.h>
|
||||
#include <pthread_np.h>
|
||||
@@ -187,14 +193,13 @@ mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
|
||||
*staddr = (guint8*)pthread_get_stackaddr_np (pthread_self());
|
||||
*stsize = pthread_get_stacksize_np (pthread_self());
|
||||
|
||||
|
||||
#ifdef TARGET_OSX
|
||||
/*
|
||||
* Mavericks reports stack sizes as 512kb:
|
||||
* http://permalink.gmane.org/gmane.comp.java.openjdk.hotspot.devel/11590
|
||||
* https://bugs.openjdk.java.net/browse/JDK-8020753
|
||||
*/
|
||||
if (*stsize == 512 * 1024)
|
||||
if (pthread_main_np () && *stsize == 512 * 1024)
|
||||
*stsize = 2048 * mono_pagesize ();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<ClCompile Include="..\mono\metadata\environment.c" />
|
||||
<ClCompile Include="..\mono\metadata\exception.c" />
|
||||
<ClCompile Include="..\mono\metadata\file-io.c" />
|
||||
<ClCompile Include="..\mono\metadata\file-mmap-windows.c" />
|
||||
<ClCompile Include="..\mono\metadata\filewatcher.c" />
|
||||
<ClCompile Include="..\mono\metadata\gc-memfuncs.c" />
|
||||
<ClCompile Include="..\mono\metadata\gc.c" />
|
||||
|
||||
Reference in new issue
Block a user