5 #if defined(A_HAVE_MIMALLOC_H)
6 #include <mimalloc-override.h>
7 #endif /* A_HAVE_MIMALLOC_H */
9 void *a_copy(void *__restrict dst
, void const *__restrict src
, a_size siz
) { return memcpy(dst
, src
, siz
); }
11 void *a_move(void *dst
, void const *src
, a_size siz
) { return memmove(dst
, src
, siz
); }
13 void *a_fill(void *ptr
, a_size siz
, int val
) { return memset(ptr
, val
, siz
); }
15 void *a_zero(void *ptr
, a_size siz
) { return memset(ptr
, 0, siz
); }
17 void a_swap(void *_lhs
, void *_rhs
, a_size siz
)
19 a_byte
*lhs
= (a_byte
*)_lhs
;
20 a_byte
*rhs
= (a_byte
*)_rhs
;
21 for (a_byte buf
; siz
; --siz
, ++lhs
, ++rhs
)
29 a_u32
a_hash_bkdr(void const *_str
, a_u32 val
)
31 a_byte
const *str
= (a_byte
const *)_str
;
36 val
= val
* 131 + *str
;
42 a_u32
a_hash_bkdr_(void const *_ptr
, a_size siz
, a_u32 val
)
44 a_byte
const *ptr
= (a_byte
const *)_ptr
;
47 for (; siz
; --siz
, ++ptr
)
49 val
= val
* 131 + *ptr
;
55 a_u32
a_hash_sdbm(void const *_str
, a_u32 val
)
57 a_byte
const *str
= (a_byte
const *)_str
;
62 val
= val
* 65599 + *str
;
68 a_u32
a_hash_sdbm_(void const *_ptr
, a_size siz
, a_u32 val
)
70 a_byte
const *ptr
= (a_byte
const *)_ptr
;
73 for (; siz
; --siz
, ++ptr
)
75 val
= val
* 65599 + *ptr
;
81 void a_float_push(a_float
*block_p
, a_size block_n
,
82 a_float
const *cache_p
, a_size cache_n
)
84 a_size
const n
= A_MIN(cache_n
, block_n
);
85 for (a_size t
= block_n
, s
= block_n
- n
; s
;)
87 block_p
[--t
] = block_p
[--s
];
89 for (a_size i
= 0; i
!= n
; ++i
)
91 block_p
[i
] = cache_p
[i
];
95 void a_float_roll(a_float
*block_p
, a_size block_n
,
96 a_float
*shift_p
, a_size shift_n
)
98 a_size
const shift
= shift_n
% block_n
;
99 a_size
const start
= block_n
- shift
;
100 for (a_size t
= 0, s
= start
; t
!= shift
;)
102 shift_p
[t
++] = block_p
[s
++];
104 for (a_size t
= block_n
, s
= start
; s
;)
106 block_p
[--t
] = block_p
[--s
];
108 for (a_size i
= 0; i
!= shift
; ++i
)
110 block_p
[i
] = shift_p
[i
];
114 A_ALLOC((*a_alloc
), addr
, size
) = a_alloc_
;
115 A_ALLOC(a_alloc_
, addr
, size
)
121 return realloc(addr
, size
);