Compare commits

...

116 Commits

Author SHA1 Message Date
Claude Bot
c2403a8d46 fix: correct JSONLineBuffer import path after rebase
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 09:17:43 +00:00
autofix-ci[bot]
e6db5003e0 [autofix.ci] apply automated fixes 2025-12-31 09:02:51 +00:00
Claude Bot
e48a9985cf docs: update CLAUDE.md with new source organization
Completely rewrite the Code Architecture section to reflect the
reorganized source structure. Now includes:

- Quick-reference table mapping tasks to directories
- Full directory tree showing the organized buntime/ structure
- Updated paths (src/buntime/ instead of src/bun.js/)
- Removed references to dissolved directories (bindings/, webcore/)

The goal: Claude should be able to GUESS where code lives.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:25 +00:00
Claude Bot
3a1be14392 refactor: rename transpiler files with js_ prefix for consistency
Rename files in src/transpiler/ to have consistent js_ prefix:
- parser.zig → js_parser.zig
- printer.zig → js_printer.zig
- lexer.zig → js_lexer.zig
- lexer_tables.zig → js_lexer_tables.zig

Update all imports across the codebase:
- bun.zig
- renamer.zig
- ast.zig
- ast/Expr.zig
- logger.zig
- string/MutableString.zig
- bundler/bundle_v2.zig
- bundler/LinkerContext.zig
- transpiler/js_lexer.zig (internal import)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:25 +00:00
Claude Bot
fd57125842 refactor: complete core/ dissolution and fix documentation paths
Move remaining core/ files to organized jsc/ subdirectories:
- BunClientData, BunIDL*, CPUFeatures, JSCTaskScheduler, coroutine → jsc/interop/
- BunGCOutputConstraint, MimallocWTFMalloc.h, bmalloc_heap_ref.h → jsc/gc/
- RegularExpression → jsc/types/

Fix outdated file paths in documentation:
- STREAMS.md: webcore/ → web/streams/
- event_loop/README.md: bindings/JSNextTickQueue → node/process/
- compat/v8/CLAUDE.md and AGENTS.md: bindings/v8/ → compat/v8/
- node/http/llhttp/README.md: bindings/ProcessBindingHTTPParser → api/process/

Fix cmake BuildBun.cmake issues:
- Remove duplicate directory entries in BUN_ERROR_CODE_SOURCES
- Remove directory (not file) arguments from WEBKIT_ADD_SOURCE_DEPENDENCIES

Update Zig imports for moved files in jsc.zig and crash_handler.zig.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:25 +00:00
Claude Bot
9e71f4453e refactor: move event_loop/ from core/ to buntime/ root
Per PLAN.md's Final Structure, event_loop should be at the buntime/
root level. This move:
- Moves the event_loop directory from core/event_loop/ to buntime/event_loop/
- Moves event_loop.zig and related C++ files (EventLoopTask.h,
  EventLoopTaskNoContext.cpp/h, BunJSCEventLoop.cpp)
- Updates imports in jsc.zig, GeneratedJS2Native.zig, rare_data.zig
- Fixes relative paths in event_loop.zig and Task.zig
- Updates cmake Sources.json and BuildBun.cmake with new paths

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:25 +00:00
Claude Bot
b40b442c62 refactor: organize node/ C++ files into domain subdirectories
Move C++ files from node/ root into organized subdirectories:
- node/buffer/ - Buffer and StringDecoder
- node/process/ - NextTickQueue
- node/vm/ - VM, VMScript
- node/crypto/ - All crypto bindings (renamed from crypto_bindings/)
- node/http/ - HTTP server socket, NodeHTTP
- node/fs/ - Dirent, stat bindings
- node/os/ - OsBinding
- node/path/ - Path utilities
- node/util/ - NodeValidator
- node/timers/ - Timer objects
- node/async_hooks/ - AsyncContextFrame, AsyncHooks
- node/perf_hooks/ - Performance histogram
- node/constants/ - NodeConstants

Also moves global scope files to jsc/global/:
- BunGlobalScope, BunObject, BunWorkerGlobalScope
- ZigSourceProvider

Updates cmake Sources.json and BuildBun.cmake with new paths.
Fixes include paths in NodeBufferModule.h and NodeStringDecoderModule.h.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:25 +00:00
Claude Bot
ab2f5a20d3 refactor: dissolve webcore/ directory into jsc/interop/
Move all JSDOM infrastructure from webcore/ to jsc/interop/:
- ActiveDOMObject, ContextDestructionObserver
- JSDOMConvert*, JSDOMPromise, JSDOMIterator
- JSDOMWrapper*, JSDOMConstructor*, JSDOMBuiltin*
- DOMJITHelpers, DOMIsoSubspaces, DOMClientIsoSubspaces
- WebCoreTypedArrayController, BufferSource
- All other JSDOM binding utilities

Also:
- Move AutoFlusher.zig to jsc/interop/
- Move ScriptExecutionContext.zig to jsc/global/
- Update cmake Sources.json to remove webcore/ glob
- Fix missing JSDOMGlobalObject.h include in JSPerformanceObserverCallback.h
- Fix JSC::JSValue qualification in JSAbortAlgorithm.h

The webcore/ directory is now fully dissolved.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:25 +00:00
Claude Bot
d07c1bba42 refactor: dissolve bindings/ into jsc/ directory with subdirectories
Move bindings/ directory to jsc/ with the following organization:
- jsc/types/ - JSValue types (JSArray, JSObject, JSPromise, etc.)
- jsc/global/ - Global objects (ZigGlobalObject, ScriptExecutionContext, etc.)
- jsc/gc/ - GC-related files (StrongRef, Weak, MarkingConstraint, etc.)
- jsc/interop/ - C++/Zig interop (bindings.cpp, helpers.cpp, etc.)
- jsc/generated/ - Generated code (GeneratedBindings, JS2Native, etc.)

Also:
- Move uv polyfills to compat/libuv/
- Move v8 fixture to compat/v8/
- Move Windows files to compat/windows/
- Move bindgen_test.bind.ts to jsc/interop/
- Update cmake Sources.json and BuildBun.cmake for new paths
- Update codegen scripts to generate correct relative import paths
- Fix Zig imports throughout the codebase

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:25 +00:00
Claude Bot
fedccb4b6d refactor: move HTMLEntryPoint.cpp to src/bake/
Per PLAN.md section 4.90, this bundler-related file belongs in bake/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
c7ed08f4ff refactor: move string utility files to src/string/
Move string-related C++ files per PLAN.md section 4.80:
- bun-simdutf.cpp, bun-simdutf.zig
- BunString.cpp, BunString.h
- BunCommonStrings.cpp, BunCommonStrings.h
- DoubleFormatter.cpp
- highway_strings.cpp
- StringBuilderBinding.cpp
- stripANSI.cpp, stripANSI.h

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
00ba82605a refactor: move webcrypto from webcore/ to web/
According to PLAN.md, webcrypto should be under web/ as a Web Standard API,
not under webcore/ which is for core JSDOM infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
1fa3829f55 refactor: move VirtualMachine and virtual_machine_exports to core/
These are core runtime infrastructure files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
e7c861c643 refactor: move bindgen files and JSC C API to bindings/
Move bindgen.zig, bindgen_test.zig, javascript_core_c_api.zig to bindings/
since they are all binding-related files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
6e5ef1bedb refactor: move rare_data.zig and hot_reloader.zig to core/
These are core runtime infrastructure files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
456176deef refactor: move jsc/ files to bindings/ and remove jsc/ directory
Move RefString.zig, array_buffer.zig, dom_call.zig, host_fn.zig to bindings/
since they are JSC binding utilities.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
44727cbd44 refactor: move event_loop.zig and event_loop/ to core/
Event loop is core runtime infrastructure that belongs in the core/ directory.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
9dab6a8843 refactor: move Strong.zig, Weak.zig, DeprecatedStrong.zig to bindings/
These are JSC reference management utilities that belong with other bindings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
fd84244b3d refactor: move SavedSourceMap.zig to module/
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
941986868a refactor: move ModuleLoader, AsyncModule, RuntimeTranspilerStore/Cache to module/
Move module loading related files to the module/ subdirectory:
- ModuleLoader.zig
- AsyncModule.zig
- RuntimeTranspilerStore.zig
- RuntimeTranspilerCache.zig

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
b9a2852d53 chore: move Algo/Tuple.h to core/Algo/
Generic tuple algorithms belong in core utilities.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
a7797a7339 chore: move debug-helpers.h to api/inspector/
Debugger helpers belong with inspector/profiling code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
6c5f83417e chore: move string utility headers to src/string/
Move StringAdaptors.h, MiString.h, and ConcatCStrings.h to the existing
src/string/ directory where other string utilities live.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
2a40325984 chore: move string utility headers to core/
String adaptors and utilities belong in core infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
53b587ad74 chore: move memory allocator headers to core/
bmalloc and mimalloc integration belongs in core infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
2936b29a73 chore: move CachedScript.h to module/
Script caching belongs with module loading infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
6f4fcfaeb9 chore: move generated_perf_trace_events.h to api/inspector/
Performance trace events belong with profiling/inspector code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
7ceb58fc8b chore: move uv-posix-polyfills.h to compat/libuv/
libuv polyfills belong with libuv compatibility layer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
316087d3be chore: move dh-primes.h to node/crypto_bindings/
Diffie-Hellman primes belong with crypto infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
158d805751 chore: move ares_build.h to api/bun/
c-ares DNS config belongs with DNS functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
e4a34a4b23 chore: move Sink.h and StreamGlobals.h to web/streams/
Stream-related header files belong with web streams infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
d4adbae015 chore: move ZigSourceProvider files to module/
Source provider is part of module loading infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
0847104330 chore: move EventLoopTask files to core/
Event loop infrastructure belongs in core.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
fca5b782d5 chore: move BakeAdditionsToGlobalObject files to bake/
Bake-specific global object additions belong with other bake code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
0d11a4e4c0 chore: move JSBakeResponse.cpp to bake/
JSBakeResponse is Bake/DevServer infrastructure - keep with header file.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
695db55b77 chore: move coroutine.cpp to core/
Low-level coroutine support belongs in core infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
ef906c38bb chore: move linux_perf_tracing.cpp to api/inspector/
Linux perf tracing belongs with other profiling/inspector code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
5bdb625281 chore: move spawn.cpp to api/bun/
Spawn functionality belongs with other subprocess code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
793682ba43 chore: move ZigException.cpp to api/error/
Keep C++ file alongside the Zig file it implements.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
c88d0d2ab5 chore: move config.zig to core/
Core config belongs in core infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
601e9dbceb chore: move Counters.zig to core/
Internal counters/metrics belong in core infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
790887eb7b chore: move HardcodedModule.zig to module/
Hardcoded module definitions belong with other module-related code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
eede4efac9 chore: move ResolveMessage.zig to api/error/
Resolve error message belongs with other error-related code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
795264752b chore: move BuildMessage.zig to api/error/
Build error message belongs with other error-related code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
cef59deb21 chore: move ipc.zig to api/ipc/
IPC functionality belongs in the api/ipc directory.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
e4a2d75e4a chore: move web_worker.zig to web/workers/
Web Worker functionality belongs with the workers directory.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
1f47e3fd00 chore: move ProcessAutoKiller.zig to api/process/
Process-related utilities belong in api/process/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
2ad1284442 chore: move Debugger.zig to api/inspector/
Debugger functionality belongs with inspector/profiling tools.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
03c3949648 chore: move uuid.zig to webcore/webcrypto/
UUID functionality is primarily used for crypto operations. Moving it to
webcore/webcrypto/ makes its purpose clearer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:24 +00:00
Claude Bot
872a5a335d chore: move ZigException and ZigStackFrame files to api/error/
Moved:
- ZigException.zig -> api/error/
- ZigStackFrame.zig -> api/error/
- ZigStackFrameCode.zig -> api/error/
- ZigStackFramePosition.zig -> api/error/
- ZigStackTrace.zig -> api/error/

Updated imports in jsc.zig, Exception.zig and within the moved files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
655038a408 Move JSCTaskScheduler to core/
Move JSCTaskScheduler.cpp, JSCTaskScheduler.h from bindings/ to core/.
Core task scheduling utility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
ff2ba59f4a Move stripANSI to api/console/
Move stripANSI.cpp, stripANSI.h from bindings/ to api/console/.
Related to console output formatting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
25be9ea0ae Move highway_strings to core/
Move highway_strings.cpp from bindings/ to core/.
SIMD string utilities.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
07d6e07e87 Move simdutf files to core/
Move bun-simdutf.cpp, bun-simdutf.zig from bindings/ to core/.
String/unicode utilities.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
0efcfaa464 Move CachedBytecode to module/
Move CachedBytecode.zig from bindings/ to module/.
Related to module bytecode caching.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
877c36108d Move DoubleFormatter to core/
Move DoubleFormatter.cpp from bindings/ to core/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
289c26a164 Move RegularExpression to core/
Move RegularExpression.cpp, RegularExpression.zig from bindings/ to core/.
Updated import in jsc.zig.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
2dfbeec70d Move CPUFeatures to core/
Move CPUFeatures.cpp, CPUFeatures.zig from bindings/ to core/.
Updated import in crash_handler.zig.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
ae4dd4ee08 Move prompt.zig to api/console/
Move prompt.zig from webcore/ to api/console/.
Related to console input functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
24b38f1a9b Move Crypto.zig to webcore/webcrypto/
Move Crypto.zig from webcore/ to webcore/webcrypto/.
Updated uuid.zig import paths and webcore.zig import.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
c41207374b Move BunProcessReportObjectWindows to api/process/
Move BunProcessReportObjectWindows.cpp from bindings/ to api/process/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
e137723de0 Move JSEnvironmentVariableMap to api/process/
Move JSEnvironmentVariableMap.cpp/h from bindings/ to api/process/.
Related to process.env functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
f2ce862308 Move JSNextTickQueue to node/
Move JSNextTickQueue.cpp, JSNextTickQueue.h from bindings/ to node/.
Related to Node.js process.nextTick functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
9a1791d53d Move DOMException to api/error/
Move DOMException.cpp, DOMException.h from bindings/ to api/error/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
5c76c0f7fa Move OsBinding.cpp to node/
Move OsBinding.cpp from bindings/ to node/.
Related to node:os module.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
8e8d8548a9 Move CodeCoverage.cpp to api/test/
Move CodeCoverage.cpp from bindings/ to api/test/.
Related to test coverage functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
31cf2e9692 Move Serialization.cpp to web/serialization/
Move Serialization.cpp from bindings/ to web/serialization/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
8cf859f460 Move ImportMetaObject to module/
Move ImportMetaObject.cpp, ImportMetaObject.h from bindings/
to module/. Related to ES module import.meta functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
ef9f4af60f Move JSSocketAddressDTO to api/server/
Move JSSocketAddressDTO.cpp, JSSocketAddressDTO.h from bindings/
to api/server/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
dc1bf7b2b8 Move AsyncContextFrame to node/
Move AsyncContextFrame.cpp, AsyncContextFrame.h from bindings/ to node/.
Related to Node.js async_hooks functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
0f2441febd Move CallSite/StackTrace files to api/error/
Move CallSite, CallSitePrototype, FormatStackTraceForJS from bindings/
to api/error/. All error/stack trace related files now together.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
64c75fedb7 Move Cookie C++ files to api/cookie/
Move Cookie.cpp, Cookie.h, CookieMap.cpp, CookieMap.h from bindings/
to api/cookie/. Now all cookie-related files are together.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
f66d82a296 Move debugger/profiler files to api/inspector/
Move BunCPUProfiler, BunDebugger, BunInjectedScriptHost from bindings/
to api/inspector/. Update imports in bun.js.zig and VirtualMachine.zig.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
49fd4dc56e Move ncrypto files to node/crypto_bindings/
Move AsymmetricKeyValue, ncrypto from bindings/ to node/crypto_bindings/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
8fa79c2b5f Move X509Certificate files to node/crypto_bindings/
Move JSX509Certificate, Constructor, and Prototype from bindings/
to node/crypto_bindings/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
742b0f0ad6 Move Path files to node/
Move Path.cpp, Path.h, PathInlines.h from bindings/ to node/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
a02748ef11 Move Buffer-related C++ files to node/
Move BufferEncodingType, JSBuffer, JSBufferEncodingType, JSBufferList,
JSStringDecoder from bindings/ to node/.
Updated BuildBun.cmake and NodeBufferModule.h, NodeStringDecoderModule.h.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
70daa60d0b Move JSNodePerformanceHooksHistogram files to node/
Move JSNodePerformanceHooksHistogram, Constructor, and Prototype
from bindings/ to node/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
ff72b9566d Move Node-related C++ files to node/
Move NodeAsyncHooks, NodeConstants, NodeDirent, NodeFSStatBinding,
NodeFSStatFSBinding, NodeHTTP, NodeTLS, NodeTimerObject, NodeVM,
NodeVMScript, NodeVMScriptFetcher, NodeValidator from bindings/ to node/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
8c2ce7f15d Move error-related files to api/error/
Move ErrorCallback, ExceptionDetails, JSErrorCallback, JSErrorHandler,
JSDOMException from webcore/ to api/error/. Now all error-related
files are together.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
e993178e6e Move QueuingStrategy files to web/streams/
Move JSByteLengthQueuingStrategy, JSCountQueuingStrategy from
webcore/ to web/streams/. Now all stream-related files are together.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
018f9e0946 Move AbortController/AbortSignal C++ files to web/events/
Move AbortController, AbortSignal, AbortAlgorithm, JSAbortController,
JSAbortSignal, JSAbortAlgorithm from webcore/ to web/events/.
Now all abort-related files are together.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
834605e5c5 Move FileReader.zig to web/blob/
Move FileReader.zig from webcore/ to web/blob/.
Update import in webcore.zig.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
02a022f143 Move CookieMap.zig to api/cookie/
Move CookieMap.zig from webcore/ to api/cookie/.
Update import in webcore.zig.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
16e98547c9 Move HTTP parser files to web/http/
Move HTTPParsers, HeaderFieldTokenizer, RFC7230 from webcore/ to web/http/.
Updated cmake/Sources.json and cmake/targets/BuildBun.cmake.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:23 +00:00
Claude Bot
e3cb63ec8e Move serialization files to web/serialization/
Move SerializedScriptValue, StructuredClone, StructuredSerializeOptions,
JSStructuredSerializeOptions, JSDOMConvertSerializedScriptValue
from webcore/ to web/serialization/.
Updated cmake/Sources.json and cmake/targets/BuildBun.cmake.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
f040a828d3 Move MIME files to web/mime/
Move JSMIMEBindings, JSMIMEParams, JSMIMEType from webcore/ to web/mime/.
Updated cmake/Sources.json and cmake/targets/BuildBun.cmake.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
2194724425 Move MessageChannel files to web/messaging/
Move MessageChannel, JSMessageChannel files from webcore/ to web/messaging/.
Updated cmake/Sources.json and cmake/targets/BuildBun.cmake.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
313f714b6d Move Worker files to web/workers/
Move Worker, JSWorker, JSWorkerOptions, WorkerOptions, JSServiceWorker
from webcore/ to web/workers/.
Updated cmake/Sources.json and cmake/targets/BuildBun.cmake.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
8696c55595 Move S3 Zig files to api/s3/
Move S3Client.zig, S3File.zig, S3Stat.zig from webcore/ to api/s3/.
Update imports in webcore.zig and Blob.zig.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
9ffbb5c99c Move WebSocket files to web/websocket/
Move 8 WebSocket-related files from webcore/ to web/websocket/.
Includes WebSocket core, JSWebSocket bindings, and helpers.
Updated cmake/Sources.json and cmake/targets/BuildBun.cmake.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
52407bca9c Move Performance files to web/performance/
Move 60 performance-related files from webcore/ to web/performance/.
Includes Performance API, PerformanceObserver, Timing, Marks, Measures,
ResourceTiming, ServerTiming, and NetworkLoadMetrics.

