Exemple #1
0
        public static bool SetMallCtlSInt64(string name, long value)
        {
            void *n    = &value;
            ulong size = sizeof(Int64);
            ERRNO r    = (ERRNO)Mallctl(name, IntPtr.Zero, ref size, (IntPtr)n, size);

            return(r == ERRNO.ENONE ? true : throw GetExceptionForErrNo($"Could not set mallctl value {name} to {value}.", r));
        }
Exemple #2
0
        public static Int64 GetMallCtlSInt64(string name)
        {
            void *i    = stackalloc Int64[1];
            ulong size = sizeof(Int64);
            ERRNO r    = (ERRNO)Mallctl(name, (IntPtr)i, ref size, IntPtr.Zero, 0);

            return(r == ERRNO.ENONE ? *(Int64 *)(i) : throw GetExceptionForErrNo($"Could not get mallctl value {name}.", r));
        }
Exemple #3
0
        public static bool SetMallCtlBool(string name, bool value)
        {
            byte  v    = value ? (byte)1 : (byte)0;
            void *n    = &v;
            ulong size = sizeof(byte);
            ERRNO r    = (ERRNO)Mallctl(name, IntPtr.Zero, ref size, (IntPtr)n, size);

            return(r == ERRNO.ENONE ? true : throw GetExceptionForErrNo($"Could not set mallctl value {name} to {value}.", r));
        }
Exemple #4
0
        public static bool GetMallCtlBool(string name)
        {
            void *i    = stackalloc byte[1];
            ulong size = sizeof(byte);
            ERRNO r    = (ERRNO)Mallctl(name, (IntPtr)i, ref size, IntPtr.Zero, 0);

            return(r == ERRNO.ENONE ? *(byte *)(i) == 1 ? true : false:
                   r == ERRNO.ENOENT ? false : throw GetExceptionForErrNo($"Could not get mallctl value {name}.", r));
        }
Exemple #5
0
        internal static Exception GetExceptionForErrNo(string message, ERRNO no)
        {
            switch (no)
            {
            case ERRNO.ENOMEM:
                return(new OutOfMemoryException(message));

            default:
                return(new Exception(message + $" {no}."));
            }
        }
        internal static Exception GetExceptionForErrNo(ERRNO no)
        {
            switch (no)
            {
            case ERRNO.ENOMEM:
                return(new OutOfMemoryException());

            default:
                return(new Exception());
            }
        }
Exemple #7
0
 public static long ToErrCode(this ERRNO e)
 {
     return(mapper.ToHash(e));
 }