Skip to content

Commit

Permalink
fix: zig 0.12.0-dev.3666+a2b834e8c
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed Apr 17, 2024
1 parent e14654b commit f26067d
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ A small/lightweight statically typed scripting language written in Zig

## How to build and install

_Latest zig version supported: 0.12.0-dev.3245+4f782d1e8_
_Latest zig version supported: 0.12.0-dev.3666+a2b834e8c_

### Requirements
- Since this is built with Zig, you should be able to build buzz on a wide variety of architectures even though this has only been tested on x86/M1.
Expand Down
10 changes: 5 additions & 5 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ const BuzzBuildOptions = struct {
};

fn getBuzzPrefix(b: *Build) []const u8 {
return std.os.getenv("BUZZ_PATH") orelse std.fs.path.dirname(b.exe_dir).?;
return std.posix.getenv("BUZZ_PATH") orelse std.fs.path.dirname(b.exe_dir).?;
}

pub fn build(b: *Build) !void {
// Check minimum zig version
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse("0.12.0-dev.3245+4f782d1e8") catch return;
const min_zig = std.SemanticVersion.parse("0.12.0-dev.3666+a2b834e8c") catch return;
if (current_zig.order(min_zig).compare(.lt)) {
@panic(b.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig }));
}
Expand Down Expand Up @@ -128,8 +128,8 @@ pub fn build(b: *Build) !void {
"\n \t",
),
// Current commit sha
.sha = std.os.getenv("GIT_SHA") orelse
std.os.getenv("GITHUB_SHA") orelse std.mem.trim(
.sha = std.posix.getenv("GIT_SHA") orelse
std.posix.getenv("GITHUB_SHA") orelse std.mem.trim(
u8,
(std.ChildProcess.run(.{
.allocator = b.allocator,
Expand Down Expand Up @@ -320,7 +320,7 @@ pub fn build(b: *Build) !void {
const prefix = if (result) |r|
std.mem.trim(u8, r.stdout, "\n")
else
std.os.getenv("HOMEBREW_PREFIX") orelse "/opt/homebrew";
std.posix.getenv("HOMEBREW_PREFIX") orelse "/opt/homebrew";

var include = std.ArrayList(u8).init(b.allocator);
include.writer().print("{s}{s}include", .{ prefix, std.fs.path.sep_str }) catch unreachable;
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub fn defaultBuzzPrefix() []const u8 {

var _buzz_path_buffer: [4096]u8 = undefined;
pub fn buzzPrefix() []const u8 {
if (std.os.getenv("BUZZ_PATH")) |buzz_path| return buzz_path;
if (std.posix.getenv("BUZZ_PATH")) |buzz_path| return buzz_path;
const path = if (!is_wasm)
std.fs.selfExePath(&_buzz_path_buffer) catch return defaultBuzzPrefix()
else
Expand Down
2 changes: 1 addition & 1 deletion src/Reporter.zig
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub const Report = struct {
pub fn report(self: *Report, reporter: *Self, out: anytype) !void {
assert(self.items.len > 0);

const colorterm = std.os.getenv("COLORTERM");
const colorterm = std.posix.getenv("COLORTERM");
const true_color = if (colorterm) |ct|
std.mem.eql(u8, ct, "24bit") or std.mem.eql(u8, ct, "truecolor")
else
Expand Down
6 changes: 3 additions & 3 deletions src/builtin/list.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn append(ctx: *NativeCtx) c_int {
const messageValue: Value = (ctx.vm.gc.copyString("Could not append to list") catch {
std.debug.print("Could not append to list", .{});
if (!is_wasm) {
std.os.exit(1);
std.posix.exit(1);
} else {
unreachable;
}
Expand Down Expand Up @@ -49,7 +49,7 @@ pub fn insert(ctx: *NativeCtx) c_int {
const messageValue: Value = (ctx.vm.gc.copyString("Could not insert into list") catch {
std.debug.print("Could not insert into list", .{});
if (!is_wasm) {
std.os.exit(1);
std.posix.exit(1);
} else {
unreachable;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn remove(ctx: *NativeCtx) c_int {
ctx.vm.gc.markObjDirty(&list.obj) catch {
std.debug.print("Could not remove from list", .{});
if (!is_wasm) {
std.os.exit(1);
std.posix.exit(1);
} else {
unreachable;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ext/clap
Submodule clap updated 1 files
+9 −2 clap.zig
2 changes: 1 addition & 1 deletion src/jit_extern_api.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const JIT = @import("Jit.zig");
const jmp = @import("jmp.zig").jmp;

export fn bz_exit(code: c_int) noreturn {
std.os.exit(@truncate(@as(c_uint, @bitCast(code))));
std.posix.exit(@truncate(@as(c_uint, @bitCast(code))));
}

pub const ExternApi = enum {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/buzz_http.zig
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub export fn HttpClientSend(ctx: *api.NativeCtx) c_int {
return -1;
};

request.send(.{ .raw_uri = false }) catch |err| {
request.send() catch |err| {
handleStartError(ctx, err);

return -1;
Expand Down Expand Up @@ -295,7 +295,7 @@ fn handleWaitError(ctx: *api.NativeCtx, err: anytype) void {
error.UnexpectedWriteFailure,
error.UnknownHostName,
error.UnsupportedTransferEncoding,
error.UnsupportedUrlScheme,
error.UnsupportedUriScheme,
error.UriMissingHost,
=> ctx.vm.pushErrorEnum("http.HttpError", @errorName(err)),
}
Expand Down Expand Up @@ -331,7 +331,7 @@ fn handleError(ctx: *api.NativeCtx, err: anytype) void {
error.UnexpectedWriteFailure,
error.UnknownHostName,
error.UnsupportedTransferEncoding,
error.UnsupportedUrlScheme,
error.UnsupportedUriScheme,
error.UriMissingHost,
=> ctx.vm.pushErrorEnum("http.HttpError", @errorName(err)),
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/buzz_io.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub export fn FileIsTTY(ctx: api.NativeCtx) c_int {
ctx.vm.bz_peek(0).integer(),
);

ctx.vm.bz_pushBool(std.os.isatty(handle));
ctx.vm.bz_pushBool(std.posix.isatty(handle));

return 1;
}
Expand Down
20 changes: 10 additions & 10 deletions src/lib/buzz_os.zig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub export fn env(ctx: *api.NativeCtx) c_int {
const key_slice = api.VM.allocator.dupeZ(u8, key.?[0..len]) catch @panic("Out of memory");
defer api.VM.allocator.free(key_slice);

if (std.os.getenvZ(key_slice)) |value| {
if (std.posix.getenvZ(key_slice)) |value| {
ctx.vm.bz_pushString(api.ObjString.bz_string(ctx.vm, if (value.len > 0) @as([*]const u8, @ptrCast(value)) else null, value.len) orelse {
@panic("Out of memory");
});
Expand All @@ -43,7 +43,7 @@ pub export fn env(ctx: *api.NativeCtx) c_int {
fn sysTempDir() []const u8 {
return switch (builtin.os.tag) {
.windows => unreachable, // TODO: GetTempPath
else => std.os.getenv("TMPDIR") orelse std.os.getenv("TMP") orelse std.os.getenv("TEMP") orelse std.os.getenv("TEMPDIR") orelse "/tmp",
else => std.posix.getenv("TMPDIR") orelse std.posix.getenv("TMP") orelse std.posix.getenv("TEMP") orelse std.posix.getenv("TEMPDIR") orelse "/tmp",
};
}

Expand Down Expand Up @@ -92,11 +92,11 @@ pub export fn tmpFilename(ctx: *api.NativeCtx) c_int {
return 1;
}

// If it was named `exit` it would be considered by zig as a callback when std.os.exit is called
// If it was named `exit` it would be considered by zig as a callback when std.posix.exit is called
pub export fn buzzExit(ctx: *api.NativeCtx) c_int {
const exitCode: i32 = ctx.vm.bz_peek(0).integer();

std.os.exit(@intCast(exitCode));
std.posix.exit(@intCast(exitCode));

return 0;
}
Expand Down Expand Up @@ -332,11 +332,11 @@ pub export fn SocketConnect(ctx: *api.NativeCtx) c_int {
}

pub export fn SocketClose(ctx: *api.NativeCtx) c_int {
const socket: std.os.socket_t = @intCast(
const socket: std.posix.socket_t = @intCast(
ctx.vm.bz_peek(0).integer(),
);

std.os.shutdown(socket, .both) catch @panic("Could not stop socket");
std.posix.shutdown(socket, .both) catch @panic("Could not stop socket");

return 0;
}
Expand Down Expand Up @@ -376,7 +376,7 @@ pub export fn SocketRead(ctx: *api.NativeCtx) c_int {
return -1;
}

const handle: std.os.socket_t = @intCast(
const handle: std.posix.socket_t = @intCast(
ctx.vm.bz_peek(1).integer(),
);

Expand Down Expand Up @@ -434,7 +434,7 @@ fn handleReadLineError(ctx: *api.NativeCtx, err: anytype) void {
}

pub export fn SocketReadLine(ctx: *api.NativeCtx) c_int {
const handle: std.os.socket_t = @intCast(
const handle: std.posix.socket_t = @intCast(
ctx.vm.bz_peek(1).integer(),
);
const max_size = ctx.vm.bz_peek(0);
Expand Down Expand Up @@ -479,7 +479,7 @@ pub export fn SocketReadLine(ctx: *api.NativeCtx) c_int {
}

pub export fn SocketReadAll(ctx: *api.NativeCtx) c_int {
const handle: std.os.socket_t = @intCast(
const handle: std.posix.socket_t = @intCast(
ctx.vm.bz_peek(1).integer(),
);
const max_size = ctx.vm.bz_peek(0);
Expand Down Expand Up @@ -523,7 +523,7 @@ pub export fn SocketReadAll(ctx: *api.NativeCtx) c_int {
}

pub export fn SocketWrite(ctx: *api.NativeCtx) c_int {
const handle: std.os.socket_t = @intCast(
const handle: std.posix.socket_t = @intCast(
ctx.vm.bz_peek(1).integer(),
);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/buzz_std.zig
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub export fn assert(ctx: *api.NativeCtx) c_int {
}

if (!is_wasm) {
std.os.exit(1);
std.posix.exit(1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/http.buzz
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export enum HttpError {
UnexpectedWriteFailure,
UnknownHostName,
UnsupportedTransferEncoding,
UnsupportedUrlScheme,
UnsupportedUriScheme,
UriMissingHost,
}

Expand Down
12 changes: 6 additions & 6 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pub fn main() !void {
printBanner(std.io.getStdOut().writer(), true);

if (!is_wasm) {
std.os.exit(0);
std.posix.exit(0);
}
}

Expand All @@ -283,7 +283,7 @@ pub fn main() !void {
);

if (!is_wasm) {
std.os.exit(0);
std.posix.exit(0);
}
}

Expand Down Expand Up @@ -325,7 +325,7 @@ pub fn main() !void {
if (!is_wasm and flavor == .Repl) {
repl(allocator) catch {
if (!is_wasm) {
std.os.exit(1);
std.posix.exit(1);
}

std.debug.print("REPL stopped", .{});
Expand All @@ -338,7 +338,7 @@ pub fn main() !void {
flavor,
) catch {
if (!is_wasm) {
std.os.exit(1);
std.posix.exit(1);
}

std.debug.print("VM stopped", .{});
Expand All @@ -350,7 +350,7 @@ pub fn main() !void {
}

if (!is_wasm) {
std.os.exit(0);
std.posix.exit(0);
}
}

Expand Down Expand Up @@ -460,5 +460,5 @@ test "Testing behavior" {
fail_count,
});

std.os.exit(if (fail_count == 0) 0 else 1);
std.posix.exit(if (fail_count == 0) 0 else 1);
}
2 changes: 1 addition & 1 deletion src/obj.zig
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub const Obj = struct {
return null;
}

return @fieldParentPtr(T, "obj", obj);
return @alignCast(@fieldParentPtr("obj", obj));
}

pub inline fn access(obj: *Obj, comptime T: type, obj_type: ObjType, gc: *GarbageCollector) ?*T {
Expand Down
4 changes: 2 additions & 2 deletions src/repl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn printBanner(out: std.fs.File.Writer, full: bool) void {
}

pub fn repl(allocator: std.mem.Allocator) !void {
const colorterm = std.os.getenv("COLORTERM");
const colorterm = std.posix.getenv("COLORTERM");
const true_color = if (colorterm) |ct|
std.mem.eql(u8, ct, "24bit") or std.mem.eql(u8, ct, "truecolor")
else
Expand Down Expand Up @@ -143,7 +143,7 @@ pub fn repl(allocator: std.mem.Allocator) !void {

try buzz_history_path.writer().print(
"{s}/.buzz_history\x00",
.{std.os.getenv("HOME") orelse "."},
.{std.posix.getenv("HOME") orelse "."},
);

_ = ln.linenoiseHistorySetMaxLen(100);
Expand Down
4 changes: 2 additions & 2 deletions src/vm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ pub const VM = struct {
fn vmPanic(e: anytype) void {
std.debug.print("{}\n", .{e});
if (!is_wasm) {
std.os.exit(1);
std.posix.exit(1);
}
}

Expand Down Expand Up @@ -3904,7 +3904,7 @@ pub const VM = struct {
);

if (!is_wasm) {
std.os.exit(1);
std.posix.exit(1);
} else {
return Error.RuntimeError;
}
Expand Down

0 comments on commit f26067d

Please sign in to comment.