1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
pub const MDBX_VERSION_MAJOR: ::libc::c_uint = 0;
pub const MDBX_VERSION_MINOR: ::libc::c_uint = 11;
pub const MDBX_LOCKNAME: &[u8; 10usize] = b"/mdbx.lck\0";
pub const MDBX_DATANAME: &[u8; 10usize] = b"/mdbx.dat\0";
pub const MDBX_LOCK_SUFFIX: &[u8; 5usize] = b"-lck\0";
pub type va_list = __builtin_va_list;
pub type __uint8_t = ::libc::c_uchar;
pub type __uint16_t = ::libc::c_ushort;
pub type __int32_t = ::libc::c_int;
pub type __uint32_t = ::libc::c_uint;
pub type __int64_t = ::libc::c_long;
pub type __uint64_t = ::libc::c_ulong;
pub type __mode_t = ::libc::c_uint;
pub type __pid_t = ::libc::c_int;
pub type pid_t = __pid_t;
pub type pthread_t = ::libc::c_ulong;
pub type mode_t = __mode_t;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct iovec {
    pub iov_base: *mut ::libc::c_void,
    pub iov_len: usize,
}
pub type mdbx_filehandle_t = ::libc::c_int;
pub type mdbx_pid_t = pid_t;
pub type mdbx_tid_t = pthread_t;
pub type mdbx_mode_t = mode_t;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_version_info {
    pub major: u8,
    pub minor: u8,
    pub release: u16,
    pub revision: u32,
    pub git: MDBX_version_info__bindgen_ty_1,
    pub sourcery: *const ::libc::c_char,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_version_info__bindgen_ty_1 {
    pub datetime: *const ::libc::c_char,
    pub tree: *const ::libc::c_char,
    pub commit: *const ::libc::c_char,
    pub describe: *const ::libc::c_char,
}
extern "C" {
    pub static mdbx_version: MDBX_version_info;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_build_info {
    pub datetime: *const ::libc::c_char,
    pub target: *const ::libc::c_char,
    pub options: *const ::libc::c_char,
    pub compiler: *const ::libc::c_char,
    pub flags: *const ::libc::c_char,
}
extern "C" {
    pub static mdbx_build: MDBX_build_info;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_env {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_txn {
    _unused: [u8; 0],
}
pub type MDBX_dbi = u32;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_cursor {
    _unused: [u8; 0],
}
pub type MDBX_val = iovec;
pub const MDBX_MAX_DBI: MDBX_constants = 32765;
pub const MDBX_MAXDATASIZE: MDBX_constants = 2147418112;
pub const MDBX_MIN_PAGESIZE: MDBX_constants = 256;
pub const MDBX_MAX_PAGESIZE: MDBX_constants = 65536;
pub type MDBX_constants = ::libc::c_uint;
pub const MDBX_LOG_FATAL: MDBX_log_level_t = 0;
pub const MDBX_LOG_ERROR: MDBX_log_level_t = 1;
pub const MDBX_LOG_WARN: MDBX_log_level_t = 2;
pub const MDBX_LOG_NOTICE: MDBX_log_level_t = 3;
pub const MDBX_LOG_VERBOSE: MDBX_log_level_t = 4;
pub const MDBX_LOG_DEBUG: MDBX_log_level_t = 5;
pub const MDBX_LOG_TRACE: MDBX_log_level_t = 6;
pub const MDBX_LOG_EXTRA: MDBX_log_level_t = 7;
pub const MDBX_LOG_DONTCHANGE: MDBX_log_level_t = -1;
pub type MDBX_log_level_t = ::libc::c_int;
pub const MDBX_DBG_NONE: MDBX_debug_flags_t = 0;
pub const MDBX_DBG_ASSERT: MDBX_debug_flags_t = 1;
pub const MDBX_DBG_AUDIT: MDBX_debug_flags_t = 2;
pub const MDBX_DBG_JITTER: MDBX_debug_flags_t = 4;
pub const MDBX_DBG_DUMP: MDBX_debug_flags_t = 8;
pub const MDBX_DBG_LEGACY_MULTIOPEN: MDBX_debug_flags_t = 16;
pub const MDBX_DBG_LEGACY_OVERLAP: MDBX_debug_flags_t = 32;
pub const MDBX_DBG_DONTCHANGE: MDBX_debug_flags_t = -1;
pub type MDBX_debug_flags_t = ::libc::c_int;
pub type MDBX_debug_func = ::std::option::Option<
    unsafe extern "C" fn(
        loglevel: MDBX_log_level_t,
        function: *const ::libc::c_char,
        line: ::libc::c_int,
        fmt: *const ::libc::c_char,
        args: *mut __va_list_tag,
    ),
>;
extern "C" {
    pub fn mdbx_setup_debug(
        log_level: MDBX_log_level_t,
        debug_flags: MDBX_debug_flags_t,
        logger: MDBX_debug_func,
    ) -> ::libc::c_int;
}
pub type MDBX_assert_func = ::std::option::Option<
    unsafe extern "C" fn(
        env: *const MDBX_env,
        msg: *const ::libc::c_char,
        function: *const ::libc::c_char,
        line: ::libc::c_uint,
    ),
>;
extern "C" {
    pub fn mdbx_env_set_assert(env: *mut MDBX_env, func: MDBX_assert_func) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_dump_val(
        key: *const MDBX_val,
        buf: *mut ::libc::c_char,
        bufsize: usize,
    ) -> *const ::libc::c_char;
}
extern "C" {
    pub fn mdbx_panic(fmt: *const ::libc::c_char, ...);
}
pub const MDBX_ENV_DEFAULTS: MDBX_env_flags_t = 0;
pub const MDBX_NOSUBDIR: MDBX_env_flags_t = 16384;
pub const MDBX_RDONLY: MDBX_env_flags_t = 131072;
pub const MDBX_EXCLUSIVE: MDBX_env_flags_t = 4194304;
pub const MDBX_ACCEDE: MDBX_env_flags_t = 1073741824;
pub const MDBX_WRITEMAP: MDBX_env_flags_t = 524288;
pub const MDBX_NOTLS: MDBX_env_flags_t = 2097152;
pub const MDBX_NORDAHEAD: MDBX_env_flags_t = 8388608;
pub const MDBX_NOMEMINIT: MDBX_env_flags_t = 16777216;
pub const MDBX_COALESCE: MDBX_env_flags_t = 33554432;
pub const MDBX_LIFORECLAIM: MDBX_env_flags_t = 67108864;
pub const MDBX_PAGEPERTURB: MDBX_env_flags_t = 134217728;
pub const MDBX_SYNC_DURABLE: MDBX_env_flags_t = 0;
pub const MDBX_NOMETASYNC: MDBX_env_flags_t = 262144;
pub const MDBX_SAFE_NOSYNC: MDBX_env_flags_t = 65536;
pub const MDBX_MAPASYNC: MDBX_env_flags_t = 65536;
pub const MDBX_UTTERLY_NOSYNC: MDBX_env_flags_t = 1114112;
pub type MDBX_env_flags_t = ::libc::c_uint;
pub const MDBX_TXN_READWRITE: MDBX_txn_flags_t = 0;
pub const MDBX_TXN_RDONLY: MDBX_txn_flags_t = 131072;
pub const MDBX_TXN_RDONLY_PREPARE: MDBX_txn_flags_t = 16908288;
pub const MDBX_TXN_TRY: MDBX_txn_flags_t = 268435456;
pub const MDBX_TXN_NOMETASYNC: MDBX_txn_flags_t = 262144;
pub const MDBX_TXN_NOSYNC: MDBX_txn_flags_t = 65536;
pub type MDBX_txn_flags_t = ::libc::c_uint;
pub const MDBX_DB_DEFAULTS: MDBX_db_flags_t = 0;
pub const MDBX_REVERSEKEY: MDBX_db_flags_t = 2;
pub const MDBX_DUPSORT: MDBX_db_flags_t = 4;
pub const MDBX_INTEGERKEY: MDBX_db_flags_t = 8;
pub const MDBX_DUPFIXED: MDBX_db_flags_t = 16;
pub const MDBX_INTEGERDUP: MDBX_db_flags_t = 32;
pub const MDBX_REVERSEDUP: MDBX_db_flags_t = 64;
pub const MDBX_CREATE: MDBX_db_flags_t = 262144;
pub const MDBX_DB_ACCEDE: MDBX_db_flags_t = 1073741824;
pub type MDBX_db_flags_t = ::libc::c_uint;
pub const MDBX_UPSERT: MDBX_put_flags_t = 0;
pub const MDBX_NOOVERWRITE: MDBX_put_flags_t = 16;
pub const MDBX_NODUPDATA: MDBX_put_flags_t = 32;
pub const MDBX_CURRENT: MDBX_put_flags_t = 64;
pub const MDBX_ALLDUPS: MDBX_put_flags_t = 128;
pub const MDBX_RESERVE: MDBX_put_flags_t = 65536;
pub const MDBX_APPEND: MDBX_put_flags_t = 131072;
pub const MDBX_APPENDDUP: MDBX_put_flags_t = 262144;
pub const MDBX_MULTIPLE: MDBX_put_flags_t = 524288;
pub type MDBX_put_flags_t = ::libc::c_uint;
pub const MDBX_CP_DEFAULTS: MDBX_copy_flags_t = 0;
pub const MDBX_CP_COMPACT: MDBX_copy_flags_t = 1;
pub const MDBX_CP_FORCE_DYNAMIC_SIZE: MDBX_copy_flags_t = 2;
pub type MDBX_copy_flags_t = ::libc::c_uint;
pub const MDBX_FIRST: MDBX_cursor_op = 0;
pub const MDBX_FIRST_DUP: MDBX_cursor_op = 1;
pub const MDBX_GET_BOTH: MDBX_cursor_op = 2;
pub const MDBX_GET_BOTH_RANGE: MDBX_cursor_op = 3;
pub const MDBX_GET_CURRENT: MDBX_cursor_op = 4;
pub const MDBX_GET_MULTIPLE: MDBX_cursor_op = 5;
pub const MDBX_LAST: MDBX_cursor_op = 6;
pub const MDBX_LAST_DUP: MDBX_cursor_op = 7;
pub const MDBX_NEXT: MDBX_cursor_op = 8;
pub const MDBX_NEXT_DUP: MDBX_cursor_op = 9;
pub const MDBX_NEXT_MULTIPLE: MDBX_cursor_op = 10;
pub const MDBX_NEXT_NODUP: MDBX_cursor_op = 11;
pub const MDBX_PREV: MDBX_cursor_op = 12;
pub const MDBX_PREV_DUP: MDBX_cursor_op = 13;
pub const MDBX_PREV_NODUP: MDBX_cursor_op = 14;
pub const MDBX_SET: MDBX_cursor_op = 15;
pub const MDBX_SET_KEY: MDBX_cursor_op = 16;
pub const MDBX_SET_RANGE: MDBX_cursor_op = 17;
pub const MDBX_PREV_MULTIPLE: MDBX_cursor_op = 18;
pub const MDBX_SET_LOWERBOUND: MDBX_cursor_op = 19;
pub type MDBX_cursor_op = ::libc::c_uint;
pub const MDBX_SUCCESS: MDBX_error_t = 0;
pub const MDBX_RESULT_FALSE: MDBX_error_t = 0;
pub const MDBX_RESULT_TRUE: MDBX_error_t = -1;
pub const MDBX_KEYEXIST: MDBX_error_t = -30799;
pub const MDBX_FIRST_LMDB_ERRCODE: MDBX_error_t = -30799;
pub const MDBX_NOTFOUND: MDBX_error_t = -30798;
pub const MDBX_PAGE_NOTFOUND: MDBX_error_t = -30797;
pub const MDBX_CORRUPTED: MDBX_error_t = -30796;
pub const MDBX_PANIC: MDBX_error_t = -30795;
pub const MDBX_VERSION_MISMATCH: MDBX_error_t = -30794;
pub const MDBX_INVALID: MDBX_error_t = -30793;
pub const MDBX_MAP_FULL: MDBX_error_t = -30792;
pub const MDBX_DBS_FULL: MDBX_error_t = -30791;
pub const MDBX_READERS_FULL: MDBX_error_t = -30790;
pub const MDBX_TXN_FULL: MDBX_error_t = -30788;
pub const MDBX_CURSOR_FULL: MDBX_error_t = -30787;
pub const MDBX_PAGE_FULL: MDBX_error_t = -30786;
pub const MDBX_UNABLE_EXTEND_MAPSIZE: MDBX_error_t = -30785;
pub const MDBX_INCOMPATIBLE: MDBX_error_t = -30784;
pub const MDBX_BAD_RSLOT: MDBX_error_t = -30783;
pub const MDBX_BAD_TXN: MDBX_error_t = -30782;
pub const MDBX_BAD_VALSIZE: MDBX_error_t = -30781;
pub const MDBX_BAD_DBI: MDBX_error_t = -30780;
pub const MDBX_PROBLEM: MDBX_error_t = -30779;
pub const MDBX_LAST_LMDB_ERRCODE: MDBX_error_t = -30779;
pub const MDBX_BUSY: MDBX_error_t = -30778;
pub const MDBX_FIRST_ADDED_ERRCODE: MDBX_error_t = -30778;
pub const MDBX_EMULTIVAL: MDBX_error_t = -30421;
pub const MDBX_EBADSIGN: MDBX_error_t = -30420;
pub const MDBX_WANNA_RECOVERY: MDBX_error_t = -30419;
pub const MDBX_EKEYMISMATCH: MDBX_error_t = -30418;
pub const MDBX_TOO_LARGE: MDBX_error_t = -30417;
pub const MDBX_THREAD_MISMATCH: MDBX_error_t = -30416;
pub const MDBX_TXN_OVERLAPPING: MDBX_error_t = -30415;
pub const MDBX_LAST_ADDED_ERRCODE: MDBX_error_t = -30415;
pub const MDBX_ENODATA: MDBX_error_t = 61;
pub const MDBX_EINVAL: MDBX_error_t = 22;
pub const MDBX_EACCESS: MDBX_error_t = 13;
pub const MDBX_ENOMEM: MDBX_error_t = 12;
pub const MDBX_EROFS: MDBX_error_t = 30;
pub const MDBX_ENOSYS: MDBX_error_t = 38;
pub const MDBX_EIO: MDBX_error_t = 5;
pub const MDBX_EPERM: MDBX_error_t = 1;
pub const MDBX_EINTR: MDBX_error_t = 4;
pub const MDBX_ENOFILE: MDBX_error_t = 2;
pub const MDBX_EREMOTE: MDBX_error_t = 15;
pub type MDBX_error_t = ::libc::c_int;
extern "C" {
    pub fn mdbx_strerror(errnum: ::libc::c_int) -> *const ::libc::c_char;
}
extern "C" {
    pub fn mdbx_strerror_r(
        errnum: ::libc::c_int,
        buf: *mut ::libc::c_char,
        buflen: usize,
    ) -> *const ::libc::c_char;
}
extern "C" {
    pub fn mdbx_liberr2str(errnum: ::libc::c_int) -> *const ::libc::c_char;
}
extern "C" {
    pub fn mdbx_env_create(penv: *mut *mut MDBX_env) -> ::libc::c_int;
}
pub const MDBX_opt_max_db: MDBX_option_t = 0;
pub const MDBX_opt_max_readers: MDBX_option_t = 1;
pub const MDBX_opt_sync_bytes: MDBX_option_t = 2;
pub const MDBX_opt_sync_period: MDBX_option_t = 3;
pub const MDBX_opt_rp_augment_limit: MDBX_option_t = 4;
pub const MDBX_opt_loose_limit: MDBX_option_t = 5;
pub const MDBX_opt_dp_reserve_limit: MDBX_option_t = 6;
pub const MDBX_opt_txn_dp_limit: MDBX_option_t = 7;
pub const MDBX_opt_txn_dp_initial: MDBX_option_t = 8;
pub const MDBX_opt_spill_max_denominator: MDBX_option_t = 9;
pub const MDBX_opt_spill_min_denominator: MDBX_option_t = 10;
pub const MDBX_opt_spill_parent4child_denominator: MDBX_option_t = 11;
pub const MDBX_opt_merge_threshold_16dot16_percent: MDBX_option_t = 12;
pub type MDBX_option_t = ::libc::c_uint;
extern "C" {
    pub fn mdbx_env_set_option(
        env: *mut MDBX_env,
        option: MDBX_option_t,
        value: u64,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_get_option(
        env: *const MDBX_env,
        option: MDBX_option_t,
        pvalue: *mut u64,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_open(
        env: *mut MDBX_env,
        pathname: *const ::libc::c_char,
        flags: MDBX_env_flags_t,
        mode: mdbx_mode_t,
    ) -> ::libc::c_int;
}
pub const MDBX_ENV_JUST_DELETE: MDBX_env_delete_mode_t = 0;
pub const MDBX_ENV_ENSURE_UNUSED: MDBX_env_delete_mode_t = 1;
pub const MDBX_ENV_WAIT_FOR_UNUSED: MDBX_env_delete_mode_t = 2;
pub type MDBX_env_delete_mode_t = ::libc::c_uint;
extern "C" {
    pub fn mdbx_env_delete(
        pathname: *const ::libc::c_char,
        mode: MDBX_env_delete_mode_t,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_copy(
        env: *mut MDBX_env,
        dest: *const ::libc::c_char,
        flags: MDBX_copy_flags_t,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_copy2fd(
        env: *mut MDBX_env,
        fd: mdbx_filehandle_t,
        flags: MDBX_copy_flags_t,
    ) -> ::libc::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_stat {
    pub ms_psize: u32,
    pub ms_depth: u32,
    pub ms_branch_pages: u64,
    pub ms_leaf_pages: u64,
    pub ms_overflow_pages: u64,
    pub ms_entries: u64,
    pub ms_mod_txnid: u64,
}
extern "C" {
    pub fn mdbx_env_stat_ex(
        env: *const MDBX_env,
        txn: *const MDBX_txn,
        stat: *mut MDBX_stat,
        bytes: usize,
    ) -> ::libc::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_envinfo {
    pub mi_geo: MDBX_envinfo__bindgen_ty_1,
    pub mi_mapsize: u64,
    pub mi_last_pgno: u64,
    pub mi_recent_txnid: u64,
    pub mi_latter_reader_txnid: u64,
    pub mi_self_latter_reader_txnid: u64,
    pub mi_meta0_txnid: u64,
    pub mi_meta0_sign: u64,
    pub mi_meta1_txnid: u64,
    pub mi_meta1_sign: u64,
    pub mi_meta2_txnid: u64,
    pub mi_meta2_sign: u64,
    pub mi_maxreaders: u32,
    pub mi_numreaders: u32,
    pub mi_dxb_pagesize: u32,
    pub mi_sys_pagesize: u32,
    pub mi_bootid: MDBX_envinfo__bindgen_ty_2,
    pub mi_unsync_volume: u64,
    pub mi_autosync_threshold: u64,
    pub mi_since_sync_seconds16dot16: u32,
    pub mi_autosync_period_seconds16dot16: u32,
    pub mi_since_reader_check_seconds16dot16: u32,
    pub mi_mode: u32,
    pub mi_pgop_stat: MDBX_envinfo__bindgen_ty_3,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_envinfo__bindgen_ty_1 {
    pub lower: u64,
    pub upper: u64,
    pub current: u64,
    pub shrink: u64,
    pub grow: u64,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_envinfo__bindgen_ty_2 {
    pub current: MDBX_envinfo__bindgen_ty_2__bindgen_ty_1,
    pub meta0: MDBX_envinfo__bindgen_ty_2__bindgen_ty_1,
    pub meta1: MDBX_envinfo__bindgen_ty_2__bindgen_ty_1,
    pub meta2: MDBX_envinfo__bindgen_ty_2__bindgen_ty_1,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_envinfo__bindgen_ty_2__bindgen_ty_1 {
    pub x: u64,
    pub y: u64,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_envinfo__bindgen_ty_3 {
    pub newly: u64,
    pub cow: u64,
    pub clone: u64,
    pub split: u64,
    pub merge: u64,
    pub spill: u64,
    pub unspill: u64,
    pub wops: u64,
}
extern "C" {
    pub fn mdbx_env_info_ex(
        env: *const MDBX_env,
        txn: *const MDBX_txn,
        info: *mut MDBX_envinfo,
        bytes: usize,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_sync_ex(env: *mut MDBX_env, force: bool, nonblock: bool) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_close_ex(env: *mut MDBX_env, dont_sync: bool) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_set_flags(
        env: *mut MDBX_env,
        flags: MDBX_env_flags_t,
        onoff: bool,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_get_flags(env: *const MDBX_env, flags: *mut ::libc::c_uint) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_get_path(
        env: *const MDBX_env,
        dest: *mut *const ::libc::c_char,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_get_fd(env: *const MDBX_env, fd: *mut mdbx_filehandle_t) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_set_geometry(
        env: *mut MDBX_env,
        size_lower: isize,
        size_now: isize,
        size_upper: isize,
        growth_step: isize,
        shrink_threshold: isize,
        pagesize: isize,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_is_readahead_reasonable(volume: usize, redundancy: isize) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_limits_dbsize_min(pagesize: isize) -> isize;
}
extern "C" {
    pub fn mdbx_limits_dbsize_max(pagesize: isize) -> isize;
}
extern "C" {
    pub fn mdbx_limits_keysize_max(pagesize: isize, flags: MDBX_db_flags_t) -> isize;
}
extern "C" {
    pub fn mdbx_limits_valsize_max(pagesize: isize, flags: MDBX_db_flags_t) -> isize;
}
extern "C" {
    pub fn mdbx_limits_txnsize_max(pagesize: isize) -> isize;
}
extern "C" {
    pub fn mdbx_default_pagesize() -> usize;
}
extern "C" {
    pub fn mdbx_get_sysraminfo(
        page_size: *mut isize,
        total_pages: *mut isize,
        avail_pages: *mut isize,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_get_maxkeysize_ex(
        env: *const MDBX_env,
        flags: MDBX_db_flags_t,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_get_maxvalsize_ex(
        env: *const MDBX_env,
        flags: MDBX_db_flags_t,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_get_maxkeysize(env: *const MDBX_env) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_set_userctx(env: *mut MDBX_env, ctx: *mut ::libc::c_void) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_get_userctx(env: *const MDBX_env) -> *mut ::libc::c_void;
}
extern "C" {
    pub fn mdbx_txn_begin_ex(
        env: *mut MDBX_env,
        parent: *mut MDBX_txn,
        flags: MDBX_txn_flags_t,
        txn: *mut *mut MDBX_txn,
        context: *mut ::libc::c_void,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_txn_set_userctx(txn: *mut MDBX_txn, ctx: *mut ::libc::c_void) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_txn_get_userctx(txn: *const MDBX_txn) -> *mut ::libc::c_void;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_txn_info {
    pub txn_id: u64,
    pub txn_reader_lag: u64,
    pub txn_space_used: u64,
    pub txn_space_limit_soft: u64,
    pub txn_space_limit_hard: u64,
    pub txn_space_retired: u64,
    pub txn_space_leftover: u64,
    pub txn_space_dirty: u64,
}
extern "C" {
    pub fn mdbx_txn_info(
        txn: *const MDBX_txn,
        info: *mut MDBX_txn_info,
        scan_rlt: bool,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_txn_env(txn: *const MDBX_txn) -> *mut MDBX_env;
}
extern "C" {
    pub fn mdbx_txn_flags(txn: *const MDBX_txn) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_txn_id(txn: *const MDBX_txn) -> u64;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_commit_latency {
    pub preparation: u32,
    pub gc: u32,
    pub audit: u32,
    pub write: u32,
    pub sync: u32,
    pub ending: u32,
    pub whole: u32,
}
extern "C" {
    pub fn mdbx_txn_commit_ex(
        txn: *mut MDBX_txn,
        latency: *mut MDBX_commit_latency,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_txn_abort(txn: *mut MDBX_txn) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_txn_break(txn: *mut MDBX_txn) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_txn_reset(txn: *mut MDBX_txn) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_txn_renew(txn: *mut MDBX_txn) -> ::libc::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct MDBX_canary {
    pub x: u64,
    pub y: u64,
    pub z: u64,
    pub v: u64,
}
extern "C" {
    pub fn mdbx_canary_put(txn: *mut MDBX_txn, canary: *const MDBX_canary) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_canary_get(txn: *const MDBX_txn, canary: *mut MDBX_canary) -> ::libc::c_int;
}
pub type MDBX_cmp_func = ::std::option::Option<
    unsafe extern "C" fn(a: *const MDBX_val, b: *const MDBX_val) -> ::libc::c_int,
>;
extern "C" {
    pub fn mdbx_dbi_open(
        txn: *mut MDBX_txn,
        name: *const ::libc::c_char,
        flags: MDBX_db_flags_t,
        dbi: *mut MDBX_dbi,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_dbi_open_ex(
        txn: *mut MDBX_txn,
        name: *const ::libc::c_char,
        flags: MDBX_db_flags_t,
        dbi: *mut MDBX_dbi,
        keycmp: MDBX_cmp_func,
        datacmp: MDBX_cmp_func,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_key_from_jsonInteger(json_integer: i64) -> u64;
}
extern "C" {
    pub fn mdbx_key_from_double(ieee754_64bit: f64) -> u64;
}
extern "C" {
    pub fn mdbx_key_from_ptrdouble(ieee754_64bit: *const f64) -> u64;
}
extern "C" {
    pub fn mdbx_key_from_float(ieee754_32bit: f32) -> u32;
}
extern "C" {
    pub fn mdbx_key_from_ptrfloat(ieee754_32bit: *const f32) -> u32;
}
extern "C" {
    pub fn mdbx_jsonInteger_from_key(arg1: MDBX_val) -> i64;
}
extern "C" {
    pub fn mdbx_double_from_key(arg1: MDBX_val) -> f64;
}
extern "C" {
    pub fn mdbx_float_from_key(arg1: MDBX_val) -> f32;
}
extern "C" {
    pub fn mdbx_int32_from_key(arg1: MDBX_val) -> i32;
}
extern "C" {
    pub fn mdbx_int64_from_key(arg1: MDBX_val) -> i64;
}
extern "C" {
    pub fn mdbx_dbi_stat(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        stat: *mut MDBX_stat,
        bytes: usize,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_dbi_dupsort_depthmask(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        mask: *mut u32,
    ) -> ::libc::c_int;
}
pub const MDBX_DBI_DIRTY: MDBX_dbi_state_t = 1;
pub const MDBX_DBI_STALE: MDBX_dbi_state_t = 2;
pub const MDBX_DBI_FRESH: MDBX_dbi_state_t = 4;
pub const MDBX_DBI_CREAT: MDBX_dbi_state_t = 8;
pub type MDBX_dbi_state_t = ::libc::c_uint;
extern "C" {
    pub fn mdbx_dbi_flags_ex(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        flags: *mut ::libc::c_uint,
        state: *mut ::libc::c_uint,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_dbi_close(env: *mut MDBX_env, dbi: MDBX_dbi) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_drop(txn: *mut MDBX_txn, dbi: MDBX_dbi, del: bool) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_get(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        key: *const MDBX_val,
        data: *mut MDBX_val,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_get_ex(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        key: *mut MDBX_val,
        data: *mut MDBX_val,
        values_count: *mut usize,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_get_equal_or_great(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        key: *mut MDBX_val,
        data: *mut MDBX_val,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_put(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        key: *const MDBX_val,
        data: *mut MDBX_val,
        flags: MDBX_put_flags_t,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_replace(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        key: *const MDBX_val,
        new_data: *mut MDBX_val,
        old_data: *mut MDBX_val,
        flags: MDBX_put_flags_t,
    ) -> ::libc::c_int;
}
pub type MDBX_preserve_func = ::std::option::Option<
    unsafe extern "C" fn(
        context: *mut ::libc::c_void,
        target: *mut MDBX_val,
        src: *const ::libc::c_void,
        bytes: usize,
    ) -> ::libc::c_int,
>;
extern "C" {
    pub fn mdbx_replace_ex(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        key: *const MDBX_val,
        new_data: *mut MDBX_val,
        old_data: *mut MDBX_val,
        flags: MDBX_put_flags_t,
        preserver: MDBX_preserve_func,
        preserver_context: *mut ::libc::c_void,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_del(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        key: *const MDBX_val,
        data: *const MDBX_val,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_create(context: *mut ::libc::c_void) -> *mut MDBX_cursor;
}
extern "C" {
    pub fn mdbx_cursor_set_userctx(
        cursor: *mut MDBX_cursor,
        ctx: *mut ::libc::c_void,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_get_userctx(cursor: *const MDBX_cursor) -> *mut ::libc::c_void;
}
extern "C" {
    pub fn mdbx_cursor_bind(
        txn: *mut MDBX_txn,
        cursor: *mut MDBX_cursor,
        dbi: MDBX_dbi,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_open(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        cursor: *mut *mut MDBX_cursor,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_close(cursor: *mut MDBX_cursor);
}
extern "C" {
    pub fn mdbx_cursor_renew(txn: *mut MDBX_txn, cursor: *mut MDBX_cursor) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_txn(cursor: *const MDBX_cursor) -> *mut MDBX_txn;
}
extern "C" {
    pub fn mdbx_cursor_dbi(cursor: *const MDBX_cursor) -> MDBX_dbi;
}
extern "C" {
    pub fn mdbx_cursor_copy(src: *const MDBX_cursor, dest: *mut MDBX_cursor) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_get(
        cursor: *mut MDBX_cursor,
        key: *mut MDBX_val,
        data: *mut MDBX_val,
        op: MDBX_cursor_op,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_put(
        cursor: *mut MDBX_cursor,
        key: *const MDBX_val,
        data: *mut MDBX_val,
        flags: MDBX_put_flags_t,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_del(cursor: *mut MDBX_cursor, flags: MDBX_put_flags_t) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_count(cursor: *const MDBX_cursor, pcount: *mut usize) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_eof(cursor: *const MDBX_cursor) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_on_first(cursor: *const MDBX_cursor) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cursor_on_last(cursor: *const MDBX_cursor) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_estimate_distance(
        first: *const MDBX_cursor,
        last: *const MDBX_cursor,
        distance_items: *mut isize,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_estimate_move(
        cursor: *const MDBX_cursor,
        key: *mut MDBX_val,
        data: *mut MDBX_val,
        move_op: MDBX_cursor_op,
        distance_items: *mut isize,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_estimate_range(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        begin_key: *mut MDBX_val,
        begin_data: *mut MDBX_val,
        end_key: *mut MDBX_val,
        end_data: *mut MDBX_val,
        distance_items: *mut isize,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_is_dirty(txn: *const MDBX_txn, ptr: *const ::libc::c_void) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_dbi_sequence(
        txn: *mut MDBX_txn,
        dbi: MDBX_dbi,
        result: *mut u64,
        increment: u64,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_cmp(
        txn: *const MDBX_txn,
        dbi: MDBX_dbi,
        a: *const MDBX_val,
        b: *const MDBX_val,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_get_keycmp(flags: MDBX_db_flags_t) -> MDBX_cmp_func;
}
extern "C" {
    pub fn mdbx_dcmp(
        txn: *const MDBX_txn,
        dbi: MDBX_dbi,
        a: *const MDBX_val,
        b: *const MDBX_val,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_get_datacmp(flags: MDBX_db_flags_t) -> MDBX_cmp_func;
}
pub type MDBX_reader_list_func = ::std::option::Option<
    unsafe extern "C" fn(
        ctx: *mut ::libc::c_void,
        num: ::libc::c_int,
        slot: ::libc::c_int,
        pid: mdbx_pid_t,
        thread: mdbx_tid_t,
        txnid: u64,
        lag: u64,
        bytes_used: usize,
        bytes_retained: usize,
    ) -> ::libc::c_int,
>;
extern "C" {
    pub fn mdbx_reader_list(
        env: *const MDBX_env,
        func: MDBX_reader_list_func,
        ctx: *mut ::libc::c_void,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_reader_check(env: *mut MDBX_env, dead: *mut ::libc::c_int) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_txn_straggler(txn: *const MDBX_txn, percent: *mut ::libc::c_int) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_thread_register(env: *const MDBX_env) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_thread_unregister(env: *const MDBX_env) -> ::libc::c_int;
}
pub type MDBX_hsr_func = ::std::option::Option<
    unsafe extern "C" fn(
        env: *const MDBX_env,
        txn: *const MDBX_txn,
        pid: mdbx_pid_t,
        tid: mdbx_tid_t,
        laggard: u64,
        gap: ::libc::c_uint,
        space: usize,
        retry: ::libc::c_int,
    ) -> ::libc::c_int,
>;
extern "C" {
    pub fn mdbx_env_set_hsr(env: *mut MDBX_env, hsr_callback: MDBX_hsr_func) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_get_hsr(env: *const MDBX_env) -> MDBX_hsr_func;
}
pub const MDBX_page_broken: MDBX_page_type_t = 0;
pub const MDBX_page_meta: MDBX_page_type_t = 1;
pub const MDBX_page_large: MDBX_page_type_t = 2;
pub const MDBX_page_branch: MDBX_page_type_t = 3;
pub const MDBX_page_leaf: MDBX_page_type_t = 4;
pub const MDBX_page_dupfixed_leaf: MDBX_page_type_t = 5;
pub const MDBX_subpage_leaf: MDBX_page_type_t = 6;
pub const MDBX_subpage_dupfixed_leaf: MDBX_page_type_t = 7;
pub const MDBX_subpage_broken: MDBX_page_type_t = 8;
pub type MDBX_page_type_t = ::libc::c_uint;
pub type MDBX_pgvisitor_func = ::std::option::Option<
    unsafe extern "C" fn(
        pgno: u64,
        number: ::libc::c_uint,
        ctx: *mut ::libc::c_void,
        deep: ::libc::c_int,
        dbi: *const ::libc::c_char,
        page_size: usize,
        type_: MDBX_page_type_t,
        err: MDBX_error_t,
        nentries: usize,
        payload_bytes: usize,
        header_bytes: usize,
        unused_bytes: usize,
    ) -> ::libc::c_int,
>;
extern "C" {
    pub fn mdbx_env_pgwalk(
        txn: *mut MDBX_txn,
        visitor: MDBX_pgvisitor_func,
        ctx: *mut ::libc::c_void,
        dont_check_keys_ordering: bool,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_open_for_recovery(
        env: *mut MDBX_env,
        pathname: *const ::libc::c_char,
        target_meta: ::libc::c_uint,
        writeable: bool,
    ) -> ::libc::c_int;
}
extern "C" {
    pub fn mdbx_env_turn_for_recovery(
        env: *mut MDBX_env,
        target_meta: ::libc::c_uint,
    ) -> ::libc::c_int;
}
pub type __builtin_va_list = [__va_list_tag; 1usize];
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __va_list_tag {
    pub gp_offset: ::libc::c_uint,
    pub fp_offset: ::libc::c_uint,
    pub overflow_arg_area: *mut ::libc::c_void,
    pub reg_save_area: *mut ::libc::c_void,
}