Porting Mono

Though I like ArtPaint and Wonderbrush, they both lack the real simplicity of Microsoft Paint (probably the only app I actually like coming from Redmond). I have PaintBrush on Mac that is a close cousin.

There is KDE-based KolourPaint in the repos. It it exactly the same as MS Paint was before they introduced that office ribbon control =)

I have it installed actually. However, it would be great to get a more native Paint like app for Haiku.

As for the ribbon UIā€¦ I hate it :dizzy_face:

Well, Kolourpaint is a Qt application, but how do you actually notice this while using it? Apart from the file dialog it looks exactly like a native Haiku application to me.

I think even when Mono is ported the UI components wonā€™t be. Paint.net needs Win32 controls and the Win32 API to be implemented as well as Mono.

1 Like

That is rather impossible, so one would probably go for QtSharp or something similar. Paint.NET is out of question, so letā€™s hope CLR will be running at leastā€¦ Calvin doesnā€™t quite get any help on GitHub with that issue, so first letā€™s see if itā€™s feasible to do at all =)

Or maybe the support .mono from Godot engine 3.0, it can use it.

An old version of Paint.NET is possible (before they closed sourced it, let alone added more native Windows stuff) once Mono is ported, and then work on getting libgdiplus/Mono.Windows.Forms outputting onto app_server can be done for the UI. Work for sure, but quite doable.

I havenā€™t used Godot, but once Mono works, itā€™d probably work there I guess.

Iā€™m still stumped, but I havenā€™t done any debugging in a while. Iā€™d like for someone smarter than me to give it a shot thoughā€¦

1 Like

As a little motivation: /r/OpenBSD_Gaming has games written for XNA (that were ported to Linux via FNA/MonoGame) running on OpenBSD, unmodified, just with minor library tweaks - including games like Bastion, Owlboy, Rogue Legacy, and Stardew Valley. If we get Mono running, then we can just get FNA/MonoGame working and have a bunch of hot indie games people play, working fine on Haiku.

3 Likes

i think in the gamer develop it is very very needed.

Still working on it, and I still would really like help debugging this runtime termination issue. I really donā€™t know if Iā€™m hitting a Mono bug or a possible Haiku bug.

If you care to join me working against master, apply this patch (iā€™ll submit a PR for it) to the corefx submodule, and configure with --with-sigaltstack=no:

diff --git a/src/Native/Unix/System.Native/pal_errno.c b/src/Native/Unix/System.Native/pal_errno.c
index 996d777da0..793d09747a 100644
--- a/src/Native/Unix/System.Native/pal_errno.c
+++ b/src/Native/Unix/System.Native/pal_errno.c
@@ -178,8 +178,10 @@ int32_t SystemNative_ConvertErrorPlatformToPal(int32_t platformErrno)
             return Error_ETXTBSY;
         case EXDEV:
             return Error_EXDEV;
+#ifdef ESOCKTNOSUPPORT
         case ESOCKTNOSUPPORT:
             return Error_ESOCKTNOSUPPORT;
+#endif
         case EPFNOSUPPORT:
             return Error_EPFNOSUPPORT;
         case ESHUTDOWN:
@@ -366,8 +368,10 @@ int32_t SystemNative_ConvertErrorPalToPlatform(int32_t error)
             return EXDEV;
         case Error_EPFNOSUPPORT:
             return EPFNOSUPPORT;
+#ifdef ESOCKTNOSUPPORT:
         case Error_ESOCKTNOSUPPORT:
             return ESOCKTNOSUPPORT;
+#endif
         case Error_ESHUTDOWN:
             return ESHUTDOWN;
         case Error_EHOSTDOWN:
diff --git a/src/Native/Unix/System.Native/pal_io.c b/src/Native/Unix/System.Native/pal_io.c
index f95a18a5de..c8c65e6299 100644
--- a/src/Native/Unix/System.Native/pal_io.c
+++ b/src/Native/Unix/System.Native/pal_io.c
@@ -121,8 +121,8 @@ c_static_assert(PAL_SEEK_CUR == SEEK_CUR);
 c_static_assert(PAL_SEEK_END == SEEK_END);
 
 // Validate our PollFlags enum values are correct for the platform
-// HACK: AIX values are different; we convert them between PAL_POLL and POLL now
-#ifndef _AIX
+// HACK: AIX and Haiku values are different; we convert them between PAL_POLL and POLL now
+#if !(defined (_AIX) || defined (__HAIKU__))
 c_static_assert(PAL_POLLIN == POLLIN);
 c_static_assert(PAL_POLLPRI == POLLPRI);
 c_static_assert(PAL_POLLOUT == POLLOUT);
