diff options
author | Jan Kotas <jkotas@microsoft.com> | 2015-09-12 11:31:02 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2015-09-13 21:35:25 -0700 |
commit | eeb7076e3993ca3fea11ee599a272d985eb3d4d4 (patch) | |
tree | 4b9cba322e51276897d3a9e220b90aa660ce7963 /src/gc/env/gcenv.h | |
parent | 003a8b171a4fcac4907fe03facf4c84246435985 (diff) | |
download | coreclr-eeb7076e3993ca3fea11ee599a272d985eb3d4d4.tar.gz coreclr-eeb7076e3993ca3fea11ee599a272d985eb3d4d4.tar.bz2 coreclr-eeb7076e3993ca3fea11ee599a272d985eb3d4d4.zip |
Initial port of GC sample to Linux
- Add CMake build for the GC sample
- Add Unix clone of the GC environment. The Unix GC environment is partially
implemented, enough to make GC sample to compile and run on Linux.
Diffstat (limited to 'src/gc/env/gcenv.h')
-rw-r--r-- | src/gc/env/gcenv.h | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/src/gc/env/gcenv.h b/src/gc/env/gcenv.h index f7f39cbd85..6a9c4211bf 100644 --- a/src/gc/env/gcenv.h +++ b/src/gc/env/gcenv.h @@ -10,6 +10,11 @@ #define FEATURE_REDHAWK 1 #define FEATURE_CONSERVATIVE_GC 1 +#ifndef _MSC_VER +#define __stdcall +#define __forceinline inline +#endif + #ifndef _INC_WINDOWS // ----------------------------------------------------------------------------------------------------------- @@ -99,7 +104,7 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x) #define E_INVALIDARG 0x80070057 #define NOERROR 0x0 -#define ERROR_TIMEOUT 1460 +#define ERROR_TIMEOUT 1460 #define TRUE true #define FALSE false @@ -129,6 +134,13 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x) #define INVALID_HANDLE_VALUE ((HANDLE)-1) +#ifndef WIN32 +#define _vsnprintf vsnprintf +#define sprintf_s snprintf +#endif + +#ifdef WIN32 + #pragma pack(push, 8) typedef struct _RTL_CRITICAL_SECTION { @@ -148,6 +160,14 @@ typedef struct _RTL_CRITICAL_SECTION { #pragma pack(pop) +#else + +typedef struct _RTL_CRITICAL_SECTION { + pthread_mutex_t mutex; +} CRITICAL_SECTION, RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION; + +#endif + typedef struct _MEMORYSTATUSEX { DWORD dwLength; DWORD dwMemoryLoad; @@ -160,11 +180,11 @@ typedef struct _MEMORYSTATUSEX { DWORDLONG ullAvailExtendedVirtual; } MEMORYSTATUSEX, *LPMEMORYSTATUSEX; -typedef DWORD (__stdcall *PTHREAD_START_ROUTINE)(void* lpThreadParameter); - #define WINBASEAPI extern "C" #define WINAPI __stdcall +typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(PVOID lpThreadParameter); + WINBASEAPI void WINAPI @@ -271,14 +291,37 @@ WINAPI FlushFileBuffers( HANDLE hFile); +#ifdef _MSC_VER + extern "C" VOID _mm_pause ( VOID ); +extern "C" VOID +_mm_mfence ( + VOID + ); + #pragma intrinsic(_mm_pause) +#pragma intrinsic(_mm_mfence) #define YieldProcessor _mm_pause +#define MemoryBarrier _mm_mfence + +#else // _MSC_VER + +WINBASEAPI +VOID +WINAPI +YieldProcessor(); + +WINBASEAPI +VOID +WINAPI +MemoryBarrier(); + +#endif // _MSC_VER #endif // _INC_WINDOWS @@ -1003,7 +1046,7 @@ public: GCSTRESS_UNIQUE = 16, // GC only on a unique stack trace }; - int GetHeapVerifyLevel(); + int GetHeapVerifyLevel() { return 0; } bool IsHeapVerifyEnabled() { return GetHeapVerifyLevel() != 0; } GCStressFlags GetGCStressLevel() const { return GCSTRESS_NONE; } @@ -1066,7 +1109,9 @@ public: case Config_COUNT: default: +#ifdef _MSC_VER #pragma warning(suppress:4127) // Constant conditional expression in ASSERT below +#endif ASSERT(!"Unknown config value type"); return 0; } @@ -1169,7 +1214,6 @@ public: bool Set(); bool Reset(); uint32_t Wait(uint32_t dwMilliseconds, bool bAlertable); - HANDLE GetOSEvent(); private: HANDLE m_hEvent; @@ -1270,9 +1314,9 @@ public: } }; -inline bool FitsInU1(unsigned __int64 val) +inline bool FitsInU1(uint64_t val) { - return val == (unsigned __int64)(unsigned __int8)val; + return val == (uint64_t)(uint8_t)val; } // ----------------------------------------------------------------------------------------------------------- |