[Mono.Posix] Support OS X ENOATTR
[mono.git] / mcs / class / Mono.Posix / Mono.Unix.Native / Stdlib.cs
1 //
2 // Mono.Unix/Stdlib.cs
3 //
4 // Authors:
5 //   Jonathan Pryor (jonpryor@vt.edu)
6 //
7 // (C) 2004-2006 Jonathan Pryor
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 using System;
30 using System.Collections;
31 using System.IO;
32 using System.Runtime.InteropServices;
33 using System.Text;
34 using Mono.Unix.Native;
35
36 namespace Mono.Unix.Native {
37
38         #region Enumerations
39
40         [Map]
41         public enum Errno : int {
42                 // errors & their values liberally copied from
43                 // FC2 /usr/include/asm/errno.h
44                 
45                 EPERM           =   1, // Operation not permitted 
46                 ENOENT          =   2, // No such file or directory 
47                 ESRCH           =   3, // No such process 
48                 EINTR           =   4, // Interrupted system call 
49                 EIO             =   5, // I/O error 
50                 ENXIO           =   6, // No such device or address 
51                 E2BIG           =   7, // Arg list too long 
52                 ENOEXEC         =   8, // Exec format error 
53                 EBADF           =   9, // Bad file number 
54                 ECHILD          =  10, // No child processes 
55                 EAGAIN          =  11, // Try again 
56                 ENOMEM          =  12, // Out of memory 
57                 EACCES          =  13, // Permission denied 
58                 EFAULT          =  14, // Bad address 
59                 ENOTBLK         =  15, // Block device required 
60                 EBUSY           =  16, // Device or resource busy 
61                 EEXIST          =  17, // File exists 
62                 EXDEV           =  18, // Cross-device link 
63                 ENODEV          =  19, // No such device 
64                 ENOTDIR         =  20, // Not a directory 
65                 EISDIR          =  21, // Is a directory 
66                 EINVAL          =  22, // Invalid argument 
67                 ENFILE          =  23, // File table overflow 
68                 EMFILE          =  24, // Too many open files 
69                 ENOTTY          =  25, // Not a typewriter 
70                 ETXTBSY         =  26, // Text file busy 
71                 EFBIG           =  27, // File too large 
72                 ENOSPC          =  28, // No space left on device 
73                 ESPIPE          =  29, // Illegal seek 
74                 EROFS           =  30, // Read-only file system 
75                 EMLINK          =  31, // Too many links 
76                 EPIPE           =  32, // Broken pipe 
77                 EDOM            =  33, // Math argument out of domain of func 
78                 ERANGE          =  34, // Math result not representable 
79                 EDEADLK         =  35, // Resource deadlock would occur 
80                 ENAMETOOLONG    =  36, // File name too long 
81                 ENOLCK          =  37, // No record locks available 
82                 ENOSYS          =  38, // Function not implemented 
83                 ENOTEMPTY       =  39, // Directory not empty 
84                 ELOOP           =  40, // Too many symbolic links encountered 
85                 EWOULDBLOCK     =  EAGAIN, // Operation would block 
86                 ENOMSG          =  42, // No message of desired type 
87                 EIDRM           =  43, // Identifier removed 
88                 ECHRNG          =  44, // Channel number out of range 
89                 EL2NSYNC        =  45, // Level 2 not synchronized 
90                 EL3HLT          =  46, // Level 3 halted 
91                 EL3RST          =  47, // Level 3 reset 
92                 ELNRNG          =  48, // Link number out of range 
93                 EUNATCH         =  49, // Protocol driver not attached 
94                 ENOCSI          =  50, // No CSI structure available 
95                 EL2HLT          =  51, // Level 2 halted 
96                 EBADE           =  52, // Invalid exchange 
97                 EBADR           =  53, // Invalid request descriptor 
98                 EXFULL          =  54, // Exchange full 
99                 ENOANO          =  55, // No anode 
100                 EBADRQC         =  56, // Invalid request code 
101                 EBADSLT         =  57, // Invalid slot 
102                       
103                 EDEADLOCK             =  EDEADLK,
104                       
105                 EBFONT          =  59, // Bad font file format 
106                 ENOSTR          =  60, // Device not a stream 
107                 ENODATA         =  61, // No data available 
108                 ETIME           =  62, // Timer expired 
109                 ENOSR           =  63, // Out of streams resources 
110                 ENONET          =  64, // Machine is not on the network 
111                 ENOPKG          =  65, // Package not installed 
112                 EREMOTE         =  66, // Object is remote 
113                 ENOLINK         =  67, // Link has been severed 
114                 EADV            =  68, // Advertise error 
115                 ESRMNT          =  69, // Srmount error 
116                 ECOMM           =  70, // Communication error on send 
117                 EPROTO          =  71, // Protocol error 
118                 EMULTIHOP       =  72, // Multihop attempted 
119                 EDOTDOT         =  73, // RFS specific error 
120                 EBADMSG         =  74, // Not a data message 
121                 EOVERFLOW       =  75, // Value too large for defined data type 
122                 ENOTUNIQ        =  76, // Name not unique on network 
123                 EBADFD          =  77, // File descriptor in bad state 
124                 EREMCHG         =  78, // Remote address changed 
125                 ELIBACC         =  79, // Can not access a needed shared library 
126                 ELIBBAD         =  80, // Accessing a corrupted shared library 
127                 ELIBSCN         =  81, // .lib section in a.out corrupted 
128                 ELIBMAX         =  82, // Attempting to link in too many shared libraries 
129                 ELIBEXEC        =  83, // Cannot exec a shared library directly 
130                 EILSEQ          =  84, // Illegal byte sequence 
131                 ERESTART        =  85, // Interrupted system call should be restarted 
132                 ESTRPIPE        =  86, // Streams pipe error 
133                 EUSERS          =  87, // Too many users 
134                 ENOTSOCK        =  88, // Socket operation on non-socket 
135                 EDESTADDRREQ    =  89, // Destination address required 
136                 EMSGSIZE        =  90, // Message too long 
137                 EPROTOTYPE      =  91, // Protocol wrong type for socket 
138                 ENOPROTOOPT     =  92, // Protocol not available 
139                 EPROTONOSUPPORT =  93, // Protocol not supported 
140                 ESOCKTNOSUPPORT =  94, // Socket type not supported 
141                 EOPNOTSUPP      =  95, // Operation not supported on transport endpoint 
142                 EPFNOSUPPORT    =  96, // Protocol family not supported 
143                 EAFNOSUPPORT    =  97, // Address family not supported by protocol 
144                 EADDRINUSE      =  98, // Address already in use 
145                 EADDRNOTAVAIL   =  99, // Cannot assign requested address 
146                 ENETDOWN        = 100, // Network is down 
147                 ENETUNREACH     = 101, // Network is unreachable 
148                 ENETRESET       = 102, // Network dropped connection because of reset 
149                 ECONNABORTED    = 103, // Software caused connection abort 
150                 ECONNRESET      = 104, // Connection reset by peer 
151                 ENOBUFS         = 105, // No buffer space available 
152                 EISCONN         = 106, // Transport endpoint is already connected 
153                 ENOTCONN        = 107, // Transport endpoint is not connected 
154                 ESHUTDOWN       = 108, // Cannot send after transport endpoint shutdown 
155                 ETOOMANYREFS    = 109, // Too many references: cannot splice 
156                 ETIMEDOUT       = 110, // Connection timed out 
157                 ECONNREFUSED    = 111, // Connection refused 
158                 EHOSTDOWN       = 112, // Host is down 
159                 EHOSTUNREACH    = 113, // No route to host 
160                 EALREADY        = 114, // Operation already in progress 
161                 EINPROGRESS     = 115, // Operation now in progress 
162                 ESTALE          = 116, // Stale NFS file handle 
163                 EUCLEAN         = 117, // Structure needs cleaning 
164                 ENOTNAM         = 118, // Not a XENIX named type file 
165                 ENAVAIL         = 119, // No XENIX semaphores available 
166                 EISNAM          = 120, // Is a named type file 
167                 EREMOTEIO       = 121, // Remote I/O error 
168                 EDQUOT          = 122, // Quota exceeded 
169
170                 ENOMEDIUM       = 123, // No medium found 
171                 EMEDIUMTYPE     = 124, // Wrong medium type 
172
173                 ECANCELED       = 125,
174                 ENOKEY          = 126,
175                 EKEYEXPIRED     = 127,
176                 EKEYREVOKED     = 128,
177                 EKEYREJECTED    = 129,
178
179                 EOWNERDEAD      = 130,
180                 ENOTRECOVERABLE = 131,
181
182                 // OS X-specific values: OS X value + 1000
183                 EPROCLIM        = 1067, // Too many processes
184                 EBADRPC         = 1072, // RPC struct is bad
185                 ERPCMISMATCH    = 1073, // RPC version wrong
186                 EPROGUNAVAIL    = 1074, // RPC prog. not avail
187                 EPROGMISMATCH   = 1075, // Program version wrong
188                 EPROCUNAVAIL    = 1076, // Bad procedure for program
189                 EFTYPE          = 1079, // Inappropriate file type or format
190                 EAUTH           = 1080, // Authentication error
191                 ENEEDAUTH       = 1081, // Need authenticator
192                 EPWROFF         = 1082, // Device power is off
193                 EDEVERR         = 1083, // Device error, e.g. paper out
194                 EBADEXEC        = 1085, // Bad executable
195                 EBADARCH        = 1086, // Bad CPU type in executable
196                 ESHLIBVERS      = 1087, // Shared library version mismatch
197                 EBADMACHO       = 1088, // Malformed Macho file
198                 ENOATTR         = 1093, // Attribute not found
199                 ENOPOLICY       = 1103, // No such policy registered
200         }
201
202         #endregion
203
204         #region Classes
205
206         public sealed class FilePosition : MarshalByRefObject, IDisposable 
207 #if NET_2_0
208                 , IEquatable <FilePosition>
209 #endif
210         {
211
212                 private static readonly int FilePositionDumpSize = 
213                         Stdlib.DumpFilePosition (null, new HandleRef (null, IntPtr.Zero), 0);
214
215                 private HandleRef pos;
216
217                 public FilePosition ()
218                 {
219                         IntPtr p = Stdlib.CreateFilePosition ();
220                         if (p == IntPtr.Zero)
221                                 throw new OutOfMemoryException ("Unable to malloc fpos_t!");
222                         pos = new HandleRef (this, p);
223                 }
224
225                 internal HandleRef Handle {
226                         get {return pos;}
227                 }
228
229                 public void Dispose ()
230                 {
231                         Cleanup ();
232                         GC.SuppressFinalize (this);
233                 }
234
235                 private void Cleanup ()
236                 {
237                         if (pos.Handle != IntPtr.Zero) {
238                                 Stdlib.free (pos.Handle);
239                                 pos = new HandleRef (this, IntPtr.Zero);
240                         }
241                 }
242
243                 public override string ToString ()
244                 {
245                         return "(" + base.ToString () + " " + GetDump () + ")";
246                 }
247
248                 private string GetDump ()
249                 {
250                         if (FilePositionDumpSize <= 0)
251                                 return "internal error";
252
253                         StringBuilder buf = new StringBuilder (FilePositionDumpSize+1);
254
255                         if (Stdlib.DumpFilePosition (buf, Handle, FilePositionDumpSize+1) <= 0)
256                                 return "internal error dumping fpos_t";
257
258                         return buf.ToString ();
259                 }
260
261                 public override bool Equals (object obj)
262                 {
263                         FilePosition fp = obj as FilePosition;
264                         if (obj == null || fp == null)
265                                 return false;
266                         return ToString().Equals (obj.ToString());
267                 }
268
269                 public bool Equals (FilePosition value)
270                 {
271                         if (object.ReferenceEquals (this, value))
272                                 return true;
273                         return ToString().Equals (value.ToString());
274                 }
275
276                 public override int GetHashCode ()
277                 {
278                         return ToString ().GetHashCode ();
279                 }
280
281                 ~FilePosition ()
282                 {
283                         Cleanup ();
284                 }
285
286                 public static bool operator== (FilePosition lhs, FilePosition rhs)
287                 {
288                         return Object.Equals (lhs, rhs);
289                 }
290
291                 public static bool operator!= (FilePosition lhs, FilePosition rhs)
292                 {
293                         return !Object.Equals (lhs, rhs);
294                 }
295         }
296
297
298         public enum SignalAction {
299                 Default,
300                 Ignore,
301                 Error
302         }
303
304         //
305         // Right now using this attribute gives an assert because it
306         // isn't implemented.
307         //
308 #if NET_2_0 && UNMANAGED_FN_PTR_SUPPORT_FIXED
309         [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
310 #endif
311         public delegate void SignalHandler (int signal);
312
313 #if !NET_2_0
314         internal sealed class SignalWrapper {
315                 private IntPtr handler;
316
317                 internal SignalWrapper (IntPtr handler)
318                 {
319                         this.handler = handler;
320                 }
321
322                 public void InvokeSignalHandler (int signum)
323                 {
324                         Stdlib.InvokeSignalHandler (signum, handler);
325                 }
326         }
327 #endif
328
329         internal class XPrintfFunctions
330         {
331                 internal delegate object XPrintf (object[] parameters);
332
333                 internal static XPrintf printf;
334                 internal static XPrintf fprintf;
335                 internal static XPrintf snprintf;
336                 internal static XPrintf syslog;
337
338                 static XPrintfFunctions ()
339                 {
340                         CdeclFunction _printf = new CdeclFunction (Stdlib.LIBC, "printf", typeof(int));
341                         printf = new XPrintf (_printf.Invoke);
342
343                         CdeclFunction _fprintf = new CdeclFunction (Stdlib.LIBC, "fprintf", typeof(int));
344                         fprintf = new XPrintf (_fprintf.Invoke);
345
346                         CdeclFunction _snprintf = new CdeclFunction (Stdlib.MPH, 
347                                         "Mono_Posix_Stdlib_snprintf", typeof(int));
348                         snprintf = new XPrintf (_snprintf.Invoke);
349
350                         CdeclFunction _syslog = new CdeclFunction (Syscall.MPH, 
351                                         "Mono_Posix_Stdlib_syslog2", typeof(int));
352                         syslog = new XPrintf (_syslog.Invoke);
353                 }
354         }
355
356         //
357         // Convention: Functions that are part of the C standard library go here.
358         //
359         // For example, the man page should say something similar to:
360         //
361         //    CONFORMING TO
362         //           ISO 9899 (''ANSI C'')
363         //
364         // The intent is that members of this class should be portable to any system
365         // supporting the C runtime (read: non-Unix, including Windows).  Using
366         // anything from Syscall is non-portable, but restricting yourself to just
367         // Stdlib is intended to be portable.
368         //
369         // The only methods in here should be:
370         //  (1) low-level functions (as defined above).
371         //  (2) "Trivial" function overloads.  For example, if the parameters to a
372         //      function are related (e.g. fwrite(3))
373         //  (3) The return type SHOULD NOT be changed.  If you want to provide a
374         //      convenience function with a nicer return type, place it into one of
375         //      the Mono.Unix.Std* wrapper classes, and give it a .NET-styled name.
376         //      - EXCEPTION: No public functions should have a `void' return type.
377         //        `void' return types should be replaced with `int'.
378         //        Rationality: `void'-return functions typically require a
379         //        complicated call sequence, such as clear errno, then call, then
380         //        check errno to see if any errors occurred.  This sequence can't 
381         //        be done safely in managed code, as errno may change as part of 
382         //        the P/Invoke mechanism.
383         //        Instead, add a MonoPosixHelper export which does:
384         //          errno = 0;
385         //          INVOKE SYSCALL;
386         //          return errno == 0 ? 0 : -1;
387         //        This lets managed code check the return value in the usual manner.
388         //  (4) Exceptions SHOULD NOT be thrown.  EXCEPTIONS: 
389         //      - If you're wrapping *broken* methods which make assumptions about 
390         //        input data, such as that an argument refers to N bytes of data.  
391         //        This is currently limited to cuserid(3) and encrypt(3).
392         //      - If you call functions which themselves generate exceptions.  
393         //        This is the case for using NativeConvert, which will throw an
394         //        exception if an invalid/unsupported value is used.
395         //
396         public class Stdlib
397         {
398                 internal const string LIBC = "msvcrt";
399                 internal const string MPH  = "MonoPosixHelper";
400
401                 internal Stdlib () {}
402
403                 #region <errno.h> Declarations
404                 //
405                 // <errno.h>  -- COMPLETE
406                 //
407
408                 public static Errno GetLastError ()
409                 {
410                         int errno = Marshal.GetLastWin32Error ();
411                         return NativeConvert.ToErrno (errno);
412                 }
413
414                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
415                                 EntryPoint="Mono_Posix_Stdlib_SetLastError")]
416                 private static extern void SetLastError (int error);
417
418                 protected static void SetLastError (Errno error)
419                 {
420                         int _error = NativeConvert.FromErrno (error);
421                         SetLastError (_error);
422                 }
423
424                 #endregion
425
426                 //
427                 // <signal.h>
428                 //
429                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
430                                 EntryPoint="Mono_Posix_Stdlib_InvokeSignalHandler")]
431                 internal static extern void InvokeSignalHandler (int signum, IntPtr handler);
432
433                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
434                                 EntryPoint="Mono_Posix_Stdlib_SIG_DFL")]
435                 private static extern IntPtr GetDefaultSignal ();
436
437                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
438                                 EntryPoint="Mono_Posix_Stdlib_SIG_ERR")]
439                 private static extern IntPtr GetErrorSignal ();
440
441                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
442                                 EntryPoint="Mono_Posix_Stdlib_SIG_IGN")]
443                 private static extern IntPtr GetIgnoreSignal ();
444
445                 private static readonly IntPtr _SIG_DFL = GetDefaultSignal ();
446                 private static readonly IntPtr _SIG_ERR = GetErrorSignal ();
447                 private static readonly IntPtr _SIG_IGN = GetIgnoreSignal ();
448
449                 private static void _ErrorHandler (int signum)
450                 {
451                         Console.Error.WriteLine ("Error handler invoked for signum " + 
452                                         signum + ".  Don't do that.");
453                 }
454
455                 private static void _DefaultHandler (int signum)
456                 {
457                         Console.Error.WriteLine ("Default handler invoked for signum " + 
458                                         signum + ".  Don't do that.");
459                 }
460
461                 private static void _IgnoreHandler (int signum)
462                 {
463                         Console.Error.WriteLine ("Ignore handler invoked for signum " + 
464                                         signum + ".  Don't do that.");
465                 }
466
467                 [CLSCompliant (false)]
468                 public static readonly SignalHandler SIG_DFL = new SignalHandler (_DefaultHandler);
469                 [CLSCompliant (false)]
470                 public static readonly SignalHandler SIG_ERR = new SignalHandler (_ErrorHandler);
471                 [CLSCompliant (false)]
472                 public static readonly SignalHandler SIG_IGN = new SignalHandler (_IgnoreHandler);
473
474                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl,
475                                 SetLastError=true, EntryPoint="signal")]
476                 private static extern IntPtr sys_signal (int signum, SignalHandler handler);
477
478                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl,
479                                 SetLastError=true, EntryPoint="signal")]
480                 private static extern IntPtr sys_signal (int signum, IntPtr handler);
481
482                 [CLSCompliant (false)]
483                 [Obsolete ("This is not safe; " + 
484                                 "use Mono.Unix.UnixSignal for signal delivery or SetSignalAction()")]
485                 public static SignalHandler signal (Signum signum, SignalHandler handler)
486                 {
487                         int _sig = NativeConvert.FromSignum (signum);
488
489                         Delegate[] handlers = handler.GetInvocationList ();
490                         for (int i = 0; i < handlers.Length; ++i) {
491                                 Marshal.Prelink (handlers [i].Method);
492                         }
493
494                         IntPtr r;
495                         if (handler == SIG_DFL)
496                                 r = sys_signal (_sig, _SIG_DFL);
497                         else if (handler == SIG_ERR)
498                                 r = sys_signal (_sig, _SIG_ERR);
499                         else if (handler == SIG_IGN)
500                                 r = sys_signal (_sig, _SIG_IGN);
501                         else
502                                 r = sys_signal (_sig, handler);
503                         return TranslateHandler (r);
504                 }
505
506                 private static SignalHandler TranslateHandler (IntPtr handler)
507                 {
508                         if (handler == _SIG_DFL)
509                                 return SIG_DFL;
510                         if (handler == _SIG_ERR)
511                                 return SIG_ERR;
512                         if (handler == _SIG_IGN)
513                                 return SIG_IGN;
514 #if NET_2_0
515                         return (SignalHandler) Marshal.GetDelegateForFunctionPointer (handler, typeof(SignalHandler));
516 #else
517                         return new SignalHandler (new SignalWrapper (handler).InvokeSignalHandler);
518 #endif
519                 }
520
521                 public static int SetSignalAction (Signum signal, SignalAction action)
522                 {
523                         return SetSignalAction (NativeConvert.FromSignum (signal), action);
524                 }
525
526                 public static int SetSignalAction (RealTimeSignum rts, SignalAction action)
527                 {
528                         return SetSignalAction (NativeConvert.FromRealTimeSignum (rts), action);
529                 }
530                 
531                 private static int SetSignalAction (int signum, SignalAction action)
532                 {
533                         IntPtr handler = IntPtr.Zero;
534                         switch (action) {
535                                 case SignalAction.Default:
536                                         handler = _SIG_DFL;
537                                         break;
538                                 case SignalAction.Ignore:
539                                         handler = _SIG_IGN;
540                                         break;
541                                 case SignalAction.Error:
542                                         handler = _SIG_ERR;
543                                         break;
544                                 default:
545                                         throw new ArgumentException ("Invalid action value.", "action");
546                         }
547                         IntPtr r = sys_signal (signum, handler);
548                         if (r == _SIG_ERR)
549                                 return -1;
550                         return 0;
551                 }
552
553                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, EntryPoint="raise")]
554                 private static extern int sys_raise (int sig);
555
556                 [CLSCompliant (false)]
557                 public static int raise (Signum sig)
558                 {
559                         return sys_raise (NativeConvert.FromSignum (sig));
560                 }
561
562                 public static int raise (RealTimeSignum rts)
563                 {
564                         return sys_raise (NativeConvert.FromRealTimeSignum (rts));
565                 }
566
567                 //
568                 // <stdio.h> -- COMPLETE except for :
569                 //    - the scanf(3) family .
570                 //    - vararg functions.
571                 //    - Horribly unsafe functions (gets(3)).
572                 //
573                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
574                                 EntryPoint="Mono_Posix_Stdlib__IOFBF")]
575                 private static extern int GetFullyBuffered ();
576
577                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
578                                 EntryPoint="Mono_Posix_Stdlib__IOLBF")]
579                 private static extern int GetLineBuffered ();
580
581                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
582                                 EntryPoint="Mono_Posix_Stdlib__IONBF")]
583                 private static extern int GetNonBuffered ();
584
585                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
586                                 EntryPoint="Mono_Posix_Stdlib_BUFSIZ")]
587                 private static extern int GetBufferSize ();
588
589                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
590                                 EntryPoint="Mono_Posix_Stdlib_CreateFilePosition")]
591                 internal static extern IntPtr CreateFilePosition ();
592
593                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
594                                 EntryPoint="Mono_Posix_Stdlib_DumpFilePosition")]
595                 internal static extern int DumpFilePosition (StringBuilder buf, HandleRef handle, int len);
596
597                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
598                                 EntryPoint="Mono_Posix_Stdlib_EOF")]
599                 private static extern int GetEOF ();
600
601                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
602                                 EntryPoint="Mono_Posix_Stdlib_FILENAME_MAX")]
603                 private static extern int GetFilenameMax ();
604
605                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
606                                 EntryPoint="Mono_Posix_Stdlib_FOPEN_MAX")]
607                 private static extern int GetFopenMax ();
608
609                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
610                                 EntryPoint="Mono_Posix_Stdlib_L_tmpnam")]
611                 private static extern int GetTmpnamLength ();
612
613                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
614                                 EntryPoint="Mono_Posix_Stdlib_stdin")]
615                 private static extern IntPtr GetStandardInput ();
616
617                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
618                                 EntryPoint="Mono_Posix_Stdlib_stdout")]
619                 private static extern IntPtr GetStandardOutput ();
620
621                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
622                                 EntryPoint="Mono_Posix_Stdlib_stderr")]
623                 private static extern IntPtr GetStandardError ();
624
625                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
626                                 EntryPoint="Mono_Posix_Stdlib_TMP_MAX")]
627                 private static extern int GetTmpMax ();
628
629                 [CLSCompliant (false)]
630                 public static readonly int    _IOFBF       = GetFullyBuffered ();
631                 [CLSCompliant (false)]
632                 public static readonly int    _IOLBF       = GetLineBuffered ();
633                 [CLSCompliant (false)]
634                 public static readonly int    _IONBF       = GetNonBuffered ();
635                 [CLSCompliant (false)]
636                 public static readonly int    BUFSIZ       = GetBufferSize ();
637                 [CLSCompliant (false)]
638                 public static readonly int    EOF          = GetEOF ();
639                 [CLSCompliant (false)]
640                 public static readonly int    FOPEN_MAX    = GetFopenMax ();
641                 [CLSCompliant (false)]
642                 public static readonly int    FILENAME_MAX = GetFilenameMax ();
643                 [CLSCompliant (false)]
644                 public static readonly int    L_tmpnam     = GetTmpnamLength ();
645                 public static readonly IntPtr stderr       = GetStandardError ();
646                 public static readonly IntPtr stdin        = GetStandardInput ();
647                 public static readonly IntPtr stdout       = GetStandardOutput ();
648                 [CLSCompliant (false)]
649                 public static readonly int    TMP_MAX      = GetTmpMax ();
650
651                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
652                 public static extern int remove (
653                                 [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
654                                 string filename);
655
656                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
657                 public static extern int rename (
658                                 [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
659                                 string oldpath, 
660                                 [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
661                                 string newpath);
662
663                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
664                 public static extern IntPtr tmpfile ();
665
666                 private static object tmpnam_lock = new object ();
667
668                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl,
669                                 SetLastError=true, EntryPoint="tmpnam")]
670                 private static extern IntPtr sys_tmpnam (StringBuilder s);
671
672                 [Obsolete ("Syscall.mkstemp() should be preferred.")]
673                 public static string tmpnam (StringBuilder s)
674                 {
675                         if (s != null && s.Capacity < L_tmpnam)
676                                 throw new ArgumentOutOfRangeException ("s", "s.Capacity < L_tmpnam");
677                         lock (tmpnam_lock) {
678                                 IntPtr r = sys_tmpnam (s);
679                                 return UnixMarshal.PtrToString (r);
680                         }
681                 }
682
683                 [Obsolete ("Syscall.mkstemp() should be preferred.")]
684                 public static string tmpnam ()
685                 {
686                         lock (tmpnam_lock) {
687                                 IntPtr r = sys_tmpnam (null);
688                                 return UnixMarshal.PtrToString (r);
689                         }
690                 }
691
692                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
693                 public static extern int fclose (IntPtr stream);
694
695                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
696                 public static extern int fflush (IntPtr stream);
697
698                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
699                 public static extern IntPtr fopen (
700                                 [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
701                                 string path, string mode);
702
703                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
704                 public static extern IntPtr freopen (
705                                 [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
706                                 string path, string mode, IntPtr stream);
707
708                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl, 
709                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_setbuf")]
710                 public static extern int setbuf (IntPtr stream, IntPtr buf);
711
712                 [CLSCompliant (false)]
713                 public static unsafe int setbuf (IntPtr stream, byte* buf)
714                 {
715                         return setbuf (stream, (IntPtr) buf);
716                 }
717
718                 [CLSCompliant (false)]
719                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
720                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_setvbuf")]
721                 public static extern int setvbuf (IntPtr stream, IntPtr buf, int mode, ulong size);
722
723                 [CLSCompliant (false)]
724                 public static unsafe int setvbuf (IntPtr stream, byte* buf, int mode, ulong size)
725                 {
726                         return setvbuf (stream, (IntPtr) buf, mode, size);
727                 }
728
729                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl,
730                                 EntryPoint="fprintf")]
731                 private static extern int sys_fprintf (IntPtr stream, string format, string message);
732
733                 public static int fprintf (IntPtr stream, string message)
734                 {
735                         return sys_fprintf (stream, "%s", message);
736                 }
737
738                 [Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
739                                 "Use fprintf (IntPtr, string) instead.")]
740                 public static int fprintf (IntPtr stream, string format, params object[] parameters)
741                 {
742                         object[] _parameters = new object[checked(parameters.Length+2)];
743                         _parameters [0] = stream;
744                         _parameters [1] = format;
745                         Array.Copy (parameters, 0, _parameters, 2, parameters.Length);
746                         return (int) XPrintfFunctions.fprintf (_parameters);
747                 }
748
749                 /* SKIP: fscanf(3) */
750
751                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl,
752                                 EntryPoint="printf")]
753                 private static extern int sys_printf (string format, string message);
754
755                 public static int printf (string message)
756                 {
757                         return sys_printf ("%s", message);
758                 }
759
760                 [Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
761                                 "Use printf (string) instead.")]
762                 public static int printf (string format, params object[] parameters)
763                 {
764                         object[] _parameters = new object[checked(parameters.Length+1)];
765                         _parameters [0] = format;
766                         Array.Copy (parameters, 0, _parameters, 1, parameters.Length);
767                         return (int) XPrintfFunctions.printf (_parameters);
768                 }
769
770                 /* SKIP: scanf(3) */
771
772                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
773                                 EntryPoint="Mono_Posix_Stdlib_snprintf")]
774                 private static extern int sys_snprintf (StringBuilder s, ulong n, 
775                                 string format, string message);
776
777                 [CLSCompliant (false)]
778                 public static int snprintf (StringBuilder s, ulong n, string message)
779                 {
780                         if (n > (ulong) s.Capacity)
781                                 throw new ArgumentOutOfRangeException ("n", "n must be <= s.Capacity");
782                         return sys_snprintf (s, n, "%s", message);
783                 }
784
785                 public static int snprintf (StringBuilder s, string message)
786                 {
787                         return sys_snprintf (s, (ulong) s.Capacity, "%s", message);
788                 }
789
790                 [CLSCompliant (false)]
791                 [Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
792                                 "Use snprintf (StringBuilder, string) instead.")]
793                 public static int snprintf (StringBuilder s, ulong n, 
794                                 string format, params object[] parameters)
795                 {
796                         if (n > (ulong) s.Capacity)
797                                 throw new ArgumentOutOfRangeException ("n", "n must be <= s.Capacity");
798
799                         object[] _parameters = new object[checked(parameters.Length+3)];
800                         _parameters [0] = s;
801                         _parameters [1] = n;
802                         _parameters [2] = format;
803                         Array.Copy (parameters, 0, _parameters, 3, parameters.Length);
804                         return (int) XPrintfFunctions.snprintf (_parameters);
805                 }
806
807                 [CLSCompliant (false)]
808                 [Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
809                                 "Use snprintf (StringBuilder, string) instead.")]
810                 public static int snprintf (StringBuilder s,
811                                 string format, params object[] parameters)
812                 {
813                         object[] _parameters = new object[checked(parameters.Length+3)];
814                         _parameters [0] = s;
815                         _parameters [1] = (ulong) s.Capacity;
816                         _parameters [2] = format;
817                         Array.Copy (parameters, 0, _parameters, 3, parameters.Length);
818                         return (int) XPrintfFunctions.snprintf (_parameters);
819                 }
820
821                 /*
822                  * SKIP:
823                  *    sprintf(3)
824                  *    sscanf(3)
825                  *    vfprintf(3)
826                  *    vfscanf(3)
827                  *    vprintf(3)
828                  *    vscanf(3)
829                  *    vsnprintf(3)
830                  *    vsprint(3)
831                  *    vsscanf(3)
832                  */
833
834                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
835                 public static extern int fgetc (IntPtr stream);
836
837                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl,
838                                 SetLastError=true, EntryPoint="fgets")]
839                 private static extern IntPtr sys_fgets (StringBuilder sb, int size, IntPtr stream);
840
841                 public static StringBuilder fgets (StringBuilder sb, int size, IntPtr stream)
842                 {
843                         IntPtr r = sys_fgets (sb, size, stream);
844                         if (r == IntPtr.Zero)
845                                 return null;
846                         return sb;
847                 }
848
849                 public static StringBuilder fgets (StringBuilder sb, IntPtr stream)
850                 {
851                         return fgets (sb, sb.Capacity, stream);
852                 }
853
854                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
855                 public static extern int fputc (int c, IntPtr stream);
856
857                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
858                 public static extern int fputs (string s, IntPtr stream);
859
860                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
861                 public static extern int getc (IntPtr stream);
862
863                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
864                 public static extern int getchar ();
865
866                 /* SKIP: gets(3) */
867
868                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
869                 public static extern int putc (int c, IntPtr stream);
870
871                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
872                 public static extern int putchar (int c);
873
874                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
875                 public static extern int puts (string s);
876
877                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
878                 public static extern int ungetc (int c, IntPtr stream);
879
880                 [CLSCompliant (false)]
881                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
882                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fread")]
883                 public static extern ulong fread (IntPtr ptr, ulong size, ulong nmemb, IntPtr stream);
884
885                 [CLSCompliant (false)]
886                 public static unsafe ulong fread (void* ptr, ulong size, ulong nmemb, IntPtr stream)
887                 {
888                         return fread ((IntPtr) ptr, size, nmemb, stream);
889                 }
890
891                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
892                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fread")]
893                 private static extern ulong sys_fread ([Out] byte[] ptr, 
894                                 ulong size, ulong nmemb, IntPtr stream);
895
896                 [CLSCompliant (false)]
897                 public static ulong fread (byte[] ptr, ulong size, ulong nmemb, IntPtr stream)
898                 {
899                         if ((size * nmemb) > (ulong) ptr.Length)
900                                 throw new ArgumentOutOfRangeException ("nmemb");
901                         return sys_fread (ptr, size, nmemb, stream);
902                 }
903
904                 [CLSCompliant (false)]
905                 public static ulong fread (byte[] ptr, IntPtr stream)
906                 {
907                         return fread (ptr, 1, (ulong) ptr.Length, stream);
908                 }
909
910                 [CLSCompliant (false)]
911                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
912                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fwrite")]
913                 public static extern ulong fwrite (IntPtr ptr, ulong size, ulong nmemb, IntPtr stream);
914
915                 [CLSCompliant (false)]
916                 public static unsafe ulong fwrite (void* ptr, ulong size, ulong nmemb, IntPtr stream)
917                 {
918                         return fwrite ((IntPtr) ptr, size, nmemb, stream);
919                 }
920
921                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
922                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fwrite")]
923                 private static extern ulong sys_fwrite (byte[] ptr, 
924                                 ulong size, ulong nmemb, IntPtr stream);
925
926                 [CLSCompliant (false)]
927                 public static ulong fwrite (byte[] ptr, ulong size, ulong nmemb, IntPtr stream)
928                 {
929                         if ((size * nmemb) > (ulong) ptr.Length)
930                                 throw new ArgumentOutOfRangeException ("nmemb");
931                         return sys_fwrite (ptr, size, nmemb, stream);
932                 }
933
934                 [CLSCompliant (false)]
935                 public static ulong fwrite (byte[] ptr, IntPtr stream)
936                 {
937                         return fwrite (ptr, 1, (ulong) ptr.Length, stream);
938                 }
939
940                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
941                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fgetpos")]
942                 private static extern int sys_fgetpos (IntPtr stream, HandleRef pos);
943
944                 public static int fgetpos (IntPtr stream, FilePosition pos)
945                 {
946                         return sys_fgetpos (stream, pos.Handle);
947                 }
948
949                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
950                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fseek")]
951                 private static extern int sys_fseek (IntPtr stream, long offset, int origin);
952
953                 [CLSCompliant (false)]
954                 public static int fseek (IntPtr stream, long offset, SeekFlags origin)
955                 {
956                         int _origin = NativeConvert.FromSeekFlags (origin);
957                         return sys_fseek (stream, offset, _origin);
958                 }
959
960                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
961                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fsetpos")]
962                 private static extern int sys_fsetpos (IntPtr stream, HandleRef pos);
963
964                 public static int fsetpos (IntPtr stream, FilePosition pos)
965                 {
966                         return sys_fsetpos (stream, pos.Handle);
967                 }
968
969                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
970                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_ftell")]
971                 public static extern long ftell (IntPtr stream);
972
973                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
974                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_rewind")]
975                 public static extern int rewind (IntPtr stream);
976
977                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
978                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_clearerr")]
979                 public static extern int clearerr (IntPtr stream);
980
981                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
982                 public static extern int feof (IntPtr stream);
983
984                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
985                 public static extern int ferror (IntPtr stream);
986
987                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl, 
988                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_perror")]
989                 private static extern int perror (string s, int err);
990
991                 public static int perror (string s)
992                 {
993                         return perror (s, Marshal.GetLastWin32Error ());
994                 }
995
996                 //
997                 // <stdlib.h>
998                 //
999                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
1000                                 EntryPoint="Mono_Posix_Stdlib_EXIT_FAILURE")]
1001                 private static extern int GetExitFailure();
1002
1003                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
1004                                 EntryPoint="Mono_Posix_Stdlib_EXIT_SUCCESS")]
1005                 private static extern int GetExitSuccess ();
1006
1007                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
1008                                 EntryPoint="Mono_Posix_Stdlib_MB_CUR_MAX")]
1009                 private static extern int GetMbCurMax ();
1010
1011                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
1012                                 EntryPoint="Mono_Posix_Stdlib_RAND_MAX")]
1013                 private static extern int GetRandMax ();
1014
1015                 [CLSCompliant (false)]
1016                 public static readonly int  EXIT_FAILURE = GetExitFailure ();
1017                 [CLSCompliant (false)]
1018                 public static readonly int  EXIT_SUCCESS = GetExitSuccess ();
1019                 [CLSCompliant (false)]
1020                 public static readonly int  MB_CUR_MAX   = GetMbCurMax ();
1021                 [CLSCompliant (false)]
1022                 public static readonly int  RAND_MAX     = GetRandMax ();
1023
1024                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
1025                 public static extern int rand ();
1026
1027                 [CLSCompliant (false)]
1028                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
1029                 public static extern void srand (uint seed);
1030
1031                 // calloc(3):
1032                 //    void *calloc (size_t nmemb, size_t size);
1033                 [CLSCompliant (false)]
1034                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
1035                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_calloc")]
1036                 public static extern IntPtr calloc (ulong nmemb, ulong size);
1037
1038                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
1039                 public static extern void free (IntPtr ptr);
1040
1041                 // malloc(3):
1042                 //    void *malloc(size_t size);
1043                 [CLSCompliant (false)]
1044                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
1045                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_malloc")]
1046                 public static extern IntPtr malloc (ulong size);
1047
1048                 // realloc(3):
1049                 //    void *realloc(void *ptr, size_t size);
1050                 [CLSCompliant (false)]
1051                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
1052                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_realloc")]
1053                 public static extern IntPtr realloc (IntPtr ptr, ulong size);
1054
1055                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
1056                 public static extern void abort ();
1057
1058                 /* SKIP: atexit(3) -- the GC should have collected most references by the
1059                  * time this runs, so no delegates should exist, making it pointless. */
1060
1061                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
1062                 public static extern void exit (int status);
1063
1064                 [CLSCompliant (false)]
1065                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
1066                 public static extern void _Exit (int status);
1067
1068                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, EntryPoint="getenv")]
1069                 private static extern IntPtr sys_getenv (string name);
1070
1071                 public static string getenv (string name)
1072                 {
1073                         IntPtr r = sys_getenv (name);
1074                         return UnixMarshal.PtrToString (r);
1075                 }
1076
1077                 [CLSCompliant (false)]
1078                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
1079                 public static extern int system (string @string);
1080
1081                 //
1082                 // <string.h>
1083                 //
1084
1085                 private static object strerror_lock = new object ();
1086
1087                 [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl,
1088                                 SetLastError=true, EntryPoint="strerror")]
1089                 private static extern IntPtr sys_strerror (int errnum);
1090
1091                 [CLSCompliant (false)]
1092                 public static string strerror (Errno errnum)
1093                 {
1094                         int e = NativeConvert.FromErrno (errnum);
1095                         lock (strerror_lock) {
1096                                 IntPtr r = sys_strerror (e);
1097                                 return UnixMarshal.PtrToString (r);
1098                         }
1099                 }
1100
1101                 // strlen(3):
1102                 //    size_t strlen(const char *s);
1103                 [CLSCompliant (false)]
1104                 [DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
1105                                 SetLastError=true, EntryPoint="Mono_Posix_Stdlib_strlen")]
1106                 public static extern ulong strlen (IntPtr s);
1107         }
1108
1109         #endregion // Classes
1110 }
1111
1112 // vim: noexpandtab