@@ -883,6 +883,7 @@ int32_t SystemNative_MAdvise(void* address, uint64_t length, int32_t advice)
 
 int32_t SystemNative_MLock(void* address, uint64_t length)
 {
+#if !defined (__HAIKU__)
     if (length > SIZE_MAX)
     {
         errno = ERANGE;
@@ -890,10 +891,15 @@ int32_t SystemNative_MLock(void* address, uint64_t length)
     }
 
     return mlock(address, (size_t)length);
+#else
+    errno = ENOSYS;
+    return -1;
+#endif
 }
 
 int32_t SystemNative_MUnlock(void* address, uint64_t length)
 {
+#if !defined (__HAIKU__)
     if (length > SIZE_MAX)
     {
         errno = ERANGE;
@@ -901,6 +907,10 @@ int32_t SystemNative_MUnlock(void* address, uint64_t length)
     }
 
     return munlock(address, (size_t)length);
+#else
+    errno = ENOSYS;
+    return -1;
+#endif
 }
 
 int32_t SystemNative_MProtect(void* address, uint64_t length, int32_t protection)
@@ -1442,7 +1452,7 @@ int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length,
         return -1;
     }
 
-#if HAVE_FLOCK64
+#if HAVE_FLOCK64 && !defined (__HAIKU__)
     struct flock64 lockArgs;
 #else
     struct flock lockArgs;
diff --git a/src/Native/Unix/System.Native/pal_maphardwaretype.c b/src/Native/Unix/System.Native/pal_maphardwaretype.c
index 7f8e825783..47864e45f9 100644
--- a/src/Native/Unix/System.Native/pal_maphardwaretype.c
+++ b/src/Native/Unix/System.Native/pal_maphardwaretype.c
@@ -56,27 +56,39 @@ uint16_t MapHardwareType(uint16_t nativeType)
     {
         case IFT_ETHER:
             return NetworkInterfaceType_Ethernet;
+#ifdef IFT_ISO88025
         case IFT_ISO88025:
             return NetworkInterfaceType_TokenRing;
+#endif
+#ifdef IFT_FDDI
         case IFT_FDDI:
             return NetworkInterfaceType_Fddi;
+#endif
+#ifdef IFT_ISDNBASIC
         case IFT_ISDNBASIC:
             return NetworkInterfaceType_Isdn;
+#endif
+#ifdef IFT_ISDNPRIMARY
         case IFT_ISDNPRIMARY:
             return NetworkInterfaceType_PrimaryIsdn;
+#endif
         case IFT_PPP:
             return NetworkInterfaceType_Ppp;
         case IFT_LOOP:
             return NetworkInterfaceType_Loopback;
+#ifdef IFT_XETHER
         case IFT_XETHER:
             return NetworkInterfaceType_Ethernet3Megabit;
+#endif
         case IFT_SLIP:
             return NetworkInterfaceType_Slip;
+#ifdef IFT_ATM
         case IFT_ATM:
             return NetworkInterfaceType_Atm;
+#endif
         case IFT_MODEM:
             return NetworkInterfaceType_GenericModem;
-#if defined(IFT_IEEE1394)
+#ifdef IFT_IEEE1394
         case IFT_IEEE1394:
             return NetworkInterfaceType_HighPerformanceSerialBus;
 #endif
diff --git a/src/Native/Unix/System.Native/pal_networking.c b/src/Native/Unix/System.Native/pal_networking.c
index 74864b371b..0f7fcd5706 100644
--- a/src/Native/Unix/System.Native/pal_networking.c
+++ b/src/Native/Unix/System.Native/pal_networking.c
@@ -31,6 +31,10 @@
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
+#if defined (__HAIKU__)
+#include <sys/time.h>
+#include <sys/sockio.h>
+#endif
 #include <sys/un.h>
 #if defined(__APPLE__) && __APPLE__
 #include <sys/socketvar.h>
@@ -49,6 +53,10 @@
 #if !HAVE_IN_PKTINFO
 #include <net/if.h>
 #if HAVE_GETIFADDRS
+#if defined (__HAIKU__)
+// Haiku needs this define for getifaddrs
+#define _BSD_SOURCE
+#endif
 #include <ifaddrs.h>
 #endif
 #endif
@@ -400,7 +408,7 @@ int32_t SystemNative_GetDomainName(uint8_t* name, int32_t nameLength)
 #endif
 
     return getdomainname((char*)name, namelen);
-#elif HAVE_UNAME
+#elif HAVE_UNAME && !defined (__HAIKU__)
     // On Android, there's no getdomainname but we can use uname to fetch the domain name
     // of the current device
     size_t namelen = (uint32_t)nameLength;
@@ -1852,9 +1860,11 @@ static bool TryConvertSocketTypePalToPlatform(int32_t palSocketType, int* platfo
             *platformSocketType = SOCK_RAW;
             return true;
 
+#ifdef SOCK_RDM
         case SocketType_SOCK_RDM:
             *platformSocketType = SOCK_RDM;
             return true;
+#endif
 
         case SocketType_SOCK_SEQPACKET:
             *platformSocketType = SOCK_SEQPACKET;
diff --git a/src/Native/Unix/System.Native/pal_tcpstate.c b/src/Native/Unix/System.Native/pal_tcpstate.c
index 7ea8fc1895..8fe6070708 100644
--- a/src/Native/Unix/System.Native/pal_tcpstate.c
+++ b/src/Native/Unix/System.Native/pal_tcpstate.c
@@ -11,7 +11,7 @@
 #elif HAVE_TCP_H_TCPSTATE_ENUM
 #include <netinet/tcp.h>
 #else
-#error System must have TCP states defined in either tcp.h or tcp_fsm.h.
+#warning System doesn't have TCP states defined in either tcp.h or tcp_fsm.h; falling back to always returning unknown.
 #endif
 
 int32_t SystemNative_MapTcpState(int32_t tcpState)
@@ -66,6 +66,9 @@ int32_t SystemNative_MapTcpState(int32_t tcpState)
             return TcpState_Closing;
         default:
             return TcpState_Unknown;
+#else
+        default:
+            return TcpState_Unknown;
 #endif
     }
 }
