diff --git a/src/gc/unix/gcenv.unix.cpp b/src/gc/unix/gcenv.unix.cpp index e64f62ac34d3..ed09e89f2641 100644 --- a/src/gc/unix/gcenv.unix.cpp +++ b/src/gc/unix/gcenv.unix.cpp @@ -449,7 +449,12 @@ the processors enabled. --*/ static uintptr_t GetFullAffinityMask(int cpuCount) { - return ((uintptr_t)1 << (cpuCount)) - 1; + if (cpuCount < sizeof(uintptr_t) * 8) + { + return ((uintptr_t)1 << cpuCount) - 1; + } + + return ~(uintptr_t)0; } // Get affinity mask of the current process diff --git a/src/pal/src/numa/numa.cpp b/src/pal/src/numa/numa.cpp index 92ec82f7495e..8793a09b8500 100644 --- a/src/pal/src/numa/numa.cpp +++ b/src/pal/src/numa/numa.cpp @@ -166,7 +166,12 @@ the processors enabled. --*/ KAFFINITY GetFullAffinityMask(int cpuCount) { - return ((KAFFINITY)1 << (cpuCount)) - 1; + if (cpuCount < sizeof(KAFFINITY) * 8) + { + return ((KAFFINITY)1 << (cpuCount)) - 1; + } + + return ~(KAFFINITY)0; } /*++