# include "internal.h"
+# ifdef VIR_ATOMIC_OPS_GCC
+# define VIR_STATIC /* Nothing; we just never define the functions */
+# else
+# define VIR_STATIC static
+# endif
+
/**
* virAtomicIntGet:
* Gets the current value of atomic.
* This call acts as a full compiler and hardware memory barrier
* (before the get)
*/
-int virAtomicIntGet(volatile int *atomic)
+VIR_STATIC int virAtomicIntGet(volatile int *atomic)
ATTRIBUTE_NONNULL(1);
/**
* This call acts as a full compiler and hardware memory barrier
* (after the set)
*/
-void virAtomicIntSet(volatile int *atomic,
- int newval)
+VIR_STATIC void virAtomicIntSet(volatile int *atomic,
+ int newval)
ATTRIBUTE_NONNULL(1);
/**
*
* This call acts as a full compiler and hardware memory barrier.
*/
-int virAtomicIntInc(volatile int *atomic)
+VIR_STATIC int virAtomicIntInc(volatile int *atomic)
ATTRIBUTE_NONNULL(1);
/**
*
* This call acts as a full compiler and hardware memory barrier.
*/
-bool virAtomicIntDecAndTest(volatile int *atomic)
+VIR_STATIC bool virAtomicIntDecAndTest(volatile int *atomic)
ATTRIBUTE_NONNULL(1);
/**
*
* This call acts as a full compiler and hardware memory barrier.
*/
-bool virAtomicIntCompareExchange(volatile int *atomic,
- int oldval,
- int newval)
+VIR_STATIC bool virAtomicIntCompareExchange(volatile int *atomic,
+ int oldval,
+ int newval)
ATTRIBUTE_NONNULL(1);
/**
*
* This call acts as a full compiler and hardware memory barrier.
*/
-int virAtomicIntAdd(volatile int *atomic,
- int val)
+VIR_STATIC int virAtomicIntAdd(volatile int *atomic,
+ int val)
ATTRIBUTE_NONNULL(1);
/**
* Think of this operation as an atomic version of
* { tmp = *atomic; *atomic &= val; return tmp; }
*/
-unsigned int virAtomicIntAnd(volatile unsigned int *atomic,
- unsigned int val)
+VIR_STATIC unsigned int virAtomicIntAnd(volatile unsigned int *atomic,
+ unsigned int val)
ATTRIBUTE_NONNULL(1);
/**
*
* This call acts as a full compiler and hardware memory barrier.
*/
-unsigned int virAtomicIntOr(volatile unsigned int *atomic,
- unsigned int val)
+VIR_STATIC unsigned int virAtomicIntOr(volatile unsigned int *atomic,
+ unsigned int val)
ATTRIBUTE_NONNULL(1);
/**
*
* This call acts as a full compiler and hardware memory barrier.
*/
-unsigned int virAtomicIntXor(volatile unsigned int *atomic,
- unsigned int val)
+VIR_STATIC unsigned int virAtomicIntXor(volatile unsigned int *atomic,
+ unsigned int val)
ATTRIBUTE_NONNULL(1);
+# undef VIR_STATIC
# ifdef VIR_ATOMIC_OPS_GCC
/*
* http://msdn.microsoft.com/en-us/library/ms684122(v=vs.85).aspx
*/
-inline int
+static inline int
virAtomicIntGet(volatile int *atomic)
{
MemoryBarrier();
return *atomic;
}
-inline void
+static inline void
virAtomicIntSet(volatile int *atomic,
int newval)
{
MemoryBarrier();
}
-inline int
+static inline int
virAtomicIntInc(volatile int *atomic)
{
return InterlockedIncrement((volatile LONG *)atomic);
}
-inline bool
+static inline bool
virAtomicIntDecAndTest(volatile int *atomic)
{
return InterlockedDecrement((volatile LONG *)atomic) == 0;
}
-inline bool
+static inline bool
virAtomicIntCompareExchange(volatile int *atomic,
int oldval,
int newval)
return InterlockedCompareExchange((volatile LONG *)atomic, newval, oldval) == oldval;
}
-inline int
+static inline int
virAtomicIntAdd(volatile int *atomic,
int val)
{
return InterlockedExchangeAdd((volatile LONG *)atomic, val);
}
-inline unsigned int
+static inline unsigned int
virAtomicIntAnd(volatile unsigned int *atomic,
unsigned int val)
{
return InterlockedAnd((volatile LONG *)atomic, val);
}
-inline unsigned int
+static inline unsigned int
virAtomicIntOr(volatile unsigned int *atomic,
unsigned int val)
{
return InterlockedOr((volatile LONG *)atomic, val);
}
-inline unsigned int
+static inline unsigned int
virAtomicIntXor(volatile unsigned int *atomic,
unsigned int val)
{
extern pthread_mutex_t virAtomicLock;
-inline int
+static inline int
virAtomicIntGet(volatile int *atomic)
{
int value;
return value;
}
-inline void
+static inline void
virAtomicIntSet(volatile int *atomic,
int value)
{
pthread_mutex_unlock(&virAtomicLock);
}
-inline int
+static inline int
virAtomicIntInc(volatile int *atomic)
{
int value;
return value;
}
-inline bool
+static inline bool
virAtomicIntDecAndTest(volatile int *atomic)
{
bool is_zero;
return is_zero;
}
-inline bool
+static inline bool
virAtomicIntCompareExchange(volatile int *atomic,
int oldval,
int newval)
return success;
}
-inline int
+static inline int
virAtomicIntAdd(volatile int *atomic,
int val)
{
return oldval;
}
-inline unsigned int
+static inline unsigned int
virAtomicIntAnd(volatile unsigned int *atomic,
unsigned int val)
{
return oldval;
}
-inline unsigned int
+static inline unsigned int
virAtomicIntOr(volatile unsigned int *atomic,
unsigned int val)
{
return oldval;
}
-inline unsigned int
+static inline unsigned int
virAtomicIntXor(volatile unsigned int *atomic,
unsigned int val)
{