Beispiel #1
0
        static NativeMethods()
        {
            _libraryFacade = Environment.Is64BitProcess
                ? new Native64BitLibraryFacade()
                : (INativeLibraryFacade) new Native32BitLibraryFacade();

            Exception archSpecificException;

            _libraryVersion = GetVersionInfo(_libraryFacade, out archSpecificException);

            if (archSpecificException != null)
            {
                Exception fallbackException;

                var fallbackLibrary = new FallbackLibraryFacade();
                _libraryVersion = GetVersionInfo(fallbackLibrary, out fallbackException);

                if (fallbackException != null)
                {
                    throw archSpecificException;
                }

                _libraryFacade = fallbackLibrary;
            }
        }
        int INativeLibraryFacade.mdb_env_set_mapsize(IntPtr env, long size)
        {
            IntPtr sizeValue;

            if (!Environment.Is64BitProcess && size > Int32.MaxValue)
            {
                if (LightningConfig.Environment.AutoReduceMapSizeIn32BitProcess)
                {
                    sizeValue = new IntPtr(Int32.MaxValue);
                }
                else
                {
                    throw new InvalidOperationException("Can't set MapSize larger than Int32.MaxValue in 32-bit process");
                }
            }
            else
            {
                sizeValue = new IntPtr((int)size);
            }
            return(FallbackLibraryFacade.mdb_env_set_mapsize(env, sizeValue));
        }
Beispiel #3
0
        static NativeMethods()
        {
            _libraryFacade = Environment.Is64BitProcess
                ? new Native64BitLibraryFacade()
                : (INativeLibraryFacade) new Native32BitLibraryFacade();

            Exception archSpecificException;
            _libraryVersion = GetVersionInfo(_libraryFacade, out archSpecificException);

            if (archSpecificException != null)
            {
                Exception fallbackException;

                var fallbackLibrary = new FallbackLibraryFacade();
                _libraryVersion = GetVersionInfo(fallbackLibrary, out fallbackException);

                if (fallbackException != null)
                    throw archSpecificException;

                _libraryFacade = fallbackLibrary;
            }
        }
 int INativeLibraryFacade.mdb_env_copy(IntPtr env, string path)
 {
     return(FallbackLibraryFacade.mdb_env_copy(env, path));
 }
 void INativeLibraryFacade.mdb_env_close(IntPtr env)
 {
     FallbackLibraryFacade.mdb_env_close(env);
 }
 int INativeLibraryFacade.mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, PutOptions flags)
 {
     return(FallbackLibraryFacade.mdb_cursor_put(cursor, ref key, ref data, flags));
 }
 int INativeLibraryFacade.mdb_cursor_renew(IntPtr txn, IntPtr cursor)
 {
     return(FallbackLibraryFacade.mdb_cursor_renew(txn, cursor));
 }
 int INativeLibraryFacade.mdb_cursor_open(IntPtr txn, uint dbi, out IntPtr cursor)
 {
     return(FallbackLibraryFacade.mdb_cursor_open(txn, dbi, out cursor));
 }
 int INativeLibraryFacade.mdb_put(IntPtr txn, uint dbi, ref ValueStructure key, ref ValueStructure data, PutOptions flags)
 {
     return(FallbackLibraryFacade.mdb_put(txn, dbi, ref key, ref data, flags));
 }
 int INativeLibraryFacade.mdb_drop(IntPtr txn, uint dbi, bool del)
 {
     return(FallbackLibraryFacade.mdb_drop(txn, dbi, del));
 }
 void INativeLibraryFacade.mdb_dbi_close(IntPtr env, uint dbi)
 {
     FallbackLibraryFacade.mdb_dbi_close(env, dbi);
 }
 int INativeLibraryFacade.mdb_dbi_open(IntPtr txn, string name, DatabaseOpenFlags flags, out uint db)
 {
     return(FallbackLibraryFacade.mdb_dbi_open(txn, name, flags, out db));
 }
 int INativeLibraryFacade.mdb_env_set_maxdbs(IntPtr env, uint dbs)
 {
     return(FallbackLibraryFacade.mdb_env_set_maxdbs(env, dbs));
 }
 int INativeLibraryFacade.mdb_env_set_maxreaders(IntPtr env, uint readers)
 {
     return(FallbackLibraryFacade.mdb_env_set_maxreaders(env, readers));
 }
 int INativeLibraryFacade.mdb_env_open(IntPtr env, string path, EnvironmentOpenFlags flags, int mode)
 {
     return(FallbackLibraryFacade.mdb_env_open(env, path, flags, mode));
 }
 int INativeLibraryFacade.mdb_env_sync(IntPtr env, bool force)
 {
     return(FallbackLibraryFacade.mdb_env_sync(env, force));
 }
 int INativeLibraryFacade.mdb_get(IntPtr txn, uint dbi, ref ValueStructure key, out ValueStructure data)
 {
     return(FallbackLibraryFacade.mdb_get(txn, dbi, ref key, out data));
 }
 int INativeLibraryFacade.mdb_txn_begin(IntPtr env, IntPtr parent, TransactionBeginFlags flags, out IntPtr txn)
 {
     return(FallbackLibraryFacade.mdb_txn_begin(env, parent, flags, out txn));
 }
 int INativeLibraryFacade.mdb_del(IntPtr txn, uint dbi, ref ValueStructure key, IntPtr data)
 {
     return(FallbackLibraryFacade.mdb_del(txn, dbi, ref key, data));
 }
 int INativeLibraryFacade.mdb_txn_commit(IntPtr txn)
 {
     return(FallbackLibraryFacade.mdb_txn_commit(txn));
 }
 void INativeLibraryFacade.mdb_cursor_close(IntPtr cursor)
 {
     FallbackLibraryFacade.mdb_cursor_close(cursor);
 }
 void INativeLibraryFacade.mdb_txn_reset(IntPtr txn)
 {
     FallbackLibraryFacade.mdb_txn_reset(txn);
 }
 int INativeLibraryFacade.mdb_cursor_get(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, CursorOperation op)
 {
     return(FallbackLibraryFacade.mdb_cursor_get(cursor, ref key, ref data, op));
 }
 int INativeLibraryFacade.mdb_txn_renew(IntPtr txn)
 {
     return(FallbackLibraryFacade.mdb_txn_renew(txn));
 }
 int INativeLibraryFacade.mdb_cursor_del(IntPtr cursor, CursorDeleteOption flags)
 {
     return(FallbackLibraryFacade.mdb_cursor_del(cursor, flags));
 }
 IntPtr INativeLibraryFacade.mdb_version(out IntPtr major, out IntPtr minor, out IntPtr patch)
 {
     return(FallbackLibraryFacade.mdb_version(out major, out minor, out patch));
 }
 IntPtr INativeLibraryFacade.mdb_strerror(int err)
 {
     return(FallbackLibraryFacade.mdb_strerror(err));
 }
 int INativeLibraryFacade.mdb_env_create(out IntPtr env)
 {
     return(FallbackLibraryFacade.mdb_env_create(out env));
 }