Use int instead of long in interlocked_* functions for 64-bit

compatibility.
This commit is contained in:
Alexandre Julliard 2005-09-26 13:51:58 +00:00
parent 81d64af17e
commit 43c6396e94
7 changed files with 47 additions and 47 deletions

View File

@ -1919,7 +1919,7 @@ __ASM_GLOBAL_FUNC(InterlockedDecrement,
*/
LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
{
return interlocked_cmpxchg( dest, xchg, compare );
return interlocked_cmpxchg( (int *)dest, xchg, compare );
}
/***********************************************************************
@ -1936,7 +1936,7 @@ LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG com
*/
LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
{
return interlocked_xchg( dest, val );
return interlocked_xchg( (int *)dest, val );
}
/***********************************************************************
@ -1953,7 +1953,7 @@ LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
*/
LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
{
return interlocked_xchg_add( dest, incr );
return interlocked_xchg_add( (int *)dest, incr );
}
/***********************************************************************
@ -1969,7 +1969,7 @@ LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
*/
LONG WINAPI InterlockedIncrement( LONG volatile *dest )
{
return interlocked_xchg_add( dest, 1 ) + 1;
return interlocked_xchg_add( (int *)dest, 1 ) + 1;
}
/***********************************************************************
@ -1985,7 +1985,7 @@ LONG WINAPI InterlockedIncrement( LONG volatile *dest )
*/
LONG WINAPI InterlockedDecrement( LONG volatile *dest )
{
return interlocked_xchg_add( dest, -1 ) - 1;
return interlocked_xchg_add( (int *)dest, -1 ) - 1;
}
#endif /* __i386__ */

View File

@ -35,12 +35,12 @@ WINE_DECLARE_DEBUG_CHANNEL(relay);
inline static LONG interlocked_inc( PLONG dest )
{
return interlocked_xchg_add( dest, 1 ) + 1;
return interlocked_xchg_add( (int *)dest, 1 ) + 1;
}
inline static LONG interlocked_dec( PLONG dest )
{
return interlocked_xchg_add( dest, -1 ) - 1;
return interlocked_xchg_add( (int *)dest, -1 ) - 1;
}
inline static void small_pause(void)
@ -322,7 +322,7 @@ NTSTATUS WINAPI RtlEnterCriticalSection( RTL_CRITICAL_SECTION *crit )
if (crit->LockCount > 0) break; /* more than one waiter, don't bother spinning */
if (crit->LockCount == -1) /* try again */
{
if (interlocked_cmpxchg( &crit->LockCount, 0, -1 ) == -1) goto done;
if (interlocked_cmpxchg( (int *)&crit->LockCount, 0, -1 ) == -1) goto done;
}
small_pause();
}
@ -366,7 +366,7 @@ done:
BOOL WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit )
{
BOOL ret = FALSE;
if (interlocked_cmpxchg( &crit->LockCount, 0L, -1 ) == -1)
if (interlocked_cmpxchg( (int *)&crit->LockCount, 0, -1 ) == -1)
{
crit->OwningThread = (HANDLE)GetCurrentThreadId();
crit->RecursionCount = 1;

View File

@ -383,15 +383,15 @@ extern int spawnvp(int mode, const char *cmdname, const char * const argv[]);
#if defined(__i386__) && defined(__GNUC__)
extern inline long interlocked_cmpxchg( long *dest, long xchg, long compare );
extern inline int interlocked_cmpxchg( int *dest, int xchg, int compare );
extern inline void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare );
extern inline long interlocked_xchg( long *dest, long val );
extern inline int interlocked_xchg( int *dest, int val );
extern inline void *interlocked_xchg_ptr( void **dest, void *val );
extern inline long interlocked_xchg_add( long *dest, long incr );
extern inline int interlocked_xchg_add( int *dest, int incr );
extern inline long interlocked_cmpxchg( long *dest, long xchg, long compare )
extern inline int interlocked_cmpxchg( int *dest, int xchg, int compare )
{
long ret;
int ret;
__asm__ __volatile__( "lock; cmpxchgl %2,(%1)"
: "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" );
return ret;
@ -405,9 +405,9 @@ extern inline void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *comp
return ret;
}
extern inline long interlocked_xchg( long *dest, long val )
extern inline int interlocked_xchg( int *dest, int val )
{
long ret;
int ret;
__asm__ __volatile__( "lock; xchgl %0,(%1)"
: "=r" (ret) : "r" (dest), "0" (val) : "memory" );
return ret;
@ -421,9 +421,9 @@ extern inline void *interlocked_xchg_ptr( void **dest, void *val )
return ret;
}
extern inline long interlocked_xchg_add( long *dest, long incr )
extern inline int interlocked_xchg_add( int *dest, int incr )
{
long ret;
int ret;
__asm__ __volatile__( "lock; xaddl %0,(%1)"
: "=r" (ret) : "r" (dest), "0" (incr) : "memory" );
return ret;
@ -431,11 +431,11 @@ extern inline long interlocked_xchg_add( long *dest, long incr )
#else /* __i386___ && __GNUC__ */
extern long interlocked_cmpxchg( long *dest, long xchg, long compare );
extern int interlocked_cmpxchg( int *dest, int xchg, int compare );
extern void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare );
extern long interlocked_xchg( long *dest, long val );
extern int interlocked_xchg( int *dest, int val );
extern void *interlocked_xchg_ptr( void **dest, void *val );
extern long interlocked_xchg_add( long *dest, long incr );
extern int interlocked_xchg_add( int *dest, int incr );
#endif /* __i386___ && __GNUC__ */

View File

@ -55,7 +55,7 @@ __ASM_GLOBAL_FUNC(interlocked_xchg_add,
#elif defined(_MSC_VER)
__declspec(naked) long interlocked_cmpxchg( long *dest, long xchg, long compare )
__declspec(naked) int interlocked_cmpxchg( int *dest, int xchg, int compare )
{
__asm mov eax, 12[esp];
__asm mov ecx, 8[esp];
@ -73,7 +73,7 @@ __declspec(naked) void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *
__asm ret;
}
__declspec(naked) long interlocked_xchg( long *dest, long val )
__declspec(naked) int interlocked_xchg( int *dest, int val )
{
__asm mov eax, 8[esp];
__asm mov edx, 4[esp];
@ -89,7 +89,7 @@ __declspec(naked) void *interlocked_xchg_ptr( void **dest, void *val )
__asm ret;
}
__declspec(naked) long interlocked_xchg_add( long *dest, long incr )
__declspec(naked) int interlocked_xchg_add( int *dest, int incr )
{
__asm mov eax, 8[esp];
__asm mov edx, 4[esp];
@ -133,8 +133,8 @@ __ASM_GLOBAL_FUNC(interlocked_xchg_add,
#elif defined(__powerpc__)
void* interlocked_cmpxchg_ptr( void **dest, void* xchg, void* compare)
{
long ret = 0;
long scratch;
void *ret = 0;
void *scratch;
__asm__ __volatile__(
"0: lwarx %0,0,%2\n"
" xor. %1,%4,%0\n"
@ -146,13 +146,13 @@ void* interlocked_cmpxchg_ptr( void **dest, void* xchg, void* compare)
: "=&r"(ret), "=&r"(scratch)
: "r"(dest), "r"(xchg), "r"(compare)
: "cr0","memory");
return (void*)ret;
return ret;
}
long interlocked_cmpxchg( long *dest, long xchg, long compare)
int interlocked_cmpxchg( int *dest, int xchg, int compare)
{
long ret = 0;
long scratch;
int ret = 0;
int scratch;
__asm__ __volatile__(
"0: lwarx %0,0,%2\n"
" xor. %1,%4,%0\n"
@ -167,10 +167,10 @@ long interlocked_cmpxchg( long *dest, long xchg, long compare)
return ret;
}
long interlocked_xchg_add( long *dest, long incr )
int interlocked_xchg_add( int *dest, int incr )
{
long ret = 0;
long zero = 0;
int ret = 0;
int zero = 0;
__asm__ __volatile__(
"0: lwarx %0, %3, %1\n"
" add %0, %2, %0\n"
@ -184,9 +184,9 @@ long interlocked_xchg_add( long *dest, long incr )
return ret-incr;
}
long interlocked_xchg( long* dest, long val )
int interlocked_xchg( int* dest, int val )
{
long ret = 0;
int ret = 0;
__asm__ __volatile__(
"0: lwarx %0,0,%1\n"
" stwcx. %2,0,%1\n"
@ -226,7 +226,7 @@ void* interlocked_xchg_ptr( void** dest, void* val )
#include <synch.h>
static lwp_mutex_t interlocked_mutex = DEFAULTMUTEX;
long interlocked_cmpxchg( long *dest, long xchg, long compare )
int interlocked_cmpxchg( int *dest, int xchg, int compare )
{
_lwp_mutex_lock( &interlocked_mutex );
if (*dest == compare) *dest = xchg;
@ -244,9 +244,9 @@ void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare )
return compare;
}
long interlocked_xchg( long *dest, long val )
int interlocked_xchg( int *dest, int val )
{
long retv;
int retv;
_lwp_mutex_lock( &interlocked_mutex );
retv = *dest;
*dest = val;
@ -256,7 +256,7 @@ long interlocked_xchg( long *dest, long val )
void *interlocked_xchg_ptr( void **dest, void *val )
{
long retv;
void *retv;
_lwp_mutex_lock( &interlocked_mutex );
retv = *dest;
*dest = val;
@ -264,9 +264,9 @@ void *interlocked_xchg_ptr( void **dest, void *val )
return retv;
}
long interlocked_xchg_add( long *dest, long incr )
int interlocked_xchg_add( int *dest, int incr )
{
long retv;
int retv;
_lwp_mutex_lock( &interlocked_mutex );
retv = *dest;
*dest += incr;

View File

@ -243,7 +243,7 @@ int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *chan
static char *get_tmp_space( int size )
{
static char *list[32];
static long pos;
static int pos;
char *ret;
int idx;

View File

@ -166,7 +166,7 @@ static inline void writejump( const char *symbol, void *dest )
#define TEMP_STACK_SIZE 1024
#define NB_TEMP_STACKS 8
static char temp_stacks[NB_TEMP_STACKS][TEMP_STACK_SIZE];
static LONG next_temp_stack; /* next temp stack to use */
static int next_temp_stack; /* next temp stack to use */
/***********************************************************************
* get_temp_stack
@ -543,10 +543,10 @@ int pthread_attr_setstack(pthread_attr_t *attr, void *addr, size_t size)
int __pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
{
static pthread_once_t the_once = PTHREAD_ONCE_INIT;
long once_now;
int once_now;
memcpy(&once_now,&the_once,sizeof(once_now));
if (interlocked_cmpxchg((long*)once_control, once_now+1, once_now) == once_now)
if (interlocked_cmpxchg((int*)once_control, once_now+1, once_now) == once_now)
(*init_routine)();
return 0;
}
@ -694,7 +694,7 @@ strong_alias(__pthread_mutexattr_gettype, pthread_mutexattr_gettype);
int __pthread_key_create(pthread_key_t *key, void (*destr_function)(void *))
{
static long keycnt = FIRST_KEY;
static int keycnt = FIRST_KEY;
*key = interlocked_xchg_add(&keycnt, 1);
return 0;
}

View File

@ -55,7 +55,7 @@ struct change
struct list entry; /* entry in global change notifications list */
int subtree; /* watch all the subtree */
unsigned int filter; /* notification filter */
long notified; /* SIGIO counter */
int notified; /* SIGIO counter */
long signaled; /* the file changed */
};