diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-01-10 06:14:54 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-10 06:14:54 +0000 |
commit | d09b1da02d67a8a51f1b41e0a8e9026218ffa20a (patch) | |
tree | b32df508ac0b9087e3319a1d2b33dfbb86db8ad1 /pkg/sentry/time/seqatomic_parameters_unsafe.go | |
parent | aca2ac5c956a7542eebf50806b0e0171c8caa816 (diff) | |
parent | 27500d529f7fb87eef8812278fd1bbca67bcba72 (diff) |
Merge release-20191213.0-96-g27500d5 (automated)
Diffstat (limited to 'pkg/sentry/time/seqatomic_parameters_unsafe.go')
-rwxr-xr-x | pkg/sentry/time/seqatomic_parameters_unsafe.go | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/pkg/sentry/time/seqatomic_parameters_unsafe.go b/pkg/sentry/time/seqatomic_parameters_unsafe.go index e3c134e49..32820e9ba 100755 --- a/pkg/sentry/time/seqatomic_parameters_unsafe.go +++ b/pkg/sentry/time/seqatomic_parameters_unsafe.go @@ -1,25 +1,24 @@ package time import ( - "strings" - "unsafe" - "fmt" - "gvisor.dev/gvisor/pkg/syncutil" + "gvisor.dev/gvisor/pkg/sync" "reflect" + "strings" + "unsafe" ) // SeqAtomicLoad returns a copy of *ptr, ensuring that the read does not race // with any writer critical sections in sc. -func SeqAtomicLoadParameters(sc *syncutil.SeqCount, ptr *Parameters) Parameters { +func SeqAtomicLoadParameters(sc *sync.SeqCount, ptr *Parameters) Parameters { // This function doesn't use SeqAtomicTryLoad because doing so is // measurably, significantly (~20%) slower; Go is awful at inlining. var val Parameters for { epoch := sc.BeginRead() - if syncutil.RaceEnabled { + if sync.RaceEnabled { - syncutil.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val)) + sync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val)) } else { val = *ptr @@ -35,10 +34,10 @@ func SeqAtomicLoadParameters(sc *syncutil.SeqCount, ptr *Parameters) Parameters // in sc initiated by a call to sc.BeginRead() that returned epoch. If the read // would race with a writer critical section, SeqAtomicTryLoad returns // (unspecified, false). -func SeqAtomicTryLoadParameters(sc *syncutil.SeqCount, epoch syncutil.SeqCountEpoch, ptr *Parameters) (Parameters, bool) { +func SeqAtomicTryLoadParameters(sc *sync.SeqCount, epoch sync.SeqCountEpoch, ptr *Parameters) (Parameters, bool) { var val Parameters - if syncutil.RaceEnabled { - syncutil.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val)) + if sync.RaceEnabled { + sync.Memmove(unsafe.Pointer(&val), unsafe.Pointer(ptr), unsafe.Sizeof(val)) } else { val = *ptr } @@ -49,7 +48,7 @@ func initParameters() { var val Parameters typ := reflect.TypeOf(val) name := typ.Name() - if ptrs := syncutil.PointersInType(typ, name); len(ptrs) != 0 { + if ptrs := sync.PointersInType(typ, name); len(ptrs) != 0 { panic(fmt.Sprintf("SeqAtomicLoad<%s> is invalid since values %s of type %s contain pointers:\n%s", typ, name, typ, strings.Join(ptrs, "\n"))) } } |