sync.go 644 B

12345678910111213141516171819202122
  1. // Copyright 2021 The Libc Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //go:build !(linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm))
  5. package libc // import "modernc.org/libc"
  6. import (
  7. "sync/atomic"
  8. )
  9. var __sync_synchronize_dummy int32
  10. // __sync_synchronize();
  11. func X__sync_synchronize(t *TLS) {
  12. if __ccgo_strace {
  13. trc("t=%v, (%v:)", t, origin(2))
  14. }
  15. // Attempt to implement a full memory barrier without assembler.
  16. atomic.StoreInt32(&__sync_synchronize_dummy, atomic.LoadInt32(&__sync_synchronize_dummy)+1)
  17. }