Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new __traits(classInstanceAlignment) #8459

Merged
merged 1 commit into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions std/experimental/logger/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,8 @@ private @property Logger defaultSharedLoggerImpl() @trusted
import core.lifetime : emplace;
import std.stdio : stderr;

__gshared align(FileLogger.alignof) void[__traits(classInstanceSize, FileLogger)] _buffer;
__gshared align(__traits(classInstanceAlignment, FileLogger))
void[__traits(classInstanceSize, FileLogger)] _buffer;

import std.concurrency : initOnce;
initOnce!stdSharedDefaultLogger({
Expand Down Expand Up @@ -1762,9 +1763,8 @@ private @property Logger stdThreadLocalLogImpl() @trusted
{
import core.lifetime : emplace;

static void*[(__traits(classInstanceSize, StdForwardLogger) - 1) / (void*).sizeof + 1] _buffer;

auto buffer = cast(ubyte[]) _buffer;
static align(__traits(classInstanceAlignment, StdForwardLogger))
void[__traits(classInstanceSize, StdForwardLogger)] buffer;

if (stdLoggerDefaultThreadLogger is null)
{
Expand Down
2 changes: 1 addition & 1 deletion std/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -4839,7 +4839,7 @@ Returns class instance alignment.
template classInstanceAlignment(T)
if (is(T == class))
{
alias classInstanceAlignment = maxAlignment!(void*, typeof(T.tupleof));
enum classInstanceAlignment = __traits(classInstanceAlignment, T);
}

///
Expand Down
2 changes: 1 addition & 1 deletion std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -8267,7 +8267,7 @@ if (is(T == class))
{
// _d_newclass now use default GC alignment (looks like (void*).sizeof * 2 for
// small objects). We will just use the maximum of filed alignments.
alias alignment = classInstanceAlignment!T;
enum alignment = __traits(classInstanceAlignment, T);
alias aligned = _alignUp!alignment;

static struct Scoped
Expand Down