Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit bb55909

Browse files
committed
Merge pull request #2031 from janhenke/freebsd-system.console
Add FreeBSD support to System.Console.
2 parents a764229 + 91979b7 commit bb55909

File tree

5 files changed

+134
-0
lines changed

5 files changed

+134
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
internal static partial class Interop
5+
{
6+
/// <summary>Common Unix errno error codes.</summary>
7+
internal static partial class Errors
8+
{
9+
// These values were defined in:
10+
// include/errno.h
11+
12+
internal const int EDEADLK = 11;
13+
14+
internal const int EAGAIN = 35;
15+
internal const int EWOULDBLOCK = EAGAIN;
16+
internal const int EINPROGRESS = 36;
17+
internal const int EALREADY = 37;
18+
internal const int ENOTSOCK = 38;
19+
internal const int EDESTADDRREQ = 39;
20+
internal const int EMSGSIZE = 40;
21+
internal const int EPROTOTYPE = 41;
22+
internal const int ENOPROTOOPT = 42;
23+
internal const int EPROTONOSUPPORT = 43;
24+
internal const int ESOCKTNOSUPPORT = 44;
25+
internal const int EOPNOTSUPP = 45;
26+
internal const int ENOTSUP = EOPNOTSUPP;
27+
internal const int EPFNOSUPPORT = 46;
28+
internal const int EAFNOSUPPORT = 47;
29+
internal const int EADDRINUSE = 48;
30+
internal const int EADDRNOTAVAIL = 49;
31+
internal const int ENETDOWN = 50;
32+
internal const int ENETUNREACH = 51;
33+
internal const int ENETRESET = 52;
34+
internal const int ECONNABORTED = 53;
35+
internal const int ECONNRESET = 54;
36+
internal const int ENOBUFS = 55;
37+
internal const int EISCONN = 56;
38+
internal const int ENOTCONN = 57;
39+
internal const int ESHUTDOWN = 58;
40+
internal const int ETOOMANYREFS = 59;
41+
internal const int ETIMEDOUT = 60;
42+
internal const int ECONNREFUSED = 61;
43+
internal const int ELOOP = 62;
44+
internal const int ENAMETOOLONG = 63;
45+
internal const int EHOSTDOWN = 64;
46+
internal const int EHOSTUNREACH = 65;
47+
internal const int ENOTEMPTY = 66;
48+
internal const int EPROCLIM = 67;
49+
internal const int EUSERS = 68;
50+
internal const int EDQUOT = 69;
51+
internal const int ESTALE = 70;
52+
internal const int EREMOTE = 71;
53+
internal const int EBADRPC = 72;
54+
internal const int ERPCMISMATCH = 73;
55+
internal const int EPROGUNAVAIL = 74;
56+
internal const int EPROGMISMATCH = 75;
57+
internal const int EPROCUNAVAIL = 76;
58+
internal const int ENOLCK = 77;
59+
internal const int ENOSYS = 78;
60+
internal const int EFTYPE = 79;
61+
internal const int EAUTH = 80;
62+
internal const int ENEEDAUTH = 81;
63+
internal const int EIDRM = 82;
64+
internal const int ENOMSG = 83;
65+
internal const int EOVERFLOW = 84;
66+
internal const int ECANCELED = 85;
67+
internal const int EILSEQ = 86;
68+
internal const int ENOATTR = 87;
69+
internal const int EDOOFUS = 88;
70+
internal const int EBADMSG = 89;
71+
internal const int EMULTIHOP = 90;
72+
internal const int ENOLINK = 91;
73+
internal const int EPROTO = 92;
74+
internal const int ENOTCAPABLE = 93;
75+
internal const int ECAPMODE = 94;
76+
internal const int ENOTRECOVERABLE = 95;
77+
internal const int EOWNERDEAD = 96;
78+
internal const int ELAST = 96;
79+
}
80+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
internal static partial class Interop
5+
{
6+
private static partial class Libraries
7+
{
8+
internal const string LibRt = "librt"; // POSIX Realtime Extensions library
9+
}
10+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
6+
internal static partial class Interop
7+
{
8+
internal static partial class libc
9+
{
10+
[Flags]
11+
internal enum OpenFlags
12+
{
13+
O_RDONLY = 0x0000,
14+
O_WRONLY = 0x0001,
15+
O_RDWR = 0x0002,
16+
O_CREAT = 0x0200,
17+
O_TRUNC = 0x0400,
18+
O_EXCL = 0x0800,
19+
O_SYNC = 0x0080,
20+
O_ASYNC = 0x0040,
21+
O_CLOEXEC = 0x00100000,
22+
}
23+
}
24+
}

src/System.Console/System.Console.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Console.Tests", "tes
1515
EndProject
1616
Global
1717
GlobalSection(SolutionConfigurationPlatforms) = preSolution
18+
FreeBSD_Debug|Any CPU = FreeBSD_Debug|Any CPU
19+
FreeBSD_Release|Any CPU = FreeBSD_Release|Any CPU
1820
Linux_Debug|Any CPU = Linux_Debug|Any CPU
1921
Linux_Release|Any CPU = Linux_Release|Any CPU
2022
OSX_Debug|Any CPU = OSX_Debug|Any CPU
@@ -23,6 +25,10 @@ Global
2325
Windows_Release|Any CPU = Windows_Release|Any CPU
2426
EndGlobalSection
2527
GlobalSection(ProjectConfigurationPlatforms) = postSolution
28+
{F9DF2357-81B4-4317-908E-512DA9395583}.FreeBSD_Debug|Any CPU.ActiveCfg = FreeBSD_Debug|Any CPU
29+
{F9DF2357-81B4-4317-908E-512DA9395583}.FreeBSD_Debug|Any CPU.Build.0 = FreeBSD_Debug|Any CPU
30+
{F9DF2357-81B4-4317-908E-512DA9395583}.FreeBSD_Release|Any CPU.ActiveCfg = FreeBSD_Release|Any CPU
31+
{F9DF2357-81B4-4317-908E-512DA9395583}.FreeBSD_Release|Any CPU.Build.0 = FreeBSD_Release|Any CPU
2632
{F9DF2357-81B4-4317-908E-512DA9395583}.Linux_Debug|Any CPU.ActiveCfg = Linux_Debug|Any CPU
2733
{F9DF2357-81B4-4317-908E-512DA9395583}.Linux_Debug|Any CPU.Build.0 = Linux_Debug|Any CPU
2834
{F9DF2357-81B4-4317-908E-512DA9395583}.Linux_Release|Any CPU.ActiveCfg = Linux_Release|Any CPU
@@ -35,6 +41,10 @@ Global
3541
{F9DF2357-81B4-4317-908E-512DA9395583}.Windows_Debug|Any CPU.Build.0 = Windows_Debug|Any CPU
3642
{F9DF2357-81B4-4317-908E-512DA9395583}.Windows_Release|Any CPU.ActiveCfg = Windows_Release|Any CPU
3743
{F9DF2357-81B4-4317-908E-512DA9395583}.Windows_Release|Any CPU.Build.0 = Windows_Release|Any CPU
44+
{99E5069D-241F-48A6-8F29-404B4AED72BF}.FreeBSD_Debug|Any CPU.ActiveCfg = FreeBSD_Debug|Any CPU
45+
{99E5069D-241F-48A6-8F29-404B4AED72BF}.FreeBSD_Debug|Any CPU.Build.0 = FreeBSD_Debug|Any CPU
46+
{99E5069D-241F-48A6-8F29-404B4AED72BF}.FreeBSD_Release|Any CPU.ActiveCfg = FreeBSD_Release|Any CPU
47+
{99E5069D-241F-48A6-8F29-404B4AED72BF}.FreeBSD_Release|Any CPU.Build.0 = FreeBSD_Release|Any CPU
3848
{99E5069D-241F-48A6-8F29-404B4AED72BF}.Linux_Debug|Any CPU.ActiveCfg = Linux_Debug|Any CPU
3949
{99E5069D-241F-48A6-8F29-404B4AED72BF}.Linux_Debug|Any CPU.Build.0 = Linux_Debug|Any CPU
4050
{99E5069D-241F-48A6-8F29-404B4AED72BF}.Linux_Release|Any CPU.ActiveCfg = Linux_Release|Any CPU

src/System.Console/src/System.Console.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1313
</PropertyGroup>
1414
<!-- Help VS understand available configurations -->
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'FreeBSD_Debug|AnyCPU' " />
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'FreeBSD_Release|AnyCPU' " />
1517
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Linux_Debug|AnyCPU' " />
1618
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Linux_Release|AnyCPU' " />
1719
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'OSX_Debug|AnyCPU' " />
@@ -140,6 +142,14 @@
140142
<Link>Common\Interop\Unix\Interop.SetConsoleCtrlHandler.cs"</Link>
141143
</Compile>
142144
</ItemGroup>
145+
<ItemGroup Condition=" '$(TargetsFreeBSD)' == 'true' ">
146+
<Compile Include="$(CommonPath)\Interop\FreeBSD\Interop.Errors.cs">
147+
<Link>Common\Interop\FreeBSD\Interop.Errors.cs</Link>
148+
</Compile>
149+
<Compile Include="$(CommonPath)\Interop\FreeBSD\libc\Interop.OpenFlags.cs">
150+
<Link>Common\Interop\FreeBSD\Interop.OpenFlags.cs</Link>
151+
</Compile>
152+
</ItemGroup>
143153
<ItemGroup Condition=" '$(TargetsLinux)' == 'true' ">
144154
<Compile Include="$(CommonPath)\Interop\Linux\Interop.Errors.cs">
145155
<Link>Common\Interop\Linux\Interop.Errors.cs</Link>

0 commit comments

Comments
 (0)