Skip to content

Commit cbd672e

Browse files
franksinankayajanvorli
authored andcommitted
GCC compatibility fixes #7 (dotnet#22810)
* Use thread_local for thread local storage on non MSVC targets * Use local copy of visitor rather than function parameter * Remove extra class qualifier * Replace hex number representation in ASM files * Reorder STDAPI and DLLEXPORT * Suppress conversion Suppress warning during hash add casting * Remove anonymous struct src/vm/codeversion.h:112:16: warning: ‘struct NativeCodeVersion::<anonymous union>::SyntheticStorage’ invalid; an anonymous union can only have non-static data members [-fpermissive] struct SyntheticStorage * Remove class declaration Remove extra class declaration * Remove extern C * Add implicit paranthesis src/vm/amd64/virtualcallstubcpu.hpp:735:103: warning: suggest parentheses around ‘-’ in operand of ‘&’ [-Wparentheses] resolveInit.toMiss1 = offsetof(ResolveStub,miss)-(offsetof(ResolveStub,toMiss1)+1) & 0xFF; ^ src/vm/amd64/virtualcallstubcpu.hpp:741:103: warning: suggest parentheses around ‘-’ in operand of ‘&’ [-Wparentheses] resolveInit.toMiss2 = offsetof(ResolveStub,miss)-(offsetof(ResolveStub,toMiss2)+1) & 0xFF; Add parenthesis src/vm/dataimage.cpp:631:55: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses] previousRvaInfo->rva == rvaInfo->rva && previousRvaInfo->size >= rvaInfo->size Add parenthesis src/debug/daccess/daccess.cpp:6871:29: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses] _ASSERTE(peFile == NULL && reflectionModule != NULL || peFile != NULL && reflectionModule == NULL); Add parenthesis src/vm/dataimage.cpp:631:57: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses] (previousRvaInfo->rva == rvaInfo->rva) && (previousRvaInfo->size >= rvaInfo->size) * Initialize member 1 src/ilasm/method.cpp:35:36: warning: operation on ‘((Method*)this)->Method::m_ulColumns[0]’ may be undefined [-Wsequence-point] m_ulColumns[0]=m_ulColumns[0]=0; * Remove unknown compiler option * Abstract DLLEXPORT
1 parent 9901aa1 commit cbd672e

26 files changed

+108
-100
lines changed

src/debug/daccess/daccess.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6868,7 +6868,7 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
68686868
PVOID mdBaseHost = NULL;
68696869
bool isAlternate = false;
68706870

6871-
_ASSERTE(peFile == NULL && reflectionModule != NULL || peFile != NULL && reflectionModule == NULL);
6871+
_ASSERTE((peFile == NULL && reflectionModule != NULL) || (peFile != NULL && reflectionModule == NULL));
68726872
TADDR peFileAddr = (peFile != NULL) ? dac_cast<TADDR>(peFile) : dac_cast<TADDR>(reflectionModule);
68736873

