diff options
author | Rahat Mahmood <rahat@google.com> | 2018-05-17 15:05:15 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-05-17 15:06:19 -0700 |
commit | 8878a66a565733493e702199b284cd7855f80bf0 (patch) | |
tree | eb17447b112fabb267a031ca6ec60aa0e7fd7890 /pkg/sentry/context | |
parent | a8d7cee3e819f0e278c8da9ff2e7d72fbe0e82b8 (diff) |
Implement sysv shm.
PiperOrigin-RevId: 197058289
Change-Id: I3946c25028b7e032be4894d61acb48ac0c24d574
Diffstat (limited to 'pkg/sentry/context')
-rw-r--r-- | pkg/sentry/context/context.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/sentry/context/context.go b/pkg/sentry/context/context.go index e0dffafba..598c5b4ff 100644 --- a/pkg/sentry/context/context.go +++ b/pkg/sentry/context/context.go @@ -20,6 +20,26 @@ import ( "gvisor.googlesource.com/gvisor/pkg/log" ) +type contextID int + +// Globally accessible values from a context. These keys are defined in the +// context package to resolve dependency cycles by not requiring the caller to +// import packages usually required to get these information. +const ( + // CtxThreadGroupID is the current thread group ID when a context represents + // a task context. The value is represented as an int32. + CtxThreadGroupID contextID = iota +) + +// ThreadGroupIDFromContext returns the current thread group ID when ctx +// represents a task context. +func ThreadGroupIDFromContext(ctx Context) (tgid int32, ok bool) { + if tgid := ctx.Value(CtxThreadGroupID); tgid != nil { + return tgid.(int32), true + } + return 0, false +} + // A Context represents a thread of execution (hereafter "goroutine" to reflect // Go idiosyncrasy). It carries state associated with the goroutine across API // boundaries. |