#define _DEBUG_IMPL 1
#endif
+#if __GNUC__
+#ifndef __cdecl
+#define __cdecl __attribute__((__cdecl__))
+#endif
+#endif
+
//
// CPP_ASSERT() can be used within a class definition, to perform a
// compile-time assertion involving private names within the class.
#define SCAN_WIDEN2(x) L ## x
#define SCAN_WIDEN(x) SCAN_WIDEN2(x)
+#ifndef NOINLINE
+#if __GNUC__
+#define NOINLINE __attribute__((noinline))
+#else
+#define NOINLINE __declspec(noinline)
+#endif
+#endif
+
//
// PDB annotations for the static contract analysis tool. These are seperated
// from Contract.h to allow their inclusion in any part of the system.
{
struct ScanThrowMarkerStandard
{
- __declspec(noinline) ScanThrowMarkerStandard()
+ NOINLINE ScanThrowMarkerStandard()
{
METHOD_CANNOT_BE_FOLDED_DEBUG;
STATIC_CONTRACT_THROWS;
struct ScanThrowMarkerTerminal
{
- __declspec(noinline) ScanThrowMarkerTerminal()
+ NOINLINE ScanThrowMarkerTerminal()
{
METHOD_CANNOT_BE_FOLDED_DEBUG;
}
struct ScanThrowMarkerIgnore
{
- __declspec(noinline) ScanThrowMarkerIgnore()
+ NOINLINE ScanThrowMarkerIgnore()
{
METHOD_CANNOT_BE_FOLDED_DEBUG;
}
class BlockMarker
{
public:
- __declspec(noinline) void MarkBlock()
+ NOINLINE void MarkBlock()
{
ANNOTATION_MARK_BLOCK_ANNOTATION;
METHOD_CANNOT_BE_FOLDED_DEBUG;
return;
}
- __declspec(noinline) void UseMarkedBlockAnnotation()
+ NOINLINE void UseMarkedBlockAnnotation()
{
ANNOTATION_USE_BLOCK_ANNOTATION;
METHOD_CANNOT_BE_FOLDED_DEBUG;
return;
}
- __declspec(noinline) void EndUseMarkedBlockAnnotation()
+ NOINLINE void EndUseMarkedBlockAnnotation()
{
ANNOTATION_END_USE_BLOCK_ANNOTATION;
METHOD_CANNOT_BE_FOLDED_DEBUG;
// define the return value for success
#define SAFECRT_SUCCESS 0
+#if defined(_MSC_VER) || defined(__llvm__)
+#define THROW_DECL
+#else
+#define THROW_DECL throw()
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
extern int _snscanf_s( const char *string, size_t count, const char *format, ... );
extern int _snwscanf_s( const WCHAR *string, size_t count, const WCHAR *format, ... );
-extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count );
+extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count ) THROW_DECL;
extern errno_t memmove_s( void * dst, size_t sizeInBytes, const void * src, size_t count );
#ifdef __cplusplus
#define LANG_THAI 0x1e
/******************* Compiler-specific glue *******************************/
+#if defined(_MSC_VER) || defined(__llvm__)
+#define THROW_DECL
+#else
+#define THROW_DECL throw()
+#endif
#ifndef _MSC_VER
#if defined(CORECLR)
#if defined(_MSC_VER) || defined(__llvm__)
#define DECLSPEC_ALIGN(x) __declspec(align(x))
#else
-#define DECLSPEC_ALIGN(x)
+#define DECLSPEC_ALIGN(x) __attribute__ ((aligned(x)))
#endif
#define DECLSPEC_NORETURN PAL_NORETURN
#endif
#endif
+#ifndef NOOPT_ATTRIBUTE
+#if defined(__llvm__)
+#define NOOPT_ATTRIBUTE optnone
+#else
+#define NOOPT_ATTRIBUTE optimize("O0")
+#endif
+#endif
+
#ifndef PAL_STDCPP_COMPAT
#if __GNUC__
IN OUT LONG volatile *Target,
IN LONG Value)
{
- LONG result = __sync_swap(Target, Value);
+ LONG result = __atomic_exchange_n(Target, Value, __ATOMIC_ACQ_REL);
PAL_ArmInterlockedOperationBarrier();
return result;
}
IN OUT LONGLONG volatile *Target,
IN LONGLONG Value)
{
- LONGLONG result = __sync_swap(Target, Value);
+ LONGLONG result = __atomic_exchange_n(Target, Value, __ATOMIC_ACQ_REL);
PAL_ArmInterlockedOperationBarrier();
return result;
}
PALIMPORT void * __cdecl memset(void *, int, size_t);
PALIMPORT void * __cdecl memmove(void *, const void *, size_t);
PALIMPORT void * __cdecl memchr(const void *, int, size_t);
-PALIMPORT long long int __cdecl atoll(const char *);
+PALIMPORT long long int __cdecl atoll(const char *) THROW_DECL;
PALIMPORT size_t __cdecl strlen(const char *);
PALIMPORT int __cdecl strcmp(const char*, const char *);
PALIMPORT int __cdecl strncmp(const char*, const char *, size_t);
#define _TRUNCATE ((size_t)-1)
#endif
-PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t);
+PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t) THROW_DECL;
PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
PALIMPORT char * __cdecl _strlwr(char *);
PALIMPORT int __cdecl _stricmp(const char *, const char *);
}
#endif
-#if !__has_builtin(_rotl)
+#if defined(__llvm__)
+#define HAS_ROTL __has_builtin(_rotl)
+#define HAS_ROTR __has_builtin(_rotr)
+#else
+#define HAS_ROTL 0
+#define HAS_ROTR 0
+#endif
+
+#if !HAS_ROTL
/*++
Function:
_rotl
retval = (value << shift) | (value >> (sizeof(int) * CHAR_BIT - shift));
return retval;
}
-#endif // !__has_builtin(_rotl)
+#endif // !HAS_ROTL
// On 64 bit unix, make the long an int.
#ifdef BIT64
#define _lrotl _rotl
#endif // BIT64
-#if !__has_builtin(_rotr)
+#if !HAS_ROTR
/*++
Function:
return retval;
}
-#endif // !__has_builtin(_rotr)
+#endif // !HAS_ROTR
PALIMPORT int __cdecl abs(int);
// clang complains if this is declared with __int64
PALIMPORT double __cdecl acosh(double);
PALIMPORT double __cdecl asin(double);
PALIMPORT double __cdecl asinh(double);
-PALIMPORT double __cdecl atan(double);
-PALIMPORT double __cdecl atanh(double);
+PALIMPORT double __cdecl atan(double) THROW_DECL;
+PALIMPORT double __cdecl atanh(double) THROW_DECL;
PALIMPORT double __cdecl atan2(double, double);
-PALIMPORT double __cdecl cbrt(double);
+PALIMPORT double __cdecl cbrt(double) THROW_DECL;
PALIMPORT double __cdecl ceil(double);
PALIMPORT double __cdecl cos(double);
PALIMPORT double __cdecl cosh(double);
PALIMPORT float __cdecl acoshf(float);
PALIMPORT float __cdecl asinf(float);
PALIMPORT float __cdecl asinhf(float);
-PALIMPORT float __cdecl atanf(float);
-PALIMPORT float __cdecl atanhf(float);
+PALIMPORT float __cdecl atanf(float) THROW_DECL;
+PALIMPORT float __cdecl atanhf(float) THROW_DECL;
PALIMPORT float __cdecl atan2f(float, float);
-PALIMPORT float __cdecl cbrtf(float);
+PALIMPORT float __cdecl cbrtf(float) THROW_DECL;
PALIMPORT float __cdecl ceilf(float);
PALIMPORT float __cdecl cosf(float);
PALIMPORT float __cdecl coshf(float);
#define _UINTPTR_T_DEFINED
#endif
+#ifdef __GNUC__
+#define SAFECRT_DEPRECATED __attribute__((deprecated))
+#else
#define SAFECRT_DEPRECATED __declspec(deprecated)
+#endif
/* errno_t */
#if !defined(_ERRCODE_DEFINED)
--*/
PAL_NORETURN
__attribute__((noinline))
-__attribute__((optnone))
+__attribute__((NOOPT_ATTRIBUTE))
static void
RtlpRaiseException(EXCEPTION_RECORD *ExceptionRecord, CONTEXT *ContextRecord)
{
--*/
-#ifdef __llvm__
-__thread
-#else // __llvm__
-__declspec(thread)
-#endif // !__llvm__
-static NativeExceptionHolderBase *t_nativeExceptionHolderHead = nullptr;
+#if defined(__GNUC__)
+static __thread
+#else // __GNUC__
+__declspec(thread) static
+#endif // !__GNUC__
+NativeExceptionHolderBase *t_nativeExceptionHolderHead = nullptr;
extern "C"
NativeExceptionHolderBase **
#elif defined(_ARM64_) || defined(_ARM_)
return pContext->Pc;
#else
-#error don't know how to get the program counter for this architecture
+#error "don't know how to get the program counter for this architecture"
#endif
}
#elif defined(_ARM64_) || defined(_ARM_)
pContext->Pc = pc;
#else
-#error don't know how to set the program counter for this architecture
+#error "don't know how to set the program counter for this architecture"
#endif
}
#elif defined(_ARM64_)
return pContext->Fp;
#else
-#error don't know how to get the frame pointer for this architecture
+#error "don't know how to get the frame pointer for this architecture"
#endif
}
real life scenarios work.
--*/
-__attribute__((noinline,optnone))
+__attribute__((noinline,NOOPT_ATTRIBUTE))
void
EnsureStackSize(SIZE_T stackSize)
{
}
// get pSrc 2-byte aligned
- if (((int)pSrc & 0x1) != 0) {
+ if (((size_t)pSrc & 0x1) != 0) {
ch = *pSrc;
pSrc++;
if (ch > 0x7F) {
}
// get pSrc 4-byte aligned
- if (((int)pSrc & 0x2) != 0) {
+ if (((size_t)pSrc & 0x2) != 0) {
ch = *(USHORT*)pSrc;
if ((ch & 0x8080) != 0) {
goto LongCodeWithMask16;
pTarget++;
// get pSrc to be 2-byte aligned
- if ((((int)pSrc) & 0x1) != 0) {
+ if ((((size_t)pSrc) & 0x1) != 0) {
ch = *pSrc;
pSrc++;
if (ch > 0x7F) {
}
// get pSrc to be 4-byte aligned
- if ((((int)pSrc) & 0x2) != 0) {
+ if ((((size_t)pSrc) & 0x2) != 0) {
ch = *(USHORT*)pSrc;
if ((ch & 0x8080) != 0) {
goto LongCodeWithMask16;
}
// get pSrc aligned
- if (((int)pSrc & 0x2) != 0) {
+ if (((size_t)pSrc & 0x2) != 0) {
ch = *pSrc;
pSrc++;
if (ch > 0x7F) // Not ASCII
size_t sizeInBytes,
const void * src,
size_t count
-)
+) THROW_DECL
{
if (count == 0)
{
pPalCriticalSection->LockCount = 0;
pPalCriticalSection->RecursionCount = 0;
pPalCriticalSection->SpinCount = dwSpinCount;
- pPalCriticalSection->OwningThread = NULL;
+ pPalCriticalSection->OwningThread = 0;
pPalCriticalSection->LockSemaphore = NULL;
pPalCriticalSection->fInternal = fInternal;
}
// Reset CS ownership
- pPalCriticalSection->OwningThread = NULL;
+ pPalCriticalSection->OwningThread = 0;
// Load the current LockCount value
lVal = pPalCriticalSection->LockCount;
ASSIGN_REG(X28)
#else
-#error Don't know how to assign registers on this architecture
+#error "Don't know how to assign registers on this architecture"
#endif
#define ASSIGN_ALL_REGS \
return PAL_InitializeDLL();
}
-__attribute__((noinline,optnone))
+__attribute__((noinline,NOOPT_ATTRIBUTE))
static void FailingFunction(volatile int *p)
{
if (p == NULL)
return PAL_InitializeDLL();
}
-__attribute__((noinline,optnone))
+__attribute__((noinline,NOOPT_ATTRIBUTE))
static void FailingFunction(volatile int *p)
{
if (p == NULL)