68746874
//
@@ -7507,8 +7507,8 @@ STDAPI CLRDataAccessCreateInstance(ICLRDataTarget * pLegacyTarget,
75077507
// This is the legacy entrypoint to DAC, used by dbgeng/dbghelp (windbg, SOS, watson, etc).
75087508
//
75097509
//----------------------------------------------------------------------------
7510-
DLLEXPORT
75117510
STDAPI
7511+
DLLEXPORT
75127512
CLRDataCreateInstance(REFIID iid,
75137513
ICLRDataTarget * pLegacyTarget,
75147514
void ** iface)

src/debug/daccess/dacdbiimpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ template<class T> void DeleteDbiMemory(T *p)
184184
// Must call Destroy to on interface to free its resources.
185185
//
186186
//---------------------------------------------------------------------------------------
187-
DLLEXPORT
188187
STDAPI
188+
DLLEXPORT
189189
DacDbiInterfaceInstance(
190190
ICorDebugDataTarget * pTarget,
191191
CORDB_ADDRESS baseAddress,

src/debug/daccess/dacdbiimpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515
// Prototype for creation functions
1616

17-
DLLEXPORT
1817
STDAPI
18+
DLLEXPORT
1919
CLRDataCreateInstance(REFIID iid,
2020
ICLRDataTarget * pLegacyTarget,
2121
void ** iface);
2222

23-
DLLEXPORT
2423
STDAPI
24+
DLLEXPORT
2525
DacDbiInterfaceInstance(
2626
ICorDebugDataTarget * pTarget,
2727
CORDB_ADDRESS baseAddress,

src/debug/di/shimpriv.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ class ShimProxyCallback :
216216
///
217217

218218
// Implementation of ICorDebugManagedCallback4::BeforeGarbageCollection
219-
COM_METHOD ShimProxyCallback::BeforeGarbageCollection(ICorDebugProcess* pProcess);
219+
COM_METHOD BeforeGarbageCollection(ICorDebugProcess* pProcess);
220220

221221
// Implementation of ICorDebugManagedCallback4::AfterGarbageCollection
222-
COM_METHOD ShimProxyCallback::AfterGarbageCollection(ICorDebugProcess* pProcess);
222+
COM_METHOD AfterGarbageCollection(ICorDebugProcess* pProcess);
223223

224224
// Implementation of ICorDebugManagedCallback4::DataBreakpoint
225-
COM_METHOD ShimProxyCallback::DataBreakpoint(ICorDebugProcess* pProcess, ICorDebugThread* pThread, BYTE* pContext, ULONG32 contextSize);
225+
COM_METHOD DataBreakpoint(ICorDebugProcess* pProcess, ICorDebugThread* pThread, BYTE* pContext, ULONG32 contextSize);
226226
};
227227

228228

src/dlls/mscoree/unixinterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static void ConvertConfigPropertiesToUnicode(
137137

138138
#if !defined(FEATURE_MERGE_JIT_AND_ENGINE)
139139
// Reference to the global holding the path to the JIT
140-
extern "C" LPCWSTR g_CLRJITPath;
140+
extern LPCWSTR g_CLRJITPath;
141141
#endif // !defined(FEATURE_MERGE_JIT_AND_ENGINE)
142142

143143
#ifdef FEATURE_GDBJIT

src/ilasm/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
5252
# Clang also produces a bad-codegen on this prebuilt file with optimization.
5353
# https://github.com/dotnet/coreclr/issues/2305
5454
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
55-
add_compile_options(-Wno-deprecated-register)
55+
add_compile_options(-Wno-register)
5656
add_compile_options(-Wno-array-bounds)
5757
add_compile_options(-Wno-unused-label)
5858
set_source_files_properties( prebuilt/asmparse.cpp PROPERTIES COMPILE_FLAGS "-O0" )

src/ilasm/method.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Method::Method(Assembler *pAssembler, Class *pClass, __in __nullterminated char
3232
m_szExportAlias = NULL;
3333
m_dwExportOrdinal = 0xFFFFFFFF;
3434
m_ulLines[0]=m_ulLines[1]=0;
35-
m_ulColumns[0]=m_ulColumns[0]=0;
35+
m_ulColumns[0]=m_ulColumns[1]=0;
3636
m_pbsBody = NULL;
3737
m_fNewBody = TRUE;
3838
m_fNew = TRUE;

src/pal/inc/unixasmmacros.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
#define INVALIDGCVALUE 0CCCCCCCDh
5+
#define INVALIDGCVALUE 0xCCCCCCCD
66

77
#if defined(__APPLE__)
88
#define C_FUNC(name) _##name

src/vm/amd64/jithelpers_fast.S

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ LEAF_ENTRY JIT_WriteBarrier, _TEXT
8181
// Update the write watch table if necessary
8282
mov rax, rdi
8383
movabs r10, 0xF0F0F0F0F0F0F0F0
84-
shr rax, 0Ch // SoftwareWriteWatch::AddressToTableByteIndexShift
84+
shr rax, 0xC // SoftwareWriteWatch::AddressToTableByteIndexShift
8585
NOP_2_BYTE // padding for alignment of constant
8686
movabs r11, 0xF0F0F0F0F0F0F0F0
8787
add rax, r10
88-
cmp byte ptr [rax], 0h
88+
cmp byte ptr [rax], 0x0
8989
.byte 0x75, 0x06
9090
// jne CheckCardTable
91-
mov byte ptr [rax], 0FFh
91+
mov byte ptr [rax], 0xFF
9292

9393
NOP_3_BYTE // padding for alignment of constant
9494

@@ -112,27 +112,27 @@ LEAF_ENTRY JIT_WriteBarrier, _TEXT
112112

113113
// Touch the card table entry, if not already dirty.
114114
shr rdi, 0x0B
115-
cmp byte ptr [rdi + rax], 0FFh
115+
cmp byte ptr [rdi + rax], 0xFF
116116
.byte 0x75, 0x02
117117
// jne UpdateCardTable
118118
REPRET
119119

120120
UpdateCardTable:
121-
mov byte ptr [rdi + rax], 0FFh
121+
mov byte ptr [rdi + rax], 0xFF
122122

123123
#ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES
124124
NOP_2_BYTE // padding for alignment of constant
125125
shr rdi, 0x0A
126126

127127
movabs rax, 0xF0F0F0F0F0F0F0F0
128-
cmp byte ptr [rdi + rax], 0FFh
128+
cmp byte ptr [rdi + rax], 0xFF
129129

130130
.byte 0x75, 0x02
131131
// jne UpdateCardBundle_WriteWatch_PostGrow64
132132
REPRET
133133

134134
UpdateCardBundle_WriteWatch_PostGrow64:
135-
mov byte ptr [rdi + rax], 0FFh
135+
mov byte ptr [rdi + rax], 0xFF
136136
#endif
137137

138138
ret
@@ -312,15 +312,15 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
312312
#ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP
313313
// Update the write watch table if necessary
314314
PREPARE_EXTERNAL_VAR g_sw_ww_enabled_for_gc_heap, rax
315-
cmp byte ptr [rax], 0h
315+
cmp byte ptr [rax], 0x0
316316
je CheckCardTable_ByRefWriteBarrier
317317
mov rax, rdi
318-
shr rax, 0Ch // SoftwareWriteWatch::AddressToTableByteIndexShift
318+
shr rax, 0xC // SoftwareWriteWatch::AddressToTableByteIndexShift
319319
PREPARE_EXTERNAL_VAR g_sw_ww_table, r10
320320
add rax, qword ptr [r10]
321-
cmp byte ptr [rax], 0h
321+
cmp byte ptr [rax], 0x0
322322
jne CheckCardTable_ByRefWriteBarrier
323-
mov byte ptr [rax], 0FFh
323+
mov byte ptr [rax], 0xFF
324324
#endif
325325

326326
CheckCardTable_ByRefWriteBarrier:
@@ -334,8 +334,8 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
334334

335335
// move current rdi value into rcx and then increment the pointers
336336
mov rcx, rdi
337-
add rsi, 8h
338-
add rdi, 8h
337+
add rsi, 0x8
338+
add rdi, 0x8
339339

340340
// Check if we need to update the card table
341341
// Calc pCardByte
@@ -345,13 +345,13 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
345345
mov rax, [rax]
346346

347347
// Check if this card is dirty
348-
cmp byte ptr [rcx + rax], 0FFh
348+
cmp byte ptr [rcx + rax], 0xFF
349349

350350
jne UpdateCardTable_ByRefWriteBarrier
351351
REPRET
352352

353353
UpdateCardTable_ByRefWriteBarrier:
354-
mov byte ptr [rcx + rax], 0FFh
354+
mov byte ptr [rcx + rax], 0xFF
355355

356356
#ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES
357357
// Shift rcx by 0x0A more to get the card bundle byte (we shifted by 0x0B already)
@@ -361,13 +361,13 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
361361
add rcx, [rax]
362362

363363
// Check if this bundle byte is dirty
364-
cmp byte ptr [rcx], 0FFh
364+
cmp byte ptr [rcx], 0xFF
365365

366366
jne UpdateCardBundle_ByRefWriteBarrier
367367
REPRET
368368

369369
UpdateCardBundle_ByRefWriteBarrier:
370-
mov byte ptr [rcx], 0FFh
370+
mov byte ptr [rcx], 0xFF
371371
#endif
372372

373373
ret
@@ -383,8 +383,8 @@ LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
383383
#endif
384384
Exit_ByRefWriteBarrier:
385385
// Increment the pointers before leaving
386-
add rdi, 8h
387-
add rsi, 8h
386+
add rdi, 0x8
387+
add rsi, 0x8
388388
ret
389389
LEAF_END_MARKED JIT_ByRefWriteBarrier, _TEXT
390390

0 commit comments

Comments
 (0)