2 Likes

Hello all,

I also would be interested in Mono ported to Haiku. Mono, .NET SDK, .NET Runtimeā€¦ Mostly because I use C# to code some Games in Unity 3d. I donā€™t expect Unity 3d ported in the near future, but I already asked on GitHub about porting VSCode, which first needs Electron to be ported, which first needs Chromium and Node.js to be ported.

These ā€œfeature requestsā€ (getting VSCode and Electron versions for Haiku) were closed as no demand for such requests.

Checking the apps based on Electron, it looks appealing to get it on Haiku (Skype, GitHub Desktop, GitKraken, VSCode, Wordpress, Slackā€¦)

So, forgive me if I am too naive to ask this but, has anyone asked Microsoft/Xamarin to help in any way to get Mono ported to Haiku?

Regards,
RR

1 Like

Electron is a lot of work. Youā€™d need to port libuv, V8 and Node just to get Node working. Youā€™d then need to port the entire Chromium stack, including graphics libraries. Youā€™d then need to integrate the two together.

Libuv probably wouldnā€™t be too hard, but V8 probably would be.

@cosmogatokat, I tried the Godot Engine available in the repos, but even it starts, nothing can be done there, at least inside the Virtual Machine, rendering issues, crashesā€¦ I will try again on a Bare Metal box I am building for Haiku only. I donā€™t see Unity3d ported in the near future, but if Godot is stable enough to work on itā€™s an option, even it is a C++ instead of C# engine.

Regards,
RR

1 Like

@dwt So I found out about it these days without too much digging. Seems Haiku is stuck there, at least for the time being.
I presume the ā€œlast namesā€ here are not Bezos, Shuttleworth, neither Muskā€¦ So it is in fact a lot of work. Anyway, Iā€™ll keep asking whenever VSCode presents me another surveyā€¦ Never know.

Regards,
RR

Godot need someone who help to test and send bugs to the github, i cant in these days cause i cant install haiku and my haiku machine just die, but if you can do that it will be very helpful, it need some bugfixes to start, can be excellent to have at least the 2d games working on our haiku. :slight_smile:

Iā€™m already doing what I can with MS for getting Mono and such working under Haiku. Iā€™m still debugging it, but if youā€™re persist and apply some evil hacks, you can get it to build all the way, with a lot of issuesā€¦

3 Likes

want to use it with the Godotmono game engine.

Sounds like youā€™ll need an IDE soon with Mono compiling supportā€¦

ā€¦ Paladin will soon (next 3 months) have a plugin engine allowing other developers to add language, compiler, and error log processing pluginsā€¦

ā€¦ Just sayinā€™. :wink:

1 Like

The Ide but Godot engine is like Unity a game engine with c# support, it still have the own script language but ā€¦ you know the c# are more librarys, more popular in that aspect, but the IDE is very important too.