1
0
Fork 0
mirror of https://github.com/ii64/gouring.git synced 2025-04-01 03:41:44 +02:00

feat: seq_cst implementation

This commit is contained in:
Xeffy Chen 2022-10-13 22:08:46 +07:00
parent 527c11cde6
commit 1abd875eb9
Signed by: Xeffy
GPG key ID: E41C08AD390E7C49
3 changed files with 27 additions and 1 deletions

13
atomic.go Normal file
View file

@ -0,0 +1,13 @@
package gouring
import _ "unsafe"
var io_uring_smp_mb = io_uring_smp_mb_fallback
func io_uring_smp_mb_fallback()
func io_uring_smp_mb_mfence()
func init() {
// temporary
io_uring_smp_mb = io_uring_smp_mb_mfence
}

12
atomic_amd64.s Normal file
View file

@ -0,0 +1,12 @@
#include "go_asm.h"
#include "funcdata.h"
#include "textflag.h"
TEXT ·io_uring_smp_mb_fallback(SB), NOSPLIT, $0
LOCK
ORQ $0, 0(SP)
RET
TEXT ·io_uring_smp_mb_mfence(SB), NOSPLIT, $0
MFENCE
RET

View file

@ -19,7 +19,8 @@ func (ring *IoUring) sq_ring_needs_enter(flags *uint32) bool {
return true
}
// FIXME: io_uring_smp_mb
// FIXME: Extra call - no inline asm.
io_uring_smp_mb()
if atomic.LoadUint32(ring.Sq._Flags())&IORING_SQ_NEED_WAKEUP != 0 {
*flags |= IORING_ENTER_SQ_WAKEUP