miniaudio and p2 upgraded 0.15
This commit is contained in:
parent
83537ef84f
commit
5d5e99b9c5
|
|
@ -5,16 +5,14 @@ pub fn build(b: *std.Build) void {
|
|||
const optimize = b.standardOptimizeOption(.{});
|
||||
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
||||
|
||||
const miniaudio_c = if (static_build or true) b.addStaticLibrary(.{
|
||||
const miniaudio_c = b.addLibrary(.{
|
||||
.name = "miniaudio_c",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
}) else b.addSharedLibrary(.{
|
||||
.name = "miniaudio_c",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
.linkage = if (static_build) .static else .dynamic,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
|
||||
b.installArtifact(miniaudio_c);
|
||||
|
|
@ -29,10 +27,12 @@ pub fn build(b: *std.Build) void {
|
|||
// ======== tests ============
|
||||
const test_step = b.step("test", "");
|
||||
const tests = b.addTest(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/miniaudio.zig"),
|
||||
.link_libc = true,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/miniaudio-test.zig"),
|
||||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
tests.addIncludePath(b.path("./include"));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,3 @@
|
|||
pub usingnamespace @cImport({
|
||||
pub const c = @cImport({
|
||||
@cInclude("miniaudio.h");
|
||||
});
|
||||
|
||||
const c = @This();
|
||||
const std = @import("std");
|
||||
|
||||
test "miniaudio-compile-check" {
|
||||
try std.testing.expect(c.MA_VERSION_MAJOR == 0);
|
||||
try std.testing.expect(c.MA_VERSION_MINOR == 11);
|
||||
|
||||
var engine: c.ma_engine = undefined;
|
||||
const result = c.ma_engine_init(null, &engine);
|
||||
c.ma_engine_uninit(&engine);
|
||||
|
||||
try std.testing.expect(result == c.MA_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,10 +54,12 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
const test_step = b.step("test", "");
|
||||
const tests = b.addTest(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/nfd.zig"),
|
||||
.link_libc = true,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/nfd.zig"),
|
||||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
tests.addIncludePath(b.path("./include"));
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
const test_step = b.step("test", "test p2");
|
||||
const tests = b.addTest(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/p2.zig"),
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.root_source_file = b.path("src/p2.zig"),
|
||||
}),
|
||||
// .link_libc = true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ pub const xxdWrite = xxd.xxdWrite;
|
|||
pub const loadFileAlloc = utils.loadFileAlloc;
|
||||
const ArrayList = std.ArrayList;
|
||||
const ArrayListUnmanaged = std.ArrayListUnmanaged;
|
||||
pub usingnamespace @import("structures/interface.zig");
|
||||
pub const interface = @import("structures/interface.zig");
|
||||
pub const Reference = interface.Reference;
|
||||
pub const refFromPtr = interface.refFromPtr;
|
||||
|
||||
pub const assertf = utils.assertf;
|
||||
pub const asserts = utils.asserts;
|
||||
|
|
@ -327,13 +329,13 @@ test "spin child process echo" {
|
|||
std.debug.print("spin child process\n", .{});
|
||||
const process = try shell.ShellProcess.init(std.testing.allocator, &.{ "echo", "lmao 2 nova" });
|
||||
defer process.deinit();
|
||||
std.debug.print("child process created: {s}\n", .{process.argv});
|
||||
std.debug.print("child process created: {any}\n", .{process.argv});
|
||||
}
|
||||
|
||||
{
|
||||
std.debug.print("spin child process 2\n", .{});
|
||||
const process = try shell.ShellProcess.initCmd(std.testing.allocator, "echo lmao2nova -target='lmao 3 nova'");
|
||||
defer process.deinit();
|
||||
std.debug.print("{s}\n", .{process.argv});
|
||||
std.debug.print("{any}\n", .{process.argv});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ pub fn ConcurrentQueueUnmanagedAdvanced(comptime T: type, comptime opts: struct
|
|||
return new;
|
||||
}
|
||||
|
||||
// there is 100% an ABA problem going on here...
|
||||
|
||||
pub fn push(self: *@This(), value: T) !void {
|
||||
// seek the next unread bit and reserve it
|
||||
const start: usize = self.tail.load(.acquire);
|
||||
|
|
@ -75,10 +77,8 @@ pub fn ConcurrentQueueUnmanagedAdvanced(comptime T: type, comptime opts: struct
|
|||
// this is ok, update our expected value an try to CAS again
|
||||
if ((expected > tail) or ((expected < tail) and expected < self.head.load(.acquire))) {
|
||||
expected = tail;
|
||||
}
|
||||
|
||||
// something else reserved a slot past ours, we can expect them to fixup the value
|
||||
if ((tail > expected) or ((tail < expected) and tail < self.head.load(.acquire))) {
|
||||
} else if ((tail > expected) or ((tail < expected) and tail < self.head.load(.acquire))) {
|
||||
// something else reserved a slot past ours, we can expect them to fixup the value
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -102,6 +102,7 @@ pub fn ConcurrentQueueUnmanagedAdvanced(comptime T: type, comptime opts: struct
|
|||
}
|
||||
}
|
||||
|
||||
// newHead = (popIndex + 1) % self.data.len;
|
||||
// spin and resolve
|
||||
while (self.head.cmpxchgStrong(expected, newHead, .seq_cst, .acquire)) |head| {
|
||||
// we failed to increment the head
|
||||
|
|
@ -212,11 +213,10 @@ test "concurrent queue multiple producer single consumer" {
|
|||
.x = id + pushedCount,
|
||||
}) catch unreachable;
|
||||
pushedCount += 1;
|
||||
|
||||
std.Thread.sleep(1000 * 1000 * 100);
|
||||
}
|
||||
|
||||
_ = pushedCountResults.fetchAdd(pushedCount, .acq_rel);
|
||||
_ = pushedCountResults.fetchAdd(pushedCount, .seq_cst);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -241,23 +241,22 @@ test "concurrent queue multiple producer single consumer" {
|
|||
|
||||
var poppedCount: i64 = 0;
|
||||
|
||||
var signaled: bool = false;
|
||||
|
||||
while (timeLeft > 0 or testQueue.count() > 0) {
|
||||
const newTime = test_getTime();
|
||||
const deltaTime = newTime - oldTime;
|
||||
if (timeLeft - deltaTime < 5.0) {
|
||||
exitSignalAtomic.store(true, .release);
|
||||
|
||||
if (timeLeft - deltaTime < 5.0 and !signaled) {
|
||||
signaled = true;
|
||||
exitSignalAtomic.store(true, .seq_cst);
|
||||
}
|
||||
|
||||
timeLeft -= deltaTime;
|
||||
oldTime = newTime;
|
||||
|
||||
//while (testQueue.pop()) |x| {
|
||||
{
|
||||
if (testQueue.pop()) |x| {
|
||||
_ = x;
|
||||
// std.debug.print("{d:5} head={d} ", .{ x.x, testQueue.head.load(.acquire) });
|
||||
poppedCount += 1;
|
||||
std.debug.print("popped: {d}\t time left = {d:2.3}\t queueCount = {d} \r", .{ poppedCount, timeLeft, testQueue.count() });
|
||||
}
|
||||
if (testQueue.pop()) |x| {
|
||||
_ = x;
|
||||
poppedCount += 1;
|
||||
}
|
||||
std.Thread.sleep(1000 * 1000);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ const Bucket = struct {
|
|||
|
||||
fn addPage(self: *@This(), allocator: std.mem.Allocator) !void {
|
||||
const page: Page = .{
|
||||
.bytes = try allocator.alignedAlloc(u8, 8, self.pageSize),
|
||||
.bytes = try allocator.alignedAlloc(u8, .@"8", self.pageSize),
|
||||
};
|
||||
try self.pages.append(allocator, page);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ pub const ShellProcess = struct {
|
|||
argv: []const []const u8 = undefined,
|
||||
ownedArgs: ?[][]u8 = null,
|
||||
stringArena: p2.BumpArena = undefined,
|
||||
outputQueue: std.DoublyLinkedList([]const u8) = undefined,
|
||||
|
||||
// initialize the shellprocess from a windows cmd string
|
||||
pub fn initCmd(alloc: std.mem.Allocator, cmd: []const u8) !*@This() {
|
||||
|
|
@ -41,33 +40,33 @@ pub const ShellProcess = struct {
|
|||
}
|
||||
|
||||
pub fn splitArgsFromCmd(self: *@This(), cmd: []const u8) !void {
|
||||
var currentCmd = std.ArrayList(u8).init(self.allocator());
|
||||
var ownedArgs = std.ArrayList([]u8).init(self.allocator());
|
||||
var terminalStack = std.ArrayList(u8).init(self.backingAllocator);
|
||||
defer terminalStack.deinit();
|
||||
var currentCmd = std.ArrayList(u8){};
|
||||
var ownedArgs = std.ArrayList([]u8){};
|
||||
var terminalStack = std.ArrayList(u8){};
|
||||
defer terminalStack.deinit(self.backingAllocator);
|
||||
|
||||
for (cmd) |c| {
|
||||
if (terminalStack.items.len == 0) {
|
||||
if (c == ' ') {
|
||||
try ownedArgs.append(try currentCmd.toOwnedSlice());
|
||||
try ownedArgs.append(self.allocator(), try currentCmd.toOwnedSlice(self.allocator()));
|
||||
} else if (c == '\'' or c == '\"') {
|
||||
try terminalStack.append(c);
|
||||
try currentCmd.append(c);
|
||||
try terminalStack.append(self.backingAllocator, c);
|
||||
try currentCmd.append(self.allocator(), c);
|
||||
} else {
|
||||
try currentCmd.append(c);
|
||||
try currentCmd.append(self.allocator(), c);
|
||||
}
|
||||
} else {
|
||||
if (terminalStack.items[terminalStack.items.len - 1] == c) {
|
||||
try currentCmd.append(terminalStack.pop().?);
|
||||
try currentCmd.append(self.allocator(), terminalStack.pop().?);
|
||||
} else {
|
||||
try currentCmd.append(c);
|
||||
try currentCmd.append(self.allocator(), c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try ownedArgs.append(try currentCmd.toOwnedSlice());
|
||||
try ownedArgs.append(self.allocator(), try currentCmd.toOwnedSlice(self.allocator()));
|
||||
|
||||
self.ownedArgs = try ownedArgs.toOwnedSlice();
|
||||
self.ownedArgs = try ownedArgs.toOwnedSlice(self.allocator());
|
||||
self.argv = @ptrCast(self.ownedArgs.?);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue