<!-- Sources -->
<ItemGroup>
- <Compile Include="$(BclSourcesRoot)\Internal\Console.cs" />
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\InteropServices\ComponentActivator.cs" />
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\InteropServices\IsolatedComponentLoadContext.cs" />
<Compile Include="$(BclSourcesRoot)\System\__Canon.cs" />
<Compile Include="$(BclSourcesRoot)\System\ValueType.cs" />
<Compile Include="$(BclSourcesRoot)\System\WeakReference.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\WeakReference.T.CoreCLR.cs" />
- <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetStdHandle.cs">
- <Link>Common\Interop\Windows\Kernel32\Interop.GetStdHandle.cs</Link>
- </Compile>
- <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.HandleTypes.cs">
- <Link>Common\Interop\Windows\Kernel32\Interop.HandleTypes.cs</Link>
- </Compile>
</ItemGroup>
<!-- These classes are only used for FeatureCominterop, but they are referenced by tests
in order to allow tests to be built on all platforms, these classes are included for all
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Text;
-using Microsoft.Win32.SafeHandles;
-
-namespace Internal
-{
- //
- // Simple limited console class for internal printf-style debugging in System.Private.CoreLib
- // and low-level tests that want to call System.Private.CoreLib directly
- //
-
- public static class Console
- {
- private static readonly SafeFileHandle _outputHandle =
- new SafeFileHandle(Interop.Kernel32.GetStdHandle(Interop.Kernel32.HandleTypes.STD_OUTPUT_HANDLE), ownsHandle: false);
-
- public static unsafe void Write(string s)
- {
- byte[] bytes = Encoding.UTF8.GetBytes(s);
- fixed (byte* pBytes = bytes)
- {
- Interop.Kernel32.WriteFile(_outputHandle, pBytes, bytes.Length, out _, IntPtr.Zero);
- }
- }
-
- public static void WriteLine(string? s) =>
- Write(s + Environment.NewLineConst);
-
- public static void WriteLine() =>
- Write(Environment.NewLineConst);
- }
-}
QCFuncElement("FreeEnvironmentStrings", FreeEnvironmentStringsW)
QCFuncElement("GetEnvironmentStrings", GetEnvironmentStringsW)
QCFuncElement("GetEnvironmentVariable", GetEnvironmentVariableW)
- QCFuncElement("GetStdHandle", GetStdHandle)
QCFuncElement("OpenEvent", OpenEventW)
QCFuncElement("OpenMutex", OpenMutexW)
QCFuncElement("OpenSemaphore", OpenSemaphoreW)
QCFuncElement("ResetEvent", ResetEvent)
QCFuncElement("SetEnvironmentVariable", SetEnvironmentVariableW)
QCFuncElement("SetEvent", SetEvent)
- QCFuncElement("WriteFile", WriteFile)
FCFuncEnd()
#endif
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Runtime.InteropServices;
-
-internal static partial class Interop
-{
- internal static partial class Sys
- {
- // printf takes a variable number of arguments, which is difficult to represent in C#.
- // Instead, since we only have a small and fixed number of call sites, we declare
- // an overload for each of the specific argument sets we need.
-
- [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PrintF", SetLastError = true)]
- internal static extern unsafe int PrintF(string format, string arg1);
- }
-}
project(System.Native C)
+if (NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
+ add_definitions(-DHAS_CONSOLE_SIGNALS)
+endif ()
+
set(NATIVE_SOURCES
pal_errno.c
pal_interfaceaddresses.c
pal_log.m
pal_searchpath.m)
else ()
- set(NATIVE_SOURCES ${NATIVE_SOURCES} pal_console.c)
+ set(NATIVE_SOURCES ${NATIVE_SOURCES}
+ pal_console.c
+ pal_log.c)
endif ()
if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_BROWSER)
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+#include "pal_config.h"
+#include "pal_log.h"
+
+#include <stdio.h>
+
+void SystemNative_Log(uint8_t* buffer, int32_t length)
+{
+ fwrite(buffer, 1, (size_t)length, stdout);
+ fflush(stdout);
+}
#include "pal_types.h"
PALEXPORT void SystemNative_Log(uint8_t* buffer, int32_t length);
-
-PALEXPORT int32_t SystemNative_InitializeTerminalAndSignalHandling(void);
-
-// Called by pal_signal.cpp to reinitialize the console on SIGCONT/SIGCHLD.
-void ReinitializeTerminal(void) {}
-void UninitializeTerminal(void) {}
}
[msg release];
}
-
-int32_t SystemNative_InitializeTerminalAndSignalHandling(void)
-{
- return 0;
-}
}
else if (signalCode == SIGCONT)
{
+#ifdef HAS_CONSOLE_SIGNALS
ReinitializeTerminal();
+#endif
}
else if (signalCode != SIGWINCH)
{
void SystemNative_RestoreAndHandleCtrl(CtrlCode ctrlCode)
{
int signalCode = ctrlCode == Break ? SIGQUIT : SIGINT;
+#ifdef HAS_CONSOLE_SIGNALS
UninitializeTerminal();
+#endif
sigaction(signalCode, OrigActionFor(signalCode), NULL);
kill(getpid(), signalCode);
}
return 1;
}
+
+#ifndef HAS_CONSOLE_SIGNALS
+
+int32_t SystemNative_InitializeTerminalAndSignalHandling()
+{
+ return 0;
+}
+
+#endif
*
*/
PALEXPORT void SystemNative_SetTerminalInvalidationHandler(TerminalInvalidationCallback callback);
+
+#ifndef HAS_CONSOLE_SIGNALS
+
+/**
+ * Initializes signal handling and terminal for use by System.Console and System.Diagnostics.Process.
+ *
+ * Returns 1 on success; otherwise returns 0 and sets errno.
+ */
+PALEXPORT int32_t SystemNative_InitializeTerminalAndSignalHandling(void);
+
+#endif
<!-- iOS/tvOS -->
<ItemGroup Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
<Compile Include="System\ConsolePal.iOS.cs" />
- <Compile Include="$(CommonPath)Interop\OSX\System.Native\Interop.Log.cs"
- Link="Common\Interop\OSX\Interop.Log.cs" />
+ <Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Log.cs"
+ Link="Common\Interop\Unix\Interop.Log.cs" />
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs"
Link="Common\Interop\Unix\Interop.Libraries.cs" />
</ItemGroup>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Text;
+
+namespace Internal
+{
+ public static partial class Console
+ {
+ public static unsafe void Write(string s)
+ {
+ byte[] bytes = Encoding.UTF8.GetBytes(s);
+ fixed (byte* pBytes = bytes)
+ {
+ Interop.Sys.Log(pBytes, bytes.Length);
+ }
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Text;
+
+namespace Internal
+{
+ public static partial class Console
+ {
+ private static readonly IntPtr s_outputHandle =
+ Interop.Kernel32.GetStdHandle(Interop.Kernel32.HandleTypes.STD_OUTPUT_HANDLE);
+
+ public static unsafe void Write(string s)
+ {
+ byte[] bytes = Encoding.UTF8.GetBytes(s);
+ fixed (byte* pBytes = bytes)
+ {
+ Interop.Kernel32.WriteFile(s_outputHandle, pBytes, bytes.Length, out _, IntPtr.Zero);
+ }
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+
+namespace Internal
+{
+ //
+ // Simple limited console class for internal printf-style debugging in System.Private.CoreLib
+ // and low-level tests that want to call System.Private.CoreLib directly
+ //
+
+ public static partial class Console
+ {
+ public static void WriteLine(string? s) =>
+ Write(s + Environment.NewLineConst);
+
+ public static void WriteLine() =>
+ Write(Environment.NewLineConst);
+ }
+}
</ItemGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Internal\AssemblyAttributes.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Internal\Console.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\IO\File.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\Padding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\Runtime\CompilerServices\Unsafe.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetProcessTimes_IntPtr.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.GetProcessTimes_IntPtr.cs</Link>
</Compile>
+ <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetStdHandle.cs">
+ <Link>Common\Interop\Windows\Kernel32\Interop.GetStdHandle.cs</Link>
+ </Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetSystemDirectoryW.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.GetSystemDirectoryW.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GlobalMemoryStatusEx.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.GlobalMemoryStatusEx.cs</Link>
</Compile>
+ <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.HandleTypes.cs">
+ <Link>Common\Interop\Windows\Kernel32\Interop.HandleTypes.cs</Link>
+ </Compile>
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.IsWow64Process_IntPtr.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.IsWow64Process_IntPtr.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Windows\User32\Interop.USEROBJECTFLAGS.cs">
<Link>Common\Interop\Windows\User32\Interop.USEROBJECTFLAGS.cs</Link>
</Compile>
+ <Compile Include="$(MSBuildThisFileDirectory)Internal\Console.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\IO\File.Windows.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\Win32\RegistryKey.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeFileHandle.Windows.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs">
<Link>Common\Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs</Link>
</Compile>
+ <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WriteFile_IntPtr.cs">
+ <Link>Common\Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs</Link>
+ </Compile>
<Compile Include="$(CommonPath)System\IO\Win32Marshal.cs">
<Link>Common\System\IO\Win32Marshal.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.LockFileRegion.cs">
<Link>Common\Interop\Unix\System.Native\Interop.LockFileRegion.cs</Link>
</Compile>
+ <Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Log.cs">
+ <Link>Common\Interop\Unix\System.Native\Interop.Log.cs</Link>
+ </Compile>
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.LowLevelMonitor.cs">
<Link>Common\Interop\Unix\System.Native\Interop.LowLevelMonitor.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Write.cs">
<Link>Common\Interop\Unix\System.Native\Interop.Write.cs</Link>
</Compile>
+ <Compile Include="$(MSBuildThisFileDirectory)Internal\Console.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\IO\File.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\AppDomain.Unix.cs" />
<!-- Sources -->
<ItemGroup>
- <Compile Include="$(BclSourcesRoot)\Mono\Console.Mono.cs" />
<Compile Include="$(BclSourcesRoot)\Mono\MonoListItem.cs" />
<Compile Include="$(BclSourcesRoot)\Mono\MonoDomain.cs" />
<Compile Include="$(BclSourcesRoot)\Mono\MonoDomainSetup.cs" />
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using System.Diagnostics;
-
-namespace Internal
-{
- // Some CoreCLR tests use it for internal printf-style debugging in System.Private.CoreLib
- public static class Console
- {
- public static void Write(string? s) => DebugProvider.WriteCore(s ?? string.Empty);
-
- public static void WriteLine(string? s) => Write(s + Environment.NewLineConst);
-
- public static void WriteLine() => Write(Environment.NewLineConst);
- }
-}