diff options
Diffstat (limited to 'src/libraries/Common/tests/TestUtilities/System/Buffers/BoundedMemory.Unix.cs')
-rw-r--r-- | src/libraries/Common/tests/TestUtilities/System/Buffers/BoundedMemory.Unix.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/libraries/Common/tests/TestUtilities/System/Buffers/BoundedMemory.Unix.cs b/src/libraries/Common/tests/TestUtilities/System/Buffers/BoundedMemory.Unix.cs new file mode 100644 index 00000000000..11049e88ebf --- /dev/null +++ b/src/libraries/Common/tests/TestUtilities/System/Buffers/BoundedMemory.Unix.cs @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Buffers +{ + public static partial class BoundedMemory + { + private static UnixImplementation<T> AllocateWithoutDataPopulationUnix<T>(int elementCount, PoisonPagePlacement placement) where T : unmanaged + { + // On non-Windows platforms, we don't yet have support for changing the permissions of individual pages. + return new UnixImplementation<T>(elementCount); + } + + private sealed class UnixImplementation<T> : BoundedMemory<T> where T : unmanaged + { + private readonly T[] _buffer; + + public UnixImplementation(int elementCount) + { + _buffer = new T[elementCount]; + } + + public override bool IsReadonly => false; + + public override Memory<T> Memory => _buffer; + + public override Span<T> Span => _buffer; + + public override void Dispose() + { + // no-op + } + + public override void MakeReadonly() + { + // no-op + } + + public override void MakeWriteable() + { + // no-op + } + } + } +} |