More GNUC Fixes (#22687)
authorSinan Kaya <41809318+franksinankaya@users.noreply.github.com>
Fri, 22 Feb 2019 19:11:19 +0000 (14:11 -0500)
committerJan Vorlicek <janvorli@microsoft.com>
Fri, 22 Feb 2019 19:11:19 +0000 (20:11 +0100)
* Replace __sync_swap with __atomic_exchange_n

__sync_swap() is a clang specific function.

* Remove multiline comment

* Add paranthesis around sum

src/md/hotdata/../inc/streamutil.h:73:34: warning: suggest parentheses around ‘+’ in operand of ‘&’ [-Wparentheses]
     UINT32 aligned = *totalBytes + 3 & ~3;

* Define __int64

* Define windows types for tests

* Remove undefined has_builtin defines and define alloca and inline for GNUC

* Remove __clang__ where possible

* Add implicit casting to help compiler find WCHAR* variant

src/binder/assembly.cpp:294:73: error: no matching function for call to ‘SString::SString(SString)’
         return (pAsmName == nullptr ? nullptr : pAsmName->GetSimpleName());
                                                                         ^
In file included from src/inc/sstring.h:1082:0,
                 from src/inc/ex.h:19,
                 from src/inc/stgpool.h:28,
                 from src/inc/../md/inc/metamodel.h:18,
                 from src/inc/../md/inc/metamodelro.h:19,
                 from src/inc/metadata.h:17,
                 from src/binder/../vm/util.hpp:19,
                 from src/binder/../vm/common.h:110,
                 from src/binder/assembly.cpp:14:
src/inc/sstring.inl:73:8: note: candidate: SString::SString(void*, COUNT_T)
 inline SString::SString(void *buffer, COUNT_T size)
        ^
src/inc/sstring.inl:73:8: note:   candidate expects 2 arguments, 1 provided
src/inc/sstring.inl:436:8: note: candidate: SString::SString(SString::tagLiteral, const WCHAR*, COUNT_T)
 inline SString::SString(tagLiteral dummytag, const WCHAR *literal, COUNT_T count)
        ^
src/inc/sstring.inl:436:8: note:   candidate expects 3 arguments, 1 provided
src/inc/sstring.inl:418:8: note: candidate: SString::SString(SString::tagLiteral, const WCHAR*)
 inline SString::SString(tagLiteral dummytag, const WCHAR *literal)
        ^
src/inc/sstring.inl:418:8: note:   candidate expects 2 arguments, 1 provided
src/inc/sstring.inl:401:8: note: candidate: SString::SString(SString::tagUTF8Literal, const UTF8*)
 inline SString::SString(tagUTF8Literal dummytag, const UTF8 *literal)
        ^
src/inc/sstring.inl:401:8: note:   candidate expects 2 arguments, 1 provided
src/inc/sstring.inl:382:8: note: candidate: SString::SString(SString::tagLiteral, const CHAR*)
 inline SString::SString(tagLiteral dummytag, const ASCII *literal)

* Reorder DLLEXPORT and STDAPI

GNUC wants extern "C" <attribute> format.

* Abstract __FUNCSIG__

* Abstract __debugbreak()

* Move common compiler options out of clang and add Wno-unused-value

* Add paranthesis around || and &&

src/gc/gc.cpp:9084:38: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
                     (!chosen_power2) && (i < free_space_count));

* Set Wno-delete-non-virtual-dtor for CXX files only

* Don't warn on unterminated endif labels

* Suppress unused functions

* Use 0x syntax rather than h syntax on GNU asm files

* Correct constructor call directly

src/ToolBox/superpmi/superpmi-shared/logging.cpp:301:27:   required from here
src/inc/clr_std/string:58:9: error: cannot call constructor ‘std::basic_string<char>::basic_string’ directly
         this->basic_string::basic_string(_Ptr, c_len(_Ptr));

* Suppress NULL used in arithmetic warnings

37 files changed:
configurecompiler.cmake
src/ToolBox/SOS/Strike/CMakeLists.txt
src/ToolBox/SOS/lldbplugin/CMakeLists.txt
src/ToolBox/superpmi/superpmi-shared/standardpch.h
src/binder/assembly.cpp
src/debug/daccess/daccess.cpp
src/debug/daccess/nidump.cpp
src/debug/ee/amd64/dbghelpers.S
src/dlls/mscordbi/mscordbi.cpp
src/dlls/mscoree/mscoree.cpp
src/dlls/mscorpe/CMakeLists.txt
src/gc/env/gcenv.base.h
src/gc/env/gcenv.interlocked.inl
src/gc/gc.cpp
src/gc/gcpriv.h
src/ilasm/CMakeLists.txt
src/inc/CMakeLists.txt
src/inc/clr_std/string
src/jit/compiler.cpp
src/jit/jit.h
src/md/inc/streamutil.h
src/unwinder/arm64/unwinder_arm64.cpp
src/vm/rejit.inl
tests/src/Common/Platform/platformdefines.h
tests/src/Interop/ArrayMarshalling/ByValArray/MarshalArrayByValNative.cpp
tests/src/Interop/PInvoke/Array/MarshalArray.h
tests/src/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/MarshalArrayByValArrayNative.cpp
tests/src/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/MarshalArrayLPArrayNative.cpp
tests/src/JIT/Directed/StructABI/StructABI.c
tests/src/JIT/Directed/arglist/varargnative.c
tests/src/JIT/Directed/pinning/object-pin/mirror.cpp
tests/src/JIT/Methodical/structs/systemvbringup/structinregs.cpp
tests/src/JIT/SIMD/Vector3TestNative.cpp
tests/src/JIT/jit64/hfa/main/dll/hfa_native.cpp
tests/src/JIT/jit64/hfa/main/dll/hfa_native.h
tests/src/JIT/jit64/mcc/interop/native.h
tests/src/Loader/NativeLibs/FromNativePaths_lib.cpp

