Merge pull request #927 from ermshiperete/novell-bug-708856
authorAlex Rønne Petersen <alex@lycus.org>
Fri, 28 Feb 2014 21:29:51 +0000 (22:29 +0100)
committerAlex Rønne Petersen <alex@lycus.org>
Fri, 28 Feb 2014 21:29:51 +0000 (22:29 +0100)
[MWF] Fix finding of X11 shared library on Ubuntu (#708856)

19 files changed:
configure.in
mcs/class/System.XML/System.Xml.Serialization/TypeData.cs
mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XElementTest.cs
mcs/class/corlib/System.Diagnostics.Contracts/ContractOptionAttribute.cs
mcs/class/corlib/System.Diagnostics.Tracing/EventCommandEventArgs.cs [new file with mode: 0644]
mcs/class/corlib/System.Diagnostics.Tracing/EventSource.cs [new file with mode: 0644]
mcs/class/corlib/System.Globalization/GregorianCalendar.cs
mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
mcs/class/corlib/System.Threading/CancellationTokenSource.cs
mcs/class/corlib/Test/System.Collections/SortedListTest.cs
mcs/class/corlib/Test/System/ArrayTest.cs
mcs/class/corlib/corlib.dll.sources
mono/metadata/class.c
mono/metadata/icall.c
mono/metadata/sgen-cardtable.c
mono/metadata/socket-io.c
mono/metadata/threads.c
mono/mini/mini-amd64.h
mono/utils/mono-proclib.c

index 787e66c15d0ddd3a40a1eed97a09025a491383e7..f6fb3b31fbad1448495e42545ff24e04b77a7b49 100644 (file)
@@ -2439,7 +2439,7 @@ if test "x$enable_llvm" = "xyes"; then
    else
       LLVM_LIBS=`$LLVM_CONFIG --libs core bitwriter jit mcjit $llvm_codegen`
    fi
-   LLVM_LIBS="$LLVM_LDFLAGS $LLVM_LIBS -lstdc++"
+   LLVM_LIBS="$LLVM_LIBS $LLVM_LDFLAGS -lstdc++"
 
    expected_llvm_version="3.4svn-mono-mono/e656cac"
 
index ade3d7abde293a7fd8c8e0160fcc082447c1b372..861fcc11de67455023df3b2fbe422a78319b02ec 100644 (file)
@@ -135,8 +135,6 @@ namespace System.Xml.Serialization
                        this.listItemTypeData = listItemTypeData;
                        this.sType = schemaType;
                        this.hasPublicConstructor = true;
-
-                       LookupTypeConvertor ();
                }
 
                void LookupTypeConvertor ()
index a9e35cb063f654799acd5b53ce07a34a38433348..999caff2c20e0ffc828fa0536a70ad128001ee0b 100644 (file)
@@ -2091,7 +2091,7 @@ namespace MonoTests.System.Xml.Linq
                        var res = serializer.Deserialize (new StringReader (xmlString));
 
                        Assert.IsNotNull (res, "#1");
-                       Assert.IsInstanceOfType (typeof (SerializableClass), res, "#2");
+                       Assert.AreEqual (typeof (SerializableClass), res.GetType (), "#2");
                        var xe = (SerializableClass)res;
                        Assert.AreEqual (xe.Content.ToString (), "<Data />", "#3");
                }
