Path: blob/master/arch/um/sys-i386/atomic64_cx8_32.S
10818 views
/*1* atomic64_t for 586+2*3* Copied from arch/x86/lib/atomic64_cx8_32.S4*5* Copyright © 2010 Luca Barbieri6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12*/1314#include <linux/linkage.h>15#include <asm/alternative-asm.h>16#include <asm/dwarf2.h>1718.macro SAVE reg19pushl_cfi %\reg20CFI_REL_OFFSET \reg, 021.endm2223.macro RESTORE reg24popl_cfi %\reg25CFI_RESTORE \reg26.endm2728.macro read64 reg29movl %ebx, %eax30movl %ecx, %edx31/* we need LOCK_PREFIX since otherwise cmpxchg8b always does the write */32LOCK_PREFIX33cmpxchg8b (\reg)34.endm3536ENTRY(atomic64_read_cx8)37CFI_STARTPROC3839read64 %ecx40ret41CFI_ENDPROC42ENDPROC(atomic64_read_cx8)4344ENTRY(atomic64_set_cx8)45CFI_STARTPROC46471:48/* we don't need LOCK_PREFIX since aligned 64-bit writes49* are atomic on 586 and newer */50cmpxchg8b (%esi)51jne 1b5253ret54CFI_ENDPROC55ENDPROC(atomic64_set_cx8)5657ENTRY(atomic64_xchg_cx8)58CFI_STARTPROC5960movl %ebx, %eax61movl %ecx, %edx621:63LOCK_PREFIX64cmpxchg8b (%esi)65jne 1b6667ret68CFI_ENDPROC69ENDPROC(atomic64_xchg_cx8)7071.macro addsub_return func ins insc72ENTRY(atomic64_\func\()_return_cx8)73CFI_STARTPROC74SAVE ebp75SAVE ebx76SAVE esi77SAVE edi7879movl %eax, %esi80movl %edx, %edi81movl %ecx, %ebp8283read64 %ebp841:85movl %eax, %ebx86movl %edx, %ecx87\ins\()l %esi, %ebx88\insc\()l %edi, %ecx89LOCK_PREFIX90cmpxchg8b (%ebp)91jne 1b929310:94movl %ebx, %eax95movl %ecx, %edx96RESTORE edi97RESTORE esi98RESTORE ebx99RESTORE ebp100ret101CFI_ENDPROC102ENDPROC(atomic64_\func\()_return_cx8)103.endm104105addsub_return add add adc106addsub_return sub sub sbb107108.macro incdec_return func ins insc109ENTRY(atomic64_\func\()_return_cx8)110CFI_STARTPROC111SAVE ebx112113read64 %esi1141:115movl %eax, %ebx116movl %edx, %ecx117\ins\()l $1, %ebx118\insc\()l $0, %ecx119LOCK_PREFIX120cmpxchg8b (%esi)121jne 1b12212310:124movl %ebx, %eax125movl %ecx, %edx126RESTORE ebx127ret128CFI_ENDPROC129ENDPROC(atomic64_\func\()_return_cx8)130.endm131132incdec_return inc add adc133incdec_return dec sub sbb134135ENTRY(atomic64_dec_if_positive_cx8)136CFI_STARTPROC137SAVE ebx138139read64 %esi1401:141movl %eax, %ebx142movl %edx, %ecx143subl $1, %ebx144sbb $0, %ecx145js 2f146LOCK_PREFIX147cmpxchg8b (%esi)148jne 1b1491502:151movl %ebx, %eax152movl %ecx, %edx153RESTORE ebx154ret155CFI_ENDPROC156ENDPROC(atomic64_dec_if_positive_cx8)157158ENTRY(atomic64_add_unless_cx8)159CFI_STARTPROC160SAVE ebp161SAVE ebx162/* these just push these two parameters on the stack */163SAVE edi164SAVE esi165166movl %ecx, %ebp167movl %eax, %esi168movl %edx, %edi169170read64 %ebp1711:172cmpl %eax, 0(%esp)173je 4f1742:175movl %eax, %ebx176movl %edx, %ecx177addl %esi, %ebx178adcl %edi, %ecx179LOCK_PREFIX180cmpxchg8b (%ebp)181jne 1b182183movl $1, %eax1843:185addl $8, %esp186CFI_ADJUST_CFA_OFFSET -8187RESTORE ebx188RESTORE ebp189ret1904:191cmpl %edx, 4(%esp)192jne 2b193xorl %eax, %eax194jmp 3b195CFI_ENDPROC196ENDPROC(atomic64_add_unless_cx8)197198ENTRY(atomic64_inc_not_zero_cx8)199CFI_STARTPROC200SAVE ebx201202read64 %esi2031:204testl %eax, %eax205je 4f2062:207movl %eax, %ebx208movl %edx, %ecx209addl $1, %ebx210adcl $0, %ecx211LOCK_PREFIX212cmpxchg8b (%esi)213jne 1b214215movl $1, %eax2163:217RESTORE ebx218ret2194:220testl %edx, %edx221jne 2b222jmp 3b223CFI_ENDPROC224ENDPROC(atomic64_inc_not_zero_cx8)225226227