index f5eb063..d9b2a66 100644 (file)
@@ -446,6 +446,14 @@ if (CLR_CMAKE_PLATFORM_UNIX)
     add_compile_options(-Werror)
   endif(CLR_CMAKE_WARNINGS_ARE_ERRORS)
 
+  # Disabled common warnings
+  add_compile_options(-Wno-unused-variable)
+  add_compile_options(-Wno-unused-value)
+  add_compile_options(-Wno-unused-function)
+
+  #These seem to indicate real issues
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
+
   if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
     # The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop
     # after hitting just about 20 errors.
@@ -453,7 +461,6 @@ if (CLR_CMAKE_PLATFORM_UNIX)
 
     # Disabled warnings
     add_compile_options(-Wno-unused-private-field)
-    add_compile_options(-Wno-unused-variable)
     # Explicit constructor calls are not supported by clang (this->ClassName::ClassName())
     add_compile_options(-Wno-microsoft)
     # This warning is caused by comparing 'this' to NULL
@@ -468,8 +475,6 @@ if (CLR_CMAKE_PLATFORM_UNIX)
 
     add_compile_options(-Wno-unknown-warning-option)
 
-    #These seem to indicate real issues
-    add_compile_options(-Wno-invalid-offsetof)
     # The following warning indicates that an attribute __attribute__((__ms_struct__)) was applied
     # to a struct or a class that has virtual members or a base class. In that case, clang
     # may not generate the same object layout as MSVC.
index e1673bc..a4fe91c 100644 (file)
@@ -106,7 +106,12 @@ if(WIN32)
   )
 else(WIN32)
   add_definitions(-DPAL_STDCPP_COMPAT=1)
-  add_compile_options(-Wno-null-arithmetic)
+  if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+    add_compile_options(-Wno-null-arithmetic)
+  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion-null")
+    add_compile_options(-Wno-pointer-arith)
+  endif()
   add_compile_options(-Wno-format)
 
   include_directories(BEFORE xplat)
index 1aeab14..0e4d40a 100644 (file)
@@ -124,7 +124,7 @@ endif()
 
 message(STATUS "LLDB_H: ${LLDB_H}")
 
-add_compile_options(-Wno-delete-non-virtual-dtor)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
 
 include_directories(inc)
 include_directories("${LLDB_H}")
index 08eb603..65a4f32 100644 (file)
 
 #define DEFAULT_REAL_JIT_NAME_A MAKEDLLNAME_A("clrjit2")
 #define DEFAULT_REAL_JIT_NAME_W MAKEDLLNAME_W("clrjit2")
+
+#if !defined(_MSC_VER) && !defined(__llvm__)
+static inline void __debugbreak()
+{
+  DebugBreak();
+}
+#endif
+
index 7f7ab26..9649233 100644 (file)
@@ -291,7 +291,7 @@ Exit:
     LPCWSTR Assembly::GetSimpleName() 
     {
         AssemblyName *pAsmName = GetAssemblyName();
-        return (pAsmName == nullptr ? nullptr : pAsmName->GetSimpleName());
+        return (pAsmName == nullptr ? nullptr : (LPCWSTR)pAsmName->GetSimpleName());
     }
 
     HRESULT Assembly::BindAssemblyByName(IAssemblyName * pIAssemblyName, ICLRPrivAssembly ** ppAssembly)
index 9b2b3ad..5ebbe31 100644 (file)
@@ -40,10 +40,11 @@ HINSTANCE g_thisModule;
 
 extern VOID STDMETHODCALLTYPE TLS_FreeMasterSlotIndex();
 
+EXTERN_C
 #ifdef FEATURE_PAL
 DLLEXPORT // For Win32 PAL LoadLibrary emulation
 #endif
