1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file under third_party_mods/chromium directory of
4 // source tree or at
5 // http://src.chromium.org/viewvc/chrome/trunk/src/LICENSE
6 
7 // Various inline functions and macros to fix compilation of 32 bit target
8 // on MSVC with /Wp64 flag enabled.
9 
10 // The original code can be found here:
11 // http://src.chromium.org/svn/trunk/src/base/fix_wp64.h
12 
13 #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_FIX_INTERLOCKED_EXCHANGE_POINTER_WINDOWS_H_
14 #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_FIX_INTERLOCKED_EXCHANGE_POINTER_WINDOWS_H_
15 
16 #include <windows.h>
17 
18 // Platform SDK fixes when building with /Wp64 for a 32 bits target.
19 #if !defined(_WIN64) && defined(_Wp64)
20 
21 #ifdef InterlockedExchangePointer
22 #undef InterlockedExchangePointer
23 // The problem is that the macro provided for InterlockedExchangePointer() is
24 // doing a (LONG) C-style cast that triggers invariably the warning C4312 when
25 // building on 32 bits.
InterlockedExchangePointer(void * volatile * target,void * value)26 inline void* InterlockedExchangePointer(void* volatile* target, void* value) {
27   return reinterpret_cast<void*>(static_cast<LONG_PTR>(InterlockedExchange(
28       reinterpret_cast<volatile LONG*>(target),
29       static_cast<LONG>(reinterpret_cast<LONG_PTR>(value)))));
30 }
31 #endif  // #ifdef InterlockedExchangePointer
32 
33 #endif // #if !defined(_WIN64) && defined(_Wp64)
34 
35 #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_FIX_INTERLOCKED_EXCHANGE_POINTER_WINDOWS_H_
36