// using strerror(3).
// This should be thread safe, since the check is done within the
// class constructor lock.
- // Problem: But if strerror_r() isn't present, we're not thread safe!
- // Solution: Tough. It's still better than nothing. I think.
- // Check UnixMarshal.IsErrorDescriptionThreadSafe if you need to
- // know which error translator is being used.
+ // Strerror(3) will be thread-safe from managed code, but won't
+ // be thread-safe between managed & unmanaged code.
internal class ErrorMarshal
{
- public delegate string ErrorTranslator (Error errno);
+ internal delegate string ErrorTranslator (Error errno);
- public static readonly ErrorTranslator Translate;
- public static readonly bool HaveStrerror_r;
+ internal static readonly ErrorTranslator Translate;
static ErrorMarshal ()
{
try {
Translate = new ErrorTranslator (strerror_r);
- string ignore = Translate (Error.ERANGE);
- ignore = ignore;
- HaveStrerror_r = true;
+ Translate (Error.ERANGE);
}
catch (EntryPointNotFoundException e) {
Translate = new ErrorTranslator (strerror);
- HaveStrerror_r = false;
}
}
return ErrorMarshal.Translate (errno);
}
- public static bool IsErrorDescriptionThreadSafe {
- get {return ErrorMarshal.HaveStrerror_r;}
- }
-
public static IntPtr Alloc (long size)
{
if (size < 0)