index b060838289258b31d4e6d22158339c18a84617d4..62c757e720ff81dbce3b6ef3d5092d6e72de569b 100644 (file)
@@ -28,7 +28,7 @@ namespace System.Diagnostics.Contracts {
 
        [AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
        [ConditionalAttribute("CONTRACTS_FULL")]
-       public class ContractOptionAttribute : Attribute {
+       public sealed class ContractOptionAttribute : Attribute {
                public ContractOptionAttribute (string category, string setting, bool enabled)
                {
                        Category = category;
diff --git a/mcs/class/corlib/System.Diagnostics.Tracing/EventCommandEventArgs.cs b/mcs/class/corlib/System.Diagnostics.Tracing/EventCommandEventArgs.cs
new file mode 100644 (file)
index 0000000..b64e522
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// EventCommandEventArgs.cs.cs
+//
+// Authors:
+//     Marek Safar  <marek.safar@gmail.com>
+//
+// Copyright (C) 2014 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.
+//
+
+#if NET_4_5
+
+namespace System.Diagnostics.Tracing
+{
+       public class EventCommandEventArgs : EventArgs
+       {
+               private EventCommandEventArgs ()
+               {                       
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/corlib/System.Diagnostics.Tracing/EventSource.cs b/mcs/class/corlib/System.Diagnostics.Tracing/EventSource.cs
new file mode 100644 (file)
index 0000000..aaf65a2
--- /dev/null
@@ -0,0 +1,63 @@
+//
+// EventSource.cs
+//
+// Authors:
+//     Marek Safar  <marek.safar@gmail.com>
+//
+// Copyright (C) 2014 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.
+//
+
+#if NET_4_5
+
+namespace System.Diagnostics.Tracing
+{
+       public class EventSource : IDisposable
+       {
+               protected EventSource ()
+               {
+               }
+
+               protected EventSource (bool throwOnEventWriteErrors)
+               {
+               }
+
+               public bool IsEnabled ()
+               {
+                       return false;
+               }
+
+               public void Dispose ()
+               {
+                       Dispose (true);
+               }
+
+               protected virtual void Dispose (bool disposing)
+               {                       
+               }
+
+               protected void WriteEvent (int eventId, int arg1, int arg2, int arg3)
+               {
+               }
+       }
+}
+
+#endif
index 82f8e52b113f64506d662da3ebead88bfa6828fc..1f36373367679932efc5076b69d014b62a727d08 100644 (file)
@@ -344,11 +344,13 @@ public class GregorianCalendar : Calendar {
                return 12;
        }
 
+#if !NET_4_5
        [ComVisible (false)]
        public override int GetWeekOfYear (DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
        {
                return base.GetWeekOfYear (time, rule, firstDayOfWeek);
        }
+#endif
 
        /// <summary>
        /// Overridden. Gives the number of the year of the specified
index a66a8dc7ae222b5a49ceca16ac8e6f8334b2c474..83665f71cfdb0d5a2cc3b390daffe8c53f028706 100644 (file)
@@ -747,8 +747,8 @@ namespace System.Runtime.InteropServices
                        PtrToStructure (ptr, (object)structure);
                }
 
-               public static object PtrToStructure<T> (IntPtr ptr) {
-                       return PtrToStructure (ptr, typeof (T));
+               public static T PtrToStructure<T> (IntPtr ptr) {
+                       return (T) PtrToStructure (ptr, typeof (T));
                }
 #endif
 
@@ -1354,8 +1354,8 @@ namespace System.Runtime.InteropServices
                }
 
 #if NET_4_5
-               public static Delegate GetDelegateForFunctionPointer<T> (IntPtr ptr) {
-                       return GetDelegateForFunctionPointer (ptr, typeof (T));
+               public static TDelegate GetDelegateForFunctionPointer<TDelegate> (IntPtr ptr) {
+                       return (TDelegate) (object) GetDelegateForFunctionPointer (ptr, typeof (TDelegate));
                }
 #endif
 
index c5557f0446e69b7808e73a295b08c7c244d4e469..f92eba8f58894e735bc8132eb467a561f4d6f773 100644 (file)
@@ -125,7 +125,7 @@ namespace System.Threading
                // Don't throw ObjectDisposedException if the callback
                // is called concurrently with a Dispose
                //
-               public void CancelSafe ()
+               void CancelSafe ()
                {
                        if (!disposed)
                                Cancellation (true);
index 8f5bbdf1e6af54d51e072eff58ae0447b3d4e2e2..08b6130106f909377682f626c6bede3d743062c9 100644 (file)
@@ -197,6 +197,8 @@ namespace MonoTests.System.Collections
                        list.Capacity = 0;
                }
 
+               // This doesn't fail on 64 bit systems
+               /*
                [Test]
                [ExpectedException (typeof (OutOfMemoryException))]
                public void TestCapacity4 ()
@@ -204,6 +206,7 @@ namespace MonoTests.System.Collections
                        SortedList list = new SortedList ();
                        list.Capacity = Int32.MaxValue;
                }
+               */
 
                [Test]
                public void TestCount ()
index b0aea630b10e5788e1bde8ade615309f5ac5fd95..eab4c40e1434ad47d8c4fb335497cb760a647a24 100644 (file)
@@ -3636,22 +3636,5 @@ public class ArrayTest
 
 #endif
 
-       [Test]
-       public void JaggedArrayCtor ()
-       {
-        var type = Type.GetType ("System.Object[][]");
-
-               ConstructorInfo ctor = null;
-        foreach (var c in type.GetConstructors ()) {
-                       if (c.GetParameters ().Length == 2)
-                               ctor = c;
-               }
-               Assert.IsNotNull (ctor);
-               var arr = (object[])ctor.Invoke (new object [] { 4, 10 });
-               for (int i = 0; i < 4; ++i) {
-                       Assert.IsNotNull (arr [i]);
-                       Assert.AreEqual (10, ((object[])arr [i]).Length);
-               }
-       }
 }
 }
index 3bab3edb7f8d9495a371fcf13a5b0ae8bb1ef975..53e6e76d7aed5af2219c418a26606ab3c74d75e9 100644 (file)
@@ -360,6 +360,8 @@ System.Diagnostics.Contracts/ContractShouldAssertException.cs
 System.Diagnostics.Contracts/ContractVerificationAttribute.cs
 System.Diagnostics.Contracts/PureAttribute.cs
 System.Diagnostics.Contracts.Internal/ContractHelper.cs
+System.Diagnostics.Tracing/EventSource.cs
+System.Diagnostics.Tracing/EventCommandEventArgs.cs
 System.Diagnostics.SymbolStore/ISymbolBinder.cs
 System.Diagnostics.SymbolStore/ISymbolBinder1.cs
 System.Diagnostics.SymbolStore/ISymbolDocument.cs
index 6ba180402dd95a9e459c0b020e4bfc02e3e62eb3..36a86794e77bf55a723c6e26bebff446b1fdb4ce 100644 (file)
@@ -2084,18 +2084,12 @@ mono_class_setup_methods (MonoClass *class)
                MonoMethodSignature *sig;
                int count_generic = 0, first_generic = 0;
                int method_num = 0;
-               gboolean jagged_ctor = FALSE;
 
                class->method.count = 3 + (class->rank > 1? 2: 1);
 
                mono_class_setup_interfaces (class, &error);
                g_assert (mono_error_ok (&error)); /*FIXME can this fail for array types?*/
 
-               if (class->rank == 1 && class->element_class->rank) {
-                       jagged_ctor = TRUE;
-                       class->method.count ++;
-               }
-
                if (class->interface_count) {
                        count_generic = generic_array_methods (class);
                        first_generic = class->method.count;
@@ -2124,19 +2118,6 @@ mono_class_setup_methods (MonoClass *class)
                        amethod = create_array_method (class, ".ctor", sig);
                        methods [method_num++] = amethod;
                }
-
-               if (jagged_ctor) {
-                       /* Jagged arrays have an extra ctor in .net which creates an array of arrays */
-                       sig = mono_metadata_signature_alloc (class->image, class->rank + 1);
-                       sig->ret = &mono_defaults.void_class->byval_arg;
-                       sig->pinvoke = TRUE;
-                       sig->hasthis = TRUE;
-                       for (i = 0; i < class->rank + 1; ++i)
-                               sig->params [i] = &mono_defaults.int32_class->byval_arg;
-                       amethod = create_array_method (class, ".ctor", sig);
-                       methods [method_num++] = amethod;
-               }
-
                /* element Get (idx11, [idx2, ...]) */
                sig = mono_metadata_signature_alloc (class->image, class->rank);
                sig->ret = &class->element_class->byval_arg;
index 7e1563168ed5c3c680d920271e8d3a0fd969ecf5..40cac17433a0d11355545385e113f893baaf7b44 100644 (file)
@@ -2830,18 +2830,6 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr
                for (i = 0; i < pcount; ++i)
                        lengths [i] = *(int32_t*) ((char*)mono_array_get (params, gpointer, i) + sizeof (MonoObject));
 
-               if (m->klass->rank == 1 && sig->param_count == 2 && m->klass->element_class->rank) {
-                       /* This is a ctor for jagged arrays. MS creates an array of arrays. */
-                       MonoArray *arr = mono_array_new_full (mono_object_domain (params), m->klass, lengths, NULL);
-
-                       for (i = 0; i < mono_array_length (arr); ++i) {
-                               MonoArray *subarray = mono_array_new_full (mono_object_domain (params), m->klass->element_class, &lengths [1], NULL);
-
-                               mono_array_setref_fast (arr, i, subarray);
-                       }
-                       return (MonoObject*)arr;
-               }
-
                if (m->klass->rank == pcount) {
                        /* Only lengths provided. */
                        lower_bounds = NULL;
index d41cbc66eae77bf2c1f423471ead98391798e307..a4f1871ea1ad5014e5e02ca948260b53e6d3c727 100644 (file)
@@ -315,29 +315,25 @@ sgen_card_table_update_mod_union (guint8 *dest, char *obj, mword obj_size, size_
        size_t num_cards;
 
 #ifdef SGEN_HAVE_OVERLAPPING_CARDS
-       if (end_card < start_card) {
-               guint8 *edge_card = sgen_cardtable + CARD_COUNT_IN_BYTES;
-               size_t num_cards_to_edge = edge_card - start_card;
-
-               num_cards = (end_card + CARD_COUNT_IN_BYTES) - start_card;
-               if (init) {
-                       result = dest = alloc_mod_union (num_cards);
-                       //g_print ("%d cards for %d bytes: %p\n", num_cards, num_bytes, dest);
-               }
+       size_t rest;
 
-               update_mod_union (dest, init, start_card, edge_card);
+       rest = num_cards = cards_in_range ((mword) obj, obj_size);
 
-               SGEN_ASSERT (0, num_cards == (edge_card - start_card) + (end_card - sgen_cardtable), "wrong number of cards");
+       if (init)
+               result = dest = alloc_mod_union (num_cards);
 
-               dest += num_cards_to_edge;
+       while (start_card + rest > SGEN_CARDTABLE_END) {
+               size_t count = SGEN_CARDTABLE_END - start_card;
+               update_mod_union (dest, init, start_card, SGEN_CARDTABLE_END);
+               dest += count;
+               rest -= count;
                start_card = sgen_cardtable;
-       } else
-#endif
-       {
-               num_cards = end_card - start_card;
-               if (init)
-                       result = dest = alloc_mod_union (num_cards);
        }
+#else
+       num_cards = end_card - start_card;
+       if (init)
+               result = dest = alloc_mod_union (num_cards);
+#endif
 
        update_mod_union (dest, init, start_card, end_card);
 
@@ -356,7 +352,9 @@ move_cards_to_shadow_table (mword start, mword size)
        guint8 *to = sgen_card_table_get_shadow_card_address (start);
        size_t bytes = cards_in_range (start, size);
 
-       if (to + bytes > SGEN_SHADOW_CARDTABLE_END) {
+       if (bytes >= CARD_COUNT_IN_BYTES) {
+               memcpy (sgen_shadow_cardtable, sgen_cardtable, CARD_COUNT_IN_BYTES);
+       } else if (to + bytes > SGEN_SHADOW_CARDTABLE_END) {
                size_t first_chunk = SGEN_SHADOW_CARDTABLE_END - to;
                size_t second_chunk = MIN (CARD_COUNT_IN_BYTES, bytes) - first_chunk;
 
@@ -373,7 +371,9 @@ clear_cards (mword start, mword size)
        guint8 *addr = sgen_card_table_get_card_address (start);
        size_t bytes = cards_in_range (start, size);
 
-       if (addr + bytes > SGEN_CARDTABLE_END) {
+       if (bytes >= CARD_COUNT_IN_BYTES) {
+               memset (sgen_cardtable, 0, CARD_COUNT_IN_BYTES);
+       } else if (addr + bytes > SGEN_CARDTABLE_END) {
                size_t first_chunk = SGEN_CARDTABLE_END - addr;
 
                memset (addr, 0, first_chunk);
index 145633f943585e969c37d9507460cfad1d255c52..6a27c1bf53a00714cf32af301cd98c3596dfbaf3 100644 (file)
@@ -3018,6 +3018,7 @@ MonoBoolean ves_icall_System_Net_Dns_GetHostByName_internal(MonoString *host, Mo
        hints.ai_flags = AI_CANONNAME;
 
        if (*hostname && getaddrinfo(hostname, NULL, &hints, &info) == -1) {
+               g_free (hostname);
                return(FALSE);
        }
        
@@ -3106,10 +3107,13 @@ MonoBoolean ves_icall_System_Net_Dns_GetHostByName_internal(MonoString *host, Mo
 #else
        he = _wapi_gethostbyname (hostname);
 #endif
-       g_free(hostname);
 
-       if (*hostname && he==NULL)
+       if (*hostname && he==NULL) {
+               g_free (hostname);
                return(FALSE);
+       }
+
+       g_free (hostname);
 
        return(hostent_to_IPHostEntry(he, h_name, h_aliases, h_addr_list, add_local_ips));
 }
index 0e1473c751fba8465ac398e767f56c3dfdf433ff..867a4ce8d483d7f74376c4a5fdc50bcaf33b78a2 100755 (executable)
@@ -385,10 +385,14 @@ static void thread_cleanup (MonoInternalThread *thread)
                        mono_array_set (thread->cached_culture_info, MonoObject*, i, NULL);
        }
 
+       /*
+        * thread->synch_cs can be NULL if this was called after
+        * ves_icall_System_Threading_InternalThread_Thread_free_internal.
+        * This can happen only during shutdown.
+        * The shutting_down flag is not always set, so we can't assert on it.
+        */
        if (thread->synch_cs)
                LOCK_THREAD (thread);
-       else
-               g_assert (shutting_down);
 
        thread->state |= ThreadState_Stopped;
        thread->state &= ~ThreadState_Background;
@@ -1031,15 +1035,18 @@ ves_icall_System_Threading_Thread_Thread_internal (MonoThread *this,
 }
 
 /*
- * This is called from the finalizer of the internal thread object. Since threads keep a reference to their
- * thread object while running, by the time this function is called, the thread has already exited/detached,
- * i.e. thread_cleanup () has ran.
+ * This is called from the finalizer of the internal thread object.
  */
 void
 ves_icall_System_Threading_InternalThread_Thread_free_internal (MonoInternalThread *this, HANDLE thread)
 {
        THREAD_DEBUG (g_message ("%s: Closing thread %p, handle %p", __func__, this, thread));
 
+       /*
+        * Since threads keep a reference to their thread object while running, by the time this function is called,
+        * the thread has already exited/detached, i.e. thread_cleanup () has ran. The exception is during shutdown,
+        * when thread_cleanup () can be called after this.
+        */
        if (thread)
                CloseHandle (thread);
 
index b523d9981cd5df64e67e02d64ef9bac4b83c81a6..7925949356461bab31fc0e00a52d4f52f8c1f986 100644 (file)
@@ -450,7 +450,7 @@ GSList*
 mono_amd64_get_exception_trampolines (gboolean aot) MONO_INTERNAL;
 
 int
-mono_amd64_get_tls_gs_offset (void) MONO_INTERNAL;
+mono_amd64_get_tls_gs_offset (void) MONO_LLVM_INTERNAL;
 
 typedef struct {
        guint8 *address;
index dab3a5579e2dfbbd8cac0f47179fae0a2cd3a92a..c6965b680dd88738f404a7c0e60cd6b2439f444e 100644 (file)
@@ -583,7 +583,7 @@ get_cpu_times (int cpu_id, gint64 *user, gint64 *systemt, gint64 *irq, gint64 *s
                nice_ticks = strtoull (data, &data, 10);
                system_ticks = strtoull (data, &data, 10);
                idle_ticks = strtoull (data, &data, 10);
-               strtoull (data, &data, 10); /* iowait_ticks */
+               /* iowait_ticks = strtoull (data, &data, 10); */
                irq_ticks = strtoull (data, &data, 10);
                sirq_ticks = strtoull (data, &data, 10);
                break;