aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/decl.go15
-rw-r--r--sys/decl_test.go13
2 files changed, 24 insertions, 4 deletions
diff --git a/sys/decl.go b/sys/decl.go
index 322158b92..d09328c91 100644
--- a/sys/decl.go
+++ b/sys/decl.go
@@ -437,10 +437,8 @@ func TransitivelyEnabledCalls(enabled map[*Call]bool) map[*Call]bool {
}
for {
n := len(supported)
- for c := range enabled {
- if !supported[c] {
- continue
- }
+ haveGettime := supported[CallMap["clock_gettime"]]
+ for c := range supported {
canCreate := true
for _, res := range c.InputResources() {
noctors := true
@@ -455,6 +453,15 @@ func TransitivelyEnabledCalls(enabled map[*Call]bool) map[*Call]bool {
break
}
}
+ // We need to support structs as resources,
+ // but for now we just special-case timespec/timeval.
+ if canCreate && !haveGettime {
+ ForeachType(c, func(typ Type) {
+ if a, ok := typ.(*StructType); ok && a.Dir() != DirOut && (a.Name() == "timespec" || a.Name() == "timeval") {
+ canCreate = false
+ }
+ })
+ }
if !canCreate {
delete(supported, c)
}
diff --git a/sys/decl_test.go b/sys/decl_test.go
index a5c1d7be4..7c64f28fe 100644
--- a/sys/decl_test.go
+++ b/sys/decl_test.go
@@ -33,3 +33,16 @@ func TestTransitivelyEnabledCalls(t *testing.T) {
t.Fatalf("epoll fd is not disabled")
}
}
+
+func TestClockGettime(t *testing.T) {
+ calls := make(map[*Call]bool)
+ for _, c := range Calls {
+ calls[c] = true
+ }
+ // Removal of clock_gettime should disable all calls that accept timespec/timeval.
+ delete(calls, CallMap["clock_gettime"])
+ trans := TransitivelyEnabledCalls(calls)
+ if len(trans)+10 > len(calls) {
+ t.Fatalf("clock_gettime did not disable enough calls: before %v, after %v", len(calls), len(trans))
+ }
+}