From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Wed, 14 May 2014 16:34:48 -0400 To: 9fans@9fans.net Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] ainc() 386/amd64 differences Topicbox-Message-UUID: e652b008-ead8-11e9-9d60-3106f5b1d025 for 386, libc has this definition for ainc TEXT ainc(SB), $0 /* int ainc(int *); */ MOVL addr+0(FP), BX ainclp: MOVL (BX), AX MOVL AX, CX INCL CX LOCK BYTE $0x0F; BYTE $0xB1; BYTE $0x0B /* CMPXCHGL CX, (BX) */ JNZ ainclp MOVL CX, AX RET the amd64 kernel has had this definition (the pc kernel doesn't define ainc) TEXT ainc(SB), 1, $-4 MOVL $1, AX LOCK; XADDL AX, (RARG) ADDL $1, AX /* overflow if -ve or 0 */ JGT _return _trap: XORQ BX, BX MOVQ (BX), BX /* over under sideways down */ _return: RET these are substantially different in two ways. - the first is not wait free. the second may be wait free. - the second is geared toward reference counting, and will trap instead of wrapping. it can't be used for generating a unique sequence. i'd like to see the amd64 kernel version replace incref, and this version of ainc TEXT ainc(SB), 1, $-4 TEXT ainc32(SB), 1, $-4 MOVL $1, AX LOCK; XADDL AX, (RARG) INCL AX RET what does the list think? - erik