mirror of
https://github.com/oven-sh/bun
synced 2026-02-22 16:51:50 +00:00
Compare commits
116 Commits
claude/smt
...
claude/sou
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2403a8d46 | ||
|
|
e6db5003e0 | ||
|
|
e48a9985cf | ||
|
|
3a1be14392 | ||
|
|
fd57125842 | ||
|
|
9e71f4453e | ||
|
|
b40b442c62 | ||
|
|
ab2f5a20d3 | ||
|
|
d07c1bba42 | ||
|
|
fedccb4b6d | ||
|
|
c7ed08f4ff | ||
|
|
00ba82605a | ||
|
|
1fa3829f55 | ||
|
|
e7c861c643 | ||
|
|
6e5ef1bedb | ||
|
|
456176deef | ||
|
|
44727cbd44 | ||
|
|
9dab6a8843 | ||
|
|
fd84244b3d | ||
|
|
941986868a | ||
|
|
b9a2852d53 | ||
|
|
a7797a7339 | ||
|
|
6c5f83417e | ||
|
|
2a40325984 | ||
|
|
53b587ad74 | ||
|
|
2936b29a73 | ||
|
|
6f4fcfaeb9 | ||
|
|
7ceb58fc8b | ||
|
|
316087d3be | ||
|
|
158d805751 | ||
|
|
e4a34a4b23 | ||
|
|
d4adbae015 | ||
|
|
0847104330 | ||
|
|
fca5b782d5 | ||
|
|
0d11a4e4c0 | ||
|
|
695db55b77 | ||
|
|
ef906c38bb | ||
|
|
5bdb625281 | ||
|
|
793682ba43 | ||
|
|
c88d0d2ab5 | ||
|
|
601e9dbceb | ||
|
|
790887eb7b | ||
|
|
eede4efac9 | ||
|
|
795264752b | ||
|
|
cef59deb21 | ||
|
|
e4a2d75e4a | ||
|
|
1f47e3fd00 | ||
|
|
2ad1284442 | ||
|
|
03c3949648 | ||
|
|
872a5a335d | ||
|
|
655038a408 | ||
|
|
ff2ba59f4a | ||
|
|
25be9ea0ae | ||
|
|
07d6e07e87 | ||
|
|
0efcfaa464 | ||
|
|
877c36108d | ||
|
|
289c26a164 | ||
|
|
2dfbeec70d | ||
|
|
ae4dd4ee08 | ||
|
|
24b38f1a9b | ||
|
|
c41207374b | ||
|
|
e137723de0 | ||
|
|
f2ce862308 | ||
|
|
9a1791d53d | ||
|
|
5c76c0f7fa | ||
|
|
8e8d8548a9 | ||
|
|
31cf2e9692 | ||
|
|
8cf859f460 | ||
|
|
ef9f4af60f | ||
|
|
dc1bf7b2b8 | ||
|
|
0f2441febd | ||
|
|
64c75fedb7 | ||
|
|
f66d82a296 | ||
|
|
49fd4dc56e | ||
|
|
8fa79c2b5f | ||
|
|
742b0f0ad6 | ||
|
|
a02748ef11 | ||
|
|
70daa60d0b | ||
|
|
ff72b9566d | ||
|
|
8c2ce7f15d | ||
|
|
e993178e6e | ||
|
|
018f9e0946 | ||
|
|
834605e5c5 | ||
|
|
02a022f143 | ||
|
|
16e98547c9 | ||
|
|
e3cb63ec8e | ||
|
|
f040a828d3 | ||
|
|
2194724425 | ||
|
|
313f714b6d | ||
|
|
8696c55595 | ||
|
|
9ffbb5c99c | ||
|
|
52407bca9c | ||
|
|
5a33924475 | ||
|
|
c67d6182f7 | ||
|
|
c9bb8b16c1 | ||
|
|
cf86901409 | ||
|
|
f13396c8d2 | ||
|
|
f066c98c2a | ||
|
|
f0db7ce4e9 | ||
|
|
a8a15feb8e | ||
|
|
57a92ae359 | ||
|
|
0197c54a2c | ||
|
|
73abb99ea3 | ||
|
|
b9af431178 | ||
|
|
c4205a4a3a | ||
|
|
772533afd8 | ||
|
|
ced6ba6c82 | ||
|
|
d8b43c28da | ||
|
|
bfc99fa5de | ||
|
|
e306d9dbda | ||
|
|
0620ff58fe | ||
|
|
7227eef0ff | ||
|
|
781a3f9508 | ||
|
|
5fea6eb184 | ||
|
|
e0ae7683a7 | ||
|
|
e84b4b4847 |
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
183
CLAUDE.md
@@ -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`.
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,7 +2,7 @@ register_cmake_command(
|
||||
TARGET
|
||||
sqlite
|
||||
CWD
|
||||
${CWD}/src/bun.js/bindings/sqlite
|
||||
${CWD}/src/buntime/bindings/sqlite
|
||||
LIBRARIES
|
||||
sqlite3
|
||||
INCLUDES
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
CLAUDE.md
|
||||
11
src/AGENTS.md
Normal file
11
src/AGENTS.md
Normal 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.
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
@@ -1,2 +0,0 @@
|
||||
*.lut.h
|
||||
sqlite/sqlite3_local.h
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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 */
|
||||
@@ -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_ */
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
@@ -1 +0,0 @@
|
||||
CLAUDE.md
|
||||
24
src/bun.zig
24
src/bun.zig
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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");
|
||||
@@ -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;
|
||||
@@ -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,
|
||||
|
||||
@@ -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");
|
||||
@@ -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
Reference in New Issue
Block a user