From: John Wolfe Date: Fri, 31 Jul 2020 20:36:34 +0000 (-0700) Subject: Changes to common header files not directly applicable to open-vm-tools. X-Git-Tag: stable-11.2.0~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=631280670bd5e0f50c2ece8ea43cc01c8586eb46;p=thirdparty%2Fopen-vm-tools.git Changes to common header files not directly applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/include/vm_atomic.h b/open-vm-tools/lib/include/vm_atomic.h index e65f36210..9673a5cc0 100644 --- a/open-vm-tools/lib/include/vm_atomic.h +++ b/open-vm-tools/lib/include/vm_atomic.h @@ -41,6 +41,13 @@ #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 +#pragma warning(pop) +#endif + #include "vm_basic_types.h" #include "vm_assert.h" @@ -145,61 +152,6 @@ typedef ALIGNED(16) struct Atomic_uint128 { } 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 diff --git a/open-vm-tools/lib/include/vm_basic_asm.h b/open-vm-tools/lib/include/vm_basic_asm.h index bc548e096..b1720ada3 100644 --- a/open-vm-tools/lib/include/vm_basic_asm.h +++ b/open-vm-tools/lib/include/vm_basic_asm.h @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -49,6 +49,13 @@ #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 +#pragma warning(pop) +#endif + #include "vm_basic_types.h" #if defined VM_X86_64 diff --git a/open-vm-tools/lib/include/vm_basic_asm_x86_64.h b/open-vm-tools/lib/include/vm_basic_asm_x86_64.h index 09dd473ef..5b171871e 100644 --- a/open-vm-tools/lib/include/vm_basic_asm_x86_64.h +++ b/open-vm-tools/lib/include/vm_basic_asm_x86_64.h @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -53,41 +53,6 @@ #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 diff --git a/open-vm-tools/lib/include/vm_basic_asm_x86_common.h b/open-vm-tools/lib/include/vm_basic_asm_x86_common.h index 4be3f8fa2..8ec30e2d9 100644 --- a/open-vm-tools/lib/include/vm_basic_asm_x86_common.h +++ b/open-vm-tools/lib/include/vm_basic_asm_x86_common.h @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -52,20 +52,6 @@ #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" { @@ -75,6 +61,8 @@ 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); @@ -85,59 +73,6 @@ unsigned short _outpw(unsigned short, 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 diff --git a/open-vm-tools/lib/include/x86cpuid_asm.h b/open-vm-tools/lib/include/x86cpuid_asm.h index f7f9d73c4..53bd3b4c3 100644 --- a/open-vm-tools/lib/include/x86cpuid_asm.h +++ b/open-vm-tools/lib/include/x86cpuid_asm.h @@ -1,5 +1,5 @@ /********************************************************* - * 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 @@ -53,31 +53,6 @@ #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__ // { /*