summaryrefslogtreecommitdiff
path: root/src/trans/allocator.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-07-16 13:27:31 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-07-16 13:27:31 +0800
commit97567dbbd8c3f8719dbb9e32c6d0f3a155246508 (patch)
tree3268a7f2bcadd013199883b7bbc2f26b9c385643 /src/trans/allocator.cpp
parent9d1a660045de5a3cc37315c78a3a75999fef9b9a (diff)
downloadmrust-97567dbbd8c3f8719dbb9e32c6d0f3a155246508.tar.gz
All - Upgrade to rustc 1.19.0 beta (2017-07-08)
Diffstat (limited to 'src/trans/allocator.cpp')
-rw-r--r--src/trans/allocator.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/trans/allocator.cpp b/src/trans/allocator.cpp
new file mode 100644
index 00000000..ce4b3340
--- /dev/null
+++ b/src/trans/allocator.cpp
@@ -0,0 +1,30 @@
+
+
+#include "allocator.hpp"
+
+#define DEF_METHOD_ARGS(name, ...) const AllocatorDataTy ALLOCATOR_METHODS_ARGS_##name[] = { __VA_ARGS__ };
+#define DEF_METHOD(name, ret) { #name, AllocatorDataTy::ret, sizeof(ALLOCATOR_METHODS_ARGS_##name)/sizeof(AllocatorDataTy), ALLOCATOR_METHODS_ARGS_##name }
+
+DEF_METHOD_ARGS(alloc, AllocatorDataTy::Layout)
+DEF_METHOD_ARGS(oom, AllocatorDataTy::AllocError)
+DEF_METHOD_ARGS(dealloc, AllocatorDataTy::Ptr, AllocatorDataTy::Layout)
+DEF_METHOD_ARGS(usable_size, AllocatorDataTy::LayoutRef)
+DEF_METHOD_ARGS(realloc, AllocatorDataTy::Ptr, AllocatorDataTy::Layout, AllocatorDataTy::Layout)
+DEF_METHOD_ARGS(alloc_zeroed, AllocatorDataTy::Layout)
+DEF_METHOD_ARGS(alloc_excess, AllocatorDataTy::Layout)
+DEF_METHOD_ARGS(realloc_excess, AllocatorDataTy::Ptr, AllocatorDataTy::Layout, AllocatorDataTy::Layout)
+DEF_METHOD_ARGS(grow_in_place, AllocatorDataTy::Ptr, AllocatorDataTy::Layout, AllocatorDataTy::Layout)
+DEF_METHOD_ARGS(shrink_in_place, AllocatorDataTy::Ptr, AllocatorDataTy::Layout, AllocatorDataTy::Layout)
+
+const AllocatorMethod ALLOCATOR_METHODS[10] = {
+ DEF_METHOD(alloc, ResultPtr),
+ DEF_METHOD(oom, Never),
+ DEF_METHOD(dealloc, Unit),
+ DEF_METHOD(usable_size, UsizePair),
+ DEF_METHOD(realloc, ResultPtr),
+ DEF_METHOD(alloc_zeroed, ResultPtr),
+ DEF_METHOD(alloc_excess, ResultExcess),
+ DEF_METHOD(realloc_excess, ResultExcess),
+ DEF_METHOD(grow_in_place, ResultUnit),
+ DEF_METHOD(shrink_in_place, ResultUnit)
+ };