Merge pull request #2965 from lambdageek/dev/checked-pinvoke3
authorAleksey Kliger (λgeek) <akliger@gmail.com>
Thu, 5 May 2016 17:18:47 +0000 (13:18 -0400)
committerAleksey Kliger (λgeek) <akliger@gmail.com>
Thu, 5 May 2016 17:18:47 +0000 (13:18 -0400)
[coop] Allow BLOCKING->DETACHED transition

36 files changed:
configure.ac
mcs/class/System/ReferenceSources/CAPI.cs [new file with mode: 0644]
mcs/class/System/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.cs
mcs/class/System/System.Security.Cryptography/AsnEncodedData.cs
mcs/class/System/System.Security.Cryptography/Oid.cs [deleted file]
mcs/class/System/System.Security.Cryptography/OidCollection.cs [deleted file]
mcs/class/System/System.Security.Cryptography/OidEnumerator.cs [deleted file]
mcs/class/System/System.Security.Cryptography/OidGroup.cs [deleted file]
mcs/class/System/System.dll.sources
mcs/class/System/Test/System.Security.Cryptography/OidTest.cs
mcs/class/System/mobile_System.dll.sources
mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Helper.cs
mcs/class/referencesource/System/security/system/security/cryptography/x509/x509utils.cs
mono/io-layer/processes.c
mono/metadata/gc.c
mono/metadata/icall-def.h
mono/metadata/icall.c
mono/metadata/monitor.c
mono/metadata/sgen-client-mono.h
mono/metadata/sgen-mono.c
mono/metadata/sgen-os-mach.c
mono/metadata/sgen-os-posix.c
mono/metadata/sgen-os-win32.c
mono/metadata/sgen-stw.c
mono/metadata/threadpool-ms.c
mono/metadata/threads.c
mono/mini/debugger-agent.c
mono/mini/mini-exceptions.c
mono/profiler/Makefile.am
mono/sgen/sgen-archdep.h
mono/sgen/sgen-debug.c
mono/utils/mono-context.h
mono/utils/mono-proclib.c
mono/utils/mono-time.c
mono/utils/mono-time.h
winconfig.h

