Coreclr gnuport (#22129)
authorSinan Kaya <41809318+franksinankaya@users.noreply.github.com>
Fri, 1 Feb 2019 15:27:39 +0000 (10:27 -0500)
committerJan Vorlicek <janvorli@microsoft.com>
Fri, 1 Feb 2019 15:27:39 +0000 (16:27 +0100)
commitfc7a8fbbc1754c8dd49f66f9b59c1ff12a5f842e
treeaebcfe9a9ea0f9381cf1c6ff184f3b96c852a65b
parenta8a05e8c595ae0b9e12333134f38e19acf981be4
Coreclr gnuport (#22129)

* Abstract away NOINLINE statement

MSVC and GNU compilers use different attributes for noinline.
Abstract away compiler differences.

* Replace __sync_swap with __atomic_exchange_n

__sync_swap doesn't exist on GNU. Replacing with __atomic_exchange_n
which is universally available.

* Define CDECL for GNUC

__cdecl is not defined by default on GNU compilers.

* Define gcc version of __declspec(thread)

* Correct pointer casting

A pointer value is usually unsigned long on most platforms.
Casting it to integer causes signedness issues. Use size_t
to be efficient on all 32 and 64 bit architectures.

* Put quotes around the error string

Correct error statement. GNU G++ is picky about the string
following the error statement with ' character in it. It needs
to be enclosed with double quotes.

* Fix casting problem

Seeing these warnings with GNU G++ compiler

src/pal/src/sync/cs.cpp: In function ‘void CorUnix::InternalInitializeCriticalSectionAndSpinCount(PCRITICAL_SECTION, DWORD, bool)’:
src/pal/src/sync/cs.cpp:630:48: warning: converting to non-pointer type ‘SIZE_T {aka long unsigned int}’ from NULL [-Wconversion-null]
         pPalCriticalSection->OwningThread      = NULL;
                                                ^
src/pal/src/sync/cs.cpp: In function ‘void CorUnix::InternalLeaveCriticalSection(CorUnix::CPalThread*, _CRITICAL_SECTION*)’:
src/pal/src/sync/cs.cpp:880:43: warning: converting to non-pointer type ‘SIZE_T {aka long unsigned int}’ from NULL [-Wconversion-null]
         pPalCriticalSection->OwningThread = NULL;
                                           ^

* Abstract optnone compiler attribute

GNU compiler doesn't support optnone attribute.

pal/src/exception/seh-unwind.cpp:449:77: warning: ‘optnone’ attribute directive ignored [-Wattributes]

* Set the aligned attribute for GNU compiler

* Make __rotl and __rotr functions portable

GNU compiler doesn't have an intrinsic for these. Open code them
using the provided implementation.

* Define deprecated attribute for gcc

* Add throw specifier for GCC

/usr/include/string.h:43:28: error: declaration of ‘void* memcpy(void*, const void*, size_t) throw ()’ has a different exception specifier
        size_t __n) __THROW __nonnull ((1, 2));
15 files changed:
src/inc/palclr.h
src/inc/staticcontract.h
src/pal/inc/mbusafecrt.h
src/pal/inc/pal.h
src/pal/inc/rt/safecrt.h
src/pal/src/exception/seh-unwind.cpp
src/pal/src/exception/seh.cpp
src/pal/src/include/pal/context.h
src/pal/src/init/pal.cpp
src/pal/src/locale/utf8.cpp
src/pal/src/safecrt/memcpy_s.cpp
src/pal/src/sync/cs.cpp
src/pal/src/thread/context.cpp
src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest1.cpp
src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest2.cpp