memfile_defs.h
Go to the documentation of this file.
1 #ifndef NVIM_MEMFILE_DEFS_H
2 #define NVIM_MEMFILE_DEFS_H
3 
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include <stdlib.h>
7 
8 #include "nvim/pos.h"
9 #include "nvim/types.h"
10 
16 typedef int64_t blocknr_T;
17 
25 typedef struct mf_hashitem {
30 
32 #define MHT_INIT_SIZE 64
33 
40 typedef struct mf_hashtab {
41  size_t mht_mask;
42  size_t mht_count;
48 } mf_hashtab_T;
49 
63 typedef struct bhdr {
65 #define bh_bnum bh_hashitem.mhi_key
66 
67  struct bhdr *bh_next;
68  struct bhdr *bh_prev;
69  void *bh_data;
70  unsigned bh_page_count;
71 
72 #define BH_DIRTY 1U
73 #define BH_LOCKED 2U
74  unsigned bh_flags; // BH_DIRTY or BH_LOCKED
75 } bhdr_T;
76 
83 typedef struct mf_blocknr_trans_item {
85 #define nt_old_bnum nt_hashitem.mhi_key
86  blocknr_T nt_new_bnum;
87 } mf_blocknr_trans_item_T;
88 
90 typedef struct memfile {
93  int mf_fd;
103  unsigned mf_page_size;
104  bool mf_dirty;
105 } memfile_T;
106 
107 #endif // NVIM_MEMFILE_DEFS_H
mf_hashitem_T
struct mf_hashitem mf_hashitem_T
bhdr::bh_flags
unsigned bh_flags
Definition: memfile_defs.h:74
mf_blocknr_trans_item::nt_hashitem
mf_hashitem_T nt_hashitem
Definition: memfile_defs.h:84
memfile::mf_fname
char_u * mf_fname
Definition: memfile_defs.h:91
memfile::mf_ffname
char_u * mf_ffname
name of the file
Definition: memfile_defs.h:92
MHT_INIT_SIZE
#define MHT_INIT_SIZE
Initial size for a hashtable.
Definition: memfile_defs.h:32
memfile::mf_neg_count
blocknr_T mf_neg_count
lowest negative block number - 1
Definition: memfile_defs.h:101
types.h
bhdr::bh_hashitem
mf_hashitem_T bh_hashitem
Definition: memfile_defs.h:64
mf_blocknr_trans_item
Definition: memfile_defs.h:83
memfile::mf_hash
mf_hashtab_T mf_hash
lru block header in used list
Definition: memfile_defs.h:97
bhdr::bh_page_count
unsigned bh_page_count
pointer to memory (for used block)
Definition: memfile_defs.h:70
memfile::mf_fd
int mf_fd
idem, full path
Definition: memfile_defs.h:93
memfile_T
struct memfile memfile_T
A memory file.
bhdr_T
struct bhdr bhdr_T
memfile
A memory file.
Definition: memfile_defs.h:90
memfile::mf_free_first
bhdr_T * mf_free_first
file descriptor
Definition: memfile_defs.h:94
bhdr::bh_data
void * bh_data
previous block header in used list
Definition: memfile_defs.h:69
blocknr_T
int64_t blocknr_T
Definition: memfile_defs.h:16
memfile::mf_used_last
bhdr_T * mf_used_last
mru block header in used list
Definition: memfile_defs.h:96
memfile::mf_blocknr_max
blocknr_T mf_blocknr_max
trans lists
Definition: memfile_defs.h:99
bhdr::bh_next
struct bhdr * bh_next
Definition: memfile_defs.h:67
mf_hashitem::mhi_key
blocknr_T mhi_key
Definition: memfile_defs.h:28
memfile::mf_infile_count
blocknr_T mf_infile_count
number of negative blocks numbers
Definition: memfile_defs.h:102
memfile::mf_trans
mf_hashtab_T mf_trans
hash lists
Definition: memfile_defs.h:98
mf_hashtab::mht_buckets
mf_hashitem_T ** mht_buckets
number of items inserted
Definition: memfile_defs.h:44
memfile::mf_page_size
unsigned mf_page_size
number of pages in the file
Definition: memfile_defs.h:103
memfile::mf_used_first
bhdr_T * mf_used_first
first block header in free list
Definition: memfile_defs.h:95
bhdr::bh_prev
struct bhdr * bh_prev
next block header in free or used list
Definition: memfile_defs.h:68
mf_hashtab::mht_mask
size_t mht_mask
Definition: memfile_defs.h:41
mf_hashtab
Definition: memfile_defs.h:40
mf_hashitem::mhi_next
struct mf_hashitem * mhi_next
Definition: memfile_defs.h:26
mf_hashtab::mht_count
size_t mht_count
Definition: memfile_defs.h:43
memfile::mf_blocknr_min
blocknr_T mf_blocknr_min
highest positive block number + 1
Definition: memfile_defs.h:100
char_u
unsigned char char_u
Definition: types.h:12
bhdr
Definition: memfile_defs.h:63
mf_hashitem
Definition: memfile_defs.h:25
mf_hashtab_T
struct mf_hashtab mf_hashtab_T
stdlib.h
mf_hashitem::mhi_prev
struct mf_hashitem * mhi_prev
Definition: memfile_defs.h:27
mf_hashtab::mht_small_buckets
mf_hashitem_T * mht_small_buckets[MHT_INIT_SIZE]
Definition: memfile_defs.h:47
memfile::mf_dirty
bool mf_dirty
number of bytes in a page
Definition: memfile_defs.h:104
pos.h