index 966bd50391504aa8e884de27ef4bbf2fe058645e..ee3a9666ecd73c02cfd238b893fc23ec790db9e5 100644 (file)
@@ -3558,20 +3558,6 @@ AC_ARG_WITH(bitcode,         [  --with-bitcode=yes,no           If bitcode is en
 AC_ARG_WITH(xammac,          [  --with-xammac=yes,no            If you want to build the Xamarin.Mac assemblies (defaults to no)],    [], [with_xammac=no])
 AC_ARG_WITH(mobile_static,   [  --with-mobile_static=yes,no     If you want to build the mobile_static assemblies (defaults to no)],  [], [with_mobile_static=no])
 
-OPROFILE=no
-AC_ARG_WITH(oprofile,[  --with-oprofile=no,<oprofile install dir>   Enable oprofile support (defaults to no)],[
-       if test x$with_oprofile != xno; then
-           oprofile_include=$with_oprofile/include
-           if test ! -f $oprofile_include/opagent.h; then
-                 AC_MSG_ERROR([oprofile include file not found at $oprofile_include/opagent.h])
-               fi
-           OPROFILE=yes
-               OPROFILE_CFLAGS="-I$oprofile_include"
-           OPROFILE_LIBS="-L$with_oprofile/lib/oprofile -lopagent"
-           AC_DEFINE(HAVE_OPROFILE,1,[Have oprofile support])
-       fi
-])
-
 MALLOC_MEMPOOLS=no
 AC_ARG_WITH(malloc_mempools,[  --with-malloc-mempools=yes,no  Use malloc for each single mempool allocation (only for runtime debugging, defaults to no)],[
        if test x$with_malloc_mempools = xyes; then
@@ -3681,10 +3667,6 @@ AC_SUBST(docs_dir)
 ## Maybe should also disable if mcsdir is invalid.  Let's punt the issue for now.
 AM_CONDITIONAL(BUILD_MCS, [test x$cross_compiling = xno && test x$enable_mcs_build != xno])
 
-AM_CONDITIONAL(HAVE_OPROFILE, test x$OPROFILE = xyes)
-AC_SUBST(OPROFILE_CFLAGS)
-AC_SUBST(OPROFILE_LIBS)
-
 libmono_ldflags="$libmono_ldflags $LIBS"
 
 AM_CONDITIONAL(INSTALL_4_x, [test "x$with_profile4_x" = xyes])
@@ -4106,7 +4088,6 @@ echo "
        TLS:           $with_tls
        SIGALTSTACK:   $with_sigaltstack
        Engine:        $jit_status
-       oprofile:      $OPROFILE
        BigArrays:     $enable_big_arrays
        DTrace:        $enable_dtrace
        LLVM Back End: $enable_llvm (dynamically loaded: $enable_loadedllvm)
diff --git a/mcs/class/System/ReferenceSources/CAPI.cs b/mcs/class/System/ReferenceSources/CAPI.cs
new file mode 100644 (file)
index 0000000..28e1c47
--- /dev/null
@@ -0,0 +1,162 @@
+namespace System.Security.Cryptography {
+
+       static class CAPI {
+               // OID key type.
+               internal const uint CRYPT_OID_INFO_OID_KEY   = 1;
+               internal const uint CRYPT_OID_INFO_NAME_KEY  = 2;
+               internal const uint CRYPT_OID_INFO_ALGID_KEY = 3;
+               internal const uint CRYPT_OID_INFO_SIGN_KEY  = 4;
+
+               public static string CryptFindOIDInfoNameFromKey (string key, OidGroup oidGroup)
+               {
+                       // TODO: incomplete
+                       // TODO: oidGroup is ignored
+                       switch (key) {
+                       case "1.2.840.113549.1.1.5":
+                       case "1.3.14.3.2.29":
+                       case "1.3.14.3.2.15":
+                               return "sha1RSA";
+                       case "1.2.840.113549.1.1.4":
+                       case "1.3.14.3.2.3":
+                               return "md5RSA";
+                       case "1.2.840.10040.4.3":
+                       case "1.3.14.3.2.13":
+                               return "sha1DSA";
+                       case "1.2.840.113549.1.1.2":
+                       case "1.3.14.7.2.3.1":
+                               return "md2RSA";
+                       case "1.2.840.113549.1.1.3":
+                               return "md4RSA";
+                               return "md4RSA";
+                               return "md4RSA";
+                       case "1.3.14.3.2.27":
+                               return "dsaSHA1";
+                       case "2.16.840.1.101.2.1.1.19":
+                               return "mosaicUpdatedSig";
+                       case "1.3.14.3.2.26":
+                               return "sha1";
+                       case "1.2.840.113549.2.5":
+                               return "md5";
+                       case "2.16.840.1.101.3.4.2.1":
+                               return "sha256";
+                       case "2.16.840.1.101.3.4.2.2":
+                               return "sha384";
+                       case "2.16.840.1.101.3.4.2.3":
+                               return "sha512";
+                       case "1.2.840.113549.1.1.11":
+                               return "sha256RSA";
+                       case "1.2.840.113549.1.1.12":
+                               return "sha384RSA";
+                       case "1.2.840.113549.1.1.13":
+                               return "sha512RSA";
+                       case "1.2.840.113549.1.1.10":
+                               return "RSASSA-PSS";
+                       case "1.2.840.10045.4.1":
+                               return "sha1ECDSA";
+                       case "1.2.840.10045.4.3.2":
+                               return "sha256ECDSA";
+                       case "1.2.840.10045.4.3.3":
+                               return "sha384ECDSA";
+                       case "1.2.840.10045.4.3.4":
+                               return "sha512ECDSA";
+                       case "1.2.840.10045.4.3":
+                               return "specifiedECDSA";
+                       case "1.2.840.113549.1.1.1":
+                               return "RSA";
+                       case "1.2.840.113549.1.7.1":
+                               return "PKCS 7 Data";
+                       case "1.2.840.113549.1.9.3":
+                               return "Content Type";
+                       case "1.2.840.113549.1.9.4":
+                               return "Message Digest";
+                       case "1.2.840.113549.1.9.5":
+                               return "Signing Time";
+                       case "1.2.840.113549.3.7":
+                               return "3des";
+                       case "2.5.29.17":
+                               return "Subject Alternative Name";
+                       case "2.16.840.1.101.3.4.1.2":
+                               return "aes128";
+                       case "2.16.840.1.101.3.4.1.42":
+                               return "aes256";
+                       case "2.16.840.1.113730.1.1":
+                               return "Netscape Cert Type";
+                       }
+
+                       return null;
+               }
+
+               public static string CryptFindOIDInfoKeyFromName (string name, OidGroup oidGroup)
+               {
+                       // TODO: incomplete
+                       // TODO: oidGroup is ignored                    
+                       switch(name) {
+                       case "sha1RSA":
+                               return "1.2.840.113549.1.1.5";
+                       case "md5RSA":
+                               return "1.2.840.113549.1.1.4";
+                       case "sha1DSA":
+                               return "1.2.840.10040.4.3";
+                       case "shaRSA":
+                               return "1.3.14.3.2.29";
+                       case "md2RSA":
+                               return "1.2.840.113549.1.1.2";
+                       case "md4RSA":
+                               return "1.2.840.113549.1.1.3";
+                       case "dsaSHA1":
+                               return "1.3.14.3.2.27";
+                       case "mosaicUpdatedSig":
+                               return "2.16.840.1.101.2.1.1.19";
+                       case "sha1":
+                               return "1.3.14.3.2.26";
+                       case "md5":
+                               return "1.2.840.113549.2.5";
+                       case "sha256":
+                               return "2.16.840.1.101.3.4.2.1";
+                       case "sha384":
+                               return "2.16.840.1.101.3.4.2.2";
+                       case "sha512":
+                               return "2.16.840.1.101.3.4.2.3";
+                       case "sha256RSA":
+                               return "1.2.840.113549.1.1.11";
+                       case "sha384RSA":
+                               return "1.2.840.113549.1.1.12";
+                       case "sha512RSA":
+                               return "1.2.840.113549.1.1.13";
+                       case "RSASSA-PSS":
+                               return "1.2.840.113549.1.1.10";
+                       case "sha1ECDSA":
+                               return "1.2.840.10045.4.1";
+                       case "sha256ECDSA":
+                               return "1.2.840.10045.4.3.2";
+                       case "sha384ECDSA":
+                               return "1.2.840.10045.4.3.3";
+                       case "sha512ECDSA":
+                               return "1.2.840.10045.4.3.4";
+                       case "specifiedECDSA":
+                               return "1.2.840.10045.4.3";
+                       case "RSA":
+                               return "1.2.840.113549.1.1.1";
+                       case "PKCS 7 Data":
+                               return "1.2.840.113549.1.7.1";
+                       case "Content Type":
+                               return "1.2.840.113549.1.9.3";
+                       case "Message Digest":
+                               return "1.2.840.113549.1.9.4";
+                       case "Signing Time":
+                               return "1.2.840.113549.1.9.5";
+                       case "3des":
+                               return "1.2.840.113549.3.7";
+                       case "Subject Alternative Name":
+                               return "2.5.29.17";
+                       case "aes128":
+                               return "2.16.840.1.101.3.4.1.2";
+                       case "aes256":
+                               return "2.16.840.1.101.3.4.1.42";
+                       case "Netscape Cert Type":
+                               return "2.16.840.1.113730.1.1";
+                       }
+                       return null;
+               }
+       }
+}
\ No newline at end of file
index 92007a397d4fd040e8a65f134b55a5a4bbd91662..eeabf6905e3dcaab28bb514cde75d7419e5212ac 100644 (file)
@@ -70,7 +70,10 @@ namespace System.Security.Cryptography.X509Certificates {
 
                        _oid = new Oid (oid, friendlyName);
                        base.Critical = critical;
-                       _enhKeyUsage = enhancedKeyUsages.ReadOnlyCopy ();
+                       _enhKeyUsage = new OidCollection();
+                       foreach (Oid oid in enhancedKeyUsages) {
+                               _enhKeyUsage.Add(oid);
+                       }
                        RawData = Encode ();
                }
 
@@ -81,10 +84,14 @@ namespace System.Security.Cryptography.X509Certificates {
                                switch (_status) {
                                case AsnDecodeStatus.Ok:
                                case AsnDecodeStatus.InformationNotAvailable:
-                                       if (_enhKeyUsage == null)
-                                               _enhKeyUsage = new OidCollection ();
-                                       _enhKeyUsage.ReadOnly = true;
-                                       return _enhKeyUsage;
+
+                                       OidCollection oids = new OidCollection();
+                                       if (_enhKeyUsage != null) {
+                                               foreach(Oid oid in _enhKeyUsage) {
+                                                       oids.Add(oid);
+                                               }
+                                       }
+                                       return oids;
                                default:
                                        throw new CryptographicException ("Badly encoded extension.");
                                }
index 99860521102f983a62be9679c90bfa724b77610c..f6b45dd5e7ccd06af2833941fe3a4ce78bbe3771 100644 (file)
@@ -157,9 +157,9 @@ namespace System.Security.Cryptography {
                                return SubjectKeyIdentifierExtension (multiLine);
                        // other known objects (i.e. supported structure) - 
                        // but without any corresponding framework class
-                       case Oid.oidSubjectAltName:
+                       case "2.5.29.17": // oidSubjectAltName:
                                return SubjectAltName (multiLine);
-                       case Oid.oidNetscapeCertType:
+                       case "2.16.840.1.113730.1.1": // oidNetscapeCertType
                                return NetscapeCertType (multiLine);
                        default:
                                return Default (multiLine);
diff --git a/mcs/class/System/System.Security.Cryptography/Oid.cs b/mcs/class/System/System.Security.Cryptography/Oid.cs
deleted file mode 100644 (file)
index 7a1e785..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-//
-// Oid.cs - System.Security.Cryptography.Oid
-//
-// Author:
-//     Sebastien Pouliot  <sebastien@ximian.com>
-//
-// (C) 2003 Motus Technologies Inc. (http://www.motus.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
-
-using System.Security.Cryptography.X509Certificates;
-
-namespace System.Security.Cryptography {
-
-       public sealed class Oid {
-
-               private string _value;
-               private string _name;
-
-               // constructors
-
-               public Oid ()
-               {
-               }
-
-               public Oid (string oid) 
-               {
-                       if (oid == null)
-                               throw new ArgumentNullException ("oid");
-
-                       _value = oid;
-                       _name = GetName (oid);
-               }
-
-               public Oid (string value, string friendlyName)
-               {
-                       _value = value;
-                       _name = friendlyName;
-               }
-
-               public Oid (Oid oid) 
-               {
-                       if (oid == null)
-                               throw new ArgumentNullException ("oid");
-
-                       _value = oid.Value;
-                       _name = oid.FriendlyName;
-               }
-
-               // properties
-
-               public string FriendlyName {
-                       get { return _name; }
-                       set { 
-                               _name = value;
-                               _value = GetValue (_name);
-                       }
-               }
-
-               public string Value { 
-                       get { return _value; }
-                       set { 
-                               _value = value; 
-                               _name = GetName (_value);
-                       }
-               }
-
-               // internal stuff
-
-               // Known OID/Names not defined anywhere else (by OID order)
-               internal const string oidRSA = "1.2.840.113549.1.1.1";
-               internal const string nameRSA = "RSA";
-               internal const string oidPkcs7Data = "1.2.840.113549.1.7.1";
-               internal const string namePkcs7Data = "PKCS 7 Data";
-               internal const string oidPkcs9ContentType = "1.2.840.113549.1.9.3";
-               internal const string namePkcs9ContentType = "Content Type";
-               internal const string oidPkcs9MessageDigest = "1.2.840.113549.1.9.4";
-               internal const string namePkcs9MessageDigest = "Message Digest";
-               internal const string oidPkcs9SigningTime = "1.2.840.113549.1.9.5";
-               internal const string namePkcs9SigningTime = "Signing Time";
-               internal const string oidMd5 = "1.2.840.113549.2.5";
-               internal const string nameMd5 = "md5";
-               internal const string oid3Des = "1.2.840.113549.3.7";
-               internal const string name3Des = "3des";
-               internal const string oidSha1 = "1.3.14.3.2.26";
-               internal const string nameSha1 = "sha1";
-               internal const string oidSubjectAltName = "2.5.29.17";
-               internal const string nameSubjectAltName = "Subject Alternative Name";
-               internal const string oidAes128 = "2.16.840.1.101.3.4.1.2";
-               internal const string nameAes128 = "aes128";
-               internal const string oidAes256 = "2.16.840.1.101.3.4.1.42";
-               internal const string nameAes256 = "aes256";
-               internal const string oidSha256 = "2.16.840.1.101.3.4.2.1";
-               internal const string nameSha256 = "sha256";
-               internal const string oidSha512 = "2.16.840.1.101.3.4.2.3";
-               internal const string nameSha512 = "sha512";
-               internal const string oidNetscapeCertType = "2.16.840.1.113730.1.1";
-               internal const string nameNetscapeCertType = "Netscape Cert Type";
-
-               // TODO - find the complete list
-               private string GetName (string oid) 
-               {
-                       switch (oid) {
-                               case oidRSA:
-                                       return nameRSA;
-                               case oidPkcs7Data:
-                                       return namePkcs7Data;
-                               case oidPkcs9ContentType:
-                                       return namePkcs9ContentType;
-                               case oidPkcs9MessageDigest:
-                                       return namePkcs9MessageDigest;
-                               case oidPkcs9SigningTime:
-                                       return namePkcs9SigningTime;
-                               case oid3Des:
-                                       return name3Des;
-                               case X509BasicConstraintsExtension.oid:
-                                       return X509BasicConstraintsExtension.friendlyName;
-                               case X509KeyUsageExtension.oid:
-                                       return X509KeyUsageExtension.friendlyName;
-                               case X509EnhancedKeyUsageExtension.oid:
-                                       return X509EnhancedKeyUsageExtension.friendlyName;
-                               case X509SubjectKeyIdentifierExtension.oid:
-                                       return X509SubjectKeyIdentifierExtension.friendlyName;
-                               case oidSubjectAltName:
-                                       return nameSubjectAltName;
-                               case oidNetscapeCertType:
-                                       return nameNetscapeCertType;
-                               case oidMd5:
-                                       return nameMd5;
-                               case oidAes128:
-                                       return nameAes128;
-                               case oidAes256:
-                                       return nameAes256;
-                               case oidSha1:
-                                       return nameSha1;
-                               case oidSha256:
-                                       return nameSha256;
-                               case oidSha512:
-                                       return nameSha512;
-                               default:
-                                       return _name;
-                       }
-               }
-
-               // TODO - find the complete list
-               private string GetValue (string name) 
-               {
-                       switch (name) {
-                               case nameRSA:
-                                       return oidRSA;
-                               case namePkcs7Data:
-                                       return oidPkcs7Data;
-                               case namePkcs9ContentType:
-                                       return oidPkcs9ContentType;
-                               case namePkcs9MessageDigest:
-                                       return oidPkcs9MessageDigest;
-                               case namePkcs9SigningTime:
-                                       return oidPkcs9SigningTime;
-                               case name3Des:
-                                       return oid3Des;
-                               case X509BasicConstraintsExtension.friendlyName:
-                                       return X509BasicConstraintsExtension.oid;
-                               case X509KeyUsageExtension.friendlyName:
-                                       return X509KeyUsageExtension.oid;
-                               case X509EnhancedKeyUsageExtension.friendlyName:
-                                       return X509EnhancedKeyUsageExtension.oid;
-                               case X509SubjectKeyIdentifierExtension.friendlyName:
-                                       return X509SubjectKeyIdentifierExtension.oid;
-                               case nameSubjectAltName:
-                                       return oidSubjectAltName;
-                               case nameNetscapeCertType:
-                                       return oidNetscapeCertType;
-                               case nameMd5:
-                                       return oidMd5;
-                               case nameAes128:
-                                       return oidAes128;
-                               case nameAes256:
-                                       return oidAes256;
-                               case nameSha1:
-                                       return oidSha1;
-                               case nameSha256:
-                                       return oidSha256;
-                               case nameSha512:
-                                       return oidSha512;
-                               default:
-                                       return _value;
-                       }
-               }
-       }
-}
-
-#endif
diff --git a/mcs/class/System/System.Security.Cryptography/OidCollection.cs b/mcs/class/System/System.Security.Cryptography/OidCollection.cs
deleted file mode 100644 (file)
index 094582f..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-//
-// OidCollection.cs - System.Security.Cryptography.OidCollection
-//
-// Author:
-//     Sebastien Pouliot  <sebastien@ximian.com>
-//
-// (C) 2003 Motus Technologies Inc. (http://www.motus.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
-
-using System.Collections;
-
-namespace System.Security.Cryptography {
-
-       public sealed class OidCollection : ICollection, IEnumerable {
-
-               private ArrayList _list;
-               private bool _readOnly;
-
-               // constructors
-
-               public OidCollection ()
-               {
-                       _list = new ArrayList ();
-               }
-
-               // properties
-
-               public int Count {
-                       get { return _list.Count; }
-               }
-
-               public bool IsSynchronized {
-                       get { return _list.IsSynchronized; }
-               }
-
-               public Oid this [int index] {
-                       get { return (Oid) _list [index]; }
-               }
-
-               public Oid this [string oid] {
-                       get { 
-                               foreach (Oid o in _list) {
-                                       if (o.Value == oid)
-                                               return o;
-                               }
-                               return null; 
-                       }
-               }
-
-               public object SyncRoot {
-                       get { return _list.SyncRoot; }
-               }
-
-               // methods
-
-               public int Add (Oid oid)
-               {
-                       return (_readOnly ? 0 : _list.Add (oid));
-               }
-
-               public void CopyTo (Oid[] array, int index)
-               {
-                       _list.CopyTo ((Array)array, index);
-               }
-
-               // to satisfy ICollection - private
-               void ICollection.CopyTo (Array array, int index)
-               {
-                       _list.CopyTo (array, index);
-               }
-
-               public OidEnumerator GetEnumerator () 
-               {
-                       return new OidEnumerator (this);
-               }
-
-               // to satisfy IEnumerator - private
-               IEnumerator IEnumerable.GetEnumerator () 
-               {
-                       return new OidEnumerator (this);
-               }
-
-               // internal stuff
-
-               internal bool ReadOnly {
-                       get { return _readOnly; }
-                       set { _readOnly = value; }
-               }
-
-               internal OidCollection ReadOnlyCopy ()
-               {
-                       OidCollection copy = new OidCollection ();
-                       foreach (Oid oid in _list) {
-                               copy.Add (oid);
-                       }
-                       copy._readOnly = true;
-                       return copy;
-               }
-       }
-}
-
-#endif
diff --git a/mcs/class/System/System.Security.Cryptography/OidEnumerator.cs b/mcs/class/System/System.Security.Cryptography/OidEnumerator.cs
deleted file mode 100644 (file)
index cfd4214..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-// OidEnumerator.cs - System.Security.Cryptography.OidEnumerator
-//
-// Author:
-//     Sebastien Pouliot (spouliot@motus.com)
-//
-// (C) 2003 Motus Technologies Inc. (http://www.motus.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
-
-using System.Collections;
-
-namespace System.Security.Cryptography {
-
-       // Note: Match the definition of framework version 1.2.3400.0 on http://longhorn.msdn.microsoft.com
-
-       public sealed class OidEnumerator : IEnumerator {
-
-               private OidCollection _collection;
-               private int _position;
-
-               // note: couldn't reuse the IEnumerator from ArrayList because 
-               // it doesn't throw the same exceptions
-               internal OidEnumerator (OidCollection collection) 
-               {
-                       _collection = collection;
-                       _position = -1;
-               }
-
-               // properties
-
-               public Oid Current {
-                       get {
-                               if (_position < 0)
-                                       throw new ArgumentOutOfRangeException ();
-                               return (Oid) _collection [_position];
-                       }
-               }
-
-               object IEnumerator.Current {
-                       get {
-                               if (_position < 0)
-                                       throw new ArgumentOutOfRangeException ();
-                               return _collection [_position];
-                       }
-               }
-
-               // methods
-
-               public bool MoveNext () 
-               {
-                       if (++_position < _collection.Count)
-                               return true;
-                       else {
-                               // strangely we must always be able to return the last entry 
-                               _position = _collection.Count - 1;
-                               return false;
-                       }
-               }
-
-               public void Reset () 
-               {
-                       _position = -1;
-               }
-       }
-}
-
-#endif
diff --git a/mcs/class/System/System.Security.Cryptography/OidGroup.cs b/mcs/class/System/System.Security.Cryptography/OidGroup.cs
deleted file mode 100644 (file)
index 55045d9..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// OidGroup.cs:
-//
-// Authors:
-//     Marek Safar  <marek.safar@gmail.com>
-//
-// Copyright (C) 2015 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.
-//
-
-namespace System.Security.Cryptography
-{
-       public enum OidGroup {
-               All                     = 0,
-               HashAlgorithm           = 1,
-               EncryptionAlgorithm     = 2,
-               PublicKeyAlgorithm      = 3,
-               SignatureAlgorithm      = 4,
-               Attribute               = 5,
-               ExtensionOrAttribute    = 6,
-               EnhancedKeyUsage        = 7,
-               Policy                  = 8,
-               Template                = 9,
-               KeyDerivationFunction   = 10
-       }
-}
index 68a9f89f88fabf5390bd19560ceafde970cd6e8a..d1f99dac40d99b38a49802faa450c1cc57e8ddac 100644 (file)
@@ -521,10 +521,6 @@ System.Security.Authentication.ExtendedProtection.Configuration/ServiceNameEleme
 System.Security.Cryptography/AsnEncodedDataCollection.cs
 System.Security.Cryptography/AsnEncodedData.cs
 System.Security.Cryptography/AsnEncodedDataEnumerator.cs
-System.Security.Cryptography/OidCollection.cs
-System.Security.Cryptography/Oid.cs
-System.Security.Cryptography/OidEnumerator.cs
-System.Security.Cryptography/OidGroup.cs
 System.Security.Cryptography.X509Certificates/OpenFlags.cs
 System.Security.Cryptography.X509Certificates/OSX509Certificates.cs
 System.Security.Cryptography.X509Certificates/PublicKey.cs
@@ -645,6 +641,7 @@ Mono.Net.Security/SystemCertificateValidator.cs
 ReferenceSources/AssertWrapper.cs
 ReferenceSources/BinaryCompatibility.cs
 ReferenceSources/ConfigurationManagerInternalFactory.cs
+ReferenceSources/CAPI.cs
 ReferenceSources/EnvironmentHelpers.cs
 ReferenceSources/Internal.cs
 ReferenceSources/HttpSysSettings.cs
@@ -1072,6 +1069,10 @@ ReferenceSources/_SslStream.cs
 ../referencesource/System/sys/system/threading/Barrier.cs
 ../referencesource/System/sys/system/windows/markup/ValueSerializerAttribute.cs
 
+../referencesource/System/security/system/security/cryptography/oid.cs
+
+../referencesource/System/security/system/security/cryptography/x509/x509utils.cs
+
 ../referencesource/System/security/system/security/permissions/typedescriptorpermission.cs
 
 ../referencesource/System/services/timers/system/timers/ElapsedEventHandler.cs
index 4aa40ff84e75af8e636bd9bfb6d4a4f106e85d8b..7179e186f33987fde7de157ab0cc31975c94b9e0 100644 (file)
@@ -36,7 +36,6 @@ using System.Security.Cryptography;
 namespace MonoTests.System.Security.Cryptography {
 
        [TestFixture]
-
        public class OidTest {
 
                static string invalidOid = "1.0";
@@ -97,7 +96,7 @@ namespace MonoTests.System.Security.Cryptography {
                public void ConstructorStringStringNull () 
                {
                        Oid o = new Oid (validOid, null);
-                       Assert.IsNull (o.FriendlyName, "FriendlyName");
+                       Assert.AreEqual ("RSA", o.FriendlyName, "FriendlyName");
                        Assert.AreEqual (validOid, o.Value, "Value");
                }
 
@@ -136,7 +135,7 @@ namespace MonoTests.System.Security.Cryptography {
                        Oid o = new Oid (validOid, invalidName);
                        Assert.AreEqual (invalidName, o.FriendlyName, "FriendlyName");
                        o.FriendlyName = null;
-                       Assert.IsNull (o.FriendlyName, "FriendlyName-Null");
+                       Assert.AreEqual ("RSA", o.FriendlyName, "FriendlyName-Null");
                }
 
                [Test]
@@ -212,8 +211,15 @@ namespace MonoTests.System.Security.Cryptography {
                        o.FriendlyName = "sha512";
                        Assert.AreEqual (o.Value, "2.16.840.1.101.3.4.2.3", "sha512 Value from FriendlyName");
 
+                       o = new Oid ("2.16.840.1.101.3.4.2.2");
+                       Assert.AreEqual ("2.16.840.1.101.3.4.2.2", o.Value, "sha384 Value");
+                       Assert.AreEqual ("sha384", o.FriendlyName, "sha384 FriendlyName");
+
+                       o = new Oid ("1.2.840.113549.1.1.12");
+                       Assert.AreEqual ("1.2.840.113549.1.1.12", o.Value, "sha384RSA Value");
+                       Assert.AreEqual ("sha384RSA", o.FriendlyName, "sha384RSA FriendlyName");
+
                        // TODO: add other well known oid as we find them
                }
        }
 }
-
index 4bb3791c6d412f070cd861899fa16ce814be4574..fde44350a2c67cb5ac395431eae6bb079743c619 100644 (file)
@@ -331,10 +331,6 @@ System.Security.Cryptography.X509Certificates/X509VerificationFlags.cs
 System.Security.Cryptography/AsnEncodedData.cs
 System.Security.Cryptography/AsnEncodedDataCollection.cs
 System.Security.Cryptography/AsnEncodedDataEnumerator.cs
-System.Security.Cryptography/Oid.cs
-System.Security.Cryptography/OidCollection.cs
-System.Security.Cryptography/OidEnumerator.cs
-System.Security.Cryptography/OidGroup.cs
 System.Threading/Semaphore.cs
 System.Threading/ThreadExceptionEventArgs.cs
 System.Threading/ThreadExceptionEventHandler.cs
@@ -376,6 +372,7 @@ Mono.Net.Security/NoReflectionHelper.cs
 Mono.Net.Security/SystemCertificateValidator.cs
 
 ReferenceSources/AssertWrapper.cs
+ReferenceSources/CAPI.cs
 ReferenceSources/EnvironmentHelpers.cs
 ReferenceSources/Internal.cs
 ReferenceSources/HttpSysSettings.cs
@@ -781,6 +778,10 @@ ReferenceSources/Win32Exception.cs
 
 ../referencesource/System/sys/system/threading/Barrier.cs
 
+../referencesource/System/security/system/security/cryptography/oid.cs
+
+../referencesource/System/security/system/security/cryptography/x509/x509utils.cs
+
 ../referencesource/System/security/system/security/permissions/typedescriptorpermission.cs
 
 ../referencesource/System/services/timers/system/timers/ElapsedEventHandler.cs
index 1f3f1f83d1f9281914969e2139926fde093d3107..01a55bce6a3704073f26621039b17ec517b28bc7 100644 (file)
@@ -148,9 +148,37 @@ namespace System.Security.Cryptography.X509Certificates
                        }
                }
 
+               static byte[] PEM (string type, byte[] data)
+               {
+                       string pem = Encoding.ASCII.GetString (data);
+                       string header = String.Format ("-----BEGIN {0}-----", type);
+                       string footer = String.Format ("-----END {0}-----", type);
+                       int start = pem.IndexOf (header) + header.Length;
+                       int end = pem.IndexOf (footer, start);
+                       string base64 = pem.Substring (start, (end - start));
+                       return Convert.FromBase64String (base64);
+               }
+
+               static byte[] ConvertData (byte[] data)
+               {
+                       if (data == null || data.Length == 0)
+                               return data;
+
+                       // does it looks like PEM ?
+                       if (data [0] != 0x30) {
+                               try {
+                                       return PEM ("CERTIFICATE", data);
+                               } catch {
+                                       // let the implementation take care of it.
+                               }
+                       }
+                       return data;
+               }
+
 #if !MONOTOUCH && !XAMMAC
                public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
                {
+                       rawData = ConvertData (rawData);
                        if (nativeHelper != null)
                                return nativeHelper.Import (rawData, password, keyStorageFlags);
 
index 92fecf7812adb3acf330548b3ab483e8070d53ff..c5a093a1765a87ffbe3856cec3636fdc2d8cf76f 100644 (file)
@@ -23,7 +23,7 @@ namespace System.Security.Cryptography.X509Certificates {
 
     internal class X509Utils {
         private X509Utils () {}
-
+#if !MONO
         internal static bool IsCertRdnCharString (uint dwValueType) {
             return ((dwValueType & CAPI.CERT_RDN_TYPE_MASK) >= CAPI.CERT_RDN_NUMERIC_STRING);
         }
@@ -349,16 +349,26 @@ namespace System.Security.Cryptography.X509Certificates {
             CAPI.CRYPT_OID_INFO pOIDInfo = CAPI.CryptFindOIDInfo(CAPI.CRYPT_OID_INFO_OID_KEY, pszOid, 0);
             return pOIDInfo.Algid;
         }
-
+#endif
 #if FEATURE_CORESYSTEM
         [SecuritySafeCritical]
 #endif
-        internal static string FindOidInfo(uint keyType, string keyValue, OidGroup oidGroup) {
+        internal static string FindOidInfo(uint keyType, string keyValue, System.Security.Cryptography.OidGroup oidGroup) {
             if (keyValue == null)
                 throw new ArgumentNullException("keyValue");
             if (keyValue.Length == 0)
                 return null;
 
+#if MONO
+            switch(keyType) {
+                case CAPI.CRYPT_OID_INFO_OID_KEY:
+                    return CAPI.CryptFindOIDInfoNameFromKey(keyValue, oidGroup);
+                case CAPI.CRYPT_OID_INFO_NAME_KEY:
+                    return CAPI.CryptFindOIDInfoKeyFromName(keyValue, oidGroup);
+                default:
+                    throw new NotImplementedException(keyType.ToString());
+            }
+#else
             SafeLocalAllocHandle pvKey = SafeLocalAllocHandle.InvalidHandle;
 
             try {
@@ -389,21 +399,22 @@ namespace System.Security.Cryptography.X509Certificates {
             finally {
                 pvKey.Dispose();
             }
+#endif
         }
 
         // Try to find OID info within a specific group, and if that doesn't work fall back to all
         // groups for compatibility with previous frameworks
-        internal static string FindOidInfoWithFallback(uint key, string value, OidGroup group) {
+        internal static string FindOidInfoWithFallback(uint key, string value, System.Security.Cryptography.OidGroup group) {
             string info = FindOidInfo(key, value, group);
 
             // If we couldn't find it in the requested group, then try again in all groups
-            if (info == null && group != OidGroup.All) {
-                info = FindOidInfo(key, value, OidGroup.All);
+            if (info == null && group != System.Security.Cryptography.OidGroup.All) {
+                info = FindOidInfo(key, value, System.Security.Cryptography.OidGroup.All);
             }
 
             return info;
         }
-
+#if !MONO
         //
         // verify the passed keyValue is valid as per X.208
         //
@@ -568,5 +579,6 @@ error:
             else 
                 return SR.GetString(SR.Unknown_Error);
         }
+#endif
     }
 }
index 1136d17dcb2deb3aca5ab0c3d1daf0ca6244862d..212079346038545bd84f02e27809bacd4990ef9a 100644 (file)
@@ -2725,8 +2725,7 @@ process_wait (gpointer handle, guint32 timeout, gboolean alertable)
        WapiHandle_process *process_handle;
        pid_t pid G_GNUC_UNUSED, ret;
        int status;
-       guint32 start;
-       guint32 now;
+       gint64 start, now;
        struct MonoProcess *mp;
 
        /* FIXME: We can now easily wait on processes that aren't our own children,
index 9ab8f7dd6d674aa778d9a9f89a871ec77d1381bb..2cff646db1771c099780ffccbf618800d049a270 100644 (file)
@@ -876,14 +876,14 @@ mono_gc_cleanup (void)
                finished = TRUE;
                if (mono_thread_internal_current () != gc_thread) {
                        gboolean timed_out = FALSE;
-                       guint32 start_ticks = mono_msec_ticks ();
-                       guint32 end_ticks = start_ticks + 2000;
+                       gint64 start_ticks = mono_msec_ticks ();
+                       gint64 end_ticks = start_ticks + 2000;
 
                        mono_gc_finalize_notify ();
                        /* Finishing the finalizer thread, so wait a little bit... */
                        /* MS seems to wait for about 2 seconds */
                        while (!finalizer_thread_exited) {
-                               guint32 current_ticks = mono_msec_ticks ();
+                               gint64 current_ticks = mono_msec_ticks ();
                                guint32 timeout;
 
                                if (current_ticks >= end_ticks)
index 9c345a269cde4a0e5a36d7b234a9450695c4a004..b74631fd9420a19a216568a45eb1d0c00380a785 100644 (file)
@@ -239,7 +239,7 @@ ICALL(ENV_10, "get_HasShutdownStarted", ves_icall_System_Environment_get_HasShut
 ICALL(ENV_11, "get_MachineName", ves_icall_System_Environment_get_MachineName)
 ICALL(ENV_13, "get_Platform", ves_icall_System_Environment_get_Platform)
 ICALL(ENV_14, "get_ProcessorCount", mono_cpu_count)
-ICALL(ENV_15, "get_TickCount", mono_msec_ticks)
+ICALL(ENV_15, "get_TickCount", ves_icall_System_Environment_get_TickCount)
 ICALL(ENV_16, "get_UserName", ves_icall_System_Environment_get_UserName)
 ICALL(ENV_16m, "internalBroadcastSettingChange", ves_icall_System_Environment_BroadcastSettingChange)
 ICALL(ENV_17, "internalGetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable)
index 285905fb9b8b8369f009526ea213975274c8ff3c..e22c730342dc4a3bc8eadcb4932aa9722ad5cc93 100644 (file)
@@ -7278,6 +7278,14 @@ ves_icall_System_Environment_BroadcastSettingChange (void)
 #endif
 }
 
+ICALL_EXPORT
+gint32
+ves_icall_System_Environment_get_TickCount (void)
+{
+       /* this will overflow after ~24 days */
+       return (gint32) (mono_msec_boottime () & 0xffffffff);
+}
+
 ICALL_EXPORT gint32
 ves_icall_System_Runtime_Versioning_VersioningHelper_GetRuntimeId (void)
 {
index 45c13be4e0f780ed511c327c5c9925ff97626e36..510d1c18bcd31b3fcd86556f7ee0cea21b4fe0ef 100644 (file)
@@ -743,7 +743,7 @@ mono_monitor_try_enter_inflated (MonoObject *obj, guint32 ms, gboolean allow_int
        LockWord lw;
        MonoThreadsSync *mon;
        HANDLE sem;
-       guint32 then = 0, now, delta;
+       gint64 then = 0, now, delta;
        guint32 waitms;
        guint32 ret;
        guint32 new_status, old_status, tmp_status;
@@ -900,14 +900,9 @@ retry_contended:
                if (!mono_thread_test_state (mono_thread_internal_current (), (MonoThreadState)(ThreadState_StopRequested | ThreadState_SuspendRequested | ThreadState_AbortRequested))) {
                        if (ms != INFINITE) {
                                now = mono_msec_ticks ();
-                               if (now < then) {
-                                       LOCK_DEBUG (g_message ("%s: wrapped around! now=0x%x then=0x%x", __func__, now, then));
 
-                                       now += (0xffffffff - then);
-                                       then = 0;
-
-                                       LOCK_DEBUG (g_message ("%s: wrap rejig: now=0x%x then=0x%x delta=0x%x", __func__, now, then, now-then));
-                               }
+                               /* it should not overflow before ~30k years */
+                               g_assert (now >= then);
 
                                delta = now - then;
                                if (delta >= ms) {
index e9f9b1a81a7a5ddeaad89a7ae0ddac596f328fcc..36d6e7e968151fd47f0474fe538fd49a4d1b9bf1 100644 (file)
@@ -64,12 +64,7 @@ struct _SgenClientThreadInfo {
        void *stack_start;
        void *stack_start_limit;
 
-       /*FIXME pretty please finish killing ARCH_NUM_REGS */
-#ifdef USE_MONO_CTX
        MonoContext ctx;                /* ditto */
-#else
-       gpointer regs[ARCH_NUM_REGS];       /* ditto */
-#endif
 };
 
 #else
index bbd97e955df2a69003dafb75b8333c0bb505859b..e4ad7665f56c9dd02f974f3d91fb37360d2167d6 100644 (file)
@@ -2183,11 +2183,7 @@ sgen_client_thread_register (SgenThreadInfo* info, void *stack_bottom_fallback)
                info->client_info.stack_end = (char*)stack_bottom;
        }
 
-#ifdef USE_MONO_CTX
        memset (&info->client_info.ctx, 0, sizeof (MonoContext));
-#else
-       memset (&info->client_info.regs, 0, sizeof (info->client_info.regs));
-#endif
 
        if (mono_gc_get_gc_callbacks ()->thread_attach_func)
                info->client_info.runtime_data = mono_gc_get_gc_callbacks ()->thread_attach_func ();
@@ -2350,13 +2346,9 @@ sgen_client_scan_thread_data (void *start_nursery, void *end_nursery, gboolean p
                }
 
                if (!precise) {
-#ifdef USE_MONO_CTX
                        sgen_conservatively_pin_objects_from ((void**)&info->client_info.ctx, (void**)(&info->client_info.ctx + 1),
                                start_nursery, end_nursery, PIN_TYPE_STACK);
-#else
-                       sgen_conservatively_pin_objects_from ((void**)&info->client_info.regs, (void**)&info->client_info.regs + ARCH_NUM_REGS,
-                                       start_nursery, end_nursery, PIN_TYPE_STACK);
-#endif
+
                        {
                                // This is used on Coop GC for platforms where we cannot get the data for individual registers.
                                // We force a spill of all registers into the stack and pass a chunk of data into sgen.
index 1c45e375af5dffb372cc6b0338189ecee7e96d82..1f87eb137f329b42144817e3f483c7b3ab74df89 100644 (file)
@@ -78,11 +78,7 @@ sgen_suspend_thread (SgenThreadInfo *info)
        if (stack_start >= info->client_info.stack_start_limit && stack_start <= info->client_info.stack_end) {
                info->client_info.stack_start = stack_start;
 
-#ifdef USE_MONO_CTX
                mono_sigctx_to_monoctx (&ctx, &info->client_info.ctx);
-#else
-               ARCH_COPY_SIGCTX_REGS (&info->client_info.regs, &ctx);
-#endif
        } else {
                g_assert (!info->client_info.stack_start);
        }
index dc9d29ff1395ad81be62b1a63edde30f691135dc..5a9bae85b6db35d7c95d81b19ad82a6c2e921a65 100644 (file)
@@ -42,9 +42,6 @@ static void
 suspend_thread (SgenThreadInfo *info, void *context)
 {
        int stop_count;
-#ifndef USE_MONO_CTX
-       gpointer regs [ARCH_NUM_REGS];
-#endif
        MonoContext ctx;
        gpointer stack_start;
 
@@ -55,7 +52,6 @@ suspend_thread (SgenThreadInfo *info, void *context)
        if (0 && info->client_info.stop_count == stop_count)
                return;
 
-#ifdef USE_MONO_CTX
        if (context) {
                mono_sigctx_to_monoctx (context, &ctx);
                info->client_info.stopped_ip = MONO_CONTEXT_GET_IP (&ctx);
@@ -64,30 +60,17 @@ suspend_thread (SgenThreadInfo *info, void *context)
                info->client_info.stopped_ip = NULL;
                stack_start = NULL;
        }
-#else
-       info->client_info.stopped_ip = context ? (gpointer) ARCH_SIGCTX_IP (context) : NULL;
-       stack_start = context ? (char*) ARCH_SIGCTX_SP (context) - REDZONE_SIZE : NULL;
-#endif
 
        /* If stack_start is not within the limits, then don't set it
           in info and we will be restarted. */
        if (stack_start >= info->client_info.stack_start_limit && stack_start <= info->client_info.stack_end) {
                info->client_info.stack_start = stack_start;
 
-#ifdef USE_MONO_CTX
                if (context) {
                        memcpy (&info->client_info.ctx, &ctx, sizeof (MonoContext));
                } else {
                        memset (&info->client_info.ctx, 0, sizeof (MonoContext));
                }
-#else
-               if (context) {
-                       ARCH_COPY_SIGCTX_REGS (regs, context);
-                       memcpy (&info->client_info.regs, regs, sizeof (info->client_info.regs));
-               } else {
-                       memset (&info->client_info.regs, 0, sizeof (info->client_info.regs));
-               }
-#endif
        } else {
                g_assert (!info->client_info.stack_start);
        }
index 3e78396ccd10f536f2bd73be7b41f01c69b76435..8b78616129a9da8ed7a593fab28349e1143bd791 100644 (file)
@@ -58,7 +58,6 @@ sgen_suspend_thread (SgenThreadInfo *info)
        CloseHandle (handle);
 
 #if !defined(MONO_CROSS_COMPILE)
-#ifdef USE_MONO_CTX
        memset (&info->client_info.ctx, 0, sizeof (MonoContext));
 #ifdef TARGET_AMD64
     info->client_info.ctx.gregs[AMD64_RIP] = context.Rip;
@@ -92,19 +91,6 @@ sgen_suspend_thread (SgenThreadInfo *info)
        info->client_info.stopped_ip = (gpointer)context.Eip;
        info->client_info.stack_start = (char*)context.Esp - REDZONE_SIZE;
 #endif
-
-#else
-       info->client_info.regs [0] = context.Edi;
-       info->client_info.regs [1] = context.Esi;
-       info->client_info.regs [2] = context.Ebx;
-       info->client_info.regs [3] = context.Edx;
-       info->client_info.regs [4] = context.Ecx;
-       info->client_info.regs [5] = context.Eax;
-       info->client_info.regs [6] = context.Ebp;
-       info->client_info.regs [7] = context.Esp;
-       info->client_info.stopped_ip = (gpointer)context.Eip;
-       info->client_info.stack_start = (char*)context.Esp - REDZONE_SIZE;
-#endif
 #endif
 
        /* Notify the JIT */
index 4185ce07b8ad67d96965485b9516dcf02fb70a59..501a9f41b85acd08790d8f74784299f7bf3ea01d 100644 (file)
@@ -43,34 +43,20 @@ align_pointer (void *ptr)
        return (void*)p;
 }
 
-#ifdef USE_MONO_CTX
 static MonoContext cur_thread_ctx;
-#else
-static mword cur_thread_regs [ARCH_NUM_REGS];
-#endif
 
 static void
 update_current_thread_stack (void *start)
 {
        int stack_guard = 0;
-#if !defined(USE_MONO_CTX)
-       void *reg_ptr = cur_thread_regs;
-#endif
        SgenThreadInfo *info = mono_thread_info_current ();
        
        info->client_info.stack_start = align_pointer (&stack_guard);
        g_assert (info->client_info.stack_start >= info->client_info.stack_start_limit && info->client_info.stack_start < info->client_info.stack_end);
-#ifdef USE_MONO_CTX
        MONO_CONTEXT_GET_CURRENT (cur_thread_ctx);
        memcpy (&info->client_info.ctx, &cur_thread_ctx, sizeof (MonoContext));
        if (mono_gc_get_gc_callbacks ()->thread_suspend_func)
                mono_gc_get_gc_callbacks ()->thread_suspend_func (info->client_info.runtime_data, NULL, &info->client_info.ctx);
-#else
-       ARCH_STORE_REGS (reg_ptr);
-       memcpy (&info->client_info.regs, reg_ptr, sizeof (info->client_info.regs));
-       if (mono_gc_get_gc_callbacks ()->thread_suspend_func)
-               mono_gc_get_gc_callbacks ()->thread_suspend_func (info->client_info.runtime_data, NULL, NULL);
-#endif
 }
 
 static gboolean
@@ -251,11 +237,7 @@ sgen_client_restart_world (int generation, GGTimingInfo *timing)
 
        FOREACH_THREAD (info) {
                info->client_info.stack_start = NULL;
-#ifdef USE_MONO_CTX
                memset (&info->client_info.ctx, 0, sizeof (MonoContext));
-#else
-               memset (&info->client_info.regs, 0, sizeof (info->client_info.regs));
-#endif
        } FOREACH_THREAD_END
 
        TV_GETTIME (start_handshake);
@@ -363,11 +345,7 @@ update_sgen_info (SgenThreadInfo *info)
                g_error ("BAD STACK");
 
        info->client_info.stack_start = stack_start;
-#ifdef USE_MONO_CTX
        info->client_info.ctx = mono_thread_info_get_suspend_state (info)->ctx;
-#else
-       g_assert_not_reached ();
-#endif
 }
 
 static void
index 6151395688005d2ba455d7684bfec5f3bdb67d8c..69ade32e593ef5fc5db50665d5924f1069595dcb 100644 (file)
@@ -140,10 +140,10 @@ typedef struct {
        MonoCoopMutex worker_creation_lock;
 
        gint32 heuristic_completions;
-       guint32 heuristic_sample_start;
-       guint32 heuristic_last_dequeue; // ms
-       guint32 heuristic_last_adjustment; // ms
-       guint32 heuristic_adjustment_interval; // ms
+       gint64 heuristic_sample_start;
+       gint64 heuristic_last_dequeue; // ms
+       gint64 heuristic_last_adjustment; // ms
+       gint64 heuristic_adjustment_interval; // ms
        ThreadPoolHillClimbing heuristic_hill_climbing;
        MonoCoopMutex heuristic_lock;
 
@@ -855,7 +855,7 @@ monitor_should_keep_running (void)
 static gboolean
 monitor_sufficient_delay_since_last_dequeue (void)
 {
-       guint32 threshold;
+       gint64 threshold;
 
        g_assert (threadpool);
 
@@ -893,7 +893,7 @@ monitor_thread (void)
                mono_gc_set_skip_thread (TRUE);
 
                do {
-                       guint32 ts;
+                       gint64 ts;
                        gboolean alerted = FALSE;
 
                        if (mono_runtime_is_shutting_down ())
@@ -1052,7 +1052,7 @@ hill_climbing_get_wave_component (gdouble *samples, guint sample_count, gdouble
 }
 
 static gint16
-hill_climbing_update (gint16 current_thread_count, guint32 sample_duration, gint32 completions, guint32 *adjustment_interval)
+hill_climbing_update (gint16 current_thread_count, guint32 sample_duration, gint32 completions, gint64 *adjustment_interval)
 {
        ThreadPoolHillClimbing *hc;
        ThreadPoolHeuristicStateTransition transition;
@@ -1292,8 +1292,8 @@ heuristic_adjust (void)
 
        if (mono_coop_mutex_trylock (&threadpool->heuristic_lock) == 0) {
                gint32 completions = InterlockedExchange (&threadpool->heuristic_completions, 0);
-               guint32 sample_end = mono_msec_ticks ();
-               guint32 sample_duration = sample_end - threadpool->heuristic_sample_start;
+               gint64 sample_end = mono_msec_ticks ();
+               gint64 sample_duration = sample_end - threadpool->heuristic_sample_start;
 
                if (sample_duration >= threadpool->heuristic_adjustment_interval / 2) {
                        ThreadPoolCounter counter;
@@ -1418,7 +1418,7 @@ gboolean
 mono_threadpool_ms_remove_domain_jobs (MonoDomain *domain, int timeout)
 {
        gboolean res = TRUE;
-       guint32 start;
+       gint64 end;
        gpointer sem;
 
        g_assert (domain);
@@ -1427,13 +1427,12 @@ mono_threadpool_ms_remove_domain_jobs (MonoDomain *domain, int timeout)
        g_assert (mono_domain_is_unloading (domain));
 
        if (timeout != -1)
-               start = mono_msec_ticks ();
+               end = mono_msec_ticks () + timeout;
 
 #ifndef DISABLE_SOCKETS
        mono_threadpool_ms_io_remove_domain_jobs (domain);
        if (timeout != -1) {
-               timeout -= mono_msec_ticks () - start;
-               if (timeout < 0)
+               if (mono_msec_ticks () > end)
                        return FALSE;
        }
 #endif
@@ -1452,16 +1451,19 @@ mono_threadpool_ms_remove_domain_jobs (MonoDomain *domain, int timeout)
        mono_memory_write_barrier ();
 
        while (domain->threadpool_jobs) {
-               MONO_PREPARE_BLOCKING;
-               WaitForSingleObject (sem, timeout);
-               MONO_FINISH_BLOCKING;
+               gint64 now;
+
                if (timeout != -1) {
-                       timeout -= mono_msec_ticks () - start;
-                       if (timeout <= 0) {
+                       now = mono_msec_ticks ();
+                       if (now > end) {
                                res = FALSE;
                                break;
                        }
                }
+
+               MONO_PREPARE_BLOCKING;
+               WaitForSingleObject (sem, timeout != -1 ? end - now : timeout);
+               MONO_FINISH_BLOCKING;
        }
 
        domain->cleanup_semaphore = NULL;
index 2f7fcabf081a4d25662147a77241d59472c17981..6dbba62b347d948ad99129603748dc6e967ee124 100644 (file)
@@ -3790,7 +3790,7 @@ mono_threads_abort_appdomain_threads (MonoDomain *domain, int timeout)
 #endif
 
        abort_appdomain_data user_data;
-       guint32 start_time;
+       gint64 start_time;
        int orig_timeout = timeout;
        int i;
 
index 5b05e57c90e39af906a32a24d9f876a0e900d337..8c4d16aa4f27b4a3fb88d33e64e4e858d048365e 100644 (file)
@@ -1120,8 +1120,8 @@ socket_transport_recv (void *buf, int len)
        int total = 0;
        int fd = conn_fd;
        int flags = 0;
-       static gint32 last_keepalive;
-       gint32 msecs;
+       static gint64 last_keepalive;
+       gint64 msecs;
 
        MONO_PREPARE_BLOCKING;
 
index a4d15fa4849100f30054a6e2324dc540937f0aa9..16ea7ed29acfe1cda29106d24564eae2d9d92e31 100644 (file)
@@ -1506,6 +1506,7 @@ mono_handle_exception_internal_first_pass (MonoContext *ctx, MonoObject *obj, gi
                                        if (is_user_frame)
                                                setup_stack_trace (mono_ex, dynamic_methods, initial_trace_ips, &trace_ips);
 
+#ifndef MONO_CROSS_COMPILE
 #ifdef MONO_CONTEXT_SET_LLVM_EXC_REG
                                        if (ji->from_llvm)
                                                MONO_CONTEXT_SET_LLVM_EXC_REG (ctx, ex_obj);
@@ -1517,6 +1518,7 @@ mono_handle_exception_internal_first_pass (MonoContext *ctx, MonoObject *obj, gi
                                        /* store the exception object in bp + ei->exvar_offset */
                                        *((gpointer *)(gpointer)((char *)MONO_CONTEXT_GET_BP (ctx) + ei->exvar_offset)) = ex_obj;
 #endif
+#endif
 
 #ifdef MONO_CONTEXT_SET_LLVM_EH_SELECTOR_REG
                                        /*
@@ -1821,12 +1823,14 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
                                        ex_obj = obj;
 
                                if (((ei->flags == MONO_EXCEPTION_CLAUSE_NONE) || (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER))) {
+#ifndef MONO_CROSS_COMPILE
 #ifdef MONO_CONTEXT_SET_LLVM_EXC_REG
                                        MONO_CONTEXT_SET_LLVM_EXC_REG (ctx, ex_obj);
 #else
                                        g_assert (!ji->from_llvm);
                                        /* store the exception object in bp + ei->exvar_offset */
                                        *((gpointer *)(gpointer)((char *)MONO_CONTEXT_GET_BP (ctx) + ei->exvar_offset)) = ex_obj;
+#endif
 #endif
                                }
 
index 6ae3d2556e90c46cd2cba6631b4c60cb4814d5f1..75b2348e53ce678f12ce2b4a443dd017e880dc8c 100644 (file)
@@ -5,7 +5,6 @@ Z_LIBS=
 endif
 
 AM_CPPFLAGS = \
-       -fexceptions -DMONO_USE_EXC_TABLES      \
        -DSUPPRESSION_DIR=\""$(datadir)/mono-$(API_VER)/mono/profiler"\"        \
        -I$(top_srcdir)         \
        $(GLIB_CFLAGS)
@@ -15,77 +14,73 @@ if !DISABLE_LIBRARIES
 if !DISABLE_PROFILER
 bin_PROGRAMS = mprof-report
 
+if !BITCODE
+prof_shlibs = \
+       libmono-profiler-aot.la \
+       libmono-profiler-iomap.la \
+       libmono-profiler-log.la
+endif
+
 if HAVE_VTUNE
-vtune_lib = libmono-profiler-vtune.la
+vtune_stlibs = libmono-profiler-vtune-static.la
+if !BITCODE
+vtune_shlibs = libmono-profiler-vtune.la
+endif
 endif
 
-lib_LTLIBRARIES = libmono-profiler-aot.la libmono-profiler-iomap.la libmono-profiler-log.la libmono-profiler-log-static.la $(vtune_lib)
+lib_LTLIBRARIES = \
+       $(prof_shlibs) \
+       libmono-profiler-aot-static.la \
+       libmono-profiler-iomap-static.la \
+       libmono-profiler-log-static.la \
+       $(vtune_shlibs) \
+       $(vtune_stlibs)
 
 if PLATFORM_DARWIN
-if BITCODE
-libmono_profiler_log_la_LDFLAGS = -no-undefined
-else
-libmono_profiler_log_la_LDFLAGS = -Wl,-undefined -Wl,suppress -Wl,-flat_namespace
-endif
-endif
-if PLATFORM_ANDROID
-libmono_profiler_log_la_LDFLAGS = -avoid-version
-endif
-endif
-endif
+prof_ldflags = -Wl,-undefined -Wl,suppress -Wl,-flat_namespace
 endif
 
-if HAVE_OPROFILE
-# Do something that uses OPROFILE_CFLAGS and OPROFILE_LIBS
+if PLATFORM_ANDROID
+prof_ldflags = -avoid-version
 endif
 
-if SUPPORT_BOEHM
-if DISABLE_EXECUTABLES
-LIBMONO=$(top_builddir)/mono/mini/$(LIBMONO_LA)
-else
-if !SHARED_MONO
-static_libs=   \
-       $(top_builddir)/mono/metadata/libmonoruntime-static.la  \
-       $(top_builddir)/mono/io-layer/libwapi.la        \
-       $(top_builddir)/mono/utils/libmonoutils.la \
-       $(GLIB_LIBS) $(LIBICONV) \
-       $(LIBGC_STATIC_LIBS)
-
-LIBMONO=$(top_builddir)/mono/mini/$(LIBMONO_LA) $(static_libs)
-else
-LIBMONO=$(top_builddir)/mono/mini/$(LIBMONO_LA)
 endif
 endif
-else
-LIBMONO=$(top_builddir)/mono/mini/libmonosgen-$(API_VER).la
 endif
 
+# The log profiler uses eglib functions, so it needs to be linked against
+# libeglib in shared mode, but not in static mode, since that would
+# leads to duplicate symbols when it is linked into an app which
+# also uses eglib (e.g. the runtime). Automake doesn't support this
+# functionality, so create a separate static version of the library.
+
 libmono_profiler_aot_la_SOURCES = mono-profiler-aot.c
 libmono_profiler_aot_la_LIBADD = $(GLIB_LIBS) $(LIBICONV)
-if BITCODE
-libmono_profiler_aot_la_LDFLAGS = -no-undefined
-endif
+libmono_profiler_aot_la_LDFLAGS = $(prof_ldflags)
+libmono_profiler_aot_static_la_SOURCES = mono-profiler-aot.c
+libmono_profiler_aot_static_la_LDFLAGS = -static
+
 libmono_profiler_iomap_la_SOURCES = mono-profiler-iomap.c
 libmono_profiler_iomap_la_LIBADD = $(GLIB_LIBS) $(LIBICONV)
-if BITCODE
-libmono_profiler_iomap_la_LDFLAGS = -no-undefined
-endif
+libmono_profiler_iomap_la_LDFLAGS = $(prof_ldflags)
+libmono_profiler_iomap_static_la_SOURCES = mono-profiler-iomap.c
+libmono_profiler_iomap_static_la_LDFLAGS = -static
+
 libmono_profiler_log_la_SOURCES = proflog.c
 libmono_profiler_log_la_LIBADD = $(GLIB_LIBS) $(Z_LIBS)
+libmono_profiler_log_la_LDFLAGS = $(prof_ldflags)
+libmono_profiler_log_static_la_SOURCES = proflog.c
+libmono_profiler_log_static_la_LDFLAGS = -static
+
 if HAVE_VTUNE
 libmono_profiler_vtune_la_SOURCES = mono-profiler-vtune.c
 libmono_profiler_vtune_la_CFLAGS = $(VTUNE_CFLAGS)
 libmono_profiler_vtune_la_LIBADD = $(VTUNE_LIBS) $(GLIB_LIBS) $(LIBICONV)
+libmono_profiler_vtune_la_LDFLAGS = $(prof_ldflags)
+libmono_profiler_vtune_static_la_SOURCES = mono-profiler-vtune.c
+libmono_profiler_vtune_static_la_LDFLAGS = -static
 endif
 
-# The log profile uses eglib functions, so it needs to be linked against
-# libeglib in shared mode, but not in static mode, since that would
-# leads to duplicate symbols when it is linked into an app which
-# also uses eglib (e.g. the runtime). Automake doesn't support this
-# functionality, so create a separate static version of the library.
-libmono_profiler_log_static_la_SOURCES = proflog.c
-libmono_profiler_log_static_la_LDFLAGS = -static
-
 mprof_report_SOURCES = decode.c
 mprof_report_LDADD = $(Z_LIBS) $(GLIB_LIBS) $(LIBICONV)
 
index c72ed326b00afbb28d565e48b113352bed1965d1..da6aaf01823c56265c44967c7e78504ec1165670 100644 (file)
 
 #include <mono/utils/mono-context.h>
 
-/*
- * Define either USE_MONO_CTX, or
- * ARCH_SIGCTX_SP/ARCH_SIGCTX_IP/ARCH_STORE_REGS/ARCH_COPY_SIGCTX_REGS.
- * Define ARCH_NUM_REGS to be the number of general registers in MonoContext, or the
- * number of registers stored by ARCH_STORE_REGS.
- */
-
 #if defined(MONO_CROSS_COMPILE)
 
 #define REDZONE_SIZE   0
 
-#define ARCH_NUM_REGS 0
-#define ARCH_STORE_REGS(ptr)
-#define ARCH_SIGCTX_SP(ctx) NULL
-#define ARCH_SIGCTX_IP(ctx) NULL
-#define ARCH_COPY_SIGCTX_REGS(a,ctx)
-
 #elif defined(TARGET_X86)
 
 #define REDZONE_SIZE   0
 
-#define ARCH_NUM_REGS 8
-
 #ifndef MONO_ARCH_HAS_MONO_CONTEXT
 #error 0
 #endif
 
-#define USE_MONO_CTX
-
 #elif defined(TARGET_AMD64)
 
 #define REDZONE_SIZE   128
 
-#define ARCH_NUM_REGS 16
-#define USE_MONO_CTX
-
 #elif defined(TARGET_POWERPC)
 
 #define REDZONE_SIZE   224
 
-#define ARCH_NUM_REGS 32
-#ifdef __APPLE__
-#define ARCH_STORE_REGS(ptr)   \
-       __asm__ __volatile__(   \
-               "stmw r0, 0(%0)\n"      \
-               :                       \
-               : "b" (ptr)             \
-       )
-#else
-#define ARCH_STORE_REGS(ptr)   \
-       __asm__ __volatile__(   \
-               "stmw 0, 0(%0)\n"       \
-               :                       \
-               : "b" (ptr)             \
-       )
-#endif
-#define ARCH_SIGCTX_SP(ctx)    (UCONTEXT_REG_Rn((ctx), 1))
-#define ARCH_SIGCTX_IP(ctx)    (UCONTEXT_REG_NIP((ctx)))
-#define ARCH_COPY_SIGCTX_REGS(a,ctx) do {      \
-       int __i;        \
-       for (__i = 0; __i < 32; ++__i)  \
-               ((a)[__i]) = (gpointer) UCONTEXT_REG_Rn((ctx), __i);    \
-       } while (0)
-
 /* MS_BLOCK_SIZE must be a multiple of the system pagesize, which for some
    architectures is 64k.  */
 #if defined(TARGET_POWERPC) || defined(TARGET_POWERPC64)
 #elif defined(TARGET_ARM)
 
 #define REDZONE_SIZE   0
-#define USE_MONO_CTX
-
-/* We dont store ip, sp */
-#define ARCH_NUM_REGS 14
 
 #elif defined(TARGET_ARM64)
 
 #else
 #error "Not implemented."
 #endif
-#define USE_MONO_CTX
-#define ARCH_NUM_REGS 31
 
 #elif defined(__mips__)
 
 #define REDZONE_SIZE   0
 
-#define USE_MONO_CTX
-#define ARCH_NUM_REGS 32
-
 #elif defined(__s390x__)
 
 #define REDZONE_SIZE   0
 
-#define USE_MONO_CTX
-#define ARCH_NUM_REGS 16       
-
 #elif defined(__sparc__)
 
 #define REDZONE_SIZE   0
 
-/* Don't bother with %g0 (%r0), it's always hard-coded to zero */
-#define ARCH_NUM_REGS 15       
-#ifdef __sparcv9
-#define ARCH_STORE_REGS(ptr)   \
-       __asm__ __volatile__(   \
-               "st %%g1,[%0]\n\t"      \
-               "st %%g2,[%0+0x08]\n\t" \
-               "st %%g3,[%0+0x10]\n\t" \
-               "st %%g4,[%0+0x18]\n\t" \
-               "st %%g5,[%0+0x20]\n\t" \
-               "st %%g6,[%0+0x28]\n\t" \
-               "st %%g7,[%0+0x30]\n\t" \
-               "st %%o0,[%0+0x38]\n\t" \
-               "st %%o1,[%0+0x40]\n\t" \
-               "st %%o2,[%0+0x48]\n\t" \
-               "st %%o3,[%0+0x50]\n\t" \
-               "st %%o4,[%0+0x58]\n\t" \
-               "st %%o5,[%0+0x60]\n\t" \
-               "st %%o6,[%0+0x68]\n\t" \
-               "st %%o7,[%0+0x70]\n\t" \
-               :                       \
-               : "r" (ptr)             \
-               : "memory"                      \
-       )
-#else
-#define ARCH_STORE_REGS(ptr)   \
-       __asm__ __volatile__(   \
-               "st %%g1,[%0]\n\t"      \
-               "st %%g2,[%0+0x04]\n\t" \
-               "st %%g3,[%0+0x08]\n\t" \
-               "st %%g4,[%0+0x0c]\n\t" \
-               "st %%g5,[%0+0x10]\n\t" \
-               "st %%g6,[%0+0x14]\n\t" \
-               "st %%g7,[%0+0x18]\n\t" \
-               "st %%o0,[%0+0x1c]\n\t" \
-               "st %%o1,[%0+0x20]\n\t" \
-               "st %%o2,[%0+0x24]\n\t" \
-               "st %%o3,[%0+0x28]\n\t" \
-               "st %%o4,[%0+0x2c]\n\t" \
-               "st %%o5,[%0+0x30]\n\t" \
-               "st %%o6,[%0+0x34]\n\t" \
-               "st %%o7,[%0+0x38]\n\t" \
-               :                       \
-               : "r" (ptr)             \
-               : "memory"                      \
-       )
-#endif
-
-#ifndef REG_SP
-#define REG_SP REG_O6
-#endif
-
-#define ARCH_SIGCTX_SP(ctx)    (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_SP])
-#define ARCH_SIGCTX_IP(ctx)    (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_PC])
-#define ARCH_COPY_SIGCTX_REGS(a,ctx) do {      \
-       (a)[0] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_G1]);        \
-       (a)[1] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_G2]);        \
-       (a)[2] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_G3]);        \
-       (a)[3] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_G4]);        \
-       (a)[4] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_G5]);        \
-       (a)[5] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_G6]);        \
-       (a)[6] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_G7]);        \
-       (a)[7] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_O0]);        \
-       (a)[8] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_O1]);        \
-       (a)[9] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_O2]);        \
-       (a)[10] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_O3]);       \
-       (a)[11] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_O4]);       \
-       (a)[12] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_O5]);       \
-       (a)[13] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_O6]);       \
-       (a)[14] = (gpointer) (((ucontext_t *)(ctx))->uc_mcontext.gregs [REG_O7]);       \
-       } while (0)
-
 #endif
 
 #endif /* __MONO_SGENARCHDEP_H__ */
