Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 6befc40

Browse files
franksinankayaSinan Kaya
authored and
Sinan Kaya
committed
Abstract away NOINLINE statement
MSVC and GNU compilers use different attributes for noinline. Abstract away compiler differences.
1 parent aa70c0a commit 6befc40

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/inc/staticcontract.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
#define SCAN_WIDEN2(x) L ## x
1616
#define SCAN_WIDEN(x) SCAN_WIDEN2(x)
1717

18+
#ifndef NOINLINE
19+
#if __GNUC__
20+
#define NOINLINE __attribute__((noinline))
21+
#else
22+
#define NOINLINE __declspec(noinline)
23+
#endif
24+
#endif
25+
1826
//
1927
// PDB annotations for the static contract analysis tool. These are seperated
2028
// from Contract.h to allow their inclusion in any part of the system.
@@ -236,7 +244,7 @@ namespace StaticContract
236244
{
237245
struct ScanThrowMarkerStandard
238246
{
239-
__declspec(noinline) ScanThrowMarkerStandard()
247+
NOINLINE ScanThrowMarkerStandard()
240248
{
241249
METHOD_CANNOT_BE_FOLDED_DEBUG;
242250
STATIC_CONTRACT_THROWS;
@@ -251,7 +259,7 @@ namespace StaticContract
251259

252260
struct ScanThrowMarkerTerminal
253261
{
254-
__declspec(noinline) ScanThrowMarkerTerminal()
262+
NOINLINE ScanThrowMarkerTerminal()
255263
{
256264
METHOD_CANNOT_BE_FOLDED_DEBUG;
257265
}
@@ -263,7 +271,7 @@ namespace StaticContract
263271

264272
struct ScanThrowMarkerIgnore
265273
{
266-
__declspec(noinline) ScanThrowMarkerIgnore()
274+
NOINLINE ScanThrowMarkerIgnore()
267275
{
268276
METHOD_CANNOT_BE_FOLDED_DEBUG;
269277
}
@@ -340,21 +348,21 @@ template <UINT COUNT>
340348
class BlockMarker
341349
{
342350
public:
343-
__declspec(noinline) void MarkBlock()
351+
NOINLINE void MarkBlock()
344352
{
345353
ANNOTATION_MARK_BLOCK_ANNOTATION;
346354
METHOD_CANNOT_BE_FOLDED_DEBUG;
347355
return;
348356
}
349357

350-
__declspec(noinline) void UseMarkedBlockAnnotation()
358+
NOINLINE void UseMarkedBlockAnnotation()
351359
{
352360
ANNOTATION_USE_BLOCK_ANNOTATION;
353361
METHOD_CANNOT_BE_FOLDED_DEBUG;
354362
return;
355363
}
356364

357-
__declspec(noinline) void EndUseMarkedBlockAnnotation()
365+
NOINLINE void EndUseMarkedBlockAnnotation()
358366
{
359367
ANNOTATION_END_USE_BLOCK_ANNOTATION;
360368
METHOD_CANNOT_BE_FOLDED_DEBUG;

0 commit comments

Comments
 (0)