-EXTERN_C BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
+BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
 {
     static bool g_procInitialized = false;
 
index e61c61d..37de104 100644 (file)
@@ -447,7 +447,7 @@ static OptionDependencies g_dependencies[] =
 // 
 
 // This function gets the Dispenser interface given the CLSID and REFIID.
-DLLEXPORT STDAPI MetaDataGetDispenser(
+STDAPI DLLEXPORT MetaDataGetDispenser(
     REFCLSID     rclsid,    // The class to desired.
     REFIID       riid,      // Interface wanted on class factory.
     LPVOID FAR * ppv)       // Return interface pointer here.
index 85ec80c..864c4dc 100644 (file)
@@ -29,7 +29,7 @@ NESTED_ENTRY FuncEvalHijack, _TEXT, UnhandledExceptionHandlerUnix
         //
         // epilogue
         //
-        add     rsp, 20h
+        add     rsp, 0x20
         TAILJMP_RAX
 NESTED_END FuncEvalHijack, _TEXT
 
@@ -65,14 +65,14 @@ NESTED_ENTRY ExceptionHijack, _TEXT, UnhandledExceptionHandlerUnix
         // its arguments on the stack. In x64, it gets its arguments in
         // registers (set up for us by DacDbiInterfaceImpl::Hijack),
         // and this stack space may be reused.
-        mov     rax, [rsp + 20h]
+        mov     rax, [rsp + 0x20]
         mov     [rsp], rax
-        mov     rax, [rsp + 28h]
-        mov     [rsp + 8h], rax
-        mov     rax, [rsp + 30h]
-        mov     [rsp + 10h], rax
-        mov     rax, [rsp + 38h]
-        mov     [rsp + 18h], rax
+        mov     rax, [rsp + 0x28]
+        mov     [rsp + 0x8], rax
+        mov     rax, [rsp + 0x30]
+        mov     [rsp + 0x10], rax
+        mov     rax, [rsp + 0x38]
+        mov     [rsp + 0x18], rax
         
         // DD Hijack primitive already set the stack. So just make the call now.
         call    C_FUNC(ExceptionHijackWorker)
@@ -93,7 +93,7 @@ NESTED_ENTRY ExceptionHijack, _TEXT, UnhandledExceptionHandlerUnix
         //
         // epilogue
         //
-        add     rsp, 20h
+        add     rsp, 0x20
         TAILJMP_RAX
 
 // Put a label here to tell the debugger where the end of this function is.
index 7173e73..a44679b 100644 (file)
@@ -18,10 +18,11 @@ extern BOOL WINAPI DbgDllMain(HINSTANCE hInstance, DWORD dwReason,
 // The main dll entry point for this module.  This routine is called by the
 // OS when the dll gets loaded.  Control is simply deferred to the main code.
 //*****************************************************************************
+extern "C"
 #ifdef FEATURE_PAL
 DLLEXPORT // For Win32 PAL LoadLibrary emulation
 #endif
-extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 {
        // Defer to the main debugging code.
     return DbgDllMain(hInstance, dwReason, lpReserved);
index 45298c5..d1c8a76 100644 (file)
@@ -62,10 +62,11 @@ extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserv
 // we need to capture coreclr's hInstance before the C runtime initializes. This function
 // will capture hInstance, let the C runtime initialize and then invoke the "classic"
 // DllMain that initializes everything else.
+extern "C"
 #ifdef FEATURE_PAL
 DLLEXPORT // For Win32 PAL LoadLibrary emulation
 #endif
-extern "C" BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
+BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
 {
     STATIC_CONTRACT_NOTHROW;
 
@@ -118,10 +119,11 @@ extern "C" BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpRe
     return result;
 }
 
+extern "C"
 #ifdef FEATURE_PAL
 DLLEXPORT // For Win32 PAL LoadLibrary emulation
 #endif
-extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
+BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
 {
     STATIC_CONTRACT_NOTHROW;
 
@@ -226,7 +228,7 @@ HINSTANCE GetModuleInst()
 // %%Function: MetaDataGetDispenser
 // This function gets the Dispenser interface given the CLSID and REFIID.
 // ---------------------------------------------------------------------------
-DLLEXPORT STDAPI MetaDataGetDispenser(            // Return HRESULT
+STDAPI DLLEXPORT MetaDataGetDispenser(            // Return HRESULT
     REFCLSID    rclsid,                 // The class to desired.
     REFIID      riid,                   // Interface wanted on class factory.
     LPVOID FAR  *ppv)                   // Return interface pointer here.
@@ -256,7 +258,7 @@ ErrExit:
 // %%Function: GetMetaDataInternalInterface
 // This function gets the IMDInternalImport given the metadata on memory.
 // ---------------------------------------------------------------------------
-DLLEXPORT STDAPI  GetMetaDataInternalInterface(
+STDAPI DLLEXPORT GetMetaDataInternalInterface(
     LPVOID      pData,                  // [IN] in memory metadata section
     ULONG       cbData,                 // [IN] size of the metadata section
     DWORD       flags,                  // [IN] MDInternal_OpenForRead or MDInternal_OpenForENC
@@ -285,7 +287,7 @@ DLLEXPORT STDAPI  GetMetaDataInternalInterface(
 // This function gets the internal scopeless interface given the public
 // scopeless interface.
 // ---------------------------------------------------------------------------
-DLLEXPORT STDAPI  GetMetaDataInternalInterfaceFromPublic(
+STDAPI DLLEXPORT GetMetaDataInternalInterfaceFromPublic(
     IUnknown    *pv,                    // [IN] Given interface.
     REFIID      riid,                   // [IN] desired interface
     void        **ppv)                  // [OUT] returned interface
@@ -312,7 +314,7 @@ DLLEXPORT STDAPI  GetMetaDataInternalInterfaceFromPublic(
 // This function gets the public scopeless interface given the internal
 // scopeless interface.
 // ---------------------------------------------------------------------------
-DLLEXPORT STDAPI  GetMetaDataPublicInterfaceFromInternal(
+STDAPI DLLEXPORT GetMetaDataPublicInterfaceFromInternal(
     void        *pv,                    // [IN] Given interface.
     REFIID      riid,                   // [IN] desired interface.
     void        **ppv)                  // [OUT] returned interface
index fd884b1..2e91a02 100644 (file)
@@ -11,7 +11,7 @@ set(MSCORPE_SOURCES
 
 if(WIN32)
 else()
-  add_compile_options(-Wno-delete-non-virtual-dtor)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
 endif(WIN32)
 
 add_library_clr(mscorpe STATIC
index 351f4f3..e99149e 100644 (file)
 #define REDHAWK_PALIMPORT extern "C"
 #define REDHAWK_PALAPI __stdcall
 
+#if !defined(_MSC_VER)
+#define _alloca alloca
+#endif //_MSC_VER
+
 #ifndef _MSC_VER
 #define __stdcall
-#ifdef __clang__
+#ifdef __GNUC__
 #define __forceinline __attribute__((always_inline)) inline
-#else // __clang__
+#else // __GNUC__
 #define __forceinline inline
-#endif // __clang__
+#endif // __GNUC__
 // [LOCALGC TODO] is there a better place for this?
 #define NOINLINE __attribute__((noinline))
 #else // !_MSC_VER
@@ -178,18 +182,26 @@ typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter);
  #endif
 #else // _MSC_VER
 
+#ifdef __llvm__
+#define HAS_IA32_PAUSE __has_builtin(__builtin_ia32_pause)
+#define HAS_IA32_MFENCE __has_builtin(__builtin_ia32_mfence)
+#else
+#define HAS_IA32_PAUSE 0
+#define HAS_IA32_MFENCE 0
+#endif
+
 // Only clang defines __has_builtin, so we first test for a GCC define
 // before using __has_builtin.
 
 #if defined(__i386__) || defined(__x86_64__)
 
-#if (__GNUC__ > 4 && __GNUC_MINOR > 7) || __has_builtin(__builtin_ia32_pause)
+#if (__GNUC__ > 4 && __GNUC_MINOR > 7) || HAS_IA32_PAUSE
  // clang added this intrinsic in 3.8
  // gcc added this intrinsic by 4.7.1
  #define YieldProcessor __builtin_ia32_pause
 #endif // __has_builtin(__builtin_ia32_pause)
 
-#if defined(__GNUC__) || __has_builtin(__builtin_ia32_mfence)
+#if defined(__GNUC__) || HAS_IA32_MFENCE
  // clang has had this intrinsic since at least 3.0
  // gcc has had this intrinsic since forever
  #define MemoryBarrier __builtin_ia32_mfence
@@ -455,7 +467,13 @@ typedef DPTR(uint8_t)   PTR_uint8_t;
 
 #define DATA_ALIGNMENT sizeof(uintptr_t)
 #define RAW_KEYWORD(x) x
+
+#ifdef _MSC_VER
 #define DECLSPEC_ALIGN(x)   __declspec(align(x))
+#else
+#define DECLSPEC_ALIGN(x)   __attribute__((aligned(x)))
+#endif
+
 #ifndef _ASSERTE
 #define _ASSERTE(_expr) ASSERT(_expr)
 #endif
index 3eaaa3a..1df2700 100644 (file)
@@ -70,7 +70,7 @@ __forceinline T Interlocked::Exchange(T volatile *destination, T value)
     static_assert(sizeof(long) == sizeof(T), "Size of long must be the same as size of T");
     return _InterlockedExchange((long*)destination, value);
 #else
-    T result = __sync_swap(destination, value);
+    T result = __atomic_exchange_n(destination, value, __ATOMIC_ACQ_REL);
     ArmInterlockedOperationBarrier();
     return result;
 #endif
@@ -164,7 +164,7 @@ __forceinline T Interlocked::ExchangePointer(T volatile * destination, T value)
     return (T)(TADDR)_InterlockedExchange((long volatile *)(void* volatile *)destination, (long)(void*)value);
 #endif
 #else
-    T result = (T)(TADDR)__sync_swap((void* volatile *)destination, value);
+    T result = (T)(TADDR)__atomic_exchange_n((void* volatile *)destination, value, __ATOMIC_ACQ_REL);
     ArmInterlockedOperationBarrier();
     return result;
 #endif
@@ -180,7 +180,7 @@ __forceinline T Interlocked::ExchangePointer(T volatile * destination, std::null
     return (T)(TADDR)_InterlockedExchange((long volatile *)(void* volatile *)destination, (long)(void*)value);
 #endif
 #else
-    T result = (T)(TADDR)__sync_swap((void* volatile *)destination, value);
+    T result = (T)(TADDR)__atomic_exchange_n((void* volatile *)destination, value, __ATOMIC_ACQ_REL);
     ArmInterlockedOperationBarrier();
     return result;
 #endif
index 01f51c2..d7f8d6d 100644 (file)
@@ -5020,7 +5020,7 @@ extern "C" uint64_t __rdtsc();
     {
         return (ptrdiff_t)__rdtsc();
     }
-#elif defined(__clang__)    
+#elif defined(__GNUC__)
     static ptrdiff_t get_cycle_count()
     {
         ptrdiff_t cycles;
@@ -9081,7 +9081,7 @@ retry:
                 new_address += pad;
             }
             assert ((chosen_power2 && (i == 0)) ||
-                    (!chosen_power2) && (i < free_space_count));
+                    ((!chosen_power2) && (i < free_space_count)));
         }
 
         int new_bucket_power2 = index_of_highest_set_bit (new_free_space_size);
index 18785d5..8a7dfdf 100644 (file)
 #pragma optimize( "t", on )
 #endif
 #endif
+
+#ifdef __GNUC__
+#define inline __attribute__((always_inline)) inline
+#else
 #define inline __forceinline
+#endif // __GNUC__
 
 #include "gc.h"
 
index e67267a..f6852e6 100644 (file)
@@ -51,7 +51,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
   # Need generate a right form of asmparse.cpp to avoid the following options.
   # Clang also produces a bad-codegen on this prebuilt file with optimization.
   # https://github.com/dotnet/coreclr/issues/2305
-  add_compile_options(-Wno-delete-non-virtual-dtor)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
   add_compile_options(-Wno-deprecated-register)
   add_compile_options(-Wno-array-bounds)
   add_compile_options(-Wno-unused-label)
index c109c2f..c54b4f0 100644 (file)
@@ -50,7 +50,12 @@ else()
 
 # The prebuilt files contain extra '!_MIDL_USE_GUIDDEF_' after the #endif, but not in the comment.
 # In order to not to have to modify these prebuilt files, we disable the extra tokens warning.
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
 add_compile_options(-Wno-extra-tokens)
+elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+add_compile_options(-Wno-endif-labels)
+endif()
+
 add_compile_options(-D_MIDL_USE_GUIDDEF_)
 foreach(IDL_SOURCE IN LISTS CORGUIDS_IDL_SOURCES)
    get_filename_component(IDLNAME ${IDL_SOURCE} NAME_WE)
index 78a3d1b..66f219c 100644 (file)
@@ -53,9 +53,8 @@ public:
         copy(_Ptr, _Count);
     }
 
-    basic_string(const value_type* _Ptr)
+    basic_string(const value_type* _Ptr) : basic_string(_Ptr, c_len(_Ptr))
     {
-        this->basic_string::basic_string(_Ptr, c_len(_Ptr));
     }
 
     void reserve(size_t newcapacity)
index 691f35b..cef3083 100644 (file)
@@ -76,7 +76,7 @@ inline bool _our_GetThreadCycles(unsigned __int64* cycleOut)
     return true;
 }
 
-#elif defined(__clang__)
+#elif defined(__GNUC__)
 
 inline bool _our_GetThreadCycles(unsigned __int64* cycleOut)
 {
@@ -86,7 +86,7 @@ inline bool _our_GetThreadCycles(unsigned __int64* cycleOut)
     return true;
 }
 
-#else // neither _MSC_VER nor __clang__
+#else // neither _MSC_VER nor __GNUC__
 
 // The following *might* work - might as well try.
 #define _our_GetThreadCycles(cp) GetThreadCycles(cp)
index f5f96b4..5cdb1fd 100644 (file)
@@ -503,7 +503,7 @@ typedef ptrdiff_t ssize_t;
 #if !defined(_HOST_X86_) && !defined(_HOST_AMD64_)
 #define MEASURE_CLRAPI_CALLS 0 // Cycle counters only hooked up on x86/x64.
 #endif
-#if !defined(_MSC_VER) && !defined(__clang__)
+#if !defined(_MSC_VER) && !defined(__GNUC__)
 #define MEASURE_CLRAPI_CALLS 0 // Only know how to do this with VC and Clang.
 #endif
 
index 89c4934..55ff635 100644 (file)
@@ -70,7 +70,7 @@ HRESULT AlignDWORD( IStream * strm, UINT32 * totalBytes )
 {
     HRESULT hr = S_OK;
 
-    UINT32 aligned = *totalBytes + 3 & ~3;
+    UINT32 aligned = (*totalBytes + 3) & ~3;
     if (aligned > *totalBytes)
     {   // The *totalBytes were not aligned to DWORD, we need to add padding
         DWORD data = 0;
index 4c63815..873ddf1 100644 (file)
@@ -235,7 +235,7 @@ Return Value:
         SourceAddress = StartingSp + FIELD_OFFSET(ARM64_KTRAP_FRAME, X);
         for (RegIndex = 0; RegIndex < 18; RegIndex++) {
             UPDATE_CONTEXT_POINTERS(UnwindParams, RegIndex, SourceAddress);
-#ifdef __clang__
+#ifdef __GNUC__
             *(&ContextRecord->X0 + RegIndex) = MEMORY_READ_QWORD(UnwindParams, SourceAddress);
 #else
             ContextRecord->X[RegIndex] = MEMORY_READ_QWORD(UnwindParams, SourceAddress);
@@ -315,7 +315,7 @@ Return Value:
         SourceAddress = StartingSp + FIELD_OFFSET(T_CONTEXT, X0);
         for (RegIndex = 0; RegIndex < 29; RegIndex++) {
             UPDATE_CONTEXT_POINTERS(UnwindParams, RegIndex, SourceAddress);
-#ifdef __clang__
+#ifdef __GNUC__
             *(&ContextRecord->X0 + RegIndex) = MEMORY_READ_QWORD(UnwindParams, SourceAddress);
 #else
             ContextRecord->X[RegIndex] = MEMORY_READ_QWORD(UnwindParams, SourceAddress);
@@ -501,7 +501,7 @@ Return Value:
 
     for (RegIndex = 0; RegIndex < RegisterCount; RegIndex++) {
         UPDATE_CONTEXT_POINTERS(UnwindParams, FirstRegister + RegIndex, CurAddress);
-#ifdef __clang__
+#ifdef __GNUC__
         *(&ContextRecord->X0 + FirstRegister + RegIndex) = MEMORY_READ_QWORD(UnwindParams, CurAddress);
 #else
         ContextRecord->X[FirstRegister + RegIndex] = MEMORY_READ_QWORD(UnwindParams, CurAddress);
index 96cefc6..d26d9e4 100644 (file)
@@ -6,7 +6,7 @@
 //
 
 // 
-// Inline definitions of various items declared in REJIT.H\
+// Inline definitions of various items declared in REJIT.H
 // ===========================================================================
 #ifndef _REJIT_INL_
 #define _REJIT_INL_
index fe37ec1..0c2008b 100644 (file)
@@ -78,6 +78,13 @@ typedef unsigned int ULONG, *PULONG;
 #define _HRESULT_TYPEDEF_(_sc) ((HRESULT)_sc)
 #endif // RC_INVOKED
 #define E_INVALIDARG                     _HRESULT_TYPEDEF_(0x80070057L)
+
+#ifdef BIT64
+#define __int64     long
+#else // BIT64
+#define __int64     long long
+#endif // BIT64
+
 #define UInt32x32To64(a, b) ((unsigned __int64)((ULONG)(a)) * (unsigned __int64)((ULONG)(b)))
 
 #define ARRAYSIZE(x) (sizeof(x)/sizeof(*x))
index 86d726e..b80e4ca 100644 (file)
@@ -34,6 +34,12 @@ macro definition
 
 #define EQUALS(__actual, __cActual, __expected) Equals((__actual), (__cActual), (__expected), (int)sizeof(__expected) / sizeof(__expected[0]))
 
+#if defined(_MSC_VER)
+#define FUNCTIONNAME __FUNCSIG__
+#else
+#define FUNCTIONNAME __PRETTY_FUNCTION__
+#endif //_MSC_VER
+
 /*----------------------------------------------------------------------------
 struct definition
 ----------------------------------------------------------------------------*/
@@ -99,7 +105,7 @@ BOOL Equals(T *pActual, int cActual, T *pExpected, int cExpected)
         return TRUE;
     else if ( cActual != cExpected )
     {
-        printf("WARNING: Test error - %s\n", __FUNCSIG__);        
+        printf("WARNING: Test error - %s\n", FUNCTIONNAME);
         return FALSE;
     }
 
@@ -107,7 +113,7 @@ BOOL Equals(T *pActual, int cActual, T *pExpected, int cExpected)
     {
         if ( !IsObjectEquals(pActual[i], pExpected[i]) )
         {
-            printf("WARNING: Test error - %s\n", __FUNCSIG__);            
+            printf("WARNING: Test error - %s\n", FUNCTIONNAME);
             return FALSE;
         }
     }
@@ -168,7 +174,7 @@ bool TestStructEquals(TestStruct Actual[], TestStruct Expected[])
             IsObjectEquals(Actual[i].l, Expected[i].l) &&
             IsObjectEquals(Actual[i].str, Expected[i].str) ))
         {
-            printf("WARNING: Test error - %s\n", __FUNCSIG__);
+            printf("WARNING: Test error - %s\n", FUNCTIONNAME);
             return false;
         }
     }
index c3d027e..00db79e 100644 (file)
     return false; \
     }
 
+#if defined(_MSC_VER)
+#define FUNCTIONNAME __FUNCSIG__
+#else
+#define FUNCTIONNAME __PRETTY_FUNCTION__
+#endif //_MSC_VER
+
 #define VERIFY_ERROR(__expect, __actual) \
-    std::cout << '[' << __FUNCSIG__ << "] EXPECT: " << (__expect) << ", ACTUAL: " << (__actual) << std::endl
+    std::cout << '[' << FUNCTIONNAME << "] EXPECT: " << (__expect) << ", ACTUAL: " << (__actual) << std::endl
 
 #define TRACE(__msg) \
     std::cout << __msg << std::endl
 
 #define VERIFY_ERROR_MSG(__msg, __expect, __actual) \
-    printf("["##__FUNCSIG__##"] "##__msg, (__expect), (__actual))
+    printf("["##FUNCTIONNAME##"] "##__msg, (__expect), (__actual))
 
 //////////////////////////////////////////////////////////////////////////////
 // Verify helper methods
index a0fcb5a..c24b465 100644 (file)
@@ -24,6 +24,13 @@ macro definition
 
 #define EQUALS(__actual, __cActual, __expected) Equals((__actual), (__cActual), (__expected), (int)sizeof(__expected) / sizeof(__expected[0]))
 
+#if defined(_MSC_VER)
+#define FUNCTIONNAME __FUNCSIG__
+#else
+#define FUNCTIONNAME __PRETTY_FUNCTION__
+#endif //_MSC_VER
+
+
 /*----------------------------------------------------------------------------
 struct definition
 ----------------------------------------------------------------------------*/
@@ -91,7 +98,7 @@ BOOL Equals(T *pActual, int cActual, T *pExpected, int cExpected)
         return TRUE;
     else if ( cActual != cExpected )
     {
-        printf("WARNING: Test error - %s\n", __FUNCSIG__);
+        printf("WARNING: Test error - %s\n", FUNCTIONNAME);
         printf("Array Length: expected: %d, actual: %d\n", cExpected, cActual);
         return FALSE;
     }
@@ -100,7 +107,7 @@ BOOL Equals(T *pActual, int cActual, T *pExpected, int cExpected)
     {
         if ( !IsObjectEquals(pActual[i], pExpected[i]) )
         {
-            printf("WARNING: Test error - %s\n", __FUNCSIG__);
+            printf("WARNING: Test error - %s\n", FUNCTIONNAME);
             printf("Array Element Not Equal: index: %d", static_cast<int>(i));
             return FALSE;
         }
@@ -125,7 +132,7 @@ bool TestStructEquals(TestStruct Actual[], TestStruct Expected[])
             IsObjectEquals(Actual[i].l, Expected[i].l) &&
             IsObjectEquals(Actual[i].str, Expected[i].str) ))
         {
-            printf("WARNING: Test error - %s\n", __FUNCSIG__);
+            printf("WARNING: Test error - %s\n", FUNCTIONNAME);
             return false;
         }
     }
index dc42224..fea447c 100644 (file)
@@ -5,6 +5,12 @@
 #include <xplatform.h>
 #include "MarshalArray.h"
 
+#if defined(_MSC_VER)
+#define FUNCTIONNAME __FUNCSIG__
+#else
+#define FUNCTIONNAME __PRETTY_FUNCTION__
+#endif //_MSC_VER
+
 template<typename T>
 bool Equals(T *pActual, int cActual, T *pExpected, int cExpected)
 {
@@ -21,7 +27,7 @@ bool Equals(T *pActual, int cActual, T *pExpected, int cExpected)
     {
         if (!IsObjectEquals(pActual[i], pExpected[i]))
         {
-            printf("WARNING: Test error - %s\n", __FUNCSIG__);
+            printf("WARNING: Test error - %s\n", FUNCTIONNAME);
             return false;
         }
     }
index 09cd14d..f56eaf2 100644 (file)
@@ -7,6 +7,16 @@
 #define DLLEXPORT __declspec(dllexport)
 #else
 #define DLLEXPORT __attribute__((visibility("default")))
+#ifdef BIT64
+#define __int64     long
+#else // BIT64
+#define __int64     long long
+#endif // BIT64
+
+#define __int32     int
+#define __int16     short int
+#define __int8      char        // assumes char is signed
+
 #endif // _MSC_VER
 
 struct SingleByte
index b0e1941..54a778f 100644 (file)
 #define _cdecl
 #endif
 
-#endif // _MSC_VER
+#define __int32     int
+#define __int16     short int
+#define __int8      char        // assumes char is signed
+
+#ifdef BIT64
+#define __int64     long
+#else // BIT64
+#define __int64     long long
+#endif // BIT64
+
+#endif // !_MSC_VER
 
 /* Structures */
 
index f5c4c4b..268fb26 100644 (file)
@@ -2,6 +2,17 @@
 #define EXPORT_API extern "C" __declspec(dllexport)
 #else
 #define EXPORT_API extern "C" __attribute__((visibility("default")))
+
+#ifdef BIT64
+#define __int64     long
+#else // BIT64
+#define __int64     long long
+#endif // BIT64
+
+#define __int32     int
+#define __int16     short int
+#define __int8      char        // assumes char is signed
+
 #endif 
 
 #include <cstddef>
index 6b634cb..65794f3 100644 (file)
@@ -1,10 +1,10 @@
 #include <stdio.h>
 
-#if defined(__clang__)
-#define EXPORT(type) __attribute__((visibility("default"))) extern "C" type
-#else // defined(__clang__)
+#if defined(__GNUC__)
+#define EXPORT(type) extern "C" __attribute__((visibility("default"))) type
+#else // defined(__GNUC__)
 #define EXPORT(type) type
-#endif // !defined(__clang__)
+#endif // !defined(__GNUC__)
 
 #if !defined(_MSC_VER)
 #if __i386__
@@ -324,7 +324,7 @@ EXPORT(void) NATIVEAPI InvokeCallback19(PFNACTION19 callback, S19 s)
 
 EXPORT(void) NATIVEAPI InvokeCallback20(PFNACTION20 callback, S20 s)
 {
-#ifdef __clang__
+#ifdef __GNUC__
     printf("Native S20: %lld, %lld, %lld, %lld\n", s.x, s.y, s.z, s.w);
 #else
     printf("Native S20: %I64d, %I64d, %I64d, %I64d\n", s.x, s.y, s.z, s.w);
@@ -468,7 +468,7 @@ EXPORT(S19) NATIVEAPI InvokeCallback19R(PFNACTION19 callback, S19 s)
 
 EXPORT(S20) NATIVEAPI InvokeCallback20R(PFNACTION20 callback, S20 s)
 {
-#ifdef __clang__
+#ifdef __GNUC__
     printf("Native S20: %lld, %lld, %lld, %lld\n", s.x, s.y, s.z, s.w);
 #else
     printf("Native S20: %I64d, %I64d, %I64d, %I64d\n", s.x, s.y, s.z, s.w);
index 66dbe84..9e6f96c 100755 (executable)
@@ -5,13 +5,13 @@
 #include <stdio.h>
 #include <string.h>
 
-#if defined(__clang__)
-#define EXPORT(type) __attribute__((visibility("default"))) extern "C" type
+#if defined(__GNUC__)
+#define EXPORT(type) extern "C" __attribute__((visibility("default"))) type
 #elif defined(_MSC_VER)
 #define EXPORT(type) extern "C" __declspec(dllexport) type
-#else // defined(__clang__)
+#else // defined(__GNUC__)
 #define EXPORT(type) type
-#endif // !defined(__clang__)
+#endif // !defined(__GNUC__)
 
 #if !defined(_MSC_VER)
 #if __i386__
index a5be99d..740790a 100644 (file)
@@ -3,6 +3,17 @@
 
 #include "hfa_native.h"
 
+#ifndef _MSC_VER
+#ifdef BIT64
+#define __int64     long
+#else // BIT64
+#define __int64     long long
+#endif // BIT64
+
+#define __int32     int
+#define __int16     short int
+#define __int8      char        // assumes char is signed
+#endif
 
 // ---------------------------------------------------
 // Init Methods
index 7cfdb28..1298225 100644 (file)
@@ -7,6 +7,17 @@
 #else // __i386__
 #define __stdcall
 #endif  // !__i386__
+
+#ifdef BIT64
+#define __int64     long
+#else // BIT64
+#define __int64     long long
+#endif // BIT64
+
+#define __int32     int
+#define __int16     short int
+#define __int8      char        // assumes char is signed
+
 #endif // !defined(_MSC_VER)
 
 #if defined(_MSC_VER)
index cd2da96..cd07950 100644 (file)
@@ -9,6 +9,16 @@
 #else
 #define MCC_API extern "C" __attribute__((visibility("default")))
 #define WINAPI
+#ifdef BIT64
+#define __int64     long
+#else // BIT64
+#define __int64     long long
+#endif // BIT64
+
+#define __int32     int
+#define __int16     short int
+#define __int8      char        // assumes char is signed
+
 #endif 
 
 // ---------------------------------
index f7eab2d..47ec5d2 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright (c) Microsoft. All rights reserved.
 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
 
-#if defined(__clang__)
+#if defined(__GNUC__)
 #define EXPORT_API extern "C" __attribute__((visibility("default")))
 #elif defined(_MSC_VER)
 #define EXPORT_API extern "C" __declspec(dllexport)