index 28e77a77e87d53c9a3145a586f0545f3b049c639..1d3c897bd726f4277fc1c7a04d1590aea4acb066 100644 (file)
@@ -493,10 +493,10 @@ static void
 find_pinning_ref_from_thread (char *obj, size_t size)
 {
 #ifndef SGEN_WITHOUT_MONO
-       int j;
        char *endobj = obj + size;
 
        FOREACH_THREAD (info) {
+               mword *ctxstart, *ctxcurrent, *ctxend;
                char **start = (char**)info->client_info.stack_start;
                if (info->client_info.skip || info->client_info.gc_disabled)
                        continue;
@@ -506,15 +506,11 @@ find_pinning_ref_from_thread (char *obj, size_t size)
                        start++;
                }
 
-               for (j = 0; j < ARCH_NUM_REGS; ++j) {
-#ifdef USE_MONO_CTX
-                       mword w = ((mword*)&info->client_info.ctx) [j];
-#else
-                       mword w = (mword)&info->client_info.regs [j];
-#endif
+               for (ctxstart = ctxcurrent = (mword*) &info->client_info.ctx, ctxend = (mword*) (&info->client_info.ctx + 1); ctxcurrent < ctxend; ctxcurrent ++) {
+                       mword w = *ctxcurrent;
 
                        if (w >= (mword)obj && w < (mword)obj + size)
-                               SGEN_LOG (0, "Object %p referenced in saved reg %d of thread %p (id %p)", obj, j, info, (gpointer)mono_thread_info_get_tid (info));
+                               SGEN_LOG (0, "Object %p referenced in saved reg %d of thread %p (id %p)", obj, (int) (ctxcurrent - ctxstart), info, (gpointer)mono_thread_info_get_tid (info));
                }
        } FOREACH_THREAD_END
 #endif
index 374171cf6747b828f5e85b5e649cc07fd08a6a8e..e0741ccf5db775be7ab9c2ad3c68e61b4efb9e5a 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef __MONO_MONO_CONTEXT_H__
 #define __MONO_MONO_CONTEXT_H__
 
+#include <glib.h>
+
 #include "mono-compiler.h"
 #include "mono-sigcontext.h"
 #include "mono-machine.h"
  * MONO_CONTEXT_GET_CURRENT captures the current context as close as possible. One reg might be clobbered
  *  to hold the address of the target MonoContext. It will be a caller save one, so should not be a problem.
  */
-#if (defined(__i386__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_X86))
+#if defined(MONO_CROSS_COMPILE)
+
+typedef struct {} MonoContext;
+
+#define MONO_CONTEXT_SET_IP(ctx,ip) g_assert_not_reached ()
+#define MONO_CONTEXT_SET_BP(ctx,bp) g_assert_not_reached ()
+#define MONO_CONTEXT_SET_SP(ctx,sp) g_assert_not_reached ()
+
+#define MONO_CONTEXT_GET_IP(ctx) NULL
+#define MONO_CONTEXT_GET_BP(ctx) NULL
+#define MONO_CONTEXT_GET_SP(ctx) NULL
+
+#define MONO_CONTEXT_GET_CURRENT(ctx) do {} while (0)
+
+#elif defined(__i386__) || defined(TARGET_X86)
 
 /*HACK, move this to an eventual mono-signal.c*/
 #if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \
@@ -146,7 +162,7 @@ typedef struct {
 
 #define MONO_ARCH_HAS_MONO_CONTEXT 1
 
-#elif (defined(__x86_64__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_AMD64)) /* defined(__i386__) */
+#elif defined(__x86_64__) || defined(TARGET_AMD64) /* defined(__i386__) */
 
 #include <mono/arch/amd64/amd64-codegen.h>
 
@@ -230,7 +246,7 @@ extern void mono_context_get_current (void *);
 
 #define MONO_ARCH_HAS_MONO_CONTEXT 1
 
-#elif (defined(__arm__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_ARM)) /* defined(__x86_64__) */
+#elif defined(__arm__) || defined(TARGET_ARM) /* defined(__x86_64__) */
 
 #include <mono/arch/arm/arm-codegen.h>
 
@@ -284,7 +300,7 @@ typedef struct {
 
 #define MONO_ARCH_HAS_MONO_CONTEXT 1
 
-#elif (defined(__aarch64__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_ARM64))
+#elif defined(__aarch64__) || defined(TARGET_ARM64)
 
 #include <mono/arch/arm64/arm64-codegen.h>
 
@@ -453,31 +469,105 @@ typedef struct {
                : "memory"                      \
        )
 
-#define MONO_ARCH_HAS_MONO_CONTEXT 1
-
-#else 
+#else /* !defined(__mono_ppc64__) */
 
 typedef struct {
-       gulong sc_ir;          // pc 
-       gulong sc_sp;          // r1
-       mgreg_t regs [19]; /*FIXME, this must be changed to 32 for sgen*/
-       double fregs [18];
+       mgreg_t sc_ir;          // pc
+       mgreg_t sc_sp;          // r1
+       mgreg_t regs [32];
+       double fregs [32];
 } MonoContext;
 
 /* we have the stack pointer, not the base pointer in sigcontext */
-#define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->sc_ir = (gulong)ip; } while (0);
+#define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->sc_ir = (mgreg_t)ip; } while (0);
 /* FIXME: should be called SET_SP */
-#define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->sc_sp = (gulong)bp; } while (0);
-#define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->sc_sp = (gulong)sp; } while (0);
+#define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->sc_sp = (mgreg_t)bp; } while (0);
+#define MONO_CONTEXT_SET_SP(ctx,sp) do { (ctx)->sc_sp = (mgreg_t)sp; } while (0);
 
 #define MONO_CONTEXT_GET_IP(ctx) ((gpointer)((ctx)->sc_ir))
 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->regs [ppc_r31-13]))
 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->sc_sp))
