Skip to content

Commit d020314

Browse files
feat: support zig 0.14
1 parent c746129 commit d020314

File tree

10 files changed

+54
-57
lines changed

10 files changed

+54
-57
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
zig-cache
1+
.zig-cache
22
zig-out

build.zig

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ pub fn build(b: *std.Build) void {
77
const no_tests = b.option(bool, "no-tests", "skip generating tests") orelse false;
88

99
const module = b.addModule("libdrm", .{
10-
.root_source_file = .{ .path = b.pathFromRoot("libdrm.zig") },
10+
.root_source_file = b.path("libdrm.zig"),
1111
});
1212

1313
const exe_example = b.addExecutable(.{
1414
.name = "example",
15-
.root_source_file = .{
16-
.path = b.pathFromRoot("example.zig"),
17-
},
15+
.root_source_file = b.path("example.zig"),
1816
.target = target,
1917
.optimize = optimize,
2018
});
@@ -25,9 +23,7 @@ pub fn build(b: *std.Build) void {
2523
const step_test = b.step("test", "Run all unit tests");
2624

2725
const unit_tests = b.addTest(.{
28-
.root_source_file = .{
29-
.path = b.pathFromRoot("libdrm.zig"),
30-
},
26+
.root_source_file = b.path("libdrm.zig"),
3127
.target = target,
3228
.optimize = optimize,
3329
});

build.zig.zon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.{
2-
.name = "libdrm.zig",
2+
.name = .libdrm,
33
.version = "0.1.0",
4+
.fingerprint = 0xaa2d215b2d787d89,
45
.paths = .{"."},
56
}

libdrm/node.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub const Iterator = struct {
6262
};
6363

6464
allocator: Allocator,
65-
fd: std.os.fd_t,
65+
fd: std.posix.fd_t,
6666

6767
pub fn open(alloc: Allocator, name: ?[]const u8, busid: ?[]const u8) !Self {
6868
return openWithType(alloc, name, busid, .primary);
@@ -80,7 +80,7 @@ pub fn openWithType(alloc: Allocator, name: ?[]const u8, busid: ?[]const u8, t:
8080
pub fn openMinor(alloc: Allocator, minor: u8, t: Type) !Self {
8181
const devName = t.getDeviceName() orelse return error.InvalidType;
8282

83-
var buff = [_]u8{0} ** std.os.PATH_MAX;
83+
var buff = [_]u8{0} ** std.posix.PATH_MAX;
8484
_ = try std.fmt.bufPrint(&buff, "/dev/dri/{s}{}", .{ devName, minor });
8585

8686
var end: usize = 0;
@@ -137,7 +137,7 @@ pub fn openBy(alloc: Allocator, kindValue: []const u8, kind: Kind, t: Type) !Sel
137137
}
138138

139139
pub fn deinit(self: *const Self) void {
140-
std.os.close(self.fd);
140+
std.posix.close(self.fd);
141141
}
142142

143143
pub fn getVersion(self: *const Self) !types.Version {

libdrm/types/base.zig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ pub const Unique = extern struct {
99
pub const reqGet = os.IOCTL.IOWR(0x1, Unique);
1010
pub const reqSet = os.IOCTL.IOWR(0x10, Unique);
1111

12-
pub fn get(self: *Unique, fd: std.os.fd_t) !void {
13-
return switch (std.os.errno(os.ioctl(fd, reqGet, @intFromPtr(self)))) {
12+
pub fn get(self: *Unique, fd: std.posix.fd_t) !void {
13+
return switch (std.posix.errno(os.ioctl(fd, reqGet, @intFromPtr(self)))) {
1414
.SUCCESS => {},
1515
.BADF => error.NotOpenForWriting,
1616
.NOENT => error.NotFound,
1717
.FAULT => unreachable,
1818
.INVAL => unreachable,
1919
.NOTTY => error.NotATerminal,
20-
else => |e| std.os.unexpectedErrno(e),
20+
else => |e| std.posix.unexpectedErrno(e),
2121
};
2222
}
2323

24-
pub fn set(self: *Unique, fd: std.os.fd_t) !void {
25-
return switch (std.os.errno(os.ioctl(fd, reqSet, @intFromPtr(self)))) {
24+
pub fn set(self: *Unique, fd: std.posix.fd_t) !void {
25+
return switch (std.posix.errno(os.ioctl(fd, reqSet, @intFromPtr(self)))) {
2626
.SUCCESS => {},
2727
.BADF => error.NotOpenForWriting,
2828
.NOENT => error.NotFound,
2929
.FAULT => unreachable,
3030
.INVAL => unreachable,
3131
.NOTTY => error.NotATerminal,
32-
else => |e| std.os.unexpectedErrno(e),
32+
else => |e| std.posix.unexpectedErrno(e),
3333
};
3434
}
3535

36-
pub fn getAllocated(self: *Unique, fd: std.os.fd_t, alloc: Allocator) !void {
36+
pub fn getAllocated(self: *Unique, fd: std.posix.fd_t, alloc: Allocator) !void {
3737
try self.get(fd);
3838

3939
errdefer self.deinit(alloc);
@@ -63,15 +63,15 @@ pub const SetVersion = extern struct {
6363

6464
pub const req = os.IOCTL.IOWR(0x7, SetVersion);
6565

66-
pub fn set(self: *Version, fd: std.os.fd_t) !void {
67-
return switch (std.os.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
66+
pub fn set(self: *Version, fd: std.posix.fd_t) !void {
67+
return switch (std.posix.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
6868
.SUCCESS => {},
6969
.BADF => error.NotOpenForWriting,
7070
.NOENT => error.NotFound,
7171
.FAULT => unreachable,
7272
.INVAL => unreachable,
7373
.NOTTY => error.NotATerminal,
74-
else => |e| std.os.unexpectedErrno(e),
74+
else => |e| std.posix.unexpectedErrno(e),
7575
};
7676
}
7777
};
@@ -89,19 +89,19 @@ pub const Version = extern struct {
8989

9090
pub const req = os.IOCTL.IOWR(0, Version);
9191

92-
pub fn get(self: *Version, fd: std.os.fd_t) !void {
93-
return switch (std.os.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
92+
pub fn get(self: *Version, fd: std.posix.fd_t) !void {
93+
return switch (std.posix.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
9494
.SUCCESS => {},
9595
.BADF => error.NotOpenForWriting,
9696
.NOENT => error.NotFound,
9797
.FAULT => unreachable,
9898
.INVAL => unreachable,
9999
.NOTTY => error.NotATerminal,
100-
else => |e| std.os.unexpectedErrno(e),
100+
else => |e| std.posix.unexpectedErrno(e),
101101
};
102102
}
103103

104-
pub fn getAllocated(self: *Version, fd: std.os.fd_t, alloc: Allocator) !void {
104+
pub fn getAllocated(self: *Version, fd: std.posix.fd_t, alloc: Allocator) !void {
105105
try self.get(fd);
106106

107107
errdefer self.deinit(alloc);

libdrm/types/mode.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ pub const ModeGetEncoder = extern struct {
5151

5252
pub const req = os.IOCTL.IOWR(0xA6, ModeGetEncoder);
5353

54-
pub fn get(self: *ModeGetEncoder, fd: std.os.fd_t) !void {
55-
return switch (std.os.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
54+
pub fn get(self: *ModeGetEncoder, fd: std.posix.fd_t) !void {
55+
return switch (std.posix.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
5656
.SUCCESS => {},
5757
.BADF => error.NotOpenForWriting,
5858
.NOENT => error.NotFound,
5959
.FAULT => unreachable,
6060
.INVAL => unreachable,
6161
.NOTTY => error.NotATerminal,
6262
.OPNOTSUPP => error.NotSupported,
63-
else => |e| std.os.unexpectedErrno(e),
63+
else => |e| std.posix.unexpectedErrno(e),
6464
};
6565
}
6666
};
@@ -81,16 +81,16 @@ pub const ModeCardRes = extern struct {
8181

8282
pub const req = os.IOCTL.IOWR(0xA0, ModeCardRes);
8383

84-
pub fn get(self: *ModeCardRes, fd: std.os.fd_t) !void {
85-
return switch (std.os.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
84+
pub fn get(self: *ModeCardRes, fd: std.posix.fd_t) !void {
85+
return switch (std.posix.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
8686
.SUCCESS => {},
8787
.BADF => error.NotOpenForWriting,
8888
.NOENT => error.NotFound,
8989
.FAULT => unreachable,
9090
.INVAL => unreachable,
9191
.NOTTY => error.NotATerminal,
9292
.OPNOTSUPP => error.NotSupported,
93-
else => |e| std.os.unexpectedErrno(e),
93+
else => |e| std.posix.unexpectedErrno(e),
9494
};
9595
}
9696

@@ -99,7 +99,7 @@ pub const ModeCardRes = extern struct {
9999
return @as([*]T, @ptrFromInt(@field(self, @tagName(field))))[0..count];
100100
}
101101

102-
pub fn getAllocated(self: *ModeCardRes, fd: std.os.fd_t, alloc: Allocator) !void {
102+
pub fn getAllocated(self: *ModeCardRes, fd: std.posix.fd_t, alloc: Allocator) !void {
103103
try self.get(fd);
104104

105105
errdefer self.deinit(alloc);

libdrm/types/mode/conn.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ pub const ModeGetConnector = extern struct {
2323

2424
pub const req = os.IOCTL.IOWR(0xA7, ModeGetConnector);
2525

26-
pub fn get(self: *ModeGetConnector, fd: std.os.fd_t) !void {
27-
return switch (std.os.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
26+
pub fn get(self: *ModeGetConnector, fd: std.posix.fd_t) !void {
27+
return switch (std.posix.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
2828
.SUCCESS => {},
2929
.BADF => error.NotOpenForWriting,
3030
.NOENT => error.NotFound,
3131
.FAULT => unreachable,
3232
.INVAL => unreachable,
3333
.NOTTY => error.NotATerminal,
3434
.OPNOTSUPP => error.NotSupported,
35-
else => |e| std.os.unexpectedErrno(e),
35+
else => |e| std.posix.unexpectedErrno(e),
3636
};
3737
}
3838

39-
pub fn getAllocated(self: *ModeGetConnector, fd: std.os.fd_t, alloc: Allocator) !void {
39+
pub fn getAllocated(self: *ModeGetConnector, fd: std.posix.fd_t, alloc: Allocator) !void {
4040
try self.get(fd);
4141

4242
errdefer self.deinit(alloc);

libdrm/types/mode/crtc.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,29 @@ pub const ModeGetCrtc = extern struct {
4040
pub const reqGet = os.IOCTL.IOWR(0xA1, ModeGetCrtc);
4141
pub const reqSet = os.IOCTL.IOWR(0xA2, ModeGetCrtc);
4242

43-
pub fn get(self: *ModeGetCrtc, fd: std.os.fd_t) !void {
44-
return switch (std.os.errno(os.ioctl(fd, reqGet, @intFromPtr(self)))) {
43+
pub fn get(self: *ModeGetCrtc, fd: std.posix.fd_t) !void {
44+
return switch (std.posix.errno(os.ioctl(fd, reqGet, @intFromPtr(self)))) {
4545
.SUCCESS => {},
4646
.BADF => error.NotOpenForWriting,
4747
.NOENT => error.NotFound,
4848
.FAULT => unreachable,
4949
.INVAL => unreachable,
5050
.NOTTY => error.NotATerminal,
5151
.OPNOTSUPP => error.NotSupported,
52-
else => |e| std.os.unexpectedErrno(e),
52+
else => |e| std.posix.unexpectedErrno(e),
5353
};
5454
}
5555

56-
pub fn set(self: *const ModeGetCrtc, fd: std.os.fd_t) !void {
57-
return switch (std.os.errno(os.ioctl(fd, reqSet, @intFromPtr(self)))) {
56+
pub fn set(self: *const ModeGetCrtc, fd: std.posix.fd_t) !void {
57+
return switch (std.posix.errno(os.ioctl(fd, reqSet, @intFromPtr(self)))) {
5858
.SUCCESS => {},
5959
.BADF => error.NotOpenForWriting,
6060
.NOENT => error.NotFound,
6161
.FAULT => unreachable,
6262
.INVAL => unreachable,
6363
.NOTTY => error.NotATerminal,
6464
.OPNOTSUPP => error.NotSupported,
65-
else => |e| std.os.unexpectedErrno(e),
65+
else => |e| std.posix.unexpectedErrno(e),
6666
};
6767
}
6868

libdrm/types/mode/fb.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,29 @@ pub const ModeFbCmd2 = extern struct {
6868
pub const reqAdd = os.IOCTL.IOWR(0xB8, ModeFbCmd2);
6969
pub const reqGet = os.IOCTL.IOWR(0xCE, ModeFbCmd2);
7070

71-
pub fn get(self: *ModeFbCmd2, fd: std.os.fd_t) !void {
72-
return switch (std.os.errno(os.ioctl(fd, reqGet, @intFromPtr(self)))) {
71+
pub fn get(self: *ModeFbCmd2, fd: std.posix.fd_t) !void {
72+
return switch (std.posix.errno(os.ioctl(fd, reqGet, @intFromPtr(self)))) {
7373
.SUCCESS => {},
7474
.BADF => error.NotOpenForWriting,
7575
.NOENT => error.NotFound,
7676
.FAULT => unreachable,
7777
.INVAL => unreachable,
7878
.NOTTY => error.NotATerminal,
7979
.OPNOTSUPP => error.NotSupported,
80-
else => |e| std.os.unexpectedErrno(e),
80+
else => |e| std.posix.unexpectedErrno(e),
8181
};
8282
}
8383

84-
pub fn add(self: *ModeFbCmd2, fd: std.os.fd_t) !void {
85-
return switch (std.os.errno(os.ioctl(fd, reqAdd, @intFromPtr(self)))) {
84+
pub fn add(self: *ModeFbCmd2, fd: std.posix.fd_t) !void {
85+
return switch (std.posix.errno(os.ioctl(fd, reqAdd, @intFromPtr(self)))) {
8686
.SUCCESS => {},
8787
.BADF => error.NotOpenForWriting,
8888
.NOENT => error.NotFound,
8989
.FAULT => unreachable,
9090
.INVAL => unreachable,
9191
.NOTTY => error.NotATerminal,
9292
.OPNOTSUPP => error.NotSupported,
93-
else => |e| std.os.unexpectedErrno(e),
93+
else => |e| std.posix.unexpectedErrno(e),
9494
};
9595
}
9696

libdrm/types/mode/props.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ pub const ModeGetBlob = extern struct {
99

1010
pub const req = os.IOCTL.IOWR(0xAC, ModeGetBlob);
1111

12-
pub fn get(self: *ModeGetBlob, fd: std.os.fd_t) !void {
13-
return switch (std.os.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
12+
pub fn get(self: *ModeGetBlob, fd: std.posix.fd_t) !void {
13+
return switch (std.posix.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
1414
.SUCCESS => {},
1515
.BADF => error.NotOpenForWriting,
1616
.NOENT => error.NotFound,
1717
.FAULT => unreachable,
1818
.INVAL => unreachable,
1919
.NOTTY => error.NotATerminal,
2020
.OPNOTSUPP => error.NotSupported,
21-
else => |e| std.os.unexpectedErrno(e),
21+
else => |e| std.posix.unexpectedErrno(e),
2222
};
2323
}
2424

25-
pub fn getAllocated(self: *ModeGetBlob, fd: std.os.fd_t, alloc: Allocator) !void {
25+
pub fn getAllocated(self: *ModeGetBlob, fd: std.posix.fd_t, alloc: Allocator) !void {
2626
try self.get(fd);
2727

2828
errdefer self.deinit(alloc);
@@ -95,20 +95,20 @@ pub const ModeGetProperty = extern struct {
9595
__future: u26,
9696
};
9797

98-
pub fn get(self: *ModeGetProperty, fd: std.os.fd_t) !void {
99-
return switch (std.os.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
98+
pub fn get(self: *ModeGetProperty, fd: std.posix.fd_t) !void {
99+
return switch (std.posix.errno(os.ioctl(fd, req, @intFromPtr(self)))) {
100100
.SUCCESS => {},
101101
.BADF => error.NotOpenForWriting,
102102
.NOENT => error.NotFound,
103103
.FAULT => unreachable,
104104
.INVAL => unreachable,
105105
.NOTTY => error.NotATerminal,
106106
.OPNOTSUPP => error.NotSupported,
107-
else => |e| std.os.unexpectedErrno(e),
107+
else => |e| std.posix.unexpectedErrno(e),
108108
};
109109
}
110110

111-
pub fn getAllocated(self: *ModeGetProperty, fd: std.os.fd_t, alloc: Allocator) !void {
111+
pub fn getAllocated(self: *ModeGetProperty, fd: std.posix.fd_t, alloc: Allocator) !void {
112112
try self.get(fd);
113113

114114
errdefer self.deinit(alloc);

0 commit comments

Comments
 (0)