Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@@ -34,9 +34,16 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Permissions;
[assembly: AssemblyVersion (Consts.FxVersion)]
#if MONO_POSIX_NETSTANDARD_BUILD
[assembly: AssemblyVersion ("1.0.0.0")]
[assembly: AssemblyTitle("Mono.Posix.NETStandard.dll")]
#else
[assembly: AssemblyVersion (Consts.FxVersion)]
[assembly: AssemblyTitle("Mono.Posix.dll")]
#endif
[assembly: AssemblyDescription("Unix Integration Classes")]
[assembly: CLSCompliant (true)]
@@ -48,9 +55,11 @@ using System.Security.Permissions;
*/
#if !MONO_POSIX_NETSTANDARD_BUILD
// We are using ../Open.snk for MONO_POSIX_NETSTANDARD_BUILD
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile ("../mono.pub")]
#endif
/*
* TODO:
*

View File

@@ -309,6 +309,7 @@ namespace Mono.Unix.Native {
public delegate void SignalHandler (int signal);
#if !NETSTANDARD2_0
internal class XPrintfFunctions
{
internal delegate object XPrintf (object[] parameters);
@@ -335,6 +336,7 @@ namespace Mono.Unix.Native {
syslog = new XPrintf (_syslog.Invoke);
}
}
#endif
//
// Convention: Functions that are part of the C standard library go here.
@@ -378,7 +380,11 @@ namespace Mono.Unix.Native {
//
public class Stdlib
{
#if FORCE_USE_LIBC_NOT_MSVC
internal const string LIBC = "c";
#else
internal const string LIBC = "msvcrt";
#endif
internal const string MPH = "MonoPosixHelper";
// It is possible for Mono.Posix and MonoPosixHelper to get out of sync,
@@ -771,6 +777,7 @@ namespace Mono.Unix.Native {
return sys_fprintf (stream, "%s", message);
}
#if !NETSTANDARD2_0
[Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
"Use fprintf (IntPtr, string) instead.")]
public static int fprintf (IntPtr stream, string format, params object[] parameters)
@@ -781,6 +788,7 @@ namespace Mono.Unix.Native {
Array.Copy (parameters, 0, _parameters, 2, parameters.Length);
return (int) XPrintfFunctions.fprintf (_parameters);
}
#endif
/* SKIP: fscanf(3) */
@@ -793,6 +801,7 @@ namespace Mono.Unix.Native {
return sys_printf ("%s", message);
}
#if !NETSTANDARD2_0
[Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
"Use printf (string) instead.")]
public static int printf (string format, params object[] parameters)
@@ -802,6 +811,7 @@ namespace Mono.Unix.Native {
Array.Copy (parameters, 0, _parameters, 1, parameters.Length);
return (int) XPrintfFunctions.printf (_parameters);
}
#endif
/* SKIP: scanf(3) */
@@ -823,6 +833,7 @@ namespace Mono.Unix.Native {
return sys_snprintf (s, (ulong) s.Capacity, "%s", message);
}
#if !NETSTANDARD2_0
[CLSCompliant (false)]
[Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
"Use snprintf (StringBuilder, string) instead.")]
@@ -853,6 +864,7 @@ namespace Mono.Unix.Native {
Array.Copy (parameters, 0, _parameters, 3, parameters.Length);
return (int) XPrintfFunctions.snprintf (_parameters);
}
#endif
/*
* SKIP:

View File

@@ -1 +1 @@
4ae330d5b46f74420f5ed35603c04f4f6cae15fc
c750e5fa86b353b625f01b0f5d1227c6a43c4dc4

View File

@@ -300,17 +300,35 @@ public class UnixEncoding : Encoding
throw new ArgumentOutOfRangeException ("byteIndex", _("ArgRange_Array"));
}
unsafe {
fixed (char* p = s) {
fixed (byte* b = bytes) {
return GetBytes (p + charIndex, charCount, b + byteIndex, bytes.Length - byteIndex);
}
}
}
}
public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
{
if (bytes == null || chars == null)
throw new ArgumentNullException (bytes == null ? "bytes" : "chars");
if (charCount < 0 || byteCount < 0)
throw new ArgumentOutOfRangeException (charCount < 0 ? "charCount" : "byteCount");
// Convert the characters into bytes.
char ch;
int length = bytes.Length;
int length = byteCount;
uint pair;
int posn = byteIndex;
int posn = 0;
int charIndex = 0;
while (charCount > 0) {
// Fetch the next UTF-16 character pair value.
ch = s[charIndex++];
ch = chars [charIndex++];
if (ch >= '\uD800' && ch <= '\uDBFF' && charCount > 1) {
// This may be the start of a surrogate pair.
pair = (uint)(s[charIndex]);
pair = (uint)(chars[charIndex]);
if (pair >= (uint)0xDC00 && pair <= (uint)0xDFFF) {
pair = (pair - (uint)0xDC00) +
((((uint)ch) - (uint)0xD800) << 10) +
@@ -326,7 +344,7 @@ public class UnixEncoding : Encoding
}
charCount -= 2;
if (charCount >= 0) {
bytes[posn++] = (byte) s [charIndex++];
bytes[posn++] = (byte)chars [charIndex++];
}
continue;
} else {
@@ -365,7 +383,7 @@ public class UnixEncoding : Encoding
}
// Return the final count to the caller.
return posn - byteIndex;
return posn;
}
// Internal version of "GetCharCount" which can handle a rolling
@@ -394,7 +412,7 @@ public class UnixEncoding : Encoding
uint leftSoFar = (leftOverCount & (uint)0x0F);
uint leftSize = ((leftOverCount >> 4) & (uint)0x0F);
while (count > 0) {
ch = (uint)(bytes[index++]);
ch = (uint)(bytes [index++]);
++next_raw;
--count;
if (leftSize == 0) {

View File

@@ -325,27 +325,42 @@ namespace Mono.Unix {
if (encoding == null)
throw new ArgumentNullException ("encoding");
int min_byte_count = encoding.GetMaxByteCount(1);
char[] copy = s.ToCharArray (index, count);
byte[] marshal = new byte [encoding.GetByteCount (copy) + min_byte_count];
if (index < 0 || count < 0)
throw new ArgumentOutOfRangeException ((index < 0 ? "index" : "count"),
"Non - negative number required.");
int bytes_copied = encoding.GetBytes (copy, 0, copy.Length, marshal, 0);
if (s.Length - index < count)
throw new ArgumentOutOfRangeException ("s", "Index and count must refer to a location within the string.");
if (bytes_copied != (marshal.Length-min_byte_count))
throw new NotSupportedException ("encoding.GetBytes() doesn't equal encoding.GetByteCount()!");
int null_terminator_count = encoding.GetMaxByteCount (1);
int length_without_null = encoding.GetByteCount (s);
int marshalLength = checked (length_without_null + null_terminator_count);
IntPtr mem = AllocHeap (marshal.Length);
IntPtr mem = AllocHeap (marshalLength);
if (mem == IntPtr.Zero)
throw new UnixIOException (Native.Errno.ENOMEM);
bool copied = false;
try {
Marshal.Copy (marshal, 0, mem, marshal.Length);
copied = true;
}
finally {
if (!copied)
FreeHeap (mem);
unsafe {
fixed (char* p = s) {
byte* marshal = (byte*)mem;
int bytes_copied;
try {
bytes_copied = encoding.GetBytes (p + index, count, marshal, marshalLength);
} catch {
FreeHeap (mem);
throw;
}
if (bytes_copied != length_without_null) {
FreeHeap (mem);
throw new NotSupportedException ("encoding.GetBytes() doesn't equal encoding.GetByteCount()!");
}
marshal += length_without_null;
for (int i = 0; i < null_terminator_count; ++i)
marshal[i] = 0;
}
}
return mem;

View File

@@ -23,21 +23,25 @@ namespace MonoTests.Mono.Unix.Native {
public class RealTimeSignumTest
{
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void TestRealTimeOutOfRange ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts = new RealTimeSignum (int.MaxValue);
Assert.Throws<ArgumentOutOfRangeException> (() => {
RealTimeSignum rts = new RealTimeSignum (int.MaxValue);
});
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void TestRealTimeSignumNegativeOffset ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts1 = new RealTimeSignum (-1);
Assert.Throws<ArgumentOutOfRangeException> (() => {
RealTimeSignum rts1 = new RealTimeSignum (-1);
});
}
[Test]

View File

@@ -56,7 +56,7 @@ namespace MonoTests.Mono.Unix.Native {
Assert.IsFalse (NativeConvert.ToSignum (st.signalReceived) == Signum.SIGURG,
"#IH: Signal Handler invoked when it should have been removed!");
}
#if !NETCOREAPP2_0
[Test]
// MSVCRT.DLL doesn't export snprintf(3).
[Category ("NotDotNet")]
@@ -92,6 +92,7 @@ namespace MonoTests.Mono.Unix.Native {
Assert.AreEqual (s.ToString(), expected,
"#SNPF: printf of many builtin types failed");
}
#endif
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -136,14 +136,16 @@ namespace MonoTests.Mono.Unix {
}
[Test]
[ExpectedException]
[Category ("NotOnMac")]
public void TestSignumPropertyThrows ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
UnixSignal signal1 = new UnixSignal (new RealTimeSignum (0));
Signum s = signal1.Signum;
Assert.Throws<InvalidOperationException> (() => {
UnixSignal signal1 = new UnixSignal (new RealTimeSignum (0));
Signum s = signal1.Signum;
});
}
[Test]
@@ -158,14 +160,16 @@ namespace MonoTests.Mono.Unix {
}
[Test]
[ExpectedException]
[Category ("NotOnMac")]
public void TestRealTimePropertyThrows ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
UnixSignal signal1 = new UnixSignal (Signum.SIGSEGV);
RealTimeSignum s = signal1.RealTimeSignum;
return;
Assert.Throws<InvalidOperationException> (() => {
UnixSignal signal1 = new UnixSignal (Signum.SIGSEGV);
RealTimeSignum s = signal1.RealTimeSignum;
});
}
[Test]