+
+#define MONO_CONTEXT_GET_CURRENT(ctx)  \
+       __asm__ __volatile__(   \
+               "std 0, 0(%0)\n"        \
+               "std 1, 4(%0)\n"        \
+               "std 0, 4*0+8(%0)\n"    \
+               "std 1, 4*1+8(%0)\n"    \
+               "std 2, 4*2+8(%0)\n"    \
+               "std 3, 4*3+8(%0)\n"    \
+               "std 4, 4*4+8(%0)\n"    \
+               "std 5, 4*5+8(%0)\n"    \
+               "std 6, 4*6+8(%0)\n"    \
+               "std 7, 4*7+8(%0)\n"    \
+               "std 8, 4*8+8(%0)\n"    \
+               "std 9, 4*9+8(%0)\n"    \
+               "std 10, 4*10+8(%0)\n"  \
+               "std 11, 4*11+8(%0)\n"  \
+               "std 12, 4*12+8(%0)\n"  \
+               "std 13, 4*13+8(%0)\n"  \
+               "std 14, 4*14+8(%0)\n"  \
+               "std 15, 4*15+8(%0)\n"  \
+               "std 16, 4*16+8(%0)\n"  \
+               "std 17, 4*17+8(%0)\n"  \
+               "std 18, 4*18+8(%0)\n"  \
+               "std 19, 4*19+8(%0)\n"  \
+               "std 20, 4*20+8(%0)\n"  \
+               "std 21, 4*21+8(%0)\n"  \
+               "std 22, 4*22+8(%0)\n"  \
+               "std 23, 4*23+8(%0)\n"  \
+               "std 24, 4*24+8(%0)\n"  \
+               "std 25, 4*25+8(%0)\n"  \
+               "std 26, 4*26+8(%0)\n"  \
+               "std 27, 4*27+8(%0)\n"  \
+               "std 28, 4*28+8(%0)\n"  \
+               "std 29, 4*29+8(%0)\n"  \
+               "std 30, 4*30+8(%0)\n"  \
+               "std 31, 4*31+8(%0)\n"  \
+               "stfd 0, 8*0+4*32+8(%0)\n"      \
+               "stfd 1, 8*1+4*32+8(%0)\n"      \
+               "stfd 2, 8*2+4*32+8(%0)\n"      \
+               "stfd 3, 8*3+4*32+8(%0)\n"      \
+               "stfd 4, 8*4+4*32+8(%0)\n"      \
+               "stfd 5, 8*5+4*32+8(%0)\n"      \
+               "stfd 6, 8*6+4*32+8(%0)\n"      \
+               "stfd 7, 8*7+4*32+8(%0)\n"      \
+               "stfd 8, 8*8+4*32+8(%0)\n"      \
+               "stfd 9, 8*9+4*32+8(%0)\n"      \
+               "stfd 10, 8*10+4*32+8(%0)\n"    \
+               "stfd 11, 8*11+4*32+8(%0)\n"    \
+               "stfd 12, 8*12+4*32+8(%0)\n"    \
+               "stfd 13, 8*13+4*32+8(%0)\n"    \
+               "stfd 14, 8*14+4*32+8(%0)\n"    \
+               "stfd 15, 8*15+4*32+8(%0)\n"    \
+               "stfd 16, 8*16+4*32+8(%0)\n"    \
+               "stfd 17, 8*17+4*32+8(%0)\n"    \
+               "stfd 18, 8*18+4*32+8(%0)\n"    \
+               "stfd 19, 8*19+4*32+8(%0)\n"    \
+               "stfd 20, 8*20+4*32+8(%0)\n"    \
+               "stfd 21, 8*21+4*32+8(%0)\n"    \
+               "stfd 22, 8*22+4*32+8(%0)\n"    \
+               "stfd 23, 8*23+4*32+8(%0)\n"    \
+               "stfd 24, 8*24+4*32+8(%0)\n"    \
+               "stfd 25, 8*25+4*32+8(%0)\n"    \
+               "stfd 26, 8*26+4*32+8(%0)\n"    \
+               "stfd 27, 8*27+4*32+8(%0)\n"    \
+               "stfd 28, 8*28+4*32+8(%0)\n"    \
+               "stfd 29, 8*29+4*32+8(%0)\n"    \
+               "stfd 30, 8*30+4*32+8(%0)\n"    \
+               "stfd 31, 8*31+4*32+8(%0)\n"    \
+               : : "r" (&(ctx))        \
+               : "memory"                      \
+       )
+
 #endif
 
