aboutsummaryrefslogtreecommitdiff
path: root/std/mem.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2019-09-01 23:45:51 +0200
committerRobin Voetter <robin@voetter.nl>2019-09-01 23:45:51 +0200
commitd62f7c6b605a672f032aff8870496d2ae2366017 (patch)
tree659ae46ac0061fcafd3ec29de8682ec1f18e97cc /std/mem.zig
parente7912dee9bd63b03415f441b4de9b3babc79c859 (diff)
parent8b1900e5df76a126404c6905b9e91136c738da55 (diff)
downloadzig-d62f7c6b605a672f032aff8870496d2ae2366017.tar.gz
zig-d62f7c6b605a672f032aff8870496d2ae2366017.zip
Merge remote-tracking branch 'upstream/master' into arm-support-improvement
Diffstat (limited to 'std/mem.zig')
-rw-r--r--std/mem.zig10
1 files changed, 9 insertions, 1 deletions
diff --git a/std/mem.zig b/std/mem.zig
index 014be487cc..61dc5c7a30 100644
--- a/std/mem.zig
+++ b/std/mem.zig
@@ -117,7 +117,15 @@ pub const Allocator = struct {
const byte_slice = try self.reallocFn(self, ([*]u8)(undefined)[0..0], undefined, byte_count, a);
assert(byte_slice.len == byte_count);
@memset(byte_slice.ptr, undefined, byte_slice.len);
- return @bytesToSlice(T, @alignCast(a, byte_slice));
+ if (alignment == null) {
+ // TODO This is a workaround for zig not being able to successfully do
+ // @bytesToSlice(T, @alignCast(a, byte_slice)) without resolving alignment of T,
+ // which causes a circular dependency in async functions which try to heap-allocate
+ // their own frame with @Frame(func).
+ return @intToPtr([*]T, @ptrToInt(byte_slice.ptr))[0..n];
+ } else {
+ return @bytesToSlice(T, @alignCast(a, byte_slice));
+ }
}
/// This function requests a new byte size for an existing allocation,