[mdoc] Fixes an issue with member deletion.
#include <fcntl.h>])
AC_CHECK_TYPES([struct iovec], [AC_DEFINE(HAVE_STRUCT_IOVEC)], ,
[#include <sys/uio.h>])
+ AC_CHECK_TYPES([struct linger], [AC_DEFINE(HAVE_STRUCT_LINGER)], ,
+ [#include <sys/socket.h>])
AC_CHECK_TYPES([struct pollfd], [AC_DEFINE(HAVE_STRUCT_POLLFD)], ,
[#include <sys/poll.h>])
AC_CHECK_TYPES([struct stat], [AC_DEFINE(HAVE_STRUCT_STAT)], ,
-Subproject commit dab43d5cf4bf3b8b9a5b5f8cb175dee38a5fe69f
+Subproject commit d6b00edf218008ecd8cfe90bc66b9b607431428f
-Subproject commit a09accbcb9771db77a3b0370c954f643d59f4ce7
+Subproject commit 1f8800c6924dee04f4091296f85f4a4971aadd25
Restrict the compiler to use only the features available in C# 4.0
specification.
.TP
-.I "future"
+.I "experimental"
Enables unstable features from upcoming versions of the language.
.PP
Notice that this flag only restricts the language features available to
-the programmer. A version of produced assemblies can be controled using
+the programmer. A version of produced assemblies can be controlled using
.I SDK
option.
.ne
monotouch_watch_SUBDIRS = $(monotouch_SUBDIRS)
-PROFILE_SUBDIRS = $(net_4_5_SUBDIRS)
+PARALLEL_SUBDIRS = $(net_4_5_SUBDIRS)
#OVERRIDE_TARGET_ALL = yes
dist-local: dist-default
-SUBDIRS = $(net_4_5_SUBDIRS)
+#SUBDIRS = $(net_4_5_SUBDIRS)
doc-update-local:
@echo "not doing docs"
doc-update-recursive:
@echo "do not recurse the Facades folder"
+
+System System.Core System.ComponentModel.DataAnnotations System.Numerics System.Runtime.Serialization System.XML System.ComponentModel.Composition System.ServiceModel System.Xml.Linq:
+
public void invoke2 () {
}
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public void invoke3 () {
+ }
+
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public void invoke_ex () {
invoke_ex_inner ();
invoke_results.Add (res);
}
+ [Test]
+ public void InvokeNested () {
+ Event e = run_until ("invoke1");
+
+ MethodMirror m = entry_point.DeclaringType.GetMethod ("invoke2");
+ Assert.IsNotNull (m);
+ vm.SetBreakpoint (m, 0);
+
+ StackFrame frame = e.Thread.GetFrames () [0];
+ var o = frame.GetThis () as ObjectMirror;
+
+ bool failed = false;
+
+ bool finished = false;
+ object wait = new object ();
+
+ Thread t = new Thread (delegate () {
+ try {
+ o.InvokeMethod (e.Thread, m, null);
+ } catch {
+ failed = true;
+ }
+ lock (wait) {
+ finished = true;
+ Monitor.Pulse (wait);
+ }
+ });
+
+ t.Start ();
+
+ StackFrame invoke_frame = null;
+
+ e = GetNextEvent ();
+ Assert.IsInstanceOfType (typeof (BreakpointEvent), e);
+
+ // Check that nested invokes are not allowed
+ AssertThrows<VMNotSuspendedException> (delegate {
+ o.InvokeMethod (e.Thread, m, null);
+ });
+
+ vm.Resume ();
+ lock (wait) {
+ if (!finished)
+ Monitor.Wait (wait);
+ }
+ }
+
[Test]
public void GetThreads () {
vm.GetThreads ();
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<ItemGroup>\r
<Compile Include="Test\Mono.Unix.Native\RealTimeSignumTests.cs" />\r
+ <Compile Include="Test\Mono.Unix.Native\SocketTest.cs" />\r
<Compile Include="Test\Mono.Unix.Native\StdlibTest.cs" />\r
<Compile Include="Test\Mono.Unix\ReadlinkTest.cs" />\r
<Compile Include="Test\Mono.Unix\StdioFileStreamTest.cs" />\r
Mono.Unix/UnixUserTest.cs
Mono.Unix.Android/TestHelper.cs
Mono.Unix.Native/RealTimeSignumTests.cs
+Mono.Unix.Native/SocketTest.cs
Mono.Unix.Native/StdlibTest.cs
/*
- * This file was automatically generated by create-native-map from ../../class/lib/net_2_0/Mono.Posix.dll.
+ * This file was automatically generated by create-native-map from ./../../class/lib/net_4_x/Mono.Posix.dll.
*
* DO NOT MODIFY.
*/
return ToIovec (source, out destination) == 0;
}
+ [DllImport (LIB, EntryPoint="Mono_Posix_FromLinger")]
+ private static extern int FromLinger (ref Linger source, IntPtr destination);
+
+ public static bool TryCopy (ref Linger source, IntPtr destination)
+ {
+ return FromLinger (ref source, destination) == 0;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_ToLinger")]
+ private static extern int ToLinger (IntPtr source, out Linger destination);
+
+ public static bool TryCopy (IntPtr source, out Linger destination)
+ {
+ return ToLinger (source, out destination) == 0;
+ }
+
[DllImport (LIB, EntryPoint="Mono_Posix_FromLockType")]
private static extern int FromLockType (LockType value, out Int16 rval);
return rval;
}
+ [DllImport (LIB, EntryPoint="Mono_Posix_FromMessageFlags")]
+ private static extern int FromMessageFlags (MessageFlags value, out Int32 rval);
+
+ public static bool TryFromMessageFlags (MessageFlags value, out Int32 rval)
+ {
+ return FromMessageFlags (value, out rval) == 0;
+ }
+
+ public static Int32 FromMessageFlags (MessageFlags value)
+ {
+ Int32 rval;
+ if (FromMessageFlags (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_ToMessageFlags")]
+ private static extern int ToMessageFlags (Int32 value, out MessageFlags rval);
+
+ public static bool TryToMessageFlags (Int32 value, out MessageFlags rval)
+ {
+ return ToMessageFlags (value, out rval) == 0;
+ }
+
+ public static MessageFlags ToMessageFlags (Int32 value)
+ {
+ MessageFlags rval;
+ if (ToMessageFlags (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
[DllImport (LIB, EntryPoint="Mono_Posix_FromMlockallFlags")]
private static extern int FromMlockallFlags (MlockallFlags value, out Int32 rval);
return rval;
}
+ [DllImport (LIB, EntryPoint="Mono_Posix_FromShutdownOption")]
+ private static extern int FromShutdownOption (ShutdownOption value, out Int32 rval);
+
+ public static bool TryFromShutdownOption (ShutdownOption value, out Int32 rval)
+ {
+ return FromShutdownOption (value, out rval) == 0;
+ }
+
+ public static Int32 FromShutdownOption (ShutdownOption value)
+ {
+ Int32 rval;
+ if (FromShutdownOption (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_ToShutdownOption")]
+ private static extern int ToShutdownOption (Int32 value, out ShutdownOption rval);
+
+ public static bool TryToShutdownOption (Int32 value, out ShutdownOption rval)
+ {
+ return ToShutdownOption (value, out rval) == 0;
+ }
+
+ public static ShutdownOption ToShutdownOption (Int32 value)
+ {
+ ShutdownOption rval;
+ if (ToShutdownOption (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
[DllImport (LIB, EntryPoint="Mono_Posix_FromSignum")]
private static extern int FromSignum (Signum value, out Int32 rval);
return ToTimezone (source, out destination) == 0;
}
+ [DllImport (LIB, EntryPoint="Mono_Posix_FromUnixAddressFamily")]
+ private static extern int FromUnixAddressFamily (UnixAddressFamily value, out Int32 rval);
+
+ public static bool TryFromUnixAddressFamily (UnixAddressFamily value, out Int32 rval)
+ {
+ return FromUnixAddressFamily (value, out rval) == 0;
+ }
+
+ public static Int32 FromUnixAddressFamily (UnixAddressFamily value)
+ {
+ Int32 rval;
+ if (FromUnixAddressFamily (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_ToUnixAddressFamily")]
+ private static extern int ToUnixAddressFamily (Int32 value, out UnixAddressFamily rval);
+
+ public static bool TryToUnixAddressFamily (Int32 value, out UnixAddressFamily rval)
+ {
+ return ToUnixAddressFamily (value, out rval) == 0;
+ }
+
+ public static UnixAddressFamily ToUnixAddressFamily (Int32 value)
+ {
+ UnixAddressFamily rval;
+ if (ToUnixAddressFamily (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_FromUnixSocketFlags")]
+ private static extern int FromUnixSocketFlags (UnixSocketFlags value, out Int32 rval);
+
+ public static bool TryFromUnixSocketFlags (UnixSocketFlags value, out Int32 rval)
+ {
+ return FromUnixSocketFlags (value, out rval) == 0;
+ }
+
+ public static Int32 FromUnixSocketFlags (UnixSocketFlags value)
+ {
+ Int32 rval;
+ if (FromUnixSocketFlags (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_ToUnixSocketFlags")]
+ private static extern int ToUnixSocketFlags (Int32 value, out UnixSocketFlags rval);
+
+ public static bool TryToUnixSocketFlags (Int32 value, out UnixSocketFlags rval)
+ {
+ return ToUnixSocketFlags (value, out rval) == 0;
+ }
+
+ public static UnixSocketFlags ToUnixSocketFlags (Int32 value)
+ {
+ UnixSocketFlags rval;
+ if (ToUnixSocketFlags (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_FromUnixSocketOptionName")]
+ private static extern int FromUnixSocketOptionName (UnixSocketOptionName value, out Int32 rval);
+
+ public static bool TryFromUnixSocketOptionName (UnixSocketOptionName value, out Int32 rval)
+ {
+ return FromUnixSocketOptionName (value, out rval) == 0;
+ }
+
+ public static Int32 FromUnixSocketOptionName (UnixSocketOptionName value)
+ {
+ Int32 rval;
+ if (FromUnixSocketOptionName (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_ToUnixSocketOptionName")]
+ private static extern int ToUnixSocketOptionName (Int32 value, out UnixSocketOptionName rval);
+
+ public static bool TryToUnixSocketOptionName (Int32 value, out UnixSocketOptionName rval)
+ {
+ return ToUnixSocketOptionName (value, out rval) == 0;
+ }
+
+ public static UnixSocketOptionName ToUnixSocketOptionName (Int32 value)
+ {
+ UnixSocketOptionName rval;
+ if (ToUnixSocketOptionName (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_FromUnixSocketProtocol")]
+ private static extern int FromUnixSocketProtocol (UnixSocketProtocol value, out Int32 rval);
+
+ public static bool TryFromUnixSocketProtocol (UnixSocketProtocol value, out Int32 rval)
+ {
+ return FromUnixSocketProtocol (value, out rval) == 0;
+ }
+
+ public static Int32 FromUnixSocketProtocol (UnixSocketProtocol value)
+ {
+ Int32 rval;
+ if (FromUnixSocketProtocol (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_ToUnixSocketProtocol")]
+ private static extern int ToUnixSocketProtocol (Int32 value, out UnixSocketProtocol rval);
+
+ public static bool TryToUnixSocketProtocol (Int32 value, out UnixSocketProtocol rval)
+ {
+ return ToUnixSocketProtocol (value, out rval) == 0;
+ }
+
+ public static UnixSocketProtocol ToUnixSocketProtocol (Int32 value)
+ {
+ UnixSocketProtocol rval;
+ if (ToUnixSocketProtocol (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_FromUnixSocketType")]
+ private static extern int FromUnixSocketType (UnixSocketType value, out Int32 rval);
+
+ public static bool TryFromUnixSocketType (UnixSocketType value, out Int32 rval)
+ {
+ return FromUnixSocketType (value, out rval) == 0;
+ }
+
+ public static Int32 FromUnixSocketType (UnixSocketType value)
+ {
+ Int32 rval;
+ if (FromUnixSocketType (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
+ [DllImport (LIB, EntryPoint="Mono_Posix_ToUnixSocketType")]
+ private static extern int ToUnixSocketType (Int32 value, out UnixSocketType rval);
+
+ public static bool TryToUnixSocketType (Int32 value, out UnixSocketType rval)
+ {
+ return ToUnixSocketType (value, out rval) == 0;
+ }
+
+ public static UnixSocketType ToUnixSocketType (Int32 value)
+ {
+ UnixSocketType rval;
+ if (ToUnixSocketType (value, out rval) == -1)
+ ThrowArgumentException (value);
+ return rval;
+ }
+
[DllImport (LIB, EntryPoint="Mono_Posix_FromUtimbuf")]
private static extern int FromUtimbuf (ref Utimbuf source, IntPtr destination);
MREMAP_MAYMOVE = 0x1,
}
+ [Map]
+ [CLSCompliant (false)]
+ public enum UnixSocketType : int {
+ SOCK_STREAM = 1, // Byte-stream socket
+ SOCK_DGRAM = 2, // Datagram socket
+ SOCK_RAW = 3, // Raw protocol interface (linux specific)
+ SOCK_RDM = 4, // Reliably-delivered messages (linux specific)
+ SOCK_SEQPACKET = 5, // Sequenced-packet socket
+ SOCK_DCCP = 6, // Datagram Congestion Control Protocol (linux specific)
+ SOCK_PACKET = 10, // Linux specific
+ }
+
+ [Map][Flags]
+ [CLSCompliant (false)]
+ public enum UnixSocketFlags : int {
+ SOCK_CLOEXEC = 0x80000, /* Atomically set close-on-exec flag for the new descriptor(s). */
+ SOCK_NONBLOCK = 0x00800, /* Atomically mark descriptor(s) as non-blocking. */
+ }
+
+ [Map]
+ [CLSCompliant (false)]
+ public enum UnixSocketProtocol : int {
+ IPPROTO_ICMP = 1, /* Internet Control Message Protocol */
+ IPPROTO_IGMP = 2, /* Internet Group Management Protocol */
+ IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */
+ IPPROTO_TCP = 6, /* Transmission Control Protocol */
+ IPPROTO_EGP = 8, /* Exterior Gateway Protocol */
+ IPPROTO_PUP = 12, /* PUP protocol */
+ IPPROTO_UDP = 17, /* User Datagram Protocol */
+ IPPROTO_IDP = 22, /* XNS IDP protocol */
+ IPPROTO_TP = 29, /* SO Transport Protocol Class 4 */
+ IPPROTO_DCCP = 33, /* Datagram Congestion Control Protocol */
+ IPPROTO_IPV6 = 41, /* IPv6-in-IPv4 tunnelling */
+ IPPROTO_RSVP = 46, /* RSVP Protocol */
+ IPPROTO_GRE = 47, /* Cisco GRE tunnels (rfc 1701,1702) */
+ IPPROTO_ESP = 50, /* Encapsulation Security Payload protocol */
+ IPPROTO_AH = 51, /* Authentication Header protocol */
+ IPPROTO_MTP = 92, /* Multicast Transport Protocol */
+ IPPROTO_BEETPH = 94, /* IP option pseudo header for BEET */
+ IPPROTO_ENCAP = 98, /* Encapsulation Header */
+ IPPROTO_PIM = 103, /* Protocol Independent Multicast */
+ IPPROTO_COMP = 108, /* Compression Header Protocol */
+ IPPROTO_SCTP = 132, /* Stream Control Transport Protocol */
+ IPPROTO_UDPLITE = 136, /* UDP-Lite (RFC 3828) */
+ IPPROTO_RAW = 255, /* Raw IP packets */
+
+ // Number used by linux (0) has a special meaning for socket()
+ IPPROTO_IP = 1024, /* Dummy protocol for TCP */
+ // Number used by linux (1) clashes with IPPROTO_ICMP
+ SOL_SOCKET = 2048, /* For setsockopt() / getsockopt(): Options to be accessed at socket level, not protocol level. */
+ }
+
+ [Map]
+ [CLSCompliant (false)]
+ public enum UnixAddressFamily : int {
+ AF_UNSPEC = 0, /* Unspecified. */
+ AF_UNIX = 1, /* Local to host (pipes and file-domain). */
+ AF_INET = 2, /* IP protocol family. */
+ AF_AX25 = 3, /* Amateur Radio AX.25. */
+ AF_IPX = 4, /* Novell Internet Protocol. */
+ AF_APPLETALK = 5, /* Appletalk DDP. */
+ AF_NETROM = 6, /* Amateur radio NetROM. */
+ AF_BRIDGE = 7, /* Multiprotocol bridge. */
+ AF_ATMPVC = 8, /* ATM PVCs. */
+ AF_X25 = 9, /* Reserved for X.25 project. */
+ AF_INET6 = 10, /* IP version 6. */
+ AF_ROSE = 11, /* Amateur Radio X.25 PLP. */
+ AF_DECnet = 12, /* Reserved for DECnet project. */
+ AF_NETBEUI = 13, /* Reserved for 802.2LLC project. */
+ AF_SECURITY = 14, /* Security callback pseudo AF. */
+ AF_KEY = 15, /* PF_KEY key management API. */
+ AF_NETLINK = 16,
+ AF_PACKET = 17, /* Packet family. */
+ AF_ASH = 18, /* Ash. */
+ AF_ECONET = 19, /* Acorn Econet. */
+ AF_ATMSVC = 20, /* ATM SVCs. */
+ AF_RDS = 21, /* RDS sockets. */
+ AF_SNA = 22, /* Linux SNA Project */
+ AF_IRDA = 23, /* IRDA sockets. */
+ AF_PPPOX = 24, /* PPPoX sockets. */
+ AF_WANPIPE = 25, /* Wanpipe API sockets. */
+ AF_LLC = 26, /* Linux LLC. */
+ AF_CAN = 29, /* Controller Area Network. */
+ AF_TIPC = 30, /* TIPC sockets. */
+ AF_BLUETOOTH = 31, /* Bluetooth sockets. */
+ AF_IUCV = 32, /* IUCV sockets. */
+ AF_RXRPC = 33, /* RxRPC sockets. */
+ AF_ISDN = 34, /* mISDN sockets. */
+ AF_PHONET = 35, /* Phonet sockets. */
+ AF_IEEE802154 = 36, /* IEEE 802.15.4 sockets. */
+ AF_CAIF = 37, /* CAIF sockets. */
+ AF_ALG = 38, /* Algorithm sockets. */
+ AF_NFC = 39, /* NFC sockets. */
+ AF_VSOCK = 40, /* vSockets. */
+ }
+
+ [Map]
+ [CLSCompliant (false)]
+ public enum UnixSocketOptionName : int {
+ SO_DEBUG = 1,
+ SO_REUSEADDR = 2,
+ SO_TYPE = 3,
+ SO_ERROR = 4,
+ SO_DONTROUTE = 5,
+ SO_BROADCAST = 6,
+ SO_SNDBUF = 7,
+ SO_RCVBUF = 8,
+ SO_SNDBUFFORCE = 32,
+ SO_RCVBUFFORCE = 33,
+ SO_KEEPALIVE = 9,
+ SO_OOBINLINE = 10,
+ SO_NO_CHECK = 11,
+ SO_PRIORITY = 12,
+ SO_LINGER = 13,
+ SO_BSDCOMPAT = 14,
+ SO_REUSEPORT = 15,
+ SO_PASSCRED = 16,
+ SO_PEERCRED = 17,
+ SO_RCVLOWAT = 18,
+ SO_SNDLOWAT = 19,
+ SO_RCVTIMEO = 20,
+ SO_SNDTIMEO = 21,
+ SO_SECURITY_AUTHENTICATION = 22,
+ SO_SECURITY_ENCRYPTION_TRANSPORT = 23,
+ SO_SECURITY_ENCRYPTION_NETWORK = 24,
+ SO_BINDTODEVICE = 25,
+ SO_ATTACH_FILTER = 26,
+ SO_DETACH_FILTER = 27,
+ SO_PEERNAME = 28,
+ SO_TIMESTAMP = 29,
+ SO_ACCEPTCONN = 30,
+ SO_PEERSEC = 31,
+ SO_PASSSEC = 34,
+ SO_TIMESTAMPNS = 35,
+ SO_MARK = 36,
+ SO_TIMESTAMPING = 37,
+ SO_PROTOCOL = 38,
+ SO_DOMAIN = 39,
+ SO_RXQ_OVFL = 40,
+ SO_WIFI_STATUS = 41,
+ SO_PEEK_OFF = 42,
+ SO_NOFCS = 43,
+ SO_LOCK_FILTER = 44,
+ SO_SELECT_ERR_QUEUE = 45,
+ SO_BUSY_POLL = 46,
+ SO_MAX_PACING_RATE = 47,
+ }
+
+ [Flags][Map]
+ [CLSCompliant (false)]
+ public enum MessageFlags : int {
+ MSG_OOB = 0x01, /* Process out-of-band data. */
+ MSG_PEEK = 0x02, /* Peek at incoming messages. */
+ MSG_DONTROUTE = 0x04, /* Don't use local routing. */
+ MSG_CTRUNC = 0x08, /* Control data lost before delivery. */
+ MSG_PROXY = 0x10, /* Supply or ask second address. */
+ MSG_TRUNC = 0x20,
+ MSG_DONTWAIT = 0x40, /* Nonblocking IO. */
+ MSG_EOR = 0x80, /* End of record. */
+ MSG_WAITALL = 0x100, /* Wait for a full request. */
+ MSG_FIN = 0x200,
+ MSG_SYN = 0x400,
+ MSG_CONFIRM = 0x800, /* Confirm path validity. */
+ MSG_RST = 0x1000,
+ MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */
+ MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */
+ MSG_MORE = 0x8000, /* Sender will send more. */
+ MSG_WAITFORONE = 0x10000, /* Wait for at least one packet to return.*/
+ MSG_FASTOPEN = 0x20000000, /* Send data in TCP SYN. */
+ MSG_CMSG_CLOEXEC = 0x40000000, /* Set close_on_exit for file descriptor received through SCM_RIGHTS. */
+ }
+
+ [Map]
+ [CLSCompliant (false)]
+ public enum ShutdownOption : int {
+ SHUT_RD = 0x01, /* No more receptions. */
+ SHUT_WR = 0x02, /* No more transmissions. */
+ SHUT_RDWR = 0x03, /* No more receptions or transmissions. */
+ }
+
#endregion
#region Structures
[FieldOffset (4)]
public ulong u64;
}
+
+ [Map ("struct linger")]
+ [CLSCompliant (false)]
+ public struct Linger {
+ public int l_onoff;
+ public int l_linger;
+ }
+
#endregion
#region Classes
return sys_pwritev (fd, iov, iov.Length, offset);
}
#endregion
+
+ #region <socket.h> Declarations
+ //
+ // <socket.h>
+ //
+
+ // socket(2)
+ // int socket(int domain, int type, int protocol);
+ [DllImport (LIBC, SetLastError=true,
+ EntryPoint="socket")]
+ static extern int sys_socket (int domain, int type, int protocol);
+
+ public static int socket (UnixAddressFamily domain, UnixSocketType type, UnixSocketFlags flags, UnixSocketProtocol protocol)
+ {
+ var _domain = NativeConvert.FromUnixAddressFamily (domain);
+ var _type = NativeConvert.FromUnixSocketType (type);
+ var _flags = NativeConvert.FromUnixSocketFlags (flags);
+ // protocol == 0 is a special case (uses default protocol)
+ var _protocol = protocol == 0 ? 0 : NativeConvert.FromUnixSocketProtocol (protocol);
+
+ return sys_socket (_domain, _type | _flags, _protocol);
+ }
+
+ public static int socket (UnixAddressFamily domain, UnixSocketType type, UnixSocketProtocol protocol)
+ {
+ return socket (domain, type, 0, protocol);
+ }
+
+ // socketpair(2)
+ // int socketpair(int domain, int type, int protocol, int sv[2]);
+ [DllImport (MPH, SetLastError=true,
+ EntryPoint="Mono_Posix_Syscall_socketpair")]
+ static extern int sys_socketpair (int domain, int type, int protocol, out int socket1, out int socket2);
+
+ public static int socketpair (UnixAddressFamily domain, UnixSocketType type, UnixSocketFlags flags, UnixSocketProtocol protocol, out int socket1, out int socket2)
+ {
+ var _domain = NativeConvert.FromUnixAddressFamily (domain);
+ var _type = NativeConvert.FromUnixSocketType (type);
+ var _flags = NativeConvert.FromUnixSocketFlags (flags);
+ // protocol == 0 is a special case (uses default protocol)
+ var _protocol = protocol == 0 ? 0 : NativeConvert.FromUnixSocketProtocol (protocol);
+
+ return sys_socketpair (_domain, _type | _flags, _protocol, out socket1, out socket2);
+ }
+
+ public static int socketpair (UnixAddressFamily domain, UnixSocketType type, UnixSocketProtocol protocol, out int socket1, out int socket2)
+ {
+ return socketpair (domain, type, 0, protocol, out socket1, out socket2);
+ }
+
+ // sockatmark(2)
+ // int sockatmark(int sockfd);
+ [DllImport (LIBC, SetLastError=true)]
+ public static extern int sockatmark (int socket);
+
+ // listen(2)
+ // int listen(int sockfd, int backlog);
+ [DllImport (LIBC, SetLastError=true)]
+ public static extern int listen (int socket, int backlog);
+
+ // getsockopt(2)
+ // int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen);
+ [DllImport (MPH, SetLastError=true,
+ EntryPoint="Mono_Posix_Syscall_getsockopt")]
+ static extern unsafe int sys_getsockopt (int socket, int level, int option_name, void *option_value, ref long option_len);
+
+ [DllImport (MPH, SetLastError=true,
+ EntryPoint="Mono_Posix_Syscall_getsockopt_timeval")]
+ static extern unsafe int sys_getsockopt_timeval (int socket, int level, int option_name, out Timeval option_value);
+
+ [DllImport (MPH, SetLastError=true,
+ EntryPoint="Mono_Posix_Syscall_getsockopt_linger")]
+ static extern unsafe int sys_getsockopt_linger (int socket, int level, int option_name, out Linger option_value);
+
+ public static unsafe int getsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, void *option_value, ref long option_len)
+ {
+ var _level = NativeConvert.FromUnixSocketProtocol (level);
+ var _option_name = NativeConvert.FromUnixSocketOptionName (option_name);
+ return sys_getsockopt (socket, _level, _option_name, option_value, ref option_len);
+ }
+
+ public static unsafe int getsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, IntPtr option_value, ref long option_len)
+ {
+ return getsockopt (socket, level, option_name, (void*) option_value, ref option_len);
+ }
+
+ public static unsafe int getsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, out int option_value)
+ {
+ int value;
+ long size = sizeof (int);
+ int ret = getsockopt (socket, level, option_name, &value, ref size);
+ if (ret != -1 && size != sizeof (int)) {
+ SetLastError (Errno.EINVAL);
+ ret = -1;
+ }
+ option_value = value;
+ return ret;
+ }
+
+ public static unsafe int getsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, byte[] option_value, ref long option_len)
+ {
+ if (option_len > (option_value == null ? 0 : option_value.Length))
+ throw new ArgumentOutOfRangeException ("option_len", "option_len > (option_value == null ? 0 : option_value.Length)");
+ fixed (byte* ptr = option_value)
+ return getsockopt (socket, level, option_name, ptr, ref option_len);
+ }
+
+ public static unsafe int getsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, out Timeval option_value)
+ {
+ var _level = NativeConvert.FromUnixSocketProtocol (level);
+ var _option_name = NativeConvert.FromUnixSocketOptionName (option_name);
+ return sys_getsockopt_timeval (socket, _level, _option_name, out option_value);
+ }
+
+ public static unsafe int getsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, out Linger option_value)
+ {
+ var _level = NativeConvert.FromUnixSocketProtocol (level);
+ var _option_name = NativeConvert.FromUnixSocketOptionName (option_name);
+ return sys_getsockopt_linger (socket, _level, _option_name, out option_value);
+ }
+
+ // setsockopt(2)
+ // int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);
+ [DllImport (MPH, SetLastError=true,
+ EntryPoint="Mono_Posix_Syscall_setsockopt")]
+ static extern unsafe int sys_setsockopt (int socket, int level, int option_name, void *option_value, long option_len);
+
+ [DllImport (MPH, SetLastError=true,
+ EntryPoint="Mono_Posix_Syscall_setsockopt_timeval")]
+ static extern unsafe int sys_setsockopt_timeval (int socket, int level, int option_name, ref Timeval option_value);
+
+ [DllImport (MPH, SetLastError=true,
+ EntryPoint="Mono_Posix_Syscall_setsockopt_linger")]
+ static extern unsafe int sys_setsockopt_linger (int socket, int level, int option_name, ref Linger option_value);
+
+ public static unsafe int setsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, void *option_value, long option_len)
+ {
+ var _level = NativeConvert.FromUnixSocketProtocol (level);
+ var _option_name = NativeConvert.FromUnixSocketOptionName (option_name);
+ return sys_setsockopt (socket, _level, _option_name, option_value, option_len);
+ }
+
+ public static unsafe int setsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, IntPtr option_value, long option_len)
+ {
+ return setsockopt (socket, level, option_name, (void*) option_value, option_len);
+ }
+
+ public static unsafe int setsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, int option_value)
+ {
+ return setsockopt (socket, level, option_name, &option_value, sizeof (int));
+ }
+
+ public static unsafe int setsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, byte[] option_value, long option_len)
+ {
+ if (option_len > (option_value == null ? 0 : option_value.Length))
+ throw new ArgumentOutOfRangeException ("option_len", "option_len > (option_value == null ? 0 : option_value.Length)");
+ fixed (byte* ptr = option_value)
+ return setsockopt (socket, level, option_name, ptr, option_len);
+ }
+
+ public static unsafe int setsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, Timeval option_value)
+ {
+ var _level = NativeConvert.FromUnixSocketProtocol (level);
+ var _option_name = NativeConvert.FromUnixSocketOptionName (option_name);
+ return sys_setsockopt_timeval (socket, _level, _option_name, ref option_value);
+ }
+
+ public static unsafe int setsockopt (int socket, UnixSocketProtocol level, UnixSocketOptionName option_name, Linger option_value)
+ {
+ var _level = NativeConvert.FromUnixSocketProtocol (level);
+ var _option_name = NativeConvert.FromUnixSocketOptionName (option_name);
+ return sys_setsockopt_linger (socket, _level, _option_name, ref option_value);
+ }
+
+ // shutdown(2)
+ // int shutdown(int sockfd, int how);
+ [DllImport (LIBC, SetLastError=true,
+ EntryPoint="shutdown")]
+ static extern int sys_shutdown (int socket, int how);
+
+ public static int shutdown (int socket, ShutdownOption how)
+ {
+ var _how = NativeConvert.FromShutdownOption (how);
+ return sys_shutdown (socket, _how);
+ }
+
+ // recv(2)
+ // ssize_t recv(int sockfd, void *buf, size_t len, int flags);
+ [DllImport (MPH, SetLastError=true,
+ EntryPoint="Mono_Posix_Syscall_recv")]
+ static extern unsafe long sys_recv (int socket, void *buffer, ulong length, int flags);
+
+ public static unsafe long recv (int socket, void *buffer, ulong length, MessageFlags flags)
+ {
+ int _flags = NativeConvert.FromMessageFlags (flags);
+ return sys_recv (socket, buffer, length, _flags);
+ }
+
+ public static unsafe long recv (int socket, IntPtr buffer, ulong length, MessageFlags flags)
+ {
+ return recv (socket, (void*) buffer, length, flags);
+ }
+
+ public static unsafe long recv (int socket, byte[] buffer, ulong length, MessageFlags flags)
+ {
+ if (length > (ulong) (buffer == null ? 0 : buffer.LongLength))
+ throw new ArgumentOutOfRangeException ("length", "length > (buffer == null ? 0 : buffer.LongLength)");
+ fixed (byte* ptr = buffer)
+ return recv (socket, ptr, length, flags);
+ }
+
+ // send(2)
+ // ssize_t send(int sockfd, const void *buf, size_t len, int flags);
+ [DllImport (MPH, SetLastError=true,
+ EntryPoint="Mono_Posix_Syscall_send")]
+ static extern unsafe long sys_send (int socket, void *message, ulong length, int flags);
+
+ public static unsafe long send (int socket, void *message, ulong length, MessageFlags flags)
+ {
+ int _flags = NativeConvert.FromMessageFlags (flags);
+ return sys_send (socket, message, length, _flags);
+ }
+
+ public static unsafe long send (int socket, IntPtr message, ulong length, MessageFlags flags)
+ {
+ return send (socket, (void*) message, length, flags);
+ }
+
+ public static unsafe long send (int socket, byte[] message, ulong length, MessageFlags flags)
+ {
+ if (length > (ulong) (message == null ? 0 : message.LongLength))
+ throw new ArgumentOutOfRangeException ("length", "length > (message == null ? 0 : message.LongLength)");
+ fixed (byte* ptr = message)
+ return send (socket, ptr, length, flags);
+ }
+
+ #endregion
}
#endregion
--- /dev/null
+//
+// socket-related test cases
+//
+// Authors:
+// Steffen Kiess (s-kiess@web.de)
+//
+// Copyright (C) 2015 Steffen Kiess
+//
+
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.InteropServices;
+
+using Mono.Unix;
+using Mono.Unix.Native;
+
+using NUnit.Framework;
+
+namespace MonoTests.Mono.Unix.Native
+{
+ [TestFixture, Category ("NotDotNet")]
+ public class SocketTest {
+
+ string TempFolder;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ TempFolder = Path.Combine (Path.GetTempPath (), this.GetType ().FullName);
+
+ if (Directory.Exists (TempFolder))
+ Directory.Delete (TempFolder, true);
+
+ Directory.CreateDirectory (TempFolder);
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ if (Directory.Exists (TempFolder))
+ Directory.Delete (TempFolder, true);
+ }
+
+ // Set a timeout on all sockets to make sure that if a test fails it
+ // won't cause the program to hang
+ void SetTimeout (int socket)
+ {
+ var timeout = new Timeval {
+ tv_sec = 0,
+ tv_usec = 500000,
+ };
+ if (Syscall.setsockopt (socket, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_RCVTIMEO, timeout) < 0 ||
+ Syscall.setsockopt (socket, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_SNDTIMEO, timeout) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ }
+
+ void WithSocketPair (Action<int, int> f)
+ {
+ int socket1, socket2;
+ if (Syscall.socketpair (UnixAddressFamily.AF_UNIX, UnixSocketType.SOCK_STREAM, 0, out socket1, out socket2) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ try {
+ SetTimeout (socket1);
+ SetTimeout (socket2);
+
+ f (socket1, socket2);
+ } finally {
+ int r0 = Syscall.close (socket1);
+ int r1 = Syscall.close (socket2);
+ if (r0 < 0 || r1 < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ }
+ }
+
+ void WithSockets (UnixAddressFamily af, UnixSocketType type, UnixSocketProtocol protocol, Action<int, int> f)
+ {
+ int so1, so2;
+ if ((so1 = Syscall.socket (af, type, protocol)) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ try {
+ if ((so2 = Syscall.socket (af, type, protocol)) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ try {
+ SetTimeout (so1);
+ SetTimeout (so2);
+
+ f (so1, so2);
+ } finally {
+ if (Syscall.close (so2) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ }
+ } finally {
+ if (Syscall.close (so1) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ }
+ }
+
+ [Test]
+ public void Socket ()
+ {
+ int socket;
+ if ((socket = Syscall.socket (UnixAddressFamily.AF_UNIX, UnixSocketType.SOCK_STREAM, 0)) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+
+ if (Syscall.close (socket) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ }
+
+ [Test]
+ public void SocketPair ()
+ {
+ int socket1, socket2;
+ if (Syscall.socketpair (UnixAddressFamily.AF_UNIX, UnixSocketType.SOCK_STREAM, 0, out socket1, out socket2) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+
+ int r0 = Syscall.close (socket1);
+ int r1 = Syscall.close (socket2);
+ if (r0 < 0 || r1 < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ }
+
+ [Test]
+ public void SendRecv ()
+ {
+ WithSocketPair ((so1, so2) => {
+ long ret;
+ var buffer1 = new byte[] { 42, 43, 44 };
+ ret = Syscall.send (so1, buffer1, (ulong) buffer1.Length, 0);
+ if (ret < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+
+ var buffer2 = new byte[1024];
+ ret = Syscall.recv (so2, buffer2, (ulong) buffer2.Length, 0);
+ if (ret < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+
+ Assert.AreEqual (buffer1.Length, ret);
+ for (int i = 0; i < buffer1.Length; i++)
+ Assert.AreEqual (buffer1[i], buffer2[i]);
+ });
+ }
+
+ [Test]
+ public void SockOpt ()
+ {
+ WithSockets (UnixAddressFamily.AF_UNIX, UnixSocketType.SOCK_STREAM, 0, (so1, so2) => {
+ // Set SO_REUSEADDR to 1
+ if (Syscall.setsockopt (so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_REUSEADDR, 1) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+
+ // Get and check SO_REUSEADDR
+ int value;
+ if (Syscall.getsockopt (so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_REUSEADDR, out value) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ Assert.AreEqual (value, 1);
+
+ // Set SO_REUSEADDR to 0
+ if (Syscall.setsockopt (so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_REUSEADDR, new byte[10], 4) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+
+ // Get and check SO_REUSEADDR
+ var buffer = new byte[15];
+ long size = 12;
+ if (Syscall.getsockopt (so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_REUSEADDR, buffer, ref size) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ Assert.AreEqual (size, 4);
+ for (int i = 0; i < size; i++)
+ Assert.AreEqual (buffer[i], 0);
+ });
+ }
+
+ [Test]
+ public void SockOptLinger ()
+ {
+ WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_STREAM, UnixSocketProtocol.IPPROTO_TCP, (so1, so2) => {
+ Linger linger = new Linger {
+ l_onoff = 1,
+ l_linger = 42,
+ };
+ // Set SO_LINGER
+ if (Syscall.setsockopt (so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_LINGER, linger) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+
+ // Get and check SO_LINGER
+ Linger value;
+ if (Syscall.getsockopt (so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_LINGER, out value) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+ Assert.AreEqual (linger, value);
+ });
+ }
+
+ [Test]
+ public void Shutdown ()
+ {
+ WithSocketPair ((so1, so2) => {
+ if (Syscall.shutdown (so1, ShutdownOption.SHUT_WR) < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+
+ var buffer2 = new byte[1024];
+ long ret = Syscall.recv (so2, buffer2, (ulong) buffer2.Length, 0);
+ if (ret < 0)
+ UnixMarshal.ThrowExceptionForLastError ();
+
+ Assert.AreEqual (ret, 0);
+ });
+ }
+ }
+}
+
+// vim: noexpandtab
+// Local Variables:
+// tab-width: 4
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// End:
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -define:TEST -resource:Test/resources/indexed.png,indexed.png \
-r:System.Drawing.dll -r:System.Runtime.Serialization.Formatters.Soap.dll -r:System.Xml.dll \
- -nowarn:0618 -nowarn:219 -nowarn:169 -nowarn:1595
+ -nowarn:0618 -nowarn:219 -nowarn:169
include ../../build/library.make
LOCAL_MCS_FLAGS = -lib:$(secxml_libdir) -lib:$(bare_libdir)
-TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:168,169,183,219,414,1595
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:168,169,183,219,414
EXTRA_DISTFILES = \
Test/System.Security.Cryptography.Xml/sample.pfx \
LIB_MCS_FLAGS = /r:$(corlib)
endif
-TEST_MCS_FLAGS = /nowarn:1595 $(LIB_MCS_FLAGS)
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
include ../../build/library.make
string host = uri.Host;
int port = uri.Port;
- string path = HttpUtility.UrlDecode (uri.AbsolutePath);
+ string path = WebUtility.UrlDecode (uri.AbsolutePath);
string path_slash = path [path.Length - 1] == '/' ? path : path + "/";
HttpListener best_match = null;
foreach (string kv in components) {
int pos = kv.IndexOf ('=');
if (pos == -1) {
- query_string.Add (null, HttpUtility.UrlDecode (kv));
+ query_string.Add (null, WebUtility.UrlDecode (kv));
} else {
- string key = HttpUtility.UrlDecode (kv.Substring (0, pos));
- string val = HttpUtility.UrlDecode (kv.Substring (pos + 1));
+ string key = WebUtility.UrlDecode (kv.Substring (0, pos));
+ string val = WebUtility.UrlDecode (kv.Substring (pos + 1));
query_string.Add (key, val);
}
+++ /dev/null
-//
-// Copied from System.Web.HttpUtility and marked internal
-//
-// Authors:
-// Patrik Torstensson (Patrik.Torstensson@labs2.com)
-// Wictor Wilén (decode/encode functions) (wictor@ibizkit.se)
-// Tim Coleman (tim@timcoleman.com)
-// Gonzalo Paniagua Javier (gonzalo@ximian.com)
-// Marek Safar (marek.safar@gmail.com)
-//
-// Copyright (C) 2005-2009 Novell, Inc (http://www.novell.com)
-// Copyright (C) 2014 Xamarin Inc (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Globalization;
-using System.IO;
-using System.Security.Permissions;
-using System.Text;
-
-namespace System.Net {
-
- static class HttpUtility
- {
- sealed class HttpQSCollection : NameValueCollection
- {
- public override string ToString ()
- {
- int count = Count;
- if (count == 0)
- return "";
- StringBuilder sb = new StringBuilder ();
- string [] keys = AllKeys;
- for (int i = 0; i < count; i++) {
- sb.AppendFormat ("{0}={1}&", keys [i], this [keys [i]]);
- }
- if (sb.Length > 0)
- sb.Length--;
- return sb.ToString ();
- }
- }
-
- // Must be sorted
- static readonly long[] entities = new long[] {
- (long)'A' << 56 | (long)'E' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24,
- (long)'A' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'A' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24,
- (long)'A' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16,
- (long)'A' << 56 | (long)'l' << 48 | (long)'p' << 40 | (long)'h' << 32 | (long)'a' << 24,
- (long)'A' << 56 | (long)'r' << 48 | (long)'i' << 40 | (long)'n' << 32 | (long)'g' << 24,
- (long)'A' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16,
- (long)'A' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'B' << 56 | (long)'e' << 48 | (long)'t' << 40 | (long)'a' << 32,
- (long)'C' << 56 | (long)'c' << 48 | (long)'e' << 40 | (long)'d' << 32 | (long)'i' << 24 | (long)'l' << 16,
- (long)'C' << 56 | (long)'h' << 48 | (long)'i' << 40,
- (long)'D' << 56 | (long)'a' << 48 | (long)'g' << 40 | (long)'g' << 32 | (long)'e' << 24 | (long)'r' << 16,
- (long)'D' << 56 | (long)'e' << 48 | (long)'l' << 40 | (long)'t' << 32 | (long)'a' << 24,
- (long)'E' << 56 | (long)'T' << 48 | (long)'H' << 40,
- (long)'E' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'E' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24,
- (long)'E' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16,
- (long)'E' << 56 | (long)'p' << 48 | (long)'s' << 40 | (long)'i' << 32 | (long)'l' << 24 | (long)'o' << 16 | (long)'n' << 8,
- (long)'E' << 56 | (long)'t' << 48 | (long)'a' << 40,
- (long)'E' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'G' << 56 | (long)'a' << 48 | (long)'m' << 40 | (long)'m' << 32 | (long)'a' << 24,
- (long)'I' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'I' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24,
- (long)'I' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16,
- (long)'I' << 56 | (long)'o' << 48 | (long)'t' << 40 | (long)'a' << 32,
- (long)'I' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'K' << 56 | (long)'a' << 48 | (long)'p' << 40 | (long)'p' << 32 | (long)'a' << 24,
- (long)'L' << 56 | (long)'a' << 48 | (long)'m' << 40 | (long)'b' << 32 | (long)'d' << 24 | (long)'a' << 16,
- (long)'M' << 56 | (long)'u' << 48,
- (long)'N' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16,
- (long)'N' << 56 | (long)'u' << 48,
- (long)'O' << 56 | (long)'E' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24,
- (long)'O' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'O' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24,
- (long)'O' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16,
- (long)'O' << 56 | (long)'m' << 48 | (long)'e' << 40 | (long)'g' << 32 | (long)'a' << 24,
- (long)'O' << 56 | (long)'m' << 48 | (long)'i' << 40 | (long)'c' << 32 | (long)'r' << 24 | (long)'o' << 16 | (long)'n' << 8,
- (long)'O' << 56 | (long)'s' << 48 | (long)'l' << 40 | (long)'a' << 32 | (long)'s' << 24 | (long)'h' << 16,
- (long)'O' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16,
- (long)'O' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'P' << 56 | (long)'h' << 48 | (long)'i' << 40,
- (long)'P' << 56 | (long)'i' << 48,
- (long)'P' << 56 | (long)'r' << 48 | (long)'i' << 40 | (long)'m' << 32 | (long)'e' << 24,
- (long)'P' << 56 | (long)'s' << 48 | (long)'i' << 40,
- (long)'R' << 56 | (long)'h' << 48 | (long)'o' << 40,
- (long)'S' << 56 | (long)'c' << 48 | (long)'a' << 40 | (long)'r' << 32 | (long)'o' << 24 | (long)'n' << 16,
- (long)'S' << 56 | (long)'i' << 48 | (long)'g' << 40 | (long)'m' << 32 | (long)'a' << 24,
- (long)'T' << 56 | (long)'H' << 48 | (long)'O' << 40 | (long)'R' << 32 | (long)'N' << 24,
- (long)'T' << 56 | (long)'a' << 48 | (long)'u' << 40,
- (long)'T' << 56 | (long)'h' << 48 | (long)'e' << 40 | (long)'t' << 32 | (long)'a' << 24,
- (long)'U' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'U' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24,
- (long)'U' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16,
- (long)'U' << 56 | (long)'p' << 48 | (long)'s' << 40 | (long)'i' << 32 | (long)'l' << 24 | (long)'o' << 16 | (long)'n' << 8,
- (long)'U' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'X' << 56 | (long)'i' << 48,
- (long)'Y' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'Y' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'Z' << 56 | (long)'e' << 48 | (long)'t' << 40 | (long)'a' << 32,
- (long)'a' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'a' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24,
- (long)'a' << 56 | (long)'c' << 48 | (long)'u' << 40 | (long)'t' << 32 | (long)'e' << 24,
- (long)'a' << 56 | (long)'e' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24,
- (long)'a' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16,
- (long)'a' << 56 | (long)'l' << 48 | (long)'e' << 40 | (long)'f' << 32 | (long)'s' << 24 | (long)'y' << 16 | (long)'m' << 8,
- (long)'a' << 56 | (long)'l' << 48 | (long)'p' << 40 | (long)'h' << 32 | (long)'a' << 24,
- (long)'a' << 56 | (long)'m' << 48 | (long)'p' << 40,
- (long)'a' << 56 | (long)'n' << 48 | (long)'d' << 40,
- (long)'a' << 56 | (long)'n' << 48 | (long)'g' << 40,
- (long)'a' << 56 | (long)'p' << 48 | (long)'o' << 40 | (long)'s' << 32,
- (long)'a' << 56 | (long)'r' << 48 | (long)'i' << 40 | (long)'n' << 32 | (long)'g' << 24,
- (long)'a' << 56 | (long)'s' << 48 | (long)'y' << 40 | (long)'m' << 32 | (long)'p' << 24,
- (long)'a' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16,
- (long)'a' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'b' << 56 | (long)'d' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24,
- (long)'b' << 56 | (long)'e' << 48 | (long)'t' << 40 | (long)'a' << 32,
- (long)'b' << 56 | (long)'r' << 48 | (long)'v' << 40 | (long)'b' << 32 | (long)'a' << 24 | (long)'r' << 16,
- (long)'b' << 56 | (long)'u' << 48 | (long)'l' << 40 | (long)'l' << 32,
- (long)'c' << 56 | (long)'a' << 48 | (long)'p' << 40,
- (long)'c' << 56 | (long)'c' << 48 | (long)'e' << 40 | (long)'d' << 32 | (long)'i' << 24 | (long)'l' << 16,
- (long)'c' << 56 | (long)'e' << 48 | (long)'d' << 40 | (long)'i' << 32 | (long)'l' << 24,
- (long)'c' << 56 | (long)'e' << 48 | (long)'n' << 40 | (long)'t' << 32,
- (long)'c' << 56 | (long)'h' << 48 | (long)'i' << 40,
- (long)'c' << 56 | (long)'i' << 48 | (long)'r' << 40 | (long)'c' << 32,
- (long)'c' << 56 | (long)'l' << 48 | (long)'u' << 40 | (long)'b' << 32 | (long)'s' << 24,
- (long)'c' << 56 | (long)'o' << 48 | (long)'n' << 40 | (long)'g' << 32,
- (long)'c' << 56 | (long)'o' << 48 | (long)'p' << 40 | (long)'y' << 32,
- (long)'c' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'r' << 32 | (long)'r' << 24,
- (long)'c' << 56 | (long)'u' << 48 | (long)'p' << 40,
- (long)'c' << 56 | (long)'u' << 48 | (long)'r' << 40 | (long)'r' << 32 | (long)'e' << 24 | (long)'n' << 16,
- (long)'d' << 56 | (long)'A' << 48 | (long)'r' << 40 | (long)'r' << 32,
- (long)'d' << 56 | (long)'a' << 48 | (long)'g' << 40 | (long)'g' << 32 | (long)'e' << 24 | (long)'r' << 16,
- (long)'d' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'r' << 32,
- (long)'d' << 56 | (long)'e' << 48 | (long)'g' << 40,
- (long)'d' << 56 | (long)'e' << 48 | (long)'l' << 40 | (long)'t' << 32 | (long)'a' << 24,
- (long)'d' << 56 | (long)'i' << 48 | (long)'a' << 40 | (long)'m' << 32 | (long)'s' << 24,
- (long)'d' << 56 | (long)'i' << 48 | (long)'v' << 40 | (long)'i' << 32 | (long)'d' << 24 | (long)'e' << 16,
- (long)'e' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'e' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24,
- (long)'e' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16,
- (long)'e' << 56 | (long)'m' << 48 | (long)'p' << 40 | (long)'t' << 32 | (long)'y' << 24,
- (long)'e' << 56 | (long)'m' << 48 | (long)'s' << 40 | (long)'p' << 32,
- (long)'e' << 56 | (long)'n' << 48 | (long)'s' << 40 | (long)'p' << 32,
- (long)'e' << 56 | (long)'p' << 48 | (long)'s' << 40 | (long)'i' << 32 | (long)'l' << 24 | (long)'o' << 16 | (long)'n' << 8,
- (long)'e' << 56 | (long)'q' << 48 | (long)'u' << 40 | (long)'i' << 32 | (long)'v' << 24,
- (long)'e' << 56 | (long)'t' << 48 | (long)'a' << 40,
- (long)'e' << 56 | (long)'t' << 48 | (long)'h' << 40,
- (long)'e' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'e' << 56 | (long)'u' << 48 | (long)'r' << 40 | (long)'o' << 32,
- (long)'e' << 56 | (long)'x' << 48 | (long)'i' << 40 | (long)'s' << 32 | (long)'t' << 24,
- (long)'f' << 56 | (long)'n' << 48 | (long)'o' << 40 | (long)'f' << 32,
- (long)'f' << 56 | (long)'o' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'l' << 24 | (long)'l' << 16,
- (long)'f' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'c' << 32 | (long)'1' << 24 | (long)'2' << 16,
- (long)'f' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'c' << 32 | (long)'1' << 24 | (long)'4' << 16,
- (long)'f' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'c' << 32 | (long)'3' << 24 | (long)'4' << 16,
- (long)'f' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'s' << 32 | (long)'l' << 24,
- (long)'g' << 56 | (long)'a' << 48 | (long)'m' << 40 | (long)'m' << 32 | (long)'a' << 24,
- (long)'g' << 56 | (long)'e' << 48,
- (long)'g' << 56 | (long)'t' << 48,
- (long)'h' << 56 | (long)'A' << 48 | (long)'r' << 40 | (long)'r' << 32,
- (long)'h' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'r' << 32,
- (long)'h' << 56 | (long)'e' << 48 | (long)'a' << 40 | (long)'r' << 32 | (long)'t' << 24 | (long)'s' << 16,
- (long)'h' << 56 | (long)'e' << 48 | (long)'l' << 40 | (long)'l' << 32 | (long)'i' << 24 | (long)'p' << 16,
- (long)'i' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'i' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24,
- (long)'i' << 56 | (long)'e' << 48 | (long)'x' << 40 | (long)'c' << 32 | (long)'l' << 24,
- (long)'i' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16,
- (long)'i' << 56 | (long)'m' << 48 | (long)'a' << 40 | (long)'g' << 32 | (long)'e' << 24,
- (long)'i' << 56 | (long)'n' << 48 | (long)'f' << 40 | (long)'i' << 32 | (long)'n' << 24,
- (long)'i' << 56 | (long)'n' << 48 | (long)'t' << 40,
- (long)'i' << 56 | (long)'o' << 48 | (long)'t' << 40 | (long)'a' << 32,
- (long)'i' << 56 | (long)'q' << 48 | (long)'u' << 40 | (long)'e' << 32 | (long)'s' << 24 | (long)'t' << 16,
- (long)'i' << 56 | (long)'s' << 48 | (long)'i' << 40 | (long)'n' << 32,
- (long)'i' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'k' << 56 | (long)'a' << 48 | (long)'p' << 40 | (long)'p' << 32 | (long)'a' << 24,
- (long)'l' << 56 | (long)'A' << 48 | (long)'r' << 40 | (long)'r' << 32,
- (long)'l' << 56 | (long)'a' << 48 | (long)'m' << 40 | (long)'b' << 32 | (long)'d' << 24 | (long)'a' << 16,
- (long)'l' << 56 | (long)'a' << 48 | (long)'n' << 40 | (long)'g' << 32,
- (long)'l' << 56 | (long)'a' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24,
- (long)'l' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'r' << 32,
- (long)'l' << 56 | (long)'c' << 48 | (long)'e' << 40 | (long)'i' << 32 | (long)'l' << 24,
- (long)'l' << 56 | (long)'d' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24,
- (long)'l' << 56 | (long)'e' << 48,
- (long)'l' << 56 | (long)'f' << 48 | (long)'l' << 40 | (long)'o' << 32 | (long)'o' << 24 | (long)'r' << 16,
- (long)'l' << 56 | (long)'o' << 48 | (long)'w' << 40 | (long)'a' << 32 | (long)'s' << 24 | (long)'t' << 16,
- (long)'l' << 56 | (long)'o' << 48 | (long)'z' << 40,
- (long)'l' << 56 | (long)'r' << 48 | (long)'m' << 40,
- (long)'l' << 56 | (long)'s' << 48 | (long)'a' << 40 | (long)'q' << 32 | (long)'u' << 24 | (long)'o' << 16,
- (long)'l' << 56 | (long)'s' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24,
- (long)'l' << 56 | (long)'t' << 48,
- (long)'m' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'r' << 32,
- (long)'m' << 56 | (long)'d' << 48 | (long)'a' << 40 | (long)'s' << 32 | (long)'h' << 24,
- (long)'m' << 56 | (long)'i' << 48 | (long)'c' << 40 | (long)'r' << 32 | (long)'o' << 24,
- (long)'m' << 56 | (long)'i' << 48 | (long)'d' << 40 | (long)'d' << 32 | (long)'o' << 24 | (long)'t' << 16,
- (long)'m' << 56 | (long)'i' << 48 | (long)'n' << 40 | (long)'u' << 32 | (long)'s' << 24,
- (long)'m' << 56 | (long)'u' << 48,
- (long)'n' << 56 | (long)'a' << 48 | (long)'b' << 40 | (long)'l' << 32 | (long)'a' << 24,
- (long)'n' << 56 | (long)'b' << 48 | (long)'s' << 40 | (long)'p' << 32,
- (long)'n' << 56 | (long)'d' << 48 | (long)'a' << 40 | (long)'s' << 32 | (long)'h' << 24,
- (long)'n' << 56 | (long)'e' << 48,
- (long)'n' << 56 | (long)'i' << 48,
- (long)'n' << 56 | (long)'o' << 48 | (long)'t' << 40,
- (long)'n' << 56 | (long)'o' << 48 | (long)'t' << 40 | (long)'i' << 32 | (long)'n' << 24,
- (long)'n' << 56 | (long)'s' << 48 | (long)'u' << 40 | (long)'b' << 32,
- (long)'n' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16,
- (long)'n' << 56 | (long)'u' << 48,
- (long)'o' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'o' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24,
- (long)'o' << 56 | (long)'e' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24,
- (long)'o' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16,
- (long)'o' << 56 | (long)'l' << 48 | (long)'i' << 40 | (long)'n' << 32 | (long)'e' << 24,
- (long)'o' << 56 | (long)'m' << 48 | (long)'e' << 40 | (long)'g' << 32 | (long)'a' << 24,
- (long)'o' << 56 | (long)'m' << 48 | (long)'i' << 40 | (long)'c' << 32 | (long)'r' << 24 | (long)'o' << 16 | (long)'n' << 8,
- (long)'o' << 56 | (long)'p' << 48 | (long)'l' << 40 | (long)'u' << 32 | (long)'s' << 24,
- (long)'o' << 56 | (long)'r' << 48,
- (long)'o' << 56 | (long)'r' << 48 | (long)'d' << 40 | (long)'f' << 32,
- (long)'o' << 56 | (long)'r' << 48 | (long)'d' << 40 | (long)'m' << 32,
- (long)'o' << 56 | (long)'s' << 48 | (long)'l' << 40 | (long)'a' << 32 | (long)'s' << 24 | (long)'h' << 16,
- (long)'o' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'l' << 32 | (long)'d' << 24 | (long)'e' << 16,
- (long)'o' << 56 | (long)'t' << 48 | (long)'i' << 40 | (long)'m' << 32 | (long)'e' << 24 | (long)'s' << 16,
- (long)'o' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'p' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'a' << 32,
- (long)'p' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'t' << 32,
- (long)'p' << 56 | (long)'e' << 48 | (long)'r' << 40 | (long)'m' << 32 | (long)'i' << 24 | (long)'l' << 16,
- (long)'p' << 56 | (long)'e' << 48 | (long)'r' << 40 | (long)'p' << 32,
- (long)'p' << 56 | (long)'h' << 48 | (long)'i' << 40,
- (long)'p' << 56 | (long)'i' << 48,
- (long)'p' << 56 | (long)'i' << 48 | (long)'v' << 40,
- (long)'p' << 56 | (long)'l' << 48 | (long)'u' << 40 | (long)'s' << 32 | (long)'m' << 24 | (long)'n' << 16,
- (long)'p' << 56 | (long)'o' << 48 | (long)'u' << 40 | (long)'n' << 32 | (long)'d' << 24,
- (long)'p' << 56 | (long)'r' << 48 | (long)'i' << 40 | (long)'m' << 32 | (long)'e' << 24,
- (long)'p' << 56 | (long)'r' << 48 | (long)'o' << 40 | (long)'d' << 32,
- (long)'p' << 56 | (long)'r' << 48 | (long)'o' << 40 | (long)'p' << 32,
- (long)'p' << 56 | (long)'s' << 48 | (long)'i' << 40,
- (long)'q' << 56 | (long)'u' << 48 | (long)'o' << 40 | (long)'t' << 32,
- (long)'r' << 56 | (long)'A' << 48 | (long)'r' << 40 | (long)'r' << 32,
- (long)'r' << 56 | (long)'a' << 48 | (long)'d' << 40 | (long)'i' << 32 | (long)'c' << 24,
- (long)'r' << 56 | (long)'a' << 48 | (long)'n' << 40 | (long)'g' << 32,
- (long)'r' << 56 | (long)'a' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24,
- (long)'r' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'r' << 32,
- (long)'r' << 56 | (long)'c' << 48 | (long)'e' << 40 | (long)'i' << 32 | (long)'l' << 24,
- (long)'r' << 56 | (long)'d' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24,
- (long)'r' << 56 | (long)'e' << 48 | (long)'a' << 40 | (long)'l' << 32,
- (long)'r' << 56 | (long)'e' << 48 | (long)'g' << 40,
- (long)'r' << 56 | (long)'f' << 48 | (long)'l' << 40 | (long)'o' << 32 | (long)'o' << 24 | (long)'r' << 16,
- (long)'r' << 56 | (long)'h' << 48 | (long)'o' << 40,
- (long)'r' << 56 | (long)'l' << 48 | (long)'m' << 40,
- (long)'r' << 56 | (long)'s' << 48 | (long)'a' << 40 | (long)'q' << 32 | (long)'u' << 24 | (long)'o' << 16,
- (long)'r' << 56 | (long)'s' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24,
- (long)'s' << 56 | (long)'b' << 48 | (long)'q' << 40 | (long)'u' << 32 | (long)'o' << 24,
- (long)'s' << 56 | (long)'c' << 48 | (long)'a' << 40 | (long)'r' << 32 | (long)'o' << 24 | (long)'n' << 16,
- (long)'s' << 56 | (long)'d' << 48 | (long)'o' << 40 | (long)'t' << 32,
- (long)'s' << 56 | (long)'e' << 48 | (long)'c' << 40 | (long)'t' << 32,
- (long)'s' << 56 | (long)'h' << 48 | (long)'y' << 40,
- (long)'s' << 56 | (long)'i' << 48 | (long)'g' << 40 | (long)'m' << 32 | (long)'a' << 24,
- (long)'s' << 56 | (long)'i' << 48 | (long)'g' << 40 | (long)'m' << 32 | (long)'a' << 24 | (long)'f' << 16,
- (long)'s' << 56 | (long)'i' << 48 | (long)'m' << 40,
- (long)'s' << 56 | (long)'p' << 48 | (long)'a' << 40 | (long)'d' << 32 | (long)'e' << 24 | (long)'s' << 16,
- (long)'s' << 56 | (long)'u' << 48 | (long)'b' << 40,
- (long)'s' << 56 | (long)'u' << 48 | (long)'b' << 40 | (long)'e' << 32,
- (long)'s' << 56 | (long)'u' << 48 | (long)'m' << 40,
- (long)'s' << 56 | (long)'u' << 48 | (long)'p' << 40,
- (long)'s' << 56 | (long)'u' << 48 | (long)'p' << 40 | (long)'1' << 32,
- (long)'s' << 56 | (long)'u' << 48 | (long)'p' << 40 | (long)'2' << 32,
- (long)'s' << 56 | (long)'u' << 48 | (long)'p' << 40 | (long)'3' << 32,
- (long)'s' << 56 | (long)'u' << 48 | (long)'p' << 40 | (long)'e' << 32,
- (long)'s' << 56 | (long)'z' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24,
- (long)'t' << 56 | (long)'a' << 48 | (long)'u' << 40,
- (long)'t' << 56 | (long)'h' << 48 | (long)'e' << 40 | (long)'r' << 32 | (long)'e' << 24 | (long)'4' << 16,
- (long)'t' << 56 | (long)'h' << 48 | (long)'e' << 40 | (long)'t' << 32 | (long)'a' << 24,
- (long)'t' << 56 | (long)'h' << 48 | (long)'e' << 40 | (long)'t' << 32 | (long)'a' << 24 | (long)'s' << 16 | (long)'y' << 8 | (long)'m' << 0,
- (long)'t' << 56 | (long)'h' << 48 | (long)'i' << 40 | (long)'n' << 32 | (long)'s' << 24 | (long)'p' << 16,
- (long)'t' << 56 | (long)'h' << 48 | (long)'o' << 40 | (long)'r' << 32 | (long)'n' << 24,
- (long)'t' << 56 | (long)'i' << 48 | (long)'l' << 40 | (long)'d' << 32 | (long)'e' << 24,
- (long)'t' << 56 | (long)'i' << 48 | (long)'m' << 40 | (long)'e' << 32 | (long)'s' << 24,
- (long)'t' << 56 | (long)'r' << 48 | (long)'a' << 40 | (long)'d' << 32 | (long)'e' << 24,
- (long)'u' << 56 | (long)'A' << 48 | (long)'r' << 40 | (long)'r' << 32,
- (long)'u' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'u' << 56 | (long)'a' << 48 | (long)'r' << 40 | (long)'r' << 32,
- (long)'u' << 56 | (long)'c' << 48 | (long)'i' << 40 | (long)'r' << 32 | (long)'c' << 24,
- (long)'u' << 56 | (long)'g' << 48 | (long)'r' << 40 | (long)'a' << 32 | (long)'v' << 24 | (long)'e' << 16,
- (long)'u' << 56 | (long)'m' << 48 | (long)'l' << 40,
- (long)'u' << 56 | (long)'p' << 48 | (long)'s' << 40 | (long)'i' << 32 | (long)'h' << 24,
- (long)'u' << 56 | (long)'p' << 48 | (long)'s' << 40 | (long)'i' << 32 | (long)'l' << 24 | (long)'o' << 16 | (long)'n' << 8,
- (long)'u' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'w' << 56 | (long)'e' << 48 | (long)'i' << 40 | (long)'e' << 32 | (long)'r' << 24 | (long)'p' << 16,
- (long)'x' << 56 | (long)'i' << 48,
- (long)'y' << 56 | (long)'a' << 48 | (long)'c' << 40 | (long)'u' << 32 | (long)'t' << 24 | (long)'e' << 16,
- (long)'y' << 56 | (long)'e' << 48 | (long)'n' << 40,
- (long)'y' << 56 | (long)'u' << 48 | (long)'m' << 40 | (long)'l' << 32,
- (long)'z' << 56 | (long)'e' << 48 | (long)'t' << 40 | (long)'a' << 32,
- (long)'z' << 56 | (long)'w' << 48 | (long)'j' << 40,
- (long)'z' << 56 | (long)'w' << 48 | (long)'n' << 40 | (long)'j' << 32
- };
-
- static readonly char[] entities_values = new char[] {
- '\u00C6',
- '\u00C1',
- '\u00C2',
- '\u00C0',
- '\u0391',
- '\u00C5',
- '\u00C3',
- '\u00C4',
- '\u0392',
- '\u00C7',
- '\u03A7',
- '\u2021',
- '\u0394',
- '\u00D0',
- '\u00C9',
- '\u00CA',
- '\u00C8',
- '\u0395',
- '\u0397',
- '\u00CB',
- '\u0393',
- '\u00CD',
- '\u00CE',
- '\u00CC',
- '\u0399',
- '\u00CF',
- '\u039A',
- '\u039B',
- '\u039C',
- '\u00D1',
- '\u039D',
- '\u0152',
- '\u00D3',
- '\u00D4',
- '\u00D2',
- '\u03A9',
- '\u039F',
- '\u00D8',
- '\u00D5',
- '\u00D6',
- '\u03A6',
- '\u03A0',
- '\u2033',
- '\u03A8',
- '\u03A1',
- '\u0160',
- '\u03A3',
- '\u00DE',
- '\u03A4',
- '\u0398',
- '\u00DA',
- '\u00DB',
- '\u00D9',
- '\u03A5',
- '\u00DC',
- '\u039E',
- '\u00DD',
- '\u0178',
- '\u0396',
- '\u00E1',
- '\u00E2',
- '\u00B4',
- '\u00E6',
- '\u00E0',
- '\u2135',
- '\u03B1',
- '\u0026',
- '\u2227',
- '\u2220',
- '\u0027',
- '\u00E5',
- '\u2248',
- '\u00E3',
- '\u00E4',
- '\u201E',
- '\u03B2',
- '\u00A6',
- '\u2022',
- '\u2229',
- '\u00E7',
- '\u00B8',
- '\u00A2',
- '\u03C7',
- '\u02C6',
- '\u2663',
- '\u2245',
- '\u00A9',
- '\u21B5',
- '\u222A',
- '\u00A4',
- '\u21D3',
- '\u2020',
- '\u2193',
- '\u00B0',
- '\u03B4',
- '\u2666',
- '\u00F7',
- '\u00E9',
- '\u00EA',
- '\u00E8',
- '\u2205',
- '\u2003',
- '\u2002',
- '\u03B5',
- '\u2261',
- '\u03B7',
- '\u00F0',
- '\u00EB',
- '\u20AC',
- '\u2203',
- '\u0192',
- '\u2200',
- '\u00BD',
- '\u00BC',
- '\u00BE',
- '\u2044',
- '\u03B3',
- '\u2265',
- '\u003E',
- '\u21D4',
- '\u2194',
- '\u2665',
- '\u2026',
- '\u00ED',
- '\u00EE',
- '\u00A1',
- '\u00EC',
- '\u2111',
- '\u221E',
- '\u222B',
- '\u03B9',
- '\u00BF',
- '\u2208',
- '\u00EF',
- '\u03BA',
- '\u21D0',
- '\u03BB',
- '\u2329',
- '\u00AB',
- '\u2190',
- '\u2308',
- '\u201C',
- '\u2264',
- '\u230A',
- '\u2217',
- '\u25CA',
- '\u200E',
- '\u2039',
- '\u2018',
- '\u003C',
- '\u00AF',
- '\u2014',
- '\u00B5',
- '\u00B7',
- '\u2212',
- '\u03BC',
- '\u2207',
- '\u00A0',
- '\u2013',
- '\u2260',
- '\u220B',
- '\u00AC',
- '\u2209',
- '\u2284',
- '\u00F1',
- '\u03BD',
- '\u00F3',
- '\u00F4',
- '\u0153',
- '\u00F2',
- '\u203E',
- '\u03C9',
- '\u03BF',
- '\u2295',
- '\u2228',
- '\u00AA',
- '\u00BA',
- '\u00F8',
- '\u00F5',
- '\u2297',
- '\u00F6',
- '\u00B6',
- '\u2202',
- '\u2030',
- '\u22A5',
- '\u03C6',
- '\u03C0',
- '\u03D6',
- '\u00B1',
- '\u00A3',
- '\u2032',
- '\u220F',
- '\u221D',
- '\u03C8',
- '\u0022',
- '\u21D2',
- '\u221A',
- '\u232A',
- '\u00BB',
- '\u2192',
- '\u2309',
- '\u201D',
- '\u211C',
- '\u00AE',
- '\u230B',
- '\u03C1',
- '\u200F',
- '\u203A',
- '\u2019',
- '\u201A',
- '\u0161',
- '\u22C5',
- '\u00A7',
- '\u00AD',
- '\u03C3',
- '\u03C2',
- '\u223C',
- '\u2660',
- '\u2282',
- '\u2286',
- '\u2211',
- '\u2283',
- '\u00B9',
- '\u00B2',
- '\u00B3',
- '\u2287',
- '\u00DF',
- '\u03C4',
- '\u2234',
- '\u03B8',
- '\u03D1',
- '\u2009',
- '\u00FE',
- '\u02DC',
- '\u00D7',
- '\u2122',
- '\u21D1',
- '\u00FA',
- '\u2191',
- '\u00FB',
- '\u00F9',
- '\u00A8',
- '\u03D2',
- '\u03C5',
- '\u00FC',
- '\u2118',
- '\u03BE',
- '\u00FD',
- '\u00A5',
- '\u00FF',
- '\u03B6',
- '\u200D',
- '\u200C'
- };
-
- static readonly char[] hexChars = new [] {
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- 'A',
- 'B',
- 'C',
- 'D',
- 'E',
- 'F'
- };
-
- #region Methods
-
- public static void HtmlAttributeEncode (string s, TextWriter output)
- {
- output.Write(HtmlAttributeEncode(s));
- }
-
- public static string HtmlAttributeEncode (string s)
- {
- if (null == s)
- return null;
-
- bool needEncode = false;
- for (int i = 0; i < s.Length; i++) {
- if (s [i] == '&' || s [i] == '"' || s [i] == '<') {
- needEncode = true;
- break;
- }
- }
-
- if (!needEncode)
- return s;
-
- StringBuilder output = new StringBuilder ();
- int len = s.Length;
- for (int i = 0; i < len; i++)
- switch (s [i]) {
- case '&' :
- output.Append ("&");
- break;
- case '"' :
- output.Append (""");
- break;
- case '<':
- output.Append ("<");
- break;
- default:
- output.Append (s [i]);
- break;
- }
-
- return output.ToString();
- }
-
- public static string UrlDecode (string str)
- {
- return UrlDecode(str, Encoding.UTF8);
- }
-
- static char [] GetChars (MemoryStream b, Encoding e)
- {
- return e.GetChars (b.GetBuffer (), 0, (int) b.Length);
- }
-
- static void WriteCharBytes (IList buf, char ch, Encoding e)
- {
- if (ch > 255) {
- foreach (byte b in e.GetBytes (new char[] { ch }))
- buf.Add (b);
- } else
- buf.Add ((byte)ch);
- }
-
- public static string UrlDecode (string s, Encoding e)
- {
- if (null == s)
- return null;
-
- if (s.IndexOf ('%') == -1 && s.IndexOf ('+') == -1)
- return s;
-
- if (e == null)
- e = Encoding.UTF8;
-
- long len = s.Length;
- var bytes = new List <byte> ();
- int xchar;
- char ch;
-
- for (int i = 0; i < len; i++) {
- ch = s [i];
- if (ch == '%' && i + 2 < len && s [i + 1] != '%') {
- if (s [i + 1] == 'u' && i + 5 < len) {
- // unicode hex sequence
- xchar = GetChar (s, i + 2, 4);
- if (xchar != -1) {
- WriteCharBytes (bytes, (char)xchar, e);
- i += 5;
- } else
- WriteCharBytes (bytes, '%', e);
- } else if ((xchar = GetChar (s, i + 1, 2)) != -1) {
- WriteCharBytes (bytes, (char)xchar, e);
- i += 2;
- } else {
- WriteCharBytes (bytes, '%', e);
- }
- continue;
- }
-
- if (ch == '+')
- WriteCharBytes (bytes, ' ', e);
- else
- WriteCharBytes (bytes, ch, e);
- }
-
- byte[] buf = bytes.ToArray ();
- bytes = null;
- return e.GetString (buf);
-
- }
-
- public static string UrlDecode (byte [] bytes, Encoding e)
- {
- if (bytes == null)
- return null;
-
- return UrlDecode (bytes, 0, bytes.Length, e);
- }
-
- static int GetInt (byte b)
- {
- char c = (char) b;
- if (c >= '0' && c <= '9')
- return c - '0';
-
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
-
- if (c >= 'A' && c <= 'F')
- return c - 'A' + 10;
-
- return -1;
- }
-
- static int GetChar (byte [] bytes, int offset, int length)
- {
- int value = 0;
- int end = length + offset;
- for (int i = offset; i < end; i++) {
- int current = GetInt (bytes [i]);
- if (current == -1)
- return -1;
- value = (value << 4) + current;
- }
-
- return value;
- }
-
- static int GetChar (string str, int offset, int length)
- {
- int val = 0;
- int end = length + offset;
- for (int i = offset; i < end; i++) {
- char c = str [i];
- if (c > 127)
- return -1;
-
- int current = GetInt ((byte) c);
- if (current == -1)
- return -1;
- val = (val << 4) + current;
- }
-
- return val;
- }
-
- public static string UrlDecode (byte [] bytes, int offset, int count, Encoding e)
- {
- if (bytes == null)
- return null;
- if (count == 0)
- return String.Empty;
-
- if (bytes == null)
- throw new ArgumentNullException ("bytes");
-
- if (offset < 0 || offset > bytes.Length)
- throw new ArgumentOutOfRangeException ("offset");
-
- if (count < 0 || offset + count > bytes.Length)
- throw new ArgumentOutOfRangeException ("count");
-
- StringBuilder output = new StringBuilder ();
- MemoryStream acc = new MemoryStream ();
-
- int end = count + offset;
- int xchar;
- for (int i = offset; i < end; i++) {
- if (bytes [i] == '%' && i + 2 < count && bytes [i + 1] != '%') {
- if (bytes [i + 1] == (byte) 'u' && i + 5 < end) {
- if (acc.Length > 0) {
- output.Append (GetChars (acc, e));
- acc.SetLength (0);
- }
- xchar = GetChar (bytes, i + 2, 4);
- if (xchar != -1) {
- output.Append ((char) xchar);
- i += 5;
- continue;
- }
- } else if ((xchar = GetChar (bytes, i + 1, 2)) != -1) {
- acc.WriteByte ((byte) xchar);
- i += 2;
- continue;
- }
- }
-
- if (acc.Length > 0) {
- output.Append (GetChars (acc, e));
- acc.SetLength (0);
- }
-
- if (bytes [i] == '+') {
- output.Append (' ');
- } else {
- output.Append ((char) bytes [i]);
- }
- }
-
- if (acc.Length > 0) {
- output.Append (GetChars (acc, e));
- }
-
- acc = null;
- return output.ToString ();
- }
-
- public static byte [] UrlDecodeToBytes (byte [] bytes)
- {
- if (bytes == null)
- return null;
-
- return UrlDecodeToBytes (bytes, 0, bytes.Length);
- }
-
- public static byte [] UrlDecodeToBytes (string str)
- {
- return UrlDecodeToBytes (str, Encoding.UTF8);
- }
-
- public static byte [] UrlDecodeToBytes (string str, Encoding e)
- {
- if (str == null)
- return null;
-
- if (e == null)
- throw new ArgumentNullException ("e");
-
- return UrlDecodeToBytes (e.GetBytes (str));
- }
-
- public static byte [] UrlDecodeToBytes (byte [] bytes, int offset, int count)
- {
- if (bytes == null)
- return null;
- if (count == 0)
- return new byte [0];
-
- int len = bytes.Length;
- if (offset < 0 || offset >= len)
- throw new ArgumentOutOfRangeException("offset");
-
- if (count < 0 || offset > len - count)
- throw new ArgumentOutOfRangeException("count");
-
- MemoryStream result = new MemoryStream ();
- int end = offset + count;
- for (int i = offset; i < end; i++){
- char c = (char) bytes [i];
- if (c == '+') {
- c = ' ';
- } else if (c == '%' && i < end - 2) {
- int xchar = GetChar (bytes, i + 1, 2);
- if (xchar != -1) {
- c = (char) xchar;
- i += 2;
- }
- }
- result.WriteByte ((byte) c);
- }
-
- return result.ToArray ();
- }
-
- public static string UrlEncode(string str)
- {
- return UrlEncode(str, Encoding.UTF8);
- }
-
- public static string UrlEncode (string s, Encoding Enc)
- {
- if (string.IsNullOrEmpty (s))
- return s;
-
- bool needEncode = false;
- int len = s.Length;
- for (int i = 0; i < len; i++) {
- char c = s [i];
- if ((c < '0') || (c < 'A' && c > '9') || (c > 'Z' && c < 'a') || (c > 'z')) {
- if (NotEncoded (c))
- continue;
-
- needEncode = true;
- break;
- }
- }
-
- if (!needEncode)
- return s;
-
- // avoided GetByteCount call
- byte [] bytes = new byte[Enc.GetMaxByteCount(s.Length)];
- int realLen = Enc.GetBytes (s, 0, s.Length, bytes, 0);
- return Encoding.ASCII.GetString (UrlEncodeToBytes (bytes, 0, realLen));
- }
-
- public static string UrlEncode (byte [] bytes)
- {
- if (bytes == null)
- return null;
-
- if (bytes.Length == 0)
- return "";
-
- return Encoding.ASCII.GetString (UrlEncodeToBytes (bytes, 0, bytes.Length));
- }
-
- public static string UrlEncode (byte [] bytes, int offset, int count)
- {
- if (bytes == null)
- return null;
-
- if (bytes.Length == 0)
- return "";
-
- return Encoding.ASCII.GetString (UrlEncodeToBytes (bytes, offset, count));
- }
-
- public static byte [] UrlEncodeToBytes (string str)
- {
- return UrlEncodeToBytes (str, Encoding.UTF8);
- }
-
- public static byte [] UrlEncodeToBytes (string str, Encoding e)
- {
- if (str == null)
- return null;
-
- if (str == "")
- return new byte [0];
-
- byte [] bytes = e.GetBytes (str);
- return UrlEncodeToBytes (bytes, 0, bytes.Length);
- }
-
- public static byte [] UrlEncodeToBytes (byte [] bytes)
- {
- if (bytes == null)
- return null;
-
- if (bytes.Length == 0)
- return new byte [0];
-
- return UrlEncodeToBytes (bytes, 0, bytes.Length);
- }
-
- static bool NotEncoded (char c)
- {
- return (c == '!' || c == '(' || c == ')' || c == '*' || c == '-' || c == '.' || c == '_');
- }
-
- static void UrlEncodeChar (char c, Stream result, bool isUnicode) {
- if (c > 255) {
- //FIXME: what happens when there is an internal error?
- //if (!isUnicode)
- // throw new ArgumentOutOfRangeException ("c", c, "c must be less than 256");
- int idx;
- int i = (int) c;
-
- result.WriteByte ((byte)'%');
- result.WriteByte ((byte)'u');
- idx = i >> 12;
- result.WriteByte ((byte)hexChars [idx]);
- idx = (i >> 8) & 0x0F;
- result.WriteByte ((byte)hexChars [idx]);
- idx = (i >> 4) & 0x0F;
- result.WriteByte ((byte)hexChars [idx]);
- idx = i & 0x0F;
- result.WriteByte ((byte)hexChars [idx]);
- return;
- }
-
- if (c > ' ' && NotEncoded (c)) {
- result.WriteByte ((byte)c);
- return;
- }
- if (c==' ') {
- result.WriteByte ((byte)'+');
- return;
- }
- if ( (c < '0') ||
- (c < 'A' && c > '9') ||
- (c > 'Z' && c < 'a') ||
- (c > 'z')) {
- if (isUnicode && c > 127) {
- result.WriteByte ((byte)'%');
- result.WriteByte ((byte)'u');
- result.WriteByte ((byte)'0');
- result.WriteByte ((byte)'0');
- }
- else
- result.WriteByte ((byte)'%');
-
- int idx = ((int) c) >> 4;
- result.WriteByte ((byte)hexChars [idx]);
- idx = ((int) c) & 0x0F;
- result.WriteByte ((byte)hexChars [idx]);
- }
- else
- result.WriteByte ((byte)c);
- }
-
- public static byte [] UrlEncodeToBytes (byte [] bytes, int offset, int count)
- {
- if (bytes == null)
- return null;
-
- int len = bytes.Length;
- if (len == 0)
- return new byte [0];
-
- if (offset < 0 || offset >= len)
- throw new ArgumentOutOfRangeException("offset");
-
- if (count < 0 || count > len - offset)
- throw new ArgumentOutOfRangeException("count");
-
- MemoryStream result = new MemoryStream (count);
- int end = offset + count;
- for (int i = offset; i < end; i++)
- UrlEncodeChar ((char)bytes [i], result, false);
-
- return result.ToArray();
- }
-
- public static string UrlEncodeUnicode (string str)
- {
- if (str == null)
- return null;
-
- return Encoding.ASCII.GetString (UrlEncodeUnicodeToBytes (str));
- }
-
- public static byte [] UrlEncodeUnicodeToBytes (string str)
- {
- if (str == null)
- return null;
-
- if (str == "")
- return new byte [0];
-
- MemoryStream result = new MemoryStream (str.Length);
- foreach (char c in str){
- UrlEncodeChar (c, result, true);
- }
- return result.ToArray ();
- }
-
- static bool TryConvertKeyToEntity (string key, out char value)
- {
- var token = CalculateKeyValue (key);
- if (token == 0) {
- value = '\0';
- return false;
- }
-
- var idx = Array.BinarySearch (entities, token);
- if (idx < 0) {
- value = '\0';
- return false;
- }
-
- value = entities_values [idx];
- return true;
- }
-
- static long CalculateKeyValue (string s)
- {
- if (s.Length > 8)
- return 0;
-
- long key = 0;
- for (int i = 0; i < s.Length; ++i) {
- long ch = s[i];
- if (ch > 'z' || ch < '0')
- return 0;
-
- key |= ch << ((7 - i) * 8);
- }
-
- return key;
- }
-
- /// <summary>
- /// Decodes an HTML-encoded string and returns the decoded string.
- /// </summary>
- /// <param name="s">The HTML string to decode. </param>
- /// <returns>The decoded text.</returns>
- public static string HtmlDecode (string s)
- {
- if (s == null)
- throw new ArgumentNullException ("s");
-
- if (s.IndexOf ('&') == -1)
- return s;
-
- StringBuilder entity = new StringBuilder ();
- StringBuilder output = new StringBuilder ();
- int len = s.Length;
- // 0 -> nothing,
- // 1 -> right after '&'
- // 2 -> between '&' and ';' but no '#'
- // 3 -> '#' found after '&' and getting numbers
- int state = 0;
- int number = 0;
- int digit_start = 0;
- bool hex_number = false;
-
- for (int i = 0; i < len; i++) {
- char c = s [i];
- if (state == 0) {
- if (c == '&') {
- entity.Append (c);
- state = 1;
- } else {
- output.Append (c);
- }
- continue;
- }
-
- if (c == '&') {
- state = 1;
- if (digit_start > 0) {
- entity.Append (s, digit_start, i - digit_start);
- digit_start = 0;
- }
-
- output.Append (entity.ToString ());
- entity.Length = 0;
- entity.Append ('&');
- continue;
- }
-
- switch (state) {
- case 1:
- if (c == ';') {
- state = 0;
- output.Append (entity.ToString ());
- output.Append (c);
- entity.Length = 0;
- break;
- }
-
- number = 0;
- hex_number = false;
- if (c != '#') {
- state = 2;
- } else {
- state = 3;
- }
- entity.Append (c);
-
- break;
- case 2:
- entity.Append (c);
- if (c == ';') {
- string key = entity.ToString ();
- state = 0;
- entity.Length = 0;
-
- if (key.Length > 1) {
- var skey = key.Substring (1, key.Length - 2);
- if (TryConvertKeyToEntity (skey, out c)) {
- output.Append (c);
- break;
- }
- }
-
- output.Append (key);
- }
-
- break;
- case 3:
- if (c == ';') {
- if (number < 0x10000) {
- output.Append ((char)number);
- } else {
- output.Append ((char)(0xd800 + ((number - 0x10000) >> 10)));
- output.Append ((char)(0xdc00 + ((number - 0x10000) & 0x3ff)));
- }
- state = 0;
- entity.Length = 0;
- digit_start = 0;
- break;
- }
-
- if (c == 'x' || c == 'X' && !hex_number) {
- digit_start = i;
- hex_number = true;
- break;
- }
-
- if (Char.IsDigit (c)) {
- if (digit_start == 0)
- digit_start = i;
-
- number = number * (hex_number ? 16 : 10) + ((int)c - '0');
- break;
- }
-
- if (hex_number) {
- if (c >= 'a' && c <= 'f') {
- number = number * 16 + 10 + ((int)c - 'a');
- break;
- }
- if (c >= 'A' && c <= 'F') {
- number = number * 16 + 10 + ((int)c - 'A');
- break;
- }
- }
-
- state = 2;
- if (digit_start > 0) {
- entity.Append (s, digit_start, i - digit_start);
- digit_start = 0;
- }
-
- entity.Append (c);
- break;
- }
- }
-
- if (entity.Length > 0) {
- output.Append (entity);
- } else if (digit_start > 0) {
- output.Append (s, digit_start, s.Length - digit_start);
- }
- return output.ToString ();
- }
-
- /// <summary>
- /// Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream.
- /// </summary>
- /// <param name="s">The HTML string to decode</param>
- /// <param name="output">The TextWriter output stream containing the decoded string. </param>
- public static void HtmlDecode(string s, TextWriter output)
- {
- if (s != null)
- output.Write (HtmlDecode (s));
- }
-
- /// <summary>
- /// HTML-encodes a string and returns the encoded string.
- /// </summary>
- /// <param name="s">The text string to encode. </param>
- /// <returns>The HTML-encoded text.</returns>
- public static string HtmlEncode (string s)
- {
- if (s == null)
- return null;
-
- bool needEncode = false;
- int i;
- for (i = 0; i < s.Length; i++) {
- char c = s [i];
- switch (c) {
- case '&':
- case '"':
- case '<':
- case '>':
- case '\'':
- needEncode = true;
- break;
- default:
- if (c > 159) {
- needEncode = true;
- break;
- }
-
- continue;
- }
-
- break;
- }
-
- if (!needEncode)
- return s;
-
- StringBuilder output = new StringBuilder (s, 0, i, s.Length * 2);
-
- for (; i < s.Length; i++) {
- var c = s [i];
- switch (c) {
- case '&' :
- output.Append ("&");
- break;
- case '>' :
- output.Append (">");
- break;
- case '<' :
- output.Append ("<");
- break;
- case '"' :
- output.Append (""");
- break;
- case '\'':
- output.Append ("'");
- break;
- default:
- // MS starts encoding with &# from 160 and stops at 255.
- // We don't do that. One reason is the 65308/65310 unicode
- // characters that look like '<' and '>'.
- if (c > 159) {
- output.Append ("&#");
- if (char.IsSurrogate (c))
- output.Append (char.ConvertToUtf32 (s, i++));
- else
- output.Append (((int) c).ToString (CultureInfo.InvariantCulture));
-
- output.Append (";");
- } else {
- output.Append (c);
- }
- break;
- }
- }
-
- return output.ToString ();
- }
-
- /// <summary>
- /// HTML-encodes a string and sends the resulting output to a TextWriter output stream.
- /// </summary>
- /// <param name="s">The string to encode. </param>
- /// <param name="output">The TextWriter output stream containing the encoded string. </param>
- public static void HtmlEncode(string s, TextWriter output)
- {
- if (s != null)
- output.Write (HtmlEncode (s));
- }
-
- public static string UrlPathEncode (string s)
- {
- if (s == null || s.Length == 0)
- return s;
-
- MemoryStream result = new MemoryStream ();
- int length = s.Length;
- for (int i = 0; i < length; i++) {
- UrlPathEncodeChar (s [i], result);
- }
- return Encoding.ASCII.GetString (result.ToArray ());
- }
-
- static void UrlPathEncodeChar (char c, Stream result)
- {
- if (c < 33 || c > 126) {
- byte [] bIn = Encoding.UTF8.GetBytes (c.ToString ());
- for (int i = 0; i < bIn.Length; i++) {
- result.WriteByte ((byte) '%');
- int idx = ((int) bIn [i]) >> 4;
- result.WriteByte ((byte) hexChars [idx]);
- idx = ((int) bIn [i]) & 0x0F;
- result.WriteByte ((byte) hexChars [idx]);
- }
- }
- else if (c == ' ') {
- result.WriteByte ((byte) '%');
- result.WriteByte ((byte) '2');
- result.WriteByte ((byte) '0');
- }
- else
- result.WriteByte ((byte) c);
- }
-
- public static NameValueCollection ParseQueryString (string query)
- {
- return ParseQueryString (query, Encoding.UTF8);
- }
-
- public static NameValueCollection ParseQueryString (string query, Encoding encoding)
- {
- if (query == null)
- throw new ArgumentNullException ("query");
- if (encoding == null)
- throw new ArgumentNullException ("encoding");
- if (query.Length == 0 || (query.Length == 1 && query[0] == '?'))
- return new NameValueCollection ();
- if (query[0] == '?')
- query = query.Substring (1);
-
- NameValueCollection result = new HttpQSCollection ();
- ParseQueryString (query, encoding, result);
- return result;
- }
-
- internal static void ParseQueryString (string query, Encoding encoding, NameValueCollection result)
- {
- if (query.Length == 0)
- return;
-
- string decoded = HtmlDecode (query);
- int decodedLength = decoded.Length;
- int namePos = 0;
- bool first = true;
- while (namePos <= decodedLength) {
- int valuePos = -1, valueEnd = -1;
- for (int q = namePos; q < decodedLength; q++) {
- if (valuePos == -1 && decoded [q] == '=') {
- valuePos = q + 1;
- } else if (decoded [q] == '&') {
- valueEnd = q;
- break;
- }
- }
-
- if (first) {
- first = false;
- if (decoded [namePos] == '?')
- namePos++;
- }
-
- string name, value;
- if (valuePos == -1) {
- name = null;
- valuePos = namePos;
- } else {
- name = UrlDecode (decoded.Substring (namePos, valuePos - namePos - 1), encoding);
- }
- if (valueEnd < 0) {
- namePos = -1;
- valueEnd = decoded.Length;
- } else {
- namePos = valueEnd + 1;
- }
- value = UrlDecode (decoded.Substring (valuePos, valueEnd - valuePos), encoding);
-
- result.Add (name, value);
- if (namePos == -1)
- break;
- }
- }
- #endregion // Methods
- }
-}
-
int readBufferOffset;
int readBufferSize;
int stream_length; // -1 when CL not present
- int contentLength;
- int totalRead;
+ long contentLength;
+ long totalRead;
internal long totalWritten;
bool nextReadCalled;
int pendingReads;
ReadAll ();
}
} catch {
- contentLength = Int32.MaxValue;
+ contentLength = Int64.MaxValue;
}
} else {
- contentLength = Int32.MaxValue;
+ contentLength = Int64.MaxValue;
}
// Negative numbers?
internal void ForceCompletion ()
{
if (!nextReadCalled) {
- if (contentLength == Int32.MaxValue)
+ if (contentLength == Int64.MaxValue)
contentLength = 0;
nextReadCalled = true;
cnc.NextRead ();
int diff = readBufferSize - readBufferOffset;
int new_size;
- if (contentLength == Int32.MaxValue) {
+ if (contentLength == Int64.MaxValue) {
MemoryStream ms = new MemoryStream ();
byte [] buffer = null;
if (readBuffer != null && diff > 0) {
new_size = (int) ms.Length;
contentLength = new_size;
} else {
- new_size = contentLength - totalRead;
+ new_size = (int) (contentLength - totalRead);
b = new byte [new_size];
if (readBuffer != null && diff > 0) {
if (diff > new_size)
if (cb != null)
cb = cb_wrapper;
- if (contentLength != Int32.MaxValue && contentLength - totalRead < size)
- size = contentLength - totalRead;
+ if (contentLength != Int64.MaxValue && contentLength - totalRead < size)
+ size = (int)(contentLength - totalRead);
if (!read_eof) {
result.InnerAsyncResult = cnc.BeginRead (request, buffer, offset, size, cb, result);
return;
if ((info & headerRestriction.Value) != 0)
- throw new ArgumentException ("This header must be modified with the appropiate property.");
+ throw new ArgumentException ("This header must be modified with the appropriate property.");
}
void CheckHeaderConsistency (HeaderInfo value)
+++ /dev/null
-//\r
-// System.Net.WebUtility\r
-//\r
-// Authors: Mike Kestner <mkestner@novell.com>\r
-// Marek Safar (marek.safar@gmail.com)\r
-//\r
-// Copyright (C) 2014 Xamarin Inc (http://www.xamarin.com)\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System;\r
-using System.IO;\r
-using System.Runtime.Serialization;\r
-\r
-namespace System.Net \r
-{\r
-\r
- public static class WebUtility \r
- {\r
- \r
- public static string HtmlDecode (string value)\r
- {\r
- if (string.IsNullOrEmpty (value))\r
- return value;\r
-\r
- return HttpUtility.HtmlDecode (value);\r
- }\r
- \r
- public static void HtmlDecode (string value, TextWriter output)\r
- {\r
- if (output == null)\r
- throw new ArgumentNullException ("output");\r
-\r
- output.Write (HtmlDecode (value));\r
- }\r
- \r
- public static string HtmlEncode (string value)\r
- {\r
- return HttpUtility.HtmlEncode (value);\r
- }\r
- \r
- public static void HtmlEncode (string value, TextWriter output)\r
- {\r
- if (output == null)\r
- throw new ArgumentNullException ("output");\r
-\r
- output.Write (HtmlEncode (value));\r
- }\r
- \r
- public static string UrlDecode (string encodedValue)\r
- {\r
- return HttpUtility.UrlDecode (encodedValue);\r
- }\r
- \r
- public static byte[] UrlDecodeToBytes (\r
- byte[] encodedValue, int offset, int count)\r
- {\r
- return HttpUtility.UrlDecodeToBytes (encodedValue, offset, count);\r
- }\r
- \r
- public static string UrlEncode (string value)\r
- {\r
- return HttpUtility.UrlEncode (value);\r
- }\r
- \r
- public static byte[] UrlEncodeToBytes (\r
- byte[] value, int offset, int count)\r
- {\r
- return HttpUtility.UrlEncodeToBytes (value, offset, count);\r
- }\r
- }\r
-}\r
System.Net/HttpResponseHeader.cs
System.Net/HttpStatusCode.cs
System.Net/HttpStreamAsyncResult.cs
-System.Net/HttpUtility.cs
System.Net/HttpVersion.cs
System.Net/HttpWebRequest.cs
System.Net/HttpWebResponse.cs
System.Net/WebRequest.cs
System.Net/WebRequestMethods.cs
System.Net/WebResponse.cs
-System.Net/WebUtility.cs
System.Net.WebSockets/ClientWebSocket.cs
System.Net.WebSockets/ClientWebSocketOptions.cs
System.Net.WebSockets/HttpListenerWebSocketContext.cs
../../../external/referencesource/System/net/System/Net/UnicodeEncodingConformance.cs
../../../external/referencesource/System/net/System/Net/webclient.cs
../../../external/referencesource/System/net/System/Net/WebPermission.cs
+../../../external/referencesource/System/net/System/Net/WebUtility.cs
../../../external/referencesource/System/net/System/Net/WriteStreamClosedEventArgs.cs
../../../external/referencesource/System/net/System/Net/NetworkInformation/IPInterfaceStatistics.cs
}
}
+ // When used instead of UriKind.RelativeOrAbsolute paths such as "/foo" are assumed relative.
+ const UriKind DotNetRelativeOrAbsolute = (UriKind) 300;
+
public Uri (string uriString, UriKind uriKind)
{
source = uriString;
+
+ if (uriString != null && uriKind == DotNetRelativeOrAbsolute)
+ uriKind = (uriString.StartsWith ("/", StringComparison.Ordinal))? UriKind.Relative : UriKind.RelativeOrAbsolute;
+
ParseUri (uriKind);
switch (uriKind) {
return;
}
+ if (uriKind == DotNetRelativeOrAbsolute)
+ uriKind = (uriString.StartsWith ("/", StringComparison.Ordinal))? UriKind.Relative : UriKind.RelativeOrAbsolute;
+
if (uriKind != UriKind.RelativeOrAbsolute &&
uriKind != UriKind.Absolute &&
uriKind != UriKind.Relative) {
Assert.AreEqual ("id=1%262&sort=asc", escaped, "UriEscaped");
}
+ // When used, paths such as "/foo" are assumed relative.
+ static UriKind DotNetRelativeOrAbsolute = (Type.GetType ("Mono.Runtime") == null)? UriKind.RelativeOrAbsolute : (UriKind) 300;
+
+ [Test]
+ public void DotNetRelativeOrAbsoluteTest ()
+ {
+ var uri1 = new Uri ("/foo", DotNetRelativeOrAbsolute);
+ Assert.IsFalse (uri1.IsAbsoluteUri);
+
+ Uri uri2;
+ Uri.TryCreate("/foo", DotNetRelativeOrAbsolute, out uri2);
+ Assert.IsFalse (uri2.IsAbsoluteUri);
+ }
+
[Test]
// Bug #12631
public void LocalPathWithBaseUrl ()
System.Net/HttpResponseHeader.cs
System.Net/HttpStatusCode.cs
System.Net/HttpStreamAsyncResult.cs
-System.Net/HttpUtility.cs
System.Net/HttpVersion.cs
System.Net/HttpWebRequest.cs
System.Net/HttpWebResponse.cs
System.Net/WebRequest.cs
System.Net/WebRequestMethods.cs
System.Net/WebResponse.cs
-System.Net/WebUtility.cs
System.Net.WebSockets/ClientWebSocket.cs
System.Net.WebSockets/ClientWebSocketOptions.cs
System.Net.WebSockets/HttpListenerWebSocketContext.cs
../../../external/referencesource/System/net/System/Net/cookieexception.cs
../../../external/referencesource/System/net/System/Net/HttpListenerRequestUriBuilder.cs
../../../external/referencesource/System/net/System/Net/Internal.cs
+../../../external/referencesource/System/net/System/Net/UnicodeDecodingConformance.cs
+../../../external/referencesource/System/net/System/Net/UnicodeEncodingConformance.cs
../../../external/referencesource/System/net/System/Net/webclient.cs
../../../external/referencesource/System/net/System/Net/WebPermission.cs
+../../../external/referencesource/System/net/System/Net/WebUtility.cs
../../../external/referencesource/System/net/System/Net/WriteStreamClosedEventArgs.cs
../../../external/referencesource/System/net/System/Net/NetworkInformation/IPInterfaceStatistics.cs
return frames;
}
- bool AddFrames (StringBuilder sb, bool isException = false)
+ bool AddFrames (StringBuilder sb)
{
bool printOffset;
string debugInfo, indentation;
string unknown = Locale.GetText ("<unknown method>");
- if (isException) {
- printOffset = true;
- indentation = " ";
- debugInfo = Locale.GetText (" in {0}:{1} ");
- } else {
- printOffset = false;
- indentation = " ";
- debugInfo = Locale.GetText (" in {0}:line {1}");
- }
+ indentation = " ";
+ debugInfo = Locale.GetText (" in {0}:{1} ");
var newline = String.Format ("{0}{1}{2} ", Environment.NewLine, indentation,
Locale.GetText ("at"));
string internal_name = frame.GetInternalMethodName ();
if (internal_name != null)
sb.Append (internal_name);
- else if (printOffset)
- sb.AppendFormat ("<0x{0:x5} + 0x{1:x5}> {2}", frame.GetMethodAddress (), frame.GetNativeOffset (), unknown);
else
- sb.AppendFormat (unknown);
+ sb.AppendFormat ("<0x{0:x5} + 0x{1:x5}> {2}", frame.GetMethodAddress (), frame.GetNativeOffset (), unknown);
} else {
GetFullNameForStackTrace (sb, frame.GetMethod ());
- if (printOffset) {
- if (frame.GetILOffset () == -1) {
- sb.AppendFormat (" <0x{0:x5} + 0x{1:x5}>", frame.GetMethodAddress (), frame.GetNativeOffset ());
- if (frame.GetMethodIndex () != 0xffffff)
- sb.AppendFormat (" {0}", frame.GetMethodIndex ());
- } else {
- sb.AppendFormat (" [0x{0:x5}]", frame.GetILOffset ());
- }
+ if (frame.GetILOffset () == -1) {
+ sb.AppendFormat (" <0x{0:x5} + 0x{1:x5}>", frame.GetMethodAddress (), frame.GetNativeOffset ());
+ if (frame.GetMethodIndex () != 0xffffff)
+ sb.AppendFormat (" {0}", frame.GetMethodIndex ());
+ } else {
+ sb.AppendFormat (" [0x{0:x5}]", frame.GetILOffset ());
}
sb.AppendFormat (debugInfo, frame.GetSecureFileName (),
//
if (captured_traces != null) {
foreach (var t in captured_traces) {
- if (!t.AddFrames (sb, true))
+ if (!t.AddFrames (sb))
continue;
sb.Append (Environment.NewLine);
/* documentation cases : https://msdn.microsoft.com/en-us/library/system.math.pow%28v=vs.110%29.aspx */
/* x or y = NaN -> NaN */
- Assert.IsNaN (Math.Pow ( double.NaN, double.NaN), "#1");
- Assert.IsNaN (Math.Pow ( double.NaN, double.NegativeInfinity), "#2");
- Assert.IsNaN (Math.Pow ( double.NaN, -2), "#2");
- Assert.IsNaN (Math.Pow ( double.NaN, -1), "#3");
- Assert.IsNaN (Math.Pow ( double.NaN, 0), "#4");
- Assert.IsNaN (Math.Pow ( double.NaN, 1), "#5");
- Assert.IsNaN (Math.Pow ( double.NaN, 2), "#6");
- Assert.IsNaN (Math.Pow ( double.NaN, double.PositiveInfinity), "#7");
- Assert.IsNaN (Math.Pow (double.NegativeInfinity, double.NaN), "#8");
- Assert.IsNaN (Math.Pow ( -2, double.NaN), "#9");
- Assert.IsNaN (Math.Pow ( -1, double.NaN), "#10");
- Assert.IsNaN (Math.Pow ( 0, double.NaN), "#11");
- Assert.IsNaN (Math.Pow ( 1, double.NaN), "#12");
- Assert.IsNaN (Math.Pow ( 2, double.NaN), "#13");
- Assert.IsNaN (Math.Pow (double.PositiveInfinity, double.NaN), "#14");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( double.NaN, double.NaN)), "#1");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( double.NaN, double.NegativeInfinity)), "#2");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( double.NaN, -2)), "#2");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( double.NaN, -1)), "#3");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( double.NaN, 0)), "#4");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( double.NaN, 1)), "#5");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( double.NaN, 2)), "#6");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( double.NaN, double.PositiveInfinity)), "#7");
+ Assert.IsTrue (double.IsNaN (Math.Pow (double.NegativeInfinity, double.NaN)), "#8");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( -2, double.NaN)), "#9");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( -1, double.NaN)), "#10");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( 0, double.NaN)), "#11");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( 1, double.NaN)), "#12");
+ Assert.IsTrue (double.IsNaN (Math.Pow ( 2, double.NaN)), "#13");
+ Assert.IsTrue (double.IsNaN (Math.Pow (double.PositiveInfinity, double.NaN)), "#14");
/* x = Any value except NaN; y = 0 -> 1 */
Assert.AreEqual ((double) 1, Math.Pow (2, 0), "#15");
Assert.AreEqual (double.PositiveInfinity, Math.Pow (double.NegativeInfinity, 2), "#18");
/* x < 0 but not NegativeInfinity; y is not an integer, NegativeInfinity, or PositiveInfinity -> NaN */
- Assert.IsNaN (Math.Pow (-1, 2.5), "#19");
+ Assert.IsTrue (double.IsNaN (Math.Pow (-1, 2.5)), "#19");
/* x = -1; y = NegativeInfinity or PositiveInfinity -> NaN */
- Assert.IsNaN (Math.Pow (-1, double.PositiveInfinity), "#20");
- Assert.IsNaN (Math.Pow (-1, double.NegativeInfinity), "#21");
+ Assert.IsTrue (double.IsNaN (Math.Pow (-1, double.PositiveInfinity)), "#20");
+ Assert.IsTrue (double.IsNaN (Math.Pow (-1, double.NegativeInfinity)), "#21");
/* -1 < x < 1; y = NegativeInfinity -> PositiveInfinity */
Assert.AreEqual (double.PositiveInfinity, Math.Pow (-0.5, double.NegativeInfinity), "#22");
var method = (MethodInfo) typeof (TimeZoneInfo).GetMember ("GetSystemTimeZones", MemberTypes.Method, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)[0];
var timeZones = (global::System.Collections.ObjectModel.ReadOnlyCollection<TimeZoneInfo>) method.Invoke (null, null);
- Assert.IsNotEmpty (timeZones);
+ Assert.IsTrue (timeZones.Count > 0, "GetSystemTimeZones should not return an empty collection.");
}
}
-// CS1904: `-1' is not a valid warning number
+// CS1904: `4013' is not a valid warning number
// Line: 0
-// Compiler options: -nowarn:1,-1
+// Compiler options: -nowarn:4014,4013
class ClassMain {
public static void Main () {}
continue;
if (mode == LookupMode.Normal)
- throw new NotImplementedException ();
+ continue;
return null;
}
{
bool valid = true;
foreach (string wid in text.Split (numeric_value_separator, StringSplitOptions.RemoveEmptyEntries)) {
+ var warning = wid;
+ if (warning.Length == 6 && warning [0] == 'C' && warning [1] == 'S')
+ warning = warning.Substring (2);
+
int id;
- if (!int.TryParse (wid, NumberStyles.AllowLeadingWhite, CultureInfo.InvariantCulture, out id)) {
- report.Error (1904, "`{0}' is not a valid warning number", wid);
- valid = false;
+ if (!int.TryParse (warning, NumberStyles.AllowLeadingWhite, CultureInfo.InvariantCulture, out id)) {
continue;
}
- if (report.CheckWarningCode (id, Location.Null))
+ if (report.CheckWarningCode (id, Location.Null)) {
action (id);
+ } else {
+ report.Error (1904, "`{0}' is not a valid warning number", wid);
+ valid = false;
+ }
}
return valid;
" -help Lists all compiler options (short: -?)\n" +
" -keycontainer:NAME The key pair container used to sign the output assembly\n" +
" -keyfile:FILE The key file used to strongname the ouput assembly\n" +
- " -langversion:TEXT Specifies language version: ISO-1, ISO-2, 3, 4, 5, Default or Future\n" +
+ " -langversion:TEXT Specifies language version: ISO-1, ISO-2, 3, 4, 5, Default or Experimental\n" +
" -lib:PATH1[,PATHn] Specifies the location of referenced assemblies\n" +
" -main:CLASS Specifies the class with the Main method (short: -m)\n" +
" -noconfig Disables implicitly referenced assemblies\n" +
--- /dev/null
+using static A;
+using static B;
+
+class A
+{
+ public class TestMe
+ {
+ }
+
+ public static int TestMe1 ()
+ {
+ return 0;
+ }
+}
+
+class B
+{
+ public static int TestMe2 ()
+ {
+ return 0;
+ }
+
+ public class TestMe1
+ {
+ }
+}
+
+class C
+{
+ public static void Main ()
+ {
+ new TestMe1 ();
+ }
+}
\ No newline at end of file
</method>
</type>
</test>
+ <test name="test-static-using-11.cs">
+ <type name="A">
+ <method name="Int32 TestMe1()" attrs="150">
+ <size>10</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="A+TestMe">
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="B">
+ <method name="Int32 TestMe2()" attrs="150">
+ <size>10</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="B+TestMe1">
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="C">
+ <method name="Void Main()" attrs="150">
+ <size>8</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-var-01.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
mkdir -p $(OUT_DIR); \
$(MCS) -debug $(TEST_CS) -out:$(TEST_EXE)
-check: all
+check: test-local
+
+test-local: all
$(BUILD_TEST_EXE)
@echo "Checking $(PROGRAM) without AOT"
$(CHECK_DIFF)
throw new Exception ("Stacktrace with 1 frame");
} catch (Exception e) {
Console.WriteLine (e);
+ Console.WriteLine ("Stacktrace:");
+ Console.WriteLine (new System.Diagnostics.StackTrace(e));
}
- try {
- ThrowException ("Stacktrace with 2 frames");
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ Catch (() => {throw new Exception ("Stacktrace with 2 frames");});
- try {
- ThrowException ("Stacktrace with 3 frames", 2);
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ Catch (() => ThrowException ("Stacktrace with 3 frames", 1));
- try {
+ Catch (() => ThrowException ("Stacktrace with 4 frames", 2));
+
+ Catch (() => {
var message = "Stack frame with method overload using ref parameter";
ThrowException (ref message);
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ });
- try {
+ Catch (() => {
int i;
ThrowException ("Stack frame with method overload using out parameter", out i);
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ });
- try {
- ThrowExceptionGeneric<double> ("Stack frame with 1 generic parameter");
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ Catch (() => ThrowExceptionGeneric<double> ("Stack frame with 1 generic parameter"));
- try {
- ThrowExceptionGeneric<double,string> ("Stack frame with 2 generic parameters");
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ Catch (() => ThrowExceptionGeneric<double,string> ("Stack frame with 2 generic parameters"));
- try {
- ThrowExceptionGeneric (12);
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ Catch (() => ThrowExceptionGeneric (12));
- try {
- InnerClass.ThrowException ("Stack trace with inner class");
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ Catch (() => InnerClass.ThrowException ("Stack trace with inner class"));
- try {
- InnerGenericClass<string>.ThrowException ("Stack trace with inner generic class");
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ Catch (() => InnerGenericClass<string>.ThrowException ("Stack trace with inner generic class"));
- try {
- InnerGenericClass<string>.ThrowException ("Stack trace with inner generic class and method generic parameter", "string");
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ Catch (() => InnerGenericClass<string>.ThrowException ("Stack trace with inner generic class and method generic parameter", "string"));
- try {
- InnerGenericClass<string>.ThrowException<string> ("Stack trace with inner generic class and generic overload", "string");
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ Catch (() => InnerGenericClass<string>.ThrowException<string> ("Stack trace with inner generic class and generic overload", "string"));
- try {
- InnerGenericClass<string>.InnerInnerGenericClass<int>.ThrowException ("Stack trace with 2 inner generic class and generic overload");
- } catch (Exception e) {
- Console.WriteLine (e);
- }
+ Catch (() => InnerGenericClass<string>.InnerInnerGenericClass<int>.ThrowException ("Stack trace with 2 inner generic class and generic overload"));
+ Catch (() => InnerGenericClass<int>.InnerInnerGenericClass<string>.ThrowException ("Stack trace with 2 inner generic class and generic overload"));
+ }
+
+ public static void Catch (Action action)
+ {
try {
- InnerGenericClass<int>.InnerInnerGenericClass<string>.ThrowException ("Stack trace with 2 inner generic class and generic overload");
+ action ();
} catch (Exception e) {
+ Console.WriteLine();
Console.WriteLine (e);
+ Console.WriteLine ("Stacktrace:");
+ Console.WriteLine (new System.Diagnostics.StackTrace (e));
}
}
System.Exception: Stacktrace with 1 frame
at StackTraceDumper.Main () in StackTraceDumper.cs:9
+Stacktrace:
+ at StackTraceDumper.Main () in StackTraceDumper.cs:9
+
System.Exception: Stacktrace with 2 frames
- at StackTraceDumper.ThrowException (System.String message) in StackTraceDumper.cs:97
- at StackTraceDumper.Main () in StackTraceDumper.cs:15
+ at StackTraceDumper.<Main>m__0 () in StackTraceDumper.cs:16
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper.<Main>m__0 () in StackTraceDumper.cs:16
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stacktrace with 3 frames
- at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:110
- at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:108
- at StackTraceDumper.Main () in StackTraceDumper.cs:21
+ at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:78
+ at StackTraceDumper.<Main>m__1 () in StackTraceDumper.cs:18
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:78
+ at StackTraceDumper.<Main>m__1 () in StackTraceDumper.cs:18
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
+System.Exception: Stacktrace with 4 frames
+ at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:78
+ at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:76
+ at StackTraceDumper.<Main>m__2 () in StackTraceDumper.cs:20
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:78
+ at StackTraceDumper.ThrowException (System.String message, Int32 i) in StackTraceDumper.cs:76
+ at StackTraceDumper.<Main>m__2 () in StackTraceDumper.cs:20
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stack frame with method overload using ref parameter
- at StackTraceDumper.ThrowException (System.String& message) in StackTraceDumper.cs:102
- at StackTraceDumper.Main () in StackTraceDumper.cs:28
+ at StackTraceDumper.ThrowException (System.String& message) in StackTraceDumper.cs:70
+ at StackTraceDumper.<Main>m__3 () in StackTraceDumper.cs:24
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper.ThrowException (System.String& message) in StackTraceDumper.cs:70
+ at StackTraceDumper.<Main>m__3 () in StackTraceDumper.cs:24
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stack frame with method overload using out parameter
- at StackTraceDumper.ThrowException (System.String message, System.Int32& o) in StackTraceDumper.cs:115
- at StackTraceDumper.Main () in StackTraceDumper.cs:35
+ at StackTraceDumper.ThrowException (System.String message, System.Int32& o) in StackTraceDumper.cs:83
+ at StackTraceDumper.<Main>m__4 () in StackTraceDumper.cs:29
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper.ThrowException (System.String message, System.Int32& o) in StackTraceDumper.cs:83
+ at StackTraceDumper.<Main>m__4 () in StackTraceDumper.cs:29
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stack frame with 1 generic parameter
- at StackTraceDumper.ThrowExceptionGeneric[T] (System.String message) in StackTraceDumper.cs:120
- at StackTraceDumper.Main () in StackTraceDumper.cs:41
+ at StackTraceDumper.ThrowExceptionGeneric[T] (System.String message) in StackTraceDumper.cs:88
+ at StackTraceDumper.<Main>m__5 () in StackTraceDumper.cs:32
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper.ThrowExceptionGeneric[T] (System.String message) in StackTraceDumper.cs:88
+ at StackTraceDumper.<Main>m__5 () in StackTraceDumper.cs:32
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stack frame with 2 generic parameters
- at StackTraceDumper.ThrowExceptionGeneric[T1,T2] (System.String message) in StackTraceDumper.cs:140
- at StackTraceDumper.Main () in StackTraceDumper.cs:47
+ at StackTraceDumper.ThrowExceptionGeneric[T1,T2] (System.String message) in StackTraceDumper.cs:108
+ at StackTraceDumper.<Main>m__6 () in StackTraceDumper.cs:34
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper.ThrowExceptionGeneric[T1,T2] (System.String message) in StackTraceDumper.cs:108
+ at StackTraceDumper.<Main>m__6 () in StackTraceDumper.cs:34
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stack frame with generic method overload
- at StackTraceDumper.ThrowExceptionGeneric[T] (T a1) in StackTraceDumper.cs:125
- at StackTraceDumper.Main () in StackTraceDumper.cs:53
+ at StackTraceDumper.ThrowExceptionGeneric[T] (T a1) in StackTraceDumper.cs:93
+ at StackTraceDumper.<Main>m__7 () in StackTraceDumper.cs:36
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper.ThrowExceptionGeneric[T] (T a1) in StackTraceDumper.cs:93
+ at StackTraceDumper.<Main>m__7 () in StackTraceDumper.cs:36
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stack trace with inner class
- at StackTraceDumper+InnerClass.ThrowException (System.String message) in StackTraceDumper.cs:146
- at StackTraceDumper.Main () in StackTraceDumper.cs:59
+ at StackTraceDumper+InnerClass.ThrowException (System.String message) in StackTraceDumper.cs:114
+ at StackTraceDumper.<Main>m__8 () in StackTraceDumper.cs:38
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper+InnerClass.ThrowException (System.String message) in StackTraceDumper.cs:114
+ at StackTraceDumper.<Main>m__8 () in StackTraceDumper.cs:38
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stack trace with inner generic class
- at StackTraceDumper+InnerGenericClass`1[T].ThrowException (System.String message) in StackTraceDumper.cs:153
- at StackTraceDumper.Main () in StackTraceDumper.cs:65
+ at StackTraceDumper+InnerGenericClass`1[T].ThrowException (System.String message) in StackTraceDumper.cs:121
+ at StackTraceDumper.<Main>m__9 () in StackTraceDumper.cs:40
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper+InnerGenericClass`1[T].ThrowException (System.String message) in StackTraceDumper.cs:121
+ at StackTraceDumper.<Main>m__9 () in StackTraceDumper.cs:40
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
Generic to string:string
+
System.Exception: Stack trace with inner generic class and method generic parameter
- at StackTraceDumper+InnerGenericClass`1[T].ThrowException (System.String message, T arg) in StackTraceDumper.cs:159
- at StackTraceDumper.Main () in StackTraceDumper.cs:71
+ at StackTraceDumper+InnerGenericClass`1[T].ThrowException (System.String message, T arg) in StackTraceDumper.cs:127
+ at StackTraceDumper.<Main>m__A () in StackTraceDumper.cs:42
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper+InnerGenericClass`1[T].ThrowException (System.String message, T arg) in StackTraceDumper.cs:127
+ at StackTraceDumper.<Main>m__A () in StackTraceDumper.cs:42
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stack trace with inner generic class and generic overload
- at StackTraceDumper+InnerGenericClass`1[T].ThrowException[T1] (System.String message, T1 arg) in StackTraceDumper.cs:164
- at StackTraceDumper.Main () in StackTraceDumper.cs:77
+ at StackTraceDumper+InnerGenericClass`1[T].ThrowException[T1] (System.String message, T1 arg) in StackTraceDumper.cs:132
+ at StackTraceDumper.<Main>m__B () in StackTraceDumper.cs:44
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper+InnerGenericClass`1[T].ThrowException[T1] (System.String message, T1 arg) in StackTraceDumper.cs:132
+ at StackTraceDumper.<Main>m__B () in StackTraceDumper.cs:44
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stack trace with 2 inner generic class and generic overload
- at StackTraceDumper+InnerGenericClass`1+InnerInnerGenericClass`1[T,T2].ThrowException (T message) in StackTraceDumper.cs:170
- at StackTraceDumper.Main () in StackTraceDumper.cs:83
+ at StackTraceDumper+InnerGenericClass`1+InnerInnerGenericClass`1[T,T2].ThrowException (T message) in StackTraceDumper.cs:138
+ at StackTraceDumper.<Main>m__C () in StackTraceDumper.cs:46
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper+InnerGenericClass`1+InnerInnerGenericClass`1[T,T2].ThrowException (T message) in StackTraceDumper.cs:138
+ at StackTraceDumper.<Main>m__C () in StackTraceDumper.cs:46
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+
System.Exception: Stack trace with 2 inner generic class and generic overload
- at StackTraceDumper+InnerGenericClass`1+InnerInnerGenericClass`1[T,T2].ThrowException (T2 message) in StackTraceDumper.cs:175
- at StackTraceDumper.Main () in StackTraceDumper.cs:89
+ at StackTraceDumper+InnerGenericClass`1+InnerInnerGenericClass`1[T,T2].ThrowException (T2 message) in StackTraceDumper.cs:143
+ at StackTraceDumper.<Main>m__D () in StackTraceDumper.cs:48
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
+Stacktrace:
+ at StackTraceDumper+InnerGenericClass`1+InnerInnerGenericClass`1[T,T2].ThrowException (T2 message) in StackTraceDumper.cs:143
+ at StackTraceDumper.<Main>m__D () in StackTraceDumper.cs:48
+ at StackTraceDumper.Catch (System.Action action) in StackTraceDumper.cs:54
char *path;
gunichar2 *proc_path;
+ size *= sizeof (gunichar2); /* adjust for unicode characters */
+
+ if (basename == NULL || size == 0)
+ return 0;
+
pid = GetProcessId (process);
path = wapi_process_get_path (pid);
return 0;
proc_path = mono_unicode_from_external (path, &bytes);
+ g_free (path);
+
if (proc_path == NULL)
return 0;
memcpy (basename, proc_path, bytes);
}
+ g_free (proc_path);
+
return len;
}
}
g_hash_table_destroy (name_cache2);
+
+ mono_image_lock (image);
if (image->name_cache) {
/* Somebody initialized it before us */
g_hash_table_destroy (the_name_cache);
mono_array_setref (arr, i, mono_array_get (temp_arr, MonoObject*, i));
}
- if (count == num_added) {
- arr = temp_arr;
- } else {
- /* shorter version of the array */
- arr = mono_array_new (mono_domain_get (), proc_class, num_added);
-
- for (i = 0; i < num_added; i++)
- mono_array_setref (arr, i, mono_array_get (temp_arr, MonoObject*, i));
- }
-
return arr;
}
INTERNAL_MEM_MAX
};
+static inline mword
+sgen_mono_array_size (GCVTable vtable, MonoArray *array, mword *bounds_size, mword descr)
+{
+ mword size, size_without_bounds;
+ int element_size;
+
+ if ((descr & DESC_TYPE_MASK) == DESC_TYPE_VECTOR)
+ element_size = ((descr) >> VECTOR_ELSIZE_SHIFT) & MAX_ELEMENT_SIZE;
+ else
+ element_size = vtable->klass->sizes.element_size;
+
+ size_without_bounds = size = sizeof (MonoArray) + element_size * mono_array_length_fast (array);
+
+ if (G_UNLIKELY (array->bounds)) {
+ size += sizeof (mono_array_size_t) - 1;
+ size &= ~(sizeof (mono_array_size_t) - 1);
+ size += sizeof (MonoArrayBounds) * vtable->klass->rank;
+ }
+
+ if (bounds_size)
+ *bounds_size = size - size_without_bounds;
+ return size;
+}
+
#define SGEN_CLIENT_OBJECT_HEADER_SIZE (sizeof (GCObject))
#define SGEN_CLIENT_MINIMUM_OBJECT_SIZE SGEN_CLIENT_OBJECT_HEADER_SIZE
if (klass == mono_defaults.string_class) {
return G_STRUCT_OFFSET (MonoString, chars) + 2 * mono_string_length_fast ((MonoString*) o) + 2;
} else if (klass->rank) {
- MonoArray *array = (MonoArray*)o;
- size_t size = sizeof (MonoArray) + klass->sizes.element_size * mono_array_length_fast (array);
- if (G_UNLIKELY (array->bounds)) {
- size += sizeof (mono_array_size_t) - 1;
- size &= ~(sizeof (mono_array_size_t) - 1);
- size += sizeof (MonoArrayBounds) * klass->rank;
- }
- return size;
+ return sgen_mono_array_size (vtable, (MonoArray*)o, NULL, 0);
} else {
/* from a created object: the class must be inited already */
return klass->instance_size;
} else if (descr == SGEN_DESC_STRING) {
return G_STRUCT_OFFSET (MonoString, chars) + 2 * mono_string_length_fast ((MonoString*) o) + 2;
} else if (type == DESC_TYPE_VECTOR) {
- int element_size = ((descr) >> VECTOR_ELSIZE_SHIFT) & MAX_ELEMENT_SIZE;
- MonoArray *array = (MonoArray*)o;
- size_t size = sizeof (MonoArray) + element_size * mono_array_length_fast (array);
-
- /*
- * Non-vector arrays with a single dimension whose lower bound is zero are
- * allocated without bounds.
- */
- if ((descr & VECTOR_KIND_ARRAY) && array->bounds) {
- size += sizeof (mono_array_size_t) - 1;
- size &= ~(sizeof (mono_array_size_t) - 1);
- size += sizeof (MonoArrayBounds) * ((MonoVTable*)vtable)->klass->rank;
- }
- return size;
+ return sgen_mono_array_size (vtable, (MonoArray*)o, NULL, descr);
}
return sgen_client_slow_object_get_size (vtable, o);
SGEN_ASSERT (0, SGEN_VTABLE_HAS_REFERENCES (vt), "Why would we ever call this on reference-free objects?");
if (vt->rank) {
+ MonoArray *arr = (MonoArray*)obj;
guint8 *card_data, *card_base;
guint8 *card_data_end;
char *obj_start = sgen_card_table_align_pointer (obj);
- mword obj_size = sgen_client_par_object_get_size (vt, obj);
- char *obj_end = (char*)obj + obj_size;
+ mword bounds_size;
+ mword obj_size = sgen_mono_array_size (vt, arr, &bounds_size, sgen_vtable_get_descriptor (vt));
+ /* We don't want to scan the bounds entries at the end of multidimensional arrays */
+ char *obj_end = (char*)obj + obj_size - bounds_size;
size_t card_count;
size_t extra_idx = 0;
- MonoArray *arr = (MonoArray*)obj;
mword desc = (mword)klass->element_class->gc_descr;
int elem_size = mono_array_element_size (klass);
static gboolean
poll_init (gint wakeup_pipe_fd)
{
- gint i;
+ g_assert (wakeup_pipe_fd >= 0);
- poll_fds_size = wakeup_pipe_fd + 1;
+ poll_fds_size = 1;
poll_fds_capacity = 64;
- while (wakeup_pipe_fd >= poll_fds_capacity)
- poll_fds_capacity *= 4;
-
poll_fds = g_new0 (mono_pollfd, poll_fds_capacity);
- for (i = 0; i < wakeup_pipe_fd; ++i)
- POLL_INIT_FD (&poll_fds [i], -1, 0);
-
- POLL_INIT_FD (&poll_fds [wakeup_pipe_fd], wakeup_pipe_fd, POLLIN);
+ POLL_INIT_FD (&poll_fds [0], wakeup_pipe_fd, POLLIN);
return TRUE;
}
poll_register_fd (gint fd, gint events, gboolean is_new)
{
gint i;
- mono_pollfd *poll_fd;
+ gint poll_event;
g_assert (fd >= 0);
g_assert (poll_fds_size <= poll_fds_capacity);
- if (fd >= poll_fds_capacity) {
- do {
- poll_fds_capacity *= 4;
- } while (fd >= poll_fds_capacity);
+ g_assert ((events & ~(EVENT_IN | EVENT_OUT)) == 0);
- poll_fds = g_renew (mono_pollfd, poll_fds, poll_fds_capacity);
+ poll_event = 0;
+ if (events & EVENT_IN)
+ poll_event |= POLLIN;
+ if (events & EVENT_OUT)
+ poll_event |= POLLOUT;
+
+ for (i = 0; i < poll_fds_size; ++i) {
+ if (poll_fds [i].fd == fd) {
+ g_assert (!is_new);
+ POLL_INIT_FD (&poll_fds [i], fd, poll_event);
+ return;
+ }
}
- if (fd >= poll_fds_size) {
- for (i = poll_fds_size; i <= fd; ++i)
- POLL_INIT_FD (&poll_fds [i], -1, 0);
+ g_assert (is_new);
- poll_fds_size = fd + 1;
+ for (i = 0; i < poll_fds_size; ++i) {
+ if (poll_fds [i].fd == -1) {
+ POLL_INIT_FD (&poll_fds [i], fd, poll_event);
+ return;
+ }
}
- poll_fd = &poll_fds [fd];
+ poll_fds_size += 1;
- if (poll_fd->fd != -1) {
- g_assert (poll_fd->fd == fd);
- g_assert (!is_new);
+ if (poll_fds_size > poll_fds_capacity) {
+ poll_fds_capacity *= 2;
+ g_assert (poll_fds_size <= poll_fds_capacity);
+
+ poll_fds = g_renew (mono_pollfd, poll_fds, poll_fds_capacity);
}
- POLL_INIT_FD (poll_fd, fd, ((events & EVENT_IN) ? POLLIN : 0) | ((events & EVENT_OUT) ? POLLOUT : 0));
+ POLL_INIT_FD (&poll_fds [poll_fds_size - 1], fd, poll_event);
}
static void
poll_remove_fd (gint fd)
{
- mono_pollfd *poll_fd;
+ gint i;
g_assert (fd >= 0);
- g_assert (fd < poll_fds_size);
- poll_fd = &poll_fds [fd];
+ for (i = 0; i < poll_fds_size; ++i) {
+ if (poll_fds [i].fd == fd) {
+ POLL_INIT_FD (&poll_fds [i], -1, 0);
+ break;
+ }
+ }
+
+ /* if we don't find the fd in poll_fds,
+ * it means we try to delete it twice */
+ g_assert (i < poll_fds_size);
+
+ /* if we find it again, it means we added
+ * it twice */
+ for (; i < poll_fds_size; ++i)
+ g_assert (poll_fds [i].fd != fd);
- g_assert (poll_fd->fd == fd);
- POLL_INIT_FD (poll_fd, -1, 0);
+ /* reduce the value of poll_fds_size so we
+ * do not keep it too big */
+ while (poll_fds_size > 1 && poll_fds [poll_fds_size - 1].fd == -1)
+ poll_fds_size -= 1;
}
static gint
#if !defined(HOST_WIN32)
ready = poll (poll_fds, poll_fds_size, -1);
#else
- ready = WSAPOLLFD (poll_fds, poll_fds_size, -1);
+ ready = WSAPoll(poll_fds, poll_fds_size, -1);
if (ready == SOCKET_ERROR)
ready = -1;
#endif
loadu4_mem: dest:i len:8
move: dest:i src1:i len:4
fmove: dest:f src1:f len:4
+move_f_to_i4: dest:i src1:f len:8
+move_i4_to_f: dest:f src1:i len:8
add_imm: dest:i src1:i len:4
sub_imm: dest:i src1:i len:4
mul_imm: dest:i src1:i len:4
* Store the invoke data into tls, the thread will execute it after it is
* resumed.
*/
- if (tls->pending_invoke)
+ if (tls->pending_invoke || tls->invoke)
return ERR_NOT_SUSPENDED;
tls->pending_invoke = g_new0 (InvokeData, 1);
tls->pending_invoke->id = id;
interface IFaceBox {
object box<T> (T t);
+ bool is_null<T> (T t);
}
class ClassBox : IFaceBox {
object o = t;
return o;
}
+
+ public bool is_null<T> (T t) {
+ if (!(default(T) == null))
+ return false;
+ return true;
+ }
}
public static int test_0_nullable_box () {
return 0;
}
+ public static int test_0_nullable_box_brtrue_opt () {
+ IFaceBox c = new ClassBox ();
+
+ if (c.is_null<double?> (null))
+ return 0;
+ else
+ return 1;
+ }
+
interface IFaceUnbox2 {
T unbox<T> (object o);
}
// FIXME: LLVM can't handle the inconsistent bb linking
if (!mono_class_is_nullable (klass) &&
+ !mini_is_gsharedvt_klass (klass) &&
ip + 5 < end && ip_in_bb (cfg, cfg->cbb, ip + 5) &&
(ip [5] == CEE_BRTRUE ||
ip [5] == CEE_BRTRUE_S ||
return code [0] == 0xe8;
}
+static inline gboolean
+amd64_use_imm32 (gint64 val)
+{
+ if (mini_get_debug_options()->single_imm_size)
+ return FALSE;
+
+ return amd64_is_imm32 (val);
+}
+
#ifdef __native_client_codegen__
/* Keep track of instruction "depth", that is, the level of sub-instruction */
break;
case OP_COMPARE_IMM:
case OP_LCOMPARE_IMM:
- if (!amd64_is_imm32 (ins->inst_imm)) {
+ if (!amd64_use_imm32 (ins->inst_imm)) {
NEW_INS (cfg, ins, temp, OP_I8CONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
#ifndef __native_client_codegen__
/* Don't generate memindex opcodes (to simplify */
/* read sandboxing) */
- if (!amd64_is_imm32 (ins->inst_offset)) {
+ if (!amd64_use_imm32 (ins->inst_offset)) {
NEW_INS (cfg, ins, temp, OP_I8CONST);
temp->inst_c0 = ins->inst_offset;
temp->dreg = mono_alloc_ireg (cfg);
case OP_STORE_MEMBASE_IMM:
#endif
case OP_STOREI8_MEMBASE_IMM:
- if (!amd64_is_imm32 (ins->inst_imm)) {
+ if (!amd64_use_imm32 (ins->inst_imm)) {
NEW_INS (cfg, ins, temp, OP_I8CONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
#endif
case OP_LOADI8_MEM:
// FIXME: Decompose this earlier
- if (amd64_is_imm32 (ins->inst_imm))
+ if (amd64_use_imm32 (ins->inst_imm))
amd64_mov_reg_mem (code, ins->dreg, ins->inst_imm, 8);
else {
- amd64_mov_reg_imm (code, ins->dreg, ins->inst_imm);
+ amd64_mov_reg_imm_size (code, ins->dreg, ins->inst_imm, sizeof(gpointer));
amd64_mov_reg_membase (code, ins->dreg, ins->dreg, 0, 8);
}
break;
break;
case OP_LOADU4_MEM:
// FIXME: Decompose this earlier
- if (amd64_is_imm32 (ins->inst_imm))
+ if (amd64_use_imm32 (ins->inst_imm))
amd64_mov_reg_mem (code, ins->dreg, ins->inst_imm, 4);
else {
- amd64_mov_reg_imm (code, ins->dreg, ins->inst_imm);
+ amd64_mov_reg_imm_size (code, ins->dreg, ins->inst_imm, sizeof(gpointer));
amd64_mov_reg_membase (code, ins->dreg, ins->dreg, 0, 4);
}
break;
case OP_ICONST:
case OP_I8CONST:
- if ((((guint64)ins->inst_c0) >> 32) == 0)
+ if ((((guint64)ins->inst_c0) >> 32) == 0 && !mini_get_debug_options()->single_imm_size)
amd64_mov_reg_imm_size (code, ins->dreg, ins->inst_c0, 4);
else
amd64_mov_reg_imm_size (code, ins->dreg, ins->inst_c0, 8);
gboolean
mono_arch_is_inst_imm (gint64 imm)
{
- return amd64_is_imm32 (imm);
+ return amd64_use_imm32 (imm);
}
/*
if (item->is_equals) {
if (item->check_target_idx) {
if (!item->compare_done) {
- if (amd64_is_imm32 (item->key))
+ if (amd64_use_imm32 ((gint64)item->key))
item->chunk_size += CMP_SIZE;
else
item->chunk_size += MOV_REG_IMM_SIZE + CMP_REG_REG_SIZE;
}
}
} else {
- if (amd64_is_imm32 (item->key))
+ if (amd64_use_imm32 ((gint64)item->key))
item->chunk_size += CMP_SIZE;
else
item->chunk_size += MOV_REG_IMM_SIZE + CMP_REG_REG_SIZE;
if (item->check_target_idx || fail_case) {
if (!item->compare_done || fail_case) {
- if (amd64_is_imm32 (item->key))
+ if (amd64_use_imm32 ((gint64)item->key))
amd64_alu_reg_imm_size (code, X86_CMP, MONO_ARCH_IMT_REG, (guint32)(gssize)item->key, sizeof(gpointer));
else {
- amd64_mov_reg_imm (code, MONO_ARCH_IMT_SCRATCH_REG, item->key);
+ amd64_mov_reg_imm_size (code, MONO_ARCH_IMT_SCRATCH_REG, item->key, sizeof(gpointer));
amd64_alu_reg_reg (code, X86_CMP, MONO_ARCH_IMT_REG, MONO_ARCH_IMT_SCRATCH_REG);
}
}
#endif
}
} else {
- if (amd64_is_imm32 (item->key))
+ if (amd64_use_imm32 ((gint64)item->key))
amd64_alu_reg_imm_size (code, X86_CMP, MONO_ARCH_IMT_REG, (guint32)(gssize)item->key, sizeof (gpointer));
else {
- amd64_mov_reg_imm (code, MONO_ARCH_IMT_SCRATCH_REG, item->key);
+ amd64_mov_reg_imm_size (code, MONO_ARCH_IMT_SCRATCH_REG, item->key, sizeof (gpointer));
amd64_alu_reg_reg (code, X86_CMP, MONO_ARCH_IMT_REG, MONO_ARCH_IMT_SCRATCH_REG);
}
item->jmp_code = code;
gboolean using_lldb = FALSE;
using_lldb = TRUE;
- /*
+
argv [0] = g_find_program_in_path ("gdb");
- if (!argv [0])
- using_lldb = TRUE;
- */
+ if (argv [0])
+ using_lldb = FALSE;
+
if (using_lldb)
argv [0] = g_find_program_in_path ("lldb");
*/
typedef struct {
LLVMModuleRef module;
- LLVMValueRef throw, rethrow, throw_corlib_exception;
+ LLVMValueRef throw, rethrow, throw_corlib_exception, state_poll;
GHashTable *llvm_types;
LLVMValueRef got_var;
const char *got_symbol;
case OP_DUMMY_USE:
break;
+ case OP_GC_SAFE_POINT: {
+ LLVMValueRef callee, cmp, val;
+ LLVMTypeRef llvm_sig;
+ const char *icall_name;
+ LLVMBasicBlockRef poll_bb, cont_bb;
+
+ poll_bb = gen_bb (ctx, "POLL_BB");
+ cont_bb = gen_bb (ctx, "NOPOLL_BB");
+
+ val = LLVMBuildLoad (ctx->builder, convert (ctx, lhs, LLVMPointerType (LLVMInt8Type (), 0)), "");
+ cmp = LLVMBuildICmp (builder, LLVMIntEQ, val, LLVMConstInt (LLVMTypeOf (val), 0, FALSE), "");
+ LLVMBuildCondBr (ctx->builder, cmp, cont_bb, poll_bb);
+
+ builder = ctx->builder = create_builder (ctx);
+ LLVMPositionBuilderAtEnd (builder, poll_bb);
+
+ MonoMethodSignature *sig = mono_metadata_signature_alloc (mono_get_corlib (), 0);
+ sig->ret = &mono_get_void_class ()->byval_arg;
+ icall_name = "mono_threads_state_poll";
+ llvm_sig = sig_to_llvm_sig (ctx, sig);
+
+ if (ctx->cfg->compile_aot) {
+ callee = ctx->lmodule->state_poll;
+ if (!callee) {
+ MonoMethodSignature *sig = mono_metadata_signature_alloc (mono_get_corlib (), 0);
+ sig->ret = &mono_get_void_class ()->byval_arg;
+ llvm_sig = sig_to_llvm_sig (ctx, sig);
+
+ callee = get_plt_entry (ctx, llvm_sig, MONO_PATCH_INFO_INTERNAL_METHOD, icall_name);
+ }
+ } else {
+ callee = ctx->lmodule->state_poll;
+ if (!callee) {
+ MonoMethodSignature *sig = mono_metadata_signature_alloc (mono_get_corlib (), 0);
+ sig->ret = &mono_get_void_class ()->byval_arg;
+ llvm_sig = sig_to_llvm_sig (ctx, sig);
+
+ callee = LLVMAddFunction (ctx->module, icall_name, llvm_sig);
+ LLVMAddGlobalMapping (ctx->lmodule->ee, callee, resolve_patch (ctx->cfg, MONO_PATCH_INFO_INTERNAL_METHOD, icall_name));
+ ctx->lmodule->state_poll = callee;
+ }
+ }
+ //
+ // FIXME: This can use the PreserveAll cconv to avoid clobbering registers.
+ // It requires the wrapper to also use that calling convention.
+ //
+ val = emit_call (ctx, bb, &builder, callee, NULL, 0);
+ LLVMBuildBr (builder, cont_bb);
+
+ builder = ctx->builder = create_builder (ctx);
+ LLVMPositionBuilderAtEnd (builder, cont_bb);
+
+ bblocks [bb->block_num].end_bblock = cont_bb;
+ break;
+ }
/*
* EXCEPTION HANDLING
if (ins->dreg != ins->sreg1)
ppc_fmr (code, ins->dreg, ins->sreg1);
break;
+ case OP_MOVE_F_TO_I4:
+ ppc_stfs (code, ins->sreg1, -4, ppc_r1);
+ ppc_ldptr (code, ins->dreg, -4, ppc_r1);
+ break;
+ case OP_MOVE_I4_TO_F:
+ ppc_stw (code, ins->sreg1, -4, ppc_r1);
+ ppc_lfs (code, ins->dreg, -4, ppc_r1);
+ break;
case OP_FCONV_TO_R4:
ppc_frsp (code, ins->dreg, ins->sreg1);
break;
debug_options.gen_sdb_seq_points = TRUE;
else if (!strcmp (arg, "gen-compact-seq-points"))
debug_options.gen_seq_points_compact_data = TRUE;
+ else if (!strcmp (arg, "single-imm-size"))
+ debug_options.single_imm_size = TRUE;
else if (!strcmp (arg, "init-stacks"))
debug_options.init_stacks = TRUE;
else if (!strcmp (arg, "casts"))
mono_align_small_structs = TRUE;
else {
fprintf (stderr, "Invalid option for the MONO_DEBUG env variable: %s\n", arg);
- fprintf (stderr, "Available options: 'handle-sigint', 'keep-delegates', 'reverse-pinvoke-exceptions', 'collect-pagefault-stats', 'break-on-unverified', 'no-gdb-backtrace', 'dont-free-domains', 'suspend-on-sigsegv', 'suspend-on-exception', 'suspend-on-unhandled', 'dyn-runtime-invoke', 'gdb', 'explicit-null-checks', 'init-stacks', 'check-pinvoke-callconv', 'arm-use-fallback-tls', 'debug-domain-unload', 'partial-sharing', 'align-small-structs'\n");
+ fprintf (stderr, "Available options: 'handle-sigint', 'keep-delegates', 'reverse-pinvoke-exceptions', 'collect-pagefault-stats', 'break-on-unverified', 'no-gdb-backtrace', 'suspend-on-sigsegv', 'suspend-on-exception', 'suspend-on-unhandled', 'dont-free-domains', 'dyn-runtime-invoke', 'gdb', 'explicit-null-checks', 'gen-seq-points', 'gen-compact-seq-points', 'single-imm-size', 'init-stacks', 'casts', 'soft-breakpoints', 'check-pinvoke-callconv', 'arm-use-fallback-tls', 'debug-domain-unload', 'partial-sharing', 'align-small-structs'\n");
exit (1);
}
}
{
mono_mutex_init_recursive (&mini_arch_mutex);
- bp_trampoline = mini_get_breakpoint_trampoline ();
+ if (!mono_aot_only)
+ bp_trampoline = mini_get_breakpoint_trampoline ();
mono_aot_register_jit_icall ("mono_x86_throw_exception", mono_x86_throw_exception);
mono_aot_register_jit_icall ("mono_x86_throw_corlib_exception", mono_x86_throw_corlib_exception);
return tramps;
}
-
-#if __APPLE__
-#define DBG_SIGNAL SIGBUS
-#else
-#define DBG_SIGNAL SIGSEGV
-#endif
-
/* Soft Debug support */
#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
if (cfg->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) {
WrapperInfo *info = mono_marshal_get_wrapper_info (cfg->method);
- if (info && info->subtype == WRAPPER_SUBTYPE_ICALL_WRAPPER && info->d.icall.func == mono_thread_interruption_checkpoint) {
+ if (info && info->subtype == WRAPPER_SUBTYPE_ICALL_WRAPPER &&
+ (info->d.icall.func == mono_thread_interruption_checkpoint ||
+ info->d.icall.func == mono_threads_finish_blocking ||
+ info->d.icall.func == mono_threads_reset_blocking_start)) {
/* These wrappers are called from the wrapper for the polling function, leading to potential stack overflow */
if (cfg->verbose_level > 1)
- printf ("SKIPPING SAFEPOINTS for the interruption checkpoint icall\n");
+ printf ("SKIPPING SAFEPOINTS for wrapper %s\n", cfg->method->name);
return;
}
}
*/
gboolean gen_sdb_seq_points;
gboolean gen_seq_points_compact_data;
+ /*
+ * Setting single_imm_size should guarantee that each time managed code is compiled
+ * the same instructions and registers are used, regardless of the size of used values.
+ */
+ gboolean single_imm_size;
gboolean explicit_null_checks;
/*
* Fill stack frames with 0x2a in method prologs. This helps with the
rm -rf *.exe..so *.exe.dylib *.exe.dylib.dSYM
}
+# The test compares the generated native code size between a compilation with and without seq points.
+# In some architectures ie:amd64 when possible 32bit instructions and registers are used instead of 64bit ones.
+# Using MONO_DEBUG=single-imm-size avoids 32bit optimizations thus mantaining the native code size between compilations.
+
get_methods () {
if [ -z $4 ]; then
MONO_PATH=$1 $2 -v --compile-all=1 $3 | grep '^Method .*code length' | sed 's/emitted[^()]*//' | sort
diff_methods () {
TMP_FILE=$(tmp_file)
- echo "$(get_methods $1 $2 $3 $4)" >$TMP_FILE
- diff <(cat $TMP_FILE) <(echo "$(MONO_DEBUG=gen-compact-seq-points get_methods $1 $2 $3 $4)")
+ echo "$(MONO_DEBUG=single-imm-size get_methods $1 $2 $3 $4)" >$TMP_FILE
+ diff <(cat $TMP_FILE) <(echo "$(MONO_DEBUG=gen-compact-seq-points,single-imm-size get_methods $1 $2 $3 $4)")
}
diff_method () {
TMP_FILE=$(tmp_file)
- echo "$(get_method $1 $2 $3 $4 $5)" >$TMP_FILE
- sdiff -w 150 <(cat $TMP_FILE) <(echo "$(MONO_DEBUG=gen-compact-seq-points get_method $1 $2 $3 $4 $5 | grep -Ev il_seq_point)")
+ echo "$(MONO_DEBUG=single-imm-size get_method $1 $2 $3 $4 $5)" >$TMP_FILE
+ sdiff -w 150 <(cat $TMP_FILE) <(echo "$(MONO_DEBUG=gen-compact-seq-points,single-imm-size get_method $1 $2 $3 $4 $5 | grep -Ev il_seq_point)")
}
get_method_name () {
x86_mov_membase_reg (code, X86_ESP, 0, X86_EAX, sizeof (mgreg_t));
if (aot) {
- g_assert_not_reached ();
+ x86_breakpoint (code);
} else {
if (single_step)
x86_call_code (code, debugger_agent_single_step_from_context);
* [pointer: sleb128] pointer of the metadata type depending on mtype
* if mtype == TYPE_CLASS
* [image: sleb128] MonoImage* as a pointer difference from ptr_base
- * [flags: uleb128] must be 0
+ * [flags: uleb128] must be 0
* [name: string] full class name
* if mtype == TYPE_IMAGE
- * [flags: uleb128] must be 0
+ * [flags: uleb128] must be 0
* [name: string] image file name
* if mtype == TYPE_ASSEMBLY
- * [flags: uleb128] must be 0
+ * [flags: uleb128] must be 0
* [name: string] assembly name
* if mtype == TYPE_DOMAIN
- * [flags: uleb128] must be 0
+ * [flags: uleb128] must be 0
* if mtype == TYPE_DOMAIN && exinfo == 0
* [name: string] domain friendly name
* if mtype == TYPE_CONTEXT
+ * [flags: uleb128] must be 0
* [domain: sleb128] domain id as pointer
* if mtype == TYPE_THREAD && (format_version < 11 || (format_version > 10 && exinfo == 0))
+ * [flags: uleb128] must be 0
* [name: string] thread name
*
* type method format:
#define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
void sgen_client_ ## method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6);
-#define FLUSH()
-
#define DEFAULT_PRINT()
#define CUSTOM_PRINT(_)
#define IS_VTABLE_MATCH(_)
#define END_PROTOCOL_ENTRY
+#define END_PROTOCOL_ENTRY_FLUSH
#define END_PROTOCOL_ENTRY_HEAVY
#include "sgen-protocol-def.h"
sgen_client_scan_thread_data (start_nursery, end_nursery, FALSE, ctx);
}
-static void
-unpin_objects_from_queue (SgenGrayQueue *queue)
-{
- for (;;) {
- GCObject *addr;
- SgenDescriptor desc;
- GRAY_OBJECT_DEQUEUE (queue, &addr, &desc);
- if (!addr)
- break;
- g_assert (SGEN_OBJECT_IS_PINNED (addr));
- SGEN_UNPIN_OBJECT (addr);
- }
-}
-
static void
single_arg_user_copy_or_mark (GCObject **obj, void *gc_data)
{
return needs_major;
}
-static void
-scan_nursery_objects_callback (GCObject *obj, size_t size, ScanCopyContext *ctx)
-{
- /*
- * This is called on all objects in the nursery, including pinned ones, so we need
- * to use sgen_obj_get_descriptor_safe(), which masks out the vtable tag bits.
- */
- ctx->ops->scan_object (obj, sgen_obj_get_descriptor_safe (obj), ctx->queue);
-}
-
-static void
-scan_nursery_objects (ScanCopyContext ctx)
-{
- sgen_scan_area_with_callback (nursery_section->data, nursery_section->end_data,
- (IterateObjectCallbackFunc)scan_nursery_objects_callback, (void*)&ctx, FALSE, TRUE);
-}
-
typedef enum {
COPY_OR_MARK_FROM_ROOTS_SERIAL,
COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT,
} CopyOrMarkFromRootsMode;
static void
-major_copy_or_mark_from_roots (size_t *old_next_pin_slot, CopyOrMarkFromRootsMode mode, gboolean scan_whole_nursery, SgenObjectOperations *object_ops)
+major_copy_or_mark_from_roots (size_t *old_next_pin_slot, CopyOrMarkFromRootsMode mode, SgenObjectOperations *object_ops)
{
LOSObject *bigobj;
TV_DECLARE (atv);
SGEN_ASSERT (0, !!concurrent == !!concurrent_collection_in_progress, "We've been called with the wrong mode.");
- if (scan_whole_nursery)
- SGEN_ASSERT (0, mode == COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT, "Scanning whole nursery only makes sense when we're finishing a concurrent collection.");
-
- if (concurrent) {
+ if (mode == COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT) {
/*This cleans up unused fragments */
sgen_nursery_allocator_prepare_for_pinning ();
SGEN_LOG (6, "Collecting pinned addresses");
pin_from_roots ((void*)lowest_heap_address, (void*)highest_heap_address, ctx);
- if (mode != COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT) {
- if (major_collector.is_concurrent) {
- /*
- * The concurrent major collector cannot evict
- * yet, so we need to pin cemented objects to
- * not break some asserts.
- *
- * FIXME: We could evict now!
- */
- sgen_pin_cemented_objects ();
- }
- }
-
sgen_optimize_pin_queue ();
sgen_client_collecting_major_1 ();
sgen_client_pinned_los_object (bigobj->data);
}
}
- /* second pass for the sections */
- /*
- * Concurrent mark never follows references into the nursery. In the start and
- * finish pauses we must scan live nursery objects, though.
- *
- * In the finish pause we do this conservatively by scanning all nursery objects.
- * Previously we would only scan pinned objects here. We assumed that all objects
- * that were pinned during the nursery collection immediately preceding this finish
- * mark would be pinned again here. Due to the way we get the stack end for the GC
- * thread, however, that's not necessarily the case: we scan part of the stack used
- * by the GC itself, which changes constantly, so pinning isn't entirely
- * deterministic.
- *
- * The split nursery also complicates things because non-pinned objects can survive
- * in the nursery. That's why we need to do a full scan of the nursery for it, too.
- *
- * In the future we shouldn't do a preceding nursery collection at all and instead
- * do the finish pause with promotion from the nursery.
- *
- * A further complication arises when we have late-pinned objects from the preceding
- * nursery collection. Those are the result of being out of memory when trying to
- * evacuate objects. They won't be found from the roots, so we just scan the whole
- * nursery.
- *
- * Non-concurrent mark evacuates from the nursery, so it's
- * sufficient to just scan pinned nursery objects.
- */
- if (scan_whole_nursery || mode == COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT || (concurrent && sgen_minor_collector.is_split)) {
- scan_nursery_objects (ctx);
- } else {
- pin_objects_in_nursery (concurrent, ctx);
- if (check_nursery_objects_pinned && !sgen_minor_collector.is_split)
- sgen_check_nursery_objects_pinned (mode != COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT);
- }
+ pin_objects_in_nursery (mode == COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT, ctx);
+ if (check_nursery_objects_pinned && !sgen_minor_collector.is_split)
+ sgen_check_nursery_objects_pinned (mode != COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT);
major_collector.pin_objects (WORKERS_DISTRIBUTE_GRAY_QUEUE);
if (old_next_pin_slot)
}
static void
-major_finish_copy_or_mark (void)
+major_finish_copy_or_mark (CopyOrMarkFromRootsMode mode)
{
- if (!concurrent_collection_in_progress)
- return;
-
- /*
- * Prepare the pin queue for the next collection. Since pinning runs on the worker
- * threads we must wait for the jobs to finish before we can reset it.
- */
- sgen_workers_wait_for_jobs_finished ();
- sgen_finish_pinning ();
+ switch (mode) {
+ case COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT:
+ /*
+ * Prepare the pin queue for the next collection. Since pinning runs on the worker
+ * threads we must wait for the jobs to finish before we can reset it.
+ */
+ sgen_workers_wait_for_jobs_finished ();
+ sgen_finish_pinning ();
- sgen_pin_stats_reset ();
+ sgen_pin_stats_reset ();
- if (do_concurrent_checks)
- sgen_debug_check_nursery_is_clean ();
+ if (do_concurrent_checks)
+ sgen_debug_check_nursery_is_clean ();
+ break;
+ case COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT:
+ sgen_workers_wait_for_jobs_finished ();
+ break;
+ case COPY_OR_MARK_FROM_ROOTS_SERIAL:
+ break;
+ default:
+ g_assert_not_reached ();
+ }
}
static void
g_assert (sgen_section_gray_queue_is_empty (sgen_workers_get_distribute_section_gray_queue ()));
- sgen_cement_reset ();
+ if (!concurrent)
+ sgen_cement_reset ();
if (concurrent) {
g_assert (major_collector.is_concurrent);
if (major_collector.start_major_collection)
major_collector.start_major_collection ();
- major_copy_or_mark_from_roots (old_next_pin_slot, concurrent ? COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT : COPY_OR_MARK_FROM_ROOTS_SERIAL, FALSE, object_ops);
- major_finish_copy_or_mark ();
+ major_copy_or_mark_from_roots (old_next_pin_slot, concurrent ? COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT : COPY_OR_MARK_FROM_ROOTS_SERIAL, object_ops);
+ major_finish_copy_or_mark (concurrent ? COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT : COPY_OR_MARK_FROM_ROOTS_SERIAL);
}
static void
-major_finish_collection (const char *reason, size_t old_next_pin_slot, gboolean forced, gboolean scan_whole_nursery)
+major_finish_collection (const char *reason, size_t old_next_pin_slot, gboolean forced)
{
ScannedObjectCounts counts;
SgenObjectOperations *object_ops;
+ mword fragment_total;
TV_DECLARE (atv);
TV_DECLARE (btv);
if (concurrent_collection_in_progress) {
object_ops = &major_collector.major_ops_concurrent_finish;
- major_copy_or_mark_from_roots (NULL, COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT, scan_whole_nursery, object_ops);
+ major_copy_or_mark_from_roots (NULL, COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT, object_ops);
- major_finish_copy_or_mark ();
+ major_finish_copy_or_mark (COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT);
sgen_workers_join ();
#ifdef SGEN_DEBUG_INTERNAL_ALLOC
main_gc_thread = NULL;
#endif
-
- if (do_concurrent_checks)
- sgen_debug_check_nursery_is_clean ();
} else {
- SGEN_ASSERT (0, !scan_whole_nursery, "scan_whole_nursery only applies to concurrent collections");
object_ops = &major_collector.major_ops_serial;
}
reset_heap_boundaries ();
sgen_update_heap_boundaries ((mword)sgen_get_nursery_start (), (mword)sgen_get_nursery_end ());
- if (!concurrent_collection_in_progress) {
- /* walk the pin_queue, build up the fragment list of free memory, unmark
- * pinned objects as we go, memzero() the empty fragments so they are ready for the
- * next allocations.
- */
- if (!sgen_build_nursery_fragments (nursery_section, NULL))
- degraded_mode = 1;
+ /* walk the pin_queue, build up the fragment list of free memory, unmark
+ * pinned objects as we go, memzero() the empty fragments so they are ready for the
+ * next allocations.
+ */
+ fragment_total = sgen_build_nursery_fragments (nursery_section, NULL);
+ if (!fragment_total)
+ degraded_mode = 1;
+ SGEN_LOG (4, "Free space in nursery after major %ld", fragment_total);
- /* prepare the pin queue for the next collection */
- sgen_finish_pinning ();
+ if (do_concurrent_checks && concurrent_collection_in_progress)
+ sgen_debug_check_nursery_is_clean ();
- /* Clear TLABs for all threads */
- sgen_clear_tlabs ();
+ /* prepare the pin queue for the next collection */
+ sgen_finish_pinning ();
- sgen_pin_stats_reset ();
- }
+ /* Clear TLABs for all threads */
+ sgen_clear_tlabs ();
+
+ sgen_pin_stats_reset ();
sgen_cement_clear_below_threshold ();
TV_GETTIME (time_start);
major_start_collection (FALSE, &old_next_pin_slot);
- major_finish_collection (reason, old_next_pin_slot, forced, FALSE);
+ major_finish_collection (reason, old_next_pin_slot, forced);
TV_GETTIME (time_end);
gc_stats.major_gc_time += TV_ELAPSED (time_start, time_end);
{
TV_DECLARE (total_start);
TV_DECLARE (total_end);
- gboolean late_pinned;
- SgenGrayQueue unpin_queue;
- memset (&unpin_queue, 0, sizeof (unpin_queue));
TV_GETTIME (total_start);
major_collector.update_cardtable_mod_union ();
sgen_los_update_cardtable_mod_union ();
- late_pinned = collect_nursery (&unpin_queue, TRUE);
-
if (mod_union_consistency_check)
sgen_check_mod_union_consistency ();
current_collection_generation = GENERATION_OLD;
- major_finish_collection ("finishing", -1, forced, late_pinned);
+ sgen_cement_reset ();
+ major_finish_collection ("finishing", -1, forced);
if (whole_heap_check_before_collection)
sgen_check_whole_heap (FALSE);
- unpin_objects_from_queue (&unpin_queue);
- sgen_gray_object_queue_deinit (&unpin_queue);
-
TV_GETTIME (total_end);
gc_stats.major_gc_time += TV_ELAPSED (total_start, total_end) - TV_ELAPSED (last_minor_collection_start_tv, last_minor_collection_end_tv);
{
SGEN_LOG (8, "Wbarrier store at %p to %p (%s)", ptr, value, value ? sgen_client_vtable_get_name (SGEN_LOAD_VTABLE (value)) : "null");
SGEN_UPDATE_REFERENCE_ALLOW_NULL (ptr, value);
- if (ptr_in_nursery (value))
+ if (ptr_in_nursery (value) || concurrent_collection_in_progress)
mono_gc_wbarrier_generic_nostore (ptr);
sgen_dummy_use (value);
}
InterlockedWritePointer (ptr, value);
- if (ptr_in_nursery (value))
+ if (ptr_in_nursery (value) || concurrent_collection_in_progress)
mono_gc_wbarrier_generic_nostore (ptr);
sgen_dummy_use (value);
sgen_nursery_size = DEFAULT_NURSERY_SIZE;
- if (major_collector.is_concurrent)
- cement_enabled = FALSE;
-
if (opts) {
gboolean usage_printed = FALSE;
alloc_nursery ();
- if (major_collector.is_concurrent && cement_enabled) {
- sgen_env_var_error (MONO_GC_PARAMS_NAME, "Ignoring.", "`cementing` is not supported on concurrent major collectors.");
- cement_enabled = FALSE;
- }
-
sgen_cement_init (cement_enabled);
if ((env = g_getenv (MONO_GC_DEBUG_NAME))) {
sgen_env_var_error (MONO_GC_DEBUG_NAME, "Ignoring.", "`check-concurrent` only works with concurrent major collectors.");
continue;
}
+ nursery_clear_policy = CLEAR_AT_GC;
do_concurrent_checks = TRUE;
} else if (!strcmp (opt, "dump-nursery-at-minor-gc")) {
do_dump_nursery_content = TRUE;
static int los_segment_index = 0;
#endif
+mword
+sgen_los_object_size (LOSObject *obj)
+{
+ return obj->size & ~1L;
+}
+
#ifdef LOS_CONSISTENCY_CHECK
static void
los_consistency_check (void)
mword memory_usage = 0;
for (obj = los_object_list; obj; obj = obj->next) {
- char *end = obj->data + obj->size;
+ mword obj_size = sgen_los_object_size (obj);
+ char *end = obj->data + obj_size;
int start_index, num_chunks;
- memory_usage += obj->size;
+ memory_usage += obj_size;
- if (obj->size > LOS_SECTION_OBJECT_LIMIT)
+ if (obj_size > LOS_SECTION_OBJECT_LIMIT)
continue;
section = LOS_SECTION_FOR_OBJ (obj);
g_assert (end <= (char*)section + LOS_SECTION_SIZE);
start_index = LOS_CHUNK_INDEX (obj, section);
- num_chunks = (obj->size + sizeof (LOSObject) + LOS_CHUNK_SIZE - 1) >> LOS_CHUNK_BITS;
+ num_chunks = (obj_size + sizeof (LOSObject) + LOS_CHUNK_SIZE - 1) >> LOS_CHUNK_BITS;
for (i = start_index; i < start_index + num_chunks; ++i)
g_assert (!section->free_chunk_map [i]);
}
SGEN_ASSERT (0, !obj->cardtable_mod_union, "We should never free a LOS object with a mod-union table.");
#ifndef LOS_DUMMY
- size_t size = obj->size;
- SGEN_LOG (4, "Freed large object %p, size %lu", obj->data, (unsigned long)obj->size);
- binary_protocol_empty (obj->data, obj->size);
+ mword size = sgen_los_object_size (obj);
+ SGEN_LOG (4, "Freed large object %p, size %lu", obj->data, (unsigned long)size);
+ binary_protocol_empty (obj->data, size);
los_memory_usage -= size;
los_num_objects--;
SGEN_ASSERT (0, !SGEN_OBJECT_IS_PINNED (bigobj->data), "Who pinned a LOS object?");
if (bigobj->cardtable_mod_union) {
- sgen_card_table_free_mod_union (bigobj->cardtable_mod_union, (char*)bigobj->data, bigobj->size);
+ sgen_card_table_free_mod_union (bigobj->cardtable_mod_union, (char*)bigobj->data, sgen_los_object_size (bigobj));
bigobj->cardtable_mod_union = NULL;
}
*start = NULL;
for (obj = los_object_list; obj; obj = obj->next) {
- char *end = (char*)obj->data + obj->size;
+ char *end = (char*)obj->data + sgen_los_object_size (obj);
if (ptr >= (char*)obj->data && ptr < end) {
*start = (char*)obj->data;
LOSObject *obj;
for (obj = los_object_list; obj; obj = obj->next)
- cb (obj->data, obj->size, user_data);
+ cb (obj->data, sgen_los_object_size (obj), user_data);
}
gboolean
mword size;
gboolean pinned;
- if ((char*)obj->data > ptr || (char*)obj->data + obj->size <= ptr)
+ if ((char*)obj->data > ptr || (char*)obj->data + sgen_los_object_size (obj) <= ptr)
continue;
size = sgen_los_object_size (obj);
for (obj = los_object_list; obj; obj = obj->next) {
GCVTable vt = SGEN_LOAD_VTABLE (obj->data);
if (SGEN_VTABLE_HAS_REFERENCES (vt))
- callback ((mword)obj->data, (mword)obj->size);
+ callback ((mword)obj->data, sgen_los_object_size (obj));
}
}
static guint8*
get_cardtable_mod_union_for_object (LOSObject *obj)
{
+ mword size = sgen_los_object_size (obj);
guint8 *mod_union = obj->cardtable_mod_union;
guint8 *other;
if (mod_union)
return mod_union;
- mod_union = sgen_card_table_alloc_mod_union ((char*)obj->data, obj->size);
+ mod_union = sgen_card_table_alloc_mod_union ((char*)obj->data, size);
other = SGEN_CAS_PTR ((gpointer*)&obj->cardtable_mod_union, mod_union, NULL);
if (!other) {
SGEN_ASSERT (0, obj->cardtable_mod_union == mod_union, "Why did CAS not replace?");
return mod_union;
}
- sgen_card_table_free_mod_union (mod_union, (char*)obj->data, obj->size);
+ sgen_card_table_free_mod_union (mod_union, (char*)obj->data, size);
return other;
}
cards = NULL;
}
- sgen_cardtable_scan_object (obj->data, obj->size, cards, mod_union, ctx);
+ sgen_cardtable_scan_object (obj->data, sgen_los_object_size (obj), cards, mod_union, ctx);
}
}
for (obj = los_object_list; obj; obj = obj->next) {
int i;
guint8 *cards = sgen_card_table_get_card_scan_address ((mword) obj->data);
- guint8 *cards_end = sgen_card_table_get_card_scan_address ((mword) obj->data + obj->size - 1);
+ guint8 *cards_end = sgen_card_table_get_card_scan_address ((mword) obj->data + sgen_los_object_size (obj) - 1);
mword num_cards = (cards_end - cards) + 1;
if (!SGEN_OBJECT_HAS_REFERENCES (obj->data))
if (!SGEN_OBJECT_HAS_REFERENCES (obj->data))
continue;
sgen_card_table_update_mod_union (get_cardtable_mod_union_for_object (obj),
- (char*)obj->data, obj->size, NULL);
+ (char*)obj->data, sgen_los_object_size (obj), NULL);
}
}
-mword
-sgen_los_object_size (LOSObject *obj)
-{
- return obj->size & ~1L;
-}
-
LOSObject*
sgen_los_header_for_object (GCObject *data)
{
major_scan_object_no_mark_concurrent_anywhere (start, desc, queue);
}
-#undef ADD_TO_GLOBAL_REMSET
-#define ADD_TO_GLOBAL_REMSET(object,ptr,target) sgen_add_to_global_remset ((ptr), (target))
+#undef HANDLE_PTR
+#define HANDLE_PTR(ptr,obj) do { \
+ void *__old = *(ptr); \
+ binary_protocol_scan_process_reference ((obj), (ptr), __old); \
+ if (__old) { \
+ gboolean __still_in_nursery = major_copy_or_mark_object_no_evacuation ((ptr), __old, queue); \
+ if (G_UNLIKELY (__still_in_nursery && !sgen_ptr_in_nursery ((ptr)) && !SGEN_OBJECT_IS_CEMENTED (*(ptr)))) { \
+ void *__copy = *(ptr); \
+ sgen_add_to_global_remset ((ptr), __copy); \
+ } \
+ } \
+ } while (0)
+
static void
major_scan_vtype_concurrent_finish (GCObject *full_object, char *start, SgenDescriptor desc, SgenGrayQueue *queue BINARY_PROTOCOL_ARG (size_t size))
static GCObject*
major_alloc_degraded (GCVTable vtable, size_t size)
{
- GCObject *obj = alloc_obj (vtable, size, FALSE, SGEN_VTABLE_HAS_REFERENCES (vtable));
+ GCObject *obj;
+
+ major_finish_sweep_checking ();
+
+ obj = alloc_obj (vtable, size, FALSE, SGEN_VTABLE_HAS_REFERENCES (vtable));
if (G_LIKELY (obj)) {
HEAVY_STAT (++stat_objects_alloced_degraded);
HEAVY_STAT (stat_bytes_alloced_degraded += size);
END_PROTOCOL_ENTRY
BEGIN_PROTOCOL_ENTRY2 (binary_protocol_collection_begin, TYPE_INT, index, TYPE_INT, generation)
-FLUSH ()
DEFAULT_PRINT ()
IS_ALWAYS_MATCH (TRUE)
MATCH_INDEX (BINARY_PROTOCOL_MATCH)
IS_VTABLE_MATCH (FALSE)
-END_PROTOCOL_ENTRY
+END_PROTOCOL_ENTRY_FLUSH
BEGIN_PROTOCOL_ENTRY4 (binary_protocol_collection_end, TYPE_INT, index, TYPE_INT, generation, TYPE_LONGLONG, num_scanned_objects, TYPE_LONGLONG, num_unique_scanned_objects)
-FLUSH()
CUSTOM_PRINT (printf ("%d generation %d scanned %lld unique %lld %0.2f%%", entry->index, entry->generation, entry->num_scanned_objects, entry->num_unique_scanned_objects, entry->num_unique_scanned_objects ? (100.0 * (double) entry->num_scanned_objects / (double) entry->num_unique_scanned_objects) : 0.0))
IS_ALWAYS_MATCH (TRUE)
MATCH_INDEX (BINARY_PROTOCOL_MATCH)
IS_VTABLE_MATCH (FALSE)
-END_PROTOCOL_ENTRY
+END_PROTOCOL_ENTRY_FLUSH
BEGIN_PROTOCOL_ENTRY0 (binary_protocol_concurrent_start)
DEFAULT_PRINT ()
#undef BEGIN_PROTOCOL_ENTRY_HEAVY5
#undef BEGIN_PROTOCOL_ENTRY_HEAVY6
-#undef FLUSH
-
#undef DEFAULT_PRINT
#undef CUSTOM_PRINT
#undef IS_VTABLE_MATCH
#undef END_PROTOCOL_ENTRY
+#undef END_PROTOCOL_ENTRY_FLUSH
#undef END_PROTOCOL_ENTRY_HEAVY
int __size = sizeof (PROTOCOL_STRUCT(method)); \
CLIENT_PROTOCOL_NAME (method) (f1, f2, f3, f4, f5, f6);
-#define FLUSH() \
- binary_protocol_flush_buffers (FALSE);
-
#define DEFAULT_PRINT()
#define CUSTOM_PRINT(_)
protocol_entry (__type, __data, __size); \
}
+#define END_PROTOCOL_ENTRY_FLUSH \
+ protocol_entry (__type, __data, __size); \
+ binary_protocol_flush_buffers (FALSE); \
+ }
+
#ifdef SGEN_HEAVY_BINARY_PROTOCOL
#define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
BEGIN_PROTOCOL_ENTRY0 (method)
#define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
#define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
-#define FLUSH()
-
#define DEFAULT_PRINT()
#define CUSTOM_PRINT(_)
#define IS_VTABLE_MATCH(_)
#define END_PROTOCOL_ENTRY
+#define END_PROTOCOL_ENTRY_FLUSH
#define END_PROTOCOL_ENTRY_HEAVY
#include "sgen-protocol-def.h"
#define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
-#define FLUSH()
-
#define DEFAULT_PRINT()
#define CUSTOM_PRINT(_)
#define IS_VTABLE_MATCH(_)
#define END_PROTOCOL_ENTRY
+#define END_PROTOCOL_ENTRY_FLUSH
#define END_PROTOCOL_ENTRY_HEAVY
#include "sgen-protocol-def.h"
static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6) {}
#endif
-#define FLUSH()
-
#define DEFAULT_PRINT()
#define CUSTOM_PRINT(_)
#define IS_VTABLE_MATCH(_)
#define END_PROTOCOL_ENTRY
+#define END_PROTOCOL_ENTRY_FLUSH
#define END_PROTOCOL_ENTRY_HEAVY
#include "sgen-protocol-def.h"
if (a1->A != 42)
return 8;
- if (!fabs (a1->B - 3.1415) < 0.001)
+ if (!(fabs (a1->B - 3.1415) < 0.001))
return 9;
break;
if (a1->A != 42)
return 5;
- if (!fabs (a1->B - 3.1415) < 0.001)
+ if (!(fabs (a1->B - 3.1415) < 0.001))
return 6;
break;
mono-threads-openbsd.c \
mono-threads-android.c \
mono-threads.h \
+ mono-threads-api.h \
mono-threads-coop.c \
mono-threads-coop.h \
mono-tls.h \
--- /dev/null
+/*
+ * mono-threads-api.h: Low level access to thread state.
+ *
+ * Author:
+ * Rodrigo Kumpera (kumpera@gmail.com)
+ *
+ * (C) 2015 Xamarin
+ */
+
+#ifndef __MONO_THREADS_API_H__
+#define __MONO_THREADS_API_H__
+
+#include <mono/utils/mono-publib.h>
+MONO_BEGIN_DECLS
+
+/*
+>>>> WARNING WARNING WARNING <<<<
+
+This API is experimental. It will eventually be required to properly use the rest of the raw-omp embedding API.
+*/
+
+/* Don't use those directly, use the MONO_(BEGIN|END)_EFRAME */
+MONO_API void* mono_threads_enter_gc_unsafe_region (void);
+MONO_API void mono_threads_exit_gc_unsafe_region (void *region_cookie);
+
+/*
+Use those macros to limit regions of code that interact with managed memory or use the embedding API.
+This will put the current thread in GC Unsafe mode.
+
+For further explanation of what can and can't be done in GC unsafe mode:
+http://www.mono-project.com/docs/advanced/runtime/docs/coop-suspend/#gc-unsafe-mode
+
+*/
+#define MONO_BEGIN_EFRAME { void *__region_cookie = mono_threads_enter_gc_unsafe_region ();
+#define MONO_END_EFRAME mono_threads_exit_gc_unsafe_region (__region_cookie); }
+
+
+MONO_END_DECLS
+
+#endif /* __MONO_LOGGER_H__ */
mono_polling_required = 0;
}
+void*
+mono_threads_enter_gc_unsafe_region (void)
+{
+ return mono_threads_reset_blocking_start ();
+}
+
+void
+mono_threads_exit_gc_unsafe_region (void *regions_cookie)
+{
+ mono_threads_reset_blocking_end (regions_cookie);
+}
+
+#else
+
+void*
+mono_threads_enter_gc_unsafe_region (void)
+{
+ return NULL;
+}
+
+void
+mono_threads_exit_gc_unsafe_region (void *regions_cookie)
+{
+}
#endif
\ No newline at end of file
#include <mono/utils/mono-mutex.h>
#include <mono/utils/mono-tls.h>
#include <mono/utils/mono-threads-coop.h>
+#include <mono/utils/mono-threads-api.h>
#include <glib.h>
#include <config.h>
serial.c \
sys-mman.c \
sys-sendfile.c \
+ sys-socket.c \
sys-stat.c \
sys-statvfs.c \
sys-time.c \
--impl-macro=_GNU_SOURCE --impl-macro=_XOPEN_SOURCE \
--impl-header="<sys/types.h>" \
--impl-header="<sys/stat.h>" \
+ --autoconf-header="<netinet/in.h>" \
--autoconf-header="<sys/time.h>" \
--autoconf-header="<sys/poll.h>" \
--autoconf-header="<sys/wait.h>" \
--autoconf-header="<sys/statvfs.h>" \
--autoconf-header="<sys/xattr.h>" \
--autoconf-header="<sys/mman.h>" \
+ --autoconf-header="<sys/socket.h>" \
--autoconf-header="<sys/uio.h>" \
--autoconf-header="<unistd.h>" \
--impl-header="<fcntl.h>" \
--rename-member=st_mtime=st_mtime_ \
--rename-namespace=Mono.Unix.Native=Mono.Posix \
--library=MonoPosixHelper \
- $(mcs_topdir)/class/lib/net_4_5/Mono.Posix.dll map
+ $(mcs_topdir)/class/lib/net_4_x/Mono.Posix.dll map
# Useful if mono is compiled with --enable-shared=no
patch-libtool:
* we assume that the XPG version is present.
*/
-#ifdef _GNU_SOURCE && !PLATFORM_ANDROID
+#ifdef _GNU_SOURCE
#define mph_min(x,y) ((x) <= (y) ? (x) : (y))
/* If you pass an invalid errno value to glibc 2.3.2's strerror_r, you get
/*
- * This file was automatically generated by create-native-map from /cvs/mono/mcs/class/lib/net_4_5/Mono.Posix.dll.
+ * This file was automatically generated by create-native-map from /home/kiesssn/prog/mono/mono/mcs/class/lib/net_4_x/Mono.Posix.dll.
*
* DO NOT MODIFY.
*/
*/
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif /* ndef HAVE_NETINET_IN_H */
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif /* ndef HAVE_SYS_TIME_H */
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif /* ndef HAVE_SYS_MMAN_H */
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif /* ndef HAVE_SYS_SOCKET_H */
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif /* ndef HAVE_SYS_UIO_H */
#endif /* ndef HAVE_STRUCT_IOVEC */
+#ifdef HAVE_STRUCT_LINGER
+int
+Mono_Posix_FromLinger (struct Mono_Posix_Linger *from, struct linger *to)
+{
+ _cnm_return_val_if_overflow (int, from->l_onoff, -1);
+ _cnm_return_val_if_overflow (int, from->l_linger, -1);
+
+ memset (to, 0, sizeof(*to));
+
+ to->l_onoff = from->l_onoff;
+ to->l_linger = from->l_linger;
+
+ return 0;
+}
+#endif /* ndef HAVE_STRUCT_LINGER */
+
+
+#ifdef HAVE_STRUCT_LINGER
+int
+Mono_Posix_ToLinger (struct linger *from, struct Mono_Posix_Linger *to)
+{
+ _cnm_return_val_if_overflow (int, from->l_onoff, -1);
+ _cnm_return_val_if_overflow (int, from->l_linger, -1);
+
+ memset (to, 0, sizeof(*to));
+
+ to->l_onoff = from->l_onoff;
+ to->l_linger = from->l_linger;
+
+ return 0;
+}
+#endif /* ndef HAVE_STRUCT_LINGER */
+
+
int Mono_Posix_FromLockType (short x, short *r)
{
*r = 0;
errno = EINVAL; return -1;
}
+int Mono_Posix_FromMessageFlags (int x, int *r)
+{
+ *r = 0;
+ if ((x & Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC) == Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC)
+#ifdef MSG_CMSG_CLOEXEC
+ *r |= MSG_CMSG_CLOEXEC;
+#else /* def MSG_CMSG_CLOEXEC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_CMSG_CLOEXEC */
+ if ((x & Mono_Posix_MessageFlags_MSG_CONFIRM) == Mono_Posix_MessageFlags_MSG_CONFIRM)
+#ifdef MSG_CONFIRM
+ *r |= MSG_CONFIRM;
+#else /* def MSG_CONFIRM */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_CONFIRM */
+ if ((x & Mono_Posix_MessageFlags_MSG_CTRUNC) == Mono_Posix_MessageFlags_MSG_CTRUNC)
+#ifdef MSG_CTRUNC
+ *r |= MSG_CTRUNC;
+#else /* def MSG_CTRUNC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_CTRUNC */
+ if ((x & Mono_Posix_MessageFlags_MSG_DONTROUTE) == Mono_Posix_MessageFlags_MSG_DONTROUTE)
+#ifdef MSG_DONTROUTE
+ *r |= MSG_DONTROUTE;
+#else /* def MSG_DONTROUTE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_DONTROUTE */
+ if ((x & Mono_Posix_MessageFlags_MSG_DONTWAIT) == Mono_Posix_MessageFlags_MSG_DONTWAIT)
+#ifdef MSG_DONTWAIT
+ *r |= MSG_DONTWAIT;
+#else /* def MSG_DONTWAIT */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_DONTWAIT */
+ if ((x & Mono_Posix_MessageFlags_MSG_EOR) == Mono_Posix_MessageFlags_MSG_EOR)
+#ifdef MSG_EOR
+ *r |= MSG_EOR;
+#else /* def MSG_EOR */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_EOR */
+ if ((x & Mono_Posix_MessageFlags_MSG_ERRQUEUE) == Mono_Posix_MessageFlags_MSG_ERRQUEUE)
+#ifdef MSG_ERRQUEUE
+ *r |= MSG_ERRQUEUE;
+#else /* def MSG_ERRQUEUE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_ERRQUEUE */
+ if ((x & Mono_Posix_MessageFlags_MSG_FASTOPEN) == Mono_Posix_MessageFlags_MSG_FASTOPEN)
+#ifdef MSG_FASTOPEN
+ *r |= MSG_FASTOPEN;
+#else /* def MSG_FASTOPEN */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_FASTOPEN */
+ if ((x & Mono_Posix_MessageFlags_MSG_FIN) == Mono_Posix_MessageFlags_MSG_FIN)
+#ifdef MSG_FIN
+ *r |= MSG_FIN;
+#else /* def MSG_FIN */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_FIN */
+ if ((x & Mono_Posix_MessageFlags_MSG_MORE) == Mono_Posix_MessageFlags_MSG_MORE)
+#ifdef MSG_MORE
+ *r |= MSG_MORE;
+#else /* def MSG_MORE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_MORE */
+ if ((x & Mono_Posix_MessageFlags_MSG_NOSIGNAL) == Mono_Posix_MessageFlags_MSG_NOSIGNAL)
+#ifdef MSG_NOSIGNAL
+ *r |= MSG_NOSIGNAL;
+#else /* def MSG_NOSIGNAL */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_NOSIGNAL */
+ if ((x & Mono_Posix_MessageFlags_MSG_OOB) == Mono_Posix_MessageFlags_MSG_OOB)
+#ifdef MSG_OOB
+ *r |= MSG_OOB;
+#else /* def MSG_OOB */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_OOB */
+ if ((x & Mono_Posix_MessageFlags_MSG_PEEK) == Mono_Posix_MessageFlags_MSG_PEEK)
+#ifdef MSG_PEEK
+ *r |= MSG_PEEK;
+#else /* def MSG_PEEK */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_PEEK */
+ if ((x & Mono_Posix_MessageFlags_MSG_PROXY) == Mono_Posix_MessageFlags_MSG_PROXY)
+#ifdef MSG_PROXY
+ *r |= MSG_PROXY;
+#else /* def MSG_PROXY */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_PROXY */
+ if ((x & Mono_Posix_MessageFlags_MSG_RST) == Mono_Posix_MessageFlags_MSG_RST)
+#ifdef MSG_RST
+ *r |= MSG_RST;
+#else /* def MSG_RST */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_RST */
+ if ((x & Mono_Posix_MessageFlags_MSG_SYN) == Mono_Posix_MessageFlags_MSG_SYN)
+#ifdef MSG_SYN
+ *r |= MSG_SYN;
+#else /* def MSG_SYN */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_SYN */
+ if ((x & Mono_Posix_MessageFlags_MSG_TRUNC) == Mono_Posix_MessageFlags_MSG_TRUNC)
+#ifdef MSG_TRUNC
+ *r |= MSG_TRUNC;
+#else /* def MSG_TRUNC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_TRUNC */
+ if ((x & Mono_Posix_MessageFlags_MSG_WAITALL) == Mono_Posix_MessageFlags_MSG_WAITALL)
+#ifdef MSG_WAITALL
+ *r |= MSG_WAITALL;
+#else /* def MSG_WAITALL */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_WAITALL */
+ if ((x & Mono_Posix_MessageFlags_MSG_WAITFORONE) == Mono_Posix_MessageFlags_MSG_WAITFORONE)
+#ifdef MSG_WAITFORONE
+ *r |= MSG_WAITFORONE;
+#else /* def MSG_WAITFORONE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef MSG_WAITFORONE */
+ if (x == 0)
+ return 0;
+ return 0;
+}
+
+int Mono_Posix_ToMessageFlags (int x, int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+#ifdef MSG_CMSG_CLOEXEC
+ if ((x & MSG_CMSG_CLOEXEC) == MSG_CMSG_CLOEXEC)
+ *r |= Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC;
+#endif /* ndef MSG_CMSG_CLOEXEC */
+#ifdef MSG_CONFIRM
+ if ((x & MSG_CONFIRM) == MSG_CONFIRM)
+ *r |= Mono_Posix_MessageFlags_MSG_CONFIRM;
+#endif /* ndef MSG_CONFIRM */
+#ifdef MSG_CTRUNC
+ if ((x & MSG_CTRUNC) == MSG_CTRUNC)
+ *r |= Mono_Posix_MessageFlags_MSG_CTRUNC;
+#endif /* ndef MSG_CTRUNC */
+#ifdef MSG_DONTROUTE
+ if ((x & MSG_DONTROUTE) == MSG_DONTROUTE)
+ *r |= Mono_Posix_MessageFlags_MSG_DONTROUTE;
+#endif /* ndef MSG_DONTROUTE */
+#ifdef MSG_DONTWAIT
+ if ((x & MSG_DONTWAIT) == MSG_DONTWAIT)
+ *r |= Mono_Posix_MessageFlags_MSG_DONTWAIT;
+#endif /* ndef MSG_DONTWAIT */
+#ifdef MSG_EOR
+ if ((x & MSG_EOR) == MSG_EOR)
+ *r |= Mono_Posix_MessageFlags_MSG_EOR;
+#endif /* ndef MSG_EOR */
+#ifdef MSG_ERRQUEUE
+ if ((x & MSG_ERRQUEUE) == MSG_ERRQUEUE)
+ *r |= Mono_Posix_MessageFlags_MSG_ERRQUEUE;
+#endif /* ndef MSG_ERRQUEUE */
+#ifdef MSG_FASTOPEN
+ if ((x & MSG_FASTOPEN) == MSG_FASTOPEN)
+ *r |= Mono_Posix_MessageFlags_MSG_FASTOPEN;
+#endif /* ndef MSG_FASTOPEN */
+#ifdef MSG_FIN
+ if ((x & MSG_FIN) == MSG_FIN)
+ *r |= Mono_Posix_MessageFlags_MSG_FIN;
+#endif /* ndef MSG_FIN */
+#ifdef MSG_MORE
+ if ((x & MSG_MORE) == MSG_MORE)
+ *r |= Mono_Posix_MessageFlags_MSG_MORE;
+#endif /* ndef MSG_MORE */
+#ifdef MSG_NOSIGNAL
+ if ((x & MSG_NOSIGNAL) == MSG_NOSIGNAL)
+ *r |= Mono_Posix_MessageFlags_MSG_NOSIGNAL;
+#endif /* ndef MSG_NOSIGNAL */
+#ifdef MSG_OOB
+ if ((x & MSG_OOB) == MSG_OOB)
+ *r |= Mono_Posix_MessageFlags_MSG_OOB;
+#endif /* ndef MSG_OOB */
+#ifdef MSG_PEEK
+ if ((x & MSG_PEEK) == MSG_PEEK)
+ *r |= Mono_Posix_MessageFlags_MSG_PEEK;
+#endif /* ndef MSG_PEEK */
+#ifdef MSG_PROXY
+ if ((x & MSG_PROXY) == MSG_PROXY)
+ *r |= Mono_Posix_MessageFlags_MSG_PROXY;
+#endif /* ndef MSG_PROXY */
+#ifdef MSG_RST
+ if ((x & MSG_RST) == MSG_RST)
+ *r |= Mono_Posix_MessageFlags_MSG_RST;
+#endif /* ndef MSG_RST */
+#ifdef MSG_SYN
+ if ((x & MSG_SYN) == MSG_SYN)
+ *r |= Mono_Posix_MessageFlags_MSG_SYN;
+#endif /* ndef MSG_SYN */
+#ifdef MSG_TRUNC
+ if ((x & MSG_TRUNC) == MSG_TRUNC)
+ *r |= Mono_Posix_MessageFlags_MSG_TRUNC;
+#endif /* ndef MSG_TRUNC */
+#ifdef MSG_WAITALL
+ if ((x & MSG_WAITALL) == MSG_WAITALL)
+ *r |= Mono_Posix_MessageFlags_MSG_WAITALL;
+#endif /* ndef MSG_WAITALL */
+#ifdef MSG_WAITFORONE
+ if ((x & MSG_WAITFORONE) == MSG_WAITFORONE)
+ *r |= Mono_Posix_MessageFlags_MSG_WAITFORONE;
+#endif /* ndef MSG_WAITFORONE */
+ return 0;
+}
+
int Mono_Posix_FromMlockallFlags (int x, int *r)
{
*r = 0;
errno = EINVAL; return -1;
}
+int Mono_Posix_FromShutdownOption (int x, int *r)
+{
+ *r = 0;
+ if (x == Mono_Posix_ShutdownOption_SHUT_RD)
+#ifdef SHUT_RD
+ {*r = SHUT_RD; return 0;}
+#else /* def SHUT_RD */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SHUT_RD */
+ if (x == Mono_Posix_ShutdownOption_SHUT_RDWR)
+#ifdef SHUT_RDWR
+ {*r = SHUT_RDWR; return 0;}
+#else /* def SHUT_RDWR */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SHUT_RDWR */
+ if (x == Mono_Posix_ShutdownOption_SHUT_WR)
+#ifdef SHUT_WR
+ {*r = SHUT_WR; return 0;}
+#else /* def SHUT_WR */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SHUT_WR */
+ if (x == 0)
+ return 0;
+ errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToShutdownOption (int x, int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+#ifdef SHUT_RD
+ if (x == SHUT_RD)
+ {*r = Mono_Posix_ShutdownOption_SHUT_RD; return 0;}
+#endif /* ndef SHUT_RD */
+#ifdef SHUT_RDWR
+ if (x == SHUT_RDWR)
+ {*r = Mono_Posix_ShutdownOption_SHUT_RDWR; return 0;}
+#endif /* ndef SHUT_RDWR */
+#ifdef SHUT_WR
+ if (x == SHUT_WR)
+ {*r = Mono_Posix_ShutdownOption_SHUT_WR; return 0;}
+#endif /* ndef SHUT_WR */
+ errno = EINVAL; return -1;
+}
+
int Mono_Posix_FromSignum (int x, int *r)
{
*r = 0;
#endif /* ndef HAVE_STRUCT_TIMEZONE */
+int Mono_Posix_FromUnixAddressFamily (int x, int *r)
+{
+ *r = 0;
+ if (x == Mono_Posix_UnixAddressFamily_AF_ALG)
+#ifdef AF_ALG
+ {*r = AF_ALG; return 0;}
+#else /* def AF_ALG */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_ALG */
+ if (x == Mono_Posix_UnixAddressFamily_AF_APPLETALK)
+#ifdef AF_APPLETALK
+ {*r = AF_APPLETALK; return 0;}
+#else /* def AF_APPLETALK */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_APPLETALK */
+ if (x == Mono_Posix_UnixAddressFamily_AF_ASH)
+#ifdef AF_ASH
+ {*r = AF_ASH; return 0;}
+#else /* def AF_ASH */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_ASH */
+ if (x == Mono_Posix_UnixAddressFamily_AF_ATMPVC)
+#ifdef AF_ATMPVC
+ {*r = AF_ATMPVC; return 0;}
+#else /* def AF_ATMPVC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_ATMPVC */
+ if (x == Mono_Posix_UnixAddressFamily_AF_ATMSVC)
+#ifdef AF_ATMSVC
+ {*r = AF_ATMSVC; return 0;}
+#else /* def AF_ATMSVC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_ATMSVC */
+ if (x == Mono_Posix_UnixAddressFamily_AF_AX25)
+#ifdef AF_AX25
+ {*r = AF_AX25; return 0;}
+#else /* def AF_AX25 */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_AX25 */
+ if (x == Mono_Posix_UnixAddressFamily_AF_BLUETOOTH)
+#ifdef AF_BLUETOOTH
+ {*r = AF_BLUETOOTH; return 0;}
+#else /* def AF_BLUETOOTH */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_BLUETOOTH */
+ if (x == Mono_Posix_UnixAddressFamily_AF_BRIDGE)
+#ifdef AF_BRIDGE
+ {*r = AF_BRIDGE; return 0;}
+#else /* def AF_BRIDGE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_BRIDGE */
+ if (x == Mono_Posix_UnixAddressFamily_AF_CAIF)
+#ifdef AF_CAIF
+ {*r = AF_CAIF; return 0;}
+#else /* def AF_CAIF */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_CAIF */
+ if (x == Mono_Posix_UnixAddressFamily_AF_CAN)
+#ifdef AF_CAN
+ {*r = AF_CAN; return 0;}
+#else /* def AF_CAN */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_CAN */
+ if (x == Mono_Posix_UnixAddressFamily_AF_DECnet)
+#ifdef AF_DECnet
+ {*r = AF_DECnet; return 0;}
+#else /* def AF_DECnet */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_DECnet */
+ if (x == Mono_Posix_UnixAddressFamily_AF_ECONET)
+#ifdef AF_ECONET
+ {*r = AF_ECONET; return 0;}
+#else /* def AF_ECONET */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_ECONET */
+ if (x == Mono_Posix_UnixAddressFamily_AF_IEEE802154)
+#ifdef AF_IEEE802154
+ {*r = AF_IEEE802154; return 0;}
+#else /* def AF_IEEE802154 */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_IEEE802154 */
+ if (x == Mono_Posix_UnixAddressFamily_AF_INET)
+#ifdef AF_INET
+ {*r = AF_INET; return 0;}
+#else /* def AF_INET */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_INET */
+ if (x == Mono_Posix_UnixAddressFamily_AF_INET6)
+#ifdef AF_INET6
+ {*r = AF_INET6; return 0;}
+#else /* def AF_INET6 */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_INET6 */
+ if (x == Mono_Posix_UnixAddressFamily_AF_IPX)
+#ifdef AF_IPX
+ {*r = AF_IPX; return 0;}
+#else /* def AF_IPX */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_IPX */
+ if (x == Mono_Posix_UnixAddressFamily_AF_IRDA)
+#ifdef AF_IRDA
+ {*r = AF_IRDA; return 0;}
+#else /* def AF_IRDA */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_IRDA */
+ if (x == Mono_Posix_UnixAddressFamily_AF_ISDN)
+#ifdef AF_ISDN
+ {*r = AF_ISDN; return 0;}
+#else /* def AF_ISDN */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_ISDN */
+ if (x == Mono_Posix_UnixAddressFamily_AF_IUCV)
+#ifdef AF_IUCV
+ {*r = AF_IUCV; return 0;}
+#else /* def AF_IUCV */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_IUCV */
+ if (x == Mono_Posix_UnixAddressFamily_AF_KEY)
+#ifdef AF_KEY
+ {*r = AF_KEY; return 0;}
+#else /* def AF_KEY */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_KEY */
+ if (x == Mono_Posix_UnixAddressFamily_AF_LLC)
+#ifdef AF_LLC
+ {*r = AF_LLC; return 0;}
+#else /* def AF_LLC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_LLC */
+ if (x == Mono_Posix_UnixAddressFamily_AF_NETBEUI)
+#ifdef AF_NETBEUI
+ {*r = AF_NETBEUI; return 0;}
+#else /* def AF_NETBEUI */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_NETBEUI */
+ if (x == Mono_Posix_UnixAddressFamily_AF_NETLINK)
+#ifdef AF_NETLINK
+ {*r = AF_NETLINK; return 0;}
+#else /* def AF_NETLINK */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_NETLINK */
+ if (x == Mono_Posix_UnixAddressFamily_AF_NETROM)
+#ifdef AF_NETROM
+ {*r = AF_NETROM; return 0;}
+#else /* def AF_NETROM */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_NETROM */
+ if (x == Mono_Posix_UnixAddressFamily_AF_NFC)
+#ifdef AF_NFC
+ {*r = AF_NFC; return 0;}
+#else /* def AF_NFC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_NFC */
+ if (x == Mono_Posix_UnixAddressFamily_AF_PACKET)
+#ifdef AF_PACKET
+ {*r = AF_PACKET; return 0;}
+#else /* def AF_PACKET */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_PACKET */
+ if (x == Mono_Posix_UnixAddressFamily_AF_PHONET)
+#ifdef AF_PHONET
+ {*r = AF_PHONET; return 0;}
+#else /* def AF_PHONET */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_PHONET */
+ if (x == Mono_Posix_UnixAddressFamily_AF_PPPOX)
+#ifdef AF_PPPOX
+ {*r = AF_PPPOX; return 0;}
+#else /* def AF_PPPOX */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_PPPOX */
+ if (x == Mono_Posix_UnixAddressFamily_AF_RDS)
+#ifdef AF_RDS
+ {*r = AF_RDS; return 0;}
+#else /* def AF_RDS */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_RDS */
+ if (x == Mono_Posix_UnixAddressFamily_AF_ROSE)
+#ifdef AF_ROSE
+ {*r = AF_ROSE; return 0;}
+#else /* def AF_ROSE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_ROSE */
+ if (x == Mono_Posix_UnixAddressFamily_AF_RXRPC)
+#ifdef AF_RXRPC
+ {*r = AF_RXRPC; return 0;}
+#else /* def AF_RXRPC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_RXRPC */
+ if (x == Mono_Posix_UnixAddressFamily_AF_SECURITY)
+#ifdef AF_SECURITY
+ {*r = AF_SECURITY; return 0;}
+#else /* def AF_SECURITY */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_SECURITY */
+ if (x == Mono_Posix_UnixAddressFamily_AF_SNA)
+#ifdef AF_SNA
+ {*r = AF_SNA; return 0;}
+#else /* def AF_SNA */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_SNA */
+ if (x == Mono_Posix_UnixAddressFamily_AF_TIPC)
+#ifdef AF_TIPC
+ {*r = AF_TIPC; return 0;}
+#else /* def AF_TIPC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_TIPC */
+ if (x == Mono_Posix_UnixAddressFamily_AF_UNIX)
+#ifdef AF_UNIX
+ {*r = AF_UNIX; return 0;}
+#else /* def AF_UNIX */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_UNIX */
+ if (x == Mono_Posix_UnixAddressFamily_AF_UNSPEC)
+#ifdef AF_UNSPEC
+ {*r = AF_UNSPEC; return 0;}
+#else /* def AF_UNSPEC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_UNSPEC */
+ if (x == Mono_Posix_UnixAddressFamily_AF_VSOCK)
+#ifdef AF_VSOCK
+ {*r = AF_VSOCK; return 0;}
+#else /* def AF_VSOCK */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_VSOCK */
+ if (x == Mono_Posix_UnixAddressFamily_AF_WANPIPE)
+#ifdef AF_WANPIPE
+ {*r = AF_WANPIPE; return 0;}
+#else /* def AF_WANPIPE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_WANPIPE */
+ if (x == Mono_Posix_UnixAddressFamily_AF_X25)
+#ifdef AF_X25
+ {*r = AF_X25; return 0;}
+#else /* def AF_X25 */
+ {errno = EINVAL; return -1;}
+#endif /* ndef AF_X25 */
+ if (x == 0)
+ return 0;
+ errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToUnixAddressFamily (int x, int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+#ifdef AF_ALG
+ if (x == AF_ALG)
+ {*r = Mono_Posix_UnixAddressFamily_AF_ALG; return 0;}
+#endif /* ndef AF_ALG */
+#ifdef AF_APPLETALK
+ if (x == AF_APPLETALK)
+ {*r = Mono_Posix_UnixAddressFamily_AF_APPLETALK; return 0;}
+#endif /* ndef AF_APPLETALK */
+#ifdef AF_ASH
+ if (x == AF_ASH)
+ {*r = Mono_Posix_UnixAddressFamily_AF_ASH; return 0;}
+#endif /* ndef AF_ASH */
+#ifdef AF_ATMPVC
+ if (x == AF_ATMPVC)
+ {*r = Mono_Posix_UnixAddressFamily_AF_ATMPVC; return 0;}
+#endif /* ndef AF_ATMPVC */
+#ifdef AF_ATMSVC
+ if (x == AF_ATMSVC)
+ {*r = Mono_Posix_UnixAddressFamily_AF_ATMSVC; return 0;}
+#endif /* ndef AF_ATMSVC */
+#ifdef AF_AX25
+ if (x == AF_AX25)
+ {*r = Mono_Posix_UnixAddressFamily_AF_AX25; return 0;}
+#endif /* ndef AF_AX25 */
+#ifdef AF_BLUETOOTH
+ if (x == AF_BLUETOOTH)
+ {*r = Mono_Posix_UnixAddressFamily_AF_BLUETOOTH; return 0;}
+#endif /* ndef AF_BLUETOOTH */
+#ifdef AF_BRIDGE
+ if (x == AF_BRIDGE)
+ {*r = Mono_Posix_UnixAddressFamily_AF_BRIDGE; return 0;}
+#endif /* ndef AF_BRIDGE */
+#ifdef AF_CAIF
+ if (x == AF_CAIF)
+ {*r = Mono_Posix_UnixAddressFamily_AF_CAIF; return 0;}
+#endif /* ndef AF_CAIF */
+#ifdef AF_CAN
+ if (x == AF_CAN)
+ {*r = Mono_Posix_UnixAddressFamily_AF_CAN; return 0;}
+#endif /* ndef AF_CAN */
+#ifdef AF_DECnet
+ if (x == AF_DECnet)
+ {*r = Mono_Posix_UnixAddressFamily_AF_DECnet; return 0;}
+#endif /* ndef AF_DECnet */
+#ifdef AF_ECONET
+ if (x == AF_ECONET)
+ {*r = Mono_Posix_UnixAddressFamily_AF_ECONET; return 0;}
+#endif /* ndef AF_ECONET */
+#ifdef AF_IEEE802154
+ if (x == AF_IEEE802154)
+ {*r = Mono_Posix_UnixAddressFamily_AF_IEEE802154; return 0;}
+#endif /* ndef AF_IEEE802154 */
+#ifdef AF_INET
+ if (x == AF_INET)
+ {*r = Mono_Posix_UnixAddressFamily_AF_INET; return 0;}
+#endif /* ndef AF_INET */
+#ifdef AF_INET6
+ if (x == AF_INET6)
+ {*r = Mono_Posix_UnixAddressFamily_AF_INET6; return 0;}
+#endif /* ndef AF_INET6 */
+#ifdef AF_IPX
+ if (x == AF_IPX)
+ {*r = Mono_Posix_UnixAddressFamily_AF_IPX; return 0;}
+#endif /* ndef AF_IPX */
+#ifdef AF_IRDA
+ if (x == AF_IRDA)
+ {*r = Mono_Posix_UnixAddressFamily_AF_IRDA; return 0;}
+#endif /* ndef AF_IRDA */
+#ifdef AF_ISDN
+ if (x == AF_ISDN)
+ {*r = Mono_Posix_UnixAddressFamily_AF_ISDN; return 0;}
+#endif /* ndef AF_ISDN */
+#ifdef AF_IUCV
+ if (x == AF_IUCV)
+ {*r = Mono_Posix_UnixAddressFamily_AF_IUCV; return 0;}
+#endif /* ndef AF_IUCV */
+#ifdef AF_KEY
+ if (x == AF_KEY)
+ {*r = Mono_Posix_UnixAddressFamily_AF_KEY; return 0;}
+#endif /* ndef AF_KEY */
+#ifdef AF_LLC
+ if (x == AF_LLC)
+ {*r = Mono_Posix_UnixAddressFamily_AF_LLC; return 0;}
+#endif /* ndef AF_LLC */
+#ifdef AF_NETBEUI
+ if (x == AF_NETBEUI)
+ {*r = Mono_Posix_UnixAddressFamily_AF_NETBEUI; return 0;}
+#endif /* ndef AF_NETBEUI */
+#ifdef AF_NETLINK
+ if (x == AF_NETLINK)
+ {*r = Mono_Posix_UnixAddressFamily_AF_NETLINK; return 0;}
+#endif /* ndef AF_NETLINK */
+#ifdef AF_NETROM
+ if (x == AF_NETROM)
+ {*r = Mono_Posix_UnixAddressFamily_AF_NETROM; return 0;}
+#endif /* ndef AF_NETROM */
+#ifdef AF_NFC
+ if (x == AF_NFC)
+ {*r = Mono_Posix_UnixAddressFamily_AF_NFC; return 0;}
+#endif /* ndef AF_NFC */
+#ifdef AF_PACKET
+ if (x == AF_PACKET)
+ {*r = Mono_Posix_UnixAddressFamily_AF_PACKET; return 0;}
+#endif /* ndef AF_PACKET */
+#ifdef AF_PHONET
+ if (x == AF_PHONET)
+ {*r = Mono_Posix_UnixAddressFamily_AF_PHONET; return 0;}
+#endif /* ndef AF_PHONET */
+#ifdef AF_PPPOX
+ if (x == AF_PPPOX)
+ {*r = Mono_Posix_UnixAddressFamily_AF_PPPOX; return 0;}
+#endif /* ndef AF_PPPOX */
+#ifdef AF_RDS
+ if (x == AF_RDS)
+ {*r = Mono_Posix_UnixAddressFamily_AF_RDS; return 0;}
+#endif /* ndef AF_RDS */
+#ifdef AF_ROSE
+ if (x == AF_ROSE)
+ {*r = Mono_Posix_UnixAddressFamily_AF_ROSE; return 0;}
+#endif /* ndef AF_ROSE */
+#ifdef AF_RXRPC
+ if (x == AF_RXRPC)
+ {*r = Mono_Posix_UnixAddressFamily_AF_RXRPC; return 0;}
+#endif /* ndef AF_RXRPC */
+#ifdef AF_SECURITY
+ if (x == AF_SECURITY)
+ {*r = Mono_Posix_UnixAddressFamily_AF_SECURITY; return 0;}
+#endif /* ndef AF_SECURITY */
+#ifdef AF_SNA
+ if (x == AF_SNA)
+ {*r = Mono_Posix_UnixAddressFamily_AF_SNA; return 0;}
+#endif /* ndef AF_SNA */
+#ifdef AF_TIPC
+ if (x == AF_TIPC)
+ {*r = Mono_Posix_UnixAddressFamily_AF_TIPC; return 0;}
+#endif /* ndef AF_TIPC */
+#ifdef AF_UNIX
+ if (x == AF_UNIX)
+ {*r = Mono_Posix_UnixAddressFamily_AF_UNIX; return 0;}
+#endif /* ndef AF_UNIX */
+#ifdef AF_UNSPEC
+ if (x == AF_UNSPEC)
+ {*r = Mono_Posix_UnixAddressFamily_AF_UNSPEC; return 0;}
+#endif /* ndef AF_UNSPEC */
+#ifdef AF_VSOCK
+ if (x == AF_VSOCK)
+ {*r = Mono_Posix_UnixAddressFamily_AF_VSOCK; return 0;}
+#endif /* ndef AF_VSOCK */
+#ifdef AF_WANPIPE
+ if (x == AF_WANPIPE)
+ {*r = Mono_Posix_UnixAddressFamily_AF_WANPIPE; return 0;}
+#endif /* ndef AF_WANPIPE */
+#ifdef AF_X25
+ if (x == AF_X25)
+ {*r = Mono_Posix_UnixAddressFamily_AF_X25; return 0;}
+#endif /* ndef AF_X25 */
+ errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromUnixSocketFlags (int x, int *r)
+{
+ *r = 0;
+ if ((x & Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC) == Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC)
+#ifdef SOCK_CLOEXEC
+ *r |= SOCK_CLOEXEC;
+#else /* def SOCK_CLOEXEC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_CLOEXEC */
+ if ((x & Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK) == Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK)
+#ifdef SOCK_NONBLOCK
+ *r |= SOCK_NONBLOCK;
+#else /* def SOCK_NONBLOCK */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_NONBLOCK */
+ if (x == 0)
+ return 0;
+ return 0;
+}
+
+int Mono_Posix_ToUnixSocketFlags (int x, int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+#ifdef SOCK_CLOEXEC
+ if ((x & SOCK_CLOEXEC) == SOCK_CLOEXEC)
+ *r |= Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC;
+#endif /* ndef SOCK_CLOEXEC */
+#ifdef SOCK_NONBLOCK
+ if ((x & SOCK_NONBLOCK) == SOCK_NONBLOCK)
+ *r |= Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK;
+#endif /* ndef SOCK_NONBLOCK */
+ return 0;
+}
+
+int Mono_Posix_FromUnixSocketOptionName (int x, int *r)
+{
+ *r = 0;
+ if (x == Mono_Posix_UnixSocketOptionName_SO_ACCEPTCONN)
+#ifdef SO_ACCEPTCONN
+ {*r = SO_ACCEPTCONN; return 0;}
+#else /* def SO_ACCEPTCONN */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_ACCEPTCONN */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_ATTACH_FILTER)
+#ifdef SO_ATTACH_FILTER
+ {*r = SO_ATTACH_FILTER; return 0;}
+#else /* def SO_ATTACH_FILTER */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_ATTACH_FILTER */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_BINDTODEVICE)
+#ifdef SO_BINDTODEVICE
+ {*r = SO_BINDTODEVICE; return 0;}
+#else /* def SO_BINDTODEVICE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_BINDTODEVICE */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_BROADCAST)
+#ifdef SO_BROADCAST
+ {*r = SO_BROADCAST; return 0;}
+#else /* def SO_BROADCAST */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_BROADCAST */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_BSDCOMPAT)
+#ifdef SO_BSDCOMPAT
+ {*r = SO_BSDCOMPAT; return 0;}
+#else /* def SO_BSDCOMPAT */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_BSDCOMPAT */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_BUSY_POLL)
+#ifdef SO_BUSY_POLL
+ {*r = SO_BUSY_POLL; return 0;}
+#else /* def SO_BUSY_POLL */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_BUSY_POLL */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_DEBUG)
+#ifdef SO_DEBUG
+ {*r = SO_DEBUG; return 0;}
+#else /* def SO_DEBUG */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_DEBUG */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_DETACH_FILTER)
+#ifdef SO_DETACH_FILTER
+ {*r = SO_DETACH_FILTER; return 0;}
+#else /* def SO_DETACH_FILTER */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_DETACH_FILTER */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_DOMAIN)
+#ifdef SO_DOMAIN
+ {*r = SO_DOMAIN; return 0;}
+#else /* def SO_DOMAIN */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_DOMAIN */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_DONTROUTE)
+#ifdef SO_DONTROUTE
+ {*r = SO_DONTROUTE; return 0;}
+#else /* def SO_DONTROUTE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_DONTROUTE */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_ERROR)
+#ifdef SO_ERROR
+ {*r = SO_ERROR; return 0;}
+#else /* def SO_ERROR */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_ERROR */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_KEEPALIVE)
+#ifdef SO_KEEPALIVE
+ {*r = SO_KEEPALIVE; return 0;}
+#else /* def SO_KEEPALIVE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_KEEPALIVE */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_LINGER)
+#ifdef SO_LINGER
+ {*r = SO_LINGER; return 0;}
+#else /* def SO_LINGER */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_LINGER */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_LOCK_FILTER)
+#ifdef SO_LOCK_FILTER
+ {*r = SO_LOCK_FILTER; return 0;}
+#else /* def SO_LOCK_FILTER */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_LOCK_FILTER */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_MARK)
+#ifdef SO_MARK
+ {*r = SO_MARK; return 0;}
+#else /* def SO_MARK */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_MARK */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_MAX_PACING_RATE)
+#ifdef SO_MAX_PACING_RATE
+ {*r = SO_MAX_PACING_RATE; return 0;}
+#else /* def SO_MAX_PACING_RATE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_MAX_PACING_RATE */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_NOFCS)
+#ifdef SO_NOFCS
+ {*r = SO_NOFCS; return 0;}
+#else /* def SO_NOFCS */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_NOFCS */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_NO_CHECK)
+#ifdef SO_NO_CHECK
+ {*r = SO_NO_CHECK; return 0;}
+#else /* def SO_NO_CHECK */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_NO_CHECK */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_OOBINLINE)
+#ifdef SO_OOBINLINE
+ {*r = SO_OOBINLINE; return 0;}
+#else /* def SO_OOBINLINE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_OOBINLINE */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_PASSCRED)
+#ifdef SO_PASSCRED
+ {*r = SO_PASSCRED; return 0;}
+#else /* def SO_PASSCRED */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_PASSCRED */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_PASSSEC)
+#ifdef SO_PASSSEC
+ {*r = SO_PASSSEC; return 0;}
+#else /* def SO_PASSSEC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_PASSSEC */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_PEEK_OFF)
+#ifdef SO_PEEK_OFF
+ {*r = SO_PEEK_OFF; return 0;}
+#else /* def SO_PEEK_OFF */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_PEEK_OFF */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_PEERCRED)
+#ifdef SO_PEERCRED
+ {*r = SO_PEERCRED; return 0;}
+#else /* def SO_PEERCRED */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_PEERCRED */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_PEERNAME)
+#ifdef SO_PEERNAME
+ {*r = SO_PEERNAME; return 0;}
+#else /* def SO_PEERNAME */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_PEERNAME */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_PEERSEC)
+#ifdef SO_PEERSEC
+ {*r = SO_PEERSEC; return 0;}
+#else /* def SO_PEERSEC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_PEERSEC */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_PRIORITY)
+#ifdef SO_PRIORITY
+ {*r = SO_PRIORITY; return 0;}
+#else /* def SO_PRIORITY */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_PRIORITY */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_PROTOCOL)
+#ifdef SO_PROTOCOL
+ {*r = SO_PROTOCOL; return 0;}
+#else /* def SO_PROTOCOL */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_PROTOCOL */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_RCVBUF)
+#ifdef SO_RCVBUF
+ {*r = SO_RCVBUF; return 0;}
+#else /* def SO_RCVBUF */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_RCVBUF */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_RCVBUFFORCE)
+#ifdef SO_RCVBUFFORCE
+ {*r = SO_RCVBUFFORCE; return 0;}
+#else /* def SO_RCVBUFFORCE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_RCVBUFFORCE */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_RCVLOWAT)
+#ifdef SO_RCVLOWAT
+ {*r = SO_RCVLOWAT; return 0;}
+#else /* def SO_RCVLOWAT */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_RCVLOWAT */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_RCVTIMEO)
+#ifdef SO_RCVTIMEO
+ {*r = SO_RCVTIMEO; return 0;}
+#else /* def SO_RCVTIMEO */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_RCVTIMEO */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_REUSEADDR)
+#ifdef SO_REUSEADDR
+ {*r = SO_REUSEADDR; return 0;}
+#else /* def SO_REUSEADDR */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_REUSEADDR */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_REUSEPORT)
+#ifdef SO_REUSEPORT
+ {*r = SO_REUSEPORT; return 0;}
+#else /* def SO_REUSEPORT */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_REUSEPORT */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_RXQ_OVFL)
+#ifdef SO_RXQ_OVFL
+ {*r = SO_RXQ_OVFL; return 0;}
+#else /* def SO_RXQ_OVFL */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_RXQ_OVFL */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_SECURITY_AUTHENTICATION)
+#ifdef SO_SECURITY_AUTHENTICATION
+ {*r = SO_SECURITY_AUTHENTICATION; return 0;}
+#else /* def SO_SECURITY_AUTHENTICATION */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_SECURITY_AUTHENTICATION */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_NETWORK)
+#ifdef SO_SECURITY_ENCRYPTION_NETWORK
+ {*r = SO_SECURITY_ENCRYPTION_NETWORK; return 0;}
+#else /* def SO_SECURITY_ENCRYPTION_NETWORK */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_SECURITY_ENCRYPTION_NETWORK */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_TRANSPORT)
+#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
+ {*r = SO_SECURITY_ENCRYPTION_TRANSPORT; return 0;}
+#else /* def SO_SECURITY_ENCRYPTION_TRANSPORT */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_SECURITY_ENCRYPTION_TRANSPORT */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_SELECT_ERR_QUEUE)
+#ifdef SO_SELECT_ERR_QUEUE
+ {*r = SO_SELECT_ERR_QUEUE; return 0;}
+#else /* def SO_SELECT_ERR_QUEUE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_SELECT_ERR_QUEUE */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_SNDBUF)
+#ifdef SO_SNDBUF
+ {*r = SO_SNDBUF; return 0;}
+#else /* def SO_SNDBUF */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_SNDBUF */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_SNDBUFFORCE)
+#ifdef SO_SNDBUFFORCE
+ {*r = SO_SNDBUFFORCE; return 0;}
+#else /* def SO_SNDBUFFORCE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_SNDBUFFORCE */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_SNDLOWAT)
+#ifdef SO_SNDLOWAT
+ {*r = SO_SNDLOWAT; return 0;}
+#else /* def SO_SNDLOWAT */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_SNDLOWAT */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_SNDTIMEO)
+#ifdef SO_SNDTIMEO
+ {*r = SO_SNDTIMEO; return 0;}
+#else /* def SO_SNDTIMEO */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_SNDTIMEO */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_TIMESTAMP)
+#ifdef SO_TIMESTAMP
+ {*r = SO_TIMESTAMP; return 0;}
+#else /* def SO_TIMESTAMP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_TIMESTAMP */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPING)
+#ifdef SO_TIMESTAMPING
+ {*r = SO_TIMESTAMPING; return 0;}
+#else /* def SO_TIMESTAMPING */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_TIMESTAMPING */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPNS)
+#ifdef SO_TIMESTAMPNS
+ {*r = SO_TIMESTAMPNS; return 0;}
+#else /* def SO_TIMESTAMPNS */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_TIMESTAMPNS */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_TYPE)
+#ifdef SO_TYPE
+ {*r = SO_TYPE; return 0;}
+#else /* def SO_TYPE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_TYPE */
+ if (x == Mono_Posix_UnixSocketOptionName_SO_WIFI_STATUS)
+#ifdef SO_WIFI_STATUS
+ {*r = SO_WIFI_STATUS; return 0;}
+#else /* def SO_WIFI_STATUS */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SO_WIFI_STATUS */
+ if (x == 0)
+ return 0;
+ errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToUnixSocketOptionName (int x, int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+#ifdef SO_ACCEPTCONN
+ if (x == SO_ACCEPTCONN)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_ACCEPTCONN; return 0;}
+#endif /* ndef SO_ACCEPTCONN */
+#ifdef SO_ATTACH_FILTER
+ if (x == SO_ATTACH_FILTER)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_ATTACH_FILTER; return 0;}
+#endif /* ndef SO_ATTACH_FILTER */
+#ifdef SO_BINDTODEVICE
+ if (x == SO_BINDTODEVICE)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_BINDTODEVICE; return 0;}
+#endif /* ndef SO_BINDTODEVICE */
+#ifdef SO_BROADCAST
+ if (x == SO_BROADCAST)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_BROADCAST; return 0;}
+#endif /* ndef SO_BROADCAST */
+#ifdef SO_BSDCOMPAT
+ if (x == SO_BSDCOMPAT)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_BSDCOMPAT; return 0;}
+#endif /* ndef SO_BSDCOMPAT */
+#ifdef SO_BUSY_POLL
+ if (x == SO_BUSY_POLL)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_BUSY_POLL; return 0;}
+#endif /* ndef SO_BUSY_POLL */
+#ifdef SO_DEBUG
+ if (x == SO_DEBUG)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_DEBUG; return 0;}
+#endif /* ndef SO_DEBUG */
+#ifdef SO_DETACH_FILTER
+ if (x == SO_DETACH_FILTER)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_DETACH_FILTER; return 0;}
+#endif /* ndef SO_DETACH_FILTER */
+#ifdef SO_DOMAIN
+ if (x == SO_DOMAIN)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_DOMAIN; return 0;}
+#endif /* ndef SO_DOMAIN */
+#ifdef SO_DONTROUTE
+ if (x == SO_DONTROUTE)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_DONTROUTE; return 0;}
+#endif /* ndef SO_DONTROUTE */
+#ifdef SO_ERROR
+ if (x == SO_ERROR)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_ERROR; return 0;}
+#endif /* ndef SO_ERROR */
+#ifdef SO_KEEPALIVE
+ if (x == SO_KEEPALIVE)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_KEEPALIVE; return 0;}
+#endif /* ndef SO_KEEPALIVE */
+#ifdef SO_LINGER
+ if (x == SO_LINGER)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_LINGER; return 0;}
+#endif /* ndef SO_LINGER */
+#ifdef SO_LOCK_FILTER
+ if (x == SO_LOCK_FILTER)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_LOCK_FILTER; return 0;}
+#endif /* ndef SO_LOCK_FILTER */
+#ifdef SO_MARK
+ if (x == SO_MARK)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_MARK; return 0;}
+#endif /* ndef SO_MARK */
+#ifdef SO_MAX_PACING_RATE
+ if (x == SO_MAX_PACING_RATE)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_MAX_PACING_RATE; return 0;}
+#endif /* ndef SO_MAX_PACING_RATE */
+#ifdef SO_NOFCS
+ if (x == SO_NOFCS)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_NOFCS; return 0;}
+#endif /* ndef SO_NOFCS */
+#ifdef SO_NO_CHECK
+ if (x == SO_NO_CHECK)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_NO_CHECK; return 0;}
+#endif /* ndef SO_NO_CHECK */
+#ifdef SO_OOBINLINE
+ if (x == SO_OOBINLINE)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_OOBINLINE; return 0;}
+#endif /* ndef SO_OOBINLINE */
+#ifdef SO_PASSCRED
+ if (x == SO_PASSCRED)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_PASSCRED; return 0;}
+#endif /* ndef SO_PASSCRED */
+#ifdef SO_PASSSEC
+ if (x == SO_PASSSEC)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_PASSSEC; return 0;}
+#endif /* ndef SO_PASSSEC */
+#ifdef SO_PEEK_OFF
+ if (x == SO_PEEK_OFF)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_PEEK_OFF; return 0;}
+#endif /* ndef SO_PEEK_OFF */
+#ifdef SO_PEERCRED
+ if (x == SO_PEERCRED)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_PEERCRED; return 0;}
+#endif /* ndef SO_PEERCRED */
+#ifdef SO_PEERNAME
+ if (x == SO_PEERNAME)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_PEERNAME; return 0;}
+#endif /* ndef SO_PEERNAME */
+#ifdef SO_PEERSEC
+ if (x == SO_PEERSEC)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_PEERSEC; return 0;}
+#endif /* ndef SO_PEERSEC */
+#ifdef SO_PRIORITY
+ if (x == SO_PRIORITY)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_PRIORITY; return 0;}
+#endif /* ndef SO_PRIORITY */
+#ifdef SO_PROTOCOL
+ if (x == SO_PROTOCOL)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_PROTOCOL; return 0;}
+#endif /* ndef SO_PROTOCOL */
+#ifdef SO_RCVBUF
+ if (x == SO_RCVBUF)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_RCVBUF; return 0;}
+#endif /* ndef SO_RCVBUF */
+#ifdef SO_RCVBUFFORCE
+ if (x == SO_RCVBUFFORCE)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_RCVBUFFORCE; return 0;}
+#endif /* ndef SO_RCVBUFFORCE */
+#ifdef SO_RCVLOWAT
+ if (x == SO_RCVLOWAT)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_RCVLOWAT; return 0;}
+#endif /* ndef SO_RCVLOWAT */
+#ifdef SO_RCVTIMEO
+ if (x == SO_RCVTIMEO)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_RCVTIMEO; return 0;}
+#endif /* ndef SO_RCVTIMEO */
+#ifdef SO_REUSEADDR
+ if (x == SO_REUSEADDR)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_REUSEADDR; return 0;}
+#endif /* ndef SO_REUSEADDR */
+#ifdef SO_REUSEPORT
+ if (x == SO_REUSEPORT)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_REUSEPORT; return 0;}
+#endif /* ndef SO_REUSEPORT */
+#ifdef SO_RXQ_OVFL
+ if (x == SO_RXQ_OVFL)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_RXQ_OVFL; return 0;}
+#endif /* ndef SO_RXQ_OVFL */
+#ifdef SO_SECURITY_AUTHENTICATION
+ if (x == SO_SECURITY_AUTHENTICATION)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_SECURITY_AUTHENTICATION; return 0;}
+#endif /* ndef SO_SECURITY_AUTHENTICATION */
+#ifdef SO_SECURITY_ENCRYPTION_NETWORK
+ if (x == SO_SECURITY_ENCRYPTION_NETWORK)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_NETWORK; return 0;}
+#endif /* ndef SO_SECURITY_ENCRYPTION_NETWORK */
+#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
+ if (x == SO_SECURITY_ENCRYPTION_TRANSPORT)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_TRANSPORT; return 0;}
+#endif /* ndef SO_SECURITY_ENCRYPTION_TRANSPORT */
+#ifdef SO_SELECT_ERR_QUEUE
+ if (x == SO_SELECT_ERR_QUEUE)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_SELECT_ERR_QUEUE; return 0;}
+#endif /* ndef SO_SELECT_ERR_QUEUE */
+#ifdef SO_SNDBUF
+ if (x == SO_SNDBUF)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_SNDBUF; return 0;}
+#endif /* ndef SO_SNDBUF */
+#ifdef SO_SNDBUFFORCE
+ if (x == SO_SNDBUFFORCE)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_SNDBUFFORCE; return 0;}
+#endif /* ndef SO_SNDBUFFORCE */
+#ifdef SO_SNDLOWAT
+ if (x == SO_SNDLOWAT)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_SNDLOWAT; return 0;}
+#endif /* ndef SO_SNDLOWAT */
+#ifdef SO_SNDTIMEO
+ if (x == SO_SNDTIMEO)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_SNDTIMEO; return 0;}
+#endif /* ndef SO_SNDTIMEO */
+#ifdef SO_TIMESTAMP
+ if (x == SO_TIMESTAMP)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_TIMESTAMP; return 0;}
+#endif /* ndef SO_TIMESTAMP */
+#ifdef SO_TIMESTAMPING
+ if (x == SO_TIMESTAMPING)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPING; return 0;}
+#endif /* ndef SO_TIMESTAMPING */
+#ifdef SO_TIMESTAMPNS
+ if (x == SO_TIMESTAMPNS)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPNS; return 0;}
+#endif /* ndef SO_TIMESTAMPNS */
+#ifdef SO_TYPE
+ if (x == SO_TYPE)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_TYPE; return 0;}
+#endif /* ndef SO_TYPE */
+#ifdef SO_WIFI_STATUS
+ if (x == SO_WIFI_STATUS)
+ {*r = Mono_Posix_UnixSocketOptionName_SO_WIFI_STATUS; return 0;}
+#endif /* ndef SO_WIFI_STATUS */
+ errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromUnixSocketProtocol (int x, int *r)
+{
+ *r = 0;
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_AH)
+#ifdef IPPROTO_AH
+ {*r = IPPROTO_AH; return 0;}
+#else /* def IPPROTO_AH */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_AH */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_BEETPH)
+#ifdef IPPROTO_BEETPH
+ {*r = IPPROTO_BEETPH; return 0;}
+#else /* def IPPROTO_BEETPH */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_BEETPH */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_COMP)
+#ifdef IPPROTO_COMP
+ {*r = IPPROTO_COMP; return 0;}
+#else /* def IPPROTO_COMP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_COMP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_DCCP)
+#ifdef IPPROTO_DCCP
+ {*r = IPPROTO_DCCP; return 0;}
+#else /* def IPPROTO_DCCP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_DCCP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_EGP)
+#ifdef IPPROTO_EGP
+ {*r = IPPROTO_EGP; return 0;}
+#else /* def IPPROTO_EGP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_EGP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_ENCAP)
+#ifdef IPPROTO_ENCAP
+ {*r = IPPROTO_ENCAP; return 0;}
+#else /* def IPPROTO_ENCAP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_ENCAP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_ESP)
+#ifdef IPPROTO_ESP
+ {*r = IPPROTO_ESP; return 0;}
+#else /* def IPPROTO_ESP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_ESP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_GRE)
+#ifdef IPPROTO_GRE
+ {*r = IPPROTO_GRE; return 0;}
+#else /* def IPPROTO_GRE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_GRE */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_ICMP)
+#ifdef IPPROTO_ICMP
+ {*r = IPPROTO_ICMP; return 0;}
+#else /* def IPPROTO_ICMP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_ICMP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IDP)
+#ifdef IPPROTO_IDP
+ {*r = IPPROTO_IDP; return 0;}
+#else /* def IPPROTO_IDP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_IDP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IGMP)
+#ifdef IPPROTO_IGMP
+ {*r = IPPROTO_IGMP; return 0;}
+#else /* def IPPROTO_IGMP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_IGMP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IP)
+#ifdef IPPROTO_IP
+ {*r = IPPROTO_IP; return 0;}
+#else /* def IPPROTO_IP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_IP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IPIP)
+#ifdef IPPROTO_IPIP
+ {*r = IPPROTO_IPIP; return 0;}
+#else /* def IPPROTO_IPIP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_IPIP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IPV6)
+#ifdef IPPROTO_IPV6
+ {*r = IPPROTO_IPV6; return 0;}
+#else /* def IPPROTO_IPV6 */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_IPV6 */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_MTP)
+#ifdef IPPROTO_MTP
+ {*r = IPPROTO_MTP; return 0;}
+#else /* def IPPROTO_MTP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_MTP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_PIM)
+#ifdef IPPROTO_PIM
+ {*r = IPPROTO_PIM; return 0;}
+#else /* def IPPROTO_PIM */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_PIM */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_PUP)
+#ifdef IPPROTO_PUP
+ {*r = IPPROTO_PUP; return 0;}
+#else /* def IPPROTO_PUP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_PUP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_RAW)
+#ifdef IPPROTO_RAW
+ {*r = IPPROTO_RAW; return 0;}
+#else /* def IPPROTO_RAW */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_RAW */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_RSVP)
+#ifdef IPPROTO_RSVP
+ {*r = IPPROTO_RSVP; return 0;}
+#else /* def IPPROTO_RSVP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_RSVP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_SCTP)
+#ifdef IPPROTO_SCTP
+ {*r = IPPROTO_SCTP; return 0;}
+#else /* def IPPROTO_SCTP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_SCTP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_TCP)
+#ifdef IPPROTO_TCP
+ {*r = IPPROTO_TCP; return 0;}
+#else /* def IPPROTO_TCP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_TCP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_TP)
+#ifdef IPPROTO_TP
+ {*r = IPPROTO_TP; return 0;}
+#else /* def IPPROTO_TP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_TP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_UDP)
+#ifdef IPPROTO_UDP
+ {*r = IPPROTO_UDP; return 0;}
+#else /* def IPPROTO_UDP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_UDP */
+ if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_UDPLITE)
+#ifdef IPPROTO_UDPLITE
+ {*r = IPPROTO_UDPLITE; return 0;}
+#else /* def IPPROTO_UDPLITE */
+ {errno = EINVAL; return -1;}
+#endif /* ndef IPPROTO_UDPLITE */
+ if (x == Mono_Posix_UnixSocketProtocol_SOL_SOCKET)
+#ifdef SOL_SOCKET
+ {*r = SOL_SOCKET; return 0;}
+#else /* def SOL_SOCKET */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SOL_SOCKET */
+ if (x == 0)
+ return 0;
+ errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToUnixSocketProtocol (int x, int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+#ifdef IPPROTO_AH
+ if (x == IPPROTO_AH)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_AH; return 0;}
+#endif /* ndef IPPROTO_AH */
+#ifdef IPPROTO_BEETPH
+ if (x == IPPROTO_BEETPH)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_BEETPH; return 0;}
+#endif /* ndef IPPROTO_BEETPH */
+#ifdef IPPROTO_COMP
+ if (x == IPPROTO_COMP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_COMP; return 0;}
+#endif /* ndef IPPROTO_COMP */
+#ifdef IPPROTO_DCCP
+ if (x == IPPROTO_DCCP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_DCCP; return 0;}
+#endif /* ndef IPPROTO_DCCP */
+#ifdef IPPROTO_EGP
+ if (x == IPPROTO_EGP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_EGP; return 0;}
+#endif /* ndef IPPROTO_EGP */
+#ifdef IPPROTO_ENCAP
+ if (x == IPPROTO_ENCAP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_ENCAP; return 0;}
+#endif /* ndef IPPROTO_ENCAP */
+#ifdef IPPROTO_ESP
+ if (x == IPPROTO_ESP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_ESP; return 0;}
+#endif /* ndef IPPROTO_ESP */
+#ifdef IPPROTO_GRE
+ if (x == IPPROTO_GRE)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_GRE; return 0;}
+#endif /* ndef IPPROTO_GRE */
+#ifdef IPPROTO_ICMP
+ if (x == IPPROTO_ICMP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_ICMP; return 0;}
+#endif /* ndef IPPROTO_ICMP */
+#ifdef IPPROTO_IDP
+ if (x == IPPROTO_IDP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IDP; return 0;}
+#endif /* ndef IPPROTO_IDP */
+#ifdef IPPROTO_IGMP
+ if (x == IPPROTO_IGMP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IGMP; return 0;}
+#endif /* ndef IPPROTO_IGMP */
+#ifdef IPPROTO_IP
+ if (x == IPPROTO_IP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IP; return 0;}
+#endif /* ndef IPPROTO_IP */
+#ifdef IPPROTO_IPIP
+ if (x == IPPROTO_IPIP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IPIP; return 0;}
+#endif /* ndef IPPROTO_IPIP */
+#ifdef IPPROTO_IPV6
+ if (x == IPPROTO_IPV6)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IPV6; return 0;}
+#endif /* ndef IPPROTO_IPV6 */
+#ifdef IPPROTO_MTP
+ if (x == IPPROTO_MTP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_MTP; return 0;}
+#endif /* ndef IPPROTO_MTP */
+#ifdef IPPROTO_PIM
+ if (x == IPPROTO_PIM)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_PIM; return 0;}
+#endif /* ndef IPPROTO_PIM */
+#ifdef IPPROTO_PUP
+ if (x == IPPROTO_PUP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_PUP; return 0;}
+#endif /* ndef IPPROTO_PUP */
+#ifdef IPPROTO_RAW
+ if (x == IPPROTO_RAW)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_RAW; return 0;}
+#endif /* ndef IPPROTO_RAW */
+#ifdef IPPROTO_RSVP
+ if (x == IPPROTO_RSVP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_RSVP; return 0;}
+#endif /* ndef IPPROTO_RSVP */
+#ifdef IPPROTO_SCTP
+ if (x == IPPROTO_SCTP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_SCTP; return 0;}
+#endif /* ndef IPPROTO_SCTP */
+#ifdef IPPROTO_TCP
+ if (x == IPPROTO_TCP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_TCP; return 0;}
+#endif /* ndef IPPROTO_TCP */
+#ifdef IPPROTO_TP
+ if (x == IPPROTO_TP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_TP; return 0;}
+#endif /* ndef IPPROTO_TP */
+#ifdef IPPROTO_UDP
+ if (x == IPPROTO_UDP)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_UDP; return 0;}
+#endif /* ndef IPPROTO_UDP */
+#ifdef IPPROTO_UDPLITE
+ if (x == IPPROTO_UDPLITE)
+ {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_UDPLITE; return 0;}
+#endif /* ndef IPPROTO_UDPLITE */
+#ifdef SOL_SOCKET
+ if (x == SOL_SOCKET)
+ {*r = Mono_Posix_UnixSocketProtocol_SOL_SOCKET; return 0;}
+#endif /* ndef SOL_SOCKET */
+ errno = EINVAL; return -1;
+}
+
+int Mono_Posix_FromUnixSocketType (int x, int *r)
+{
+ *r = 0;
+ if (x == Mono_Posix_UnixSocketType_SOCK_DCCP)
+#ifdef SOCK_DCCP
+ {*r = SOCK_DCCP; return 0;}
+#else /* def SOCK_DCCP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_DCCP */
+ if (x == Mono_Posix_UnixSocketType_SOCK_DGRAM)
+#ifdef SOCK_DGRAM
+ {*r = SOCK_DGRAM; return 0;}
+#else /* def SOCK_DGRAM */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_DGRAM */
+ if (x == Mono_Posix_UnixSocketType_SOCK_PACKET)
+#ifdef SOCK_PACKET
+ {*r = SOCK_PACKET; return 0;}
+#else /* def SOCK_PACKET */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_PACKET */
+ if (x == Mono_Posix_UnixSocketType_SOCK_RAW)
+#ifdef SOCK_RAW
+ {*r = SOCK_RAW; return 0;}
+#else /* def SOCK_RAW */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_RAW */
+ if (x == Mono_Posix_UnixSocketType_SOCK_RDM)
+#ifdef SOCK_RDM
+ {*r = SOCK_RDM; return 0;}
+#else /* def SOCK_RDM */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_RDM */
+ if (x == Mono_Posix_UnixSocketType_SOCK_SEQPACKET)
+#ifdef SOCK_SEQPACKET
+ {*r = SOCK_SEQPACKET; return 0;}
+#else /* def SOCK_SEQPACKET */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_SEQPACKET */
+ if (x == Mono_Posix_UnixSocketType_SOCK_STREAM)
+#ifdef SOCK_STREAM
+ {*r = SOCK_STREAM; return 0;}
+#else /* def SOCK_STREAM */
+ {errno = EINVAL; return -1;}
+#endif /* ndef SOCK_STREAM */
+ if (x == 0)
+ return 0;
+ errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToUnixSocketType (int x, int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+#ifdef SOCK_DCCP
+ if (x == SOCK_DCCP)
+ {*r = Mono_Posix_UnixSocketType_SOCK_DCCP; return 0;}
+#endif /* ndef SOCK_DCCP */
+#ifdef SOCK_DGRAM
+ if (x == SOCK_DGRAM)
+ {*r = Mono_Posix_UnixSocketType_SOCK_DGRAM; return 0;}
+#endif /* ndef SOCK_DGRAM */
+#ifdef SOCK_PACKET
+ if (x == SOCK_PACKET)
+ {*r = Mono_Posix_UnixSocketType_SOCK_PACKET; return 0;}
+#endif /* ndef SOCK_PACKET */
+#ifdef SOCK_RAW
+ if (x == SOCK_RAW)
+ {*r = Mono_Posix_UnixSocketType_SOCK_RAW; return 0;}
+#endif /* ndef SOCK_RAW */
+#ifdef SOCK_RDM
+ if (x == SOCK_RDM)
+ {*r = Mono_Posix_UnixSocketType_SOCK_RDM; return 0;}
+#endif /* ndef SOCK_RDM */
+#ifdef SOCK_SEQPACKET
+ if (x == SOCK_SEQPACKET)
+ {*r = Mono_Posix_UnixSocketType_SOCK_SEQPACKET; return 0;}
+#endif /* ndef SOCK_SEQPACKET */
+#ifdef SOCK_STREAM
+ if (x == SOCK_STREAM)
+ {*r = Mono_Posix_UnixSocketType_SOCK_STREAM; return 0;}
+#endif /* ndef SOCK_STREAM */
+ errno = EINVAL; return -1;
+}
+
#ifdef HAVE_STRUCT_UTIMBUF
int
Mono_Posix_FromUtimbuf (struct Mono_Posix_Utimbuf *from, struct utimbuf *to)
int Mono_Posix_FromLockfCommand (int x, int *r);
int Mono_Posix_ToLockfCommand (int x, int *r);
+enum Mono_Posix_MessageFlags {
+ Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC = 0x40000000,
+ #define Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC
+ Mono_Posix_MessageFlags_MSG_CONFIRM = 0x00000800,
+ #define Mono_Posix_MessageFlags_MSG_CONFIRM Mono_Posix_MessageFlags_MSG_CONFIRM
+ Mono_Posix_MessageFlags_MSG_CTRUNC = 0x00000008,
+ #define Mono_Posix_MessageFlags_MSG_CTRUNC Mono_Posix_MessageFlags_MSG_CTRUNC
+ Mono_Posix_MessageFlags_MSG_DONTROUTE = 0x00000004,
+ #define Mono_Posix_MessageFlags_MSG_DONTROUTE Mono_Posix_MessageFlags_MSG_DONTROUTE
+ Mono_Posix_MessageFlags_MSG_DONTWAIT = 0x00000040,
+ #define Mono_Posix_MessageFlags_MSG_DONTWAIT Mono_Posix_MessageFlags_MSG_DONTWAIT
+ Mono_Posix_MessageFlags_MSG_EOR = 0x00000080,
+ #define Mono_Posix_MessageFlags_MSG_EOR Mono_Posix_MessageFlags_MSG_EOR
+ Mono_Posix_MessageFlags_MSG_ERRQUEUE = 0x00002000,
+ #define Mono_Posix_MessageFlags_MSG_ERRQUEUE Mono_Posix_MessageFlags_MSG_ERRQUEUE
+ Mono_Posix_MessageFlags_MSG_FASTOPEN = 0x20000000,
+ #define Mono_Posix_MessageFlags_MSG_FASTOPEN Mono_Posix_MessageFlags_MSG_FASTOPEN
+ Mono_Posix_MessageFlags_MSG_FIN = 0x00000200,
+ #define Mono_Posix_MessageFlags_MSG_FIN Mono_Posix_MessageFlags_MSG_FIN
+ Mono_Posix_MessageFlags_MSG_MORE = 0x00008000,
+ #define Mono_Posix_MessageFlags_MSG_MORE Mono_Posix_MessageFlags_MSG_MORE
+ Mono_Posix_MessageFlags_MSG_NOSIGNAL = 0x00004000,
+ #define Mono_Posix_MessageFlags_MSG_NOSIGNAL Mono_Posix_MessageFlags_MSG_NOSIGNAL
+ Mono_Posix_MessageFlags_MSG_OOB = 0x00000001,
+ #define Mono_Posix_MessageFlags_MSG_OOB Mono_Posix_MessageFlags_MSG_OOB
+ Mono_Posix_MessageFlags_MSG_PEEK = 0x00000002,
+ #define Mono_Posix_MessageFlags_MSG_PEEK Mono_Posix_MessageFlags_MSG_PEEK
+ Mono_Posix_MessageFlags_MSG_PROXY = 0x00000010,
+ #define Mono_Posix_MessageFlags_MSG_PROXY Mono_Posix_MessageFlags_MSG_PROXY
+ Mono_Posix_MessageFlags_MSG_RST = 0x00001000,
+ #define Mono_Posix_MessageFlags_MSG_RST Mono_Posix_MessageFlags_MSG_RST
+ Mono_Posix_MessageFlags_MSG_SYN = 0x00000400,
+ #define Mono_Posix_MessageFlags_MSG_SYN Mono_Posix_MessageFlags_MSG_SYN
+ Mono_Posix_MessageFlags_MSG_TRUNC = 0x00000020,
+ #define Mono_Posix_MessageFlags_MSG_TRUNC Mono_Posix_MessageFlags_MSG_TRUNC
+ Mono_Posix_MessageFlags_MSG_WAITALL = 0x00000100,
+ #define Mono_Posix_MessageFlags_MSG_WAITALL Mono_Posix_MessageFlags_MSG_WAITALL
+ Mono_Posix_MessageFlags_MSG_WAITFORONE = 0x00010000,
+ #define Mono_Posix_MessageFlags_MSG_WAITFORONE Mono_Posix_MessageFlags_MSG_WAITFORONE
+};
+int Mono_Posix_FromMessageFlags (int x, int *r);
+int Mono_Posix_ToMessageFlags (int x, int *r);
+
enum Mono_Posix_MlockallFlags {
Mono_Posix_MlockallFlags_MCL_CURRENT = 0x00000001,
#define Mono_Posix_MlockallFlags_MCL_CURRENT Mono_Posix_MlockallFlags_MCL_CURRENT
int Mono_Posix_FromSeekFlags (short x, short *r);
int Mono_Posix_ToSeekFlags (short x, short *r);
+enum Mono_Posix_ShutdownOption {
+ Mono_Posix_ShutdownOption_SHUT_RD = 0x00000001,
+ #define Mono_Posix_ShutdownOption_SHUT_RD Mono_Posix_ShutdownOption_SHUT_RD
+ Mono_Posix_ShutdownOption_SHUT_RDWR = 0x00000003,
+ #define Mono_Posix_ShutdownOption_SHUT_RDWR Mono_Posix_ShutdownOption_SHUT_RDWR
+ Mono_Posix_ShutdownOption_SHUT_WR = 0x00000002,
+ #define Mono_Posix_ShutdownOption_SHUT_WR Mono_Posix_ShutdownOption_SHUT_WR
+};
+int Mono_Posix_FromShutdownOption (int x, int *r);
+int Mono_Posix_ToShutdownOption (int x, int *r);
+
enum Mono_Posix_Signum {
Mono_Posix_Signum_SIGABRT = 0x00000006,
#define Mono_Posix_Signum_SIGABRT Mono_Posix_Signum_SIGABRT
int Mono_Posix_FromSyslogOptions (int x, int *r);
int Mono_Posix_ToSyslogOptions (int x, int *r);
+enum Mono_Posix_UnixAddressFamily {
+ Mono_Posix_UnixAddressFamily_AF_ALG = 0x00000026,
+ #define Mono_Posix_UnixAddressFamily_AF_ALG Mono_Posix_UnixAddressFamily_AF_ALG
+ Mono_Posix_UnixAddressFamily_AF_APPLETALK = 0x00000005,
+ #define Mono_Posix_UnixAddressFamily_AF_APPLETALK Mono_Posix_UnixAddressFamily_AF_APPLETALK
+ Mono_Posix_UnixAddressFamily_AF_ASH = 0x00000012,
+ #define Mono_Posix_UnixAddressFamily_AF_ASH Mono_Posix_UnixAddressFamily_AF_ASH
+ Mono_Posix_UnixAddressFamily_AF_ATMPVC = 0x00000008,
+ #define Mono_Posix_UnixAddressFamily_AF_ATMPVC Mono_Posix_UnixAddressFamily_AF_ATMPVC
+ Mono_Posix_UnixAddressFamily_AF_ATMSVC = 0x00000014,
+ #define Mono_Posix_UnixAddressFamily_AF_ATMSVC Mono_Posix_UnixAddressFamily_AF_ATMSVC
+ Mono_Posix_UnixAddressFamily_AF_AX25 = 0x00000003,
+ #define Mono_Posix_UnixAddressFamily_AF_AX25 Mono_Posix_UnixAddressFamily_AF_AX25
+ Mono_Posix_UnixAddressFamily_AF_BLUETOOTH = 0x0000001f,
+ #define Mono_Posix_UnixAddressFamily_AF_BLUETOOTH Mono_Posix_UnixAddressFamily_AF_BLUETOOTH
+ Mono_Posix_UnixAddressFamily_AF_BRIDGE = 0x00000007,
+ #define Mono_Posix_UnixAddressFamily_AF_BRIDGE Mono_Posix_UnixAddressFamily_AF_BRIDGE
+ Mono_Posix_UnixAddressFamily_AF_CAIF = 0x00000025,
+ #define Mono_Posix_UnixAddressFamily_AF_CAIF Mono_Posix_UnixAddressFamily_AF_CAIF
+ Mono_Posix_UnixAddressFamily_AF_CAN = 0x0000001d,
+ #define Mono_Posix_UnixAddressFamily_AF_CAN Mono_Posix_UnixAddressFamily_AF_CAN
+ Mono_Posix_UnixAddressFamily_AF_DECnet = 0x0000000c,
+ #define Mono_Posix_UnixAddressFamily_AF_DECnet Mono_Posix_UnixAddressFamily_AF_DECnet
+ Mono_Posix_UnixAddressFamily_AF_ECONET = 0x00000013,
+ #define Mono_Posix_UnixAddressFamily_AF_ECONET Mono_Posix_UnixAddressFamily_AF_ECONET
+ Mono_Posix_UnixAddressFamily_AF_IEEE802154 = 0x00000024,
+ #define Mono_Posix_UnixAddressFamily_AF_IEEE802154 Mono_Posix_UnixAddressFamily_AF_IEEE802154
+ Mono_Posix_UnixAddressFamily_AF_INET = 0x00000002,
+ #define Mono_Posix_UnixAddressFamily_AF_INET Mono_Posix_UnixAddressFamily_AF_INET
+ Mono_Posix_UnixAddressFamily_AF_INET6 = 0x0000000a,
+ #define Mono_Posix_UnixAddressFamily_AF_INET6 Mono_Posix_UnixAddressFamily_AF_INET6
+ Mono_Posix_UnixAddressFamily_AF_IPX = 0x00000004,
+ #define Mono_Posix_UnixAddressFamily_AF_IPX Mono_Posix_UnixAddressFamily_AF_IPX
+ Mono_Posix_UnixAddressFamily_AF_IRDA = 0x00000017,
+ #define Mono_Posix_UnixAddressFamily_AF_IRDA Mono_Posix_UnixAddressFamily_AF_IRDA
+ Mono_Posix_UnixAddressFamily_AF_ISDN = 0x00000022,
+ #define Mono_Posix_UnixAddressFamily_AF_ISDN Mono_Posix_UnixAddressFamily_AF_ISDN
+ Mono_Posix_UnixAddressFamily_AF_IUCV = 0x00000020,
+ #define Mono_Posix_UnixAddressFamily_AF_IUCV Mono_Posix_UnixAddressFamily_AF_IUCV
+ Mono_Posix_UnixAddressFamily_AF_KEY = 0x0000000f,
+ #define Mono_Posix_UnixAddressFamily_AF_KEY Mono_Posix_UnixAddressFamily_AF_KEY
+ Mono_Posix_UnixAddressFamily_AF_LLC = 0x0000001a,
+ #define Mono_Posix_UnixAddressFamily_AF_LLC Mono_Posix_UnixAddressFamily_AF_LLC
+ Mono_Posix_UnixAddressFamily_AF_NETBEUI = 0x0000000d,
+ #define Mono_Posix_UnixAddressFamily_AF_NETBEUI Mono_Posix_UnixAddressFamily_AF_NETBEUI
+ Mono_Posix_UnixAddressFamily_AF_NETLINK = 0x00000010,
+ #define Mono_Posix_UnixAddressFamily_AF_NETLINK Mono_Posix_UnixAddressFamily_AF_NETLINK
+ Mono_Posix_UnixAddressFamily_AF_NETROM = 0x00000006,
+ #define Mono_Posix_UnixAddressFamily_AF_NETROM Mono_Posix_UnixAddressFamily_AF_NETROM
+ Mono_Posix_UnixAddressFamily_AF_NFC = 0x00000027,
+ #define Mono_Posix_UnixAddressFamily_AF_NFC Mono_Posix_UnixAddressFamily_AF_NFC
+ Mono_Posix_UnixAddressFamily_AF_PACKET = 0x00000011,
+ #define Mono_Posix_UnixAddressFamily_AF_PACKET Mono_Posix_UnixAddressFamily_AF_PACKET
+ Mono_Posix_UnixAddressFamily_AF_PHONET = 0x00000023,
+ #define Mono_Posix_UnixAddressFamily_AF_PHONET Mono_Posix_UnixAddressFamily_AF_PHONET
+ Mono_Posix_UnixAddressFamily_AF_PPPOX = 0x00000018,
+ #define Mono_Posix_UnixAddressFamily_AF_PPPOX Mono_Posix_UnixAddressFamily_AF_PPPOX
+ Mono_Posix_UnixAddressFamily_AF_RDS = 0x00000015,
+ #define Mono_Posix_UnixAddressFamily_AF_RDS Mono_Posix_UnixAddressFamily_AF_RDS
+ Mono_Posix_UnixAddressFamily_AF_ROSE = 0x0000000b,
+ #define Mono_Posix_UnixAddressFamily_AF_ROSE Mono_Posix_UnixAddressFamily_AF_ROSE
+ Mono_Posix_UnixAddressFamily_AF_RXRPC = 0x00000021,
+ #define Mono_Posix_UnixAddressFamily_AF_RXRPC Mono_Posix_UnixAddressFamily_AF_RXRPC
+ Mono_Posix_UnixAddressFamily_AF_SECURITY = 0x0000000e,
+ #define Mono_Posix_UnixAddressFamily_AF_SECURITY Mono_Posix_UnixAddressFamily_AF_SECURITY
+ Mono_Posix_UnixAddressFamily_AF_SNA = 0x00000016,
+ #define Mono_Posix_UnixAddressFamily_AF_SNA Mono_Posix_UnixAddressFamily_AF_SNA
+ Mono_Posix_UnixAddressFamily_AF_TIPC = 0x0000001e,
+ #define Mono_Posix_UnixAddressFamily_AF_TIPC Mono_Posix_UnixAddressFamily_AF_TIPC
+ Mono_Posix_UnixAddressFamily_AF_UNIX = 0x00000001,
+ #define Mono_Posix_UnixAddressFamily_AF_UNIX Mono_Posix_UnixAddressFamily_AF_UNIX
+ Mono_Posix_UnixAddressFamily_AF_UNSPEC = 0x00000000,
+ #define Mono_Posix_UnixAddressFamily_AF_UNSPEC Mono_Posix_UnixAddressFamily_AF_UNSPEC
+ Mono_Posix_UnixAddressFamily_AF_VSOCK = 0x00000028,
+ #define Mono_Posix_UnixAddressFamily_AF_VSOCK Mono_Posix_UnixAddressFamily_AF_VSOCK
+ Mono_Posix_UnixAddressFamily_AF_WANPIPE = 0x00000019,
+ #define Mono_Posix_UnixAddressFamily_AF_WANPIPE Mono_Posix_UnixAddressFamily_AF_WANPIPE
+ Mono_Posix_UnixAddressFamily_AF_X25 = 0x00000009,
+ #define Mono_Posix_UnixAddressFamily_AF_X25 Mono_Posix_UnixAddressFamily_AF_X25
+};
+int Mono_Posix_FromUnixAddressFamily (int x, int *r);
+int Mono_Posix_ToUnixAddressFamily (int x, int *r);
+
+enum Mono_Posix_UnixSocketFlags {
+ Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC = 0x00080000,
+ #define Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC
+ Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK = 0x00000800,
+ #define Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK
+};
+int Mono_Posix_FromUnixSocketFlags (int x, int *r);
+int Mono_Posix_ToUnixSocketFlags (int x, int *r);
+
+enum Mono_Posix_UnixSocketOptionName {
+ Mono_Posix_UnixSocketOptionName_SO_ACCEPTCONN = 0x0000001e,
+ #define Mono_Posix_UnixSocketOptionName_SO_ACCEPTCONN Mono_Posix_UnixSocketOptionName_SO_ACCEPTCONN
+ Mono_Posix_UnixSocketOptionName_SO_ATTACH_FILTER = 0x0000001a,
+ #define Mono_Posix_UnixSocketOptionName_SO_ATTACH_FILTER Mono_Posix_UnixSocketOptionName_SO_ATTACH_FILTER
+ Mono_Posix_UnixSocketOptionName_SO_BINDTODEVICE = 0x00000019,
+ #define Mono_Posix_UnixSocketOptionName_SO_BINDTODEVICE Mono_Posix_UnixSocketOptionName_SO_BINDTODEVICE
+ Mono_Posix_UnixSocketOptionName_SO_BROADCAST = 0x00000006,
+ #define Mono_Posix_UnixSocketOptionName_SO_BROADCAST Mono_Posix_UnixSocketOptionName_SO_BROADCAST
+ Mono_Posix_UnixSocketOptionName_SO_BSDCOMPAT = 0x0000000e,
+ #define Mono_Posix_UnixSocketOptionName_SO_BSDCOMPAT Mono_Posix_UnixSocketOptionName_SO_BSDCOMPAT
+ Mono_Posix_UnixSocketOptionName_SO_BUSY_POLL = 0x0000002e,
+ #define Mono_Posix_UnixSocketOptionName_SO_BUSY_POLL Mono_Posix_UnixSocketOptionName_SO_BUSY_POLL
+ Mono_Posix_UnixSocketOptionName_SO_DEBUG = 0x00000001,
+ #define Mono_Posix_UnixSocketOptionName_SO_DEBUG Mono_Posix_UnixSocketOptionName_SO_DEBUG
+ Mono_Posix_UnixSocketOptionName_SO_DETACH_FILTER = 0x0000001b,
+ #define Mono_Posix_UnixSocketOptionName_SO_DETACH_FILTER Mono_Posix_UnixSocketOptionName_SO_DETACH_FILTER
+ Mono_Posix_UnixSocketOptionName_SO_DOMAIN = 0x00000027,
+ #define Mono_Posix_UnixSocketOptionName_SO_DOMAIN Mono_Posix_UnixSocketOptionName_SO_DOMAIN
+ Mono_Posix_UnixSocketOptionName_SO_DONTROUTE = 0x00000005,
+ #define Mono_Posix_UnixSocketOptionName_SO_DONTROUTE Mono_Posix_UnixSocketOptionName_SO_DONTROUTE
+ Mono_Posix_UnixSocketOptionName_SO_ERROR = 0x00000004,
+ #define Mono_Posix_UnixSocketOptionName_SO_ERROR Mono_Posix_UnixSocketOptionName_SO_ERROR
+ Mono_Posix_UnixSocketOptionName_SO_KEEPALIVE = 0x00000009,
+ #define Mono_Posix_UnixSocketOptionName_SO_KEEPALIVE Mono_Posix_UnixSocketOptionName_SO_KEEPALIVE
+ Mono_Posix_UnixSocketOptionName_SO_LINGER = 0x0000000d,
+ #define Mono_Posix_UnixSocketOptionName_SO_LINGER Mono_Posix_UnixSocketOptionName_SO_LINGER
+ Mono_Posix_UnixSocketOptionName_SO_LOCK_FILTER = 0x0000002c,
+ #define Mono_Posix_UnixSocketOptionName_SO_LOCK_FILTER Mono_Posix_UnixSocketOptionName_SO_LOCK_FILTER
+ Mono_Posix_UnixSocketOptionName_SO_MARK = 0x00000024,
+ #define Mono_Posix_UnixSocketOptionName_SO_MARK Mono_Posix_UnixSocketOptionName_SO_MARK
+ Mono_Posix_UnixSocketOptionName_SO_MAX_PACING_RATE = 0x0000002f,
+ #define Mono_Posix_UnixSocketOptionName_SO_MAX_PACING_RATE Mono_Posix_UnixSocketOptionName_SO_MAX_PACING_RATE
+ Mono_Posix_UnixSocketOptionName_SO_NOFCS = 0x0000002b,
+ #define Mono_Posix_UnixSocketOptionName_SO_NOFCS Mono_Posix_UnixSocketOptionName_SO_NOFCS
+ Mono_Posix_UnixSocketOptionName_SO_NO_CHECK = 0x0000000b,
+ #define Mono_Posix_UnixSocketOptionName_SO_NO_CHECK Mono_Posix_UnixSocketOptionName_SO_NO_CHECK
+ Mono_Posix_UnixSocketOptionName_SO_OOBINLINE = 0x0000000a,
+ #define Mono_Posix_UnixSocketOptionName_SO_OOBINLINE Mono_Posix_UnixSocketOptionName_SO_OOBINLINE
+ Mono_Posix_UnixSocketOptionName_SO_PASSCRED = 0x00000010,
+ #define Mono_Posix_UnixSocketOptionName_SO_PASSCRED Mono_Posix_UnixSocketOptionName_SO_PASSCRED
+ Mono_Posix_UnixSocketOptionName_SO_PASSSEC = 0x00000022,
+ #define Mono_Posix_UnixSocketOptionName_SO_PASSSEC Mono_Posix_UnixSocketOptionName_SO_PASSSEC
+ Mono_Posix_UnixSocketOptionName_SO_PEEK_OFF = 0x0000002a,
+ #define Mono_Posix_UnixSocketOptionName_SO_PEEK_OFF Mono_Posix_UnixSocketOptionName_SO_PEEK_OFF
+ Mono_Posix_UnixSocketOptionName_SO_PEERCRED = 0x00000011,
+ #define Mono_Posix_UnixSocketOptionName_SO_PEERCRED Mono_Posix_UnixSocketOptionName_SO_PEERCRED
+ Mono_Posix_UnixSocketOptionName_SO_PEERNAME = 0x0000001c,
+ #define Mono_Posix_UnixSocketOptionName_SO_PEERNAME Mono_Posix_UnixSocketOptionName_SO_PEERNAME
+ Mono_Posix_UnixSocketOptionName_SO_PEERSEC = 0x0000001f,
+ #define Mono_Posix_UnixSocketOptionName_SO_PEERSEC Mono_Posix_UnixSocketOptionName_SO_PEERSEC
+ Mono_Posix_UnixSocketOptionName_SO_PRIORITY = 0x0000000c,
+ #define Mono_Posix_UnixSocketOptionName_SO_PRIORITY Mono_Posix_UnixSocketOptionName_SO_PRIORITY
+ Mono_Posix_UnixSocketOptionName_SO_PROTOCOL = 0x00000026,
+ #define Mono_Posix_UnixSocketOptionName_SO_PROTOCOL Mono_Posix_UnixSocketOptionName_SO_PROTOCOL
+ Mono_Posix_UnixSocketOptionName_SO_RCVBUF = 0x00000008,
+ #define Mono_Posix_UnixSocketOptionName_SO_RCVBUF Mono_Posix_UnixSocketOptionName_SO_RCVBUF
+ Mono_Posix_UnixSocketOptionName_SO_RCVBUFFORCE = 0x00000021,
+ #define Mono_Posix_UnixSocketOptionName_SO_RCVBUFFORCE Mono_Posix_UnixSocketOptionName_SO_RCVBUFFORCE
+ Mono_Posix_UnixSocketOptionName_SO_RCVLOWAT = 0x00000012,
+ #define Mono_Posix_UnixSocketOptionName_SO_RCVLOWAT Mono_Posix_UnixSocketOptionName_SO_RCVLOWAT
+ Mono_Posix_UnixSocketOptionName_SO_RCVTIMEO = 0x00000014,
+ #define Mono_Posix_UnixSocketOptionName_SO_RCVTIMEO Mono_Posix_UnixSocketOptionName_SO_RCVTIMEO
+ Mono_Posix_UnixSocketOptionName_SO_REUSEADDR = 0x00000002,
+ #define Mono_Posix_UnixSocketOptionName_SO_REUSEADDR Mono_Posix_UnixSocketOptionName_SO_REUSEADDR
+ Mono_Posix_UnixSocketOptionName_SO_REUSEPORT = 0x0000000f,
+ #define Mono_Posix_UnixSocketOptionName_SO_REUSEPORT Mono_Posix_UnixSocketOptionName_SO_REUSEPORT
+ Mono_Posix_UnixSocketOptionName_SO_RXQ_OVFL = 0x00000028,
+ #define Mono_Posix_UnixSocketOptionName_SO_RXQ_OVFL Mono_Posix_UnixSocketOptionName_SO_RXQ_OVFL
+ Mono_Posix_UnixSocketOptionName_SO_SECURITY_AUTHENTICATION = 0x00000016,
+ #define Mono_Posix_UnixSocketOptionName_SO_SECURITY_AUTHENTICATION Mono_Posix_UnixSocketOptionName_SO_SECURITY_AUTHENTICATION
+ Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_NETWORK = 0x00000018,
+ #define Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_NETWORK Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_NETWORK
+ Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_TRANSPORT = 0x00000017,
+ #define Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_TRANSPORT Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_TRANSPORT
+ Mono_Posix_UnixSocketOptionName_SO_SELECT_ERR_QUEUE = 0x0000002d,
+ #define Mono_Posix_UnixSocketOptionName_SO_SELECT_ERR_QUEUE Mono_Posix_UnixSocketOptionName_SO_SELECT_ERR_QUEUE
+ Mono_Posix_UnixSocketOptionName_SO_SNDBUF = 0x00000007,
+ #define Mono_Posix_UnixSocketOptionName_SO_SNDBUF Mono_Posix_UnixSocketOptionName_SO_SNDBUF
+ Mono_Posix_UnixSocketOptionName_SO_SNDBUFFORCE = 0x00000020,
+ #define Mono_Posix_UnixSocketOptionName_SO_SNDBUFFORCE Mono_Posix_UnixSocketOptionName_SO_SNDBUFFORCE
+ Mono_Posix_UnixSocketOptionName_SO_SNDLOWAT = 0x00000013,
+ #define Mono_Posix_UnixSocketOptionName_SO_SNDLOWAT Mono_Posix_UnixSocketOptionName_SO_SNDLOWAT
+ Mono_Posix_UnixSocketOptionName_SO_SNDTIMEO = 0x00000015,
+ #define Mono_Posix_UnixSocketOptionName_SO_SNDTIMEO Mono_Posix_UnixSocketOptionName_SO_SNDTIMEO
+ Mono_Posix_UnixSocketOptionName_SO_TIMESTAMP = 0x0000001d,
+ #define Mono_Posix_UnixSocketOptionName_SO_TIMESTAMP Mono_Posix_UnixSocketOptionName_SO_TIMESTAMP
+ Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPING = 0x00000025,
+ #define Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPING Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPING
+ Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPNS = 0x00000023,
+ #define Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPNS Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPNS
+ Mono_Posix_UnixSocketOptionName_SO_TYPE = 0x00000003,
+ #define Mono_Posix_UnixSocketOptionName_SO_TYPE Mono_Posix_UnixSocketOptionName_SO_TYPE
+ Mono_Posix_UnixSocketOptionName_SO_WIFI_STATUS = 0x00000029,
+ #define Mono_Posix_UnixSocketOptionName_SO_WIFI_STATUS Mono_Posix_UnixSocketOptionName_SO_WIFI_STATUS
+};
+int Mono_Posix_FromUnixSocketOptionName (int x, int *r);
+int Mono_Posix_ToUnixSocketOptionName (int x, int *r);
+
+enum Mono_Posix_UnixSocketProtocol {
+ Mono_Posix_UnixSocketProtocol_IPPROTO_AH = 0x00000033,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_AH Mono_Posix_UnixSocketProtocol_IPPROTO_AH
+ Mono_Posix_UnixSocketProtocol_IPPROTO_BEETPH = 0x0000005e,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_BEETPH Mono_Posix_UnixSocketProtocol_IPPROTO_BEETPH
+ Mono_Posix_UnixSocketProtocol_IPPROTO_COMP = 0x0000006c,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_COMP Mono_Posix_UnixSocketProtocol_IPPROTO_COMP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_DCCP = 0x00000021,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_DCCP Mono_Posix_UnixSocketProtocol_IPPROTO_DCCP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_EGP = 0x00000008,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_EGP Mono_Posix_UnixSocketProtocol_IPPROTO_EGP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_ENCAP = 0x00000062,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_ENCAP Mono_Posix_UnixSocketProtocol_IPPROTO_ENCAP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_ESP = 0x00000032,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_ESP Mono_Posix_UnixSocketProtocol_IPPROTO_ESP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_GRE = 0x0000002f,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_GRE Mono_Posix_UnixSocketProtocol_IPPROTO_GRE
+ Mono_Posix_UnixSocketProtocol_IPPROTO_ICMP = 0x00000001,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_ICMP Mono_Posix_UnixSocketProtocol_IPPROTO_ICMP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_IDP = 0x00000016,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_IDP Mono_Posix_UnixSocketProtocol_IPPROTO_IDP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_IGMP = 0x00000002,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_IGMP Mono_Posix_UnixSocketProtocol_IPPROTO_IGMP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_IP = 0x00000400,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_IP Mono_Posix_UnixSocketProtocol_IPPROTO_IP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_IPIP = 0x00000004,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_IPIP Mono_Posix_UnixSocketProtocol_IPPROTO_IPIP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_IPV6 = 0x00000029,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_IPV6 Mono_Posix_UnixSocketProtocol_IPPROTO_IPV6
+ Mono_Posix_UnixSocketProtocol_IPPROTO_MTP = 0x0000005c,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_MTP Mono_Posix_UnixSocketProtocol_IPPROTO_MTP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_PIM = 0x00000067,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_PIM Mono_Posix_UnixSocketProtocol_IPPROTO_PIM
+ Mono_Posix_UnixSocketProtocol_IPPROTO_PUP = 0x0000000c,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_PUP Mono_Posix_UnixSocketProtocol_IPPROTO_PUP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_RAW = 0x000000ff,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_RAW Mono_Posix_UnixSocketProtocol_IPPROTO_RAW
+ Mono_Posix_UnixSocketProtocol_IPPROTO_RSVP = 0x0000002e,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_RSVP Mono_Posix_UnixSocketProtocol_IPPROTO_RSVP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_SCTP = 0x00000084,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_SCTP Mono_Posix_UnixSocketProtocol_IPPROTO_SCTP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_TCP = 0x00000006,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_TCP Mono_Posix_UnixSocketProtocol_IPPROTO_TCP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_TP = 0x0000001d,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_TP Mono_Posix_UnixSocketProtocol_IPPROTO_TP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_UDP = 0x00000011,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_UDP Mono_Posix_UnixSocketProtocol_IPPROTO_UDP
+ Mono_Posix_UnixSocketProtocol_IPPROTO_UDPLITE = 0x00000088,
+ #define Mono_Posix_UnixSocketProtocol_IPPROTO_UDPLITE Mono_Posix_UnixSocketProtocol_IPPROTO_UDPLITE
+ Mono_Posix_UnixSocketProtocol_SOL_SOCKET = 0x00000800,
+ #define Mono_Posix_UnixSocketProtocol_SOL_SOCKET Mono_Posix_UnixSocketProtocol_SOL_SOCKET
+};
+int Mono_Posix_FromUnixSocketProtocol (int x, int *r);
+int Mono_Posix_ToUnixSocketProtocol (int x, int *r);
+
+enum Mono_Posix_UnixSocketType {
+ Mono_Posix_UnixSocketType_SOCK_DCCP = 0x00000006,
+ #define Mono_Posix_UnixSocketType_SOCK_DCCP Mono_Posix_UnixSocketType_SOCK_DCCP
+ Mono_Posix_UnixSocketType_SOCK_DGRAM = 0x00000002,
+ #define Mono_Posix_UnixSocketType_SOCK_DGRAM Mono_Posix_UnixSocketType_SOCK_DGRAM
+ Mono_Posix_UnixSocketType_SOCK_PACKET = 0x0000000a,
+ #define Mono_Posix_UnixSocketType_SOCK_PACKET Mono_Posix_UnixSocketType_SOCK_PACKET
+ Mono_Posix_UnixSocketType_SOCK_RAW = 0x00000003,
+ #define Mono_Posix_UnixSocketType_SOCK_RAW Mono_Posix_UnixSocketType_SOCK_RAW
+ Mono_Posix_UnixSocketType_SOCK_RDM = 0x00000004,
+ #define Mono_Posix_UnixSocketType_SOCK_RDM Mono_Posix_UnixSocketType_SOCK_RDM
+ Mono_Posix_UnixSocketType_SOCK_SEQPACKET = 0x00000005,
+ #define Mono_Posix_UnixSocketType_SOCK_SEQPACKET Mono_Posix_UnixSocketType_SOCK_SEQPACKET
+ Mono_Posix_UnixSocketType_SOCK_STREAM = 0x00000001,
+ #define Mono_Posix_UnixSocketType_SOCK_STREAM Mono_Posix_UnixSocketType_SOCK_STREAM
+};
+int Mono_Posix_FromUnixSocketType (int x, int *r);
+int Mono_Posix_ToUnixSocketType (int x, int *r);
+
enum Mono_Posix_WaitOptions {
Mono_Posix_WaitOptions_WNOHANG = 0x00000001,
#define Mono_Posix_WaitOptions_WNOHANG Mono_Posix_WaitOptions_WNOHANG
struct Mono_Posix_Flock;
struct Mono_Posix_Iovec;
+struct Mono_Posix_Linger;
struct Mono_Posix_Pollfd;
struct Mono_Posix_Stat;
struct Mono_Posix_Statvfs;
struct flock;
struct iovec;
+struct linger;
struct pollfd;
struct timespec;
struct timeval;
Mono_Posix_ToIovec (struct iovec *from, struct Mono_Posix_Iovec* to);
+struct Mono_Posix_Linger {
+ int l_onoff;
+ int l_linger;
+};
+
+int
+Mono_Posix_FromLinger (struct Mono_Posix_Linger* from, struct linger *to);
+int
+Mono_Posix_ToLinger (struct linger *from, struct Mono_Posix_Linger* to);
+
+
struct Mono_Posix_Pollfd {
int fd;
short events;
int Mono_Posix_Syscall_endusershell (void);
int Mono_Posix_Syscall_fcntl (int fd, int cmd);
int Mono_Posix_Syscall_fcntl_arg (int fd, int cmd, gint64 arg);
+int Mono_Posix_Syscall_fcntl_arg_int (int fd, int cmd, int arg);
+int Mono_Posix_Syscall_fcntl_arg_ptr (int fd, int cmd, void* ptr);
int Mono_Posix_Syscall_fcntl_lock (int fd, int cmd, struct Mono_Posix_Flock* lock);
int Mono_Posix_Syscall_fgetgrent (void* stream, struct Mono_Posix_Syscall__Group* grbuf);
int Mono_Posix_Syscall_fgetpwent (void* stream, struct Mono_Posix_Syscall__Passwd* pwbuf);
int Mono_Posix_Syscall_getpwnam_r (const char* name, struct Mono_Posix_Syscall__Passwd* pwbuf, void** pwbufp);
int Mono_Posix_Syscall_getpwuid (unsigned int uid, struct Mono_Posix_Syscall__Passwd* passwd);
int Mono_Posix_Syscall_getpwuid_r (unsigned int uid, struct Mono_Posix_Syscall__Passwd* pwbuf, void** pwbufp);
+int Mono_Posix_Syscall_getsockopt (int socket, int level, int option_name, void* option_value, gint64* option_len);
+int Mono_Posix_Syscall_getsockopt_linger (int socket, int level, int option_name, struct Mono_Posix_Linger* option_value);
+int Mono_Posix_Syscall_getsockopt_timeval (int socket, int level, int option_name, struct Mono_Posix_Timeval* option_value);
int Mono_Posix_Syscall_gettimeofday (struct Mono_Posix_Timeval* tv, void* ignore);
gint64 Mono_Posix_Syscall_getxattr (const char* path, const char* name, unsigned char* value, guint64 size);
int Mono_Posix_Syscall_L_ctermid (void);
gint64 Mono_Posix_Syscall_readlink (const char* path, unsigned char* buf, guint64 bufsiz);
gint64 Mono_Posix_Syscall_readlinkat (int dirfd, const char* pathname, unsigned char* buf, guint64 bufsiz);
gint64 Mono_Posix_Syscall_readv (int fd, struct Mono_Posix_Iovec* iov, int iovcnt);
+gint64 Mono_Posix_Syscall_recv (int socket, void* buffer, guint64 length, int flags);
int Mono_Posix_Syscall_remap_file_pages (void* start, guint64 size, int prot, gint64 pgoff, int flags);
int Mono_Posix_Syscall_removexattr (const char* path, const char* name);
int Mono_Posix_Syscall_rewinddir (void* dir);
int Mono_Posix_Syscall_seekdir (void* dir, gint64 offset);
+gint64 Mono_Posix_Syscall_send (int socket, void* message, guint64 length, int flags);
gint64 Mono_Posix_Syscall_sendfile (int out_fd, int in_fd, gint64* offset, guint64 count);
int Mono_Posix_Syscall_setdomainname (const char* name, guint64 len);
int Mono_Posix_Syscall_setfsent (void);
int Mono_Posix_Syscall_sethostid (gint64 hostid);
int Mono_Posix_Syscall_sethostname (const char* name, guint64 len);
int Mono_Posix_Syscall_setpwent (void);
+int Mono_Posix_Syscall_setsockopt (int socket, int level, int option_name, void* option_value, gint64 option_len);
+int Mono_Posix_Syscall_setsockopt_linger (int socket, int level, int option_name, struct Mono_Posix_Linger* option_value);
+int Mono_Posix_Syscall_setsockopt_timeval (int socket, int level, int option_name, struct Mono_Posix_Timeval* option_value);
int Mono_Posix_Syscall_settimeofday (struct Mono_Posix_Timeval* tv, struct Mono_Posix_Timezone* tz);
int Mono_Posix_Syscall_setusershell (void);
int Mono_Posix_Syscall_setxattr (const char* path, const char* name, unsigned char* value, guint64 size, int flags);
+int Mono_Posix_Syscall_socketpair (int domain, int type, int protocol, int* socket1, int* socket2);
int Mono_Posix_Syscall_stat (const char* file_name, struct Mono_Posix_Stat* buf);
int Mono_Posix_Syscall_statvfs (const char* path, struct Mono_Posix_Statvfs* buf);
int Mono_Posix_Syscall_stime (gint64* t);
return ret; \
}}G_STMT_END
+#define mph_have_uint_overflow(var) ((var) < 0 || (var) > UINT_MAX)
+
+#define mph_return_val_if_uint_overflow(var, ret) \
+ _mph_return_val_if_cb_(var, ret, mph_have_uint_overflow)
+
+#define mph_return_if_uint_overflow(var) mph_return_val_if_uint_overflow(var, -1)
+
#define mph_have_long_overflow(var) ((var) > LONG_MAX || (var) < LONG_MIN)
#define mph_return_val_if_long_overflow(var, ret) \
#define mph_return_if_long_overflow(var) mph_return_val_if_long_overflow(var, -1)
-#define mph_have_ulong_overflow(var) ((var) > ULONG_MAX)
+#define mph_have_ulong_overflow(var) (var) < 0 || ((var) > ULONG_MAX)
#define mph_return_val_if_ulong_overflow(var, ret) \
_mph_return_val_if_cb_(var, ret, mph_have_ulong_overflow)
#define mph_return_if_ulong_overflow(var) mph_return_val_if_ulong_overflow(var, -1)
-#define mph_have_size_t_overflow(var) ((var) > MPH_SIZE_T_MAX)
+#define mph_have_size_t_overflow(var) ((var) < 0 || (var) > MPH_SIZE_T_MAX)
#define mph_return_val_if_size_t_overflow(var, ret) \
_mph_return_val_if_cb_(var, ret, mph_have_size_t_overflow)
#define mph_return_if_time_t_overflow(var) mph_return_if_long_overflow(var)
+#define mph_return_if_socklen_t_overflow(var) mph_return_if_uint_overflow(var)
+
#define mph_return_if_val_in_list5(var,a,b,c,d,e) \
do { \
int v = (var); \
--- /dev/null
+/*
+ * <sys/socket.h> wrapper functions.
+ *
+ * Authors:
+ * Steffen Kiess (s-kiess@web.de)
+ *
+ * Copyright (C) 2015 Steffen Kiess
+ */
+
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <sys/un.h>
+
+#include <stddef.h>
+
+#include "map.h"
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+int
+Mono_Posix_Syscall_socketpair (int domain, int type, int protocol, int* socket1, int* socket2)
+{
+ int filedes[2] = {-1, -1};
+ int r;
+
+ r = socketpair (domain, type, protocol, filedes);
+
+ *socket1 = filedes[0];
+ *socket2 = filedes[1];
+ return r;
+}
+
+int
+Mono_Posix_Syscall_getsockopt (int socket, int level, int option_name, void* option_value, gint64* option_len)
+{
+ socklen_t len;
+ int r;
+
+ mph_return_if_socklen_t_overflow (*option_len);
+
+ len = *option_len;
+
+ r = getsockopt (socket, level, option_name, option_value, &len);
+
+ *option_len = len;
+
+ return r;
+}
+
+int
+Mono_Posix_Syscall_getsockopt_timeval (int socket, int level, int option_name, struct Mono_Posix_Timeval* option_value)
+{
+ struct timeval tv;
+ int r;
+ socklen_t size;
+
+ size = sizeof (struct timeval);
+ r = getsockopt (socket, level, option_name, &tv, &size);
+
+ if (r != -1 && size == sizeof (struct timeval)) {
+ if (Mono_Posix_ToTimeval (&tv, option_value) != 0)
+ return -1;
+ } else {
+ memset (option_value, 0, sizeof (struct Mono_Posix_Timeval));
+ if (r != -1)
+ errno = EINVAL;
+ }
+
+ return r;
+}
+
+int
+Mono_Posix_Syscall_getsockopt_linger (int socket, int level, int option_name, struct Mono_Posix_Linger* option_value)
+{
+ struct linger ling;
+ int r;
+ socklen_t size;
+
+ size = sizeof (struct linger);
+ r = getsockopt (socket, level, option_name, &ling, &size);
+
+ if (r != -1 && size == sizeof (struct linger)) {
+ if (Mono_Posix_ToLinger (&ling, option_value) != 0)
+ return -1;
+ } else {
+ memset (option_value, 0, sizeof (struct Mono_Posix_Linger));
+ if (r != -1)
+ errno = EINVAL;
+ }
+
+ return r;
+}
+
+int
+Mono_Posix_Syscall_setsockopt (int socket, int level, int option_name, void* option_value, gint64 option_len)
+{
+ mph_return_if_socklen_t_overflow (option_len);
+
+ return setsockopt (socket, level, option_name, option_value, option_len);
+}
+
+int
+Mono_Posix_Syscall_setsockopt_timeval (int socket, int level, int option_name, struct Mono_Posix_Timeval* option_value)
+{
+ struct timeval tv;
+
+ if (Mono_Posix_FromTimeval (option_value, &tv) != 0)
+ return -1;
+
+ return setsockopt (socket, level, option_name, &tv, sizeof (struct timeval));
+}
+
+int
+Mono_Posix_Syscall_setsockopt_linger (int socket, int level, int option_name, struct Mono_Posix_Linger* option_value)
+{
+ struct linger ling;
+
+ if (Mono_Posix_FromLinger (option_value, &ling) != 0)
+ return -1;
+
+ return setsockopt (socket, level, option_name, &ling, sizeof (struct linger));
+}
+
+gint64
+Mono_Posix_Syscall_recv (int socket, void* message, guint64 length, int flags)
+{
+ mph_return_if_size_t_overflow (length);
+
+ return recv (socket, message, length, flags);
+}
+
+gint64
+Mono_Posix_Syscall_send (int socket, void* message, guint64 length, int flags)
+{
+ mph_return_if_size_t_overflow (length);
+
+ return send (socket, message, length, flags);
+}
#define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
-#define FLUSH()
-
#define DEFAULT_PRINT()
#define CUSTOM_PRINT(_)
#define IS_VTABLE_MATCH(_)
#define END_PROTOCOL_ENTRY
+#define END_PROTOCOL_ENTRY_FLUSH
#define END_PROTOCOL_ENTRY_HEAVY
#include <mono/sgen/sgen-protocol-def.h>
#define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
-#define FLUSH()
-
#define DEFAULT_PRINT()
#define CUSTOM_PRINT(_)
#define IS_VTABLE_MATCH(_)
#define END_PROTOCOL_ENTRY
+#define END_PROTOCOL_ENTRY_FLUSH
#define END_PROTOCOL_ENTRY_HEAVY
#include <mono/sgen/sgen-protocol-def.h>
#define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
-#define FLUSH()
-
#define DEFAULT_PRINT() \
print_entry_content (pes_size, pes, color_output);
#define CUSTOM_PRINT(print) \
printf ("\n"); \
break; \
}
+#define END_PROTOCOL_ENTRY_FLUSH \
+ END_PROTOCOL_ENTRY
#define END_PROTOCOL_ENTRY_HEAVY \
END_PROTOCOL_ENTRY
#define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
-#define FLUSH()
-
#define DEFAULT_PRINT()
#define CUSTOM_PRINT(_)
#define END_PROTOCOL_ENTRY \
break; \
}
+#define END_PROTOCOL_ENTRY_FLUSH \
+ END_PROTOCOL_ENTRY
#define END_PROTOCOL_ENTRY_HEAVY \
END_PROTOCOL_ENTRY
#define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
-#define FLUSH()
-
#define DEFAULT_PRINT()
#define CUSTOM_PRINT(_)
#define END_PROTOCOL_ENTRY \
break; \
}
+#define END_PROTOCOL_ENTRY_FLUSH \
+ END_PROTOCOL_ENTRY
#define END_PROTOCOL_ENTRY_HEAVY \
END_PROTOCOL_ENTRY