+#define MONO_ARCH_HAS_MONO_CONTEXT 1
+
 #elif defined(__sparc__) || defined(sparc) /* defined(__mono_ppc__) */
 
 typedef struct MonoContext {
+       mgreg_t regs [15];
        guint8 *ip;
        gpointer *sp;
        gpointer *fp;
@@ -491,6 +581,54 @@ typedef struct MonoContext {
 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->fp))
 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->sp))
 
+#ifdef __sparcv9
+#define MONO_CONTEXT_GET_CURRENT(ctx)  \
+       __asm__ __volatile__(   \
+               "st %%g1,[%0]\n"        \
+               "st %%g2,[%0+0x08]\n"   \
+               "st %%g3,[%0+0x10]\n"   \
+               "st %%g4,[%0+0x18]\n"   \
+               "st %%g5,[%0+0x20]\n"   \
+               "st %%g6,[%0+0x28]\n"   \
+               "st %%g7,[%0+0x30]\n"   \
+               "st %%o0,[%0+0x38]\n"   \
+               "st %%o1,[%0+0x40]\n"   \
+               "st %%o2,[%0+0x48]\n"   \
+               "st %%o3,[%0+0x50]\n"   \
+               "st %%o4,[%0+0x58]\n"   \
+               "st %%o5,[%0+0x60]\n"   \
+               "st %%o6,[%0+0x68]\n"   \
+               "st %%o7,[%0+0x70]\n"   \
+               :                       \
+               : "r" (&(ctx))          \
+               : "memory"                      \
+       )
+#else
+#define MONO_CONTEXT_GET_CURRENT(ctx)  \
+       __asm__ __volatile__(   \
+               "st %%g1,[%0]\n"        \
+               "st %%g2,[%0+0x04]\n"   \
+               "st %%g3,[%0+0x08]\n"   \
+               "st %%g4,[%0+0x0c]\n"   \
+               "st %%g5,[%0+0x10]\n"   \
+               "st %%g6,[%0+0x14]\n"   \
+               "st %%g7,[%0+0x18]\n"   \
+               "st %%o0,[%0+0x1c]\n"   \
+               "st %%o1,[%0+0x20]\n"   \
+               "st %%o2,[%0+0x24]\n"   \
+               "st %%o3,[%0+0x28]\n"   \
+               "st %%o4,[%0+0x2c]\n"   \
+               "st %%o5,[%0+0x30]\n"   \
+               "st %%o6,[%0+0x34]\n"   \
+               "st %%o7,[%0+0x38]\n"   \
+               :                       \
+               : "r" (&(ctx))          \
+               : "memory"                      \
+       )
+#endif
+
+#define MONO_ARCH_HAS_MONO_CONTEXT 1
+
 #elif defined(__ia64__) /*defined(__sparc__) || defined(sparc) */
 
 #ifndef UNW_LOCAL_ONLY
