mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
cleanup a few things
This commit is contained in:
43
.vscode/launch.json
generated
vendored
43
.vscode/launch.json
generated
vendored
@@ -292,25 +292,62 @@
|
||||
"request": "launch",
|
||||
"name": "bun test",
|
||||
"program": "bun-debug",
|
||||
"args": ["wiptest", "transpiler"],
|
||||
"args": ["wiptest"],
|
||||
"cwd": "${workspaceFolder}/integration",
|
||||
"env": {
|
||||
"FORCE_COLOR": "1"
|
||||
},
|
||||
"console": "internalConsole"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "bun test current",
|
||||
"program": "bun-debug",
|
||||
"args": ["wiptest", "response.file"],
|
||||
"cwd": "${workspaceFolder}/integration",
|
||||
"env": {
|
||||
"FORCE_COLOR": "1"
|
||||
},
|
||||
"console": "internalConsole"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "bun http example",
|
||||
"program": "bun-debug",
|
||||
"args": ["run", "examples/bun/http.ts"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"FORCE_COLOR": "1"
|
||||
},
|
||||
"console": "internalConsole"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "bun http file example",
|
||||
"program": "bun-debug",
|
||||
"args": ["run", "examples/bun/http-file.ts"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"FORCE_COLOR": "1"
|
||||
},
|
||||
"console": "internalConsole"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "bun tes2t",
|
||||
"program": "bun-debug",
|
||||
"args": ["build", "hello.jsx", "--platform=bun"],
|
||||
"cwd": "/Users/jarred/Desktop/",
|
||||
"args": ["add", "imagemin-webpack-plugin"],
|
||||
"cwd": "/tmp/testfoo",
|
||||
"env": {
|
||||
"FORCE_COLOR": "1"
|
||||
},
|
||||
"console": "internalConsole"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext"],
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"noEmit": true,
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"types": ["../../types/bun"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { describe, it, expect } from "bun:test";
|
||||
import {
|
||||
mkdirSync,
|
||||
existsSync,
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", { "replace": "node", "with": "dom" }],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"foo/bar": ["baz.js"]
|
||||
},
|
||||
"typeRoots": ["./node_modules/@types"]
|
||||
"lib": ["ESNext"],
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"noEmit": true,
|
||||
"moduleResolution": "node",
|
||||
"downlevelIteration": true,
|
||||
"module": "esnext",
|
||||
"types": ["../../types/bun"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@
|
||||
"build-fallback": "esbuild --target=esnext --bundle src/fallback.ts --format=iife --platform=browser --minify > src/fallback.out.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.9.2",
|
||||
"@types/puppeteer": "^5.4.4",
|
||||
"prettier": "^2.4.1"
|
||||
"prettier": "^2.4.1",
|
||||
"typescript": "4.6.3"
|
||||
},
|
||||
"version": "0.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,6 @@ else
|
||||
|
||||
pub fn pread(fd: os.fd_t, buf: []u8, offset: i64) Maybe(usize) {
|
||||
const adjusted_len = @minimum(buf.len, max_count);
|
||||
|
||||
const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
|
||||
while (true) {
|
||||
const rc = pread_sym(fd, buf.ptr, adjusted_len, ioffset);
|
||||
@@ -378,6 +377,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) Maybe([]u8) {
|
||||
return .{ .result = out_buffer[0..len] };
|
||||
},
|
||||
.linux => {
|
||||
// TODO: alpine linux may not have /proc/self
|
||||
var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined;
|
||||
const proc_path = std.fmt.bufPrintZ(procfs_buf[0..], "/proc/self/fd/{d}\x00", .{fd}) catch unreachable;
|
||||
|
||||
@@ -423,9 +423,9 @@ fn mmap(
|
||||
return Maybe([]align(mem.page_size) u8){
|
||||
.err = .{ .errno = @truncate(Syscall.Error.Int, @enumToInt(std.c.getErrno(@bitCast(i64, @ptrToInt(std.c.MAP.FAILED))))), .syscall = .mmap },
|
||||
};
|
||||
}
|
||||
|
||||
return Maybe([]align(mem.page_size) u8){.result = @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length] };
|
||||
}
|
||||
|
||||
return Maybe([]align(mem.page_size) u8){ .result = @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length] };
|
||||
}
|
||||
|
||||
pub fn mmapFile(path: [:0]const u8, flags: u32) Maybe([]align(mem.page_size) u8) {
|
||||
|
||||
@@ -232,7 +232,6 @@ pub fn CallbackTask(comptime Result: type) type {
|
||||
callback: JSC.C.JSObjectRef,
|
||||
option: Option,
|
||||
success: bool = false,
|
||||
completion: AsyncIO.Completion,
|
||||
|
||||
pub const Option = union {
|
||||
err: JSC.SystemError,
|
||||
|
||||
@@ -9,19 +9,21 @@ const Allocator = mem.Allocator;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
pub const Arena = struct {
|
||||
heap: *mimalloc.mi_heap_t = undefined,
|
||||
heap: ?*mimalloc.mi_heap_t = null,
|
||||
|
||||
pub fn backingAllocator(this: Arena) Allocator {
|
||||
var arena = Arena{ .heap = this.heap.backing() };
|
||||
var arena = Arena{ .heap = this.heap.?.backing() };
|
||||
return arena.allocator();
|
||||
}
|
||||
|
||||
pub fn allocator(this: Arena) Allocator {
|
||||
return Allocator{ .ptr = this.heap, .vtable = &c_allocator_vtable };
|
||||
@setRuntimeSafety(false);
|
||||
return Allocator{ .ptr = this.heap.?, .vtable = &c_allocator_vtable };
|
||||
}
|
||||
|
||||
pub fn deinit(this: *Arena) void {
|
||||
mimalloc.mi_heap_destroy(this.heap);
|
||||
this.heap = null;
|
||||
}
|
||||
|
||||
pub fn reset(this: *Arena) void {
|
||||
|
||||
17
src/yield.zig
Normal file
17
src/yield.zig
Normal file
@@ -0,0 +1,17 @@
|
||||
pub fn Yield(comptime Type: anytype) type {
|
||||
return struct {
|
||||
frame: @Frame(Type) = undefined,
|
||||
wait: bool = false,
|
||||
|
||||
pub fn set(this: *@This(), frame: anytype) void {
|
||||
this.wait = true;
|
||||
this.frame = frame.*;
|
||||
}
|
||||
|
||||
pub fn maybeResume(this: *@This()) void {
|
||||
if (!this.wait) return;
|
||||
this.wait = false;
|
||||
resume this.frame;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user