Skip to content

Commit

Permalink
Fix build break from new alignments
Browse files Browse the repository at this point in the history
- MSVC seems to require alignment specification to be on the declaration as well as the definition
- Ignore warning about padding parent struct due to __declspec(align()), as that is intentional

Original change PR: dotnet#6516

[tfs-changeset: 1622589]
  • Loading branch information
kouvel committed Aug 16, 2016
1 parent 68f3852 commit b6be3a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 11 additions & 2 deletions src/vm/threadpoolrequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ typedef DPTR(IPerAppDomainTPCount) PTR_IPerAppDomainTPCount;

static const LONG ADUnloading = -1;

#ifdef _MSC_VER
// Disable this warning - we intentionally want __declspec(align()) to insert padding for us
#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
#endif

//--------------------------------------------------------------------------
//ManagedPerAppDomainTPCount maintains per-appdomain thread pool state.
//This class maintains the count of per-appdomain work-items queued by
Expand Down Expand Up @@ -289,6 +294,10 @@ class UnManagedPerAppDomainTPCount : public IPerAppDomainTPCount {
};
};

#ifdef _MSC_VER
#pragma warning(default: 4324) // structure was padded due to __declspec(align())
#endif

//--------------------------------------------------------------------------
//PerAppDomainTPCountList maintains the collection of per-appdomain thread
//pool states. Per appdomain counts are added to the list during appdomain
Expand Down Expand Up @@ -343,8 +352,8 @@ class PerAppDomainTPCountList{
static DWORD FindFirstFreeTpEntry();

static BYTE s_padding[64 - sizeof(LONG)];
static LONG s_ADHint;
static UnManagedPerAppDomainTPCount s_unmanagedTPCount;
DECLSPEC_ALIGN(64) static LONG s_ADHint;
DECLSPEC_ALIGN(64) static UnManagedPerAppDomainTPCount s_unmanagedTPCount;

//The list of all per-appdomain work-request counts.
static ArrayListStatic s_appDomainIndexList;
Expand Down
14 changes: 7 additions & 7 deletions src/vm/win32threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -1305,11 +1305,11 @@ class ThreadpoolMgr
SVAL_DECL(LONG,MinLimitTotalWorkerThreads); // same as MinLimitTotalCPThreads
SVAL_DECL(LONG,MaxLimitTotalWorkerThreads); // same as MaxLimitTotalCPThreads

static unsigned int LastDequeueTime; // used to determine if work items are getting thread starved
DECLSPEC_ALIGN(64) static unsigned int LastDequeueTime; // used to determine if work items are getting thread starved

static HillClimbing HillClimbingInstance;

static LONG PriorCompletedWorkRequests;
DECLSPEC_ALIGN(64) static LONG PriorCompletedWorkRequests;
static DWORD PriorCompletedWorkRequestsTime;
static DWORD NextCompletedWorkRequestsTime;

Expand All @@ -1335,7 +1335,7 @@ class ThreadpoolMgr
static const DWORD WorkerTimeout = 20 * 1000;
static const DWORD WorkerTimeoutAppX = 5 * 1000; // shorter timeout to allow threads to exit prior to app suspension

SVAL_DECL(ThreadCounter,WorkerCounter);
DECLSPEC_ALIGN(64) SVAL_DECL(ThreadCounter,WorkerCounter);

//
// WorkerSemaphore is an UnfairSemaphore because:
Expand Down Expand Up @@ -1364,7 +1364,7 @@ class ThreadpoolMgr
SVAL_DECL(LIST_ENTRY,TimerQueue); // queue of timers
static HANDLE TimerThread; // Currently we only have one timer thread
static Thread* pTimerThread;
static DWORD LastTickCount; // the count just before timer thread goes to sleep
DECLSPEC_ALIGN(64) static DWORD LastTickCount; // the count just before timer thread goes to sleep

static BOOL InitCompletionPortThreadpool; // flag indicating whether completion port threadpool has been initialized
static HANDLE GlobalCompletionPort; // used for binding io completions on file handles
Expand All @@ -1377,20 +1377,20 @@ class ThreadpoolMgr
SVAL_DECL(LONG,MinLimitTotalCPThreads);
SVAL_DECL(LONG,MaxFreeCPThreads); // = MaxFreeCPThreadsPerCPU * Number of CPUS

static LONG GateThreadStatus; // See GateThreadStatus enumeration
DECLSPEC_ALIGN(64) static LONG GateThreadStatus; // See GateThreadStatus enumeration

static Volatile<LONG> NumCPInfrastructureThreads; // number of threads currently busy handling draining cycle

SVAL_DECL(LONG,cpuUtilization);
static LONG cpuUtilizationAverage;

static RecycledListsWrapper RecycledLists;
DECLSPEC_ALIGN(64) static RecycledListsWrapper RecycledLists;

#ifdef _DEBUG
static DWORD TickCountAdjustment; // add this value to value returned by GetTickCount
#endif

static int offset_counter;
DECLSPEC_ALIGN(64) static int offset_counter;
static const int offset_multiplier = 128;
};

Expand Down

0 comments on commit b6be3a0

Please sign in to comment.