22 #ifndef UV_WIN_FS_FD_HASH_INL_H_
23 #define UV_WIN_FS_FD_HASH_INL_H_
42 #define UV__FD_HASH_SIZE 256
43 #define UV__FD_HASH_GROUP_SIZE 16
92 #define FIND_COMMON_VARIABLES \
94 unsigned bucket = fd % ARRAY_SIZE(uv__fd_hash); \
95 struct uv__fd_hash_entry_s* entry_ptr = NULL; \
96 struct uv__fd_hash_entry_group_s* group_ptr; \
97 struct uv__fd_hash_bucket_s* bucket_ptr = &uv__fd_hash[bucket];
99 #define FIND_IN_GROUP_PTR(group_size) \
101 for (i = 0; i < group_size; ++i) { \
102 if (group_ptr->entries[i].fd == fd) { \
103 entry_ptr = &group_ptr->entries[i]; \
109 #define FIND_IN_BUCKET_PTR() \
111 size_t first_group_size = bucket_ptr->size % UV__FD_HASH_GROUP_SIZE; \
112 if (bucket_ptr->size != 0 && first_group_size == 0) \
113 first_group_size = UV__FD_HASH_GROUP_SIZE; \
114 group_ptr = bucket_ptr->data; \
115 FIND_IN_GROUP_PTR(first_group_size); \
116 for (group_ptr = group_ptr->next; \
117 group_ptr != NULL && entry_ptr == NULL; \
118 group_ptr = group_ptr->next) \
119 FIND_IN_GROUP_PTR(UV__FD_HASH_GROUP_SIZE); \
129 if (entry_ptr !=
NULL) {
130 *
info = entry_ptr->info;
134 return entry_ptr !=
NULL;
144 if (entry_ptr ==
NULL) {
147 if (bucket_ptr->size != 0 &&
i == 0) {
150 if (new_group_ptr ==
NULL) {
153 new_group_ptr->
next = bucket_ptr->data;
154 bucket_ptr->data = new_group_ptr;
157 bucket_ptr->size += 1;
158 entry_ptr = &bucket_ptr->data->
entries[
i];
162 entry_ptr->info = *
info;
174 if (entry_ptr !=
NULL) {
175 *
info = entry_ptr->info;
177 bucket_ptr->size -= 1;
180 if (entry_ptr != &bucket_ptr->data->entries[
i]) {
181 *entry_ptr = bucket_ptr->data->entries[
i];
184 if (bucket_ptr->size != 0 &&
187 bucket_ptr->data = old_group_ptr->
next;
193 return entry_ptr !=
NULL;
196 #undef FIND_COMMON_VARIABLES
197 #undef FIND_IN_GROUP_PTR
198 #undef FIND_IN_BUCKET_PTR
RzBinInfo * info(RzBinFile *bf)
void uv_fatal_error(const int errorno, const char *syscall)
#define UV__FD_HASH_GROUP_SIZE
static uv_mutex_t uv__fd_hash_mutex
static INLINE void uv__fd_hash_add(int fd, struct uv__fd_info_s *info)
static struct uv__fd_hash_bucket_s uv__fd_hash[UV__FD_HASH_SIZE]
#define FIND_COMMON_VARIABLES
#define FIND_IN_BUCKET_PTR()
static INLINE int uv__fd_hash_get(int fd, struct uv__fd_info_s *info)
static struct uv__fd_hash_entry_group_s uv__fd_hash_entry_initial[UV__FD_HASH_SIZE *UV__FD_HASH_GROUP_SIZE]
static INLINE void uv__fd_hash_init(void)
static INLINE int uv__fd_hash_remove(int fd, struct uv__fd_info_s *info)
struct uv__fd_hash_entry_group_s * data
struct uv__fd_hash_entry_group_s * next
struct uv__fd_hash_entry_s entries[UV__FD_HASH_GROUP_SIZE]
struct uv__fd_info_s info
LARGE_INTEGER current_pos
pthread_mutex_t uv_mutex_t
void * uv__malloc(size_t size)
UV_EXTERN void uv_mutex_lock(uv_mutex_t *handle)
UV_EXTERN void uv_mutex_unlock(uv_mutex_t *handle)
UV_EXTERN int uv_mutex_init(uv_mutex_t *handle)
static const z80_opcode fd[]