[PD-cvs] pd/src m_fifo.c,1.1.2.12,1.1.2.13

Tim Blechmann timblech at users.sourceforge.net
Mon May 9 15:26:50 CEST 2005


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8096

Modified Files:
      Tag: devel_0_38
	m_fifo.c 
Log Message:
lockfree fifos for amd64 architecture (not working for all revisions)

Index: m_fifo.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/m_fifo.c,v
retrieving revision 1.1.2.12
retrieving revision 1.1.2.13
diff -C2 -d -r1.1.2.12 -r1.1.2.13
*** m_fifo.c	6 May 2005 09:33:52 -0000	1.1.2.12
--- m_fifo.c	9 May 2005 13:26:47 -0000	1.1.2.13
***************
*** 327,330 ****
--- 327,382 ----
  }
  
+ #elif defined(__GNUC__)  && defined(__x86_64__)
+ 
+ /* this will not work for all revisions of the amd64 architecture ... */
+ 
+ static void* lifo_pop(t_lifo* lifo)
+ {
+ 	void * data = 0;
+ 	__asm__ __volatile__ (
+ 		"# LFPOP 					\n\t"
+ 		"push	%%rbx				\n\t"
+ 		"push	%%rcx				\n\t"
+ 		"mov 	8(%%rdi), %%rdx		\n\t"
+ 		"mov  	(%%rdi), %%rax		\n\t"	
+ 		"test	%%rax, %%rax		\n\t"
+ 		"jz		20f					\n"
+ 		"10:\t"
+ 		"mov 	(%%rax), %%rbx		\n\t"
+ 		"mov	%%rdx, %%rcx		\n\t"
+ 		"inc	%%rcx				\n\t"
+ 		LOCK "cmpxchg16b (%%rdi)		\n\t"
+ 		"jz		20f					\n\t"
+ 		"test	%%rax, %%rax		\n\t"
+ 		"jnz	10b					\n"
+ 		"20:\t"
+ 		"pop	%%rcx				\n\t"
+ 		"pop	%%rbx				\n\t"
+ 		:"=a" (data)
+ 		:"S" (&lifo->top)
+ 		:"memory", "rdx");
+ 	return data;			 
+ }
+ 
+ static void lifo_push(t_lifo * lifo, void * data) 
+ {
+ 	__asm__ __volatile__ (
+ 		"# LFPUSH					\n\t"
+ 		"push	%%rbx				\n\t"
+ 		"push	%%rcx				\n\t"
+ 		"mov 0(%%rdi), %%rax		\n\t"
+ 		"mov 8(%%rdi), %%rdx		\n"	
+ 		"1:\t"
+ 		"mov %%rax, %%rbx			\n\t"
+ 		"inc %%rbx					\n\t"
+ 		"mov %%rdx, (%%rcx)		\n\t"
+ 		LOCK "cmpxchg16b (%%rdi)		\n\t"
+ 		"jnz	1b					\n\t"
+ 		"pop	%%rcx				\n\t"
+ 		"pop	%%rbx				\n\t"
+ 		:/* no output */
+ 		:"S" (lifo), "c" (data)
+ 		:"memory", "rax", "rdx");
+ }
  
  #elif defined(__Windows__)





More information about the Pd-cvs mailing list