Added JSDOMWrapperCache.h include to JSPerformanceEntryCustom.cpp.
Updated cmake/Sources.json and cmake/targets/BuildBun.cmake.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
5a33924475 Move blob files to web/blob/
Move Blob.zig, ByteBlobLoader.zig and blob/ subdirectory files from
webcore/ to web/blob/. Update relative imports for env.zig, S3File.zig,
and Store/read_file/write_file/copy_file references.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
c67d6182f7 refactor: move Response/Request/Body files to web/http/
Move Response.zig, Request.zig, Body.zig, BakeResponse.zig,
and response.classes.ts from webcore/ to web/http/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
c9bb8b16c1 refactor: move stream-related files to web/streams/
Move ReadableStream, WritableStream, TransformStream, Sink,
FileSink, ByteStream, ResumableSink, JS* stream files from
webcore/ to web/streams/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
cf86901409 refactor: move event-related files to web/events/
Move Event*, MessagePort*, BroadcastChannel*, AbortSignal,
EventTarget, EventEmitter, JS* event files from bindings/
and webcore/ to web/events/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
f13396c8d2 refactor: move compression files to web/compression/
Move JSCompressionStream and JSDecompressionStream from bindings/
to web/compression/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
f066c98c2a refactor: move encoding-related files to web/encoding/
Move Base64Helpers, TextCodec*, TextEncoder*, TextDecoder*,
EncodingLabel, encoding.zig and related files from bindings/
and webcore/ to web/encoding/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
f0db7ce4e9 refactor: move blob-related files to web/blob/
Move blob.cpp, DOMFormData, JSDOMFile, and JSDOMFormData
from bindings/ and webcore/ to web/blob/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
a8a15feb8e refactor: move URL-related files to web/url/
Move DOMURL, URLSearchParams, URLPattern*, EncodeURIComponent,
decodeURIComponentSIMD, ObjectURLRegistry, NodeURL and related
files from bindings/ and webcore/ to web/url/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
57a92ae359 refactor: move fetch-related files to web/fetch/
Move FetchHeaders, FetchTasklet, HTTPHeader*, JSFetchHeaders,
NodeFetch, Undici, and fetch.zig from bindings/ and webcore/
to web/fetch/.

This groups all fetch-related functionality in one directory
for easier navigation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
0197c54a2c refactor: move Bun core files to core/
Move BunClientData, BunCommonStrings, BunGCOutputConstraint,
BunGlobalScope, BunIDL*, BunJSCEventLoop, BunObject, BunString,
and BunWorkerGlobalScope from bindings/ to core/.

This makes the purpose of these files clearer - they are core Bun
runtime infrastructure rather than JavaScript bindings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
73abb99ea3 refactor: move process files to api/process/
Move process-related files from bindings/ to api/process/:
- BunProcess, ProcessBindingBuffer, ProcessBindingConstants
- ProcessBindingFs, ProcessBindingHTTPParser, ProcessBindingNatives
- ProcessBindingTTYWrap, ProcessBindingUV, ProcessIdentifier
- bun-spawn

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
b9af431178 refactor: move napi and module files to dedicated directories
- Move napi files from bindings/ to compat/napi/
- Move module loader files from bindings/ to module/
  - InternalModuleRegistry, JSModuleLoader, JSCommonJSModule, etc.
- Update all import paths and cmake configurations

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
c4205a4a3a refactor: move libuv and webcore to dedicated directories
- Move bindings/libuv/ to compat/libuv/ for libuv compatibility layer
- Move bindings/webcore/ to webcore/ (438 files)
- Update all include paths for webcore/ prefix removal
- Fix relative includes in webcrypto files

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:22 +00:00
Claude Bot
772533afd8 refactor: move node bindings to buntime/node/
Consolidate node compatibility files:
- Move node C++ files from bindings/node/ to buntime/node/
- Rename bindings/node/crypto to node/crypto_bindings for clarity
- Move webcrypto from bindings/ to webcore/webcrypto/
- Update cmake include paths and source patterns

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:21 +00:00
Claude Bot
ced6ba6c82 refactor: move webcrypto to webcore/webcrypto/
Move webcrypto directory from bindings/ to webcore/webcrypto/ for
better organization of web-related APIs.

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:21 +00:00
Claude Bot
d8b43c28da refactor: move v8 compat to compat/v8/
Move v8 directory from bindings/ to compat/v8/ for better organization
of compatibility layers.

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:21 +00:00
Claude Bot
bfc99fa5de refactor: reorganize api/ subdirectories (step 4.5-4.14)
Move domain-specific files from bindings/ to api/ subdirectories:
- api/s3/: S3 client and error handling
- api/secrets/: Platform secrets management
- api/ffi/: Foreign Function Interface
- api/sqlite/: SQLite bindings (moved from bindings/sqlite/)
- api/sql/: SQL client
- api/shell/: Shell bindings
- api/ipc/: IPC bindings
- api/test/: Testing utilities
- api/server/: HTTP server bindings
- api/plugin/: Bundler plugin system

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:21 +00:00
Claude Bot
e306d9dbda refactor: move cookie files to api/cookie/
Step 4.4 of source reorganization - move cookie-related files:
- JSCookie.cpp/h
- JSCookieMap.cpp/h

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:21 +00:00
Claude Bot
0620ff58fe refactor: move error files to api/error/
Step 4.3 of source reorganization - move error-related files:
- DeferredError.zig
- ErrorCode.cpp/h/ts/zig
- ErrorStackFrame.cpp/h
- ErrorStackTrace.cpp/h
- Errorable.zig
- JSErrorCode.zig
- SystemError.zig
- ZigErrorType.zig

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:21 +00:00
Claude Bot
7227eef0ff refactor: move inspector files to api/inspector/
Step 4.2 of source reorganization - move inspector-related files:
- BunInspector.cpp
- InspectorBunFrontendDevServerAgent.cpp/h
- InspectorHTTPServerAgent.cpp/h
- InspectorLifecycleAgent.cpp/h
- InspectorTestReporterAgent.cpp/h

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:21 +00:00
Claude Bot
781a3f9508 refactor: move console files to api/console/
Step 4.1 of source reorganization - move console-related files:
- ConsoleObject.cpp/h
- UtilInspect.cpp/h
- ConsoleObject.zig

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:21 +00:00
Claude Bot
5fea6eb184 refactor: create src/test_runner/ for bun:test
Step 3 of source reorganization - move test runner files from
src/buntime/test/ to src/test_runner/ for better discoverability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:21 +00:00
Claude Bot
e0ae7683a7 refactor: create src/transpiler/ for JS/TS transpiler
Step 2 of source reorganization - move js_parser, js_lexer, js_printer,
and transpiler files to src/transpiler/ directory.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:21 +00:00
Claude Bot
e84b4b4847 refactor: rename src/bun.js/ to src/buntime/
Step 1 of source reorganization - rename the JavaScript runtime
directory from bun.js to buntime for better discoverability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 08:53:12 +00:00
1724 changed files with 7213 additions and 4817 deletions

View File

@@ -22,7 +22,7 @@ Bun reports a Node.js version for compatibility with the Node.js ecosystem. This
- `NODEJS_ABI_VERSION` - The ABI version number (find using command below)
### 3. Version Strings
- `src/bun.js/bindings/BunProcess.cpp`
- `src/buntime/bindings/BunProcess.cpp`
- Update `Bun__versions_node` with the Node.js version
- Update `Bun__versions_v8` with the V8 version (find using command below)
@@ -33,7 +33,7 @@ Bun reports a Node.js version for compatibility with the Node.js ecosystem. This
## Files That May Need Updates
Only check these if the build fails or tests crash after updating version numbers:
- V8 compatibility files in `src/bun.js/bindings/v8/` (if V8 API changed)
- V8 compatibility files in `src/buntime/bindings/v8/` (if V8 API changed)
- Test files (if Node.js requires newer C++ standard)
## Quick Commands to Find Version Info

View File

@@ -19,8 +19,8 @@ No public constructor? Only Prototype and class needed.
Classes with C++ fields need subspaces in:
- `src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h`
- `src/bun.js/bindings/webcore/DOMIsoSubspaces.h`
- `src/buntime/bindings/webcore/DOMClientIsoSubspaces.h`
- `src/buntime/bindings/webcore/DOMIsoSubspaces.h`
```cpp
template<typename MyClassT, JSC::SubspaceAccess mode>

View File

@@ -89,7 +89,7 @@ pub const TextDecoder = struct {
- Use `bun.JSError!JSValue` return type for error handling
- Use `globalObject` not `ctx`
- `deinit()` for cleanup, `finalize()` called by GC
- Update `src/bun.js/bindings/generated_classes_list.zig`
- Update `src/buntime/bindings/generated_classes_list.zig`
## CallFrame Access
@@ -196,7 +196,7 @@ pub const MyClass = struct {
};
```
3. Add to `src/bun.js/bindings/generated_classes_list.zig`
3. Add to `src/buntime/bindings/generated_classes_list.zig`
## Generated Components

183
CLAUDE.md
View File

