Skip to content

Commit 23dbbb0

Browse files
committed
Add Extensions to VgpuTypeID
Signed-off-by: Evan Lezar <[email protected]>
1 parent 4871684 commit 23dbbb0

File tree

6 files changed

+102
-4
lines changed

6 files changed

+102
-4
lines changed

gen/nvml/generateapi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ var GeneratableInterfaces = []GeneratableInterfacePoperties{
7777
{
7878
Type: "nvmlVgpuTypeId",
7979
Interface: "VgpuTypeId",
80+
Exclude: []string{"ID"},
8081
},
8182
}
8283

pkg/nvml/api.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ type ExtendedInterface interface {
2727
LookupSymbol(string) error
2828
}
2929

30+
//go:generate moq -rm -out mock/extendedvgputypeid.go -pkg mock . ExtendedVgpuTypeId:ExtendedVgpuTypeId
31+
type ExtendedVgpuTypeId interface {
32+
ID() uint32
33+
}
34+
3035
// libraryOptions hold the paramaters than can be set by a LibraryOption
3136
type libraryOptions struct {
3237
path string

pkg/nvml/cgo_helpers_static.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,3 @@ func unpackPCharString(str string) (*C.char, *struct{}) {
7373
h := (*stringHeader)(unsafe.Pointer(&str))
7474
return (*C.char)(h.Data), cgoAllocsUnknown
7575
}
76-
77-
func VgpuTypeIdToUint32(typeId VgpuTypeId) uint32 {
78-
return uint32(typeId.(nvmlVgpuTypeId))
79-
}

pkg/nvml/mock/extendedvgputypeid.go

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/nvml/vgpu_extensions.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package nvml
16+
17+
func (vgpuTypeId *nvmlVgpuTypeId) Extensions() ExtendedVgpuTypeId {
18+
return vgpuTypeId
19+
}
20+
21+
// ID returns the numeric representaion of the vgpuTypeId.
22+
func (vgpuTypeId *nvmlVgpuTypeId) ID() uint32 {
23+
if vgpuTypeId == nil {
24+
return 0
25+
}
26+
return uint32(*vgpuTypeId)
27+
}

pkg/nvml/zz_generated.api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,7 @@ type VgpuInstance interface {
990990
//
991991
//go:generate moq -out mock/vgputypeid.go -pkg mock . VgpuTypeId:VgpuTypeId
992992
type VgpuTypeId interface {
993+
Extensions() ExtendedVgpuTypeId
993994
GetCapabilities(VgpuCapability) (bool, Return)
994995
GetClass() (string, Return)
995996
GetCreatablePlacements(Device) (VgpuPlacementList, Return)

0 commit comments

Comments
 (0)