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

align buffer at 64-byte boundary so that memcpy can take advantage of… #1141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dokan/dokan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1366,8 +1366,8 @@ VOID DOKANAPI DokanMapKernelToUserCreateFileFlags(
}

VOID DOKANAPI DokanInit() {
// ensure 64-bit alignment
assert(FIELD_OFFSET(EVENT_INFORMATION, Buffer) % 8 == 0);
// ensure 64-byte alignment, memcpy runs much faster on 64-byte aligned buffer on moden CPU
static_assert(FIELD_OFFSET(EVENT_INFORMATION, Buffer) % 64 == 0, "alignment error");

// this is not as safe as a critical section so to some degree we rely on
// the user to do the right thing
Expand Down
1 change: 1 addition & 0 deletions sys/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ typedef struct _EVENT_INFORMATION {
ULONG64 Context;
ULONG BufferLength;
ULONG PullEventTimeoutMs;
UCHAR Padding[24]; // ensure buffer is 64-byte aligned
UCHAR Buffer[DOKAN_EVENT_INFO_MIN_BUFFER_SIZE];
} EVENT_INFORMATION, *PEVENT_INFORMATION;

Expand Down