namespace System {
internal static class Platform {
+ static bool checkedOS;
+ static bool isMacOS;
+ static bool isFreeBSD;
+
#if MONOTOUCH || XAMMAC
- public static bool IsMacOS {
- get { return true; }
+ private static void CheckOS() {
+ isMacOS = true;
+ checkedOS = true;
}
#else
[DllImport ("libc")]
static extern int uname (IntPtr buf);
-
- static bool checkedIsMacOS;
- static bool isMacOS;
-
- public static bool IsMacOS {
- get {
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- return false;
- if (!checkedIsMacOS) {
- IntPtr buf = Marshal.AllocHGlobal (8192);
- if (uname (buf) == 0) {
- string os = Marshal.PtrToStringAnsi (buf);
- if (os == "Darwin")
- isMacOS = true;
- }
- Marshal.FreeHGlobal (buf);
- checkedIsMacOS = true;
+ private static void CheckOS() {
+ if (Environment.OSVersion.Platform != PlatformID.Unix) {
+ checkedOS = true;
+ return;
+ }
+
+ IntPtr buf = Marshal.AllocHGlobal (8192);
+ if (uname (buf) == 0) {
+ string os = Marshal.PtrToStringAnsi (buf);
+ switch (os) {
+ case "Darwin":
+ isMacOS = true;
+ break;
+ case "FreeBSD":
+ isFreeBSD = true;
+ break;
}
-
- return isMacOS;
}
+ Marshal.FreeHGlobal (buf);
+ checkedOS = true;
}
#endif
+
+ public static bool IsMacOS {
+ get {
+ if (!checkedOS)
+ CheckOS();
+ return isMacOS;
+ }
+ }
+
+ public static bool IsFreeBSD {
+ get {
+ if (!checkedOS)
+ CheckOS();
+ return isFreeBSD;
+ }
+ }
}
}
#ifndef DISABLE_SOCKETS
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
#define __APPLE_USE_RFC_3542
#endif
#define AI_ADDRCONFIG 0
#endif
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
/*
* We remove this until we have a Darwin implementation
* that can walk the result of struct ifconf. The current
#endif /* AF_INET6 */
#endif
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__FreeBSD__)
#if defined(HAVE_GETIFADDRS) && defined(HAVE_IF_NAMETOINDEX)
static int
}
#endif
-#endif /* __APPLE__ */
+#endif /* defined(__APPLE__) || defined(__FreeBSD__) */
void ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal(SOCKET sock, gint32 level, gint32 name, MonoObject *obj_val, MonoArray *byte_val, gint32 int_val, gint32 *error)
{
field=mono_class_get_field_from_name(obj_val->vtable->klass, "ifIndex");
mreq6.ipv6mr_interface =*(guint64 *)(((char *)obj_val)+field->offset);
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__FreeBSD__)
/*
* Bug #5504:
*