fi
], [with_cooperative_gc=no])
+AM_CONDITIONAL([ENABLE_COOP], [test x$with_cooperative_gc != xno])
+
AC_ARG_ENABLE(checked_build, [ --enable-checked-build=LIST To enable checked build (expensive asserts), configure with a comma-separated LIST of checked build modules and then include that same list in the environment variable MONO_CHECK_MODE at runtime. Recognized checked build modules: all, gc, metadata, thread],[
if test x$enable_checked_build != x ; then
-Subproject commit 5a80e74622e66e16ed0e4f0e9598d5ebc024d789
+Subproject commit 7065bc89e8661cad447140752c0fce118644e06e
included in the bundle. To automatically include all of the
dependencies referenced, use the "--deps" command line option.
.PP
-Use \fImkbundle\FP when you want the startup runtime to load the 1.0
-profile, and use \fImkbundle2\fP when you want the startup runtime to load
-the 2.0 profile.
+There are two modes of operation, the default one uses the
+C compiler to create a bundle and requires a complete C and Mono SDK
+to produced executables. The simple mode (enabled when using the
+"--simple") command line option does not require this, and also allows
+for cross compilation.
+.PP
+For example, to create a bundle for hello world, use the following
+command:
+.nf
+ $ mkbundle -o hello --simple hello.exe
+.fi
+.PP
+The simple version allows for cross-compiling, this requires a Mono
+runtime to be installed in the ~/.mono/targets/TARGET/mono to be
+available. You can use the "--local-targets" to list all available
+targets, and the "--cross" argument to specify the target, like this:
+.nf
+ $ mkbundle --local-targets
+ Available targets:
+ default - Current System Mono
+ 4.4.0-macosx-x86
+ 4.4.0-debian-8-arm64
+ $ mkbundle --cross 4.4.0-debian-8-powerpc hello.exe -o hello-debian
+.fi
+.PP
+The above will bundle your native library into hello-debian for
+a Debian 8 system running on a PowerPC machine.
+.SH OLD EMBEDDING
.PP
For example, to create a bundle for hello world, use the following
command:
.I "-c"
Produce the stub file, do not compile the resulting stub.
.TP
+.I "--cross target"
+Creates a bundle for the specified target platform. The target
+must be a directory in ~/.mono/targets/ that contains a "mono"
+binary. You can fetch various targets using the --fetch-target
+command line option.
+.TP
.I "-o filename"
Places the output on `out'. If the flag -c is specified, this is the
C host program. If not, this contains the resulting executable.
$prefix/etc/mono/2.0/machine.config depending on the profile that you
are using (1.0 or 2.0)
.TP
-.I "--nodeps"
-This is the default: \fImkbundle\fP will only include the assemblies that
-were specified on the command line to reduce the size of the resulting
-image created.
-.TP
.I "--deps"
This option will bundle all of the referenced assemblies for the
assemblies listed on the command line option. This is useful to
distribute a self-contained image.
.TP
+.I "--fetch-target target"
+Downloads a precompiled runtime for the specified target from the Mono
+distribution site.
+.TP
+.I "--nodeps"
+This is the default: \fImkbundle\fP will only include the assemblies that
+were specified on the command line to reduce the size of the resulting
+image created.
+.TP
.I "--keeptemp"
By default \fImkbundle\fP will delete the temporary files that it uses to
produce the bundle. This option keeps the file around.
.TP
+.I "--lists-targets"
+Lists all of the available local cross compilation targets available
+as precompiled binaries on the Mono distribution server.
+.TP
+.I "--local-targets"
+Lists all of the available local cross compilation targets.
+.TP
.I "--machine-config FILE"
Uses the given FILE as the machine.config file for the generated
application.
By default \fImkbundle\fP dynamically links to mono and glib. This option
causes it to statically link instead.
.TP
-.B Important:
-Since the Mono runtime is licensed under the LGPL, even if you use
-static you should transfer the component pieces of the mkbundle to
-your users so they are able to upgrade the Mono runtime on their own.
-.TP
-If you want to use this for commercial licenses, you must obtain a
-proprietary license for Mono from mono@novell.com
+.I "--target-server SERVER"
+By default the mkbundle tool will download from a Mono server the
+target runtimes, you can specify a different server to provide
+cross-compiled runtimes.
.TP
.I "-z"
Compresses the assemblies before embedding. This results in smaller
.SH FILES
This program will load referenced assemblies from the Mono assembly
cache.
+.PP
+Targets are loaded from ~/.mono/targets/TARGETNAME/mono
.SH BUGS
The option "--static" is not supported under Windows.
Moreover, a full cygwin environment containing at least "gcc" and "as"
if (values_formated == null)
continue;
- headers.AddValue (header.Key, values_formated);
+ headers.AddInternal (header.Key, values_formated);
}
return wr;
foreach (var header in content.Headers) {
foreach (var value in header.Value) {
- headers.AddValue (header.Key, value);
+ headers.AddInternal (header.Key, value);
}
}
}
[Conditional ("TRACE")]
- internal static void Enter(TraceSource traceSource, object obj, string method, object paramObject) {
- }
+ internal static void Enter(TraceSource traceSource, object obj, string method, object paramObject) {
+ }
+
+ [Conditional ("TRACE")]
+ internal static void Exception(TraceSource traceSource, object obj, string method, Exception e) {
+ }
[Conditional ("TRACE")]
internal static void Exit(TraceSource traceSource, object obj, string method, object retObject) {
}
+ [Conditional ("TRACE")]
internal static void PrintInfo(TraceSource traceSource, object obj, string method, string msg) {
}
+ [Conditional ("TRACE")]
internal static void PrintWarning(TraceSource traceSource, object obj, string method, string msg) {
}
+
+ [Conditional ("TRACE")]
+ internal static void PrintWarning(TraceSource traceSource, string msg) {
+ }
}
#if MOBILE
{
user_async_state = null;
worker = null;
- cts = null;
+
+ if (cts != null) {
+ cts.Dispose();
+ cts = null;
+ }
if (PingCompleted != null)
PingCompleted (this, e);
if ((worker != null) || (cts != null))
throw new InvalidOperationException ("Another SendAsync operation is in progress");
+ cts = new CancellationTokenSource();
+
var task = Task<PingReply>.Factory.StartNew (
() => Send (address, timeout, buffer, options), cts.Token);
if (auth == null)
continue;
- auth.Module = mod;
+ auth.ModuleAuthenticationType = mod.AuthenticationType;
return auth;
}
}
if (auth == null)
continue;
- auth.Module = mod;
+ auth.ModuleAuthenticationType = mod.AuthenticationType;
return auth;
}
}
+++ /dev/null
-//
-// System.Net.AuthenticationSchemeSelector.cs
-//
-// Author:
-// Gonzalo Paniagua Javier <gonzalo@novell.com>
-//
-// Copyright (c) 2005 Novell, Inc. (http://www.novell.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.
-//
-
-#if SECURITY_DEP
-
-namespace System.Net {
- public delegate AuthenticationSchemes AuthenticationSchemeSelector (HttpListenerRequest httpRequest);
-}
-#endif
-
+++ /dev/null
-//
-// System.Net.AuthenticationSchemes.cs
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.com>
-//
-// (C) 2005 Novell, Inc. (http://www.novell.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.Collections;
-using System.Configuration;
-
-namespace System.Net
-{
- [Flags]
- public enum AuthenticationSchemes {
- None,
- Digest = 1,
- Negotiate = 2,
- Ntlm = 4,
- IntegratedWindowsAuthentication = 6,
- Basic = 8,
- Anonymous = 0x8000,
- }
-}
-
+++ /dev/null
-//
-// System.Net.Authorization.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-// Lawrence Pit (loz@cable.a2000.nl)
-//
-// (C) Ximian, Inc. http://www.ximian.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.
-//
-
-namespace System.Net {
-
- public class Authorization {
- string token;
- bool complete;
- string connectionGroupId;
- string [] protectionRealm;
- IAuthenticationModule module;
-
- public Authorization (string token) : this (token, true)
- {
- }
-
- public Authorization (string token, bool finished)
- : this (token, finished, null)
- {
- }
-
- public Authorization (string token, bool finished, string connectionGroupId)
- {
- this.token = token;
- this.complete = finished;
- this.connectionGroupId = connectionGroupId;
- }
-
- public string Message {
- get { return token; }
- }
-
- public bool Complete {
- get { return complete; }
- }
-
- public string ConnectionGroupId {
- get { return connectionGroupId; }
- }
-
- public string[] ProtectionRealm {
- get { return protectionRealm; }
- set { protectionRealm = value; }
- }
-
- internal IAuthenticationModule Module {
- get { return module; }
- set { module = value; }
- }
-
- static Exception GetMustImplement ()
- {
- return new NotImplementedException ();
- }
-
- [MonoTODO]
- public bool MutuallyAuthenticated
- {
- get {
- throw GetMustImplement ();
- }
- set {
- throw GetMustImplement ();
- }
- }
- }
-}
+++ /dev/null
-// ConnectionModes.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:35:39 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.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.
-//
-
-
-namespace System.Net {
-
-
- /// <summary>
- /// </summary>
- enum ConnectionModes {
-
- /// <summary>
- /// </summary>
- Single = 0,
-
- /// <summary>
- /// </summary>
- Persistent = 1,
-
- /// <summary>
- /// </summary>
- Pipeline = 2,
-
- /// <summary>
- /// </summary>
- Mux = 3,
- } // ConnectionModes
-
-} // System.Net
+++ /dev/null
-//
-// System.Net.DnsEndPoint
-//
-// Authors:
-// Stephane Delcroix <stephane@delcroix.org>
-//
-// (c) 2007, 2009 Novell, Inc. (http://www.novell.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.Net.Sockets;
-
-namespace System.Net {
-
-#if NET_2_1
- sealed
-#endif
- public class DnsEndPoint : EndPoint {
- string host;
- int port;
- AddressFamily addressFamily = AddressFamily.Unspecified;
-
- public DnsEndPoint (string host, int port)
- {
- if (host == null)
- throw new ArgumentNullException ("host");
- if (host == String.Empty)
- throw new ArgumentException ("host parameter contains an empty string");
- if (port < 0 || port > 0xffff)
- throw new ArgumentOutOfRangeException ("port is less than 0 or greater than 0xffff");
-
- this.host = host;
- this.port = port;
- }
-
- public DnsEndPoint (string host, int port, AddressFamily addressFamily) : this (host, port)
- {
- switch (addressFamily) {
- case AddressFamily.InterNetwork:
- case AddressFamily.InterNetworkV6:
- case AddressFamily.Unspecified:
- this.addressFamily = addressFamily;
- break;
- default:
- // throw for Unknown or any invalid value
- throw new ArgumentException ("addressFamily");
- }
- }
-
- public override bool Equals (object comparand)
- {
- DnsEndPoint dep = (comparand as DnsEndPoint);
- return (comparand != null) && Equals (dep);
- }
-
- private bool Equals (DnsEndPoint other)
- {
- if (port != other.port || addressFamily != other.addressFamily|| host != other.host)
- return false;
- return true;
- }
-
- public override int GetHashCode ()
- {
- return port ^ (int)addressFamily ^ host.GetHashCode ();
- }
-
- public override string ToString ()
- {
- return String.Format ("{0}/{1}:{2}", addressFamily, host, port);
- }
-
- public override AddressFamily AddressFamily {
- get { return addressFamily; }
- }
-
- public string Host {
- get { return host; }
- }
-
- public int Port {
- get { return port; }
- }
- }
-}
-
+++ /dev/null
-//
-// DownloadProgressChangedEventHandler.cs
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.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.
-//
-namespace System.Net
-{
- public delegate void DownloadProgressChangedEventHandler (object sender, DownloadProgressChangedEventArgs e);
-}
-
+++ /dev/null
-//
-// System.Net.EndPoint.cs
-//
-// Author:
-// Dick Porter (dick@ximian.com)
-//
-// (C) Ximian, Inc. http://www.ximian.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.Net.Sockets;
-
-namespace System.Net {
- [Serializable]
- public abstract class EndPoint {
-
- // NB: These methods really do nothing but throw
- // NotImplementedException
-
- public virtual AddressFamily AddressFamily {
- get { throw NotImplemented (); }
- }
-
- public virtual EndPoint Create (SocketAddress socketAddress)
- {
- throw NotImplemented ();
- }
-
- public virtual SocketAddress Serialize ()
- {
- throw NotImplemented ();
- }
-
- protected EndPoint ()
- {
- }
-
- static Exception NotImplemented ()
- {
- // hide the "normal" NotImplementedException from corcompare-like tools
- return new NotImplementedException ();
- }
- }
-}
-
+++ /dev/null
-//\r
-// System.Net.FileWebRequest\r
-//\r
-// Author:\r
-// Lawrence Pit (loz@cable.a2000.nl)\r
-//\r
-\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System;\r
-using System.Collections;\r
-using System.IO;\r
-using System.Runtime.Serialization;\r
-using System.Runtime.Remoting.Messaging;\r
-using System.Threading;\r
-\r
-namespace System.Net \r
-{\r
- [Serializable]\r
- public class FileWebRequest : WebRequest, ISerializable\r
- {\r
- private Uri uri;\r
- private WebHeaderCollection webHeaders;\r
- \r
- private ICredentials credentials;\r
- private string connectionGroup;\r
- private long contentLength;\r
- private FileAccess fileAccess = FileAccess.Read;\r
- private string method = "GET";\r
- private IWebProxy proxy;\r
- private bool preAuthenticate;\r
- private int timeout = 100000;\r
- \r
- private Stream requestStream;\r
- private FileWebResponse webResponse;\r
- private AutoResetEvent requestEndEvent;\r
- private bool requesting;\r
- private bool asyncResponding;\r
- \r
- // Constructors\r
- \r
- internal FileWebRequest (Uri uri) \r
- { \r
- this.uri = uri;\r
- this.webHeaders = new WebHeaderCollection ();\r
- }\r
- \r
- [Obsolete ("Serialization is obsoleted for this type", false)]\r
- protected FileWebRequest (SerializationInfo serializationInfo, StreamingContext streamingContext) \r
- {\r
- SerializationInfo info = serializationInfo;\r
- webHeaders = (WebHeaderCollection) info.GetValue ("headers", typeof (WebHeaderCollection));\r
- proxy = (IWebProxy) info.GetValue ("proxy", typeof (IWebProxy));\r
- uri = (Uri) info.GetValue ("uri", typeof (Uri));\r
- connectionGroup = info.GetString ("connectionGroupName");\r
- method = info.GetString ("method");\r
- contentLength = info.GetInt64 ("contentLength");\r
- timeout = info.GetInt32 ("timeout");\r
- fileAccess = (FileAccess) info.GetValue ("fileAccess", typeof (FileAccess));\r
- preAuthenticate = info.GetBoolean ("preauthenticate");\r
- }\r
- \r
- // Properties\r
- \r
- // currently not used according to spec\r
- public override string ConnectionGroupName {\r
- get { return connectionGroup; }\r
- set { connectionGroup = value; }\r
- }\r
- \r
- public override long ContentLength {\r
- get { return contentLength; }\r
- set {\r
- if (value < 0)\r
- throw new ArgumentException ("The Content-Length value must be greater than or equal to zero.", "value");\r
- contentLength = value;\r
- }\r
- }\r
- \r
- public override string ContentType { \r
- get { return webHeaders ["Content-Type"]; }\r
- set { webHeaders ["Content-Type"] = value; }\r
- }\r
- \r
- public override ICredentials Credentials { \r
- get { return credentials; }\r
- set { credentials = value; }\r
- }\r
- \r
- public override WebHeaderCollection Headers { \r
- get { return webHeaders; }\r
- }\r
- \r
- // currently not used according to spec\r
- public override string Method { \r
- get { return this.method; }\r
- set {\r
- if (value == null || value.Length == 0)\r
- throw new ArgumentException ("Cannot set null or blank "\r
- + "methods on request.", "value");\r
- this.method = value;\r
- }\r
- }\r
- \r
- // currently not used according to spec\r
- public override bool PreAuthenticate { \r
- get { return preAuthenticate; }\r
- set { preAuthenticate = value; }\r
- }\r
- \r
- // currently not used according to spec\r
- public override IWebProxy Proxy {\r
- get { return proxy; }\r
- set { proxy = value; }\r
- }\r
- \r
- public override Uri RequestUri { \r
- get { return this.uri; }\r
- }\r
- \r
- public override int Timeout { \r
- get { return timeout; }\r
- set { \r
- if (value < -1)\r
- throw new ArgumentOutOfRangeException ("Timeout can be "\r
- + "only set to 'System.Threading.Timeout.Infinite' "\r
- + "or a value >= 0.");\r
- timeout = value;\r
- }\r
- }\r
-\r
- public override bool UseDefaultCredentials\r
- {\r
- get {\r
- throw new NotSupportedException ();\r
- }\r
- set {\r
- throw new NotSupportedException ();\r
- }\r
- }\r
- // Methods\r
- \r
- private delegate Stream GetRequestStreamCallback ();\r
- private delegate WebResponse GetResponseCallback ();\r
-\r
- static Exception GetMustImplement ()\r
- {\r
- return new NotImplementedException ();\r
- }\r
- \r
- /* LAMESPEC: Docs suggest this was present in 1.1 and\r
- * 1.0 profiles, but the masterinfos say otherwise\r
- */\r
- [MonoTODO]\r
- public override void Abort ()\r
- {\r
- throw GetMustImplement ();\r
- }\r
-\r
- public override IAsyncResult BeginGetRequestStream (AsyncCallback callback, object state) \r
- {\r
- if (string.Compare ("GET", method, true) == 0 ||\r
- string.Compare ("HEAD", method, true) == 0 ||\r
- string.Compare ("CONNECT", method, true) == 0)\r
- throw new ProtocolViolationException ("Cannot send a content-body with this verb-type.");\r
- lock (this) {\r
- if (asyncResponding || webResponse != null)\r
- throw new InvalidOperationException ("This operation cannot be performed after the request has been submitted.");\r
- if (requesting)\r
- throw new InvalidOperationException ("Cannot re-call start of asynchronous method while a previous call is still in progress.");\r
- requesting = true;\r
- }\r
- GetRequestStreamCallback c = new GetRequestStreamCallback (this.GetRequestStreamInternal);\r
- return c.BeginInvoke (callback, state);\r
- }\r
- \r
- public override Stream EndGetRequestStream (IAsyncResult asyncResult)\r
- {\r
- if (asyncResult == null)\r
- throw new ArgumentNullException ("asyncResult");\r
- if (!asyncResult.IsCompleted)\r
- asyncResult.AsyncWaitHandle.WaitOne ();\r
- AsyncResult async = (AsyncResult) asyncResult;\r
- GetRequestStreamCallback cb = (GetRequestStreamCallback) async.AsyncDelegate;\r
- return cb.EndInvoke (asyncResult);\r
- }\r
-\r
- public override Stream GetRequestStream()\r
- {\r
- IAsyncResult asyncResult = BeginGetRequestStream (null, null);\r
- if (!(asyncResult.AsyncWaitHandle.WaitOne (timeout, false))) {\r
- throw new WebException("The request timed out", WebExceptionStatus.Timeout);\r
- }\r
- return EndGetRequestStream (asyncResult);\r
- }\r
- \r
- internal Stream GetRequestStreamInternal ()\r
- {\r
- this.requestStream = new FileWebStream (\r
- this,\r
- FileMode.Create,\r
- FileAccess.Write, \r
- FileShare.Read);\r
- return this.requestStream;\r
- }\r
- \r
- public override IAsyncResult BeginGetResponse (AsyncCallback callback, object state)\r
- {\r
- lock (this) {\r
- if (asyncResponding)\r
- throw new InvalidOperationException ("Cannot re-call start of asynchronous method while a previous call is still in progress.");\r
- asyncResponding = true;\r
- }\r
- GetResponseCallback c = new GetResponseCallback (this.GetResponseInternal);\r
- return c.BeginInvoke (callback, state);\r
- }\r
- \r
- public override WebResponse EndGetResponse (IAsyncResult asyncResult)\r
- {\r
- if (asyncResult == null)\r
- throw new ArgumentNullException ("asyncResult");\r
- if (!asyncResult.IsCompleted)\r
- asyncResult.AsyncWaitHandle.WaitOne ();\r
- AsyncResult async = (AsyncResult) asyncResult;\r
- GetResponseCallback cb = (GetResponseCallback) async.AsyncDelegate;\r
- FileWebResponse webResponse = (FileWebResponse) cb.EndInvoke(asyncResult);\r
- asyncResponding = false;\r
- if (webResponse.HasError)\r
- throw webResponse.Error;\r
- return webResponse;\r
- }\r
- \r
- public override WebResponse GetResponse ()\r
- {\r
- IAsyncResult asyncResult = BeginGetResponse (null, null);\r
- if (!(asyncResult.AsyncWaitHandle.WaitOne (timeout, false))) {\r
- throw new WebException("The request timed out", WebExceptionStatus.Timeout);\r
- }\r
- return EndGetResponse (asyncResult);\r
- }\r
- \r
- WebResponse GetResponseInternal ()\r
- {\r
- if (webResponse != null)\r
- return webResponse;\r
- lock (this) {\r
- if (requesting) {\r
- requestEndEvent = new AutoResetEvent (false);\r
- }\r
- }\r
- if (requestEndEvent != null) {\r
- requestEndEvent.WaitOne ();\r
- }\r
- FileStream fileStream = null;\r
- try {\r
- fileStream = new FileWebStream (this, FileMode.Open, FileAccess.Read, FileShare.Read);\r
- this.webResponse = new FileWebResponse (this.uri, fileStream);\r
- } catch (Exception ex) {\r
- this.webResponse = new FileWebResponse (this.uri, new WebException (ex.Message, ex));\r
- }\r
- return this.webResponse;\r
- }\r
- \r
- void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- {\r
- GetObjectData (serializationInfo, streamingContext);\r
- }\r
-\r
- protected override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- {\r
- SerializationInfo info = serializationInfo;\r
- info.AddValue ("headers", webHeaders, typeof (WebHeaderCollection));\r
- info.AddValue ("proxy", proxy, typeof (IWebProxy));\r
- info.AddValue ("uri", uri, typeof (Uri));\r
- info.AddValue ("connectionGroupName", connectionGroup);\r
- info.AddValue ("method", method);\r
- info.AddValue ("contentLength", contentLength);\r
- info.AddValue ("timeout", timeout);\r
- info.AddValue ("fileAccess", fileAccess);\r
- info.AddValue ("preauthenticate", false);\r
- }\r
- \r
- internal void Close ()\r
- {\r
- // already done in class below\r
- // if (requestStream != null) {\r
- // requestStream.Close ();\r
- // }\r
-\r
- lock (this) {\r
- requesting = false;\r
- if (requestEndEvent != null) \r
- requestEndEvent.Set ();\r
- // requestEndEvent = null;\r
- }\r
- }\r
- \r
- // to catch the Close called on the FileStream\r
- internal class FileWebStream : FileStream\r
- {\r
- FileWebRequest webRequest;\r
- \r
- internal FileWebStream (FileWebRequest webRequest, \r
- FileMode mode,\r
- FileAccess access,\r
- FileShare share)\r
- : base (webRequest.RequestUri.LocalPath, \r
- mode, access, share)\r
- {\r
- this.webRequest = webRequest;\r
- }\r
- \r
- public override void Close() \r
- {\r
- base.Close ();\r
- FileWebRequest req = webRequest;\r
- webRequest = null;\r
- if (req != null)\r
- req.Close ();\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-//
-// System.Net.FileWebRequestCreator
-//
-// Authors:
-// Gonzalo Paniagua Javier (gonzalo@ximian.com)
-//
-// (C) 2003 Ximian, Inc (http://www.ximian.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.
-//
-
-namespace System.Net
-{
- class FileWebRequestCreator : IWebRequestCreate
- {
- internal FileWebRequestCreator ()
- {
- }
-
- public WebRequest Create (Uri uri)
- {
- return new FileWebRequest (uri);
- }
- }
-}
-
+++ /dev/null
-//\r
-// System.Net.FileWebResponse\r
-//\r
-// Author:\r
-// Lawrence Pit (loz@cable.a2000.nl)\r
-//\r
-\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System;\r
-using System.IO;\r
-using System.Runtime.Serialization;\r
-\r
-namespace System.Net \r
-{\r
- [Serializable]\r
- public class FileWebResponse : WebResponse, ISerializable, IDisposable\r
- {\r
- private Uri responseUri;\r
- private FileStream fileStream;\r
- private long contentLength;\r
- private WebHeaderCollection webHeaders;\r
- private bool disposed;\r
- Exception exception;\r
- \r
- // Constructors\r
- \r
- internal FileWebResponse (Uri responseUri, FileStream fileStream)\r
- {\r
- try {\r
- this.responseUri = responseUri;\r
- this.fileStream = fileStream;\r
- this.contentLength = fileStream.Length;\r
- this.webHeaders = new WebHeaderCollection ();\r
- this.webHeaders.Add ("Content-Length", Convert.ToString (contentLength));\r
- this.webHeaders.Add ("Content-Type", "application/octet-stream");\r
- } catch (Exception e) {\r
- throw new WebException (e.Message, e);\r
- }\r
- }\r
-\r
- internal FileWebResponse (Uri responseUri, WebException exception)\r
- {\r
- this.responseUri = responseUri;\r
- this.exception = exception;\r
- }\r
- \r
- [Obsolete ("Serialization is obsoleted for this type", false)]\r
- protected FileWebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- {\r
- SerializationInfo info = serializationInfo;\r
-\r
- responseUri = (Uri) info.GetValue ("responseUri", typeof (Uri));\r
- contentLength = info.GetInt64 ("contentLength");\r
- webHeaders = (WebHeaderCollection) info.GetValue ("webHeaders", typeof (WebHeaderCollection));\r
- }\r
- \r
- // Properties\r
- internal bool HasError {\r
- get { return exception != null; }\r
- }\r
-\r
- internal Exception Error {\r
- get { return exception; }\r
- }\r
- \r
- public override long ContentLength {\r
- get {\r
- CheckDisposed ();\r
- return this.contentLength;\r
- }\r
- }\r
- \r
- public override string ContentType {\r
- get {\r
- CheckDisposed ();\r
- return "application/octet-stream";\r
- }\r
- }\r
- \r
- public override WebHeaderCollection Headers {\r
- get {\r
- CheckDisposed ();\r
- return this.webHeaders;\r
- }\r
- }\r
- \r
- public override Uri ResponseUri {\r
- get {\r
- CheckDisposed ();\r
- return this.responseUri;\r
- }\r
- }\r
-\r
- // Methods\r
-\r
- void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- {\r
- GetObjectData (serializationInfo, streamingContext);\r
- }\r
-\r
- protected override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- {\r
- SerializationInfo info = serializationInfo;\r
-\r
- info.AddValue ("responseUri", responseUri, typeof (Uri));\r
- info.AddValue ("contentLength", contentLength);\r
- info.AddValue ("webHeaders", webHeaders, typeof (WebHeaderCollection));\r
- }\r
-\r
- public override Stream GetResponseStream()\r
- {\r
- CheckDisposed ();\r
- return this.fileStream;\r
- }\r
- \r
- // Cleaning up stuff\r
- \r
- ~FileWebResponse ()\r
- {\r
- Dispose (false);\r
- } \r
- \r
- public override void Close()\r
- {\r
- ((IDisposable) this).Dispose ();\r
- }\r
-\r
- void IDisposable.Dispose()\r
- {\r
- Dispose (true);\r
- \r
- // see spec, suppress finalization of this object.\r
- GC.SuppressFinalize (this); \r
- }\r
- \r
- protected override\r
- void Dispose (bool disposing)\r
- {\r
- if (this.disposed)\r
- return;\r
- this.disposed = true;\r
- \r
- if (disposing) {\r
- // release managed resources\r
- this.responseUri = null;\r
- this.webHeaders = null;\r
- }\r
- \r
- // release unmanaged resources\r
- FileStream stream = fileStream;\r
- fileStream = null;\r
- if (stream != null)\r
- stream.Close (); // also closes webRequest\r
- base.Dispose (disposing);\r
- }\r
- \r
- private void CheckDisposed ()\r
- {\r
- if (disposed)\r
- throw new ObjectDisposedException (GetType ().FullName);\r
- } \r
- }\r
-}\r
+++ /dev/null
-//
-// System.Net.FtpStatusCode.cs
-//
-// Author:
-// Carlos Alberto Cortez (calberto.oortez@gmail.com)
-//
-// (c) Copyright 2005 Novell, Inc. (http://www.ximian.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.
-//
-
-namespace System.Net
-{
- public enum FtpStatusCode
- {
- Undefined = 0,
- RestartMarker = 110,
- ServiceTemporarilyNotAvailable = 120,
- DataAlreadyOpen = 125,
- OpeningData = 150,
- CommandOK = 200,
- CommandExtraneous = 202,
- DirectoryStatus = 212,
- FileStatus = 213,
- SystemType = 215,
- SendUserCommand = 220,
- ClosingControl = 221,
- ClosingData = 226,
- EnteringPassive = 227,
- LoggedInProceed = 230,
- ServerWantsSecureSession = 234,
- FileActionOK = 250,
- PathnameCreated = 257,
- SendPasswordCommand = 331,
- NeedLoginAccount = 332,
- FileCommandPending = 350,
- ServiceNotAvailable = 421,
- CantOpenData = 425,
- ConnectionClosed = 426,
- ActionNotTakenFileUnavailableOrBusy = 450,
- ActionAbortedLocalProcessingError = 451,
- ActionNotTakenInsufficientSpace = 452,
- CommandSyntaxError = 500,
- ArgumentSyntaxError = 501,
- CommandNotImplemented = 502,
- BadCommandSequence = 503,
- NotLoggedIn = 530,
- AccountNeeded = 532,
- ActionNotTakenFileUnavailable = 550,
- ActionAbortedUnknownPageType = 551,
- FileActionAborted = 552,
- ActionNotTakenFilenameNotAllowed = 553
- }
-}
-
-
+++ /dev/null
-//
-// System.Net.HttpListenerException
-//
-// Author:
-// Gonzalo Paniagua Javier (gonzalo@novell.com)
-//
-// Copyright (c) 2005 Novell, Inc. (http://www.novell.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.ComponentModel;
-using System.Runtime.Serialization;
-namespace System.Net {
- [Serializable]
- public class HttpListenerException : Win32Exception
- {
- public HttpListenerException ()
- {
- }
-
- public HttpListenerException (int errorCode) : base (errorCode)
- {
- }
-
- public HttpListenerException (int errorCode, string message) : base (errorCode, message)
- {
- }
-
- protected HttpListenerException (SerializationInfo serializationInfo, StreamingContext streamingContext) : base (serializationInfo, streamingContext)
- {
- }
-
- public override int ErrorCode {
- get { return base.ErrorCode; }
- }
- }
-}
-
+++ /dev/null
-//
-// System.Net.HttpRequestHeader
-//
-// Author:
-// Gonzalo Paniagua Javier (gonzalo@novell.com)
-//
-// Copyright (c) 2005 Novell, Inc. (http://www.novell.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.
-//
-namespace System.Net {
- public enum HttpRequestHeader {
- CacheControl,
- Connection,
- Date,
- KeepAlive,
- Pragma,
- Trailer,
- TransferEncoding,
- Upgrade,
- Via,
- Warning,
- Allow,
- ContentLength,
- ContentType,
- ContentEncoding,
- ContentLanguage,
- ContentLocation,
- ContentMd5,
- ContentRange,
- Expires,
- LastModified,
- Accept,
- AcceptCharset,
- AcceptEncoding,
- AcceptLanguage,
- Authorization,
- Cookie,
- Expect,
- From,
- Host,
- IfMatch,
- IfModifiedSince,
- IfNoneMatch,
- IfRange,
- IfUnmodifiedSince,
- MaxForwards,
- ProxyAuthorization,
- Referer,
- Range,
- Te,
- Translate,
- UserAgent
- }
-}
-
+++ /dev/null
-//
-// System.Net.HttpResponseHeader
-//
-// Author:
-// Gonzalo Paniagua Javier (gonzalo@novell.com)
-//
-// Copyright (c) 2005 Novell, Inc. (http://www.novell.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.
-//
-namespace System.Net {
- public enum HttpResponseHeader {
- CacheControl,
- Connection,
- Date,
- KeepAlive,
- Pragma,
- Trailer,
- TransferEncoding,
- Upgrade,
- Via,
- Warning,
- Allow,
- ContentLength,
- ContentType,
- ContentEncoding,
- ContentLanguage,
- ContentLocation,
- ContentMd5,
- ContentRange,
- Expires,
- LastModified,
- AcceptRanges,
- Age,
- ETag,
- Location,
- ProxyAuthenticate,
- RetryAfter,
- Server,
- SetCookie,
- Vary,
- WwwAuthenticate
- }
-}
-
+++ /dev/null
-// HttpStatusCode.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:32:05 UTC
-// Source file: AllTypes.xml
-// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.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.
-//
-
-
-namespace System.Net {
- public enum HttpStatusCode {
- Continue = 100,
- SwitchingProtocols = 101,
- OK = 200,
- Created = 201,
- Accepted = 202,
- NonAuthoritativeInformation = 203,
- NoContent = 204,
- ResetContent = 205,
- PartialContent = 206,
- MultipleChoices = 300,
- Ambiguous = 300,
- MovedPermanently = 301,
- Moved = 301,
- Found = 302,
- Redirect = 302,
- SeeOther = 303,
- RedirectMethod = 303,
- NotModified = 304,
- UseProxy = 305,
- Unused = 306,
- TemporaryRedirect = 307,
- RedirectKeepVerb = 307,
- BadRequest = 400,
- Unauthorized = 401,
- PaymentRequired = 402,
- Forbidden = 403,
- NotFound = 404,
- MethodNotAllowed = 405,
- NotAcceptable = 406,
- ProxyAuthenticationRequired = 407,
- RequestTimeout = 408,
- Conflict = 409,
- Gone = 410,
- LengthRequired = 411,
- PreconditionFailed = 412,
- RequestEntityTooLarge = 413,
- RequestUriTooLong = 414,
- UnsupportedMediaType = 415,
- RequestedRangeNotSatisfiable = 416,
- ExpectationFailed = 417,
- UpgradeRequired = 426,
- InternalServerError = 500,
- NotImplemented = 501,
- BadGateway = 502,
- ServiceUnavailable = 503,
- GatewayTimeout = 504,
- HttpVersionNotSupported = 505,
- } // HttpStatusCode
-
-} // System.Net
-
-
+++ /dev/null
-//\r
-// System.Net.HttpVersion.cs\r
-//\r
-// Author:\r
-// Lawrence Pit (loz@cable.a2000.nl)\r
-//\r
-\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System;\r
-\r
-namespace System.Net {\r
-\r
- // <remarks>\r
- // </remarks>\r
- public class HttpVersion {\r
- \r
- public static readonly Version Version10 = new Version (1, 0);\r
- public static readonly Version Version11 = new Version (1, 1);\r
- \r
- // pretty useless..\r
- public HttpVersion () {}\r
- }\r
-}\r
wex = new WebException (msg, status);
} else {
msg = String.Format ("Error: {0} ({1})", status, exc.Message);
- wex = new WebException (msg, exc, status);
+ wex = new WebException (msg, status, WebExceptionInternalStatus.RequestFatal, exc);
}
r.SetCompleted (false, wex);
r.DoCallback ();
return false;
request.webHeaders [isProxy ? "Proxy-Authorization" : "Authorization"] = auth.Message;
isCompleted = auth.Complete;
- bool is_ntlm = (auth.Module.AuthenticationType == "NTLM");
+ bool is_ntlm = (auth.ModuleAuthenticationType == "NTLM");
if (is_ntlm)
ntlm_auth_state = (NtlmAuthState)((int) ntlm_auth_state + 1);
return true;
+++ /dev/null
-//
-// System.Net.IAuthenticationModule.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// (C) Ximian, Inc. http://www.ximian.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.
-//
-
-namespace System.Net {
-
- // <remarks>
- // Authentication interface for Web client authentication modules.
- // </remarks>
- public interface IAuthenticationModule {
- Authorization Authenticate (string challenge, WebRequest request, ICredentials credentials);
- Authorization PreAuthenticate (WebRequest request, ICredentials credentials);
- string AuthenticationType { get; }
- bool CanPreAuthenticate { get; }
- }
-}
+++ /dev/null
-//
-// System.Net.ICertificatePolicy.cs
-//
-// Author:
-// Lawrence Pit (loz@cable.a2000.nl)
-//
-
-//
-// 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.Security.Cryptography.X509Certificates;
-
-namespace System.Net {
-
- public interface ICertificatePolicy {
- bool CheckValidationResult (
- ServicePoint srvPoint,
- X509Certificate certificate,
- WebRequest request,
- int certificateProblem
- );
- }
-}
+++ /dev/null
-//
-// System.Net.ICredential.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-// Duncan Mak (duncan@ximian.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.
-//
-
-namespace System.Net {
-
- // <remarks>
- // Base authentication interface for Web clients.
- // </remarks>
- public interface ICredentials
- {
- NetworkCredential GetCredential (Uri uri, string authType);
- }
-}
+++ /dev/null
-//
-// System.Net.ICredentialsByHost.cs
-//
-// Author:
-// Tim Coleman (tim@imtcoleman.com)
-//
-// Copyright (C) Tim Coleman, 2004
-
-//
-// 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.
-//
-
-
-namespace System.Net {
- public interface ICredentialsByHost
- {
- NetworkCredential GetCredential (string host, int port, string authenticationType);
- }
-}
+++ /dev/null
-//
-// System.Net.IPAddress.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-// Lawrence Pit (loz@cable.a2000.nl)
-//
-// (C) Ximian, Inc. http://www.ximian.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.Globalization;
-using System.Net.Sockets;
-using System.Runtime.InteropServices;
-
-namespace System.Net {
-
- /// <remarks>
- /// Encapsulates an IP Address.
- /// </remarks>
- [Serializable]
- public class IPAddress {
- // Don't change the name of this field without also
- // changing socket-io.c in the runtime
- // The IP address is stored in little-endian order inside the int,
- // meaning the lower order bytes contain the netid
- private long m_Address;
- private AddressFamily m_Family;
- private ushort[] m_Numbers; /// ip6 Stored in network order (as ip4)
- private long m_ScopeId;
-
- public static readonly IPAddress Any = new IPAddress(0);
- public static readonly IPAddress Broadcast = IPAddress.Parse ("255.255.255.255");
- public static readonly IPAddress Loopback = IPAddress.Parse ("127.0.0.1");
- public static readonly IPAddress None = IPAddress.Parse ("255.255.255.255");
- public static readonly IPAddress IPv6Any = IPAddress.ParseIPV6 ("::");
- public static readonly IPAddress IPv6Loopback = IPAddress.ParseIPV6 ("::1");
- public static readonly IPAddress IPv6None = IPAddress.ParseIPV6 ("::");
-
- private static short SwapShort (short number)
- {
- return (short) ( ((number >> 8) & 0xFF) | ((number << 8) & 0xFF00) );
- }
-
- private static int SwapInt (int number)
- {
- return (((number >> 24) & 0xFF)
- | ((number >> 08) & 0xFF00)
- | ((number << 08) & 0xFF0000)
- | ((number << 24)));
- }
-
- private static long SwapLong(long number)
- {
- return (((number >> 56) & 0xFF)
- | ((number >> 40) & 0xFF00)
- | ((number >> 24) & 0xFF0000)
- | ((number >> 08) & 0xFF000000)
- | ((number << 08) & 0xFF00000000)
- | ((number << 24) & 0xFF0000000000)
- | ((number << 40) & 0xFF000000000000)
- | ((number << 56)));
- }
-
- public static short HostToNetworkOrder(short host) {
- if (!BitConverter.IsLittleEndian)
- return(host);
-
- return SwapShort (host);
- }
-
- public static int HostToNetworkOrder(int host) {
- if (!BitConverter.IsLittleEndian)
- return(host);
-
- return SwapInt (host);
- }
-
- public static long HostToNetworkOrder(long host) {
- if (!BitConverter.IsLittleEndian)
- return(host);
-
- return SwapLong (host);
- }
-
- public static short NetworkToHostOrder(short network) {
- if (!BitConverter.IsLittleEndian)
- return(network);
-
- return SwapShort (network);
- }
-
- public static int NetworkToHostOrder(int network) {
- if (!BitConverter.IsLittleEndian)
- return(network);
-
- return SwapInt (network);
- }
-
- public static long NetworkToHostOrder(long network) {
- if (!BitConverter.IsLittleEndian)
- return(network);
-
- return SwapLong (network);
- }
-
- /// <summary>
- /// Constructor from a 32-bit constant with the address bytes in
- /// little-endian order (the lower order bytes contain the netid)
- /// </summary>
- public IPAddress (long newAddress)
- {
- m_Address = newAddress;
- m_Family = AddressFamily.InterNetwork;
- }
-
- public IPAddress (byte[] address)
- {
- if (address == null)
- throw new ArgumentNullException ("address");
-
- int len = address.Length;
-
- if (len != 16 && len != 4)
- throw new ArgumentException ("An invalid IP address was specified.",
- "address");
-
- if (len == 16) {
- m_Numbers = new ushort [8];
- Buffer.BlockCopy(address, 0, m_Numbers, 0, 16);
- m_Family = AddressFamily.InterNetworkV6;
- m_ScopeId = 0;
- } else {
- m_Address = ((uint) address [3] << 24) + (address [2] << 16) +
- (address [1] << 8) + address [0];
- m_Family = AddressFamily.InterNetwork;
- }
- }
-
- public IPAddress(byte[] address, long scopeid)
- {
- if (address == null)
- throw new ArgumentNullException ("address");
-
- if (address.Length != 16)
- throw new ArgumentException ("An invalid IP address was specified.",
- "address");
-
- m_Numbers = new ushort [8];
- Buffer.BlockCopy(address, 0, m_Numbers, 0, 16);
- m_Family = AddressFamily.InterNetworkV6;
- m_ScopeId = scopeid;
- }
-
- internal IPAddress(ushort[] address, long scopeId)
- {
- m_Numbers = address;
-
- for(int i=0; i<8; i++)
- m_Numbers[i] = (ushort)HostToNetworkOrder((short)m_Numbers[i]);
-
- m_Family = AddressFamily.InterNetworkV6;
- m_ScopeId = scopeId;
- }
-
- public static IPAddress Parse (string ipString)
- {
- if (ipString == null)
- throw new ArgumentNullException("ipString");
-
- IPAddress ret;
- if (TryParse (ipString, out ret))
- return ret;
- throw new FormatException ("An invalid IP address was specified.");
- }
-
- public static bool TryParse (string ipString, out IPAddress address)
- {
- if (ipString == null)
- {
- address = null;
- return false;
- }
-
- if ((address = ParseIPV4 (ipString)) == null)
- if ((address = ParseIPV6 (ipString)) == null)
- return false;
- return true;
- }
-
- private static IPAddress ParseIPV4 (string ip)
- {
-
- int pos = ip.IndexOf (' ');
- if (pos != -1) {
- string [] nets = ip.Substring (pos + 1).Split (new char [] {'.'});
- if (nets.Length > 0) {
- string lastNet = nets [nets.Length - 1];
- if (lastNet.Length == 0)
- return null;
- foreach (char c in lastNet)
- if (!Uri.IsHexDigit (c))
- return null;
- }
- ip = ip.Substring (0, pos);
- }
-
- if (ip.Length == 0 || ip [ip.Length - 1] == '.')
- return null;
-
- string [] ips = ip.Split (new char [] {'.'});
- if (ips.Length > 4)
- return null;
-
- // Make the number in network order
- try {
- long a = 0;
- long val = 0;
- for (int i = 0; i < ips.Length; i++) {
- string subnet = ips [i];
- if ((3 <= subnet.Length && subnet.Length <= 4) &&
- (subnet [0] == '0') && (subnet [1] == 'x' || subnet [1] == 'X')) {
- if (subnet.Length == 3)
- val = (byte) Uri.FromHex (subnet [2]);
- else
- val = (byte) ((Uri.FromHex (subnet [2]) << 4) | Uri.FromHex (subnet [3]));
- } else if (subnet.Length == 0)
- return null;
- else if (subnet [0] == '0') {
- // octal
- val = 0;
- for (int j = 1; j < subnet.Length; j++) {
- if ('0' <= subnet [j] && subnet [j] <= '7')
- val = (val << 3) + subnet [j] - '0';
- else
- return null;
- }
- }
- else {
- if (!Int64.TryParse (subnet, NumberStyles.None, null, out val))
- return null;
- }
-
- if (i == (ips.Length - 1)) {
- if (i != 0 && val >= (256 << ((3 - i) * 8)))
- return null;
- else if (val > 0xffffffff)
- return null;
- i = 3;
- } else if (val >= 0x100)
- return null;
- for (int j = 0; val > 0; j++, val /= 0x100)
- a |= (val & 0xFF) << ((i - j) << 3);
- }
-
- return (new IPAddress (a));
- } catch (Exception) {
- return null;
- }
- }
-
- private static IPAddress ParseIPV6 (string ip)
- {
- IPv6Address newIPv6Address;
-
- if (IPv6Address.TryParse(ip, out newIPv6Address))
- return new IPAddress (newIPv6Address.Address, newIPv6Address.ScopeId);
- return null;
- }
-
- [Obsolete("This property is obsolete. Use GetAddressBytes.")]
- public long Address
- {
- get {
- if(m_Family != AddressFamily.InterNetwork)
- throw new Exception("The attempted operation is not supported for the type of object referenced");
-
- return m_Address;
- }
- set {
- /* no need to do this test, ms.net accepts any value.
- if (value < 0 || value > 0x00000000FFFFFFFF)
- throw new ArgumentOutOfRangeException (
- "the address must be between 0 and 0xFFFFFFFF");
- */
-
- if(m_Family != AddressFamily.InterNetwork)
- throw new Exception("The attempted operation is not supported for the type of object referenced");
-
- m_Address = value;
- }
- }
-
- internal long InternalIPv4Address {
- get { return m_Address; }
- }
-
- public bool IsIPv6LinkLocal {
- get {
- if (m_Family == AddressFamily.InterNetwork)
- return false;
- int v = NetworkToHostOrder ((short) m_Numbers [0]) & 0xFFF0;
- return 0xFE80 <= v && v < 0xFEC0;
- }
- }
-
- public bool IsIPv6SiteLocal {
- get {
- if (m_Family == AddressFamily.InterNetwork)
- return false;
- int v = NetworkToHostOrder ((short) m_Numbers [0]) & 0xFFF0;
- return 0xFEC0 <= v && v < 0xFF00;
- }
- }
-
- public bool IsIPv6Multicast {
- get {
- return m_Family != AddressFamily.InterNetwork &&
- ((ushort) NetworkToHostOrder ((short) m_Numbers [0]) & 0xFF00) == 0xFF00;
- }
- }
-
- public bool IsIPv6Teredo {
- get {
- return m_Family != AddressFamily.InterNetwork &&
- NetworkToHostOrder ((short) m_Numbers [0]) == 0x2001 &&
- m_Numbers[1] == 0;
- }
- }
-
- public long ScopeId {
- get {
- if (m_Family != AddressFamily.InterNetworkV6)
- throw new SocketException ((int) SocketError.OperationNotSupported);
-
- return m_ScopeId;
- }
- set {
- if (m_Family != AddressFamily.InterNetworkV6)
- throw new SocketException ((int) SocketError.OperationNotSupported);
- if ((value < 0) || (value > UInt32.MaxValue))
- throw new ArgumentOutOfRangeException ();
-
- m_ScopeId = value;
- }
- }
-
- public byte [] GetAddressBytes ()
- {
- if(m_Family == AddressFamily.InterNetworkV6) {
- byte [] addressBytes = new byte [16];
- Buffer.BlockCopy (m_Numbers, 0, addressBytes, 0, 16);
- return addressBytes;
- } else {
- return new byte [4] { (byte)(m_Address & 0xFF),
- (byte)((m_Address >> 8) & 0xFF),
- (byte)((m_Address >> 16) & 0xFF),
- (byte)(m_Address >> 24) };
- }
- }
-
- public AddressFamily AddressFamily
- {
- get {
- return m_Family;
- }
- }
-
-#if NET_4_5
-
- public IPAddress MapToIPv4 ()
- {
- if (AddressFamily == AddressFamily.InterNetwork)
- return this;
- if (AddressFamily != AddressFamily.InterNetworkV6)
- throw new Exception ("Only AddressFamily.InterNetworkV6 can be converted to IPv4");
-
- //Test for 0000 0000 0000 0000 0000 FFFF xxxx xxxx
- for (int i = 0; i < 5; i++) {
- if (m_Numbers [i] != 0x0000)
- throw new Exception ("Address does not have the ::FFFF prefix");
- }
- if (m_Numbers [5] != 0xFFFF)
- throw new Exception ("Address does not have the ::FFFF prefix");
-
- //We've got an IPv4 address
- byte [] ipv4Bytes = new byte [4];
- Buffer.BlockCopy (m_Numbers, 12, ipv4Bytes, 0, 4);
- return new IPAddress (ipv4Bytes);
- }
-
- public IPAddress MapToIPv6 ()
- {
- if (AddressFamily == AddressFamily.InterNetworkV6)
- return this;
- if (AddressFamily != AddressFamily.InterNetwork)
- throw new Exception ("Only AddressFamily.InterNetworkV4 can be converted to IPv6");
-
- byte [] ipv4Bytes = GetAddressBytes ();
- byte [] ipv6Bytes = new byte [16] {
- 0,0, 0,0, 0,0, 0,0, 0,0, 0xFF,0xFF,
- ipv4Bytes [0], ipv4Bytes [1], ipv4Bytes [2], ipv4Bytes [3]
- };
- return new IPAddress (ipv6Bytes);
- }
-
-#endif
-
- /// <summary>
- /// Used to tell whether an address is a loopback.
- /// All IP addresses of the form 127.X.Y.Z, where X, Y, and Z are in
- /// the range 0-255, are loopback addresses.
- /// </summary>
- /// <param name="addr">Address to compare</param>
- /// <returns></returns>
- public static bool IsLoopback (IPAddress address)
- {
- if(address.m_Family == AddressFamily.InterNetwork)
- return (address.m_Address & 0xFF) == 127;
- else {
- for(int i=0; i<6; i++) {
- if(address.m_Numbers[i] != 0)
- return false;
- }
-
- return NetworkToHostOrder((short)address.m_Numbers[7]) == 1;
- }
- }
-
- /// <summary>
- /// Overrides System.Object.ToString to return
- /// this object rendered in a quad-dotted notation
- /// </summary>
- public override string ToString ()
- {
- if(m_Family == AddressFamily.InterNetwork)
- return ToString (m_Address);
- else
- {
- ushort[] numbers = m_Numbers.Clone() as ushort[];
-
- for(int i=0; i<numbers.Length; i++)
- numbers[i] = (ushort)NetworkToHostOrder((short)numbers[i]);
-
- IPv6Address v6 = new IPv6Address(numbers);
- v6.ScopeId = ScopeId;
- return v6.ToString();
- }
- }
-
- /// <summary>
- /// Returns this object rendered in a quad-dotted notation
- /// </summary>
- static string ToString (long addr)
- {
- // addr is in network order
- return (addr & 0xff).ToString () + "." +
- ((addr >> 8) & 0xff).ToString () + "." +
- ((addr >> 16) & 0xff).ToString () + "." +
- ((addr >> 24) & 0xff).ToString ();
- }
-
- /// <returns>
- /// Whether both objects are equal.
- /// </returns>
- public override bool Equals (object comparand)
- {
- IPAddress otherAddr = comparand as IPAddress;
- if (otherAddr != null){
- if(AddressFamily != otherAddr.AddressFamily)
- return false;
-
- if(AddressFamily == AddressFamily.InterNetwork) {
- return m_Address == otherAddr.m_Address;
- } else {
- ushort[] vals = otherAddr.m_Numbers;
-
- for(int i=0; i<8; i++)
- if(m_Numbers[i] != vals[i])
- return false;
-
- return true;
- }
- }
- return false;
- }
-
- public override int GetHashCode ()
- {
- if(m_Family == AddressFamily.InterNetwork)
- return (int)m_Address;
- else
- return Hash (((((int) m_Numbers[0]) << 16) + m_Numbers [1]),
- ((((int) m_Numbers [2]) << 16) + m_Numbers [3]),
- ((((int) m_Numbers [4]) << 16) + m_Numbers [5]),
- ((((int) m_Numbers [6]) << 16) + m_Numbers [7]));
- }
-
- private static int Hash (int i, int j, int k, int l)
- {
- return i ^ (j << 13 | j >> 19) ^ (k << 26 | k >> 6) ^ (l << 7 | l >> 25);
- }
-
-#pragma warning disable 169
- // Added for serialization compatibility with MS.NET
- private int m_HashCode;
-#pragma warning restore
-
- }
-}
+++ /dev/null
-//
-// System.Net.IPEndPoint.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// (C) Ximian, Inc. http://www.ximian.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.Net.Sockets;
-
-namespace System.Net {
- [Serializable]
- public class IPEndPoint : EndPoint {
-
- private IPAddress address;
- private int port;
-
- public const int MaxPort = 65535;
- public const int MinPort = 0;
-
- public IPEndPoint (IPAddress address, int port)
- {
- if (address == null)
- throw new ArgumentNullException ("address");
-
- Address = address;
- Port = port;
- }
-
- public IPEndPoint (long address, int port)
- {
- Address = new IPAddress (address);
- Port = port;
- }
-
- public IPAddress Address {
- get {
- return (address);
- }
- set {
- address=value;
- }
- }
-
- public override AddressFamily AddressFamily {
- get {
- return address.AddressFamily;
- }
- }
-
- public int Port {
- get {
- return port;
- }
- set {
- // LAMESPEC: no mention of sanity checking
- // PS: MS controls the range when setting the value
- if (value < MinPort || value > MaxPort)
- throw new ArgumentOutOfRangeException ("Invalid port");
-
- port = value;
- }
- }
-
- // bytes 2 and 3 store the port, the rest
- // stores the address
- public override EndPoint Create (SocketAddress socketAddress)
- {
- if (socketAddress == null)
- throw new ArgumentNullException ("socketAddress");
-
- if (socketAddress.Family != AddressFamily)
- throw new ArgumentException ("The IPEndPoint was created using " + AddressFamily +
- " AddressFamily but SocketAddress contains " + socketAddress.Family +
- " instead, please use the same type.");
-
- SocketAddress sockaddr = socketAddress;
- int size =sockaddr.Size;
- AddressFamily family = sockaddr.Family;
- int port;
-
- IPEndPoint ipe = null;
- switch(family)
- {
- case AddressFamily.InterNetwork:
- if (size < 8) {
- return(null);
- }
-
- port = (((int)sockaddr[2])<<8) + (int)sockaddr[3];
- long address=(((long)sockaddr[7])<<24) +
- (((long)sockaddr[6])<<16) +
- (((long)sockaddr[5])<<8) +
- (long)sockaddr[4];
-
- ipe = new IPEndPoint(address, port);
- break;
- case AddressFamily.InterNetworkV6:
- if (size < 28) {
- return(null);
- }
-
- port = (((int)sockaddr[2])<<8) + (int)sockaddr[3];
-
- /// maybe flowid ?
- /*
- int unknown = (int)sockaddr[4] +
- (((int)sockaddr[5])<<8) +
- (((int)sockaddr[6])<<16) +
- (((int)sockaddr[7])<<24);
- */
-
- int scopeId = (int)sockaddr[24] +
- (((int)sockaddr[25])<<8) +
- (((int)sockaddr[26])<<16) +
- (((int)sockaddr[27])<<24);
-
- ushort[] addressData = new ushort[8];
- for(int i=0; i<8; i++)
- addressData[i] = (ushort)((sockaddr[8+i*2] << 8) + sockaddr[8+i*2+1]);
-
- ipe = new IPEndPoint (new IPAddress(addressData, scopeId), port);
- break;
- default:
- return null;
- }
-
- return(ipe);
- }
-
- public override SocketAddress Serialize() {
- SocketAddress sockaddr = null;
-
- switch (address.AddressFamily)
- {
- case AddressFamily.InterNetwork:
- // .net produces a 16 byte buffer, even though
- // only 8 bytes are used. I guess its just a
- // holdover from struct sockaddr padding.
- sockaddr = new SocketAddress(AddressFamily.InterNetwork, 16);
-
- // bytes 2 and 3 store the port, the rest
- // stores the address
- sockaddr [2] = (byte) ((port>>8) & 0xff);
- sockaddr [3] = (byte) (port & 0xff);
- long addr = address.InternalIPv4Address;
- sockaddr [4] = (byte) (addr & 0xff);
- sockaddr [5] = (byte) ((addr >> 8) & 0xff);
- sockaddr [6] = (byte) ((addr >> 16) & 0xff);
- sockaddr [7] = (byte) ((addr >> 24) & 0xff);
- break;
-
- case AddressFamily.InterNetworkV6:
- sockaddr = new SocketAddress(AddressFamily.InterNetworkV6, 28);
-
- sockaddr [2] = (byte) ((port>>8) & 0xff);
- sockaddr [3] = (byte) (port & 0xff);
-
- byte[] addressBytes = address.GetAddressBytes();
- for(int i=0; i<16; i++)
- sockaddr[8+i] = addressBytes[i];
-
- sockaddr [24] = (byte) (address.ScopeId & 0xff);
- sockaddr [25] = (byte) ((address.ScopeId >> 8) & 0xff);
- sockaddr [26] = (byte) ((address.ScopeId >> 16) & 0xff);
- sockaddr [27] = (byte) ((address.ScopeId >> 24) & 0xff);
- break;
- }
-
- return(sockaddr);
- }
-
- public override string ToString() {
- return(address.ToString() + ":" + port);
- }
-
- public override bool Equals (object comparand)
- {
- IPEndPoint p = comparand as IPEndPoint;
- return p != null &&
- p.port == port &&
- p.address.Equals (address);
- }
-
- public override int GetHashCode ()
- {
- return address.GetHashCode () + port;
- }
- }
-}
+++ /dev/null
-// System.Net.IPHostEntry.cs
-//
-// Author: Mads Pultz (mpultz@diku.dk)
-//
-// (C) Mads Pultz, 2001
-
-//
-// 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;
-
-namespace System.Net {
-
- public class IPHostEntry {
- private IPAddress[] addressList;
- private String[] aliases;
- private String hostName;
-
- public IPHostEntry() {
- }
-
- public IPAddress[] AddressList {
- get { return addressList; }
- set { addressList = value; }
- }
-
- public string[] Aliases {
- get { return aliases; }
- set { aliases = value; }
- }
-
- public string HostName {
- get { return hostName; }
- set { hostName = value; }
- }
-
-/* According to the .NET Framework SDK Documentation (beta 2) the following
- methods from Object are not overrided. I implemented them before realizing
- this but I leave the implementation here if needed in the future.
-
- public override string ToString() {
- string res = hostName;
- if (addressList != null && addressList.Length > 0)
- res += " [" + addressList[0] + "]";
- return res;
- }
-
- public override bool Equals(object obj) {
- if (obj is IPHostEntry) {
- IPHostEntry h = (IPHostEntry)obj;
- return hostName.Equals(h.HostName) && aliases.Equals(h.Aliases) &&
- addressList.Equals(h.AddressList);
- }
- else
- return false;
- }
-
- public override int GetHashCode() {
- return hostName.GetHashCode();
- }
-
- protected new object MemberwiseClone() {
- IPHostEntry res = new IPHostEntry();
- res.AddressList = new IPAddress[addressList.Length];
- Array.Copy(addressList, res.AddressList, addressList.Length);
- res.Aliases = new String[aliases.Length];
- Array.Copy(aliases, res.Aliases, aliases.Length);
- res.HostName = hostName;
- return res;
- }
-*/
- }
-}
-
//\r
-// System.Net.IPv6Address.cs\r
+// System.Net.IPv6AddressFormatter.cs\r
//\r
// Author:\r
// Lawrence Pit (loz@cable.a2000.nl)\r
-//\r
-// Note I: This class is not defined in the specs of .Net\r
-//\r
-// Note II : The name of this class is perhaps unfortunate as it turns\r
-// out that in ms.net there's an internal class called\r
-// IPv6Address in namespace System.\r
-//\r
-\r
//\r
// Permission is hereby granted, free of charge, to any person obtaining\r
// a copy of this software and associated documentation files (the\r
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
//\r
\r
-\r
-using System;\r
using System.Globalization;\r
-using System.Net.Sockets;\r
-using System.Runtime.InteropServices;\r
using System.Text;\r
\r
namespace System.Net {\r
\r
- /// <remarks>\r
- /// Encapsulates an IPv6 Address.\r
- /// See RFC 2373 for more info on IPv6 addresses.\r
- /// </remarks>\r
- [Serializable]\r
- internal class IPv6Address {\r
- private ushort [] address;\r
- private int prefixLength;\r
- private long scopeId = 0;\r
-\r
- public static readonly IPv6Address Loopback = IPv6Address.Parse ("::1");\r
- public static readonly IPv6Address Unspecified = IPv6Address.Parse ("::");\r
+ struct IPv6AddressFormatter\r
+ {\r
+ ushort [] address;\r
+ long scopeId;\r
\r
- public IPv6Address (ushort [] addr)\r
- {\r
- if (addr == null)\r
- throw new ArgumentNullException ("addr"); \r
- if (addr.Length != 8) \r
- throw new ArgumentException ("addr");\r
- address = addr; \r
- }\r
- \r
- public IPv6Address (ushort [] addr, int prefixLength) : this (addr)\r
- {\r
- if (prefixLength < 0 || prefixLength > 128)\r
- throw new ArgumentException ("prefixLength");\r
- this.prefixLength = prefixLength;\r
- }\r
- \r
- public IPv6Address (ushort [] addr, int prefixLength, int scopeId) : this (addr, prefixLength)\r
+ public IPv6AddressFormatter (ushort[] addr, long scopeId)\r
{\r
+ this.address = addr;\r
this.scopeId = scopeId;\r
}\r
\r
- public static IPv6Address Parse (string ipString)\r
- {\r
- if (ipString == null)\r
- throw new ArgumentNullException ("ipString");\r
-\r
- IPv6Address result;\r
- if (TryParse (ipString, out result))\r
- return result;\r
- throw new FormatException ("Not a valid IPv6 address");\r
- }\r
-\r
- static int Fill (ushort [] addr, string ipString)\r
- {\r
- int p = 0;\r
- int pdigits = 0;\r
- int slot = 0;\r
-\r
- if (ipString.Length == 0)\r
- return 0;\r
- \r
- // Catch double uses of ::\r
- if (ipString.IndexOf ("::", StringComparison.Ordinal) != -1)\r
- return -1;\r
-\r
- for (int i = 0; i < ipString.Length; i++){\r
- char c = ipString [i];\r
- int n;\r
-\r
- if (c == ':'){\r
- // Leading : is not allowed.\r
- if (i == 0)\r
- return -1;\r
- \r
- // Trailing : is not allowed.\r
- if (i == ipString.Length-1)\r
- return -1;\r
- \r
- if (slot == 8)\r
- return -1;\r
- \r
- addr [slot++] = (ushort) p;\r
- p = 0;\r
- pdigits = 0;\r
- continue;\r
- }\r
- pdigits++;\r
- if (pdigits > 4)\r
- return -1;\r
- if ('0' <= c && c <= '9')\r
- n = (int) (c - '0');\r
- else if ('a' <= c && c <= 'f')\r
- n = (int) (c - 'a' + 10);\r
- else if ('A' <= c && c <= 'F')\r
- n = (int) (c - 'A' + 10);\r
- else \r
- return -1;\r
- p = (p << 4) + n;\r
- if (p > UInt16.MaxValue)\r
- return -1;\r
- }\r
-\r
- if (slot == 8)\r
- return -1;\r
- \r
- addr [slot++] = (ushort) p;\r
-\r
- return slot;\r
- }\r
-\r
- static bool TryParse (string prefix, out int res)\r
- {\r
- return Int32.TryParse (prefix, NumberStyles.Integer, CultureInfo.InvariantCulture, out res);\r
- }\r
- \r
- public static bool TryParse (string ipString, out IPv6Address result)\r
- {\r
- result = null;\r
- if (ipString == null)\r
- return false;\r
-\r
- if (ipString.Length > 2 && \r
- ipString [0] == '[' && \r
- ipString [ipString.Length - 1] == ']')\r
- ipString = ipString.Substring (1, ipString.Length - 2);\r
-\r
- if (ipString.Length < 2)\r
- return false;\r
-\r
- int prefixLen = 0;\r
- int scopeId = 0;\r
- int pos = ipString.LastIndexOf ('/');\r
- if (pos != -1) {\r
- string prefix = ipString.Substring (pos + 1);\r
- if (!TryParse (prefix , out prefixLen))\r
- prefixLen = -1;\r
- if (prefixLen < 0 || prefixLen > 128)\r
- return false;\r
- ipString = ipString.Substring (0, pos);\r
- } else {\r
- pos = ipString.LastIndexOf ('%');\r
- if (pos != -1) {\r
- string prefix = ipString.Substring (pos + 1);\r
- if (!TryParse (prefix, out scopeId))\r
- scopeId = 0;\r
- ipString = ipString.Substring (0, pos);\r
- } \r
- }\r
-\r
- //\r
- // At this point the prefix/suffixes have been removed\r
- // and we only have to deal with the ipv4 or ipv6 addressed\r
- //\r
- ushort [] addr = new ushort [8];\r
-\r
- //\r
- // Is there an ipv4 address at the end?\r
- //\r
- int pos2 = ipString.LastIndexOf (':');\r
- if (pos2 == -1)\r
- return false;\r
-\r
- int slots = 0;\r
- if (pos2 < (ipString.Length - 1)) {\r
- string ipv4Str = ipString.Substring (pos2 + 1);\r
- if (ipv4Str.IndexOf ('.') != -1) {\r
- IPAddress ip;\r
- \r
- if (!IPAddress.TryParse (ipv4Str, out ip))\r
- return false;\r
- \r
- long a = ip.InternalIPv4Address;\r
- addr [6] = (ushort) (((int) (a & 0xff) << 8) + ((int) ((a >> 8) & 0xff)));\r
- addr [7] = (ushort) (((int) ((a >> 16) & 0xff) << 8) + ((int) ((a >> 24) & 0xff)));\r
- if (pos2 > 0 && ipString [pos2 - 1] == ':') \r
- ipString = ipString.Substring (0, pos2 + 1);\r
- else\r
- ipString = ipString.Substring (0, pos2);\r
- slots = 2;\r
- }\r
- } \r
-\r
- //\r
- // Only an ipv6 block remains, either:\r
- // "hexnumbers::hexnumbers", "hexnumbers::" or "hexnumbers"\r
- //\r
- int c = ipString.IndexOf ("::", StringComparison.Ordinal);\r
- if (c != -1){\r
- int right_slots = Fill (addr, ipString.Substring (c+2));\r
- if (right_slots == -1){\r
- return false;\r
- }\r
-\r
- if (right_slots + slots > 8){\r
- return false;\r
- }\r
-\r
- int d = 8-slots-right_slots;\r
- for (int i = right_slots; i > 0; i--){\r
- addr [i+d-1] = addr [i-1];\r
- addr [i-1] = 0;\r
- }\r
- \r
- int left_slots = Fill (addr, ipString.Substring (0, c));\r
- if (left_slots == -1)\r
- return false;\r
-\r
- if (left_slots + right_slots + slots > 7)\r
- return false;\r
- } else {\r
- if (Fill (addr, ipString) != 8-slots)\r
- return false;\r
- }\r
-\r
- result = new IPv6Address (addr, prefixLen, scopeId);\r
- return true;\r
- }\r
-\r
- public ushort [] Address {\r
- get { return address; }\r
- }\r
-\r
- public int PrefixLength {\r
- get { return this.prefixLength; }\r
- }\r
- \r
- public long ScopeId {\r
- get {\r
- return scopeId;\r
- }\r
- set {\r
- scopeId = value;\r
- }\r
- }\r
-\r
- public ushort this [int index] {\r
- get { return address [index]; }\r
- } \r
-\r
- public AddressFamily AddressFamily {\r
- get { return AddressFamily.InterNetworkV6; }\r
- }\r
-\r
- public static bool IsLoopback (IPv6Address addr)\r
- {\r
- if (addr.address [7] != 1)\r
- return false;\r
-\r
- int x = addr.address [6] >> 8;\r
- if (x != 0x7f && x != 0)\r
- return false;\r
-\r
- for (int i = 0; i < 4; i++) {\r
- if (addr.address [i] != 0)\r
- return false;\r
- }\r
-\r
- if (addr.address [5] != 0 && addr.address [5] != 0xffff)\r
- return false;\r
-\r
- return true;\r
- }\r
-\r
- private static ushort SwapUShort (ushort number)\r
+ static ushort SwapUShort (ushort number)\r
{\r
return (ushort) ( ((number >> 8) & 0xFF) + ((number << 8) & 0xFF00) );\r
}\r
\r
// Convert the address into a format expected by the IPAddress (long) ctor\r
// This needs to be unsigned to satisfy the '> 1' test in IsIPv4Compatible()\r
- private uint AsIPv4Int ()\r
+ uint AsIPv4Int ()\r
{\r
return (uint)(SwapUShort (address [7]) << 16) + SwapUShort (address [6]);\r
} \r
\r
- public bool IsIPv4Compatible ()\r
+ bool IsIPv4Compatible ()\r
{\r
for (int i = 0; i < 6; i++) \r
if (address [i] != 0)\r
return (AsIPv4Int () > 1);\r
}\r
\r
- public bool IsIPv4Mapped ()\r
+ bool IsIPv4Mapped ()\r
{\r
for (int i = 0; i < 5; i++) \r
if (address [i] != 0)\r
return address [5] == 0xffff;\r
}\r
\r
- /// <summary>\r
- /// Overrides System.Object.ToString to return\r
- /// this object rendered in a canonicalized notation\r
- /// </summary>\r
public override string ToString ()\r
{\r
StringBuilder s = new StringBuilder ();\r
\r
return s.ToString ();\r
}\r
- else\r
- {\r
- int bestChStart = -1; // Best chain start\r
- int bestChLen = 0; // Best chain length\r
- int currChLen = 0; // Current chain length\r
+ \r
+ int bestChStart = -1; // Best chain start\r
+ int bestChLen = 0; // Best chain length\r
+ int currChLen = 0; // Current chain length\r
\r
- // Looks for the longest zero chain\r
- for (int i=0; i<8; i++)\r
+ // Looks for the longest zero chain\r
+ for (int i=0; i<8; i++)\r
+ {\r
+ if (address[i] != 0)\r
{\r
- if (address[i] != 0)\r
+ if ((currChLen > bestChLen) \r
+ && (currChLen > 1))\r
{\r
- if ((currChLen > bestChLen) \r
- && (currChLen > 1))\r
- {\r
- bestChLen = currChLen;\r
- bestChStart = i - currChLen;\r
- }\r
- currChLen = 0;\r
+ bestChLen = currChLen;\r
+ bestChStart = i - currChLen;\r
}\r
- else\r
- currChLen++;\r
- }\r
- if ((currChLen > bestChLen) \r
- && (currChLen > 1))\r
- {\r
- bestChLen = currChLen;\r
- bestChStart = 8 - currChLen;\r
+ currChLen = 0;\r
}\r
+ else\r
+ currChLen++;\r
+ }\r
+ if ((currChLen > bestChLen) \r
+ && (currChLen > 1))\r
+ {\r
+ bestChLen = currChLen;\r
+ bestChStart = 8 - currChLen;\r
+ }\r
\r
- // makes the string\r
- if (bestChStart == 0)\r
- s.Append(":");\r
- for (int i=0; i<8; i++)\r
+ // makes the string\r
+ if (bestChStart == 0)\r
+ s.Append(":");\r
+ for (int i=0; i<8; i++)\r
+ {\r
+ if (i == bestChStart)\r
{\r
- if (i == bestChStart)\r
- {\r
- s.Append (":");\r
- i += (bestChLen - 1);\r
- continue;\r
- }\r
- s.AppendFormat("{0:x}", address [i]);\r
- if (i < 7) s.Append (':');\r
+ s.Append (":");\r
+ i += (bestChLen - 1);\r
+ continue;\r
}\r
+ s.AppendFormat("{0:x}", address [i]);\r
+ if (i < 7) s.Append (':');\r
}\r
+ \r
if (scopeId != 0)\r
s.Append ('%').Append (scopeId);\r
return s.ToString ();\r
}\r
-\r
- public string ToString (bool fullLength)\r
- {\r
- if (!fullLength)\r
- return ToString ();\r
-\r
- StringBuilder sb = new StringBuilder ();\r
- for (int i=0; i < address.Length - 1; i++) {\r
- sb.AppendFormat ("{0:X4}:", address [i]);\r
- }\r
- sb.AppendFormat ("{0:X4}", address [address.Length - 1]);\r
- return sb.ToString ();\r
- }\r
-\r
- /// <returns>\r
- /// Whether both objects are equal.\r
- /// </returns>\r
- public override bool Equals (object other)\r
- {\r
- System.Net.IPv6Address ipv6 = other as System.Net.IPv6Address;\r
- if (ipv6 != null) {\r
- for (int i = 0; i < 8; i++) \r
- if (this.address [i] != ipv6.address [i])\r
- return false;\r
- return true;\r
- }\r
- \r
- System.Net.IPAddress ipv4 = other as System.Net.IPAddress;\r
- if (ipv4 != null) {\r
- for (int i = 0; i < 5; i++) \r
- if (address [i] != 0)\r
- return false;\r
-\r
- if (address [5] != 0 && address [5] != 0xffff)\r
- return false;\r
-\r
- long a = ipv4.InternalIPv4Address;\r
- if (address [6] != (ushort) (((int) (a & 0xff) << 8) + ((int) ((a >> 8) & 0xff))) ||\r
- address [7] != (ushort) (((int) ((a >> 16) & 0xff) << 8) + ((int) ((a >> 24) & 0xff))))\r
- return false;\r
-\r
- return true;\r
- }\r
- \r
- return false;\r
- }\r
-\r
- public override int GetHashCode ()\r
- {\r
- return Hash (((((int) address [0]) << 16) + address [1]), \r
- ((((int) address [2]) << 16) + address [3]),\r
- ((((int) address [4]) << 16) + address [5]),\r
- ((((int) address [6]) << 16) + address [7]));\r
- }\r
- \r
- private static int Hash (int i, int j, int k, int l) \r
- {\r
- return i ^ (j << 13 | j >> 19) ^ (k << 26 | k >> 6) ^ (l << 7 | l >> 25);\r
- }\r
}\r
}\r
+++ /dev/null
-//
-// System.Net.IWebProxy.cs
-//
-// Author:
-// Lawrence Pit (loz@cable.a2000.nl)
-//
-
-//
-// 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;
-
-namespace System.Net {
-
- // <remarks>
- // </remarks>
- public interface IWebProxy {
- ICredentials Credentials {
- get;
- set;
- }
-
- Uri GetProxy (Uri destination);
-
- bool IsBypassed (Uri host);
- }
-}
+++ /dev/null
-//
-// System.Net.IWebRequestCreate.cs
-//
-// Author:
-// Lawrence Pit (loz@cable.a2000.nl)
-//
-
-//
-// 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.
-//
-
-namespace System.Net {
-
- public interface IWebRequestCreate {
- WebRequest Create (Uri uri);
- }
-}
+++ /dev/null
-// NetworkAccess.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:35:58 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.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.
-//
-
-
-namespace System.Net {
- [Flags]
- public enum NetworkAccess {
- Accept = 128,
-
- Connect = 64,
- }
-
-}
+++ /dev/null
-//\r
-// System.Net.ProtocolViolationException.cs\r
-//\r
-// Author:\r
-// Lawrence Pit (loz@cable.a2000.nl)\r
-//\r
-\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System.Globalization;\r
-using System.Runtime.Serialization;\r
-\r
-namespace System.Net \r
-{\r
- [Serializable]\r
- public class ProtocolViolationException : InvalidOperationException, ISerializable\r
- {\r
-\r
- // Constructors\r
- public ProtocolViolationException () : base ()\r
- {\r
- }\r
- \r
- public ProtocolViolationException (string message) : base (message)\r
- {\r
- }\r
-\r
- protected ProtocolViolationException (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- : base (serializationInfo, streamingContext)\r
- {\r
- }\r
-\r
- // Methods\r
- void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)\r
- {\r
- base.GetObjectData (info, context);\r
- }\r
-\r
- public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- {\r
- base.GetObjectData (serializationInfo, streamingContext);\r
- }\r
- }\r
-}\r
- \r
+++ /dev/null
-//
-// System.Net.SecurityProtocolType.cs
-//
-// Authors
-// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-// Sebastien Pouliot <sebastien@ximian.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.
-//
-
-namespace System.Net {
-
- [Flags]
- public
- enum SecurityProtocolType {
- Ssl3 = 48,
- Tls = 192,
- Tls11 = 768,
- Tls12 = 3072
- }
-}
+++ /dev/null
-//
-// System.Net.SocketAddress.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-// Dick Porter (dick@ximian.com)
-//
-// (C) Ximian, Inc. http://www.ximian.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.Net.Sockets;
-
-namespace System.Net {
-
- public class SocketAddress {
- private byte[] data;
-
- public SocketAddress (AddressFamily family, int size)
- {
- if(size<2) {
- throw new ArgumentOutOfRangeException("size is too small");
- }
-
- data=new byte[size];
- data[0]=(byte)family;
- data[1]=(byte) ((int) family >> 8);
- }
-
- public SocketAddress (AddressFamily family)
- : this (family, 32)
- {
- }
-
- //LAMESPEC: the MS doc about this class is wrong. The size is not stored in byte 1. Instead
- // byte [0] and byte [1] hold the family (little endian).
- public AddressFamily Family {
- get {
- return (AddressFamily) (data [0] + (data [1] << 8));
- }
- }
-
- public int Size {
- get {
- return data.Length;
- }
- }
-
- public byte this [ int offset ] {
- get {
- return(data[offset]);
- }
-
- set {
- data[offset]=value;
- }
- }
-
- public override string ToString() {
- string af=((AddressFamily)data[0]).ToString();
- int size = data.Length;
- string ret=af+":"+size+":{";
-
- for(int i=2; i<size; i++) {
- int val=(int)data[i];
- ret=ret+val;
- if(i<size-1) {
- ret=ret+",";
- }
- }
-
- ret=ret+"}";
-
- return(ret);
- }
-
- public override bool Equals (object comparand)
- {
- SocketAddress sa = (comparand as SocketAddress);
- if ((sa != null) && (sa.data.Length == data.Length)) {
- byte [] otherData = sa.data;
- for (int i = 0; i < data.Length; i++)
- if (otherData [i] != data [i])
- return false;
-
- return true;
- }
-
- return false;
- }
-
- public override int GetHashCode ()
- {
- int code = 0;
-
- for (int i = 0; i < data.Length; i++)
- code += data [i] + i;
-
- return code;
- }
- }
-}
+++ /dev/null
-//
-// TransportContext.cs
-//
-// Authors:
-// Marek Safar <marek.safar@gmail.com>
-//
-// Copyright (C) 2011 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.Security.Authentication.ExtendedProtection;
-
-namespace System.Net
-{
- public abstract class TransportContext
- {
- public abstract ChannelBinding GetChannelBinding (ChannelBindingKind kind);
- }
-}
-
+++ /dev/null
-// TransportType.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:32:18 UTC
-// Source file: AllTypes.xml
-// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.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.
-//
-
-
-namespace System.Net {
-
-
- /// <summary>
- /// </summary>
- public enum TransportType {
-
- /// <summary>
- /// </summary>
- Udp = 1,
-
- /// <summary>
- /// </summary>
- Connectionless = 1,
-
- /// <summary>
- /// </summary>
- Tcp = 2,
-
- /// <summary>
- /// </summary>
- ConnectionOriented = 2,
-
- /// <summary>
- /// </summary>
- All = 3,
- } // TransportType
-
-} // System.Net
+++ /dev/null
-//
-// UploadProgressChangedEventHandler.cs
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.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.
-//
-namespace System.Net
-{
- public delegate void UploadProgressChangedEventHandler (object sender, UploadProgressChangedEventArgs e);
-}
-
var auth = AuthenticationManager.Authenticate (challenge [i], connect_request, creds);
if (auth == null)
continue;
- ntlm = (auth.Module.AuthenticationType == "NTLM");
+ ntlm = (auth.ModuleAuthenticationType == "NTLM");
sb.Append ("\r\nProxy-Authorization: ");
sb.Append (auth.Message);
break;
AsyncCallback cb, object state)
{
if (request.Aborted)
- throw new WebException ("The request was canceled.", null, WebExceptionStatus.RequestCanceled);
+ throw new WebException ("The request was canceled.", WebExceptionStatus.RequestCanceled);
if (isRead)
throw new NotSupportedException ("this stream does not allow writing");
} catch (WebException e) {
result.SetCompleted (false, e);
} catch (Exception e) {
- result.SetCompleted (false, new WebException ("Error writing headers", e, WebExceptionStatus.SendFailure));
+ result.SetCompleted (false, new WebException ("Error writing headers", WebExceptionStatus.SendFailure, WebExceptionInternalStatus.RequestFatal, e));
}
}, null);
IOException io = new IOException ("Cannot close the stream until all bytes are written");
nextReadCalled = true;
cnc.Close (true);
- throw new WebException ("Request was cancelled.", io, WebExceptionStatus.RequestCanceled);
+ throw new WebException ("Request was cancelled.", WebExceptionStatus.RequestCanceled, WebExceptionInternalStatus.RequestFatal, io);
}
// Commented out the next line to fix xamarin bug #1512
+++ /dev/null
-//\r
-// System.Net.WebException.cs\r
-//\r
-// Author:\r
-// Lawrence Pit (loz@cable.a2000.nl)\r
-//\r
-\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System.Runtime.Serialization;\r
-\r
-namespace System.Net \r
-{\r
- [Serializable]\r
- public class WebException : InvalidOperationException, ISerializable {\r
- private WebResponse response;\r
- private WebExceptionStatus status = WebExceptionStatus.UnknownError;\r
-\r
- // Constructors\r
- \r
- public WebException () : base ()\r
- {\r
- }\r
- \r
- public WebException (string message) : base (message)\r
- {\r
- }\r
-\r
- protected WebException (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- : base (serializationInfo, streamingContext)\r
- {\r
- }\r
-\r
- public WebException (string message, Exception innerException)\r
- : base (message, innerException)\r
- {\r
- }\r
-\r
- public WebException (string message, WebExceptionStatus status)\r
- : base (message)\r
- {\r
- this.status = status;\r
- }\r
- \r
- internal WebException (string message, Exception innerException, WebExceptionStatus status)\r
- : base (message, innerException)\r
- {\r
- this.status = status;\r
- }\r
-\r
- public WebException(string message, \r
- Exception innerException,\r
- WebExceptionStatus status, \r
- WebResponse response)\r
- : base (message, innerException)\r
- {\r
- this.status = status;\r
- this.response = response;\r
- }\r
- \r
- // Properties\r
- \r
- public WebResponse Response {\r
- get { return this.response; }\r
- }\r
- \r
- public WebExceptionStatus Status {\r
- get { return this.status; }\r
- }\r
- \r
- // Methods\r
- void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)\r
- {\r
- base.GetObjectData (info, context);\r
- }\r
-\r
- public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- {\r
- base.GetObjectData (serializationInfo,\r
- streamingContext);\r
- }\r
- }\r
-}\r
+++ /dev/null
-// System.Net.WebExceptionStatus.cs
-//
-// Author:
-// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-// originally autogenerated by Sergey Chaban (serge@wildwestsoftware.com)
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.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.
-//
-
-namespace System.Net
-{
- public
- enum WebExceptionStatus
- {
- Success = 0,
- NameResolutionFailure = 1,
- ConnectFailure = 2,
- ReceiveFailure = 3,
- SendFailure = 4,
- PipelineFailure = 5,
- RequestCanceled = 6,
- ProtocolError = 7,
- ConnectionClosed = 8,
- TrustFailure = 9,
- SecureChannelFailure = 10,
- ServerProtocolViolation = 11,
- KeepAliveFailure = 12,
- Pending = 13,
- Timeout = 14,
- ProxyNameResolutionFailure = 15,
-
-
- UnknownError = 16,
- MessageLengthLimitExceeded = 17,
-
- CacheEntryNotFound = 18,
- RequestProhibitedByCachePolicy = 19,
- RequestProhibitedByProxy = 20,
-
- }
-}
if (!IsHeaderValue (headerValue))
throw new ArgumentException ("invalid header value: " + headerValue, "headerValue");
- AddValue (headerName, headerValue);
+ AddInternal (headerName, headerValue);
}
- internal void AddValue (string headerName, string headerValue)
+ internal void AddInternal (string headerName, string headerValue)
{
base.Add (headerName, headerValue);
}
static IWebProxy defaultWebProxy;
static RequestCachePolicy defaultCachePolicy;
+ internal const int DefaultTimeout = 100000;
+
static WebRequest ()
{
#if MOBILE
void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
{
- throw new NotSupportedException ();
+ GetObjectData(serializationInfo, streamingContext);
}
protected virtual void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
{
- throw GetMustImplement ();
}
public static bool RegisterPrefix (string prefix, IWebRequestCreate creator)
{
return Task<WebResponse>.Factory.FromAsync (BeginGetResponse, EndGetResponse, null);
}
-
}
}
+++ /dev/null
-//
-// System.Net.WebRequestMethods.cs
-//
-// Author:
-// Carlos Alberto Cortez (calberto.oortez@gmail.com)
-//
-// (c) Copyright 2005 Novell, Inc. (http://www.ximian.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.
-//
-
-namespace System.Net
-{
- public static class WebRequestMethods
- {
- public static class File
- {
- public const string DownloadFile = "GET";
- public const string UploadFile = "PUT";
- }
-
- public static class Ftp
- {
- public const string AppendFile = "APPE";
- public const string DeleteFile = "DELE";
- public const string DownloadFile = "RETR";
- public const string GetFileSize = "SIZE";
- public const string GetDateTimestamp = "MDTM";
- public const string ListDirectory = "NLST";
- public const string ListDirectoryDetails = "LIST";
- public const string MakeDirectory = "MKD";
- public const string PrintWorkingDirectory = "PWD";
- public const string RemoveDirectory = "RMD";
- public const string Rename = "RENAME";
- public const string UploadFile = "STOR";
- public const string UploadFileWithUniqueName = "STOU";
- }
-
- public static class Http
- {
- public const string Connect = "CONNECT";
- public const string Get = "GET";
- public const string Head = "HEAD";
- public const string MkCol = "MKCOL";
- public const string Post = "POST";
- public const string Put = "PUT";
- }
- }
-}
-
-
+++ /dev/null
-//\r
-// System.Net.WebResponse\r
-//\r
-// Author:\r
-// Lawrence Pit (loz@cable.a2000.nl)\r
-//\r
-\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System;\r
-using System.IO;\r
-using System.Runtime.Serialization;\r
-\r
-namespace System.Net \r
-{\r
- [Serializable]\r
- public abstract class WebResponse : MarshalByRefObject, ISerializable, IDisposable {\r
- // Constructors\r
- \r
- protected WebResponse () { }\r
- \r
- protected WebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- {\r
- throw new NotSupportedException ();\r
- }\r
- \r
- // Properties\r
- \r
- public virtual long ContentLength { \r
- get { throw new NotSupportedException (); }\r
- set { throw new NotSupportedException (); }\r
- }\r
- \r
- public virtual string ContentType { \r
- get { throw new NotSupportedException (); }\r
- set { throw new NotSupportedException (); }\r
- }\r
- \r
- public virtual WebHeaderCollection Headers { \r
- get { throw new NotSupportedException (); }\r
- }\r
-\r
- static Exception GetMustImplement ()\r
- {\r
- return new NotImplementedException ();\r
- }\r
- \r
- [MonoTODO]\r
- public virtual bool IsFromCache\r
- {\r
- get {\r
- return false;\r
- // Better to return false than to kill the application\r
- // throw GetMustImplement ();\r
- }\r
- }\r
- \r
- [MonoTODO]\r
- public virtual bool IsMutuallyAuthenticated\r
- {\r
- get {\r
- throw GetMustImplement ();\r
- }\r
- }\r
- \r
- public virtual Uri ResponseUri { \r
- get { throw new NotSupportedException (); }\r
- } \r
-\r
- public virtual bool SupportsHeaders {\r
- get {\r
- // The managed stack always returns this as true, it is only\r
- // the Silverlight stack that does not support this.\r
- return true;\r
- }\r
- }\r
- // Methods\r
- \r
- public virtual void Close()\r
- {\r
- throw new NotSupportedException ();\r
- }\r
- \r
- public virtual Stream GetResponseStream()\r
- {\r
- throw new NotSupportedException ();\r
- }\r
- public void Dispose ()\r
- {\r
- Dispose (true);\r
- }\r
- \r
- protected virtual void Dispose (bool disposing)\r
- {\r
- if (disposing)\r
- Close ();\r
- }\r
-\r
- void ISerializable.GetObjectData\r
- (SerializationInfo serializationInfo,\r
- StreamingContext streamingContext)\r
- {\r
- throw new NotSupportedException ();\r
- }\r
-\r
- [MonoTODO]\r
- protected virtual void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
- {\r
- throw GetMustImplement ();\r
- }\r
- }\r
-}\r
System.Media/SystemSounds.cs
System.Media/Win32SoundPlayer.cs
System.Net/AuthenticationManager.cs
-System.Net/AuthenticationSchemes.cs
-System.Net/AuthenticationSchemeSelector.cs
-System.Net/Authorization.cs
System.Net/BasicClient.cs
System.Net/BindIPEndPoint.cs
System.Net/ChunkedInputStream.cs
System.Net.Configuration/WebRequestModuleElement.cs
System.Net.Configuration/WebRequestModuleHandler.cs
System.Net.Configuration/WebRequestModulesSection.cs
-System.Net/ConnectionModes.cs
System.Net/CredentialCache.cs
System.Net/DecompressionMethods.cs
System.Net/DefaultCertificatePolicy.cs
System.Net/DigestClient.cs
System.Net/Dns.cs
-System.Net/DnsEndPoint.cs
System.Net/DnsPermissionAttribute.cs
System.Net/DnsPermission.cs
-System.Net/EndPoint.cs
System.Net/EndPointListener.cs
System.Net/EndPointManager.cs
System.Net/EndpointPermission.cs
-System.Net/FileWebRequestCreator.cs
-System.Net/FileWebRequest.cs
-System.Net/FileWebResponse.cs
System.Net/FtpAsyncResult.cs
System.Net/FtpDataStream.cs
System.Net/FtpRequestCreator.cs
-System.Net/FtpStatusCode.cs
System.Net/FtpWebRequest.cs
System.Net/FtpStatus.cs
System.Net/FtpWebResponse.cs
System.Net/HttpListenerBasicIdentity.cs
System.Net/HttpListenerContext.cs
System.Net/HttpListener.cs
-System.Net/HttpListenerException.cs
System.Net/HttpListenerPrefixCollection.cs
System.Net/HttpListenerRequest.cs
System.Net/HttpListenerResponse.cs
System.Net/HttpListenerTimeoutManager.cs
System.Net/HttpRequestCreator.cs
-System.Net/HttpRequestHeader.cs
-System.Net/HttpResponseHeader.cs
-System.Net/HttpStatusCode.cs
System.Net/HttpStreamAsyncResult.cs
-System.Net/HttpVersion.cs
System.Net/HttpWebRequest.cs
System.Net/HttpWebResponse.cs
-System.Net/IAuthenticationModule.cs
-System.Net/ICertificatePolicy.cs
-System.Net/ICredentialLookup.cs
System.Net/ICredentialPolicy.cs
-System.Net/ICredentialsByHost.cs
-System.Net/IPAddress.cs
-System.Net/IPEndPoint.cs
-System.Net/IPHostEntry.cs
System.Net/IPv6Address.cs
-System.Net/IWebProxy.cs
System.Net/IWebProxyScript.cs
System.Net/IWebConnectionState.cs
-System.Net/IWebRequestCreate.cs
System.Net/ListenerAsyncResult.cs
System.Net/ListenerPrefix.cs
System.Net.Mail/AlternateViewCollection.cs
System.Net/MacProxy.cs
System.Net/MonoHttpDate.cs
System.Net/NetConfig.cs
-System.Net/NetworkAccess.cs
System.Net/NetworkCredential.cs
System.Net.NetworkInformation/DuplicateAddressDetectionState.cs
System.Net.NetworkInformation/GatewayIPAddressInformationCollection.cs
System.Net.NetworkInformation/UnicastIPAddressInformation.cs
System.Net.NetworkInformation/Win32NetworkInterfaceMarshal.cs
System.Net/NtlmClient.cs
-System.Net/ProtocolViolationException.cs
System.Net/RequestStream.cs
System.Net/ResponseStream.cs
../referencesource/System/net/System/Net/SecureProtocols/AuthenticatedStream.cs
System.Net.Security/EncryptionPolicy.cs
System.Net.Security/LocalCertificateSelectionCallback.cs
System.Net.Security/NegotiateStream.cs
-System.Net/SecurityProtocolType.cs
System.Net.Security/RemoteCertificateValidationCallback.cs
System.Net.Security/SslStream.cs
System.Net.Security/SslPolicyErrors.cs
System.Net/ServicePointManager.cs
System.Net/ServicePointManager.extra.cs
System.Net/SimpleAsyncResult.cs
-System.Net/SocketAddress.cs
System.Net/SocketPermissionAttribute.cs
System.Net/SocketPermission.cs
../referencesource/System/net/System/Net/Sockets/AddressFamily.cs
../referencesource/System/net/System/Net/Sockets/TransmitFileFlags.cs
System.Net.Sockets/UdpClient.cs
../referencesource/System/net/System/Net/Sockets/UdpReceiveResult.cs
-System.Net/TransportContext.cs
-System.Net/TransportType.cs
System.Net/WebAsyncResult.cs
System.Net/WebConnection.cs
System.Net/WebConnectionData.cs
System.Net/WebConnectionGroup.cs
System.Net/WebConnectionStream.cs
-System.Net/WebException.cs
-System.Net/WebExceptionStatus.cs
System.Net/WebHeaderCollection.cs
System.Net/WebProxy.cs
System.Net/WebRequest.cs
-System.Net/WebRequestMethods.cs
-System.Net/WebResponse.cs
System.Net.WebSockets/ClientWebSocket.cs
System.Net.WebSockets/ClientWebSocketOptions.cs
System.Net.WebSockets/HttpListenerWebSocketContext.cs
../referencesource/System/net/System/UriScheme.cs
../referencesource/System/net/System/Net/_BufferOffsetSize.cs
+../referencesource/System/net/System/Net/_IStreams.cs
+../referencesource/System/net/System/Net/_NetRes.cs
../referencesource/System/net/System/Net/_LazyAsyncResult.cs
../referencesource/System/net/System/Net/_LoggingObject.cs
../referencesource/System/net/System/Net/_ScatterGatherBuffers.cs
+../referencesource/System/net/System/Net/AuthenticationScheme.cs
+../referencesource/System/net/System/Net/AuthenticationSchemeSelector.cs
+../referencesource/System/net/System/Net/Authorization.cs
../referencesource/System/net/System/Net/cookie.cs
../referencesource/System/net/System/Net/cookiecollection.cs
../referencesource/System/net/System/Net/cookiecontainer.cs
../referencesource/System/net/System/Net/cookieexception.cs
+../referencesource/System/net/System/Net/DnsEndPoint.cs
+../referencesource/System/net/System/Net/EndPoint.cs
+../referencesource/System/net/System/Net/FtpStatusCode.cs
+../referencesource/System/net/System/Net/filewebrequest.cs
+../referencesource/System/net/System/Net/filewebresponse.cs
+../referencesource/System/net/System/Net/HttpListenerException.cs
../referencesource/System/net/System/Net/HttpListenerRequestUriBuilder.cs
+../referencesource/System/net/System/Net/HttpRequestHeader.cs
+../referencesource/System/net/System/Net/HttpResponseHeader.cs
+../referencesource/System/net/System/Net/HttpStatusCode.cs
+../referencesource/System/net/System/Net/HttpVersion.cs
+../referencesource/System/net/System/Net/IAuthenticationModule.cs
+../referencesource/System/net/System/Net/ICertificatePolicy.cs
+../referencesource/System/net/System/Net/ICredentials.cs
+../referencesource/System/net/System/Net/ICredentialsByHost.cs
../referencesource/System/net/System/Net/Internal.cs
+../referencesource/System/net/System/Net/IPAddress.cs
+../referencesource/System/net/System/Net/IPEndPoint.cs
+../referencesource/System/net/System/Net/IPHostEntry.cs
+../referencesource/System/net/System/Net/iwebproxy.cs
+../referencesource/System/net/System/Net/IWebRequestCreate.cs
+../referencesource/System/net/System/Net/NetworkAccess.cs
+../referencesource/System/net/System/Net/ProtocolViolationException.cs
+../referencesource/System/net/System/Net/TransportContext.cs
+../referencesource/System/net/System/Net/TransportType.cs
../referencesource/System/net/System/Net/UnicodeDecodingConformance.cs
../referencesource/System/net/System/Net/UnicodeEncodingConformance.cs
../referencesource/System/net/System/Net/ServicePointManager.cs
+../referencesource/System/net/System/Net/SocketAddress.cs
../referencesource/System/net/System/Net/webclient.cs
+../referencesource/System/net/System/Net/WebException.cs
+../referencesource/System/net/System/Net/WebExceptionStatus.cs
+../referencesource/System/net/System/Net/WebHeaderCollection.cs
../referencesource/System/net/System/Net/WebPermission.cs
+../referencesource/System/net/System/Net/WebRequestMethods.cs
+../referencesource/System/net/System/Net/WebResponse.cs
../referencesource/System/net/System/Net/WebUtility.cs
../referencesource/System/net/System/Net/WriteStreamClosedEventArgs.cs
../referencesource/System/sys/system/threading/Barrier.cs
../referencesource/System/sys/system/windows/markup/ValueSerializerAttribute.cs
+../referencesource/System/security/system/security/Authentication/ExtendedProtection/TokenBinding.cs
+
../referencesource/System/security/system/security/cryptography/oid.cs
../referencesource/System/security/system/security/cryptography/x509/x509utils.cs
using NUnit.Framework;
using System;
+using System.Net;
using System.Net.NetworkInformation;
+using System.Threading;
namespace MonoTests.System.Net.NetworkInformation
{
Assert.AreEqual(IPStatus.Success, p.Status);
#endif
}
+
+ [Test]
+#if MONOTOUCH
+ [Ignore("Ping implementation is broken on MT (requires sudo access)")]
+#endif
+ public void SendAsyncIPV4Succeeds()
+ {
+ var testIp = IPAddress.Loopback;
+ var ping = new Ping ();
+ PingReply reply = null;
+
+ using (var waiter = new AutoResetEvent (false)) {
+ ping.PingCompleted += new PingCompletedEventHandler (
+ (s, e) => {
+ reply = e.Reply;
+ (e.UserState as AutoResetEvent) ?.Set ();
+ });
+
+ ping.SendAsync (testIp, waiter);
+
+ waiter.WaitOne (TimeSpan.FromSeconds (8));
+ }
+
+ Assert.AreEqual (IPStatus.Success, reply.Status);
+ }
+
+ [Test]
+#if MONOTOUCH
+ [Ignore("Ping implementation is broken on MT (requires sudo access)")]
+#endif
+ public void SendAsyncIPV4Fails()
+ {
+ var testIp = IPAddress.Parse("192.0.2.0");
+ var ping = new Ping ();
+ PingReply reply = null;
+
+ using (var waiter = new AutoResetEvent (false)) {
+ ping.PingCompleted += new PingCompletedEventHandler (
+ (s, e) => {
+ reply = e.Reply;
+ (e.UserState as AutoResetEvent) ?.Set ();
+ });
+
+ ping.SendAsync (testIp, waiter);
+
+ waiter.WaitOne (TimeSpan.FromSeconds (8));
+ }
+
+ Assert.AreNotEqual (IPStatus.Success, reply.Status);
+ }
+
+ [Test]
+#if MONOTOUCH
+ [Ignore("Ping implementation is broken on MT (requires sudo access)")]
+#endif
+ public void SendPingAsyncIPV4Succeeds()
+ {
+ var testIp = IPAddress.Loopback;
+ var ping = new Ping ();
+ var task = ping.SendPingAsync (testIp);
+
+ task.Wait();
+
+ var result = task.Result;
+
+ Assert.AreEqual (IPStatus.Success, result.Status);
+ }
+
+ [Test]
+#if MONOTOUCH
+ [Ignore("Ping implementation is broken on MT (requires sudo access)")]
+#endif
+ public void SendPingAsyncIPV4Fails()
+ {
+ var testIp = IPAddress.Parse("192.0.2.0");
+ var ping = new Ping ();
+ var task = ping.SendPingAsync (testIp);
+
+ task.Wait();
+
+ var result = task.Result;
+
+ Assert.AreNotEqual (IPStatus.Success, result.Status);
+ }
}
}
// \r
\r
using System;\r
-using System.Collections;\r
+using System.Linq;\r
using System.Net;\r
using System.Net.Sockets;\r
using System.Threading;\r
\r
IAsyncResult async = Dns.BeginResolve (site1Dot, null, null);\r
IPHostEntry entry = Dns.EndResolve (async);\r
- SubTestValidIPHostEntry (entry);\r
- Assert.AreEqual (site1Dot, entry.AddressList [0].ToString ());\r
+ SubTestValidIPHostEntry (entry);
+ var ip = GetIPv4Address (entry);\r
+ Assert.AreEqual (site1Dot, ip.ToString ());\r
}\r
\r
void ResolveCallback (IAsyncResult ar)\r
}\r
}\r
\r
+ static IPAddress GetIPv4Address (IPHostEntry h)\r
+ {\r
+ var al = h.AddressList.FirstOrDefault (x => x.AddressFamily == AddressFamily.InterNetwork);\r
+ if (al == null)\r
+ Assert.Ignore ("Could not resolve an IPv4 address as required by this test case, e.g. running on an IPv6 only network");\r
+ return al;\r
+ }\r
+\r
void SubTestGetHostByName (string siteName, string siteDot)\r
{\r
IPHostEntry h = Dns.GetHostByName (siteName);\r
SubTestValidIPHostEntry (h);\r
Assert.AreEqual (siteName, h.HostName, "siteName");\r
- Assert.AreEqual (siteDot, h.AddressList [0].ToString (), "siteDot");\r
+ var ip = GetIPv4Address (h);\r
+ Assert.AreEqual (siteDot, ip.ToString (), "siteDot");\r
}\r
\r
[Test]\r
IPAddress addr = new IPAddress (IPAddress.NetworkToHostOrder ((int) site1IP));\r
IPHostEntry h = Dns.GetHostByAddress (addr);\r
SubTestValidIPHostEntry (h);\r
- Assert.AreEqual (addr.ToString (), h.AddressList [0].ToString ());\r
+ var ip = GetIPv4Address (h);\r
+ Assert.AreEqual (addr.ToString (), ip.ToString ());\r
}\r
\r
[Test]\r
{\r
IPAddress addr = new IPAddress (IPAddress.NetworkToHostOrder ((int) site2IP));\r
IPHostEntry h = Dns.GetHostByAddress (addr);\r
- SubTestValidIPHostEntry (h);\r
- Assert.AreEqual (addr.ToString (), h.AddressList [0].ToString ());\r
+ SubTestValidIPHostEntry (h);
+ var ip = GetIPv4Address (h);\r
+ Assert.AreEqual (addr.ToString (), ip.ToString ());\r
}\r
\r
[Test]\r
Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsNotNull (ex.ParamName, "#5");
- Assert.IsFalse (ex.ParamName == "value", "#6");
+ Assert.AreEqual ("value", ex.ParamName, "#6");
Assert.IsNull (ex.InnerException, "#7");
}
}
"0xff.0x7f.0x20.0xf", "255.127.32.15",
"0.0.0.0", IPAddress.Any.ToString(),
"255.255.255.255", IPAddress.Broadcast.ToString(),
- "12.1.1.3 abc", "12.1.1.3",
- "12.1 .1.2", "12.0.0.1",
- "12.1 .zzzz.2", "12.0.0.1",
"12.1.7", "12.1.0.7",
"12", "0.0.0.12",
- "12.5.3 foo.67.test.test.7FFFFFFFFFfaFFF789FFFFFFFFFFFFFFF", "12.5.0.3",
- "12.1 foo.bar.test.test.baf", "12.0.0.1",
- "12.1.4.6 foo.bar.test.test.baf", "12.1.4.6",
- "12.3 foo.bar.test.test.4", "12.0.0.3",
- "12 foo.bar.test.test.baf", "0.0.0.12",
"65536", "0.1.0.0",
"65535", "0.0.255.255",
"20.65535", "20.0.255.255",
"12...",
" ",
"7848198702",
+ "12.1.1.3 abc",
+ "12.1 .1.2",
+ "12.1 .zzzz.2",
+ "12.5.3 foo.67.test.test.7FFFFFFFFFfaFFF789FFFFFFFFFFFFFFF",
+ "12.1 foo.bar.test.test.baf",
+ "12.1.4.6 foo.bar.test.test.baf",
+ "12.3 foo.bar.test.test.4",
+ "12 foo.bar.test.test.baf",
};
static byte [] ipv4MappedIPv6Prefix = new byte [] { 0,0, 0,0, 0,0, 0,0, 0,0, 0xFF,0xFF };
Assert.AreEqual ((long) 0, IPAddress.Any.Address, "#1");
Assert.AreEqual ((long) 0xFFFFFFFF, IPAddress.Broadcast.Address, "#2");
long loopback = IPAddress.HostToNetworkOrder (BitConverter.IsLittleEndian ?
- 0x7f000001 :
- 0x0100007f);
+ 0x7f000001 :
+ 0x0100007f);
Assert.AreEqual (loopback, IPAddress.Loopback.Address, "#3");
Assert.AreEqual ((long) 0xFFFFFFFF, IPAddress.None.Address, "#4");
}
[Test]
public void IsLoopbackV6 ()
{
- if (!Socket.SupportsIPv6)
- Assert.Ignore ("IPv6 must be enabled in machine.config");
+// if (!Socket.SupportsIPv6)
+// Assert.Ignore ("IPv6 must be enabled in machine.config");
IPAddress ip = IPAddress.IPv6Loopback;
Assert.IsTrue (IPAddress.IsLoopback (ip), "#1");
[Test]
public void Address ()
{
- // hm, lame, anything is accepted by ms.net
- /*
try {
IPAddress ip1 = new IPAddress (0x0000000100000000);
- Assertion.Fail ("#1");
+ Assert.Fail ("#1");
} catch (ArgumentOutOfRangeException) {}
+
IPAddress ip = IPAddress.Parse ("127.0.0.1");
ip.Address = 0;
ip.Address = 0xffffffff;
- try {
- ip.Address = -1;
- Assertion.Fail ("#2");
- } catch (ArgumentOutOfRangeException) {}
- try {
- ip.Address = 0x0000000100000000;
- Assertion.Fail ("#3");
- } catch (ArgumentOutOfRangeException) {}
- */
+ ip.Address = -1;
+ ip.Address = 0x0000000100000000;
}
[Test]
[Test]
public void ParseWrongV6 ()
{
- if (!Socket.SupportsIPv6)
- Assert.Ignore ("IPv6 must be enabled in machine.config");
+ //if (!Socket.SupportsIPv6)
+ // Assert.Ignore ("IPv6 must be enabled in machine.config");
for (int i = 0; i < ipv6ParseWrong.Length; i++) {
string ipAddress = ipv6ParseWrong [i];
Assert.Fail ("#1:" + i + " (" + ipAddress + ")");
} catch (FormatException ex) {
Assert.AreEqual (typeof (FormatException), ex.GetType (), "#2:" + i);
- Assert.IsNull (ex.InnerException, "#3:" + i);
+ Assert.AreEqual(typeof(SocketException), ex.InnerException.GetType (), "#3:" + i);
Assert.IsNotNull (ex.Message, "#4:" + i);
}
}
}
-#if NET_4_5
-
[Test]
public void MapToIPv6 ()
{
return true;
}
-#endif
-
[Test]
public void EqualsFromBytes ()
{
}
+ [Test]
+ [Category ("NotDotNet")]
+ public void UnixInterfaceNameAsZoneIndex ()
+ {
+ var ip = IPAddress.Parse ("fe80::bae8:56ff:fe47:af7e%en0");
+
+ // Should be en0 but it's of long type!
+ Assert.AreEqual (0, ip.ScopeId);
+
+ Assert.AreEqual ("fe80::bae8:56ff:fe47:af7e", ip.ToString ());
+ }
+
}
}
System.Net.Security/RemoteCertificateValidationCallback.cs
System.Net.Security/SslPolicyErrors.cs
System.Net.Security/SslStream.cs
-System.Net/SocketAddress.cs
System.Net/SocketPermissionAttribute.cs
System.Net/SocketPermission.cs
../referencesource/System/net/System/Net/Sockets/AddressFamily.cs
System.Net.Sockets/UdpClient.cs
../referencesource/System/net/System/Net/Sockets/UdpReceiveResult.cs
System.Net/AuthenticationManager.cs
-System.Net/AuthenticationSchemeSelector.cs
-System.Net/AuthenticationSchemes.cs
-System.Net/Authorization.cs
System.Net/BasicClient.cs
System.Net/BindIPEndPoint.cs
System.Net/ChunkStream.cs
System.Net/ChunkedInputStream.cs
-System.Net/ConnectionModes.cs
System.Net/CredentialCache.cs
System.Net/DecompressionMethods.cs
System.Net/DefaultCertificatePolicy.cs
System.Net/DigestClient.cs
System.Net/Dns.cs
-System.Net/DnsEndPoint.cs
-System.Net/EndPoint.cs
System.Net/EndPointListener.cs
System.Net/EndPointManager.cs
System.Net/EndpointPermission.cs
-System.Net/FileWebRequest.cs
-System.Net/FileWebRequestCreator.cs
-System.Net/FileWebResponse.cs
System.Net/FtpAsyncResult.cs
System.Net/FtpDataStream.cs
System.Net/FtpRequestCreator.cs
System.Net/FtpStatus.cs
-System.Net/FtpStatusCode.cs
System.Net/FtpWebRequest.cs
System.Net/FtpWebResponse.cs
System.Net/GlobalProxySelection.cs
System.Net/HttpListener.cs
System.Net/HttpListenerBasicIdentity.cs
System.Net/HttpListenerContext.cs
-System.Net/HttpListenerException.cs
System.Net/HttpListenerPrefixCollection.cs
System.Net/HttpListenerRequest.cs
System.Net/HttpListenerResponse.cs
System.Net/HttpListenerTimeoutManager.cs
System.Net/HttpRequestCreator.cs
-System.Net/HttpRequestHeader.cs
-System.Net/HttpResponseHeader.cs
-System.Net/HttpStatusCode.cs
System.Net/HttpStreamAsyncResult.cs
-System.Net/HttpVersion.cs
System.Net/HttpWebRequest.cs
System.Net/HttpWebResponse.cs
-System.Net/IAuthenticationModule.cs
-System.Net/ICertificatePolicy.cs
-System.Net/ICredentialLookup.cs
System.Net/ICredentialPolicy.cs
-System.Net/ICredentialsByHost.cs
-System.Net/IPAddress.cs
-System.Net/IPAddress.cs
-System.Net/IPEndPoint.cs
-System.Net/IPHostEntry.cs
System.Net/IPv6Address.cs
System.Net/IPv6Address.cs
System.Net/IWebConnectionState.cs
-System.Net/IWebProxy.cs
-System.Net/IWebProxyScript.cs
-System.Net/IWebRequestCreate.cs
System.Net/ListenerAsyncResult.cs
System.Net/ListenerPrefix.cs
System.Net/MacProxy.cs
System.Net/MonoHttpDate.cs
System.Net/NetConfig.cs
-System.Net/NetworkAccess.cs
System.Net/NetworkCredential.cs
System.Net/NtlmClient.cs
-System.Net/ProtocolViolationException.cs
System.Net/RequestStream.cs
System.Net/ResponseStream.cs
-System.Net/SecurityProtocolType.cs
System.Net/ServicePoint.cs
System.Net/ServicePointManager.cs
System.Net/ServicePointManager.extra.cs
System.Net/SimpleAsyncResult.cs
-System.Net/SocketAddress.cs
-System.Net/TransportContext.cs
-System.Net/TransportType.cs
System.Net/WebAsyncResult.cs
System.Net/WebConnection.cs
System.Net/WebConnectionData.cs
System.Net/WebConnectionGroup.cs
System.Net/WebConnectionStream.cs
-System.Net/WebException.cs
-System.Net/WebExceptionStatus.cs
System.Net/WebHeaderCollection.cs
System.Net/WebProxy.cs
System.Net/WebRequest.cs
-System.Net/WebRequestMethods.cs
-System.Net/WebResponse.cs
System.Net.WebSockets/ClientWebSocket.cs
System.Net.WebSockets/ClientWebSocketOptions.cs
System.Net.WebSockets/HttpListenerWebSocketContext.cs
../referencesource/System/net/System/UriScheme.cs
../referencesource/System/net/System/Net/_BufferOffsetSize.cs
+../referencesource/System/net/System/Net/_IStreams.cs
+../referencesource/System/net/System/Net/_NetRes.cs
../referencesource/System/net/System/Net/_LazyAsyncResult.cs
../referencesource/System/net/System/Net/_LoggingObject.cs
../referencesource/System/net/System/Net/_ScatterGatherBuffers.cs
+../referencesource/System/net/System/Net/AuthenticationScheme.cs
+../referencesource/System/net/System/Net/AuthenticationSchemeSelector.cs
+../referencesource/System/net/System/Net/Authorization.cs
../referencesource/System/net/System/Net/cookie.cs
../referencesource/System/net/System/Net/cookiecollection.cs
../referencesource/System/net/System/Net/cookiecontainer.cs
../referencesource/System/net/System/Net/cookieexception.cs
+../referencesource/System/net/System/Net/DnsEndPoint.cs
+../referencesource/System/net/System/Net/EndPoint.cs
+../referencesource/System/net/System/Net/FtpStatusCode.cs
+../referencesource/System/net/System/Net/filewebrequest.cs
+../referencesource/System/net/System/Net/filewebresponse.cs
+../referencesource/System/net/System/Net/HttpListenerException.cs
+../referencesource/System/net/System/Net/HttpRequestHeader.cs
+../referencesource/System/net/System/Net/HttpResponseHeader.cs
+../referencesource/System/net/System/Net/HttpStatusCode.cs
../referencesource/System/net/System/Net/HttpListenerRequestUriBuilder.cs
+../referencesource/System/net/System/Net/HttpVersion.cs
+../referencesource/System/net/System/Net/IAuthenticationModule.cs
+../referencesource/System/net/System/Net/ICertificatePolicy.cs
+../referencesource/System/net/System/Net/ICredentials.cs
+../referencesource/System/net/System/Net/ICredentialsByHost.cs
../referencesource/System/net/System/Net/Internal.cs
+../referencesource/System/net/System/Net/IPAddress.cs
+../referencesource/System/net/System/Net/IPEndPoint.cs
+../referencesource/System/net/System/Net/IPHostEntry.cs
+../referencesource/System/net/System/Net/iwebproxy.cs
+../referencesource/System/net/System/Net/IWebRequestCreate.cs
+../referencesource/System/net/System/Net/NetworkAccess.cs
+../referencesource/System/net/System/Net/ProtocolViolationException.cs
+../referencesource/System/net/System/Net/TransportContext.cs
+../referencesource/System/net/System/Net/TransportType.cs
../referencesource/System/net/System/Net/UnicodeDecodingConformance.cs
../referencesource/System/net/System/Net/UnicodeEncodingConformance.cs
../referencesource/System/net/System/Net/ServicePointManager.cs
+../referencesource/System/net/System/Net/SocketAddress.cs
../referencesource/System/net/System/Net/webclient.cs
+../referencesource/System/net/System/Net/WebException.cs
+../referencesource/System/net/System/Net/WebExceptionStatus.cs
+../referencesource/System/net/System/Net/WebHeaderCollection.cs
../referencesource/System/net/System/Net/WebPermission.cs
+../referencesource/System/net/System/Net/WebRequestMethods.cs
+../referencesource/System/net/System/Net/WebResponse.cs
../referencesource/System/net/System/Net/WebUtility.cs
../referencesource/System/net/System/Net/WriteStreamClosedEventArgs.cs
../referencesource/System/sys/system/threading/Barrier.cs
+../referencesource/System/security/system/security/Authentication/ExtendedProtection/TokenBinding.cs
+
../referencesource/System/security/system/security/cryptography/oid.cs
../referencesource/System/security/system/security/cryptography/x509/x509utils.cs
* of icalls, do not require an increment.
*/
#pragma warning disable 169
- private const int mono_corlib_version = 146;
+ private const int mono_corlib_version = 147;
#pragma warning restore 169
[ComVisible (true)]
t.Name = "b";
}
- bool rename_finished;
- bool rename_failed;
-
- [Test]
- public void RenameTpThread ()
- {
- object monitor = new object ();
- ThreadPool.QueueUserWorkItem (new WaitCallback (Rename_callback), monitor);
- lock (monitor) {
- if (!rename_finished)
- Monitor.Wait (monitor);
- }
- Assert.IsTrue (!rename_failed);
- }
-
- void Rename_callback (object o) {
- Thread.CurrentThread.Name = "a";
- try {
- Thread.CurrentThread.Name = "b";
- //Console.WriteLine ("Thread name is: {0}", Thread.CurrentThread.Name);
- } catch (Exception e) {
- //Console.Error.WriteLine (e);
- rename_failed = true;
- }
- object monitor = o;
- lock (monitor) {
- rename_finished = true;
- Monitor.Pulse (monitor);
- }
- }
-
[Test]
public void TestNestedThreads1()
{
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.5/*.dll $(PROFILE_DIR)/4.5-api
$(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.5/Facades/*.dll $(PROFILE_DIR)/4.5-api/Facades
- # Unfortunately, a few programs (most notably NUnit) have hardcoded checks for <prefix>/lib/mono/4.0/mscorlib.dll,
+ # Unfortunately, a few programs (most notably NUnit and FSharp) have hardcoded checks for <prefix>/lib/mono/4.0/mscorlib.dll or Mono.Posix.dll,
# so we need to place something there or those tools break. We decided to symlink to the reference assembly for now.
- # See https://bugzilla.xamarin.com/show_bug.cgi?id=38331
+ # See https://bugzilla.xamarin.com/show_bug.cgi?id=38331 and https://bugzilla.xamarin.com/show_bug.cgi?id=41052
$(MKINSTALLDIRS) $(PROFILE_DIR)/4.0
ln -sf ../4.0-api/mscorlib.dll $(PROFILE_DIR)/4.0/mscorlib.dll
+ ln -sf ../4.0-api/Mono.Posix.dll $(PROFILE_DIR)/4.0/Mono.Posix.dll
DISTFILES = $(wildcard ../../../external/binary-reference-assemblies/v4.5/Facades/*.dll) $(wildcard ../../../external/binary-reference-assemblies/v4.5/*.dll) $(wildcard ../../../external/binary-reference-assemblies/v4.0/*.dll) $(wildcard ../../../external/binary-reference-assemblies/v3.5/*.dll) $(wildcard ../../../external/binary-reference-assemblies/v2.0/*.dll) Makefile
set
{
+#if !DISABLE_CAS_USE
ExceptionHelper.ControlPolicyPermission.Demand();
+#endif
Instance.CredentialPolicy = value;
}
}
/// </devdoc>
public static void Register(IAuthenticationModule authenticationModule)
{
+#if !DISABLE_CAS_USE
ExceptionHelper.UnmanagedPermission.Demand();
+#endif
Instance.Register(authenticationModule);
}
/// </devdoc>
public static void Unregister(IAuthenticationModule authenticationModule)
{
+#if !DISABLE_CAS_USE
ExceptionHelper.UnmanagedPermission.Demand();
+#endif
Instance.Unregister(authenticationModule);
}
/// </devdoc>
public static void Unregister(string authenticationScheme)
{
+#if !DISABLE_CAS_USE
ExceptionHelper.UnmanagedPermission.Demand();
+#endif
Instance.Unregister(authenticationScheme);
}
//------------------------------------------------------------------------------
namespace System.Net {
-
+#if SECURITY_DEP
public delegate AuthenticationSchemes AuthenticationSchemeSelector(HttpListenerRequest httpRequest);
-
+#endif
}
}
}
+#if MONO
+ // Temporary bridge to old implementation
+ internal string ModuleAuthenticationType;
+#endif
+
} // class Authorization
//
if (ipString.IndexOf(':') != -1 ) {
-#if !FEATURE_PAL
+#if !FEATURE_PAL || MONO
//
// If the address string contains the colon character
// then it can only be an IPv6 address. Use a separate
//
SocketException e = null;
long scope = 0;
+#if !MONO
if(Socket.OSSupportsIPv6)
{
byte[] bytes = new byte[IPv6AddressBytes];
e = new SocketException();
}
else
+#endif
{
unsafe
{
scopeId = scopeId.Substring(1);
if (UInt32.TryParse(scopeId, NumberStyles.None, null, out result))
return new IPAddress(numbers, result);
-
+#if MONO
+ //
+ // HACK: .NET does not support scopes with literals at all (API is long based)
+ // For backward Mono compatibility parsing IPv6 addresses like
+ // fe80::bae8:56ff:fe47:af7e%en0 will loose en0 information
+ //
+ return new IPAddress(numbers, 0);
+#endif
}
}
}
else
// The new IPv4 parser is better than the native one, it can parse 0xFFFFFFFF. (It's faster too).
{
+#if !MONO
// App-Compat: The .NET 4.0 parser used Winsock. When we removed this initialization in 4.5 it
// uncovered bugs in IIS's management APIs where they failed to initialize Winsock themselves.
// DDCC says we need to keep this for an in place release, but to remove it in the next SxS release.
Socket.InitializeSockets();
///////////////////////////
-
+#endif
int end = ipString.Length;
long result;
unsafe
m_ToString = addressString.ToString();
#else // !FEATURE_PAL
+
+#if MONO
+ var v6 = new IPv6AddressFormatter (m_Numbers, ScopeId);
+ m_ToString = v6.ToString ();
+#else
// IPv6 addresses not supported for FEATURE_PAL
throw new SocketException(SocketError.OperationNotSupported);
+#endif
#endif // !FEATURE_PAL
}
else {
}
}
-#if MONO_FEATURE_WEB_STACK
internal static WebException IsolatedException {
get {
return new WebException(NetRes.GetWebStatusString("net_requestaborted", WebExceptionStatus.KeepAliveFailure),WebExceptionStatus.KeepAliveFailure, WebExceptionInternalStatus.Isolated, null);
return new WebException(NetRes.GetWebStatusString("net_requestaborted", WebExceptionStatus.RequestProhibitedByCachePolicy), WebExceptionStatus.RequestProhibitedByCachePolicy);
}
}
-#endif
}
internal enum WindowsInstallationType
WriteWait = 2,
}
-#if MONO_FEATURE_WEB_STACK
//
// HttpVerb - used to define various per Verb Properties
//
}
}
-
+#if MONO_FEATURE_WEB_STACK
//
// HttpProtocolUtils - A collection of utility functions for HTTP usage.
//
using Microsoft.Win32;
// This turned to be a legacy type name that is simply forwarded to System.Security.Authentication.SslProtocols defined values.
-#if !MONO && !FEATURE_PAL
+#if !FEATURE_PAL || MONO
[Flags]
public enum SecurityProtocolType
{
Tls11 = System.Security.Authentication.SslProtocols.Tls11,
Tls12 = System.Security.Authentication.SslProtocols.Tls12,
}
-
+#endif
+#if !MONO && !FEATURE_PAL
internal class CertPolicyValidationCallback
{
readonly ICertificatePolicy m_CertificatePolicy;
using System.Globalization;
using System.Security.Permissions;
using System.Diagnostics.CodeAnalysis;
-
+#if !MONO
internal enum WebHeaderCollectionType : ushort {
Unknown,
WebRequest,
m_InnerCollection.Clear();
}
} // class WebHeaderCollection
-
+#endif
internal class CaseInsensitiveAscii : IEqualityComparer, IComparer{
// ASCII char ToLower table
//
public override int Count {
get {
+#if !DISABLE_CAS_USE
ExceptionHelper.WebPermissionUnrestricted.Demand();
+#endif
return m_SyncTable.Count;
}
}
//
public override ICollection Keys {
get {
+#if !DISABLE_CAS_USE
ExceptionHelper.WebPermissionUnrestricted.Demand();
+#endif
return m_SyncTable.Keys;
}
}
public override object SyncRoot {
[HostProtection(Synchronization=true)]
get {
+#if !DISABLE_CAS_USE
ExceptionHelper.WebPermissionUnrestricted.Demand();
+#endif
return m_SyncTable;
}
}
//
public override ICollection Values {
get {
+#if !DISABLE_CAS_USE
ExceptionHelper.WebPermissionUnrestricted.Demand();
+#endif
if (m_ValuesWrapper == null)
{
m_ValuesWrapper = new ValueCollection(this);
}
//
public override void Clear() {
+#if !DISABLE_CAS_USE
ExceptionHelper.WebPermissionUnrestricted.Demand();
+#endif
m_SyncTable.Clear();
}
//
}
//
public override bool ContainsValue(string value) {
+#if !DISABLE_CAS_USE
ExceptionHelper.WebPermissionUnrestricted.Demand();
+#endif
foreach (SpnToken spnToken in m_SyncTable.Values)
{
if (spnToken.Spn == value)
// We have to unwrap the SpnKey and just expose the Spn
public override void CopyTo(Array array, int index) {
+#if !DISABLE_CAS_USE
ExceptionHelper.WebPermissionUnrestricted.Demand();
+#endif
CheckCopyToArguments(array, index, Count);
int offset = 0;
}
//
public override IEnumerator GetEnumerator() {
+#if !DISABLE_CAS_USE
ExceptionHelper.WebPermissionUnrestricted.Demand();
+#endif
foreach (string key in m_SyncTable.Keys)
{
try {
Uri uri = new Uri(key);
key = uri.GetParts(UriComponents.Scheme | UriComponents.Host | UriComponents.Port | UriComponents.Path, UriFormat.SafeUnescaped);
+#if !DISABLE_CAS_USE
new WebPermission(NetworkAccess.Connect, new Uri(key)).Demand();
+#endif
}
catch(UriFormatException e) {
throw new ArgumentException(SR.GetString(SR.net_mustbeuri, "key"), "key", e);
if(Logging.On)Logging.Exception(Logging.Web, this, "BeginGetRequestStream", exception);
throw;
} finally {
+#if !MONO
if (FrameworkEventSource.Log.IsEnabled()) {
LogBeginGetRequestStream(success, synchronous: false);
}
+#endif
GlobalLog.Leave("FileWebRequest::BeginGetRequestSteam");
}
if(Logging.On)Logging.Exception(Logging.Web, this, "BeginGetResponse", exception);
throw;
} finally {
+#if !MONO
if (FrameworkEventSource.Log.IsEnabled()) {
LogBeginGetResponse(success, synchronous: false);
}
+#endif
GlobalLog.Leave("FileWebRequest::BeginGetResponse");
}
throw;
} finally {
GlobalLog.Leave("FileWebRequest::EndGetRequestStream");
+#if !MONO
if (FrameworkEventSource.Log.IsEnabled()) {
LogEndGetRequestStream(success, synchronous: false);
}
+#endif
}
return stream;
} finally {
GlobalLog.Leave("FileWebRequest::EndGetResponse");
+#if !MONO
// there is no statusCode in FileWebRequest object, defaulting it to zero.
if (FrameworkEventSource.Log.IsEnabled()) {
LogEndGetResponse(success, synchronous: false, statusCode: 0);
}
+#endif
}
return response;
// (C) 2016 Xamarin Inc
//
// Missing features:
-// * Implement --cross, --local-targets, --list-targets, --no-auto-fetch
-// * concatenate target with package to form native binary
+// * Add support for packaging native libraries, extracting at runtime and setting the library path.
+// * Implement --list-targets lists all the available remote targets
//
using System;
using System.Diagnostics;
using IKVM.Reflection;
using System.Linq;
using System.Diagnostics;
+using System.Net;
using System.Threading.Tasks;
class MakeBundle {
static bool skip_scan;
static string ctor_func;
static bool quiet;
+ static string cross_target = null;
+ static string fetch_target = null;
static bool custom_mode = true;
static string embedded_options = null;
static string runtime = null;
+ static string target_server = "https://download.mono-project.com/runtimes/raw/";
static int Main (string [] args)
{
case "-c":
compile_only = true;
break;
+
+ case "--local-targets":
+ CommandLocalTargets ();
+ return 0;
+
+ case "--cross":
+ if (i+1 == top){
+ Help ();
+ return 1;
+ }
+ custom_mode = false;
+ autodeps = true;
+ cross_target = args [++i];
+ break;
+
+ case "--fetch-target":
+ if (i+1 == top){
+ Help ();
+ return 1;
+ }
+ fetch_target = args [++i];
+ break;
+
+ case "--list-targets":
+ var wc = new WebClient ();
+ var s = wc.DownloadString (new Uri (target_server + "target-list.txt"));
+ Console.WriteLine ("Cross-compilation targets available:\n" + s);
+
+ return 0;
+ case "--target-server":
+ if (i+1 == top){
+ Help ();
+ return 1;
+ }
+ target_server = args [++i];
+ break;
+
case "-o":
if (i+1 == top){
Help ();
if (!QueueAssembly (files, file))
return 1;
+ if (fetch_target != null){
+ var truntime = Path.Combine (targets_dir, fetch_target, "mono");
+ Directory.CreateDirectory (Path.GetDirectoryName (truntime));
+ var wc = new WebClient ();
+ var uri = new Uri ($"{target_server}{fetch_target}");
+ try {
+ wc.DownloadFile (uri, truntime);
+ } catch {
+ Console.Error.WriteLine ($"Failure to download the specified runtime from {uri}");
+ File.Delete (truntime);
+ return 1;
+ }
+ return 0;
+ }
+
if (custom_mode)
GenerateBundles (files);
- else
+ else {
+ if (cross_target == "default")
+ runtime = null;
+ else {
+ var truntime = Path.Combine (targets_dir, cross_target, "mono");
+ if (!File.Exists (truntime)){
+ Console.Error.WriteLine ($"The runtime for the {cross_target} does not exist, use --fetch-target {cross_target} to download first");
+ return 1;
+ }
+ }
GeneratePackage (files);
+ }
return 0;
}
+ static string targets_dir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".mono", "targets");
+
+ static void CommandLocalTargets ()
+ {
+ string [] targets;
+
+ Console.WriteLine ("Available targets:");
+ Console.WriteLine ("\tdefault\t- Current System Mono");
+ try {
+ targets = Directory.GetDirectories (targets_dir);
+ } catch {
+ return;
+ }
+ foreach (var target in targets){
+ var p = Path.Combine (target, "mono");
+ if (File.Exists (p))
+ Console.WriteLine ("\t{0}", Path.GetFileName (target));
+ }
+ }
+
static void WriteSymbol (StreamWriter sw, string name, long size)
{
switch (style){
"--simple Simple mode does not require a C toolchain and can cross compile\n" +
" --cross TARGET Generates a binary for the given TARGET\n"+
" --local-targets Lists locally available targets\n" +
- " --list-targets [SERVER] Lists available targets on the remote server\n" +
- " --no-auto-fetch Prevents the tool from auto-fetching a TARGET\n" +
+ " --list-targets Lists available targets on the remote server\n" +
" --options OPTIONS Embed the specified Mono command line options on target\n" +
- " --runtime RUNTIME Manually specifies the Mono runtime to use\n" +
+ " --runtime RUNTIME Manually specifies the Mono runtime to use\n" +
+ " --target-server URL Specified a server to download targets from, default is " + target_server + "\n" +
"\n" +
"--custom Builds a custom launcher, options for --custom\n" +
" -c Produce stub only, do not compile\n" +
* Changes which are already detected at runtime, like the addition
* of icalls, do not require an increment.
*/
-#define MONO_CORLIB_VERSION 146
+#define MONO_CORLIB_VERSION 147
typedef struct
{
{
guint32 result;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
result = WaitForSingleObjectEx (handle, timeout, alertable);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return result;
}
unload_data *thread_data;
MonoNativeThreadId tid;
MonoDomain *caller_domain = mono_domain_get ();
- char *name;
/* printf ("UNLOAD STARTING FOR %s (%p) IN THREAD 0x%x.\n", domain->friendly_name, domain, mono_native_thread_id_get ()); */
thread_handle = mono_threads_create_thread ((LPTHREAD_START_ROUTINE)unload_thread_main, thread_data, 0, CREATE_SUSPENDED, &tid);
if (thread_handle == NULL)
return;
- name = g_strdup_printf ("Unload thread for domain %x", domain);
- mono_thread_info_set_name (tid, name);
mono_thread_info_resume (tid);
- g_free (name);
/* Wait for the thread */
while (!thread_data->done && guarded_wait (thread_handle, INFINITE, TRUE) == WAIT_IO_COMPLETION) {
guint8 *p, *p_end;
MonoObject *exc;
- mono_thread_info_set_name (mono_native_thread_id_get (), "Attach receiver");
+ mono_native_thread_set_name (mono_native_thread_id_get (), "Attach receiver");
printf ("attach: Listening on '%s'...\n", server_uri);
register_icall (cominterop_get_interface, "cominterop_get_interface", "ptr object ptr int32", FALSE);
register_icall (mono_string_to_bstr, "mono_string_to_bstr", "ptr obj", FALSE);
- register_icall (mono_string_from_bstr, "mono_string_from_bstr", "obj ptr", FALSE);
+ register_icall (mono_string_from_bstr_icall, "mono_string_from_bstr_icall", "obj ptr", FALSE);
register_icall (mono_free_bstr, "mono_free_bstr", "void ptr", FALSE);
register_icall (cominterop_type_from_handle, "cominterop_type_from_handle", "object ptr", FALSE);
* Constructor does not need to be called. Will be called later.
*/
MonoVTable *vtable = mono_class_vtable_full (domain, klass, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
obj = mono_object_new_alloc_specific_checked (vtable, &error);
- mono_error_raise_exception (&error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
return obj;
}
#ifdef HOST_WIN32
/* All ccw objects are free threaded */
static int
-cominterop_ccw_getfreethreadedmarshaler (MonoCCW* ccw, MonoObject* object, gpointer* ppv)
+cominterop_ccw_getfreethreadedmarshaler (MonoCCW* ccw, MonoObject* object, gpointer* ppv, MonoError *error)
{
+ mono_error_init (error);
#ifdef HOST_WIN32
- MonoError error;
if (!ccw->free_marshaler) {
int ret = 0;
gpointer tunk;
- tunk = cominterop_get_ccw_checked (object, mono_class_get_iunknown_class (), &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ tunk = cominterop_get_ccw_checked (object, mono_class_get_iunknown_class (), error);
+ return_val_if_nok (error, MONO_E_NOINTERFACE);
ret = CoCreateFreeThreadedMarshaler (tunk, (LPUNKNOWN*)&ccw->free_marshaler);
}
#ifdef HOST_WIN32
/* handle IMarshal special */
if (0 == memcmp (riid, &MONO_IID_IMarshal, sizeof (IID))) {
- return cominterop_ccw_getfreethreadedmarshaler (ccw, object, ppv);
+ int res = cominterop_ccw_getfreethreadedmarshaler (ccw, object, ppv, &error);
+ mono_error_assert_ok (&error);
+ return res;
}
#endif
klass_iter = klass;
mono_string_from_bstr (gpointer bstr)
{
MonoError error;
+ MonoString *result = mono_string_from_bstr_checked (bstr, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+MonoString *
+mono_string_from_bstr_icall (gpointer bstr)
+{
+ MonoError error;
+ MonoString *result = mono_string_from_bstr_checked (bstr, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+MonoString *
+mono_string_from_bstr_checked (gpointer bstr, MonoError *error)
+{
MonoString * res = NULL;
+ mono_error_init (error);
+
if (!bstr)
return NULL;
#ifdef HOST_WIN32
- res = mono_string_new_utf16_checked (mono_domain_get (), bstr, SysStringLen (bstr), &error);
+ res = mono_string_new_utf16_checked (mono_domain_get (), bstr, SysStringLen (bstr), error);
#else
if (com_provider == MONO_COM_DEFAULT) {
- res = mono_string_new_utf16_checked (mono_domain_get (), (const mono_unichar2 *)bstr, *((guint32 *)bstr - 1) / sizeof(gunichar2), &error);
+ res = mono_string_new_utf16_checked (mono_domain_get (), (const mono_unichar2 *)bstr, *((guint32 *)bstr - 1) / sizeof(gunichar2), error);
} else if (com_provider == MONO_COM_MS && init_com_provider_ms ()) {
MonoString* str = NULL;
glong written = 0;
gunichar2* utf16 = NULL;
utf16 = g_ucs4_to_utf16 ((const gunichar *)bstr, sys_string_len_ms (bstr), NULL, &written, NULL);
- str = mono_string_new_utf16_checked (mono_domain_get (), utf16, written, &error);
+ str = mono_string_new_utf16_checked (mono_domain_get (), utf16, written, error);
g_free (utf16);
res = str;
} else {
}
#endif
- mono_error_raise_exception (&error); /* FIXME don't raise here */
return res;
}
return result;
}
+/* This is an icall */
static gboolean
mono_marshal_safearray_begin (gpointer safearray, MonoArray **result, gpointer *indices, gpointer empty, gpointer parameter, gboolean allocateNewArray)
{
hr = mono_marshal_safe_array_get_lbound (safearray, i+1, &lbound);
if (hr < 0) {
cominterop_set_hr_error (&error, hr);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
}
if (lbound != 0)
bounded = TRUE;
hr = mono_marshal_safe_array_get_ubound (safearray, i+1, &ubound);
if (hr < 0) {
cominterop_set_hr_error (&error, hr);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
}
cursize = ubound-lbound+1;
sizes [i] = cursize;
if (allocateNewArray) {
aklass = mono_bounded_array_class_get (mono_defaults.object_class, dim, bounded);
*result = mono_array_new_full_checked (mono_domain_get (), aklass, sizes, bounds, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
} else {
*result = (MonoArray *)parameter;
}
return TRUE;
}
+/* This is an icall */
static
gpointer mono_marshal_safearray_get_value (gpointer safearray, gpointer indices)
{
int hr = SafeArrayPtrOfIndex (safearray, indices, &result);
if (hr < 0) {
cominterop_set_hr_error (&error, hr);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_set_pending_exception (&error);
+ return NULL;
}
#else
if (com_provider == MONO_COM_MS && init_com_provider_ms ()) {
int hr = safe_array_ptr_of_index_ms (safearray, (glong *)indices, &result);
if (hr < 0) {
cominterop_set_hr_error (&error, hr);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_set_pending_exception (&error);
+ return NULL;
}
} else {
g_assert_not_reached ();
return result;
}
+/* This is an icall */
static
gboolean mono_marshal_safearray_next (gpointer safearray, gpointer indices)
{
hr = mono_marshal_safe_array_get_ubound (safearray, i+1, &ubound);
if (hr < 0) {
cominterop_set_hr_error (&error, hr);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_set_pending_exception (&error);
+ return FALSE;
}
if (++pIndices[i] <= ubound) {
hr = mono_marshal_safe_array_get_lbound (safearray, i+1, &lbound);
if (hr < 0) {
cominterop_set_hr_error (&error, hr);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_set_pending_exception (&error);
+ return FALSE;
}
pIndices[i] = lbound;
return TRUE;
}
+/* This is an icall */
static
void mono_marshal_safearray_set_value (gpointer safearray, gpointer indices, gpointer value)
{
int hr = SafeArrayPutElement (safearray, indices, value);
if (hr < 0) {
cominterop_set_hr_error (&error, hr);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_set_pending_exception (&error);
+ return;
}
#else
if (com_provider == MONO_COM_MS && init_com_provider_ms ()) {
int hr = safe_array_put_element_ms (safearray, (glong *)indices, (void **)value);
if (hr < 0) {
cominterop_set_hr_error (&error, hr);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ mono_error_set_pending_exception (&error);
+ return;
}
} else
g_assert_not_reached ();
emit an exception in the generated IL.
*/
register_icall (mono_string_to_bstr, "mono_string_to_bstr", "ptr obj", FALSE);
- register_icall (mono_string_from_bstr, "mono_string_from_bstr", "obj ptr", FALSE);
+ register_icall (mono_string_from_bstr_icall, "mono_string_from_bstr_icall", "obj ptr", FALSE);
register_icall (mono_free_bstr, "mono_free_bstr", "void ptr", FALSE);
}
#endif
}
+
MonoString *
mono_string_from_bstr (gpointer bstr)
{
- MonoString *res = NULL;
MonoError error;
+ MonoString *result = mono_string_from_bstr_checked (bstr, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+MonoString *
+mono_string_from_bstr_icall (gpointer bstr)
+{
+ MonoError error;
+ MonoString *result = mono_string_from_bstr_checked (bstr, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
+MonoString *
+mono_string_from_bstr_checked (gpointer bstr, MonoError *error)
+{
+ MonoString *res = NULL;
+ mono_error_init (error);
if (!bstr)
return NULL;
#ifdef HOST_WIN32
- res = mono_string_new_utf16_checked (mono_domain_get (), bstr, SysStringLen (bstr), &error);
+ res = mono_string_new_utf16_checked (mono_domain_get (), bstr, SysStringLen (bstr), error);
#else
- res = mono_string_new_utf16_checked (mono_domain_get (), bstr, *((guint32 *)bstr - 1) / sizeof(gunichar2), &error);
+ res = mono_string_new_utf16_checked (mono_domain_get (), bstr, *((guint32 *)bstr - 1) / sizeof(gunichar2), error);
#endif
- mono_error_raise_exception (&error); /* FIXME don't raise here */
return res;
}
MonoString *
ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR (gpointer ptr)
{
- return mono_string_from_bstr(ptr);
+ MonoError error;
+ MonoString *result = mono_string_from_bstr_checked (ptr, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
}
gpointer
int conv_arg, MonoType **conv_arg_type,
MarshalAction action);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoString *
mono_string_from_bstr (gpointer bstr);
+MonoString *
+mono_string_from_bstr_icall (gpointer bstr);
+
+MonoString *
+mono_string_from_bstr_checked (gpointer bstr, MonoError *error);
+
MONO_API void
mono_free_bstr (gpointer bstr);
MonoImage *socket_assembly;
MonoClass *sockaddr_class;
MonoClassField *sockaddr_data_field;
+ MonoClassField *sockaddr_data_length_field;
/* Cache function pointers for architectures */
/* that require wrappers */
ves_icall_System_IO_MonoIO_CreateDirectory (MonoString *path, gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
*ioerror = ERROR_SUCCESS;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
names = get_filesystem_entries (mono_string_chars (path), mono_string_chars (path_with_pattern), attrs, mask, ioerror);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (!names) {
// If there's no array and no error, then return an empty array.
IncrementalFind *ifh = (IncrementalFind *)handle;
gint32 error;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
if (FindClose (ifh->find_handle) == FALSE){
error = GetLastError ();
} else
error = ERROR_SUCCESS;
g_free (ifh->utf8_path);
g_free (ifh);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return error;
}
gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
gboolean ret;
gunichar2 *utf16_sourceFileName = NULL, *utf16_destinationFileName = NULL, *utf16_destinationBackupFileName = NULL;
guint32 replaceFlags = REPLACEFILE_WRITE_THROUGH;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
if (sourceFileName)
utf16_sourceFileName = mono_string_chars (sourceFileName);
if (ret == FALSE)
*error = GetLastError ();
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return ret;
}
MonoBoolean overwrite, gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
ves_icall_System_IO_MonoIO_DeleteFile (MonoString *path, gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
ves_icall_System_IO_MonoIO_GetFileAttributes (MonoString *path, gint32 *error)
{
gint32 ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
ves_icall_System_IO_MonoIO_GetFileType (HANDLE handle, gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
{
gboolean result;
WIN32_FILE_ATTRIBUTE_DATA data;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
memset (stat, 0, sizeof (MonoIOStat));
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return result;
}
HANDLE ret;
int attributes, attrs;
gunichar2 *chars;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
chars = mono_string_chars (filename);
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
ves_icall_System_IO_MonoIO_Close (HANDLE handle, gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
buffer = mono_array_addr (dest, guchar, dest_offset);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
result = ReadFile (handle, buffer, count, &n, NULL);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (!result) {
*error=GetLastError ();
}
buffer = mono_array_addr (src, guchar, src_offset);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
result = WriteFile (handle, buffer, count, &n, NULL);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (!result) {
*error=GetLastError ();
gint32 *error)
{
gint32 offset_hi;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return offset | ((gint64)offset_hi << 32);
}
ves_icall_System_IO_MonoIO_Flush (HANDLE handle, gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
{
gint64 length;
guint32 length_hi;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return length | ((gint64)length_hi << 32);
}
const FILETIME *creation_filetime;
const FILETIME *last_access_filetime;
const FILETIME *last_write_filetime;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error=GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return(ret);
}
attr.bInheritHandle=TRUE;
attr.lpSecurityDescriptor=NULL;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret=CreatePipe (read_handle, write_handle, &attr, 0);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if(ret==FALSE) {
*error = GetLastError ();
/* This is only used on Windows */
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret=DuplicateHandle (source_process_handle, source_handle, target_process_handle, target_handle, access, inherit, options);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if(ret==FALSE) {
*error = GetLastError ();
gint64 length, gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error = GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
}
void ves_icall_System_IO_MonoIO_Unlock (HANDLE handle, gint64 position,
gint64 length, gint32 *error)
{
gboolean ret;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
*error=ERROR_SUCCESS;
*error = GetLastError ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
}
//Support for io-layer free mmap'd files.
gint64 res;
char *path = mono_string_to_utf8 (string);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
if (stat (path, &buf) == -1)
res = -1;
else
g_free (path);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return res;
}
struct stat buf;
int res;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
res = fstat (fd, &buf);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (res == -1)
return (gint64)-1;
return -1;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
res = kevent (*kq_ptr, changelist, nchanges, eventlist, nevents, NULL);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
{
guint32 result;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
result = WaitForSingleObjectEx (handle, timeout, alertable);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return result;
}
static void
add_thread_to_finalize (MonoInternalThread *thread)
{
+ MonoError error;
mono_finalizer_lock ();
if (!threads_to_finalize)
MONO_GC_REGISTER_ROOT_SINGLE (threads_to_finalize, MONO_ROOT_SOURCE_FINALIZER_QUEUE, "finalizable threads list");
- threads_to_finalize = mono_mlist_append (threads_to_finalize, (MonoObject*)thread);
+ threads_to_finalize = mono_mlist_append_checked (threads_to_finalize, (MonoObject*)thread, &error);
mono_finalizer_unlock ();
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
}
static gboolean suspend_finalizers = FALSE;
ICALL_EXPORT MonoString *
ves_icall_System_IO_DriveInfo_GetDriveFormat (MonoString *path)
{
+ MonoError error;
gunichar2 volume_name [MAX_PATH + 1];
if (GetVolumeInformation (mono_string_chars (path), NULL, 0, NULL, NULL, NULL, volume_name, MAX_PATH + 1) == FALSE)
return NULL;
- return mono_string_from_utf16 (volume_name);
+ MonoString *result = mono_string_from_utf16_checked (volume_name, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
}
ICALL_EXPORT MonoString *
static gboolean use_aot_wrappers;
-static MonoFtnPtrEHCallback ftnptr_eh_callback;
+static void ftnptr_eh_callback_default (guint32 gchandle);
+
+static MonoFtnPtrEHCallback ftnptr_eh_callback = ftnptr_eh_callback_default;
static void
delegate_hash_table_add (MonoDelegate *d);
void
mono_free_lparray (MonoArray *array, gpointer* nativeArray);
-static gint32
-mono_marshal_has_ftnptr_eh_callback (void);
-
static void
mono_marshal_ftnptr_eh_callback (guint32 gchandle);
return result;
}
+static MonoString*
+ves_icall_mono_string_from_utf16 (gunichar2 *data)
+{
+ MonoError error;
+ MonoString *result = mono_string_from_utf16_checked (data, &error);
+ mono_error_set_pending_exception (&error);
+ return result;
+}
+
void
mono_marshal_init (void)
{
register_icall (mono_marshal_string_to_utf16, "mono_marshal_string_to_utf16", "ptr obj", FALSE);
register_icall (mono_marshal_string_to_utf16_copy, "mono_marshal_string_to_utf16_copy", "ptr obj", FALSE);
register_icall (mono_string_to_utf16, "mono_string_to_utf16", "ptr obj", FALSE);
- register_icall (mono_string_from_utf16, "mono_string_from_utf16", "obj ptr", FALSE);
+ register_icall (ves_icall_mono_string_from_utf16, "ves_icall_mono_string_from_utf16", "obj ptr", FALSE);
register_icall (mono_string_from_byvalstr, "mono_string_from_byvalstr", "obj ptr int", FALSE);
register_icall (mono_string_from_byvalwstr, "mono_string_from_byvalwstr", "obj ptr int", FALSE);
register_icall (mono_string_new_wrapper, "mono_string_new_wrapper", "obj ptr", FALSE);
register_icall (mono_gchandle_get_target, "mono_gchandle_get_target", "object int32", TRUE);
register_icall (mono_gchandle_new, "mono_gchandle_new", "uint32 object bool", TRUE);
register_icall (mono_marshal_isinst_with_cache, "mono_marshal_isinst_with_cache", "object object ptr ptr", FALSE);
- register_icall (mono_marshal_has_ftnptr_eh_callback, "mono_marshal_has_ftnptr_eh_callback", "int32", TRUE);
register_icall (mono_marshal_ftnptr_eh_callback, "mono_marshal_ftnptr_eh_callback", "void uint32", TRUE);
+ register_icall (mono_threads_enter_gc_safe_region_unbalanced, "mono_threads_enter_gc_safe_region_unbalanced", "ptr ptr", TRUE);
+ register_icall (mono_threads_exit_gc_safe_region_unbalanced, "mono_threads_exit_gc_safe_region_unbalanced", "void ptr ptr", TRUE);
mono_cominterop_init ();
mono_remoting_init ();
-
- if (mono_threads_is_coop_enabled ()) {
- register_icall (mono_threads_prepare_blocking, "mono_threads_prepare_blocking", "ptr ptr", FALSE);
- register_icall (mono_threads_finish_blocking, "mono_threads_finish_blocking", "void ptr ptr", FALSE);
- register_icall (mono_threads_reset_blocking_start, "mono_threads_reset_blocking_start","ptr ptr", TRUE);
- register_icall (mono_threads_reset_blocking_end, "mono_threads_reset_blocking_end","void ptr ptr", TRUE);
- }
}
}
} else {
mono_mb_emit_ldloc (mb, 1);
mono_mb_emit_ldloc (mb, 0);
- mono_mb_emit_icall (mb, mono_string_from_utf16);
+ mono_mb_emit_icall (mb, ves_icall_mono_string_from_utf16);
}
mono_mb_emit_byte (mb, CEE_STIND_REF);
break;
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_I);
#ifdef TARGET_WIN32
- mono_mb_emit_icall (mb, mono_string_from_utf16);
+ mono_mb_emit_icall (mb, ves_icall_mono_string_from_utf16);
#else
mono_mb_emit_icall (mb, mono_string_new_wrapper);
#endif
mono_mb_emit_ldloc (mb, 1);
mono_mb_emit_ldloc (mb, 0);
mono_mb_emit_byte (mb, CEE_LDIND_I);
- mono_mb_emit_icall (mb, mono_string_from_utf16);
+ mono_mb_emit_icall (mb, ves_icall_mono_string_from_utf16);
mono_mb_emit_byte (mb, CEE_STIND_REF);
break;
case MONO_MARSHAL_CONV_OBJECT_STRUCT: {
return mono_marshal_string_to_utf16;
case MONO_MARSHAL_CONV_LPWSTR_STR:
*ind_store_type = CEE_STIND_REF;
- return mono_string_from_utf16;
+ return ves_icall_mono_string_from_utf16;
case MONO_MARSHAL_CONV_LPTSTR_STR:
*ind_store_type = CEE_STIND_REF;
return mono_string_new_wrapper;
return mono_string_to_bstr;
case MONO_MARSHAL_CONV_BSTR_STR:
*ind_store_type = CEE_STIND_REF;
- return mono_string_from_bstr;
+ return mono_string_from_bstr_icall;
case MONO_MARSHAL_CONV_STR_TBSTR:
case MONO_MARSHAL_CONV_STR_ANSIBSTR:
return mono_string_to_ansibstr;
EmitMarshalContext m;
MonoMethodSignature *csig;
MonoClass *klass;
- MonoExceptionClause *clause;
int i, argnum, *tmp_locals;
int type, param_shift = 0;
static MonoMethodSignature *get_last_error_sig = NULL;
- int coop_gc_stack_dummy, coop_gc_var, coop_unblocked_var;
- int leave_pos;
+ int coop_gc_stack_dummy, coop_gc_var;
memset (&m, 0, sizeof (m));
m.mb = mb;
coop_gc_stack_dummy = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
/* local 5, the local to be used when calling the suspend funcs */
coop_gc_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
- coop_unblocked_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
-
- clause = (MonoExceptionClause *)mono_image_alloc0 (image, sizeof (MonoExceptionClause));
- clause->flags = MONO_EXCEPTION_CLAUSE_FINALLY;
}
+ /*
+ * cookie = mono_threads_enter_gc_safe_region_unbalanced (ref dummy);
+ *
+ * ret = method (...);
+ *
+ * mono_threads_exit_gc_safe_region_unbalanced (cookie, ref dummy);
+ *
+ * <interrupt check>
+ *
+ * return ret;
+ */
+
if (MONO_TYPE_ISSTRUCT (sig->ret))
m.vtaddr_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
mono_mb_emit_byte (mb, CEE_POP); // Result not needed yet
}
- clause->try_offset = mono_mb_get_label (mb);
-
mono_mb_emit_ldloc_addr (mb, coop_gc_stack_dummy);
- mono_mb_emit_icall (mb, mono_threads_prepare_blocking);
+ mono_mb_emit_icall (mb, mono_threads_enter_gc_safe_region_unbalanced);
mono_mb_emit_stloc (mb, coop_gc_var);
}
#else
g_assert_not_reached ();
#endif
- }
- else {
+ } else {
if (aot) {
/* Reuse the ICALL_ADDR opcode for pinvokes too */
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
}
}
+ if (MONO_TYPE_ISSTRUCT (sig->ret)) {
+ MonoClass *klass = mono_class_from_mono_type (sig->ret);
+ mono_class_init (klass);
+ if (!(((klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT) || klass->blittable)) {
+ /* This is used by emit_marshal_vtype (), but it needs to go right before the call */
+ mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
+ mono_mb_emit_byte (mb, CEE_MONO_VTADDR);
+ mono_mb_emit_stloc (mb, m.vtaddr_var);
+ }
+ }
+
+ /* Unblock before converting the result, since that can involve calls into the runtime */
+ if (mono_threads_is_coop_enabled ()) {
+ mono_mb_emit_ldloc (mb, coop_gc_var);
+ mono_mb_emit_ldloc_addr (mb, coop_gc_stack_dummy);
+ mono_mb_emit_icall (mb, mono_threads_exit_gc_safe_region_unbalanced);
+ }
+
/* Set LastError if needed */
if (piinfo->piflags & PINVOKE_ATTRIBUTE_SUPPORTS_LAST_ERROR) {
if (!get_last_error_sig) {
}
#ifdef TARGET_WIN32
- /*
+ /*
* Have to call GetLastError () early and without a wrapper, since various runtime components could
* clobber its value.
*/
#else
mono_mb_emit_icall (mb, mono_marshal_set_last_error);
#endif
- }
-
- if (MONO_TYPE_ISSTRUCT (sig->ret)) {
- MonoClass *klass = mono_class_from_mono_type (sig->ret);
- mono_class_init (klass);
- if (!(((klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK) == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT) || klass->blittable)) {
- /* This is used by emit_marshal_vtype (), but it needs to go right before the call */
- mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
- mono_mb_emit_byte (mb, CEE_MONO_VTADDR);
- mono_mb_emit_stloc (mb, m.vtaddr_var);
- }
- }
-
- /* Unblock before converting the result, since that can involve calls into the runtime */
- if (mono_threads_is_coop_enabled ()) {
- mono_mb_emit_ldloc (mb, coop_gc_var);
- mono_mb_emit_ldloc_addr (mb, coop_gc_stack_dummy);
- mono_mb_emit_icall (mb, mono_threads_finish_blocking);
- mono_mb_emit_icon (mb, 1);
- mono_mb_emit_stloc (mb, coop_unblocked_var);
}
/* convert the result */
mono_mb_emit_stloc (mb, 3);
}
- if (mono_threads_is_coop_enabled ()) {
- int pos;
-
- leave_pos = mono_mb_emit_branch (mb, CEE_LEAVE);
-
- clause->try_len = mono_mb_get_label (mb) - clause->try_offset;
- clause->handler_offset = mono_mb_get_label (mb);
-
- mono_mb_emit_ldloc (mb, coop_unblocked_var);
- mono_mb_emit_icon (mb, 1);
- pos = mono_mb_emit_branch (mb, CEE_BEQ);
-
- mono_mb_emit_ldloc (mb, coop_gc_var);
- mono_mb_emit_ldloc_addr (mb, coop_gc_stack_dummy);
- mono_mb_emit_icall (mb, mono_threads_finish_blocking);
-
- mono_mb_patch_branch (mb, pos);
-
- mono_mb_emit_byte (mb, CEE_ENDFINALLY);
-
- clause->handler_len = mono_mb_get_pos (mb) - clause->handler_offset;
-
- mono_mb_patch_branch (mb, leave_pos);
- }
-
/*
* Need to call this after converting the result since MONO_VTADDR needs
* to be adjacent to the call instruction.
mono_mb_emit_ldloc (mb, 3);
mono_mb_emit_byte (mb, CEE_RET);
-
- if (mono_threads_is_coop_enabled ()) {
- mono_mb_set_clauses (mb, 1, clause);
- }
}
#endif /* DISABLE_JIT */
MonoMethodSignature *sig, *csig;
MonoExceptionClause *clauses, *clause_finally, *clause_catch;
int i, *tmp_locals, ex_local, e_local;
- int leave_try_pos, leave_catch_pos, ex_m1_pos, rethrow_pos;
+ int leave_try_pos, leave_catch_pos, ex_m1_pos;
gboolean closed = FALSE;
sig = m->sig;
*
* ret = method (...);
* } catch (Exception e) {
- * if (!mono_marshal_has_ftnptr_eh_callback ())
- * throw e;
* ex = mono_gchandle_new (e, false);
* } finally {
* mono_jit_detach ();
+ *
+ * if (ex != -1)
+ * mono_marshal_ftnptr_eh_callback (ex);
* }
- * if (ex != -1)
- * mono_marshal_ftnptr_eh_callback (ex);
*
* return ret;
*/
leave_try_pos = mono_mb_emit_branch (mb, CEE_LEAVE);
- /* } catch (Exception e) { */
+ /* } [endtry] */
+
+ /* catch (Exception e) { */
clause_catch->try_len = mono_mb_get_label (mb) - clause_catch->try_offset;
clause_catch->handler_offset = mono_mb_get_label (mb);
mono_mb_emit_stloc (mb, e_local);
- /* if (!mono_marshal_has_ftnptr_eh_callback ()) { */
- mono_mb_emit_icall (mb, mono_marshal_has_ftnptr_eh_callback);
- rethrow_pos = mono_mb_emit_branch (mb, CEE_BRTRUE);
-
- /* throw e; */
- mono_mb_emit_ldloc (mb, e_local);
- mono_mb_emit_byte (mb, CEE_THROW);
-
- /* } [endif] */
- mono_mb_patch_branch (mb, rethrow_pos);
-
/* ex = mono_gchandle_new (e, false); */
mono_mb_emit_ldloc (mb, e_local);
mono_mb_emit_icon (mb, 0);
/* } [endcatch] */
clause_catch->handler_len = mono_mb_get_pos (mb) - clause_catch->handler_offset;
- /* } finally { */
+ /* finally { */
clause_finally->try_len = mono_mb_get_label (mb) - clause_finally->try_offset;
clause_finally->handler_offset = mono_mb_get_label (mb);
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_byte (mb, CEE_MONO_JIT_DETACH);
- mono_mb_emit_byte (mb, CEE_ENDFINALLY);
-
- /* } [endfinally] */
- clause_finally->handler_len = mono_mb_get_pos (mb) - clause_finally->handler_offset;
-
- mono_mb_patch_branch (mb, leave_try_pos);
- mono_mb_patch_branch (mb, leave_catch_pos);
-
/* if (ex != -1) */
mono_mb_emit_ldloc (mb, ex_local);
mono_mb_emit_icon (mb, -1);
/* [ex == -1] */
mono_mb_patch_branch (mb, ex_m1_pos);
+ mono_mb_emit_byte (mb, CEE_ENDFINALLY);
+
+ /* } [endfinally] */
+ clause_finally->handler_len = mono_mb_get_pos (mb) - clause_finally->handler_offset;
+
+ mono_mb_patch_branch (mb, leave_try_pos);
+ mono_mb_patch_branch (mb, leave_catch_pos);
+
/* return ret; */
if (m->retobj_var) {
mono_mb_emit_ldloc (mb, m->retobj_var);
GHashTable *cache;
MonoMethod *res;
int i, param_count, sig_size, pos_leave;
- int coop_gc_var, coop_gc_dummy_local;
g_assert (method);
+ // FIXME: we need to store the exception into a MonoHandle
+ g_assert (!mono_threads_is_coop_enabled ());
+
klass = method->klass;
image = method->klass->image;
if (!MONO_TYPE_IS_VOID (sig->ret))
mono_mb_add_local (mb, sig->ret);
- if (mono_threads_is_coop_enabled ()) {
- /* local 4, the local to be used when calling the reset_blocking funcs */
- /* tons of code hardcode 3 to be the return var */
- coop_gc_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
- /* local 5, the local used to get a stack address for suspend funcs */
- coop_gc_dummy_local = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
- }
-
/* clear exception arg */
mono_mb_emit_ldarg (mb, param_count - 1);
mono_mb_emit_byte (mb, CEE_LDNULL);
mono_mb_emit_byte (mb, CEE_STIND_REF);
- if (mono_threads_is_coop_enabled ()) {
- /* FIXME this is technically wrong as the callback itself must be executed in gc unsafe context. */
- mono_mb_emit_ldloc_addr (mb, coop_gc_dummy_local);
- mono_mb_emit_icall (mb, mono_threads_reset_blocking_start);
- mono_mb_emit_stloc (mb, coop_gc_var);
- }
-
/* try */
clause = (MonoExceptionClause *)mono_image_alloc0 (image, sizeof (MonoExceptionClause));
clause->try_offset = mono_mb_get_label (mb);
mono_mb_emit_op (mb, CEE_BOX, mono_class_from_mono_type (sig->ret));
}
- if (mono_threads_is_coop_enabled ()) {
- /* XXX merge reset_blocking_end with detach */
- mono_mb_emit_ldloc (mb, coop_gc_var);
- mono_mb_emit_ldloc_addr (mb, coop_gc_dummy_local);
- mono_mb_emit_icall (mb, mono_threads_reset_blocking_end);
- }
-
mono_mb_emit_byte (mb, CEE_RET);
#endif
mono_marshal_unlock ();
}
-static gint32
-mono_marshal_has_ftnptr_eh_callback (void)
-{
- return ftnptr_eh_callback != NULL;
-}
-
static void
mono_marshal_ftnptr_eh_callback (guint32 gchandle)
{
ftnptr_eh_callback (gchandle);
}
+static void
+ftnptr_eh_callback_default (guint32 gchandle)
+{
+ MonoException *exc;
+ gpointer stackdata;
+
+ g_assert (gchandle >= 0);
+
+ mono_threads_enter_gc_unsafe_region_unbalanced (&stackdata);
+
+ exc = (MonoException*) mono_gchandle_get_target (gchandle);
+
+ mono_gchandle_free (gchandle);
+
+ mono_raise_exception (exc);
+}
+
/*
* mono_install_ftnptr_eh_callback:
*
* We pass TRUE instead of allow_interruption since we have to check for the
* StopRequested case below.
*/
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = WaitForSingleObjectEx (mon->entry_sem, waitms, TRUE);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
* is private to this thread. Therefore even if the event was
* signalled before we wait, we still succeed.
*/
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = WaitForSingleObjectEx (event, ms, TRUE);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
/* Reset the thread state fairly early, so we don't have to worry
* about the monitor error checking
/* Poll the event again, just in case it was signalled
* while we were trying to regain the monitor lock
*/
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = WaitForSingleObjectEx (event, 0, FALSE);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
}
/* Pulse will have popped our event from the queue if it signalled
#include "mono/metadata/class-internals.h"
#include "mono/metadata/object-internals.h"
+
+static
+MonoMList* mono_mlist_alloc_checked (MonoObject *data, MonoError *error);
+
+
/* matches the System.MonoListItem object*/
struct _MonoMList {
MonoObject object;
mono_mlist_alloc (MonoObject *data)
{
MonoError error;
+ MonoMList *result = mono_mlist_alloc_checked (data, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+/**
+ * mono_mlist_alloc_checked:
+ * @data: object to use as data
+ * @error: set on error
+ *
+ * Allocates a new managed list node with @data as the contents. A
+ * managed list node also represents a singly-linked list. Managed
+ * lists are garbage collected, so there is no free routine and the
+ * user is required to keep references to the managed list to prevent
+ * it from being garbage collected. On failure returns NULL and sets
+ * @error.
+ */
+MonoMList*
+mono_mlist_alloc_checked (MonoObject *data, MonoError *error)
+{
+ mono_error_init (error);
MonoMList* res;
if (!monolist_item_vtable) {
MonoClass *klass = mono_class_load_from_name (mono_defaults.corlib, "System", "MonoListItem");
monolist_item_vtable = mono_class_vtable (mono_get_root_domain (), klass);
g_assert (monolist_item_vtable);
}
- res = (MonoMList*)mono_object_new_fast_checked (monolist_item_vtable, &error);
- mono_error_raise_exception (&error);
+ res = (MonoMList*)mono_object_new_fast_checked (monolist_item_vtable, error);
+ return_val_if_nok (error, NULL);
MONO_OBJECT_SETREF (res, data, data);
return res;
}
MonoMList*
mono_mlist_prepend (MonoMList* list, MonoObject *data)
{
- MonoMList* res = mono_mlist_alloc (data);
+ MonoError error;
+ MonoMList *result = mono_mlist_prepend_checked (list, data, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+/**
+ * mono_mlist_prepend_checked:
+ * @list: the managed list
+ * @data: the object to add to the list
+ * @error: set on error
+ *
+ * Allocate a new list node with @data as content and prepend it to
+ * the list @list. @list can be NULL. On failure returns NULL and sets
+ * @error.
+ */
+MonoMList*
+mono_mlist_prepend_checked (MonoMList* list, MonoObject *data, MonoError *error)
+{
+ mono_error_init (error);
+ MonoMList* res = mono_mlist_alloc_checked (data, error);
+ return_val_if_nok (error, NULL);
+
if (list)
MONO_OBJECT_SETREF (res, next, list);
return res;
MonoMList*
mono_mlist_append (MonoMList* list, MonoObject *data)
{
- MonoMList* res = mono_mlist_alloc (data);
+ MonoError error;
+ MonoMList *result = mono_mlist_append_checked (list, data, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+/**
+ * mono_mlist_append_checked:
+ * @list: the managed list
+ * @data: the object to add to the list
+ * @error: set on error
+ *
+ * Allocate a new list node with @data as content and append it
+ * to the list @list. @list can be NULL.
+ * Since managed lists are singly-linked, this operation takes O(n) time.
+ * On failure returns NULL and sets @error.
+ */
+MonoMList*
+mono_mlist_append_checked (MonoMList* list, MonoObject *data, MonoError *error)
+{
+ mono_error_init (error);
+ MonoMList* res = mono_mlist_alloc_checked (data, error);
+ return_val_if_nok (error, NULL);
+
if (list) {
MonoMList* last = mono_mlist_last (list);
MONO_OBJECT_SETREF (last, next, res);
#include <mono/metadata/object.h>
typedef struct _MonoMList MonoMList;
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoMList* mono_mlist_alloc (MonoObject *data);
MONO_API MonoObject* mono_mlist_get_data (MonoMList* list);
MONO_API void mono_mlist_set_data (MonoMList* list, MonoObject *data);
MONO_API int mono_mlist_length (MonoMList* list);
MONO_API MonoMList* mono_mlist_next (MonoMList* list);
MONO_API MonoMList* mono_mlist_last (MonoMList* list);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoMList* mono_mlist_prepend (MonoMList* list, MonoObject *data);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoMList* mono_mlist_append (MonoMList* list, MonoObject *data);
+
+MonoMList* mono_mlist_prepend_checked (MonoMList* list, MonoObject *data, MonoError *error);
+MonoMList* mono_mlist_append_checked (MonoMList* list, MonoObject *data, MonoError *error);
+
MONO_API MonoMList* mono_mlist_remove_item (MonoMList* list, MonoMList *item);
#endif /* __MONO_METADATA_MONO_MLIST_H__ */
MonoString *
mono_string_new_utf16_checked (MonoDomain *domain, const guint16 *text, gint32 len, MonoError *error);
+MonoString *
+mono_string_from_utf16_checked (mono_unichar2 *data, MonoError *error);
+
+MonoString *
+mono_string_from_utf32_checked (mono_unichar4 *data, MonoError *error);
+
gboolean
mono_runtime_object_init_checked (MonoObject *this_obj, MonoError *error);
if (mono_profiler_get_events () & MONO_PROFILE_METHOD_EVENTS)
mono_profiler_method_start_invoke (method);
- MONO_PREPARE_RESET_BLOCKING;
+ MONO_ENTER_GC_UNSAFE;
result = callbacks.runtime_invoke (method, obj, params, exc, error);
- MONO_FINISH_RESET_BLOCKING;
+ MONO_EXIT_GC_UNSAFE;
if (mono_profiler_get_events () & MONO_PROFILE_METHOD_EVENTS)
mono_profiler_method_end_invoke (method);
gpointer res;
- MONO_PREPARE_RESET_BLOCKING;
+ g_assert (!mono_threads_is_coop_enabled ());
+
+ MONO_ENTER_GC_UNSAFE;
method = mono_marshal_get_thunk_invoke_wrapper (method);
res = mono_compile_method (method);
- MONO_FINISH_RESET_BLOCKING;
+ MONO_EXIT_GC_UNSAFE;
return res;
}
MonoString *
mono_string_from_utf16 (gunichar2 *data)
{
+ MonoError error;
+ MonoString *result = mono_string_from_utf16_checked (data, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+/**
+ * mono_string_from_utf16_checked:
+ * @data: the UTF16 string (LPWSTR) to convert
+ * @error: set on error
+ *
+ * Converts a NULL terminated UTF16 string (LPWSTR) to a MonoString.
+ *
+ * Returns: a MonoString. On failure sets @error and returns NULL.
+ */
+MonoString *
+mono_string_from_utf16_checked (gunichar2 *data, MonoError *error)
+{
+
MONO_REQ_GC_UNSAFE_MODE;
- MonoError error;
- MonoString *res = NULL;
+ mono_error_init (error);
MonoDomain *domain = mono_domain_get ();
int len = 0;
while (data [len]) len++;
- res = mono_string_new_utf16_checked (domain, data, len, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
- return res;
+ return mono_string_new_utf16_checked (domain, data, len, error);
}
/**
*/
MonoString *
mono_string_from_utf32 (mono_unichar4 *data)
+{
+ MonoError error;
+ MonoString *result = mono_string_from_utf32_checked (data, &error);
+ mono_error_cleanup (&error);
+ return result;
+}
+
+/**
+ * mono_string_from_utf32_checked:
+ * @data: the UTF32 string (LPWSTR) to convert
+ * @error: set on error
+ *
+ * Converts a UTF32 (UCS-4)to a MonoString.
+ *
+ * Returns: a MonoString. On failure returns NULL and sets @error.
+ */
+MonoString *
+mono_string_from_utf32_checked (mono_unichar4 *data, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
+ mono_error_init (error);
MonoString* result = NULL;
mono_unichar2 *utf16_output = NULL;
- GError *error = NULL;
+ GError *gerror = NULL;
glong items_written;
int len = 0;
while (data [len]) len++;
- utf16_output = g_ucs4_to_utf16 (data, len, NULL, &items_written, &error);
+ utf16_output = g_ucs4_to_utf16 (data, len, NULL, &items_written, &gerror);
- if (error)
- g_error_free (error);
+ if (gerror)
+ g_error_free (gerror);
- result = mono_string_from_utf16 (utf16_output);
+ result = mono_string_from_utf16_checked (utf16_output, error);
g_free (utf16_output);
return result;
}
MONO_API mono_unichar4 *
mono_string_to_utf32 (MonoString *string_obj);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoString *
mono_string_from_utf16 (mono_unichar2 *data);
+MONO_RT_EXTERNAL_ONLY
MONO_API MonoString *
mono_string_from_utf32 (mono_unichar4 *data);
static inline void
dynamic_image_lock (MonoDynamicImage *image)
{
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
mono_image_lock ((MonoImage*)image);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
}
static inline void
*/
klass->flags = tb->attrs;
klass->has_cctor = 1;
- klass->has_finalize = 1;
- klass->has_finalize_inited = 1;
mono_class_setup_parent (klass, klass->parent);
/* fool mono_class_setup_supertypes */
sgen_client_thread_register_worker (void)
{
mono_thread_info_register_small_id ();
- mono_thread_info_set_name (mono_native_thread_id_get (), "SGen worker");
+ mono_native_thread_set_name (mono_native_thread_id_get (), "SGen worker");
}
/* Variables holding start/end nursery so it won't have to be passed at every call */
* polling system does not notify when the socket is closed */
mono_threadpool_ms_io_remove_socket (GPOINTER_TO_INT (sock));
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
closesocket (sock);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
}
gint32
return NULL;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
#ifdef HOST_WIN32
{
newsock = _wapi_accept (sock, NULL, 0);
#endif
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
*werror = 0;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = _wapi_listen (sock, backlog);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (ret == SOCKET_ERROR)
*werror = WSAGetLastError ();
/* Locate the SocketAddress data buffer in the object */
if (!domain->sockaddr_data_field) {
- domain->sockaddr_data_field = mono_class_get_field_from_name (domain->sockaddr_class, "data");
+ domain->sockaddr_data_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Buffer");
g_assert (domain->sockaddr_data_field);
}
+ /* Locate the SocketAddress data buffer length in the object */
+ if (!domain->sockaddr_data_length_field) {
+ domain->sockaddr_data_length_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Size");
+ g_assert (domain->sockaddr_data_length_field);
+ }
+
/* May be the +2 here is too conservative, as sa_len returns
* the length of the entire sockaddr_in/in6, including
* sizeof (unsigned short) of the family */
struct sockaddr_in *sa_in = (struct sockaddr_in *)saddr;
guint16 port = ntohs (sa_in->sin_port);
guint32 address = ntohl (sa_in->sin_addr.s_addr);
+ int buffer_size = 8;
- if (sa_size < 8) {
+ if (sa_size < buffer_size) {
mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
return NULL;
}
mono_array_set (data, guint8, 7, (address) & 0xff);
mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
+ mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
return sockaddr_obj;
} else if (saddr->sa_family == AF_INET6) {
struct sockaddr_in6 *sa_in = (struct sockaddr_in6 *)saddr;
int i;
+ int buffer_size = 28;
guint16 port = ntohs (sa_in->sin6_port);
- if (sa_size < 28) {
+ if (sa_size < buffer_size) {
mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
return NULL;
}
(sa_in->sin6_scope_id >> 24) & 0xff);
mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
+ mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
return sockaddr_obj;
}
#ifdef HAVE_SYS_UN_H
else if (saddr->sa_family == AF_UNIX) {
int i;
+ int buffer_size = sa_size + 2;
for (i = 0; i < sa_size; i++)
mono_array_set (data, guint8, i + 2, saddr->sa_data [i]);
mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
+ mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
return sockaddr_obj;
}
}
sa = (salen <= 128) ? (gchar *)alloca (salen) : (gchar *)g_malloc0 (salen);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = _wapi_getsockname (sock, (struct sockaddr *)sa, &salen);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (ret == SOCKET_ERROR) {
*werror = WSAGetLastError ();
sa = (salen <= 128) ? (gchar *)alloca (salen) : (gchar *)g_malloc0 (salen);
/* Note: linux returns just 2 for AF_UNIX. Always. */
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = _wapi_getpeername (sock, (struct sockaddr *)sa, &salen);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (ret == SOCKET_ERROR) {
*werror = WSAGetLastError ();
static struct sockaddr*
create_sockaddr_from_object (MonoObject *saddr_obj, socklen_t *sa_size, gint32 *werror, MonoError *error)
{
- MonoClassField *field;
+ MonoDomain *domain = mono_domain_get ();
MonoArray *data;
gint32 family;
int len;
mono_error_init (error);
- /* Dig the SocketAddress data buffer out of the object */
- field = mono_class_get_field_from_name (saddr_obj->vtable->klass, "data");
- data = *(MonoArray **)(((char *)saddr_obj) + field->offset);
+ if (!domain->sockaddr_class)
+ domain->sockaddr_class = mono_class_load_from_name (get_socket_assembly (), "System.Net", "SocketAddress");
+
+ /* Locate the SocketAddress data buffer in the object */
+ if (!domain->sockaddr_data_field) {
+ domain->sockaddr_data_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Buffer");
+ g_assert (domain->sockaddr_data_field);
+ }
+
+ /* Locate the SocketAddress data buffer length in the object */
+ if (!domain->sockaddr_data_length_field) {
+ domain->sockaddr_data_length_field = mono_class_get_field_from_name (domain->sockaddr_class, "m_Size");
+ g_assert (domain->sockaddr_data_length_field);
+ }
+
+ data = *(MonoArray **)(((char *)saddr_obj) + domain->sockaddr_data_field->offset);
/* The data buffer is laid out as follows:
* byte 0 is the address family low byte
* UNIX:
* the rest is the file name
*/
- len = mono_array_length (data);
- if (len < 2) {
- mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
- return NULL;
- }
-
+ len = *(int *)(((char *)saddr_obj) + domain->sockaddr_data_length_field->offset);
+ g_assert (len >= 2);
+
family = convert_family ((MonoAddressFamily)(mono_array_get (data, guint8, 0) + (mono_array_get (data, guint8, 1) << 8)));
if (family == AF_INET) {
struct sockaddr_in *sa;
return FALSE;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = mono_poll (pfds, 1, timeout);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
return;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = _wapi_connect (sock, sa, sa_size);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
LOGDEBUG (g_message("%s: disconnecting from socket %p (reuse %d)", __func__, sock, reuse));
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
/* I _think_ the extension function pointers need to be looked
* up for each socket. FIXME: check the best way to store
ret = WSAIoctl (sock, SIO_GET_EXTENSION_FUNCTION_POINTER, (gchar *)&disco_guid, sizeof (GUID),
(gchar *)&_wapi_disconnectex, sizeof (void *), &output_bytes, NULL, NULL);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (ret != 0) {
/* make sure that WSAIoctl didn't put crap in the
*/
_wapi_disconnectex = NULL;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
/*
* Use the SIO_GET_EXTENSION_FUNCTION_POINTER to
ret = WSAIoctl (sock, SIO_GET_EXTENSION_FUNCTION_POINTER, (gchar *)&trans_guid, sizeof(GUID),
(gchar *)&_wapi_transmitfile, sizeof(void *), &output_bytes, NULL, NULL);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (ret != 0)
_wapi_transmitfile = NULL;
return;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
if (_wapi_disconnectex != NULL) {
if (!_wapi_disconnectex (sock, NULL, TF_REUSE_SOCKET, 0))
*werror = ERROR_NOT_SUPPORTED;
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted)
if (interrupted)
return 0;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
#ifdef HOST_WIN32
{
ret = _wapi_recv (sock, buf, count, recvflags);
#endif
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
return 0;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = WSARecv (sock, wsabufs, count, &recv, &recvflags, NULL, NULL);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
return 0;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = _wapi_recvfrom (sock, buf, count, recvflags, sa, &sa_size);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
return 0;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = _wapi_send (sock, buf, count, sendflags);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
return 0;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = WSASend (sock, wsabufs, count, &sent, sendflags, NULL, NULL);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
return 0;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = _wapi_sendto (sock, buf, count, sendflags, sa, sa_size);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
return;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = mono_poll (pfds, nfds, timeout);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
return;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
/* No need to deal with MulticastOption names here, because
* you cant getsockopt AddMembership or DropMembership (the
ret = _wapi_getsockopt (sock, system_level, system_name, &val, &valsize);
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (ret == SOCKET_ERROR) {
*werror = WSAGetLastError ();
valsize = mono_array_length (*byte_val);
buf = mono_array_addr (*byte_val, guchar, 0);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = _wapi_getsockopt (sock, system_level, system_name, buf, &valsize);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (ret == SOCKET_ERROR)
*werror = WSAGetLastError ();
int i;
field = mono_class_get_field_from_name (ipaddr->vtable->klass, "m_Numbers");
+ g_assert (field);
data = *(MonoArray **)(((char *)ipaddr) + field->offset);
-/* Solaris has only the 8 bit version. */
-#ifndef s6_addr16
for (i = 0; i < 8; i++) {
- guint16 s = mono_array_get (data, guint16, i);
+ const guint16 s = GUINT16_TO_BE (mono_array_get (data, guint16, i));
+
+/* Solaris/MacOS have only the 8 bit version. */
+#ifndef s6_addr16
in6addr.s6_addr[2 * i + 1] = (s >> 8) & 0xff;
in6addr.s6_addr[2 * i] = s & 0xff;
- }
#else
- for (i = 0; i < 8; i++)
- in6addr.s6_addr16[i] = mono_array_get (data, guint16, i);
+ in6addr.s6_addr16[i] = s;
#endif
+ }
return in6addr;
}
#endif
* Get group address
*/
field = mono_class_get_field_from_name (obj_val->vtable->klass, "m_Group");
+ g_assert (field);
address = *(MonoObject **)(((char *)obj_val) + field->offset);
if (address)
return;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
/* Currently, the values for how (recv=0, send=1, both=2) match the BSD API */
ret = _wapi_shutdown (sock, how);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
o_len = mono_array_length (output);
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = WSAIoctl (sock, code, i_buffer, i_len, o_buffer, o_len, &output_bytes, NULL, NULL);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (ret == SOCKET_ERROR) {
*werror = WSAGetLastError ();
g_free (address);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
switch (family) {
case AF_INET: {
g_assert_not_reached ();
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (!ret)
return FALSE;
return FALSE;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = TransmitFile (sock, file, 0, 0, NULL, &buffers, flags);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_info_uninstall_interrupt (&interrupted);
if (interrupted) {
return FALSE;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
CloseHandle (file);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return ret;
}
{
MonoError error;
MonoString *str = mono_string_new_size_checked (mono_domain_get (), length, &error);
- mono_error_raise_exception (&error);
+ mono_error_set_pending_exception (&error);
return str;
}
g_assert (job);
exists = mono_g_hash_table_lookup_extended (states, GINT_TO_POINTER (fd), &k, (gpointer*) &list);
- list = mono_mlist_append (list, (MonoObject*) job);
+ list = mono_mlist_append_checked (list, (MonoObject*) job, &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
mono_g_hash_table_replace (states, GINT_TO_POINTER (fd), list);
operations = get_operations_for_jobs (list);
MONO_OBJECT_SETREF (ares, handle, (MonoObject*) wait_handle);
}
mono_monitor_exit ((MonoObject*) ares);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
WaitForSingleObjectEx (wait_event, INFINITE, TRUE);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
}
ac = (MonoAsyncCall*) ares->object_data;
}
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
WaitForSingleObject (sem, timeout != -1 ? end - now : timeout);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
}
domain->cleanup_semaphore = NULL;
MONO_API MonoException* mono_thread_get_undeniable_exception (void);
-void mono_thread_set_name_internal (MonoInternalThread *this_obj, MonoString *name, gboolean managed, MonoError *error);
+void mono_thread_set_name_internal (MonoInternalThread *this_obj, MonoString *name, gboolean permanent, MonoError *error);
void mono_runtime_set_has_tls_get (gboolean val);
gboolean mono_runtime_has_tls_get (void);
if (!mono_thread_info_lookup (MONO_UINT_TO_NATIVE_THREAD_ID (thread->tid))->tools_thread)
mono_profiler_thread_end (thread->tid);
+ mono_hazard_pointer_clear (mono_hazard_pointer_get (), 1);
+
if (thread == mono_thread_internal_current ()) {
/*
* This will signal async signal handlers that the thread has exited.
mono_profiler_thread_start (tid);
/* if the name was set before starting, we didn't invoke the profiler callback */
- if (internal->name && (internal->flags & MONO_THREAD_FLAG_NAME_SET)) {
+ if (internal->name) {
char *tname = g_utf16_to_utf8 (internal->name, internal->name_len, NULL, NULL, NULL);
mono_profiler_thread_name (internal->tid, tname);
- mono_thread_info_set_name (MONO_UINT_TO_NATIVE_THREAD_ID (internal->tid), tname);
+ mono_native_thread_set_name (MONO_UINT_TO_NATIVE_THREAD_ID (internal->tid), tname);
g_free (tname);
}
+
/* start_func is set only for unmanaged start functions */
if (start_func) {
start_func (start_arg);
*/
THREAD_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT") waiting for thread %p (%"G_GSIZE_FORMAT") to start", __func__, mono_native_thread_id_get (), internal, (gsize)internal->tid));
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
WaitForSingleObjectEx (internal->start_notify, INFINITE, FALSE);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
CloseHandle (internal->start_notify);
internal->start_notify = NULL;
}
void
-mono_thread_set_name_internal (MonoInternalThread *this_obj, MonoString *name, gboolean managed, MonoError *error)
+mono_thread_set_name_internal (MonoInternalThread *this_obj, MonoString *name, gboolean permanent, MonoError *error)
{
LOCK_THREAD (this_obj);
mono_error_init (error);
- if ((this_obj->flags & MONO_THREAD_FLAG_NAME_SET) && !this_obj->threadpool_thread) {
+ if ((this_obj->flags & MONO_THREAD_FLAG_NAME_SET)) {
UNLOCK_THREAD (this_obj);
mono_error_set_invalid_operation (error, "Thread.Name can only be set once.");
this_obj->name = g_new (gunichar2, mono_string_length (name));
memcpy (this_obj->name, mono_string_chars (name), mono_string_length (name) * 2);
this_obj->name_len = mono_string_length (name);
+
+ if (permanent)
+ this_obj->flags |= MONO_THREAD_FLAG_NAME_SET;
}
else
this_obj->name = NULL;
- if (managed)
- this_obj->flags |= MONO_THREAD_FLAG_NAME_SET;
UNLOCK_THREAD (this_obj);
if (this_obj->name && this_obj->tid) {
char *tname = mono_string_to_utf8 (name);
mono_profiler_thread_name (this_obj->tid, tname);
- mono_thread_info_set_name (thread_get_tid (this_obj), tname);
+ mono_native_thread_set_name (thread_get_tid (this_obj), tname);
mono_free (tname);
}
}
mono_thread_set_state (cur_thread, ThreadState_WaitSleepJoin);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret=WaitForSingleObjectEx (handle, ms, TRUE);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_clr_state (cur_thread, ThreadState_WaitSleepJoin);
start = (ms == -1) ? 0 : mono_100ns_ticks ();
do {
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
if (multiple)
ret = WaitForMultipleObjectsEx (numhandles, handles, waitall, wait, alertable);
else
ret = WaitForSingleObjectEx (handles [0], ms, alertable);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (ret != WAIT_IO_COMPLETION)
break;
mono_thread_set_state (thread, ThreadState_WaitSleepJoin);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = SignalObjectAndWait (toSignal, toWait, ms, TRUE);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
THREAD_DEBUG (g_message("%s: %d threads to wait for in this batch", __func__, wait->num));
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret=WaitForMultipleObjectsEx(wait->num, wait->handles, TRUE, timeout, TRUE);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if(ret==WAIT_FAILED) {
/* See the comment in build_wait_tids() */
count++;
}
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret=WaitForMultipleObjectsEx (count, wait->handles, FALSE, timeout, TRUE);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if(ret==WAIT_FAILED) {
/* See the comment in build_wait_tids() */
gboolean
mono_aot_is_linkonce_method (MonoMethod *method)
{
- // FIXME:
- // This doesn't work yet, because
- // it can make us call methods which belong
- // to aot modules which haven't been loaded yet,
- // so the init method will read uninitialized got
- // entries.
return FALSE;
#if 0
WrapperInfo *info;
* METHOD might not be set if the caller only has the image/token info.
*/
static gpointer
-load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoMethod *method, guint32 token, int method_index)
+load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoMethod *method, guint32 token, int method_index,
+ MonoError *error)
{
MonoJitInfo *jinfo = NULL;
guint8 *code = NULL, *info;
gboolean res;
+ mono_error_init (error);
+
init_amodule_got (amodule);
if (mono_profiler_get_events () & MONO_PROFILE_ENTER_LEAVE) {
char *full_name;
if (!method) {
- MonoError error;
- method = mono_get_method_checked (image, token, NULL, NULL, &error);
- g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ method = mono_get_method_checked (image, token, NULL, NULL, error);
+ if (!method)
+ return NULL;
}
full_name = mono_method_full_name (method, TRUE);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: NOT FOUND: %s.", full_name);
return NULL;
else if (mono_jit_stats.methods_aot == mono_last_aot_method - 1) {
if (!method) {
- MonoError error;
- method = mono_get_method_checked (image, token, NULL, NULL, &error);
+ method = mono_get_method_checked (image, token, NULL, NULL, error);
if (!method)
- mono_error_cleanup (&error);/* FIXME don't swallow the error */
+ return NULL;
}
if (method) {
char *name = mono_method_full_name (method, TRUE);
}
if (!(is_llvm_code (amodule, code) && (amodule->info.flags & MONO_AOT_FILE_FLAG_LLVM_ONLY))) {
- MonoError error;
-
- res = init_method (amodule, method_index, method, NULL, NULL, &error);
- if (!mono_error_ok (&error))
- mono_error_raise_exception (&error); /* FIXME: Don't raise here */
+ res = init_method (amodule, method_index, method, NULL, NULL, error);
if (!res)
goto cleanup;
}
char *full_name;
if (!method) {
- MonoError error;
- method = mono_get_method_checked (image, token, NULL, NULL, &error);
+ method = mono_get_method_checked (image, token, NULL, NULL, error);
if (!method)
- g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
+ return NULL;
}
full_name = mono_method_full_name (method, TRUE);
MonoJitInfo *jinfo;
if (!method) {
- MonoError error;
- method = mono_get_method_checked (amodule->assembly->image, token, NULL, NULL, &error);
+ method = mono_get_method_checked (amodule->assembly->image, token, NULL, NULL, error);
if (!method)
- g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
+ return NULL;
}
mono_profiler_method_jit (method);
jinfo = mono_jit_info_table_find (domain, (char*)code);
g_assert (context);
res = init_method (amodule, method_index, NULL, klass, context, &error);
+ /* Its okay to raise in llvmonly mode */
mono_error_raise_exception (&error);
}
context.method_inst = rgctx->method_inst;
res = init_method (amodule, method_index, NULL, rgctx->class_vtable->klass, &context, &error);
+ /* Its okay to raise in llvmonly mode */
mono_error_raise_exception (&error);
}
g_assert (context);
res = init_method (amodule, method_index, NULL, klass, context, &error);
+ /* Its okay to raise in llvmonly mode */
mono_error_raise_exception (&error);
}
/*
- * mono_aot_get_method:
+ * mono_aot_get_method_checked:
*
* Return a pointer to the AOTed native code for METHOD if it can be found,
* NULL otherwise.
* On platforms with function pointers, this doesn't return a function pointer.
*/
gpointer
-mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
+mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *error)
{
MonoClass *klass = method->klass;
MonoMethod *orig_method = method;
guint8 *code;
gboolean cache_result = FALSE;
+ mono_error_init (error);
+
if (domain != mono_get_root_domain ())
/* Non shared AOT code can't be used in other appdomains */
return NULL;
method_index = mono_metadata_token_index (method->token) - 1;
}
- code = (guint8 *)load_method (domain, amodule, klass->image, method, method->token, method_index);
+ code = (guint8 *)load_method (domain, amodule, klass->image, method, method->token, method_index, error);
+ if (!is_ok (error))
+ return NULL;
if (code && cache_result) {
amodule_lock (amodule);
g_hash_table_insert (amodule->method_to_code, orig_method, code);
return code;
}
+/*
+ * mono_aot_get_method:
+ *
+ * Return a pointer to the AOTed native code for METHOD if it can be found,
+ * NULL otherwise.
+ * On platforms with function pointers, this doesn't return a function pointer.
+ */
+gpointer
+mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
+{
+ MonoError error;
+
+ gpointer res = mono_aot_get_method_checked (domain, method, &error);
+ mono_error_raise_exception (&error);
+ return res;
+}
+
/**
* Same as mono_aot_get_method, but we try to avoid loading any metadata from the
* method.
{
MonoAotModule *aot_module = (MonoAotModule *)image->aot_module;
int method_index;
+ MonoError error;
+ gpointer res;
if (!aot_module)
return NULL;
method_index = mono_metadata_token_index (token) - 1;
- return load_method (domain, aot_module, image, NULL, token, method_index);
+ res = load_method (domain, aot_module, image, NULL, token, method_index, &error);
+ mono_error_raise_exception (&error); /* FIXME: Don't raise here */
+ return res;
}
typedef struct {
static gint64 last_keepalive;
gint64 msecs;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
do {
again:
}
} while ((res > 0 && total < len) || (res == -1 && get_last_sock_error () == MONO_EINTR));
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return total;
}
static int
socket_transport_accept (int socket_fd)
{
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
conn_fd = accept (socket_fd, NULL, NULL);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (conn_fd == -1) {
fprintf (stderr, "debugger-agent: Unable to listen on %d\n", socket_fd);
{
int res;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
do {
res = send (conn_fd, data, len, 0);
} while (res == -1 && get_last_sock_error () == MONO_EINTR);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (res != len)
return FALSE;
FD_ZERO (&readfds);
FD_SET (sfd, &readfds);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
res = select (sfd + 1, &readfds, NULL, NULL, &tv);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (res == 0) {
fprintf (stderr, "debugger-agent: Timed out waiting to connect.\n");
if (sfd == -1)
continue;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
res = connect (sfd, &sockaddr.addr, sock_len);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (res != -1)
break; /* Success */
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
close (sfd);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
}
if (rp == 0) {
#else
shutdown (conn_fd, SHUT_RD);
shutdown (listen_fd, SHUT_RDWR);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
close (listen_fd);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
#endif
}
case OP_STOREV_MEMBASE: {
src_var = get_vreg_to_inst (cfg, ins->sreg1);
+ if (COMPILE_LLVM (cfg) && !mini_is_gsharedvt_klass (ins->klass) && !cfg->gen_write_barriers)
+ break;
+
if (!src_var) {
g_assert (ins->klass);
src_var = mono_compile_create_var_for_vreg (cfg, &ins->klass->byval_arg, OP_LOCAL, ins->sreg1);
return 1;
}
- g_free (agent);
pa [0] = main_args;
/* Pass NULL as 'exc' so unhandled exceptions abort the runtime */
mono_runtime_invoke_checked (method, NULL, pa, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!is_ok (&error)) {
+ g_print ("The entry point method of assembly '%s' could not execute due to %s\n", agent, mono_error_get_message (&error));
+ mono_error_cleanup (&error);
+ g_free (agent);
+ return 1;
+ }
+ g_free (agent);
return 0;
}
* We only set the native name of the thread since MS.NET leaves the
* managed thread name for the main thread as null.
*/
- mono_thread_info_set_name (mono_native_thread_id_get (), "Main");
+ mono_native_thread_set_name (mono_native_thread_id_get (), "Main");
if (enable_profile) {
mono_profiler_load (profile_options);
ARM_MOV_REG_REG (code, ARMREG_IP, ARMREG_SP);
ARM_PUSH (code, MONO_ARM_REGSAVE_MASK);
+ ARM_SUB_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, 8);
+
/* restore all the regs from ctx (in r0), but not sp, the stack pointer */
ctx_reg = ARMREG_R0;
ARM_LDR_IMM (code, ARMREG_IP, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, pc));
ARM_MOV_REG_REG (code, ARMREG_LR, ARMREG_PC);
ARM_MOV_REG_REG (code, ARMREG_PC, ARMREG_R1);
+ ARM_ADD_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, 8);
+
/* epilog */
ARM_POP_NWB (code, 0xff0 | ((1 << ARMREG_SP) | (1 << ARMREG_PC)));
void
mono_generic_class_init (MonoVTable *vtable);
-void mono_interruption_checkpoint_from_trampoline (void);
-
MonoObject*
mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *klass, gboolean deref_arg, gpointer *args);
return FALSE;
if (!cfg->compile_aot) {
MonoError error;
- if (!mono_runtime_class_init_full (vtable, &error))
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!mono_runtime_class_init_full (vtable, &error)) {
+ mono_error_cleanup (&error);
+ return FALSE;
+ }
}
} else if (method->klass->flags & TYPE_ATTRIBUTE_BEFORE_FIELD_INIT) {
if (cfg->run_cctors && method->klass->has_cctor) {
if (! vtable->initialized)
return FALSE;
MonoError error;
- if (!mono_runtime_class_init_full (vtable, &error))
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ if (!mono_runtime_class_init_full (vtable, &error)) {
+ mono_error_cleanup (&error);
+ return FALSE;
+ }
}
} else if (mono_class_needs_cctor_run (method->klass, NULL)) {
if (!method->klass->runtime_info)
CHECK_CFG_ERROR;
}
- if (cfg->llvm_only && !cfg->method->wrapper_type)
+ if (cfg->llvm_only && !cfg->method->wrapper_type && (!cmethod || cmethod->is_inflated))
cfg->signatures = g_slist_prepend_mempool (cfg->mempool, cfg->signatures, fsig);
/* See code below */
return 0;
}
+gboolean
+mono_arm_is_hard_float (void)
+{
+ return arm_fpu == MONO_ARM_FPU_VFP_HARD;
+}
#ifndef DISABLE_JIT
}
#endif
-gboolean
-mono_arm_is_hard_float (void)
-{
- return arm_fpu == MONO_ARM_FPU_VFP_HARD;
-}
-
static gboolean
is_regsize_var (MonoType *t)
{
if (dis_link) {
MonoObject *o = mono_gchandle_get_target (dis_link);
if (o) {
- list = mono_mlist_prepend (list, o);
+ list = mono_mlist_prepend_checked (list, o, &error);
+ mono_error_assert_ok (&error);
}
}
}
gboolean
mono_handle_exception (MonoContext *ctx, MonoObject *obj)
{
+ MONO_REQ_GC_UNSAFE_MODE;
+
#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->exceptions_thrown++;
#endif
gpointer
mono_altstack_restore_prot (mgreg_t *regs, guint8 *code, gpointer *tramp_data, guint8* tramp)
{
+ MONO_REQ_GC_UNSAFE_MODE;
+
void (*func)(void) = (void (*)(void))tramp_data;
func ();
return NULL;
void
mono_resume_unwind (MonoContext *ctx)
{
+ MONO_REQ_GC_UNSAFE_MODE;
+
MonoJitTlsData *jit_tls = (MonoJitTlsData *)mono_native_tls_get_value (mono_jit_tls_id);
MonoContext new_ctx;
// FIXME:
if (stind_op == CEE_STOBJ)
mono_mb_emit_op (mb, CEE_STOBJ, mono_class_from_mono_type (sig->ret));
+ else if (stind_op == CEE_STIND_REF)
+ /* Avoid write barriers, the vret arg points to the stack */
+ mono_mb_emit_byte (mb, CEE_STIND_I);
else
mono_mb_emit_byte (mb, stind_op);
}
// FIXME: beforefieldinit
if (ctx->has_got_access || mono_class_get_cctor (cfg->method->klass)) {
+ /*
+ * linkonce methods shouldn't have initialization,
+ * because they might belong to assemblies which
+ * haven't been loaded yet.
+ */
+ g_assert (!ctx->is_linkonce);
emit_init_method (ctx);
} else {
LLVMBuildBr (ctx->builder, ctx->inited_bb);
sampling_thread_func (void *data)
{
mono_threads_attach_tools_thread ();
- mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler sampler");
+ mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler sampler");
gint64 rate = 1000000000 / mono_profiler_get_sampling_rate ();
get_method_from_ip (void *ip)
{
MonoJitInfo *ji;
- char *method;
+ MonoMethod *method;
+ char *method_name;
char *res;
MonoDomain *domain = mono_domain_get ();
MonoDebugSourceLocation *location;
return res;
}
- method = mono_method_full_name (jinfo_get_method (ji), TRUE);
+ method = jinfo_get_method (ji);
+ method_name = mono_method_full_name (method, TRUE);
/* FIXME: unused ? */
- location = mono_debug_lookup_source_location (jinfo_get_method (ji), (guint32)((guint8*)ip - (guint8*)ji->code_start), domain);
+ location = mono_debug_lookup_source_location (method, (guint32)((guint8*)ip - (guint8*)ji->code_start), domain);
- res = g_strdup_printf (" %s + 0x%x (%p %p) [%p - %s]", method, (int)((char*)ip - (char*)ji->code_start), ji->code_start, (char*)ji->code_start + ji->code_size, domain, domain->friendly_name);
+ res = g_strdup_printf (" %s {%p} + 0x%x (%p %p) [%p - %s]", method_name, method, (int)((char*)ip - (char*)ji->code_start), ji->code_start, (char*)ji->code_start + ji->code_size, domain, domain->friendly_name);
mono_debug_free_source_location (location);
- g_free (method);
+ g_free (method_name);
return res;
}
*dummy = NULL;
/* mono_thread_attach put the thread in RUNNING mode from STARTING, but we need to
* return the right cookie. */
- return mono_threads_cookie_for_reset_blocking_start (mono_thread_info_current (), 1);
+ return mono_threads_enter_gc_unsafe_region_cookie (mono_thread_info_current ());
} else {
*dummy = orig;
/* thread state (BLOCKING|RUNNING) -> RUNNING */
- return mono_threads_reset_blocking_start (dummy);
+ return mono_threads_enter_gc_unsafe_region (dummy);
}
}
}
/* it won't do anything if cookie is NULL
* thread state RUNNING -> (RUNNING|BLOCKING) */
- mono_threads_reset_blocking_end (cookie, dummy);
+ mono_threads_exit_gc_unsafe_region (cookie, dummy);
if (orig != domain) {
if (!orig)
mono_class_init (method->klass);
- if ((code = mono_aot_get_method (domain, method))) {
+ if ((code = mono_aot_get_method_checked (domain, method, error))) {
MonoVTable *vtable;
/*
return NULL;
}
}
+ if (!is_ok (error))
+ return NULL;
}
#endif
}
/**
- * common_call_trampoline_inner:
+ * common_call_trampoline:
*
* The code to handle normal, virtual, and interface method calls and jumps, both
* from JITted and LLVM compiled code.
*/
static gpointer
-common_call_trampoline_inner (mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTable *vt, gpointer *vtable_slot, MonoError *error)
+common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTable *vt, gpointer *vtable_slot, MonoError *error)
{
gpointer addr, compiled_method;
gboolean generic_shared = FALSE;
return addr;
}
-static gpointer
-common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTable *vt, gpointer *vtable_slot, MonoError *error)
-{
- gpointer res;
- MONO_PREPARE_RESET_BLOCKING;
- res = common_call_trampoline_inner (regs, code, m, vt, vtable_slot, error);
- MONO_FINISH_RESET_BLOCKING;
- return res;
-}
-
/**
* mono_magic_trampoline:
*
gpointer
mono_magic_trampoline (mgreg_t *regs, guint8 *code, gpointer arg, guint8* tramp)
{
- MonoError error;
gpointer res;
+ MONO_ENTER_GC_UNSAFE_UNBALANCED;
+
+ MonoError error;
+
trampoline_calls ++;
res = common_call_trampoline (regs, code, (MonoMethod *)arg, NULL, NULL, &error);
- if (!mono_error_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return NULL;
- }
+ mono_error_set_pending_exception (&error);
+
+ mono_interruption_checkpoint_from_trampoline ();
+
+ MONO_EXIT_GC_UNSAFE_UNBALANCED;
+
return res;
}
static gpointer
mono_vcall_trampoline (mgreg_t *regs, guint8 *code, int slot, guint8 *tramp)
{
+ MONO_REQ_GC_UNSAFE_MODE;
+
MonoObject *this_arg;
MonoVTable *vt;
gpointer *vtable_slot;
gpointer
mono_generic_virtual_remoting_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8 *tramp)
{
+ MONO_REQ_GC_UNSAFE_MODE;
+
MonoError error;
MonoGenericContext context = { NULL, NULL };
MonoMethod *imt_method, *declaring;
mono_aot_trampoline (mgreg_t *regs, guint8 *code, guint8 *token_info,
guint8* tramp)
{
+ MONO_REQ_GC_UNSAFE_MODE;
+
MonoImage *image;
guint32 token;
MonoMethod *method = NULL;
mono_aot_plt_trampoline (mgreg_t *regs, guint8 *code, guint8 *aot_module,
guint8* tramp)
{
+ MONO_REQ_GC_UNSAFE_MODE;
+
guint32 plt_info_offset = mono_aot_get_plt_info_offset (regs, code);
gpointer res;
MonoError error;
static gpointer
mono_rgctx_lazy_fetch_trampoline (mgreg_t *regs, guint8 *code, gpointer data, guint8 *tramp)
{
+ MONO_REQ_GC_UNSAFE_MODE;
+
static gboolean inited = FALSE;
static int num_lookups = 0;
guint32 slot = GPOINTER_TO_UINT (data);
gpointer
mono_delegate_trampoline (mgreg_t *regs, guint8 *code, gpointer *arg, guint8* tramp)
{
+ MONO_REQ_GC_UNSAFE_MODE;
+
MonoDomain *domain = mono_domain_get ();
MonoDelegate *delegate;
MonoJitInfo *ji;
static gpointer
mono_handler_block_guard_trampoline (mgreg_t *regs, guint8 *code, gpointer *tramp_info, guint8* tramp)
{
+ MONO_REQ_GC_UNSAFE_MODE;
+
MonoContext ctx;
MonoException *exc;
MonoJitTlsData *jit_tls = (MonoJitTlsData *)mono_native_tls_get_value (mono_jit_tls_id);
mono_create_gc_safepoint (MonoCompile *cfg, MonoBasicBlock *bblock)
{
MonoInst *poll_addr, *ins;
+
+ if (cfg->disable_gc_safe_points)
+ return;
+
if (cfg->verbose_level > 1)
printf ("ADDING SAFE POINT TO BB %d\n", bblock->block_num);
if (info && info->subtype == WRAPPER_SUBTYPE_ICALL_WRAPPER &&
(info->d.icall.func == mono_thread_interruption_checkpoint ||
- info->d.icall.func == mono_threads_finish_blocking ||
- info->d.icall.func == mono_threads_reset_blocking_start)) {
+ info->d.icall.func == mono_threads_exit_gc_safe_region_unbalanced)) {
/* These wrappers are called from the wrapper for the polling function, leading to potential stack overflow */
if (cfg->verbose_level > 1)
printf ("SKIPPING SAFEPOINTS for wrapper %s\n", cfg->method->name);
mini_gc_init_cfg (cfg);
+ if (method->wrapper_type == MONO_WRAPPER_UNKNOWN) {
+ WrapperInfo *info = mono_marshal_get_wrapper_info (method);
+
+ /* These wrappers are using linkonce linkage, so they can't access GOT slots */
+ if ((info && (info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG || info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_OUT_SIG))) {
+ cfg->disable_gc_safe_points = TRUE;
+ /* This is safe, these wrappers only store to the stack */
+ cfg->gen_write_barriers = FALSE;
+ }
+ }
+
if (COMPILE_LLVM (cfg)) {
cfg->opt |= MONO_OPT_ABCREM;
}
guint disable_deadce_vars : 1;
guint disable_out_of_line_bblocks : 1;
guint disable_direct_icalls : 1;
+ guint disable_gc_safe_points : 1;
guint create_lmf_var : 1;
/*
* When this is set, the code to push/pop the LMF from the LMF stack is generated as IR
void mono_aot_cleanup (void);
gpointer mono_aot_get_method (MonoDomain *domain,
MonoMethod *method);
+gpointer mono_aot_get_method_checked (MonoDomain *domain,
+ MonoMethod *method, MonoError *error);
gpointer mono_aot_get_method_from_token (MonoDomain *domain, MonoImage *image, guint32 token);
gboolean mono_aot_is_got_entry (guint8 *code, guint8 *addr);
guint8* mono_aot_get_plt_entry (guint8 *code);
*/
void mono_exception_native_unwind (void *ctx, MONO_SIG_HANDLER_INFO_TYPE *info);
+/*
+ * Coop support for trampolines
+ */
+void mono_interruption_checkpoint_from_trampoline (void);
#endif /* __MONO_MINI_H__ */
MonoThread *thread = NULL;
mono_threads_attach_tools_thread ();
- mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler helper");
+ mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler helper");
//fprintf (stderr, "Server listening\n");
command_socket = -1;
MonoProfiler *prof = (MonoProfiler *)arg;
mono_threads_attach_tools_thread ();
- mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler writer");
+ mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler writer");
dump_header (prof);
MonoProfiler *prof = (MonoProfiler *)arg;
mono_threads_attach_tools_thread ();
- mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler dumper");
+ mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler dumper");
while (InterlockedRead (&prof->run_dumper_thread)) {
mono_os_sem_wait (&prof->dumper_queue_sem, MONO_SEM_FLAGS_NONE);
endif
+if ENABLE_COOP
+COOP_DISABLED_TESTS= thunks.exe
+else
+COOP_DISABLED_TESTS=
+endif
+
# The two finalizer tests only work under sgen
# gc-altstack.exe fails under boehm because it has no support for altstack
# bug-459094.exe creates an extremely deep directory tree
delegate-invoke.exe \
bug-Xamarin-5278.exe \
$(PLATFORM_DISABLED_TESTS) \
- $(EXTRA_DISABLED_TESTS)
+ $(EXTRA_DISABLED_TESTS) \
+ $(COOP_DISABLED_TESTS)
DISABLED_TESTS_WRENCH= \
$(DISABLED_TESTS) \
#if defined(HOST_WATCHOS)
#define MONO_CONTEXT_GET_CURRENT(ctx) do { \
+ gpointer _dummy; \
+ ctx.regs [ARMREG_SP] = &_dummy; \
} while (0);
#else
if (mono_os_mutex_trylock (&mutex->m) == 0)
return 0;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
res = mono_os_mutex_lock (&mutex->m);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return res;
}
{
gint res;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
res = mono_os_cond_wait (&cond->c, &mutex->m);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return res;
}
{
gint res;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
res = mono_os_cond_timedwait (&cond->c, &mutex->m, timeout_ms);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return res;
}
{
gint res;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
res = mono_os_sem_wait (&sem->s, flags);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return res;
}
{
gint res;
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
res = mono_os_sem_timedwait (&sem->s, timeout_ms, flags);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return res;
}
For further explanation of what can and can't be done in GC unsafe mode:
http://www.mono-project.com/docs/advanced/runtime/docs/coop-suspend/#gc-unsafe-mode
-
*/
-#define MONO_BEGIN_GC_UNSAFE \
+#define MONO_ENTER_GC_UNSAFE \
do { \
- gpointer __dummy; \
- gpointer __gc_unsafe_cookie = mono_threads_enter_gc_unsafe_region (&__dummy) \
+ gpointer __gc_unsafe_dummy; \
+ gpointer __gc_unsafe_cookie = mono_threads_enter_gc_unsafe_region (&__gc_unsafe_dummy) \
-#define MONO_END_GC_UNSAFE \
- mono_threads_exit_gc_unsafe_region (__gc_unsafe_cookie, &__dummy); \
+#define MONO_EXIT_GC_UNSAFE \
+ mono_threads_exit_gc_unsafe_region (__gc_unsafe_cookie, &__gc_unsafe_dummy); \
} while (0)
-#define MONO_BEGIN_GC_SAFE \
+#define MONO_ENTER_GC_SAFE \
do { \
- gpointer __dummy; \
- gpointer __gc_safe_cookie = mono_threads_enter_gc_safe_region (&__dummy) \
+ gpointer __gc_safe_dummy; \
+ gpointer __gc_safe_cookie = mono_threads_enter_gc_safe_region (&__gc_safe_dummy) \
-#define MONO_END_GC_SAFE \
- mono_threads_exit_gc_safe_region (__gc_safe_cookie, &__dummy); \
+#define MONO_EXIT_GC_SAFE \
+ mono_threads_exit_gc_safe_region (__gc_safe_cookie, &__gc_safe_dummy); \
} while (0)
MONO_END_DECLS
// FIXME: This would be more efficient if instead of instantiating the stack it just pushed a simple depth counter up and down,
// perhaps with a per-thread cookie in the high bits.
#ifdef ENABLE_CHECKED_BUILD_GC
+
// Maintains a single per-thread stack of ints, used to ensure nesting is not violated
-MonoNativeTlsKey coop_reset_count_stack_key;
-static int coop_tls_push (int v) {
- GArray *stack = mono_native_tls_get_value (coop_reset_count_stack_key);
+static MonoNativeTlsKey coop_reset_count_stack_key;
+
+static void
+coop_tls_push (gpointer cookie)
+{
+ GArray *stack;
+
+ stack = mono_native_tls_get_value (coop_reset_count_stack_key);
if (!stack) {
- stack = g_array_new (FALSE,FALSE,sizeof(int));
+ stack = g_array_new (FALSE, FALSE, sizeof(gpointer));
mono_native_tls_set_value (coop_reset_count_stack_key, stack);
}
- g_array_append_val (stack, v);
- return stack->len;
+
+ g_array_append_val (stack, cookie);
}
-static int coop_tls_pop (int *v) {
- GArray *stack = mono_native_tls_get_value (coop_reset_count_stack_key);
+
+static void
+coop_tls_pop (gpointer received_cookie)
+{
+ GArray *stack;
+ gpointer expected_cookie;
+
+ stack = mono_native_tls_get_value (coop_reset_count_stack_key);
if (!stack || 0 == stack->len)
- return -1;
- stack->len--;
- *v = g_array_index (stack, int, stack->len);
- int len = stack->len;
- if (0 == len) {
+ mono_fatal_with_history ("Received cookie %p but found no stack at all, %x\n", received_cookie);
+
+ expected_cookie = g_array_index (stack, gpointer, stack->len - 1);
+ stack->len --;
+
+ if (0 == stack->len) {
g_array_free (stack,TRUE);
mono_native_tls_set_value (coop_reset_count_stack_key, NULL);
}
- return len;
+
+ if (expected_cookie != received_cookie)
+ mono_fatal_with_history ("Received cookie %p but expected %p\n", received_cookie, expected_cookie);
}
+
#endif
static int coop_reset_blocking_count;
}
static void
-copy_stack_data (MonoThreadInfo *info, void* stackdata_begin)
+copy_stack_data (MonoThreadInfo *info, gpointer *stackdata_begin)
{
MonoThreadUnwindState *state;
int stackdata_size;
state->gc_stackdata_size = stackdata_size;
}
-void*
-mono_threads_prepare_blocking (void* stackdata)
+gpointer
+mono_threads_enter_gc_safe_region (gpointer *stackdata)
+{
+ gpointer cookie;
+
+ if (!mono_threads_is_coop_enabled ())
+ return NULL;
+
+ cookie = mono_threads_enter_gc_safe_region_unbalanced (stackdata);
+
+#ifdef ENABLE_CHECKED_BUILD_GC
+ if (mono_check_mode_enabled (MONO_CHECK_MODE_GC))
+ coop_tls_push (cookie);
+#endif
+
+ return cookie;
+}
+
+gpointer
+mono_threads_enter_gc_safe_region_unbalanced (gpointer *stackdata)
{
MonoThreadInfo *info;
}
void
-mono_threads_finish_blocking (void *cookie, void* stackdata)
+mono_threads_exit_gc_safe_region (gpointer cookie, gpointer *stackdata)
+{
+ if (!mono_threads_is_coop_enabled ())
+ return;
+
+#ifdef ENABLE_CHECKED_BUILD_GC
+ if (mono_check_mode_enabled (MONO_CHECK_MODE_GC))
+ coop_tls_pop (cookie);
+#endif
+
+ mono_threads_exit_gc_safe_region_unbalanced (cookie, stackdata);
+}
+
+void
+mono_threads_exit_gc_safe_region_unbalanced (gpointer cookie, gpointer *stackdata)
{
static gboolean warned_about_bad_transition;
MonoThreadInfo *info;
}
}
+void
+mono_threads_assert_gc_safe_region (void)
+{
+ MONO_REQ_GC_SAFE_MODE;
+}
gpointer
-mono_threads_cookie_for_reset_blocking_start (MonoThreadInfo *info, int reset_blocking_count)
+mono_threads_enter_gc_unsafe_region (gpointer *stackdata)
{
+ gpointer cookie;
+
+ if (!mono_threads_is_coop_enabled ())
+ return NULL;
+
+ cookie = mono_threads_enter_gc_unsafe_region_unbalanced (stackdata);
+
#ifdef ENABLE_CHECKED_BUILD_GC
- g_assert (reset_blocking_count != 0);
- if (mono_check_mode_enabled (MONO_CHECK_MODE_GC)) {
- int level = coop_tls_push (reset_blocking_count);
- //g_warning("Entering reset nest; level %d; cookie %d\n", level, reset_blocking_count);
- return (void *)(intptr_t)reset_blocking_count;
- }
+ if (mono_check_mode_enabled (MONO_CHECK_MODE_GC))
+ coop_tls_push (cookie);
#endif
- return info;
+ return cookie;
}
-void*
-mono_threads_reset_blocking_start (void* stackdata)
+gpointer
+mono_threads_enter_gc_unsafe_region_unbalanced (gpointer *stackdata)
{
MonoThreadInfo *info;
if (!mono_threads_is_coop_enabled ())
return NULL;
- info = mono_thread_info_current_unchecked ();
+ ++coop_reset_blocking_count;
-#ifdef ENABLE_CHECKED_BUILD_GC
- int reset_blocking_count = InterlockedIncrement (&coop_reset_blocking_count);
- // In this mode, the blocking count is used as the reset cookie. We would prefer
- // (but do not require) this to be unique across invocations and threads.
- if (reset_blocking_count == 0) // We *do* require it be nonzero
- reset_blocking_count = coop_reset_blocking_count = 1;
-#else
- int reset_blocking_count = ++coop_reset_blocking_count;
-#endif
+ info = mono_thread_info_current_unchecked ();
/* If the thread is not attached, it doesn't make sense prepare for suspend. */
if (!info || !mono_thread_info_is_live (info))
g_error ("Unknown thread state");
}
- return mono_threads_cookie_for_reset_blocking_start (info, reset_blocking_count);
+ return info;
+}
+
+gpointer
+mono_threads_enter_gc_unsafe_region_cookie (MonoThreadInfo *info)
+{
+ g_assert (mono_threads_is_coop_enabled ());
+
+#ifdef ENABLE_CHECKED_BUILD_GC
+ if (mono_check_mode_enabled (MONO_CHECK_MODE_GC))
+ coop_tls_push (info);
+#endif
+
+ return info;
+}
+
+void
+mono_threads_exit_gc_unsafe_region (gpointer cookie, gpointer *stackdata)
+{
+ if (!mono_threads_is_coop_enabled ())
+ return;
+
+#ifdef ENABLE_CHECKED_BUILD_GC
+ if (mono_check_mode_enabled (MONO_CHECK_MODE_GC))
+ coop_tls_pop (cookie);
+#endif
+
+ mono_threads_exit_gc_unsafe_region_unbalanced (cookie, stackdata);
}
void
-mono_threads_reset_blocking_end (void *cookie, void* stackdata)
+mono_threads_exit_gc_unsafe_region_unbalanced (gpointer cookie, gpointer *stackdata)
{
if (!mono_threads_is_coop_enabled ())
return;
return;
#ifdef ENABLE_CHECKED_BUILD_GC
- if (mono_check_mode_enabled (MONO_CHECK_MODE_GC)) {
- int received_cookie = (int)(intptr_t)cookie;
- int desired_cookie;
- int level = coop_tls_pop (&desired_cookie);
- //g_warning("Leaving reset nest; back to level %d; desired cookie %d; received cookie %d\n", level, desired_cookie, received_cookie);
- if (level < 0)
- mono_fatal_with_history ("Expected cookie %d but found no stack at all, %x\n", desired_cookie, level);
- if (desired_cookie != received_cookie)
- mono_fatal_with_history ("Expected cookie %d but received %d\n", desired_cookie, received_cookie);
- } else // Notice this matches the line after the endif
+ if (!mono_check_mode_enabled (MONO_CHECK_MODE_GC))
#endif
{
g_assert (((MonoThreadInfo *)cookie) == mono_thread_info_current_unchecked ());
}
- mono_threads_prepare_blocking (stackdata);
+ mono_threads_enter_gc_safe_region_unbalanced (stackdata);
+}
+
+void
+mono_threads_assert_gc_unsafe_region (void)
+{
+ MONO_REQ_GC_UNSAFE_MODE;
}
void
if (mono_threads_is_coop_enabled ())
mono_polling_required = 0;
}
-
-gpointer
-mono_threads_enter_gc_unsafe_region (gpointer* stackdata)
-{
- if (!mono_threads_is_coop_enabled ())
- return NULL;
-
- return mono_threads_reset_blocking_start (stackdata);
-}
-
-void
-mono_threads_exit_gc_unsafe_region (gpointer cookie, gpointer* stackdata)
-{
- if (!mono_threads_is_coop_enabled ())
- return;
-
- mono_threads_reset_blocking_end (cookie, stackdata);
-}
-
-void
-mono_threads_assert_gc_unsafe_region (void)
-{
- MONO_REQ_GC_UNSAFE_MODE;
-}
-
-gpointer
-mono_threads_enter_gc_safe_region (gpointer *stackdata)
-{
- if (!mono_threads_is_coop_enabled ())
- return NULL;
-
- return mono_threads_prepare_blocking (stackdata);
-}
-
-void
-mono_threads_exit_gc_safe_region (gpointer cookie, gpointer *stackdata)
-{
- if (!mono_threads_is_coop_enabled ())
- return;
-
- mono_threads_finish_blocking (cookie, stackdata);
-}
-
-void
-mono_threads_assert_gc_safe_region (void)
-{
- MONO_REQ_GC_SAFE_MODE;
-}
#include <glib.h>
#include "checked-build.h"
+#include "mono-threads-api.h"
G_BEGIN_DECLS
void
mono_threads_state_poll (void);
-gpointer
-mono_threads_prepare_blocking (gpointer stackdata);
-
-void
-mono_threads_finish_blocking (gpointer cookie, gpointer stackdata);
-
-gpointer
-mono_threads_reset_blocking_start (gpointer stackdata);
-
-void
-mono_threads_reset_blocking_end (gpointer cookie, gpointer stackdata);
-
static inline void
mono_threads_safepoint (void)
{
mono_threads_state_poll ();
}
-#define MONO_PREPARE_BLOCKING \
- MONO_REQ_GC_NOT_CRITICAL; \
- do { \
- gpointer __dummy; \
- gpointer __blocking_cookie = mono_threads_prepare_blocking (&__dummy)
+/*
+ * The following are used for wrappers and trampolines as their
+ * calls might be unbalanced, due to exception unwinding.
+ */
-#define MONO_FINISH_BLOCKING \
- mono_threads_finish_blocking (__blocking_cookie, &__dummy); \
- } while (0)
+gpointer
+mono_threads_enter_gc_safe_region_unbalanced (gpointer *stackdata);
+
+void
+mono_threads_exit_gc_safe_region_unbalanced (gpointer cookie, gpointer *stackdata);
+
+gpointer
+mono_threads_enter_gc_unsafe_region_unbalanced (gpointer *stackdata);
+
+void
+mono_threads_exit_gc_unsafe_region_unbalanced (gpointer cookie, gpointer *stackdata);
-#define MONO_PREPARE_RESET_BLOCKING \
+#define MONO_ENTER_GC_UNSAFE_UNBALANCED \
do { \
gpointer __dummy; \
- gpointer __reset_cookie = mono_threads_reset_blocking_start (&__dummy)
+ gpointer __reset_cookie = mono_threads_enter_gc_unsafe_region_unbalanced (&__dummy)
-#define MONO_FINISH_RESET_BLOCKING \
- mono_threads_reset_blocking_end (__reset_cookie, &__dummy); \
+#define MONO_EXIT_GC_UNSAFE_UNBALANCED \
+ mono_threads_exit_gc_unsafe_region_unbalanced (__reset_cookie, &__dummy); \
} while (0)
G_END_DECLS
}
void
-mono_threads_core_set_name (MonoNativeThreadId tid, const char *name)
+mono_native_thread_set_name (MonoNativeThreadId tid, const char *name)
{
#ifdef __MACH__
/*
#endif
void
-mono_threads_core_set_name (MonoNativeThreadId tid, const char *name)
+mono_native_thread_set_name (MonoNativeThreadId tid, const char *name)
{
#if defined(_MSC_VER)
/* http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx */
if (alerted)
return sleep_interruptable (ms, alerted);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
if (ms == INFINITE) {
do {
#endif /* __linux__ */
}
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return 0;
}
gint
mono_thread_info_usleep (guint64 us)
{
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
g_usleep (us);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
return 0;
}
return mono_threads_core_open_thread_handle (handle, tid);
}
-void
-mono_thread_info_set_name (MonoNativeThreadId tid, const char *name)
-{
- mono_threads_core_set_name (tid, name);
-}
-
#define INTERRUPT_STATE ((MonoThreadInfoInterruptToken*) (size_t) -1)
struct _MonoThreadInfoInterruptToken {
gboolean
mono_thread_info_resume (MonoNativeThreadId tid);
-MONO_API void
-mono_thread_info_set_name (MonoNativeThreadId tid, const char *name);
-
void
mono_thread_info_safe_suspend_and_run (MonoNativeThreadId id, gboolean interrupt_kernel, MonoSuspendThreadCallback callback, gpointer user_data);
void mono_threads_core_unregister (THREAD_INFO_TYPE *info);
HANDLE mono_threads_core_open_handle (void);
HANDLE mono_threads_core_open_thread_handle (HANDLE handle, MonoNativeThreadId tid);
-void mono_threads_core_set_name (MonoNativeThreadId tid, const char *name);
void mono_threads_coop_begin_global_suspend (void);
void mono_threads_coop_end_global_suspend (void);
gboolean
mono_native_thread_create (MonoNativeThreadId *tid, gpointer func, gpointer arg);
+MONO_API void
+mono_native_thread_set_name (MonoNativeThreadId tid, const char *name);
+
/*Mach specific internals */
void mono_threads_init_dead_letter (void);
void mono_threads_install_dead_letter (void);
MonoThreadUnwindState* mono_thread_info_get_suspend_state (THREAD_INFO_TYPE *info);
gpointer
-mono_threads_cookie_for_reset_blocking_start (THREAD_INFO_TYPE *info, int reset_blocking_count);
+mono_threads_enter_gc_unsafe_region_cookie (THREAD_INFO_TYPE *info);
void mono_thread_info_wait_for_resume (THREAD_INFO_TYPE *info);
#endif
sprintf (service_name, "%d", port);
- MONO_PREPARE_BLOCKING;
+ MONO_ENTER_GC_SAFE;
ret = getaddrinfo (hostname, service_name, &hints, &info);
- MONO_FINISH_BLOCKING;
+ MONO_EXIT_GC_SAFE;
if (ret)
return 1; /* FIXME propagate the error */