@@ -102,84 +102,129 @@ test("(multi-file test) my feature", async () => {
## Code Architecture
### Directory Structure Overview
The codebase is organized so you can **guess where code lives**:
| Task | Location |
| --------------------- | ----------------------------------- |
| Fix the transpiler | `src/transpiler/` |
| Fix the test runner | `src/test_runner/` |
| Fix the bundler | `src/bundler/` |
| Fix bun install | `src/install/` |
| Fix CSS parsing | `src/css/` |
| Fix the shell | `src/shell/` |
| Fix Postgres | `src/sql/postgres/` |
| Fix MySQL | `src/sql/mysql/` |
| Fix Valkey/Redis | `src/valkey/` |
| Fix S3 | `src/s3/` or `src/buntime/api/s3/` |
| Fix Bake | `src/bake/` |
| Fix Bun.serve() | `src/buntime/api/server/` |
| Fix fetch() | `src/buntime/web/fetch/` |
| Fix WebSocket | `src/buntime/web/websocket/` |
| Fix node:fs | `src/buntime/node/fs/` |
| Fix node:crypto | `src/buntime/node/crypto/` |
| Fix crypto.subtle | `src/buntime/web/webcrypto/` |
| Fix N-API | `src/buntime/compat/napi/` |
| Fix V8 compat | `src/buntime/compat/v8/` |
### Language Structure
- **Zig code** (`src/*.zig`): Core runtime, JavaScript bindings, package manager
- **C++ code** (`src/bun.js/bindings/*.cpp`): JavaScriptCore bindings, Web APIs
- **TypeScript** (`src/js/`): Built-in JavaScript modules with special syntax (see JavaScript Modules section)
- **Generated code**: Many files are auto-generated from `.classes.ts` and other sources. Bun will automatically rebuild these files when you make changes to them.
- **C++ code** (`src/buntime/**/*.cpp`): JavaScriptCore bindings, Web APIs
- **TypeScript** (`src/js/`): Built-in JavaScript modules with special syntax
- **Generated code**: Auto-generated from `.classes.ts` files during build
### Core Source Organization
### Top-Level Source Organization
#### Runtime Core (`src/`)
- `bun.zig` - Main entry point
- `cli.zig` - CLI command orchestration
- `js_parser.zig`, `js_lexer.zig`, `js_printer.zig` - JavaScript parsing/printing
- `transpiler.zig` - Wrapper around js_parser with sourcemap support
- `resolver/` - Module resolution system
- `allocators/` - Custom memory allocators for performance
#### JavaScript Runtime (`src/bun.js/`)
- `bindings/` - C++ JavaScriptCore bindings
- Generated classes from `.classes.ts` files
- Manual bindings for complex APIs
- `api/` - Bun-specific APIs
- `server.zig` - HTTP server implementation
- `FFI.zig` - Foreign Function Interface
- `crypto.zig` - Cryptographic operations
- `glob.zig` - File pattern matching
- `node/` - Node.js compatibility layer
- Module implementations (fs, path, crypto, etc.)
- Process and Buffer APIs
- `webcore/` - Web API implementations
- `fetch.zig` - Fetch API
- `streams.zig` - Web Streams
- `Blob.zig`, `Response.zig`, `Request.zig`
- `event_loop/` - Event loop and task management
#### Build Tools & Package Manager
- `src/bundler/` - JavaScript bundler
- Advanced tree-shaking
- CSS processing
- HTML handling
- `src/install/` - Package manager
- `lockfile/` - Lockfile handling
- `npm.zig` - npm registry client
- `lifecycle_script_runner.zig` - Package scripts
#### Other Key Components
- `src/shell/` - Cross-platform shell implementation
- `src/css/` - CSS parser and processor
- `src/http/` - HTTP client implementation
- `websocket_client/` - WebSocket client (including deflate support)
- `src/sql/` - SQL database integrations
- `src/bake/` - Server-side rendering framework
### JavaScript Class Implementation (C++)
When implementing JavaScript classes in C++:
1. Create three classes if there's a public constructor:
- `class Foo : public JSC::JSDestructibleObject` (if has C++ fields)
- `class FooPrototype : public JSC::JSNonFinalObject`
- `class FooConstructor : public JSC::InternalFunction`
2. Define properties using HashTableValue arrays
3. Add iso subspaces for classes with C++ fields
4. Cache structures in ZigGlobalObject
```
src/
├── transpiler/ # JS/TS transpiler (js_parser, js_lexer, js_printer)
├── test_runner/ # bun:test implementation
├── bundler/ # bun build
├── resolver/ # Module resolution
├── install/ # Package manager (bun install)
├── css/ # CSS parser
├── shell/ # Bun.$ shell
├── bake/ # Bake framework
├── sql/ # SQL clients (postgres/, mysql/)
├── s3/ # S3 core
├── valkey/ # Valkey/Redis
├── http/ # HTTP client
├── string/ # String utilities
├── ast/ # AST types
├── js/ # TypeScript built-in modules
└── buntime/ # JavaScript runtime
├── api/ # Bun.* APIs
│ ├── server/ # Bun.serve()
│ ├── console/ # console.*
│ ├── inspector/ # Debugger, profiler
│ ├── error/ # Error handling, stack traces
│ ├── cookie/ # Cookie parsing
│ ├── s3/ # S3 JS bindings
│ ├── ffi/ # Bun.FFI
│ ├── sqlite/ # bun:sqlite
│ ├── sql/ # SQL bindings
│ ├── shell/ # Shell bindings
│ ├── ipc/ # IPC
│ ├── plugin/ # Bundler plugins
│ ├── secrets/ # Secrets API
│ └── test/ # Test helpers
├── web/ # Web Standards
│ ├── fetch/ # Fetch API
│ ├── url/ # URL, URLSearchParams
│ ├── blob/ # Blob, File, FormData
│ ├── encoding/ # TextEncoder/Decoder
│ ├── compression/ # CompressionStream
│ ├── events/ # EventTarget, CustomEvent
│ ├── streams/ # ReadableStream, WritableStream
│ ├── performance/ # Performance API
│ ├── websocket/ # WebSocket
│ └── webcrypto/ # crypto.subtle
├── node/ # Node.js Compatibility
│ ├── buffer/ # Buffer
│ ├── process/ # process.*
│ ├── vm/ # node:vm
│ ├── crypto/ # node:crypto
│ ├── http/ # node:http
│ ├── fs/ # node:fs helpers
│ ├── os/ # node:os
│ ├── path/ # node:path
│ ├── util/ # node:util
│ ├── timers/ # Timers
│ ├── async_hooks/ # AsyncLocalStorage
│ ├── perf_hooks/ # Performance hooks
│ └── constants/ # Constants
├── compat/ # Native Addon Compatibility
│ ├── napi/ # N-API
│ ├── v8/ # V8 C++ API
│ ├── libuv/ # libuv polyfills
│ └── windows/ # Windows-specific
├── jsc/ # JavaScriptCore Integration
│ ├── types/ # JSValue, JSString, JSArray, etc.
│ ├── global/ # ZigGlobalObject, BunGlobalScope
│ ├── gc/ # GC helpers, weak refs
│ ├── interop/ # C++/Zig bindings, IDL
│ └── generated/ # Generated bindings
├── module/ # Module system (CommonJS, ESM)
├── event_loop/ # Event loop, tasks, timers
└── core/ # VirtualMachine, config
```
### Code Generation
Code generation happens automatically as part of the build process. The main scripts are:
Code generation happens automatically during build. Main scripts:
- `src/codegen/generate-classes.ts` - Generates Zig & C++ bindings from `*.classes.ts` files
- `src/codegen/generate-jssink.ts` - Generates stream-related classes
- `src/codegen/bundle-modules.ts` - Bundles built-in modules like `node:fs`
- `src/codegen/bundle-functions.ts` - Bundles global functions like `ReadableStream`
- `src/codegen/generate-classes.ts` - Generates Zig & C++ from `*.classes.ts`
- `src/codegen/generate-jssink.ts` - Stream-related classes
- `src/codegen/bundle-modules.ts` - Built-in modules like `node:fs`
- `src/codegen/bundle-functions.ts` - Global functions like `ReadableStream`
In development, bundled modules can be reloaded without rebuilding Zig by running `bun run build`.

1112
PLAN.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -42,7 +42,7 @@ const BunBuildOptions = struct {
/// is set (to allow CI to build a portable executable). Affected files:
///
/// - src/bake/runtime.ts (bundled)
/// - src/bun.js/api/FFI.h
/// - src/buntime/api/FFI.h
///
/// A similar technique is used in C++ code for JavaScript builtins
codegen_embed: bool = false,

View File

@@ -9,14 +9,17 @@
},
{
"output": "ZigGeneratedClassesSources.txt",
"paths": ["src/bun.js/*.classes.ts", "src/bun.js/{api,node,test,webcore}/*.classes.ts"]
"paths": [
"src/buntime/*.classes.ts",
"src/buntime/{api,node,web}/*.classes.ts",
"src/buntime/web/*/*.classes.ts",
"src/buntime/api/*/*.classes.ts",
"src/test_runner/*.classes.ts"
]
},
{
"output": "JavaScriptSources.txt",
"paths": [
"src/js/**/*.{js,ts}",
"src/install/PackageManager/scanner-entry.ts"
]
"paths": ["src/js/**/*.{js,ts}", "src/install/PackageManager/scanner-entry.ts"]
},
{
"output": "JavaScriptCodegenSources.txt",
@@ -47,17 +50,63 @@
"output": "CxxSources.txt",
"paths": [
"src/io/*.cpp",
"src/bun.js/modules/*.cpp",
"src/bun.js/bindings/*.cpp",
"src/bun.js/bindings/webcore/*.cpp",
"src/bun.js/bindings/sqlite/*.cpp",
"src/bun.js/bindings/webcrypto/*.cpp",
"src/bun.js/bindings/webcrypto/*/*.cpp",
"src/bun.js/bindings/node/*.cpp",
"src/bun.js/bindings/node/crypto/*.cpp",
"src/bun.js/bindings/node/http/*.cpp",
"src/bun.js/bindings/v8/*.cpp",
"src/bun.js/bindings/v8/shim/*.cpp",
"src/buntime/modules/*.cpp",
"src/buntime/jsc/types/*.cpp",
"src/buntime/jsc/global/*.cpp",
"src/buntime/jsc/gc/*.cpp",
"src/buntime/jsc/interop/*.cpp",
"src/buntime/jsc/generated/*.cpp",
"src/buntime/api/sqlite/*.cpp",
"src/buntime/web/webcrypto/*.cpp",
"src/buntime/web/webcrypto/*/*.cpp",
"src/buntime/node/buffer/*.cpp",
"src/buntime/node/process/*.cpp",
"src/buntime/node/vm/*.cpp",
"src/buntime/node/crypto/*.cpp",
"src/buntime/node/http/*.cpp",
"src/buntime/node/fs/*.cpp",
"src/buntime/node/os/*.cpp",
"src/buntime/node/path/*.cpp",
"src/buntime/node/util/*.cpp",
"src/buntime/node/timers/*.cpp",
"src/buntime/node/async_hooks/*.cpp",
"src/buntime/node/perf_hooks/*.cpp",
"src/buntime/compat/v8/*.cpp",
"src/buntime/compat/v8/shim/*.cpp",
"src/buntime/compat/napi/*.cpp",
"src/buntime/module/*.cpp",
"src/buntime/api/console/*.cpp",
"src/buntime/api/inspector/*.cpp",
"src/buntime/api/error/*.cpp",
"src/buntime/api/cookie/*.cpp",
"src/buntime/api/s3/*.cpp",
"src/buntime/api/secrets/*.cpp",
"src/buntime/api/ffi/*.cpp",
"src/buntime/api/sql/*.cpp",
"src/buntime/api/shell/*.cpp",
"src/buntime/api/ipc/*.cpp",
"src/buntime/api/test/*.cpp",
"src/buntime/api/server/*.cpp",
"src/buntime/api/plugin/*.cpp",
"src/buntime/api/process/*.cpp",
"src/buntime/api/bun/*.cpp",
"src/buntime/core/*.cpp",
"src/buntime/event_loop/*.cpp",
"src/string/*.cpp",
"src/buntime/web/fetch/*.cpp",
"src/buntime/web/url/*.cpp",
"src/buntime/web/blob/*.cpp",
"src/buntime/web/http/*.cpp",
"src/buntime/web/encoding/*.cpp",
"src/buntime/web/compression/*.cpp",
"src/buntime/web/events/*.cpp",
"src/buntime/web/streams/*.cpp",
"src/buntime/web/performance/*.cpp",
"src/buntime/web/websocket/*.cpp",
"src/buntime/web/workers/*.cpp",
"src/buntime/web/messaging/*.cpp",
"src/buntime/web/mime/*.cpp",
"src/buntime/web/serialization/*.cpp",
"src/bake/*.cpp",
"src/deps/*.cpp",
"src/vm/*.cpp",
@@ -71,10 +120,10 @@
"packages/bun-usockets/src/eventing/*.c",
"packages/bun-usockets/src/internal/*.c",
"packages/bun-usockets/src/crypto/*.c",
"src/bun.js/bindings/uv-posix-polyfills.c",
"src/bun.js/bindings/uv-posix-stubs.c",
"src/buntime/compat/libuv/uv-posix-polyfills.c",
"src/buntime/compat/libuv/uv-posix-stubs.c",
"src/*.c",
"src/bun.js/bindings/node/http/llhttp/*.c"
"src/buntime/node/http/llhttp/*.c"
]
}
]

View File

@@ -1,8 +1,8 @@
# https://clang.llvm.org/docs/ClangFormat.html
file(GLOB BUN_H_SOURCES LIST_DIRECTORIES false ${CONFIGURE_DEPENDS}
${CWD}/src/bun.js/bindings/*.h
${CWD}/src/bun.js/modules/*.h
${CWD}/src/buntime/bindings/*.h
${CWD}/src/buntime/modules/*.h
)
set(CLANG_FORMAT_SOURCES ${BUN_C_SOURCES} ${BUN_CXX_SOURCES} ${BUN_H_SOURCES})

View File

@@ -225,9 +225,9 @@ set(BUN_ERROR_CODE_SCRIPT ${CWD}/src/codegen/generate-node-errors.ts)
set(BUN_ERROR_CODE_SOURCES
${BUN_ERROR_CODE_SCRIPT}
${CWD}/src/bun.js/bindings/ErrorCode.ts
${CWD}/src/bun.js/bindings/ErrorCode.cpp
${CWD}/src/bun.js/bindings/ErrorCode.h
${CWD}/src/buntime/api/error/ErrorCode.ts
${CWD}/src/buntime/api/error/ErrorCode.cpp
${CWD}/src/buntime/api/error/ErrorCode.h
)
set(BUN_ERROR_CODE_OUTPUTS
@@ -295,7 +295,7 @@ absolute_sources(BUN_JAVASCRIPT_SOURCES ${CWD}/cmake/sources/JavaScriptSources.t
absolute_sources(BUN_JAVASCRIPT_CODEGEN_SOURCES ${CWD}/cmake/sources/JavaScriptCodegenSources.txt)
list(APPEND BUN_JAVASCRIPT_CODEGEN_SOURCES
${CWD}/src/bun.js/bindings/InternalModuleRegistry.cpp
${CWD}/src/buntime/module/InternalModuleRegistry.cpp
)
set(BUN_JAVASCRIPT_OUTPUTS
@@ -310,7 +310,7 @@ set(BUN_JAVASCRIPT_OUTPUTS
${CODEGEN_PATH}/SyntheticModuleType.h
${CODEGEN_PATH}/GeneratedJS2Native.h
# Zig will complain if files are outside of the source directory
${CWD}/src/bun.js/bindings/GeneratedJS2Native.zig
${CWD}/src/buntime/jsc/generated/GeneratedJS2Native.zig
)
set(BUN_CPP_OUTPUTS
@@ -377,7 +377,7 @@ set(BUN_BAKE_RUNTIME_CODEGEN_SCRIPT ${CWD}/src/codegen/bake-codegen.ts)
absolute_sources(BUN_BAKE_RUNTIME_SOURCES ${CWD}/cmake/sources/BakeRuntimeSources.txt)
list(APPEND BUN_BAKE_RUNTIME_CODEGEN_SOURCES
${CWD}/src/bun.js/bindings/InternalModuleRegistry.cpp
${CWD}/src/buntime/module/InternalModuleRegistry.cpp
)
set(BUN_BAKE_RUNTIME_OUTPUTS
@@ -462,7 +462,7 @@ set(BUN_BINDGEN_CPP_OUTPUTS
)
set(BUN_BINDGEN_ZIG_OUTPUTS
${CWD}/src/bun.js/bindings/GeneratedBindings.zig
${CWD}/src/buntime/jsc/generated/GeneratedBindings.zig
)
register_command(
@@ -516,16 +516,16 @@ register_command(
set(BUN_OBJECT_LUT_SCRIPT ${CWD}/src/codegen/create-hash-table.ts)
set(BUN_OBJECT_LUT_SOURCES
${CWD}/src/bun.js/bindings/BunObject.cpp
${CWD}/src/bun.js/bindings/ZigGlobalObject.lut.txt
${CWD}/src/bun.js/bindings/JSBuffer.cpp
${CWD}/src/bun.js/bindings/BunProcess.cpp
${CWD}/src/bun.js/bindings/ProcessBindingBuffer.cpp
${CWD}/src/bun.js/bindings/ProcessBindingConstants.cpp
${CWD}/src/bun.js/bindings/ProcessBindingFs.cpp
${CWD}/src/bun.js/bindings/ProcessBindingNatives.cpp
${CWD}/src/bun.js/bindings/ProcessBindingHTTPParser.cpp
${CWD}/src/bun.js/modules/NodeModuleModule.cpp
${CWD}/src/buntime/jsc/global/BunObject.cpp
${CWD}/src/buntime/jsc/global/ZigGlobalObject.lut.txt
${CWD}/src/buntime/node/buffer/JSBuffer.cpp
${CWD}/src/buntime/api/process/BunProcess.cpp
${CWD}/src/buntime/api/process/ProcessBindingBuffer.cpp
${CWD}/src/buntime/api/process/ProcessBindingConstants.cpp
${CWD}/src/buntime/api/process/ProcessBindingFs.cpp
${CWD}/src/buntime/api/process/ProcessBindingNatives.cpp
${CWD}/src/buntime/api/process/ProcessBindingHTTPParser.cpp
${CWD}/src/buntime/modules/NodeModuleModule.cpp
${CODEGEN_PATH}/ZigGeneratedClasses.lut.txt
)
@@ -591,24 +591,24 @@ foreach(i RANGE 0 ${BUN_OBJECT_LUT_SOURCES_MAX_INDEX})
endforeach()
WEBKIT_ADD_SOURCE_DEPENDENCIES(
${CWD}/src/bun.js/bindings/ErrorCode.cpp
${CWD}/src/buntime/api/error/ErrorCode.cpp
${CODEGEN_PATH}/ErrorCode+List.h
)
WEBKIT_ADD_SOURCE_DEPENDENCIES(
${CWD}/src/bun.js/bindings/ErrorCode.h
${CWD}/src/buntime/api/error/ErrorCode.h
${CODEGEN_PATH}/ErrorCode+Data.h
)
WEBKIT_ADD_SOURCE_DEPENDENCIES(
${CWD}/src/bun.js/bindings/ZigGlobalObject.cpp
${CWD}/src/buntime/jsc/global/ZigGlobalObject.cpp
${CODEGEN_PATH}/ZigGlobalObject.lut.h
)
WEBKIT_ADD_SOURCE_DEPENDENCIES(
${CWD}/src/bun.js/bindings/InternalModuleRegistry.cpp
${CWD}/src/buntime/module/InternalModuleRegistry.cpp
${CODEGEN_PATH}/InternalModuleRegistryConstants.h
)
@@ -727,8 +727,8 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "build.zig")
set(BUN_USOCKETS_SOURCE ${CWD}/packages/bun-usockets)
if(WIN32)
list(APPEND BUN_CXX_SOURCES ${CWD}/src/bun.js/bindings/windows/rescle.cpp)
list(APPEND BUN_CXX_SOURCES ${CWD}/src/bun.js/bindings/windows/rescle-binding.cpp)
list(APPEND BUN_CXX_SOURCES ${CWD}/src/buntime/compat/windows/rescle.cpp)
list(APPEND BUN_CXX_SOURCES ${CWD}/src/buntime/compat/windows/rescle-binding.cpp)
endif()
register_repository(
@@ -843,7 +843,7 @@ if (NOT WIN32)
# 2. In CI AND BUN_CPP_ONLY is enabled
if(NOT CI OR (CI AND BUN_CPP_ONLY))
target_precompile_headers(${bun} PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:${CWD}/src/bun.js/bindings/root.h>"
"$<$<COMPILE_LANGUAGE:CXX>:${CWD}/src/buntime/jsc/interop/root.h>"
)
endif()
endif()
@@ -851,21 +851,72 @@ endif()
# --- C/C++ Includes ---
if(WIN32)
target_include_directories(${bun} PRIVATE ${CWD}/src/bun.js/bindings/windows)
target_include_directories(${bun} PRIVATE ${CWD}/src/buntime/compat/windows)
endif()
target_include_directories(${bun} PRIVATE
${CWD}/packages
${CWD}/packages/bun-usockets
${CWD}/packages/bun-usockets/src
${CWD}/src/bun.js/bindings
${CWD}/src/bun.js/bindings/webcore
${CWD}/src/bun.js/bindings/webcrypto
${CWD}/src/bun.js/bindings/node/crypto
${CWD}/src/bun.js/bindings/node/http
${CWD}/src/bun.js/bindings/sqlite
${CWD}/src/bun.js/bindings/v8
${CWD}/src/bun.js/modules
${CWD}/src/buntime/jsc/interop
${CWD}/src/buntime/jsc/global
${CWD}/src/buntime/jsc/gc
${CWD}/src/buntime/jsc/types
${CWD}/src/buntime/jsc/generated
${CWD}/src/bake
${CWD}/src/string
${CWD}/src/buntime/web
${CWD}/src/buntime/web/webcrypto
${CWD}/src/buntime/node
${CWD}/src/buntime/node/buffer
${CWD}/src/buntime/node/process
${CWD}/src/buntime/node/vm
${CWD}/src/buntime/node/crypto
${CWD}/src/buntime/node/http
${CWD}/src/buntime/node/fs
${CWD}/src/buntime/node/os
${CWD}/src/buntime/node/path
${CWD}/src/buntime/node/util
${CWD}/src/buntime/node/timers
${CWD}/src/buntime/node/async_hooks
${CWD}/src/buntime/node/perf_hooks
${CWD}/src/buntime/node/constants
${CWD}/src/buntime/api/sqlite
${CWD}/src/buntime/compat/v8
${CWD}/src/buntime/compat/napi
${CWD}/src/buntime/compat
${CWD}/src/buntime/module
${CWD}/src/buntime/api/console
${CWD}/src/buntime/api/inspector
${CWD}/src/buntime/api/error
${CWD}/src/buntime/api/cookie
${CWD}/src/buntime/api/s3
${CWD}/src/buntime/api/secrets
${CWD}/src/buntime/api/ffi
${CWD}/src/buntime/api/sql
${CWD}/src/buntime/api/shell
${CWD}/src/buntime/api/ipc
${CWD}/src/buntime/api/test
${CWD}/src/buntime/api/server
${CWD}/src/buntime/api/plugin
${CWD}/src/buntime/api/process
${CWD}/src/buntime/core
${CWD}/src/buntime/event_loop
${CWD}/src/buntime/web/fetch
${CWD}/src/buntime/web/url
${CWD}/src/buntime/web/blob
${CWD}/src/buntime/web/http
${CWD}/src/buntime/web/encoding
${CWD}/src/buntime/web/compression
${CWD}/src/buntime/web/events
${CWD}/src/buntime/web/streams
${CWD}/src/buntime/web/performance
${CWD}/src/buntime/web/websocket
${CWD}/src/buntime/web/workers
${CWD}/src/buntime/web/messaging
${CWD}/src/buntime/web/mime
${CWD}/src/buntime/web/serialization
${CWD}/src/buntime/modules
${CWD}/src/js/builtins
${CWD}/src/napi
${CWD}/src/deps
@@ -878,7 +929,7 @@ target_include_directories(${bun} PRIVATE
)
if(NOT WIN32)
target_include_directories(${bun} PRIVATE ${CWD}/src/bun.js/bindings/libuv)
target_include_directories(${bun} PRIVATE ${CWD}/src/buntime/compat/libuv)
endif()
if(LINUX)

View File

@@ -2,7 +2,7 @@ register_cmake_command(
TARGET
sqlite
CWD
${CWD}/src/bun.js/bindings/sqlite
${CWD}/src/buntime/bindings/sqlite
LIBRARIES
sqlite3
INCLUDES

View File

@@ -18,7 +18,7 @@ if (NOT CI)
endif()
# If this is not set, some advanced features are not checked.
# https://github.com/oven-sh/bun/blob/cd7f6a1589db7f1e39dc4e3f4a17234afbe7826c/src/bun.js/javascript.zig#L1069-L1072
# https://github.com/oven-sh/bun/blob/cd7f6a1589db7f1e39dc4e3f4a17234afbe7826c/src/buntime/javascript.zig#L1069-L1072
setenv(BUN_GARBAGE_COLLECTOR_LEVEL 1)
setenv(BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING 1)
setenv(BUN_DEBUG_QUIET_LOGS 1)

View File

@@ -49,7 +49,7 @@
"build:debug-zig-release": "cmake . -DCMAKE_BUILD_TYPE=Release -DZIG_OPTIMIZE=Debug -GNinja -Bbuild-debug-zig-release && ninja -Cbuild-debug-zig-release",
"run:linux": "docker run --rm -v \"$PWD:/root/bun/\" -w /root/bun ghcr.io/oven-sh/bun-development-docker-image",
"css-properties": "bun run src/css/properties/generate_properties.ts",
"uv-posix-stubs": "bun run src/bun.js/bindings/libuv/generate_uv_posix_stubs.ts",
"uv-posix-stubs": "bun run src/buntime/compat/libuv/generate_uv_posix_stubs.ts",
"bump": "bun ./scripts/bump.ts",
"jsc:build": "bun ./scripts/build-jsc.ts release",
"jsc:build:debug": "bun ./scripts/build-jsc.ts debug",

View File

@@ -1 +0,0 @@
CLAUDE.md

11
src/AGENTS.md Normal file
View File

@@ -0,0 +1,11 @@
## Zig
Syntax reminders:
- Private fields are fully supported in Zig with the `#` prefix. `struct { #foo: u32 };` makes a struct with a private field named `#foo`.
- Decl literals in Zig are recommended. `const decl: Decl = .{ .binding = 0, .value = 0 };`
Conventions:
- Prefer `@import` at the **bottom** of the file, but the auto formatter will move them so you don't need to worry about it.
- You must be patient with the build.

View File

@@ -702,7 +702,7 @@ pub const BabyList = bun.BabyList;
const string = []const u8;
const std = @import("std");
const TypeScript = @import("./js_parser.zig").TypeScript;
const TypeScript = @import("./transpiler/js_parser.zig").TypeScript;
const bun = @import("bun");
const Environment = bun.Environment;

View File

@@ -3254,7 +3254,7 @@ fn stringToEquivalentNumberValue(str: []const u8) f64 {
const string = []const u8;
const stringZ = [:0]const u8;
const JSPrinter = @import("../js_printer.zig");
const JSPrinter = @import("../transpiler/js_printer.zig");
const std = @import("std");
const bun = @import("bun");

View File

@@ -219,7 +219,7 @@ pub fn ERR_toJS(globalThis: *jsc.JSGlobalObject, err_code: u32) jsc.JSValue {
return globalThis.ERR(.BORINGSSL, "{s}", .{error_message}).toJS();
}
const X509 = @import("./bun.js/api/bun/x509.zig");
const X509 = @import("./buntime/api/bun/x509.zig");
const boring = @import("./deps/boringssl.translated.zig");
const builtin = @import("builtin");
const c_ares = @import("./deps/c_ares.zig");

View File

@@ -1,7 +1,7 @@
pub const jsc = @import("./bun.js/jsc.zig");
pub const webcore = @import("./bun.js/webcore.zig");
pub const api = @import("./bun.js/api.zig");
pub const bindgen = @import("./bun.js/bindgen.zig");
pub const jsc = @import("./buntime/jsc.zig");
pub const webcore = @import("./buntime/webcore.zig");
pub const api = @import("./buntime/api.zig");
pub const bindgen = @import("./buntime/jsc/interop/bindgen.zig");
pub const Run = struct {
ctx: Command.Context,
@@ -147,7 +147,7 @@ pub const Run = struct {
var bundle = try bun.Transpiler.init(
ctx.allocator,
ctx.log,
try @import("./bun.js/config.zig").configureTransformOptionsForBunVM(ctx.allocator, ctx.args),
try @import("./buntime/core/config.zig").configureTransformOptionsForBunVM(ctx.allocator, ctx.args),
null,
);
try bundle.runEnvLoader(bundle.options.env.disable_default_env_files);
@@ -496,7 +496,7 @@ pub const Run = struct {
bun.api.napi.fixDeadCodeElimination();
bun.webcore.BakeResponse.fixDeadCodeElimination();
bun.crash_handler.fixDeadCodeElimination();
@import("./bun.js/bindings/JSSecrets.zig").fixDeadCodeElimination();
@import("./buntime/api/secrets/JSSecrets.zig").fixDeadCodeElimination();
vm.globalExit();
}
@@ -551,7 +551,7 @@ const VirtualMachine = jsc.VirtualMachine;
const string = []const u8;
const CPUProfiler = @import("./bun.js/bindings/BunCPUProfiler.zig");
const CPUProfiler = @import("./buntime/api/inspector/BunCPUProfiler.zig");
const options = @import("./options.zig");
const std = @import("std");
const Command = @import("./cli.zig").Command;

View File

@@ -1,180 +0,0 @@
/* This file is derived from clang's stdatomic.h */
/*===---- stdatomic.h - Standard header for atomic types and operations -----===
*
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
* See https://llvm.org/LICENSE.txt for license information.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*
*===-----------------------------------------------------------------------===
*/
#ifndef _STDATOMIC_H
#define _STDATOMIC_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define __ATOMIC_RELAXED 0
#define __ATOMIC_CONSUME 1
#define __ATOMIC_ACQUIRE 2
#define __ATOMIC_RELEASE 3
#define __ATOMIC_ACQ_REL 4
#define __ATOMIC_SEQ_CST 5
/* Memory ordering */
typedef enum {
memory_order_relaxed = __ATOMIC_RELAXED,
memory_order_consume = __ATOMIC_CONSUME,
memory_order_acquire = __ATOMIC_ACQUIRE,
memory_order_release = __ATOMIC_RELEASE,
memory_order_acq_rel = __ATOMIC_ACQ_REL,
memory_order_seq_cst = __ATOMIC_SEQ_CST,
} memory_order;
/* Atomic typedefs */
typedef _Atomic(_Bool) atomic_bool;
typedef _Atomic(char) atomic_char;
typedef _Atomic(signed char) atomic_schar;
typedef _Atomic(unsigned char) atomic_uchar;
typedef _Atomic(short) atomic_short;
typedef _Atomic(unsigned short) atomic_ushort;
typedef _Atomic(int) atomic_int;
typedef _Atomic(unsigned int) atomic_uint;
typedef _Atomic(long) atomic_long;
typedef _Atomic(unsigned long) atomic_ulong;
typedef _Atomic(long long) atomic_llong;
typedef _Atomic(unsigned long long) atomic_ullong;
typedef _Atomic(uint_least16_t) atomic_char16_t;
typedef _Atomic(uint_least32_t) atomic_char32_t;
typedef _Atomic(wchar_t) atomic_wchar_t;
typedef _Atomic(int_least8_t) atomic_int_least8_t;
typedef _Atomic(uint_least8_t) atomic_uint_least8_t;
typedef _Atomic(int_least16_t) atomic_int_least16_t;
typedef _Atomic(uint_least16_t) atomic_uint_least16_t;
typedef _Atomic(int_least32_t) atomic_int_least32_t;
typedef _Atomic(uint_least32_t) atomic_uint_least32_t;
typedef _Atomic(int_least64_t) atomic_int_least64_t;
typedef _Atomic(uint_least64_t) atomic_uint_least64_t;
typedef _Atomic(int_fast8_t) atomic_int_fast8_t;
typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t;
typedef _Atomic(int_fast16_t) atomic_int_fast16_t;
typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t;
typedef _Atomic(int_fast32_t) atomic_int_fast32_t;
typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t;
typedef _Atomic(int_fast64_t) atomic_int_fast64_t;
typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t;
typedef _Atomic(intptr_t) atomic_intptr_t;
typedef _Atomic(uintptr_t) atomic_uintptr_t;
typedef _Atomic(size_t) atomic_size_t;
typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t;
typedef _Atomic(intmax_t) atomic_intmax_t;
typedef _Atomic(uintmax_t) atomic_uintmax_t;
/* Atomic flag */
typedef struct {
atomic_bool value;
} atomic_flag;
#define ATOMIC_FLAG_INIT {0}
#define ATOMIC_VAR_INIT(value) (value)
#define atomic_flag_test_and_set_explicit(object, order) \
__atomic_test_and_set((void *)(&((object)->value)), order)
#define atomic_flag_test_and_set(object) \
atomic_flag_test_and_set_explicit(object, __ATOMIC_SEQ_CST)
#define atomic_flag_clear_explicit(object, order) \
__atomic_clear((bool *)(&((object)->value)), order)
#define atomic_flag_clear(object) \
atomic_flag_clear_explicit(object, __ATOMIC_SEQ_CST)
/* Generic routines */
#define atomic_init(object, desired) \
atomic_store_explicit(object, desired, __ATOMIC_RELAXED)
#define atomic_store_explicit(object, desired, order) \
({ \
__typeof__(object) ptr = (object); \
__typeof__(*ptr) tmp = (desired); \
__atomic_store(ptr, &tmp, (order)); \
})
#define atomic_store(object, desired) \
atomic_store_explicit(object, desired, __ATOMIC_SEQ_CST)
#define atomic_load_explicit(object, order) \
({ \
__typeof__(object) ptr = (object); \
__typeof__(*ptr) tmp; \
__atomic_load(ptr, &tmp, (order)); \
tmp; \
})
#define atomic_load(object) atomic_load_explicit(object, __ATOMIC_SEQ_CST)
#define atomic_exchange_explicit(object, desired, order) \
({ \
__typeof__(object) ptr = (object); \
__typeof__(*ptr) val = (desired); \
__typeof__(*ptr) tmp; \
__atomic_exchange(ptr, &val, &tmp, (order)); \
tmp; \
})
#define atomic_exchange(object, desired) \
atomic_exchange_explicit(object, desired, __ATOMIC_SEQ_CST)
#define atomic_compare_exchange_strong_explicit(object, expected, desired, \
success, failure) \
({ \
__typeof__(object) ptr = (object); \
__typeof__(*ptr) tmp = desired; \
__atomic_compare_exchange(ptr, expected, &tmp, 0, success, failure); \
})
#define atomic_compare_exchange_strong(object, expected, desired) \
atomic_compare_exchange_strong_explicit(object, expected, desired, \
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
#define atomic_compare_exchange_weak_explicit(object, expected, desired, \
success, failure) \
({ \
__typeof__(object) ptr = (object); \
__typeof__(*ptr) tmp = desired; \
__atomic_compare_exchange(ptr, expected, &tmp, 1, success, failure); \
})
#define atomic_compare_exchange_weak(object, expected, desired) \
atomic_compare_exchange_weak_explicit(object, expected, desired, \
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
#define atomic_fetch_add(object, operand) \
__atomic_fetch_add(object, operand, __ATOMIC_SEQ_CST)
#define atomic_fetch_add_explicit __atomic_fetch_add
#define atomic_fetch_sub(object, operand) \
__atomic_fetch_sub(object, operand, __ATOMIC_SEQ_CST)
#define atomic_fetch_sub_explicit __atomic_fetch_sub
#define atomic_fetch_or(object, operand) \
__atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST)
#define atomic_fetch_or_explicit __atomic_fetch_or
#define atomic_fetch_xor(object, operand) \
__atomic_fetch_xor(object, operand, __ATOMIC_SEQ_CST)
#define atomic_fetch_xor_explicit __atomic_fetch_xor
#define atomic_fetch_and(object, operand) \
__atomic_fetch_and(object, operand, __ATOMIC_SEQ_CST)
#define atomic_fetch_and_explicit __atomic_fetch_and
extern void atomic_thread_fence(memory_order);
extern void __atomic_thread_fence(memory_order);
#define atomic_thread_fence(order) __atomic_thread_fence(order)
extern void atomic_signal_fence(memory_order);
extern void __atomic_signal_fence(memory_order);
#define atomic_signal_fence(order) __atomic_signal_fence(order)
extern bool __atomic_is_lock_free(size_t size, void *ptr);
#define atomic_is_lock_free(OBJ) __atomic_is_lock_free(sizeof(*(OBJ)), (OBJ))
extern bool __atomic_test_and_set(void *, memory_order);
extern void __atomic_clear(bool *, memory_order);
#endif /* _STDATOMIC_H */

View File

@@ -1,2 +0,0 @@
*.lut.h
sqlite/sqlite3_local.h

File diff suppressed because it is too large Load Diff

View File

@@ -1,61 +0,0 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef UV_DARWIN_H
#define UV_DARWIN_H
#if defined(__APPLE__) && defined(__MACH__)
# include <mach/mach.h>
# include <mach/task.h>
# include <mach/semaphore.h>
# include <TargetConditionals.h>
# define UV_PLATFORM_SEM_T semaphore_t
#endif
#define UV_IO_PRIVATE_PLATFORM_FIELDS \
int rcount; \
int wcount; \
#define UV_PLATFORM_LOOP_FIELDS \
uv_thread_t cf_thread; \
void* _cf_reserved; \
void* cf_state; \
uv_mutex_t cf_mutex; \
uv_sem_t cf_sem; \
struct uv__queue cf_signals; \
#define UV_PLATFORM_FS_EVENT_FIELDS \
uv__io_t event_watcher; \
char* realpath; \
int realpath_len; \
int cf_flags; \
uv_async_t* cf_cb; \
struct uv__queue cf_events; \
struct uv__queue cf_member; \
int cf_error; \
uv_mutex_t cf_mutex; \
#define UV_STREAM_PRIVATE_PLATFORM_FIELDS \
void* select; \
#define UV_HAVE_KQUEUE 1
#endif /* UV_DARWIN_H */

View File

@@ -1,521 +0,0 @@
/*-
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UV_TREE_H_
#define UV_TREE_H_
#ifndef UV__UNUSED
# if __GNUC__
# define UV__UNUSED __attribute__((unused))
# else
# define UV__UNUSED
# endif
#endif
/*
* This file defines data structures for red-black trees.
* A red-black tree is a binary search tree with the node color as an
* extra attribute. It fulfills a set of conditions:
* - every search path from the root to a leaf consists of the
* same number of black nodes,
* - each red node (except for the root) has a black parent,
* - each leaf node is black.
*
* Every operation on a red-black tree is bounded as O(lg n).
* The maximum height of a red-black tree is 2lg (n+1).
*/
/* Macros that define a red-black tree */
#define RB_HEAD(name, type) \
struct name { \
struct type *rbh_root; /* root of the tree */ \
}
#define RB_INITIALIZER(root) \
{ NULL }
#define RB_INIT(root) do { \
(root)->rbh_root = NULL; \
} while (/*CONSTCOND*/ 0)
#define RB_BLACK 0
#define RB_RED 1
#define RB_ENTRY(type) \
struct { \
struct type *rbe_left; /* left element */ \
struct type *rbe_right; /* right element */ \
struct type *rbe_parent; /* parent element */ \
int rbe_color; /* node color */ \
}
#define RB_LEFT(elm, field) (elm)->field.rbe_left
#define RB_RIGHT(elm, field) (elm)->field.rbe_right
#define RB_PARENT(elm, field) (elm)->field.rbe_parent
#define RB_COLOR(elm, field) (elm)->field.rbe_color
#define RB_ROOT(head) (head)->rbh_root
#define RB_EMPTY(head) (RB_ROOT(head) == NULL)
#define RB_SET(elm, parent, field) do { \
RB_PARENT(elm, field) = parent; \
RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \
RB_COLOR(elm, field) = RB_RED; \
} while (/*CONSTCOND*/ 0)
#define RB_SET_BLACKRED(black, red, field) do { \
RB_COLOR(black, field) = RB_BLACK; \
RB_COLOR(red, field) = RB_RED; \
} while (/*CONSTCOND*/ 0)
#ifndef RB_AUGMENT
#define RB_AUGMENT(x) do {} while (0)
#endif
#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \
(tmp) = RB_RIGHT(elm, field); \
if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \
RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \
} \
RB_AUGMENT(elm); \
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
else \
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
} else \
(head)->rbh_root = (tmp); \
RB_LEFT(tmp, field) = (elm); \
RB_PARENT(elm, field) = (tmp); \
RB_AUGMENT(tmp); \
if ((RB_PARENT(tmp, field))) \
RB_AUGMENT(RB_PARENT(tmp, field)); \
} while (/*CONSTCOND*/ 0)
#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
(tmp) = RB_LEFT(elm, field); \
if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \
RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \
} \
RB_AUGMENT(elm); \
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
else \
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
} else \
(head)->rbh_root = (tmp); \
RB_RIGHT(tmp, field) = (elm); \
RB_PARENT(elm, field) = (tmp); \
RB_AUGMENT(tmp); \
if ((RB_PARENT(tmp, field))) \
RB_AUGMENT(RB_PARENT(tmp, field)); \
} while (/*CONSTCOND*/ 0)
/* Generates prototypes and inline functions */
#define RB_PROTOTYPE(name, type, field, cmp) \
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, UV__UNUSED static)
#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \
attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \
attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
attr struct type *name##_RB_REMOVE(struct name *, struct type *); \
attr struct type *name##_RB_INSERT(struct name *, struct type *); \
attr struct type *name##_RB_FIND(struct name *, struct type *); \
attr struct type *name##_RB_NFIND(struct name *, struct type *); \
attr struct type *name##_RB_NEXT(struct type *); \
attr struct type *name##_RB_PREV(struct type *); \
attr struct type *name##_RB_MINMAX(struct name *, int); \
\
/* Main rb operation.
* Moves node close to the key of elm to top
*/
#define RB_GENERATE(name, type, field, cmp) \
RB_GENERATE_INTERNAL(name, type, field, cmp,)
#define RB_GENERATE_STATIC(name, type, field, cmp) \
RB_GENERATE_INTERNAL(name, type, field, cmp, UV__UNUSED static)
#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \
attr void \
name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
{ \
struct type *parent, *gparent, *tmp; \
while ((parent = RB_PARENT(elm, field)) != NULL && \
RB_COLOR(parent, field) == RB_RED) { \
gparent = RB_PARENT(parent, field); \
if (parent == RB_LEFT(gparent, field)) { \
tmp = RB_RIGHT(gparent, field); \
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
RB_COLOR(tmp, field) = RB_BLACK; \
RB_SET_BLACKRED(parent, gparent, field); \
elm = gparent; \
continue; \
} \
if (RB_RIGHT(parent, field) == elm) { \
RB_ROTATE_LEFT(head, parent, tmp, field); \
tmp = parent; \
parent = elm; \
elm = tmp; \
} \
RB_SET_BLACKRED(parent, gparent, field); \
RB_ROTATE_RIGHT(head, gparent, tmp, field); \
} else { \
tmp = RB_LEFT(gparent, field); \
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
RB_COLOR(tmp, field) = RB_BLACK; \
RB_SET_BLACKRED(parent, gparent, field); \
elm = gparent; \
continue; \
} \
if (RB_LEFT(parent, field) == elm) { \
RB_ROTATE_RIGHT(head, parent, tmp, field); \
tmp = parent; \
parent = elm; \
elm = tmp; \
} \
RB_SET_BLACKRED(parent, gparent, field); \
RB_ROTATE_LEFT(head, gparent, tmp, field); \
} \
} \
RB_COLOR(head->rbh_root, field) = RB_BLACK; \
} \
\
attr void \
name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, \
struct type *elm) \
{ \
struct type *tmp; \
while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \
elm != RB_ROOT(head)) { \
if (RB_LEFT(parent, field) == elm) { \
tmp = RB_RIGHT(parent, field); \
if (RB_COLOR(tmp, field) == RB_RED) { \
RB_SET_BLACKRED(tmp, parent, field); \
RB_ROTATE_LEFT(head, parent, tmp, field); \
tmp = RB_RIGHT(parent, field); \
} \
if ((RB_LEFT(tmp, field) == NULL || \
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \
(RB_RIGHT(tmp, field) == NULL || \
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \
RB_COLOR(tmp, field) = RB_RED; \
elm = parent; \
parent = RB_PARENT(elm, field); \
} else { \
if (RB_RIGHT(tmp, field) == NULL || \
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) { \
struct type *oleft; \
if ((oleft = RB_LEFT(tmp, field)) \
!= NULL) \
RB_COLOR(oleft, field) = RB_BLACK; \
RB_COLOR(tmp, field) = RB_RED; \
RB_ROTATE_RIGHT(head, tmp, oleft, field); \
tmp = RB_RIGHT(parent, field); \
} \
RB_COLOR(tmp, field) = RB_COLOR(parent, field); \
RB_COLOR(parent, field) = RB_BLACK; \
if (RB_RIGHT(tmp, field)) \
RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \
RB_ROTATE_LEFT(head, parent, tmp, field); \
elm = RB_ROOT(head); \
break; \
} \
} else { \
tmp = RB_LEFT(parent, field); \
if (RB_COLOR(tmp, field) == RB_RED) { \
RB_SET_BLACKRED(tmp, parent, field); \
RB_ROTATE_RIGHT(head, parent, tmp, field); \
tmp = RB_LEFT(parent, field); \
} \
if ((RB_LEFT(tmp, field) == NULL || \
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \
(RB_RIGHT(tmp, field) == NULL || \
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \
RB_COLOR(tmp, field) = RB_RED; \
elm = parent; \
parent = RB_PARENT(elm, field); \
} else { \
if (RB_LEFT(tmp, field) == NULL || \
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) { \
struct type *oright; \
if ((oright = RB_RIGHT(tmp, field)) \
!= NULL) \
RB_COLOR(oright, field) = RB_BLACK; \
RB_COLOR(tmp, field) = RB_RED; \
RB_ROTATE_LEFT(head, tmp, oright, field); \
tmp = RB_LEFT(parent, field); \
} \
RB_COLOR(tmp, field) = RB_COLOR(parent, field); \
RB_COLOR(parent, field) = RB_BLACK; \
if (RB_LEFT(tmp, field)) \
RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \
RB_ROTATE_RIGHT(head, parent, tmp, field); \
elm = RB_ROOT(head); \
break; \
} \
} \
} \
if (elm) \
RB_COLOR(elm, field) = RB_BLACK; \
} \
\
attr struct type * \
name##_RB_REMOVE(struct name *head, struct type *elm) \
{ \
struct type *child, *parent, *old = elm; \
int color; \
if (RB_LEFT(elm, field) == NULL) \
child = RB_RIGHT(elm, field); \
else if (RB_RIGHT(elm, field) == NULL) \
child = RB_LEFT(elm, field); \
else { \
struct type *left; \
elm = RB_RIGHT(elm, field); \
while ((left = RB_LEFT(elm, field)) != NULL) \
elm = left; \
child = RB_RIGHT(elm, field); \
parent = RB_PARENT(elm, field); \
color = RB_COLOR(elm, field); \
if (child) \
RB_PARENT(child, field) = parent; \
if (parent) { \
if (RB_LEFT(parent, field) == elm) \
RB_LEFT(parent, field) = child; \
else \
RB_RIGHT(parent, field) = child; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = child; \
if (RB_PARENT(elm, field) == old) \
parent = elm; \
(elm)->field = (old)->field; \
if (RB_PARENT(old, field)) { \
if (RB_LEFT(RB_PARENT(old, field), field) == old) \
RB_LEFT(RB_PARENT(old, field), field) = elm; \
else \
RB_RIGHT(RB_PARENT(old, field), field) = elm; \
RB_AUGMENT(RB_PARENT(old, field)); \
} else \
RB_ROOT(head) = elm; \
RB_PARENT(RB_LEFT(old, field), field) = elm; \
if (RB_RIGHT(old, field)) \
RB_PARENT(RB_RIGHT(old, field), field) = elm; \
if (parent) { \
left = parent; \
do { \
RB_AUGMENT(left); \
} while ((left = RB_PARENT(left, field)) != NULL); \
} \
goto color; \
} \
parent = RB_PARENT(elm, field); \
color = RB_COLOR(elm, field); \
if (child) \
RB_PARENT(child, field) = parent; \
if (parent) { \
if (RB_LEFT(parent, field) == elm) \
RB_LEFT(parent, field) = child; \
else \
RB_RIGHT(parent, field) = child; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = child; \
color: \
if (color == RB_BLACK) \
name##_RB_REMOVE_COLOR(head, parent, child); \
return (old); \
} \
\
/* Inserts a node into the RB tree */ \
attr struct type * \
name##_RB_INSERT(struct name *head, struct type *elm) \
{ \
struct type *tmp; \
struct type *parent = NULL; \
int comp = 0; \
tmp = RB_ROOT(head); \
while (tmp) { \
parent = tmp; \
comp = (cmp)(elm, parent); \
if (comp < 0) \
tmp = RB_LEFT(tmp, field); \
else if (comp > 0) \
tmp = RB_RIGHT(tmp, field); \
else \
return (tmp); \
} \
RB_SET(elm, parent, field); \
if (parent != NULL) { \
if (comp < 0) \
RB_LEFT(parent, field) = elm; \
else \
RB_RIGHT(parent, field) = elm; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = elm; \
name##_RB_INSERT_COLOR(head, elm); \
return (NULL); \
} \
\
/* Finds the node with the same key as elm */ \
attr struct type * \
name##_RB_FIND(struct name *head, struct type *elm) \
{ \
struct type *tmp = RB_ROOT(head); \
int comp; \
while (tmp) { \
comp = cmp(elm, tmp); \
if (comp < 0) \
tmp = RB_LEFT(tmp, field); \
else if (comp > 0) \
tmp = RB_RIGHT(tmp, field); \
else \
return (tmp); \
} \
return (NULL); \
} \
\
/* Finds the first node greater than or equal to the search key */ \
attr struct type * \
name##_RB_NFIND(struct name *head, struct type *elm) \
{ \
struct type *tmp = RB_ROOT(head); \
struct type *res = NULL; \
int comp; \
while (tmp) { \
comp = cmp(elm, tmp); \
if (comp < 0) { \
res = tmp; \
tmp = RB_LEFT(tmp, field); \
} \
else if (comp > 0) \
tmp = RB_RIGHT(tmp, field); \
else \
return (tmp); \
} \
return (res); \
} \
\
/* ARGSUSED */ \
attr struct type * \
name##_RB_NEXT(struct type *elm) \
{ \
if (RB_RIGHT(elm, field)) { \
elm = RB_RIGHT(elm, field); \
while (RB_LEFT(elm, field)) \
elm = RB_LEFT(elm, field); \
} else { \
if (RB_PARENT(elm, field) && \
(elm == RB_LEFT(RB_PARENT(elm, field), field))) \
elm = RB_PARENT(elm, field); \
else { \
while (RB_PARENT(elm, field) && \
(elm == RB_RIGHT(RB_PARENT(elm, field), field))) \
elm = RB_PARENT(elm, field); \
elm = RB_PARENT(elm, field); \
} \
} \
return (elm); \
} \
\
/* ARGSUSED */ \
attr struct type * \
name##_RB_PREV(struct type *elm) \
{ \
if (RB_LEFT(elm, field)) { \
elm = RB_LEFT(elm, field); \
while (RB_RIGHT(elm, field)) \
elm = RB_RIGHT(elm, field); \
} else { \
if (RB_PARENT(elm, field) && \
(elm == RB_RIGHT(RB_PARENT(elm, field), field))) \
elm = RB_PARENT(elm, field); \
else { \
while (RB_PARENT(elm, field) && \
(elm == RB_LEFT(RB_PARENT(elm, field), field))) \
elm = RB_PARENT(elm, field); \
elm = RB_PARENT(elm, field); \
} \
} \
return (elm); \
} \
\
attr struct type * \
name##_RB_MINMAX(struct name *head, int val) \
{ \
struct type *tmp = RB_ROOT(head); \
struct type *parent = NULL; \
while (tmp) { \
parent = tmp; \
if (val < 0) \
tmp = RB_LEFT(tmp, field); \
else \
tmp = RB_RIGHT(tmp, field); \
} \
return (parent); \
}
#define RB_NEGINF -1
#define RB_INF 1
#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y)
#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y)
#define RB_FIND(name, x, y) name##_RB_FIND(x, y)
#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y)
#define RB_NEXT(name, x) name##_RB_NEXT(x)
#define RB_PREV(name, x) name##_RB_PREV(x)
#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF)
#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF)
#define RB_FOREACH(x, name, head) \
for ((x) = RB_MIN(name, head); \
(x) != NULL; \
(x) = name##_RB_NEXT(x))
#define RB_FOREACH_FROM(x, name, y) \
for ((x) = (y); \
((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \
(x) = (y))
#define RB_FOREACH_SAFE(x, name, head, y) \
for ((x) = RB_MIN(name, head); \
((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \
(x) = (y))
#define RB_FOREACH_REVERSE(x, name, head) \
for ((x) = RB_MAX(name, head); \
(x) != NULL; \
(x) = name##_RB_PREV(x))
#define RB_FOREACH_REVERSE_FROM(x, name, y) \
for ((x) = (y); \
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
(x) = (y))
#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \
for ((x) = RB_MAX(name, head); \
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
(x) = (y))
#endif /* UV_TREE_H_ */

View File

@@ -1,512 +0,0 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef UV_UNIX_H
#define UV_UNIX_H
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h> /* MAXHOSTNAMELEN on Solaris */
#include <termios.h>
#include <pwd.h>
#if !defined(__MVS__)
#include <semaphore.h>
#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
#endif
#include <pthread.h>
#include <signal.h>
#include "uv/threadpool.h"
#if defined(__linux__)
# include "uv/linux.h"
#elif defined (__MVS__)
# include "uv/os390.h"
#elif defined(__PASE__) /* __PASE__ and _AIX are both defined on IBM i */
# include "uv/posix.h" /* IBM i needs uv/posix.h, not uv/aix.h */
#elif defined(_AIX)
# include "uv/aix.h"
#elif defined(__sun)
# include "uv/sunos.h"
#elif defined(__APPLE__)
# include "uv/darwin.h"
#elif defined(__DragonFly__) || \
defined(__FreeBSD__) || \
defined(__OpenBSD__) || \
defined(__NetBSD__)
# include "uv/bsd.h"
#elif defined(__CYGWIN__) || \
defined(__MSYS__) || \
defined(__HAIKU__) || \
defined(__QNX__) || \
defined(__GNU__)
# include "uv/posix.h"
#endif
#ifndef NI_MAXHOST
# define NI_MAXHOST 1025
#endif
#ifndef NI_MAXSERV
# define NI_MAXSERV 32
#endif
#ifndef UV_IO_PRIVATE_PLATFORM_FIELDS
# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */
#endif
struct uv__io_s;
struct uv_loop_s;
typedef void (*uv__io_cb)(struct uv_loop_s* loop,
struct uv__io_s* w,
unsigned int events);
typedef struct uv__io_s uv__io_t;
struct uv__io_s {
uv__io_cb cb;
struct uv__queue pending_queue;
struct uv__queue watcher_queue;
unsigned int pevents; /* Pending event mask i.e. mask at next tick. */
unsigned int events; /* Current event mask. */
int fd;
UV_IO_PRIVATE_PLATFORM_FIELDS
};
#ifndef UV_PLATFORM_SEM_T
# define UV_PLATFORM_SEM_T sem_t
#endif
#ifndef UV_PLATFORM_LOOP_FIELDS
# define UV_PLATFORM_LOOP_FIELDS /* empty */
#endif
#ifndef UV_PLATFORM_FS_EVENT_FIELDS
# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */
#endif
#ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS
# define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */
#endif
/* Note: May be cast to struct iovec. See writev(2). */
typedef struct uv_buf_t {
char* base;
size_t len;
} uv_buf_t;
typedef int uv_file;
typedef int uv_os_sock_t;
typedef int uv_os_fd_t;
typedef pid_t uv_pid_t;
#define UV_ONCE_INIT PTHREAD_ONCE_INIT
typedef pthread_once_t uv_once_t;
typedef pthread_t uv_thread_t;
typedef pthread_mutex_t uv_mutex_t;
typedef pthread_rwlock_t uv_rwlock_t;
typedef UV_PLATFORM_SEM_T uv_sem_t;
typedef pthread_cond_t uv_cond_t;
typedef pthread_key_t uv_key_t;
/* Note: guard clauses should match uv_barrier_init's in src/unix/thread.c. */
#if defined(_AIX) || \
defined(__OpenBSD__) || \
!defined(PTHREAD_BARRIER_SERIAL_THREAD)
/* TODO(bnoordhuis) Merge into uv_barrier_t in v2. */
struct _uv_barrier {
uv_mutex_t mutex;
uv_cond_t cond;
unsigned threshold;
unsigned in;
unsigned out;
};
typedef struct {
struct _uv_barrier* b;
# if defined(PTHREAD_BARRIER_SERIAL_THREAD)
/* TODO(bnoordhuis) Remove padding in v2. */
char pad[sizeof(pthread_barrier_t) - sizeof(struct _uv_barrier*)];
# endif
} uv_barrier_t;
#else
typedef pthread_barrier_t uv_barrier_t;
#endif
/* Platform-specific definitions for uv_spawn support. */
typedef gid_t uv_gid_t;
typedef uid_t uv_uid_t;
typedef struct dirent uv__dirent_t;
#define UV_DIR_PRIVATE_FIELDS \
DIR* dir;
#if defined(DT_UNKNOWN)
# define HAVE_DIRENT_TYPES
# if defined(DT_REG)
# define UV__DT_FILE DT_REG
# else
# define UV__DT_FILE -1
# endif
# if defined(DT_DIR)
# define UV__DT_DIR DT_DIR
# else
# define UV__DT_DIR -2
# endif
# if defined(DT_LNK)
# define UV__DT_LINK DT_LNK
# else
# define UV__DT_LINK -3
# endif
# if defined(DT_FIFO)
# define UV__DT_FIFO DT_FIFO
# else
# define UV__DT_FIFO -4
# endif
# if defined(DT_SOCK)
# define UV__DT_SOCKET DT_SOCK
# else
# define UV__DT_SOCKET -5
# endif
# if defined(DT_CHR)
# define UV__DT_CHAR DT_CHR
# else
# define UV__DT_CHAR -6
# endif
# if defined(DT_BLK)
# define UV__DT_BLOCK DT_BLK
# else
# define UV__DT_BLOCK -7
# endif
#endif
/* Platform-specific definitions for uv_dlopen support. */
#define UV_DYNAMIC /* empty */
typedef struct {
void* handle;
char* errmsg;
} uv_lib_t;
#define UV_LOOP_PRIVATE_FIELDS \
unsigned long flags; \
int backend_fd; \
struct uv__queue pending_queue; \
struct uv__queue watcher_queue; \
uv__io_t** watchers; \
unsigned int nwatchers; \
unsigned int nfds; \
struct uv__queue wq; \
uv_mutex_t wq_mutex; \
uv_async_t wq_async; \
uv_rwlock_t cloexec_lock; \
uv_handle_t* closing_handles; \
struct uv__queue process_handles; \
struct uv__queue prepare_handles; \
struct uv__queue check_handles; \
struct uv__queue idle_handles; \
struct uv__queue async_handles; \
void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \
uv__io_t async_io_watcher; \
int async_wfd; \
struct { \
void* min; \
unsigned int nelts; \
} timer_heap; \
uint64_t timer_counter; \
uint64_t time; \
int signal_pipefd[2]; \
uv__io_t signal_io_watcher; \
uv_signal_t child_watcher; \
int emfile_fd; \
UV_PLATFORM_LOOP_FIELDS \
#define UV_REQ_TYPE_PRIVATE /* empty */
#define UV_REQ_PRIVATE_FIELDS /* empty */
#define UV_PRIVATE_REQ_TYPES /* empty */
#define UV_WRITE_PRIVATE_FIELDS \
struct uv__queue queue; \
unsigned int write_index; \
uv_buf_t* bufs; \
unsigned int nbufs; \
int error; \
uv_buf_t bufsml[4]; \
#define UV_CONNECT_PRIVATE_FIELDS \
struct uv__queue queue; \
#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */
#define UV_UDP_SEND_PRIVATE_FIELDS \
struct uv__queue queue; \
union { \
struct sockaddr addr; \
struct sockaddr_storage storage; \
} u; \
unsigned int nbufs; \
uv_buf_t* bufs; \
ssize_t status; \
uv_udp_send_cb send_cb; \
uv_buf_t bufsml[4]; \
#define UV_HANDLE_PRIVATE_FIELDS \
uv_handle_t* next_closing; \
unsigned int flags; \
#define UV_STREAM_PRIVATE_FIELDS \
uv_connect_t *connect_req; \
uv_shutdown_t *shutdown_req; \
uv__io_t io_watcher; \
struct uv__queue write_queue; \
struct uv__queue write_completed_queue; \
uv_connection_cb connection_cb; \
int delayed_error; \
int accepted_fd; \
void* queued_fds; \
UV_STREAM_PRIVATE_PLATFORM_FIELDS \
#define UV_TCP_PRIVATE_FIELDS /* empty */
#define UV_UDP_PRIVATE_FIELDS \
uv_alloc_cb alloc_cb; \
uv_udp_recv_cb recv_cb; \
uv__io_t io_watcher; \
struct uv__queue write_queue; \
struct uv__queue write_completed_queue; \
#define UV_PIPE_PRIVATE_FIELDS \
const char* pipe_fname; /* NULL or strdup'ed */
#define UV_POLL_PRIVATE_FIELDS \
uv__io_t io_watcher;
#define UV_PREPARE_PRIVATE_FIELDS \
uv_prepare_cb prepare_cb; \
struct uv__queue queue; \
#define UV_CHECK_PRIVATE_FIELDS \
uv_check_cb check_cb; \
struct uv__queue queue; \
#define UV_IDLE_PRIVATE_FIELDS \
uv_idle_cb idle_cb; \
struct uv__queue queue; \
#define UV_ASYNC_PRIVATE_FIELDS \
uv_async_cb async_cb; \
struct uv__queue queue; \
int pending; \
#define UV_TIMER_PRIVATE_FIELDS \
uv_timer_cb timer_cb; \
union { \
void* heap[3]; \
struct uv__queue queue; \
} node; \
uint64_t timeout; \
uint64_t repeat; \
uint64_t start_id;
#define UV_GETADDRINFO_PRIVATE_FIELDS \
struct uv__work work_req; \
uv_getaddrinfo_cb cb; \
struct addrinfo* hints; \
char* hostname; \
char* service; \
struct addrinfo* addrinfo; \
int retcode;
#define UV_GETNAMEINFO_PRIVATE_FIELDS \
struct uv__work work_req; \
uv_getnameinfo_cb getnameinfo_cb; \
struct sockaddr_storage storage; \
int flags; \
char host[NI_MAXHOST]; \
char service[NI_MAXSERV]; \
int retcode;
#define UV_PROCESS_PRIVATE_FIELDS \
struct uv__queue queue; \
int status; \
#define UV_FS_PRIVATE_FIELDS \
const char *new_path; \
uv_file file; \
int flags; \
mode_t mode; \
unsigned int nbufs; \
uv_buf_t* bufs; \
off_t off; \
uv_uid_t uid; \
uv_gid_t gid; \
double atime; \
double mtime; \
struct uv__work work_req; \
uv_buf_t bufsml[4]; \
#define UV_WORK_PRIVATE_FIELDS \
struct uv__work work_req;
#define UV_TTY_PRIVATE_FIELDS \
struct termios orig_termios; \
int mode;
#define UV_SIGNAL_PRIVATE_FIELDS \
/* RB_ENTRY(uv_signal_s) tree_entry; */ \
struct { \
struct uv_signal_s* rbe_left; \
struct uv_signal_s* rbe_right; \
struct uv_signal_s* rbe_parent; \
int rbe_color; \
} tree_entry; \
/* Use two counters here so we don have to fiddle with atomics. */ \
unsigned int caught_signals; \
unsigned int dispatched_signals;
#define UV_FS_EVENT_PRIVATE_FIELDS \
uv_fs_event_cb cb; \
UV_PLATFORM_FS_EVENT_FIELDS \
/* fs open() flags supported on this platform: */
#if defined(O_APPEND)
# define UV_FS_O_APPEND O_APPEND
#else
# define UV_FS_O_APPEND 0
#endif
#if defined(O_CREAT)
# define UV_FS_O_CREAT O_CREAT
#else
# define UV_FS_O_CREAT 0
#endif
#if defined(__linux__) && defined(__arm__)
# define UV_FS_O_DIRECT 0x10000
#elif defined(__linux__) && defined(__m68k__)
# define UV_FS_O_DIRECT 0x10000
#elif defined(__linux__) && defined(__mips__)
# define UV_FS_O_DIRECT 0x08000
#elif defined(__linux__) && defined(__powerpc__)
# define UV_FS_O_DIRECT 0x20000
#elif defined(__linux__) && defined(__s390x__)
# define UV_FS_O_DIRECT 0x04000
#elif defined(__linux__) && defined(__x86_64__)
# define UV_FS_O_DIRECT 0x04000
#elif defined(__linux__) && defined(__loongarch__)
# define UV_FS_O_DIRECT 0x04000
#elif defined(O_DIRECT)
# define UV_FS_O_DIRECT O_DIRECT
#else
# define UV_FS_O_DIRECT 0
#endif
#if defined(O_DIRECTORY)
# define UV_FS_O_DIRECTORY O_DIRECTORY
#else
# define UV_FS_O_DIRECTORY 0
#endif
#if defined(O_DSYNC)
# define UV_FS_O_DSYNC O_DSYNC
#else
# define UV_FS_O_DSYNC 0
#endif
#if defined(O_EXCL)
# define UV_FS_O_EXCL O_EXCL
#else
# define UV_FS_O_EXCL 0
#endif
#if defined(O_EXLOCK)
# define UV_FS_O_EXLOCK O_EXLOCK
#else
# define UV_FS_O_EXLOCK 0
#endif
#if defined(O_NOATIME)
# define UV_FS_O_NOATIME O_NOATIME
#else
# define UV_FS_O_NOATIME 0
#endif
#if defined(O_NOCTTY)
# define UV_FS_O_NOCTTY O_NOCTTY
#else
# define UV_FS_O_NOCTTY 0
#endif
#if defined(O_NOFOLLOW)
# define UV_FS_O_NOFOLLOW O_NOFOLLOW
#else
# define UV_FS_O_NOFOLLOW 0
#endif
#if defined(O_NONBLOCK)
# define UV_FS_O_NONBLOCK O_NONBLOCK
#else
# define UV_FS_O_NONBLOCK 0
#endif
#if defined(O_RDONLY)
# define UV_FS_O_RDONLY O_RDONLY
#else
# define UV_FS_O_RDONLY 0
#endif
#if defined(O_RDWR)
# define UV_FS_O_RDWR O_RDWR
#else
# define UV_FS_O_RDWR 0
#endif
#if defined(O_SYMLINK)
# define UV_FS_O_SYMLINK O_SYMLINK
#else
# define UV_FS_O_SYMLINK 0
#endif
#if defined(O_SYNC)
# define UV_FS_O_SYNC O_SYNC
#else
# define UV_FS_O_SYNC 0
#endif
#if defined(O_TRUNC)
# define UV_FS_O_TRUNC O_TRUNC
#else
# define UV_FS_O_TRUNC 0
#endif
#if defined(O_WRONLY)
# define UV_FS_O_WRONLY O_WRONLY
#else
# define UV_FS_O_WRONLY 0
#endif
/* fs open() flags supported on other platforms: */
#define UV_FS_O_FILEMAP 0
#define UV_FS_O_RANDOM 0
#define UV_FS_O_SHORT_LIVED 0
#define UV_FS_O_SEQUENTIAL 0
#define UV_FS_O_TEMPORARY 0
#endif /* UV_UNIX_H */

View File

@@ -1,698 +0,0 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0A00
#endif
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
typedef intptr_t ssize_t;
# define SSIZE_MAX INTPTR_MAX
# define _SSIZE_T_
# define _SSIZE_T_DEFINED
#endif
#include <winsock2.h>
#ifndef LOCALE_INVARIANT
# define LOCALE_INVARIANT 0x007f
#endif
#include <mswsock.h>
/* Disable the typedef in mstcpip.h of MinGW. */
#define _TCP_INITIAL_RTO_PARAMETERS _TCP_INITIAL_RTO_PARAMETERS__AVOID
#define TCP_INITIAL_RTO_PARAMETERS TCP_INITIAL_RTO_PARAMETERS__AVOID
#define PTCP_INITIAL_RTO_PARAMETERS PTCP_INITIAL_RTO_PARAMETERS__AVOID
#include <ws2tcpip.h>
#undef _TCP_INITIAL_RTO_PARAMETERS
#undef TCP_INITIAL_RTO_PARAMETERS
#undef PTCP_INITIAL_RTO_PARAMETERS
#include <windows.h>
#include <process.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdint.h>
#include "uv/tree.h"
#include "uv/threadpool.h"
#define MAX_PIPENAME_LEN 256
#ifndef S_IFLNK
# define S_IFLNK 0xA000
#endif
/* Define missing in Windows Kit Include\{VERSION}\ucrt\sys\stat.h */
#if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES && !defined(S_IFIFO)
# define S_IFIFO _S_IFIFO
#endif
/* Additional signals supported by uv_signal and or uv_kill. The CRT defines
* the following signals already:
*
* #define SIGINT 2
* #define SIGILL 4
* #define SIGABRT_COMPAT 6
* #define SIGFPE 8
* #define SIGSEGV 11
* #define SIGTERM 15
* #define SIGBREAK 21
* #define SIGABRT 22
*
* The additional signals have values that are common on other Unix
* variants (Linux and Darwin)
*/
#define SIGHUP 1
#define SIGQUIT 3
#define SIGKILL 9
#define SIGWINCH 28
/* Redefine NSIG to take SIGWINCH into consideration */
#if defined(NSIG) && NSIG <= SIGWINCH
# undef NSIG
#endif
#ifndef NSIG
# define NSIG SIGWINCH + 1
#endif
/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many unix-like
* platforms. However MinGW doesn't define it, so we do. */
#ifndef SIGABRT_COMPAT
# define SIGABRT_COMPAT 6
#endif
/*
* Guids and typedefs for winsock extension functions
* Mingw32 doesn't have these :-(
*/
#ifndef WSAID_ACCEPTEX
# define WSAID_ACCEPTEX \
{0xb5367df1, 0xcbac, 0x11cf, \
{0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
# define WSAID_CONNECTEX \
{0x25a207b9, 0xddf3, 0x4660, \
{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}}
# define WSAID_GETACCEPTEXSOCKADDRS \
{0xb5367df2, 0xcbac, 0x11cf, \
{0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
# define WSAID_DISCONNECTEX \
{0x7fda2e11, 0x8630, 0x436f, \
{0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
# define WSAID_TRANSMITFILE \
{0xb5367df0, 0xcbac, 0x11cf, \
{0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
typedef BOOL (PASCAL *LPFN_ACCEPTEX)
(SOCKET sListenSocket,
SOCKET sAcceptSocket,
PVOID lpOutputBuffer,
DWORD dwReceiveDataLength,
DWORD dwLocalAddressLength,
DWORD dwRemoteAddressLength,
LPDWORD lpdwBytesReceived,
LPOVERLAPPED lpOverlapped);
typedef BOOL (PASCAL *LPFN_CONNECTEX)
(SOCKET s,
const struct sockaddr* name,
int namelen,
PVOID lpSendBuffer,
DWORD dwSendDataLength,
LPDWORD lpdwBytesSent,
LPOVERLAPPED lpOverlapped);
typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS)
(PVOID lpOutputBuffer,
DWORD dwReceiveDataLength,
DWORD dwLocalAddressLength,
DWORD dwRemoteAddressLength,
LPSOCKADDR* LocalSockaddr,
LPINT LocalSockaddrLength,
LPSOCKADDR* RemoteSockaddr,
LPINT RemoteSockaddrLength);
typedef BOOL (PASCAL *LPFN_DISCONNECTEX)
(SOCKET hSocket,
LPOVERLAPPED lpOverlapped,
DWORD dwFlags,
DWORD reserved);
typedef BOOL (PASCAL *LPFN_TRANSMITFILE)
(SOCKET hSocket,
HANDLE hFile,
DWORD nNumberOfBytesToWrite,
DWORD nNumberOfBytesPerSend,
LPOVERLAPPED lpOverlapped,
LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
DWORD dwFlags);
typedef PVOID RTL_SRWLOCK;
typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
#endif
typedef int (WSAAPI* LPFN_WSARECV)
(SOCKET socket,
LPWSABUF buffers,
DWORD buffer_count,
LPDWORD bytes,
LPDWORD flags,
LPWSAOVERLAPPED overlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
typedef int (WSAAPI* LPFN_WSARECVFROM)
(SOCKET socket,
LPWSABUF buffers,
DWORD buffer_count,
LPDWORD bytes,
LPDWORD flags,
struct sockaddr* addr,
LPINT addr_len,
LPWSAOVERLAPPED overlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
#ifndef _NTDEF_
typedef LONG NTSTATUS;
typedef NTSTATUS *PNTSTATUS;
#endif
#ifndef RTL_CONDITION_VARIABLE_INIT
typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE;
#endif
typedef struct _AFD_POLL_HANDLE_INFO {
HANDLE Handle;
ULONG Events;
NTSTATUS Status;
} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO;
typedef struct _AFD_POLL_INFO {
LARGE_INTEGER Timeout;
ULONG NumberOfHandles;
ULONG Exclusive;
AFD_POLL_HANDLE_INFO Handles[1];
} AFD_POLL_INFO, *PAFD_POLL_INFO;
#define UV_MSAFD_PROVIDER_COUNT 4
/**
* It should be possible to cast uv_buf_t[] to WSABUF[]
* see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
*/
typedef struct uv_buf_t {
ULONG len;
char* base;
} uv_buf_t;
typedef int uv_file;
typedef SOCKET uv_os_sock_t;
typedef HANDLE uv_os_fd_t;
typedef int uv_pid_t;
typedef HANDLE uv_thread_t;
typedef HANDLE uv_sem_t;
typedef CRITICAL_SECTION uv_mutex_t;
/* This condition variable implementation is based on the SetEvent solution
* (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
* We could not use the SignalObjectAndWait solution (section 3.4) because
* it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and
* uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs.
*/
typedef union {
CONDITION_VARIABLE cond_var;
struct {
unsigned int waiters_count;
CRITICAL_SECTION waiters_count_lock;
HANDLE signal_event;
HANDLE broadcast_event;
} unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */
} uv_cond_t;
typedef struct {
SRWLOCK read_write_lock_;
/* TODO: retained for ABI compatibility; remove me in v2.x */
#ifdef _WIN64
unsigned char padding_[72];
#else
unsigned char padding_[44];
#endif
} uv_rwlock_t;
typedef struct {
unsigned threshold;
unsigned in;
uv_mutex_t mutex;
/* TODO: in v2 make this a uv_cond_t, without unused_ */
CONDITION_VARIABLE cond;
unsigned out;
} uv_barrier_t;
typedef struct {
DWORD tls_index;
} uv_key_t;
#define UV_ONCE_INIT { 0, NULL }
typedef struct uv_once_s {
unsigned char unused;
INIT_ONCE init_once;
} uv_once_t;
/* Platform-specific definitions for uv_spawn support. */
typedef unsigned char uv_uid_t;
typedef unsigned char uv_gid_t;
typedef struct uv__dirent_s {
int d_type;
char d_name[1];
} uv__dirent_t;
#define UV_DIR_PRIVATE_FIELDS \
HANDLE dir_handle; \
WIN32_FIND_DATAW find_data; \
BOOL need_find_call;
#define HAVE_DIRENT_TYPES
#define UV__DT_DIR UV_DIRENT_DIR
#define UV__DT_FILE UV_DIRENT_FILE
#define UV__DT_LINK UV_DIRENT_LINK
#define UV__DT_FIFO UV_DIRENT_FIFO
#define UV__DT_SOCKET UV_DIRENT_SOCKET
#define UV__DT_CHAR UV_DIRENT_CHAR
#define UV__DT_BLOCK UV_DIRENT_BLOCK
/* Platform-specific definitions for uv_dlopen support. */
#define UV_DYNAMIC FAR WINAPI
typedef struct {
HMODULE handle;
char* errmsg;
} uv_lib_t;
#define UV_LOOP_PRIVATE_FIELDS \
/* The loop's I/O completion port */ \
HANDLE iocp; \
/* The current time according to the event loop. in msecs. */ \
uint64_t time; \
/* Tail of a single-linked circular queue of pending reqs. If the queue */ \
/* is empty, tail_ is NULL. If there is only one item, */ \
/* tail_->next_req == tail_ */ \
uv_req_t* pending_reqs_tail; \
/* Head of a single-linked list of closed handles */ \
uv_handle_t* endgame_handles; \
/* TODO(bnoordhuis) Stop heap-allocating |timer_heap| in libuv v2.x. */ \
void* timer_heap; \
/* Lists of active loop (prepare / check / idle) watchers */ \
uv_prepare_t* prepare_handles; \
uv_check_t* check_handles; \
uv_idle_t* idle_handles; \
/* This pointer will refer to the prepare/check/idle handle whose */ \
/* callback is scheduled to be called next. This is needed to allow */ \
/* safe removal from one of the lists above while that list being */ \
/* iterated over. */ \
uv_prepare_t* next_prepare_handle; \
uv_check_t* next_check_handle; \
uv_idle_t* next_idle_handle; \
/* This handle holds the peer sockets for the fast variant of uv_poll_t */ \
SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \
/* No longer used. */ \
unsigned int active_tcp_streams; \
/* No longer used. */ \
unsigned int active_udp_streams; \
/* Counter to started timer */ \
uint64_t timer_counter; \
/* Threadpool */ \
struct uv__queue wq; \
uv_mutex_t wq_mutex; \
uv_async_t wq_async;
#define UV_REQ_TYPE_PRIVATE \
/* TODO: remove the req suffix */ \
UV_ACCEPT, \
UV_FS_EVENT_REQ, \
UV_POLL_REQ, \
UV_PROCESS_EXIT, \
UV_READ, \
UV_UDP_RECV, \
UV_WAKEUP, \
UV_SIGNAL_REQ,
#define UV_REQ_PRIVATE_FIELDS \
union { \
/* Used by I/O operations */ \
struct { \
OVERLAPPED overlapped; \
size_t queued_bytes; \
} io; \
/* in v2, we can move these to the UV_CONNECT_PRIVATE_FIELDS */ \
struct { \
ULONG_PTR result; /* overlapped.Internal is reused to hold the result */\
HANDLE pipeHandle; \
DWORD duplex_flags; \
WCHAR* name; \
} connect; \
} u; \
struct uv_req_s* next_req;
#define UV_WRITE_PRIVATE_FIELDS \
int coalesced; \
uv_buf_t write_buffer; \
HANDLE event_handle; \
HANDLE wait_handle;
#define UV_CONNECT_PRIVATE_FIELDS \
/* empty */
#define UV_SHUTDOWN_PRIVATE_FIELDS \
/* empty */
#define UV_UDP_SEND_PRIVATE_FIELDS \
/* empty */
#define UV_PRIVATE_REQ_TYPES \
typedef struct uv_pipe_accept_s { \
UV_REQ_FIELDS \
HANDLE pipeHandle; \
struct uv_pipe_accept_s* next_pending; \
} uv_pipe_accept_t; \
\
typedef struct uv_tcp_accept_s { \
UV_REQ_FIELDS \
SOCKET accept_socket; \
char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \
HANDLE event_handle; \
HANDLE wait_handle; \
struct uv_tcp_accept_s* next_pending; \
} uv_tcp_accept_t; \
\
typedef struct uv_read_s { \
UV_REQ_FIELDS \
HANDLE event_handle; \
HANDLE wait_handle; \
} uv_read_t;
#define uv_stream_connection_fields \
unsigned int write_reqs_pending; \
uv_shutdown_t* shutdown_req;
#define uv_stream_server_fields \
uv_connection_cb connection_cb;
#define UV_STREAM_PRIVATE_FIELDS \
unsigned int reqs_pending; \
int activecnt; \
uv_read_t read_req; \
union { \
struct { uv_stream_connection_fields } conn; \
struct { uv_stream_server_fields } serv; \
} stream;
#define uv_tcp_server_fields \
uv_tcp_accept_t* accept_reqs; \
unsigned int processed_accepts; \
uv_tcp_accept_t* pending_accepts; \
LPFN_ACCEPTEX func_acceptex;
#define uv_tcp_connection_fields \
uv_buf_t read_buffer; \
LPFN_CONNECTEX func_connectex;
#define UV_TCP_PRIVATE_FIELDS \
SOCKET socket; \
int delayed_error; \
union { \
struct { uv_tcp_server_fields } serv; \
struct { uv_tcp_connection_fields } conn; \
} tcp;
#define UV_UDP_PRIVATE_FIELDS \
SOCKET socket; \
unsigned int reqs_pending; \
int activecnt; \
uv_req_t recv_req; \
uv_buf_t recv_buffer; \
struct sockaddr_storage recv_from; \
int recv_from_len; \
uv_udp_recv_cb recv_cb; \
uv_alloc_cb alloc_cb; \
LPFN_WSARECV func_wsarecv; \
LPFN_WSARECVFROM func_wsarecvfrom;
#define uv_pipe_server_fields \
int pending_instances; \
uv_pipe_accept_t* accept_reqs; \
uv_pipe_accept_t* pending_accepts;
#define uv_pipe_connection_fields \
uv_timer_t* eof_timer; \
uv_write_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \
DWORD ipc_remote_pid; \
union { \
uint32_t payload_remaining; \
uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \
} ipc_data_frame; \
struct uv__queue ipc_xfer_queue; \
int ipc_xfer_queue_length; \
uv_write_t* non_overlapped_writes_tail; \
CRITICAL_SECTION readfile_thread_lock; \
volatile HANDLE readfile_thread_handle;
#define UV_PIPE_PRIVATE_FIELDS \
HANDLE handle; \
WCHAR* name; \
union { \
struct { uv_pipe_server_fields } serv; \
struct { uv_pipe_connection_fields } conn; \
} pipe;
/* TODO: put the parser states in a union - TTY handles are always half-duplex
* so read-state can safely overlap write-state. */
#define UV_TTY_PRIVATE_FIELDS \
HANDLE handle; \
union { \
struct { \
/* Used for readable TTY handles */ \
union { \
/* TODO: remove me in v2.x. */ \
HANDLE unused_; \
int mode; \
} mode; \
uv_buf_t read_line_buffer; \
HANDLE read_raw_wait; \
/* Fields used for translating win keystrokes into vt100 characters */ \
char last_key[8]; \
unsigned char last_key_offset; \
unsigned char last_key_len; \
WCHAR last_utf16_high_surrogate; \
INPUT_RECORD last_input_record; \
} rd; \
struct { \
/* Used for writable TTY handles */ \
/* utf8-to-utf16 conversion state */ \
unsigned int utf8_codepoint; \
unsigned char utf8_bytes_left; \
/* eol conversion state */ \
unsigned char previous_eol; \
/* ansi parser state */ \
unsigned short ansi_parser_state; \
unsigned char ansi_csi_argc; \
unsigned short ansi_csi_argv[4]; \
COORD saved_position; \
WORD saved_attributes; \
} wr; \
} tty;
#define UV_POLL_PRIVATE_FIELDS \
SOCKET socket; \
/* Used in fast mode */ \
SOCKET peer_socket; \
AFD_POLL_INFO afd_poll_info_1; \
AFD_POLL_INFO afd_poll_info_2; \
/* Used in fast and slow mode. */ \
uv_req_t poll_req_1; \
uv_req_t poll_req_2; \
unsigned char submitted_events_1; \
unsigned char submitted_events_2; \
unsigned char mask_events_1; \
unsigned char mask_events_2; \
unsigned char events;
#define UV_TIMER_PRIVATE_FIELDS \
union { \
void* heap[3]; \
struct uv__queue queue; \
} node; \
int unused; \
uint64_t timeout; \
uint64_t repeat; \
uint64_t start_id; \
uv_timer_cb timer_cb;
#define UV_ASYNC_PRIVATE_FIELDS \
struct uv_req_s async_req; \
uv_async_cb async_cb; \
/* char to avoid alignment issues */ \
char volatile async_sent;
#define UV_PREPARE_PRIVATE_FIELDS \
uv_prepare_t* prepare_prev; \
uv_prepare_t* prepare_next; \
uv_prepare_cb prepare_cb;
#define UV_CHECK_PRIVATE_FIELDS \
uv_check_t* check_prev; \
uv_check_t* check_next; \
uv_check_cb check_cb;
#define UV_IDLE_PRIVATE_FIELDS \
uv_idle_t* idle_prev; \
uv_idle_t* idle_next; \
uv_idle_cb idle_cb;
#define UV_HANDLE_PRIVATE_FIELDS \
uv_handle_t* endgame_next; \
unsigned int flags;
#define UV_GETADDRINFO_PRIVATE_FIELDS \
struct uv__work work_req; \
uv_getaddrinfo_cb getaddrinfo_cb; \
void* alloc; \
WCHAR* node; \
WCHAR* service; \
/* The addrinfoW field is used to store a pointer to the hints, and */ \
/* later on to store the result of GetAddrInfoW. The final result will */ \
/* be converted to struct addrinfo* and stored in the addrinfo field. */ \
struct addrinfoW* addrinfow; \
struct addrinfo* addrinfo; \
int retcode;
#define UV_GETNAMEINFO_PRIVATE_FIELDS \
struct uv__work work_req; \
uv_getnameinfo_cb getnameinfo_cb; \
struct sockaddr_storage storage; \
int flags; \
char host[NI_MAXHOST]; \
char service[NI_MAXSERV]; \
int retcode;
#define UV_PROCESS_PRIVATE_FIELDS \
struct uv_process_exit_s { \
UV_REQ_FIELDS \
} exit_req; \
void* unused; /* TODO: retained for ABI compat; remove this in v2.x. */ \
int exit_signal; \
HANDLE wait_handle; \
HANDLE process_handle; \
volatile char exit_cb_pending;
#define UV_FS_PRIVATE_FIELDS \
struct uv__work work_req; \
int flags; \
DWORD sys_errno_; \
union { \
/* TODO: remove me in 0.9. */ \
WCHAR* pathw; \
int fd; \
} file; \
union { \
struct { \
int mode; \
WCHAR* new_pathw; \
int file_flags; \
int fd_out; \
unsigned int nbufs; \
uv_buf_t* bufs; \
int64_t offset; \
uv_buf_t bufsml[4]; \
} info; \
struct { \
double atime; \
double mtime; \
} time; \
} fs;
#define UV_WORK_PRIVATE_FIELDS \
struct uv__work work_req;
#define UV_FS_EVENT_PRIVATE_FIELDS \
struct uv_fs_event_req_s { \
UV_REQ_FIELDS \
} req; \
HANDLE dir_handle; \
int req_pending; \
uv_fs_event_cb cb; \
WCHAR* filew; \
WCHAR* short_filew; \
WCHAR* dirw; \
char* buffer;
#define UV_SIGNAL_PRIVATE_FIELDS \
RB_ENTRY(uv_signal_s) tree_entry; \
struct uv_req_s signal_req; \
unsigned long pending_signum;
#ifndef F_OK
#define F_OK 0
#endif
#ifndef R_OK
#define R_OK 4
#endif
#ifndef W_OK
#define W_OK 2
#endif
#ifndef X_OK
#define X_OK 1
#endif
/* fs open() flags supported on this platform: */
#define UV_FS_O_APPEND _O_APPEND
#define UV_FS_O_CREAT _O_CREAT
#define UV_FS_O_EXCL _O_EXCL
#define UV_FS_O_FILEMAP 0x20000000
#define UV_FS_O_RANDOM _O_RANDOM
#define UV_FS_O_RDONLY _O_RDONLY
#define UV_FS_O_RDWR _O_RDWR
#define UV_FS_O_SEQUENTIAL _O_SEQUENTIAL
#define UV_FS_O_SHORT_LIVED _O_SHORT_LIVED
#define UV_FS_O_TEMPORARY _O_TEMPORARY
#define UV_FS_O_TRUNC _O_TRUNC
#define UV_FS_O_WRONLY _O_WRONLY
/* fs open() flags supported on other platforms (or mapped on this platform): */
#define UV_FS_O_DIRECT 0x02000000 /* FILE_FLAG_NO_BUFFERING */
#define UV_FS_O_DIRECTORY 0
#define UV_FS_O_DSYNC 0x04000000 /* FILE_FLAG_WRITE_THROUGH */
#define UV_FS_O_EXLOCK 0x10000000 /* EXCLUSIVE SHARING MODE */
#define UV_FS_O_NOATIME 0
#define UV_FS_O_NOCTTY 0
#define UV_FS_O_NOFOLLOW 0
#define UV_FS_O_NONBLOCK 0
#define UV_FS_O_SYMLINK 0
#define UV_FS_O_SYNC 0x08000000 /* FILE_FLAG_WRITE_THROUGH */

View File

@@ -1 +0,0 @@
CLAUDE.md

View File

@@ -198,19 +198,19 @@ pub const meta = @import("./meta.zig");
pub const base64 = @import("./base64/base64.zig");
pub const path = @import("./resolver/resolve_path.zig");
pub const resolver = @import("./resolver/resolver.zig");
pub const DirIterator = @import("./bun.js/node/dir_iterator.zig");
pub const DirIterator = @import("./buntime/node/dir_iterator.zig");
pub const PackageJSON = @import("./resolver/package_json.zig").PackageJSON;
pub const fmt = @import("./fmt.zig");
// This file is gennerated, but cant be placed in the build/debug/codegen
// folder because zig will complain about outside-of-module stuff
/// All functions and interfaces provided from Bun's `bindgen` utility.
pub const gen = @import("./bun.js/bindings/GeneratedBindings.zig");
pub const gen = @import("./buntime/jsc/generated/GeneratedBindings.zig");
comptime {
// This file is gennerated, but cant be placed in the build/debug/codegen
// folder because zig will complain about outside-of-module stuff
_ = &@import("./bun.js/bindings/GeneratedJS2Native.zig");
_ = &@import("./buntime/jsc/generated/GeneratedJS2Native.zig");
_ = &gen; // reference bindings
}
@@ -231,7 +231,7 @@ pub const bits = @import("./bits.zig");
pub const css = @import("./css/css_parser.zig");
pub const SmallList = css.SmallList;
pub const csrf = @import("./csrf.zig");
pub const validators = @import("./bun.js/node/util/validators.zig");
pub const validators = @import("./buntime/node/util/validators.zig");
pub const shell = @import("./shell/shell.zig");
@@ -731,7 +731,7 @@ pub const LOLHTML = @import("./deps/lol-html.zig");
pub const clap = @import("./deps/zig-clap/clap.zig");
pub const analytics = @import("./analytics.zig");
pub const zlib = @import("./zlib.zig");
pub const simdutf = @import("./bun.js/bindings/bun-simdutf.zig");
pub const simdutf = @import("./string/bun-simdutf.zig");
pub var start_time: i128 = 0;
@@ -1099,12 +1099,12 @@ pub const PackageManager = install.PackageManager;
pub const RunCommand = @import("./cli/run_command.zig").RunCommand;
pub const fs = @import("./fs.zig");
pub const transpiler = @import("./transpiler.zig");
pub const transpiler = @import("./transpiler/transpiler.zig");
pub const Transpiler = transpiler.Transpiler;
pub const which = @import("./which.zig").which;
pub const js_parser = @import("./js_parser.zig");
pub const js_printer = @import("./js_printer.zig");
pub const js_lexer = @import("./js_lexer.zig");
pub const js_parser = @import("./transpiler/js_parser.zig");
pub const js_printer = @import("./transpiler/js_printer.zig");
pub const js_lexer = @import("./transpiler/js_lexer.zig");
pub const ast = @import("./ast.zig");
pub const interchange = @import("./interchange.zig");
@@ -1380,7 +1380,7 @@ pub fn asByteSlice(buffer: anytype) []const u8 {
}
comptime {
_ = @import("./bun.js/node/buffer.zig").BufferVectorized.fill;
_ = @import("./buntime/node/buffer.zig").BufferVectorized.fill;
_ = @import("./cli/upgrade_command.zig").Version;
}
@@ -2102,7 +2102,7 @@ pub fn initArgv(allocator: std.mem.Allocator) !void {
}
}
pub const spawn = @import("./bun.js/api/bun/spawn.zig").PosixSpawn;
pub const spawn = @import("./buntime/api/bun/spawn.zig").PosixSpawn;
pub fn isRegularFile(mode: anytype) bool {
return S.ISREG(@intCast(mode));
@@ -3304,7 +3304,7 @@ pub const timespec = extern struct {
}
};
pub const UUID = @import("./bun.js/uuid.zig");
pub const UUID = @import("./buntime/web/webcrypto/uuid.zig");
/// An abstract number of element in a sequence. The sequence has a first element.
/// This type should be used instead of integer because 2 contradicting traditions can

View File

@@ -2661,8 +2661,8 @@ pub const ParseTask = bun.bundle_v2.ParseTask;
const string = []const u8;
const NodeFallbackModules = @import("../node_fallbacks.zig");
const js_printer = @import("../js_printer.zig");
const lex = @import("../js_lexer.zig");
const js_printer = @import("../transpiler/js_printer.zig");
const lex = @import("../transpiler/js_lexer.zig");
const linker = @import("../linker.zig");
const runtime = @import("../runtime.zig");
const std = @import("std");

View File

@@ -4501,10 +4501,10 @@ pub fn allocatorHasPointer(allocator: std.mem.Allocator) bool {
}
pub const std = @import("std");
pub const lex = @import("../js_lexer.zig");
pub const lex = @import("../transpiler/js_lexer.zig");
pub const Logger = @import("../logger.zig");
pub const Part = js_ast.Part;
pub const js_printer = @import("../js_printer.zig");
pub const js_printer = @import("../transpiler/js_printer.zig");
pub const js_ast = bun.ast;
pub const linker = @import("../linker.zig");
pub const SourceMap = bun.SourceMap;

View File

@@ -40,7 +40,7 @@ Identifying the _source_ of a `ReadableStream` at the native level unlocks many
- **Identification:** A C++ binding, `ReadableStreamTag__tagged` (from `ReadableStream.zig`), is the primary entry point for this identification. When native code needs to consume a stream (e.g., when sending a `Response` body), it calls this function on the JS `ReadableStream` object to determine its origin.
```zig
// src/bun.js/webcore/ReadableStream.zig
// src/buntime/web/streams/ReadableStream.zig
pub const Tag = enum(i32) {
JavaScript = 0, // A generic, user-defined stream. This is the "slow path".
Blob = 1, // An in-memory blob. Fast path available.

View File

@@ -32,7 +32,7 @@ pub const YAMLObject = @import("./api/YAMLObject.zig");
pub const Timer = @import("./api/Timer.zig");
pub const FFIObject = @import("./api/FFIObject.zig");
pub const BuildArtifact = @import("./api/JSBundler.zig").BuildArtifact;
pub const BuildMessage = @import("./BuildMessage.zig").BuildMessage;
pub const BuildMessage = @import("./api/error/BuildMessage.zig").BuildMessage;
pub const dns = @import("./api/bun/dns.zig");
pub const FFI = @import("./api/ffi.zig").FFI;
pub const HTMLRewriter = @import("./api/html_rewriter.zig");
@@ -46,7 +46,7 @@ pub const NativeBrotli = @import("./node/zlib/NativeBrotli.zig");
pub const NativeZlib = @import("./node/zlib/NativeZlib.zig");
pub const Postgres = @import("../sql/postgres.zig");
pub const MySQL = @import("../sql/mysql.zig");
pub const ResolveMessage = @import("./ResolveMessage.zig").ResolveMessage;
pub const ResolveMessage = @import("./api/error/ResolveMessage.zig").ResolveMessage;
pub const Shell = @import("../shell/shell.zig");
pub const UDPSocket = @import("./api/bun/udp_socket.zig").UDPSocket;
pub const Valkey = @import("../valkey/js_valkey.zig").JSValkeyClient;

View File

@@ -23,7 +23,7 @@ pub const BunObject = struct {
pub const gzipSync = toJSCallback(JSZlib.gzipSync);
pub const indexOfLine = toJSCallback(Bun.indexOfLine);
pub const inflateSync = toJSCallback(JSZlib.inflateSync);
pub const jest = toJSCallback(@import("../test/jest.zig").Jest.call);
pub const jest = toJSCallback(@import("../../test_runner/jest.zig").Jest.call);
pub const listen = toJSCallback(host_fn.wrapStaticMethod(api.Listener, "listen", false));
pub const mmap = toJSCallback(Bun.mmapFile);
pub const nanoseconds = toJSCallback(Bun.nanoseconds);

View File

@@ -1,6 +1,6 @@
// This file is part of Bun!
// You can find the original source:
// https://github.com/oven-sh/bun/blob/main/src/bun.js/api/FFI.h
// https://github.com/oven-sh/bun/blob/main/src/buntime/api/FFI.h
//
// clang-format off
// This file is only compatible with 64 bit CPUs

View File

@@ -93,7 +93,7 @@ pub fn dispose(self: *Self, globalThis: *JSGlobalObject, _: *jsc.CallFrame) bun.
return .js_undefined;
}
const Debugger = @import("../../Debugger.zig");
const Debugger = @import("../inspector/Debugger.zig");
const bun = @import("bun");
const EventLoopTimer = bun.api.Timer.EventLoopTimer;

View File

@@ -123,7 +123,7 @@ pub fn dispose(self: *Self, globalThis: *JSGlobalObject, _: *jsc.CallFrame) bun.
return .js_undefined;
}
const Debugger = @import("../../Debugger.zig");
const Debugger = @import("../inspector/Debugger.zig");
const bun = @import("bun");
const EventLoopTimer = bun.api.Timer.EventLoopTimer;

View File

@@ -473,7 +473,7 @@ pub fn deinit(this: *TimerObjectInternals) void {
}
}
const Debugger = @import("../../Debugger.zig");
const Debugger = @import("../inspector/Debugger.zig");
const std = @import("std");
const bun = @import("bun");

View File

@@ -1099,7 +1099,7 @@ pub fn appendEnvpFromJS(globalThis: *jsc.JSGlobalObject, object: *jsc.JSObject,
const log = Output.scoped(.Subprocess, .hidden);
extern "C" const BUN_DEFAULT_PATH_FOR_SPAWN: [*:0]const u8;
const IPC = @import("../../ipc.zig");
const IPC = @import("../ipc/ipc.zig");
const Terminal = @import("./Terminal.zig");
const std = @import("std");
const Allocator = std.mem.Allocator;

View File

@@ -7,7 +7,7 @@ const lshpack_header = extern struct {
hpack_index: u16 = 255,
};
/// wrapper implemented at src/bun.js/bindings/c-bindings.cpp
/// wrapper implemented at src/buntime/bindings/c-bindings.cpp
pub const HPACK = extern struct {
self: *anyopaque,

View File

@@ -917,7 +917,7 @@ pub const MaxBuf = bun.io.MaxBuf;
pub const spawnSync = js_bun_spawn_bindings.spawnSync;
pub const spawn = js_bun_spawn_bindings.spawn;
const IPC = @import("../../ipc.zig");
const IPC = @import("../ipc/ipc.zig");
const Terminal = @import("./Terminal.zig");
const js_bun_spawn_bindings = @import("./js_bun_spawn_bindings.zig");
const node_cluster_binding = @import("../../node/node_cluster_binding.zig");

View File

@@ -1064,7 +1064,7 @@ pub const Formatter = struct {
// For detecting circular references
pub const Visited = struct {
const ObjectPool = @import("../pool.zig").ObjectPool;
const ObjectPool = @import("../../../pool.zig").ObjectPool;
pub const Map = std.AutoHashMap(JSValue, void);
pub const Pool = ObjectPool(
Map,
@@ -3798,8 +3798,8 @@ comptime {
const string = []const u8;
const std = @import("std");
const CLI = @import("../cli.zig").Command;
const JestPrettyFormat = @import("./test/pretty_format.zig").JestPrettyFormat;
const CLI = @import("../../../cli.zig").Command;
const JestPrettyFormat = @import("../../../test_runner/pretty_format.zig").JestPrettyFormat;
const bun = @import("bun");
const Environment = bun.Environment;

Some files were not shown because too many files have changed in this diff Show More