Skip to content

Commit 1640e3c

Browse files
committed
features: return ErrNotSupportedOnOS on windows
This reverts commit 8d7c47f. Return a sentinel error instead of removing the API outright. This avoids compilation failures on non-Linux platforms. Signed-off-by: Lorenz Bauer <[email protected]>
1 parent 9124d6f commit 1640e3c

File tree

9 files changed

+12
-14
lines changed

9 files changed

+12
-14
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ jobs:
352352
./
353353
./asm
354354
./btf
355+
./features
355356
./internal
356357
./internal/efw
357358
./internal/kallsyms

features/map.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build linux
2-
31
package features
42

53
import (

features/map_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build linux
2-
31
package features
42

53
import (

features/misc.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build linux
2-
31
package features
42

53
import (

features/misc_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build linux
2-
31
package features
42

53
import (

features/prog.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build linux
2-
31
package features
42

53
import (

features/prog_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build linux
2-
31
package features
42

53
import (
@@ -74,6 +72,7 @@ func TestHaveProgramHelper(t *testing.T) {
7472
testutils.SkipOnOldKernel(t, tc.version, feature)
7573

7674
err := HaveProgramHelper(tc.prog, tc.helper)
75+
testutils.SkipIfNotSupportedOnOS(t, err)
7776
if !errors.Is(err, tc.expected) {
7877
t.Fatalf("%s/%s: %v", tc.prog.String(), tc.helper.String(), err)
7978
}

features/version.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build linux
2-
31
package features
42

53
import "github.com/cilium/ebpf/internal/linux"

internal/feature.go

+10
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,18 @@ type FeatureMatrix[K comparable] map[K]*FeatureTest
161161
// Result returns the outcome of the feature test for the given key.
162162
//
163163
// It's safe to call this function concurrently.
164+
//
165+
// Always returns [ErrNotSupportedOnOS] on Windows.
164166
func (fm FeatureMatrix[K]) Result(key K) error {
165167
ft, ok := fm[key]
166168
if !ok {
167169
return fmt.Errorf("no feature probe for %v", key)
168170
}
169171

172+
if platform.IsWindows {
173+
return fmt.Errorf("%s: %w", ft.Name, ErrNotSupportedOnOS)
174+
}
175+
170176
return ft.execute()
171177
}
172178

@@ -187,6 +193,10 @@ func NewFeatureCache[K comparable](newTest func(K) *FeatureTest) *FeatureCache[K
187193
}
188194

189195
func (fc *FeatureCache[K]) Result(key K) error {
196+
if platform.IsWindows {
197+
return fmt.Errorf("feature probe for %v: %w", key, ErrNotSupportedOnOS)
198+
}
199+
190200
// NB: Executing the feature test happens without fc.mu taken.
191201
return fc.retrieve(key).execute()
192202
}

0 commit comments

Comments
 (0)