diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-01-17 13:36:00 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-01-17 14:04:55 +0100 |
| commit | 1c7a62c93b21ad1958db80b39bca14a09ea8b4bc (patch) | |
| tree | 6b3df97b7023bc3c5ac8b6ba51993c88d878bc96 /src/rt/rust_upcall.cpp | |
| parent | e046360e690534229bd674ff2b1f61d324820230 (diff) | |
| download | rust-1c7a62c93b21ad1958db80b39bca14a09ea8b4bc.tar.gz rust-1c7a62c93b21ad1958db80b39bca14a09ea8b4bc.zip | |
Use a memset upcall to zero things without static alignment
This fixes issues #843 and #1546. The cost of an upcall is unfortunate, though. I assume there must be a way to simply manually compute the pointer or size, using something akin to the formula in `align_to` in `rust_util.h`. I could not get this to work, unfortunately.
Diffstat (limited to 'src/rt/rust_upcall.cpp')
| -rw-r--r-- | src/rt/rust_upcall.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 65299a7d244..096c814f7c9 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -227,6 +227,15 @@ upcall_shared_free(void* ptr) { UPCALL_SWITCH_STACK(&args, upcall_s_shared_free); } +/************************************************************************ + * Memset that, contrary to the llvm intrinsic, handles dynamic alignment + */ + +extern "C" CDECL void +upcall_memset(void* ptr, char val, unsigned size, unsigned align) { + memset(ptr, val, align_to(size, align)); +} + /********************************************************************** * Called to deep copy a type descriptor onto the exchange heap. * Used when sending closures. It's possible that we should have |
