#define INCLUDE_ALLOW_VMCORE
#include "includeCheck.h"
+#if defined _MSC_VER && !defined BORA_NO_WIN32_INTRINS
+#pragma warning(push)
+#pragma warning(disable : 4255) // disable no-prototype() to (void) warning
+#include <intrin.h>
+#pragma warning(pop)
+#endif
+
#include "vm_basic_types.h"
#include "vm_assert.h"
} Atomic_uint128;
#endif
-/*
- * Prototypes for msft atomics. These are defined & inlined by the
- * compiler so no function definition is needed. The prototypes are
- * needed for C++.
- *
- * The declarations for the intrinsic functions were taken from ntddk.h
- * in the DDK. The declarations must match otherwise the 64-bit C++
- * compiler will complain about second linkage of the intrinsic functions.
- * We define the intrinsic using the basic types corresponding to the
- * Windows typedefs. This avoids having to include windows header files
- * to get to the windows types.
- */
-#if defined _MSC_VER && !defined BORA_NO_WIN32_INTRINS
-#ifdef __cplusplus
-extern "C" {
-#endif
-long _InterlockedExchange(long volatile*, long);
-long _InterlockedCompareExchange(long volatile*, long, long);
-long _InterlockedExchangeAdd(long volatile*, long);
-long _InterlockedDecrement(long volatile*);
-long _InterlockedIncrement(long volatile*);
-char _InterlockedExchange8(char volatile *, char);
-char _InterlockedCompareExchange8(char volatile *, char, char);
-__int64 _InterlockedCompareExchange64(__int64 volatile*, __int64, __int64);
-#pragma intrinsic(_InterlockedExchange, _InterlockedCompareExchange)
-#pragma intrinsic(_InterlockedExchangeAdd, _InterlockedDecrement)
-#pragma intrinsic(_InterlockedIncrement)
-#pragma intrinsic(_InterlockedCompareExchange8, _InterlockedCompareExchange8)
-#pragma intrinsic(_InterlockedCompareExchange64)
-
-#if defined VM_X86_64
-long _InterlockedAnd(long volatile*, long);
-__int64 _InterlockedAnd64(__int64 volatile*, __int64);
-long _InterlockedOr(long volatile*, long);
-__int64 _InterlockedOr64(__int64 volatile*, __int64);
-long _InterlockedXor(long volatile*, long);
-__int64 _InterlockedXor64(__int64 volatile*, __int64);
-__int64 _InterlockedExchangeAdd64(__int64 volatile*, __int64);
-__int64 _InterlockedIncrement64(__int64 volatile*);
-__int64 _InterlockedDecrement64(__int64 volatile*);
-__int64 _InterlockedExchange64(__int64 volatile*, __int64);
-#if !defined _WIN64
-#pragma intrinsic(_InterlockedAnd, _InterlockedAnd64)
-#pragma intrinsic(_InterlockedOr, _InterlockedOr64)
-#pragma intrinsic(_InterlockedXor, _InterlockedXor64)
-#pragma intrinsic(_InterlockedExchangeAdd64, _InterlockedIncrement64)
-#pragma intrinsic(_InterlockedDecrement64, _InterlockedExchange64)
-#endif /* !_WIN64 */
-#endif /* __x86_64__ */
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _MSC_VER */
-
#if defined __arm__
/*
* LDREX without STREX or CLREX may cause problems in environments where the
/*********************************************************
- * Copyright (C) 2003-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2003-2020 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#define INCLUDE_ALLOW_VMCORE
#include "includeCheck.h"
+#if defined _MSC_VER && !defined BORA_NO_WIN32_INTRINS
+#pragma warning(push)
+#pragma warning(disable : 4255) // disable no-prototype() to (void) warning
+#include <intrin.h>
+#pragma warning(pop)
+#endif
+
#include "vm_basic_types.h"
#if defined VM_X86_64
/*********************************************************
- * Copyright (C) 1998-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2020 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#error "This file is x86-64 only!"
#endif
-#if defined(_MSC_VER) && !defined(BORA_NO_WIN32_INTRINS)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-uint64 _umul128(uint64 multiplier, uint64 multiplicand,
- uint64 *highProduct);
-int64 _mul128(int64 multiplier, int64 multiplicand,
- int64 *highProduct);
-uint64 __shiftright128(uint64 lowPart, uint64 highPart, uint8 shift);
-#ifdef ULM
-void _fxsave64(void *save);
-void _fxsave(void *save);
-void _fxrstor64(const void *load);
-void _fxrstor(const void *load);
-void _xsave64(void *save, uint64 mask);
-void _xsave(void *save, uint64 mask);
-void _xsaveopt64(void *save, uint64 mask);
-void _xsavec(void *save, uint64 mask);
-void _xrstor64(const void *load, uint64 mask);
-void _xrstor(const void *load, uint64 mask);
-#endif /* ULM */
-#ifdef __cplusplus
-}
-#endif
-
-#pragma intrinsic(_umul128, _mul128, __shiftright128)
-
-#ifdef ULM
-#pragma intrinsic(_fxsave64, _fxsave, _fxrstor64, _fxrstor, _xsave64, _xsave, \
- _xsaveopt64, _xsavec, _xrstor64, _xrstor)
-#endif /* ULM */
-
-#endif // _MSC_VER
-
#if defined(__GNUC__)
/*
* GET_CURRENT_PC
/*********************************************************
- * Copyright (C) 2013-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013-2020 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#error "Should be included only in x86 builds"
#endif
-/*
- * x86-64 windows doesn't support inline asm so we have to use these
- * intrinsic functions defined in the compiler. Not all of these are well
- * documented. There is an array in the compiler dll (c1.dll) which has
- * an array of the names of all the intrinsics minus the leading
- * underscore. Searching around in the ntddk.h file can also be helpful.
- *
- * The declarations for the intrinsic functions were taken from the DDK.
- * Our declarations must match the ddk's otherwise the 64-bit c++ compiler
- * will complain about second linkage of the intrinsic functions.
- * We define the intrinsic using the basic types corresponding to the
- * Windows typedefs. This avoids having to include windows header files
- * to get to the windows types.
- */
#if defined(_MSC_VER) && !defined(BORA_NO_WIN32_INTRINS)
#ifdef __cplusplus
extern "C" {
* functions. The documentation for the x86-64 suggest the
* __inbyte/__outbyte intrinsics even though the _in/_out work fine and
* __inbyte/__outbyte aren't supported on x86.
+ * NB: vs2015 removed _inp and friends in favor of __inbyte and friends.
+ * Declare these directly until we can convert to the new name.
*/
int _inp(unsigned short);
unsigned short _inpw(unsigned short);
unsigned long _outpd(uint16, unsigned long);
#pragma intrinsic(_inp, _inpw, _inpd, _outp, _outpw, _outpw, _outpd)
-/*
- * Prevents compiler from re-ordering reads, writes and reads&writes.
- * These functions do not add any instructions thus only affect
- * the compiler ordering.
- *
- * See:
- * `Lockless Programming Considerations for Xbox 360 and Microsoft Windows'
- * http://msdn.microsoft.com/en-us/library/bb310595(VS.85).aspx
- */
-void _ReadBarrier(void);
-void _WriteBarrier(void);
-void _ReadWriteBarrier(void);
-#pragma intrinsic(_ReadBarrier, _WriteBarrier, _ReadWriteBarrier)
-
-void _mm_mfence(void);
-void _mm_lfence(void);
-#pragma intrinsic(_mm_mfence, _mm_lfence)
-
-long _InterlockedXor(long volatile *, long);
-#pragma intrinsic(_InterlockedXor)
-
-unsigned int __getcallerseflags(void);
-#pragma intrinsic(__getcallerseflags)
-
-#ifdef VM_X86_64
-/*
- * intrinsic functions only supported by x86-64 windows as of 2k3sp1
- */
-unsigned __int64 __rdtsc(void);
-void __stosw(unsigned short *, unsigned short, size_t);
-void __stosd(unsigned long *, unsigned long, size_t);
-void _mm_pause(void);
-#pragma intrinsic(__rdtsc, __stosw, __stosd, _mm_pause)
-
-unsigned char _BitScanForward64(unsigned long *, unsigned __int64);
-unsigned char _BitScanReverse64(unsigned long *, unsigned __int64);
-#pragma intrinsic(_BitScanForward64, _BitScanReverse64)
-#endif /* VM_X86_64 */
-
-unsigned char _BitScanForward(unsigned long *, unsigned long);
-unsigned char _BitScanReverse(unsigned long *, unsigned long);
-#pragma intrinsic(_BitScanForward, _BitScanReverse)
-
-unsigned char _bittest(const long *, long);
-unsigned char _bittestandset(long *, long);
-unsigned char _bittestandreset(long *, long);
-unsigned char _bittestandcomplement(long *, long);
-#pragma intrinsic(_bittest, _bittestandset, _bittestandreset, _bittestandcomplement)
-#ifdef VM_X86_64
-unsigned char _bittestandset64(__int64 *, __int64);
-unsigned char _bittestandreset64(__int64 *, __int64);
-#pragma intrinsic(_bittestandset64, _bittestandreset64)
-#endif // VM_X86_64
#ifdef __cplusplus
}
#endif
/*********************************************************
- * Copyright (C) 2003-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2003-2020 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#include "x86cpuid.h"
-/*
- * The declarations for the intrinsic functions were taken from MSDN.
- * We define the intrinsic using the basic types corresponding to the
- * Windows typedefs. This avoids having to include windows header files
- * to get to the windows types.
- */
-#ifdef _MSC_VER
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * __cpuid has been supported since VS2003
- * __cpuidex has been supported since VS2008
- */
-void __cpuid(int regs[4], int eax);
-void __cpuidex(int regs[4], int eax, int ecx);
-#pragma intrinsic(__cpuid)
-#pragma intrinsic(__cpuidex)
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _MSC_VER */
-
-
#ifdef __GNUC__ // {
/*