blob: 0f1e114605cd7008b01972d8d39893bf623ba381 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
//! Location operations
const sys = @import("sys");
const types = @import("types.zig");
const ERROR_RESULT: u64 = @bitCast(@as(i64, -1));
pub fn get(buffer: []u8) types.Error![]u8 {
const result = sys.syscall(.getlocation, .{
@intFromPtr(buffer.ptr),
buffer.len,
});
if (result == ERROR_RESULT) {
return types.Error.GetLocationFailed;
}
return buffer[0..@intCast(result)];
}
pub fn set(location: []const u8) types.Error!void {
const result = sys.syscall(.setlocation, .{
@intFromPtr(location.ptr),
location.len,
});
if (result == ERROR_RESULT) {
return types.Error.InvalidLocation;
}
}
|