~ubuntu-branches/ubuntu/vivid/atlas/vivid

« back to all changes in this revision

Viewing changes to src/threads/ATL_ResetAtomicCount_ia32.S

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot
  • Date: 2013-06-11 15:58:16 UTC
  • mfrom: (1.1.3 upstream)
  • mto: (2.2.21 experimental)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: package-import@ubuntu.com-20130611155816-b72z8f621tuhbzn0
Tags: upstream-3.10.1
Import upstream version 3.10.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "atlas_asm.h"
 
2
/*
 
3
 * rax                       rdi         rsi
 
4
 * int ATL_ResetAtomicCount(void *vp, int cnt)
 
5
 * Sets vp's acnt=cnt.
 
6
 * RETURNS: acnt before the reset
 
7
 */
 
8
.text
 
9
.global ATL_asmdecor(ATL_ResetAtomicCount)
 
10
ATL_asmdecor(ATL_ResetAtomicCount):
 
11
   movl 4(%esp), %edx
 
12
   movl 8(%esp), %ecx
 
13
   sub $-128, %edx            /* skip false sharing guard zone */
 
14
   ATOMIC_LOOP:
 
15
      movl (%edx), %eax       /* read acnt from memory */
 
16
      lock                    /* make cmpxchg atomic */
 
17
      cmpxchg %ecx, (%edx)   /* put cnt in mem if mem still == acnt in eax */
 
18
      je DONE                 /* ZF set if cmpxchg wrote to mem */
 
19
   jmp ATOMIC_LOOP            /* ZF=0 means cmpxch failed, try again */
 
20
DONE:
 
21
   ret