Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ the processors enabled.
--*/
static uintptr_t GetFullAffinityMask(int cpuCount)
{
return ((uintptr_t)1 << (cpuCount)) - 1;
assert((cpuCount > 0) && (cpuCount <= sizeof(uintptr_t) * 8));
return (((uintptr_t)1 << (cpuCount - 1)) << 1) - 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not obvious why the shift is split into two parts. It can use a comment.

Also, it may be better for readability to just use if (cpuCount >= sizeof(uintptr_t) * 8) ....

}

// Get affinity mask of the current process
Expand Down
3 changes: 2 additions & 1 deletion src/pal/src/numa/numa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ the processors enabled.
--*/
KAFFINITY GetFullAffinityMask(int cpuCount)
{
return ((KAFFINITY)1 << (cpuCount)) - 1;
_ASSERTE((cpuCount > 0) && (cpuCount <= sizeof(KAFFINITY) * 8));
return (((KAFFINITY)1 << (cpuCount - 1)) << 1) - 1;
}

/*++
Expand Down