File: race.go

package info (click to toggle)
golang-github-klauspost-compress 1.17.9%2Bds1-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 46,240 kB
  • sloc: asm: 23,129; sh: 72; makefile: 11
file content (26 lines) | stat: -rw-r--r-- 511 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build race

package race

import (
	"runtime"
	"unsafe"
)

func ReadSlice[T any](s []T) {
	if len(s) == 0 {
		return
	}
	runtime.RaceReadRange(unsafe.Pointer(&s[0]), len(s)*int(unsafe.Sizeof(s[0])))
}

func WriteSlice[T any](s []T) {
	if len(s) == 0 {
		return
	}
	runtime.RaceWriteRange(unsafe.Pointer(&s[0]), len(s)*int(unsafe.Sizeof(s[0])))
}