@@ -573,7 +711,7 @@ mono_ia64_context_get_fp (MonoContext *ctx)
        return fp;
 }
 
-#elif ((defined(__mips__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_MIPS))) && SIZEOF_REGISTER == 4 /* defined(__ia64__) */
+#elif (defined(__mips__) || defined(TARGET_MIPS)) && SIZEOF_REGISTER == 4 /* defined(__ia64__) */
 
 #include <mono/arch/mips/mips-codegen.h>
 
index 7a4a02e39a3f7fea5ca4a441251215d75d406bf8..efd732d6d56b7592b9de709a4d34c352e42baf8f 100644 (file)
@@ -325,7 +325,7 @@ mono_process_get_times (gpointer pid, gint64 *start_time, gint64 *user_time, gin
                if (*start_time == 0) {
                        static guint64 boot_time = 0;
                        if (!boot_time)
-                               boot_time = mono_100ns_datetime () - ((guint64)mono_msec_ticks ()) * 10000;
+                               boot_time = mono_100ns_datetime () - mono_msec_boottime () * 10000;
 
                        *start_time = boot_time + mono_process_get_data (pid, MONO_PROCESS_ELAPSED);
                }
index 5f0168ebb7475b94886d44a002331d2aa1184842..5cc82fccb55e082f6ecd6b198f1321eed06eda95 100644 (file)
 #include <utils/mono-time.h>
 
 
-#define MTICKS_PER_SEC 10000000
+#define MTICKS_PER_SEC (10 * 1000 * 1000)
+
+gint64
+mono_msec_ticks (void)
+{
+       return mono_100ns_ticks () / 10 / 1000;
+}
 
 #ifdef HOST_WIN32
 #include <windows.h>
 
-guint32
-mono_msec_ticks (void)
+#ifndef _MSC_VER
+/* we get "error: implicit declaration of function 'GetTickCount64'" */
+WINBASEAPI ULONGLONG WINAPI GetTickCount64(void);
+#endif
+
+gint64
+mono_msec_boottime (void)
 {
        /* GetTickCount () is reportedly monotonic */
-       return GetTickCount ();
+       return GetTickCount64 ();
 }
 
 /* Returns the number of 100ns ticks from unspecified time: this should be monotonic */
@@ -102,7 +113,7 @@ get_boot_time (void)
        if (uptime) {
                double upt;
                if (fscanf (uptime, "%lf", &upt) == 1) {
-                       gint64 now = mono_100ns_ticks ();
+                       gint64 now = mono_100ns_datetime ();
                        fclose (uptime);
                        return now - (gint64)(upt * MTICKS_PER_SEC);
                }
@@ -114,14 +125,14 @@ get_boot_time (void)
 }
 
 /* Returns the number of milliseconds from boot time: this should be monotonic */
-guint32
-mono_msec_ticks (void)
+gint64
+mono_msec_boottime (void)
 {
        static gint64 boot_time = 0;
        gint64 now;
        if (!boot_time)
                boot_time = get_boot_time ();
-       now = mono_100ns_ticks ();
+       now = mono_100ns_datetime ();
        /*printf ("now: %llu (boot: %llu) ticks: %llu\n", (gint64)now, (gint64)boot_time, (gint64)(now - boot_time));*/
        return (now - boot_time)/10000;
 }
index 95bda8e530979b740b5b7fa06a99b300031e7ede..438b9ef18815b1bdc0ee574c715638654f25f44f 100644 (file)
@@ -8,14 +8,19 @@
 #include <sys/time.h>
 #endif
 
-/* Returns the number of milliseconds from boot time: this should be monotonic */
-guint32 mono_msec_ticks      (void);
+/* Returns the number of milliseconds from boot time: this should be monotonic
+ *
+ * Prefer to use mono_msec_ticks for elapsed time calculation. */
+gint64 mono_msec_boottime (void);
+
+/* Returns the number of milliseconds ticks from unspecified time: this should be monotonic */
+gint64 mono_msec_ticks (void);
 
 /* Returns the number of 100ns ticks from unspecified time: this should be monotonic */
-gint64  mono_100ns_ticks     (void);
+gint64 mono_100ns_ticks (void);
 
 /* Returns the number of 100ns ticks since 1/1/1601, UTC timezone */
-gint64  mono_100ns_datetime  (void);
+gint64 mono_100ns_datetime (void);
 
 #ifndef HOST_WIN32
 gint64 mono_100ns_datetime_from_timeval (struct timeval tv);
index 2a49fea8b19401abb058883d9ad6fe8b3a2b6d86..a6daf8b05286c8b10b8dabe416649fee9906b609 100644 (file)
 /* No GC support. */
 /* #undef HAVE_NULL_GC */
 
-/* Have oprofile support */
-/* #undef HAVE_OPROFILE */
-
 /* Define to 1 if you have the `poll' function. */
 /* #undef HAVE_POLL */