Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7621
Modified Files:
Tag: devel_0_38
m_fifo.c
Log Message:
cas/cas2 for msvc
Index: m_fifo.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/m_fifo.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** m_fifo.c 2 Dec 2004 15:17:51 -0000 1.1.2.1
--- m_fifo.c 2 Dec 2004 19:19:53 -0000 1.1.2.2
***************
*** 16,20 ****
!
--- 16,20 ----
! #define LOCKFREE
***************
*** 26,49 ****
*/
- /* for gcc on i386 */
#if defined(__GNUC__) && (defined(_X86_) || defined(__i386__) || defined(__i586__) || defined(__i686__))
! #define CAS(mem, old, new) \
! ({ __asm__ __volatile__( \
! "lock cmpxchg %2,%0 \n" \
! : : \
! "m" (mem), "a" (old), "r" (new) ); \
! old != (__typeof__(old))(mem); \
})
! #define CAS2(mem, old1, old2, new1, new2) \
! ({ __asm__ __volatile__( \
! "lock cmpxchg8b %0 \n" \
! : : \
! "m" (mem), "a" (old1), "d" (old2), \
! "b" (new1), "c"(new2)); \
! old1 != (__typeof__(old1)) (mem); \
})
#else
--- 26,78 ----
*/
#if defined(__GNUC__) && (defined(_X86_) || defined(__i386__) || defined(__i586__) || defined(__i686__))
! /* gcc on i386 */
!
! #define CAS(mem, old, new) \
! ({ __asm__ __volatile__( \
! "lock cmpxchg %2,%0 \n" \
! : : \
! "m" (*mem), "a" (old), "r" (new) ); \
! (void*)old != (void*)(*mem); \
})
! #define CAS2(mem, old1, old2, new1, new2) \
! ({ __asm__ __volatile__( \
! "lock cmpxchg8b %0 \n" \
! : : \
! "m" (*mem), "a" (old1), "d" (old2), \
! "b" (new1), "c"(new2)); \
! (void*) old1 != (void*) (*mem); \
})
+ #elif defined(NT) && defined(_MSC_VER)
+
+ /* msvc on i386 */
+
+ __inline int CAS(void** mem, void* old, void* new1)
+ {
+ __asm {
+ mov eax, old
+ mov ebx, new1
+ mov esi, mem
+ lock cmpxchg dword ptr [esi], ebx
+ }
+ return ((void*) old != (void*)(*mem));
+ }
+
+ __inline int CAS2(void** mem, void* old1, void* old2, void* new1, void* new2)
+ {
+ __asm {
+ mov eax, old1
+ mov edx, old2
+ mov ebx, new1
+ mov ecx, new2
+ mov esi, mem
+ lock cmpxchg8b qword ptr [esi]
+ }
+ return ((void*) old1 != (void*)(*mem));
+ }
+
#else
***************
*** 52,56 ****
#endif
-
struct _fifo
{
--- 81,84 ----
***************
*** 108,118 ****
tail = fifo->tail;
! if (CAS(tail->next, NULL, cell))
break;
else
! CAS2(fifo->tail, tail, icount, tail->next, icount + 1);
}
! CAS2(fifo->tail, tail, icount, cell, icount +1);
return;
}
--- 136,146 ----
tail = fifo->tail;
! if (CAS(&tail->next, NULL, cell))
break;
else
! CAS2(&fifo->tail, tail, icount, tail->next, icount + 1);
}
! CAS2(&fifo->tail, tail, icount, cell, icount +1);
return;
}
***************
*** 142,151 ****
if (next == NULL)
return NULL;
! CAS2(fifo->tail, head, icount, next, icount + 1);
}
else
{
data = next->data;
! if (CAS2(fifo->head, head, ocount, next, ocount+1))
break;
}
--- 170,179 ----
if (next == NULL)
return NULL;
! CAS2(&fifo->tail, head, icount, next, icount + 1);
}
else
{
data = next->data;
! if (CAS2(&fifo->head, head, ocount, next, ocount+1))
break;
}