summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2017-01-20 19:23:45 +0300
committerIvan Maidanski <ivmai@mail.ru>2017-01-20 19:23:45 +0300
commit4a871e01583aab0d8a040ec84113f7b0b60200d9 (patch)
tree4b04a1e709cf3fb55791faa171798c3406a0b914
parent686e915d830d5f3ddd44567952626ff67d67d19a (diff)
downloadlibatomic_ops-4a871e01583aab0d8a040ec84113f7b0b60200d9.tar.gz
Remove redundant include windows.h from headers (msftc/x86[_64])
* src/atomic_ops/sysdeps/msftc/common32_defs.h: Do not include windows.h if _MSC_VER > 1400 && AO_USE_INTERLOCKED_INTRINSICS && !_WIN32_WCE. * src/atomic_ops/sysdeps/msftc/common32_defs.h [!AO_PREFER_GENERALIZED || !AO_ASSUME_WINDOWS98] (AO_fetch_and_add_full, AO_fetch_and_add1_full, AO_fetch_and_sub1_full): Replace LONG to long; remove unnecessary cast to LONG. * src/atomic_ops/sysdeps/msftc/common32_defs.h [AO_ASSUME_WINDOWS98] (AO_fetch_compare_and_swap_full): Likewise. * src/atomic_ops/sysdeps/msftc/x86_64.h (AO_int_fetch_compare_and_swap_full): Likewise. * src/atomic_ops/sysdeps/msftc/x86_64.h [!AO_PREFER_GENERALIZED] (AO_int_fetch_and_add_full, AO_int_fetch_and_add1_full, AO_int_fetch_and_sub1_full): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [AO_ASSUME_WINDOWS98] (AO_fetch_compare_and_swap_full): Replace PVOID to void*; remove unnecessary cast to AO_t. * src/atomic_ops/sysdeps/msftc/x86_64.h: Remove include windows.h. * src/atomic_ops/sysdeps/msftc/x86_64.h [!AO_PREFER_GENERALIZED] (AO_fetch_and_add_full, AO_fetch_and_add1_full, AO_fetch_and_sub1_full): Replace LONGLONG to __int64; remove unnecessary cast to LONGLONG. * src/atomic_ops/sysdeps/msftc/x86_64.h (AO_fetch_compare_and_swap_full): Likewise.
-rw-r--r--src/atomic_ops/sysdeps/msftc/common32_defs.h21
-rw-r--r--src/atomic_ops/sysdeps/msftc/x86_64.h22
2 files changed, 20 insertions, 23 deletions
diff --git a/src/atomic_ops/sysdeps/msftc/common32_defs.h b/src/atomic_ops/sysdeps/msftc/common32_defs.h
index 989974e..ab57e45 100644
--- a/src/atomic_ops/sysdeps/msftc/common32_defs.h
+++ b/src/atomic_ops/sysdeps/msftc/common32_defs.h
@@ -29,9 +29,12 @@
/* (otherwise "Interlocked" functions family is used instead). */
/* Define AO_ASSUME_WINDOWS98 if CAS is available. */
-#include <windows.h>
+#if _MSC_VER <= 1400 || !defined(AO_USE_INTERLOCKED_INTRINSICS) \
+ || defined(_WIN32_WCE)
+# include <windows.h>
/* Seems like over-kill, but that's what MSDN recommends. */
/* And apparently winbase.h is not always self-contained. */
+#endif
#if _MSC_VER < 1310 || !defined(AO_USE_INTERLOCKED_INTRINSICS)
@@ -78,22 +81,21 @@
AO_INLINE AO_t
AO_fetch_and_add_full(volatile AO_t *p, AO_t incr)
{
- return _InterlockedExchangeAdd((LONG AO_INTERLOCKED_VOLATILE *)p,
- (LONG)incr);
+ return _InterlockedExchangeAdd((long AO_INTERLOCKED_VOLATILE *)p, incr);
}
#define AO_HAVE_fetch_and_add_full
AO_INLINE AO_t
AO_fetch_and_add1_full(volatile AO_t *p)
{
- return _InterlockedIncrement((LONG AO_INTERLOCKED_VOLATILE *)p) - 1;
+ return _InterlockedIncrement((long AO_INTERLOCKED_VOLATILE *)p) - 1;
}
#define AO_HAVE_fetch_and_add1_full
AO_INLINE AO_t
AO_fetch_and_sub1_full(volatile AO_t *p)
{
- return _InterlockedDecrement((LONG AO_INTERLOCKED_VOLATILE *)p) + 1;
+ return _InterlockedDecrement((long AO_INTERLOCKED_VOLATILE *)p) + 1;
}
#define AO_HAVE_fetch_and_sub1_full
#endif /* !AO_PREFER_GENERALIZED */
@@ -105,12 +107,11 @@ AO_fetch_and_sub1_full(volatile AO_t *p)
{
# ifdef AO_OLD_STYLE_INTERLOCKED_COMPARE_EXCHANGE
return (AO_t)_InterlockedCompareExchange(
- (PVOID AO_INTERLOCKED_VOLATILE *)addr,
- (PVOID)new_val, (PVOID)old_val);
+ (void *AO_INTERLOCKED_VOLATILE *)addr,
+ (void *)new_val, (void *)old_val);
# else
- return (AO_t)_InterlockedCompareExchange(
- (LONG AO_INTERLOCKED_VOLATILE *)addr,
- (LONG)new_val, (LONG)old_val);
+ return _InterlockedCompareExchange((long AO_INTERLOCKED_VOLATILE *)addr,
+ new_val, old_val);
# endif
}
# define AO_HAVE_fetch_compare_and_swap_full
diff --git a/src/atomic_ops/sysdeps/msftc/x86_64.h b/src/atomic_ops/sysdeps/msftc/x86_64.h
index c06d0e9..ed6eb0c 100644
--- a/src/atomic_ops/sysdeps/msftc/x86_64.h
+++ b/src/atomic_ops/sysdeps/msftc/x86_64.h
@@ -37,10 +37,6 @@
# include "../test_and_set_t_is_ao_t.h"
#endif
-#include <windows.h>
- /* Seems like over-kill, but that's what MSDN recommends. */
- /* And apparently winbase.h is not always self-contained. */
-
/* Assume _MSC_VER >= 1400 */
#include <intrin.h>
@@ -59,21 +55,21 @@
AO_INLINE AO_t
AO_fetch_and_add_full (volatile AO_t *p, AO_t incr)
{
- return _InterlockedExchangeAdd64((LONGLONG volatile *)p, (LONGLONG)incr);
+ return _InterlockedExchangeAdd64((__int64 volatile *)p, incr);
}
#define AO_HAVE_fetch_and_add_full
AO_INLINE AO_t
AO_fetch_and_add1_full (volatile AO_t *p)
{
- return _InterlockedIncrement64((LONGLONG volatile *)p) - 1;
+ return _InterlockedIncrement64((__int64 volatile *)p) - 1;
}
#define AO_HAVE_fetch_and_add1_full
AO_INLINE AO_t
AO_fetch_and_sub1_full (volatile AO_t *p)
{
- return _InterlockedDecrement64((LONGLONG volatile *)p) + 1;
+ return _InterlockedDecrement64((__int64 volatile *)p) + 1;
}
#define AO_HAVE_fetch_and_sub1_full
#endif /* !AO_PREFER_GENERALIZED */
@@ -82,8 +78,8 @@ AO_INLINE AO_t
AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old_val,
AO_t new_val)
{
- return (AO_t)_InterlockedCompareExchange64((LONGLONG volatile *)addr,
- (LONGLONG)new_val, (LONGLONG)old_val);
+ return (AO_t)_InterlockedCompareExchange64((__int64 volatile *)addr,
+ new_val, old_val);
}
#define AO_HAVE_fetch_compare_and_swap_full
@@ -91,7 +87,7 @@ AO_INLINE unsigned int
AO_int_fetch_compare_and_swap_full(volatile unsigned int *addr,
unsigned int old_val, unsigned int new_val)
{
- return _InterlockedCompareExchange((LONG volatile *)addr, new_val, old_val);
+ return _InterlockedCompareExchange((long volatile *)addr, new_val, old_val);
}
#define AO_HAVE_int_fetch_compare_and_swap_full
@@ -99,21 +95,21 @@ AO_int_fetch_compare_and_swap_full(volatile unsigned int *addr,
AO_INLINE unsigned int
AO_int_fetch_and_add_full(volatile unsigned int *p, unsigned int incr)
{
- return _InterlockedExchangeAdd((LONG volatile *)p, incr);
+ return _InterlockedExchangeAdd((long volatile *)p, incr);
}
#define AO_HAVE_int_fetch_and_add_full
AO_INLINE unsigned int
AO_int_fetch_and_add1_full(volatile unsigned int *p)
{
- return _InterlockedIncrement((LONG volatile *)p) - 1;
+ return _InterlockedIncrement((long volatile *)p) - 1;
}
# define AO_HAVE_int_fetch_and_add1_full
AO_INLINE unsigned int
AO_int_fetch_and_sub1_full(volatile unsigned int *p)
{
- return _InterlockedDecrement((LONG volatile *)p) + 1;
+ return _InterlockedDecrement((long volatile *)p) + 1;
}
# define AO_HAVE_int_fetch_and_sub1_full
#endif /* !AO_PREFER_GENERALIZED */