[PATCH?] Separate pthread patches, #2 take 3

Dave Korn dave.korn.cygwin@googlemail.com
Wed Jun 3 23:36:00 GMT 2009


Dave Korn wrote:
>   The attached patch implements ilockexch and ilockcmpexch, using the inline
> asm definition from __arch_compare_and_exchange_val_32_acq in
> glibc-2.10.1/sysdeps/i386/i486/bits/atomic.h, trivially expanded inline rather
> than in its original preprocessor macro form.

  The attached patch does likewise, but adds a "memory" clobber.  It generates
correct code:

L186:
	.loc 3 127 0
	movl	__ZN13pthread_mutex7mutexesE+8, %eax	 # mutexes.head, D.28599
	movl	%eax, 36(%ebx)	 # D.28599, <variable>.next
	.loc 2 60 0
/APP
 # 60 "/gnu/winsup/src/winsup/cygwin/winbase.h" 1
	lock cmpxchgl %ebx, __ZN13pthread_mutex7mutexesE+8	 # this,
 # 0 "" 2
/NO_APP
	movl	%eax, -12(%ebp)	 # tmp68, ret
	.loc 2 61 0
	movl	-12(%ebp), %eax	 # ret, D.28596
	.loc 3 126 0
	cmpl	%eax, 36(%ebx)	 # D.28596, <variable>.next
	jne	L186	 #,


although as you see it has some needless register motion as it stores %eax to
the stack slot for ret and reloads it.  Still, this is now almost as good as
the code generated by my original patch.

winsup/cygwin/ChangeLog

	* winbase.h (ilockexch):  Fix asm constraints.
	(ilockcmpexch):  Likewise.


  Ok-ish?

    cheers,
      DaveK

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pthread-interlocked-asms-v3.diff
Type: text/x-c
Size: 1246 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20090603/4f6c2f28/attachment.bin>


More information about the Cygwin-patches mailing list