diff options
author | Emile <git@emile.space> | 2024-08-16 19:50:26 +0200 |
---|---|---|
committer | Emile <git@emile.space> | 2024-08-16 19:50:26 +0200 |
commit | 1a57267a17c2fc17fb6e104846fabc3e363c326c (patch) | |
tree | 1e574e3a80622086dc3c81ff9cba65ef7049b1a9 /vendor/modernc.org/libc/libc_ppc64le.go |
initial commit
Diffstat (limited to 'vendor/modernc.org/libc/libc_ppc64le.go')
-rw-r--r-- | vendor/modernc.org/libc/libc_ppc64le.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/modernc.org/libc/libc_ppc64le.go b/vendor/modernc.org/libc/libc_ppc64le.go new file mode 100644 index 0000000..de3e349 --- /dev/null +++ b/vendor/modernc.org/libc/libc_ppc64le.go @@ -0,0 +1,38 @@ +// Copyright 2023 The Libc Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package libc // import "modernc.org/libc" + +import ( + "fmt" + "unsafe" +) + +// Byte loads are atomic on this CPU. +func a_load_8(addr uintptr) uint32 { + return uint32(*(*byte)(unsafe.Pointer(addr))) +} + +// int16 loads are atomic on this CPU when properly aligned. +func a_load_16(addr uintptr) uint32 { + if addr&1 != 0 { + panic(fmt.Errorf("unaligned atomic 16 bit access at %#0x", addr)) + } + + return uint32(*(*uint16)(unsafe.Pointer(addr))) +} + +// Byte sores are atomic on this CPU. +func a_store_8(addr uintptr, b byte) { + *(*byte)(unsafe.Pointer(addr)) = b +} + +// int16 stores are atomic on this CPU when properly aligned. +func a_store_16(addr uintptr, n uint16) { + if addr&1 != 0 { + panic(fmt.Errorf("unaligned atomic 16 bit access at %#0x", addr)) + } + + *(*uint16)(unsafe.Pointer(addr)) = n +} |