-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathseqmalloc.h
More file actions
58 lines (52 loc) · 2.05 KB
/
seqmalloc.h
File metadata and controls
58 lines (52 loc) · 2.05 KB
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
/*
* Copyright (C) 2019 Ricardo Leite. All rights reserved.
* Licenced under the MIT licence. See COPYING file in the project root for details.
*/
#ifndef __SEQMALLOC_H__
#define __SEQMALLOC_H__
#define SEQMALLOC_ATTR(s) __attribute__((s))
#define SEQMALLOC_ALLOC_SIZE(s) SEQMALLOC_ATTR(alloc_size(s))
#define SEQMALLOC_ALLOC_SIZE2(s1, s2) SEQMALLOC_ATTR(alloc_size(s1, s2))
#define SEQMALLOC_EXPORT SEQMALLOC_ATTR(visibility("default"))
#define SEQMALLOC_NOTHROW SEQMALLOC_ATTR(nothrow)
#define seq_malloc malloc
#define seq_free free
#define seq_calloc calloc
#define seq_realloc realloc
#define seq_malloc_usable_size malloc_usable_size
#define seq_posix_memalign posix_memalign
#define seq_aligned_alloc aligned_alloc
#define seq_valloc valloc
#define seq_memalign memalign
#define seq_pvalloc pvalloc
// called on process init/exit
void seq_malloc_initialize();
void seq_malloc_finalize();
// called on thread enter/exit
void seq_malloc_thread_initialize();
void seq_malloc_thread_finalize();
// exports
// malloc interface
void* seq_malloc(size_t size)
SEQMALLOC_EXPORT SEQMALLOC_NOTHROW SEQMALLOC_ALLOC_SIZE(1);
void seq_free(void* ptr)
SEQMALLOC_EXPORT SEQMALLOC_NOTHROW;
void* seq_calloc(size_t n, size_t size)
SEQMALLOC_EXPORT SEQMALLOC_NOTHROW SEQMALLOC_ALLOC_SIZE2(1, 2);
void* seq_realloc(void* ptr, size_t size)
SEQMALLOC_EXPORT SEQMALLOC_NOTHROW SEQMALLOC_ALLOC_SIZE(2);
// utilities
size_t seq_malloc_usable_size(void* ptr);
// memory alignment ops
int seq_posix_memalign(void** memptr, size_t alignment, size_t size)
SEQMALLOC_EXPORT SEQMALLOC_NOTHROW SEQMALLOC_ATTR(nonnull(1));
void* seq_aligned_alloc(size_t alignment, size_t size)
SEQMALLOC_EXPORT SEQMALLOC_NOTHROW SEQMALLOC_ALLOC_SIZE(2);
void* seq_valloc(size_t size)
SEQMALLOC_EXPORT SEQMALLOC_NOTHROW SEQMALLOC_ALLOC_SIZE(1);
// obsolete alignment oos
void* seq_memalign(size_t alignment, size_t size)
SEQMALLOC_EXPORT SEQMALLOC_NOTHROW SEQMALLOC_ALLOC_SIZE(2);
void* seq_pvalloc(size_t size)
SEQMALLOC_EXPORT SEQMALLOC_NOTHROW SEQMALLOC_ALLOC_SIZE(1);
#endif // __SEQMALLOC_H__