diff --git a/packages/bun-error/index.tsx b/packages/bun-error/index.tsx index 8a1aef4bf1be..88b763a518f1 100644 --- a/packages/bun-error/index.tsx +++ b/packages/bun-error/index.tsx @@ -11,7 +11,6 @@ import { type SourceLine, type StackFrame, } from "./schema"; -import { fetchAllMappings, remapPosition, sourceMappings } from "./sourcemap"; export enum JSErrorCode { Error = 0, @@ -1021,188 +1020,11 @@ export function renderFallbackError(fallback: FallbackMessageContainer) { globalThis[Symbol.for("Bun__renderFallbackError")] = renderFallbackError; -import { parse as getStackTrace } from "./stack-trace-parser"; -var runtimeErrorController: AbortController | null = null; -var pending: { stopped: boolean }[] = []; - -var onIdle = globalThis.requestIdleCallback || (cb => setTimeout(cb, 32)); -function clearSourceMappings() { - sourceMappings.clear(); -} -export function renderRuntimeError(error: Error) { - runtimeErrorController = new AbortController(); - if (typeof error === "string") { - error = { - name: "Error", - message: error, - }; - } - - const exception = { - name: String(error.name), - message: String(error.message), - runtime_type: 0, - stack: { - frames: error.stack ? getStackTrace(error.stack) : [], - source_lines: [], - }, - }; - - var lineNumberProperty = ""; - var columnNumberProperty = ""; - var fileNameProperty = ""; - - if (error && typeof error === "object") { - // safari - if ("line" in error) { - lineNumberProperty = "line"; - // firefox - } else if ("lineNumber" in error) { - lineNumberProperty = "lineNumber"; - } - - // safari - if ("column" in error) { - columnNumberProperty = "column"; - // firefox - } else if ("columnNumber" in error) { - columnNumberProperty = "columnNumber"; - } - - // safari - if ("sourceURL" in error) { - fileNameProperty = "sourceURL"; - // firefox - } else if ("fileName" in error) { - fileNameProperty = "fileName"; - } - } - - if (Number.isFinite(error[lineNumberProperty])) { - if (exception.stack?.frames.length == 0) { - exception.stack.frames.push({ - file: error[fileNameProperty] || "", - position: { - line: +error[lineNumberProperty] || 1, - column: +error[columnNumberProperty] || 1, - }, - } as StackFrame); - } else if (exception.stack && exception.stack.frames.length > 0) { - exception.stack.frames[0].position.line = error[lineNumberProperty]; - - if (Number.isFinite(error[columnNumberProperty])) { - exception.stack.frames[0].position.column = error[columnNumberProperty]; - } - } - } - const signal = runtimeErrorController.signal; - - const fallback: FallbackMessageContainer = { - message: error.message, - - problems: { - build: { - warnings: 0, - errors: 0, - msgs: [], - }, - exceptions: [exception], - }, - }; - - var stopThis = { stopped: false }; - pending.push(stopThis); - - const BunError = () => { - return ( - - - - ); - }; - - // Remap the sourcemaps - // But! If we've already fetched the source mappings in this page load before - // Rely on the cached ones - // and don't fetch them again - const framePromises = fetchAllMappings( - exception.stack.frames.map(frame => normalizedFilename(frame.file, thisCwd)), - signal, - ) - .map((frame, i) => { - if (stopThis.stopped) return null; - return [frame, i]; - }) - .map(result => { - if (!result) return; - const [mappings, frameIndex] = result; - if (mappings?.then) { - return mappings.then(mappings => { - if (!mappings || stopThis.stopped) { - return null; - } - var frame = exception.stack.frames[frameIndex]; - - const { line, column } = frame.position; - const remapped = remapPosition(mappings, line, column); - if (!remapped) return null; - frame.position.line_start = frame.position.line = remapped[0]; - frame.position.column_stop = - frame.position.expression_stop = - frame.position.expression_start = - frame.position.column = - remapped[1]; - }, console.error); - } else { - if (!mappings) return null; - var frame = exception.stack.frames[frameIndex]; - const { line, column } = frame.position; - const remapped = remapPosition(mappings, line, column); - if (!remapped) return null; - frame.position.line_start = frame.position.line = remapped[0]; - frame.position.column_stop = - frame.position.expression_stop = - frame.position.expression_start = - frame.position.column = - remapped[1]; - } - }); - - var anyPromises = false; - for (let i = 0; i < framePromises.length; i++) { - if (framePromises[i] && framePromises[i].then) { - anyPromises = true; - break; - } - } - - if (anyPromises) { - Promise.allSettled(framePromises).finally(() => { - if (stopThis.stopped || signal.aborted) return; - onIdle(clearSourceMappings); - return renderWithFunc(() => { - return ; - }); - }); - } else { - onIdle(clearSourceMappings); - renderWithFunc(() => { - return ; - }); - } -} - export function dismissError() { if (reactRoot) { render(null, reactRoot); const root = document.getElementById("__bun__error-root"); if (root) root.remove(); reactRoot = null; - if (runtimeErrorController) { - runtimeErrorController.abort(); - runtimeErrorController = null; - } - - while (pending.length > 0) pending.shift().stopped = true; } } diff --git a/packages/bun-error/schema.ts b/packages/bun-error/schema.ts index 5a00dc6eac0d..2d034982efa8 100644 --- a/packages/bun-error/schema.ts +++ b/packages/bun-error/schema.ts @@ -16,7 +16,7 @@ export interface StackFramePosition { line: number; /** 1-based; -1 when the frame has no source position */ column: number; - // Only set on frames built client-side (runtime-error.ts, source-map remapping in index.tsx). + // Only set on frames built client-side (runtime-error.ts). source_offset?: number; line_start?: number; line_stop?: number; diff --git a/packages/bun-error/sourcemap.ts b/packages/bun-error/sourcemap.ts deleted file mode 100644 index aa3fabbecb57..000000000000 --- a/packages/bun-error/sourcemap.ts +++ /dev/null @@ -1,331 +0,0 @@ -// Accelerate VLQ decoding with a lookup table -const vlqTable = new Uint8Array(128); -const vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -vlqTable.fill(0xff); -for (let i = 0; i < vlqChars.length; i++) vlqTable[vlqChars.charCodeAt(i)] = i; - -export function parseSourceMap(json) { - if (json.version !== 3) { - throw new Error("Invalid source map"); - } - - if (!(json.sources instanceof Array) || json.sources.some(x => typeof x !== "string")) { - throw new Error("Invalid source map"); - } - - if (typeof json.mappings !== "string") { - throw new Error("Invalid source map"); - } - - const { sources, sourcesContent, names, mappings } = json; - const emptyData = new Int32Array(0); - for (let i = 0; i < sources.length; i++) { - sources[i] = { - name: sources[i], - content: (sourcesContent && sourcesContent[i]) || "", - data: emptyData, - dataLength: 0, - }; - } - const data = decodeMappings(mappings, sources.length); - return { sources, names, data }; -} - -// ripped from https://github.com/evanw/source-map-visualization/blob/gh-pages/code.js#L179 -export function decodeMappings(mappings, sourcesCount) { - const n = mappings.length; - let data = new Int32Array(1024); - let dataLength = 0; - let generatedLine = 0; - let generatedLineStart = 0; - let generatedColumn = 0; - let originalSource = 0; - let originalLine = 0; - let originalColumn = 0; - let originalName = 0; - let needToSortGeneratedColumns = false; - let i = 0; - - function decodeError(text) { - const error = `Invalid VLQ data at index ${i}: ${text}`; - throw new Error(error); - } - - function decodeVLQ() { - let shift = 0; - let vlq = 0; - - // Scan over the input - while (true) { - // Read a byte - if (i >= mappings.length) decodeError("Expected extra data"); - const c = mappings.charCodeAt(i); - if ((c & 0x7f) !== c) decodeError("Invalid character"); - const index = vlqTable[c & 0x7f]; - if (index === 0xff) decodeError("Invalid character"); - i++; - - // Decode the byte - vlq |= (index & 31) << shift; - shift += 5; - - // Stop if there's no continuation bit - if ((index & 32) === 0) break; - } - - // Recover the signed value - return vlq & 1 ? -(vlq >> 1) : vlq >> 1; - } - - while (i < n) { - let c = mappings.charCodeAt(i); - - // Handle a line break - if (c === 59 /* ; */) { - // The generated columns are very rarely out of order. In that case, - // sort them with insertion since they are very likely almost ordered. - if (needToSortGeneratedColumns) { - for (let j = generatedLineStart + 6; j < dataLength; j += 6) { - const genL = data[j]; - const genC = data[j + 1]; - const origS = data[j + 2]; - const origL = data[j + 3]; - const origC = data[j + 4]; - const origN = data[j + 5]; - let k = j - 6; - for (; k >= generatedLineStart && data[k + 1] > genC; k -= 6) { - data[k + 6] = data[k]; - data[k + 7] = data[k + 1]; - data[k + 8] = data[k + 2]; - data[k + 9] = data[k + 3]; - data[k + 10] = data[k + 4]; - data[k + 11] = data[k + 5]; - } - data[k + 6] = genL; - data[k + 7] = genC; - data[k + 8] = origS; - data[k + 9] = origL; - data[k + 10] = origC; - data[k + 11] = origN; - } - } - - generatedLine++; - generatedColumn = 0; - generatedLineStart = dataLength; - needToSortGeneratedColumns = false; - i++; - continue; - } - - // Ignore stray commas - if (c === 44 /* , */) { - i++; - continue; - } - - // Read the generated column - const generatedColumnDelta = decodeVLQ(); - if (generatedColumnDelta < 0) needToSortGeneratedColumns = true; - generatedColumn += generatedColumnDelta; - if (generatedColumn < 0) decodeError("Invalid generated column"); - - // It's valid for a mapping to have 1, 4, or 5 variable-length fields - let isOriginalSourceMissing = true; - let isOriginalNameMissing = true; - if (i < n) { - c = mappings.charCodeAt(i); - if (c === 44 /* , */) { - i++; - } else if (c !== 59 /* ; */) { - isOriginalSourceMissing = false; - - // Read the original source - const originalSourceDelta = decodeVLQ(); - originalSource += originalSourceDelta; - if (originalSource < 0 || originalSource >= sourcesCount) decodeError("Invalid original source"); - - // Read the original line - const originalLineDelta = decodeVLQ(); - originalLine += originalLineDelta; - if (originalLine < 0) decodeError("Invalid original line"); - - // Read the original column - const originalColumnDelta = decodeVLQ(); - originalColumn += originalColumnDelta; - if (originalColumn < 0) decodeError("Invalid original column"); - - // Check for the optional name index - if (i < n) { - c = mappings.charCodeAt(i); - if (c === 44 /* , */) { - i++; - } else if (c !== 59 /* ; */) { - isOriginalNameMissing = false; - - // Read the optional name index - const originalNameDelta = decodeVLQ(); - originalName += originalNameDelta; - if (originalName < 0) decodeError("Invalid original name"); - - // Handle the next character - if (i < n) { - c = mappings.charCodeAt(i); - if (c === 44 /* , */) { - i++; - } else if (c !== 59 /* ; */) { - decodeError("Invalid character after mapping"); - } - } - } - } - } - } - - // Append the mapping to the typed array - if (dataLength + 6 > data.length) { - const newData = new Int32Array(data.length << 1); - newData.set(data); - data = newData; - } - data[dataLength] = generatedLine; - data[dataLength + 1] = generatedColumn; - if (isOriginalSourceMissing) { - data[dataLength + 2] = -1; - data[dataLength + 3] = -1; - data[dataLength + 4] = -1; - } else { - data[dataLength + 2] = originalSource; - data[dataLength + 3] = originalLine; - data[dataLength + 4] = originalColumn; - } - data[dataLength + 5] = isOriginalNameMissing ? -1 : originalName; - dataLength += 6; - } - - return data.subarray(0, dataLength); -} - -export function remapPosition(decodedMappings: Int32Array, line: number, column: number) { - if (!(decodedMappings instanceof Int32Array)) { - throw new Error("decodedMappings must be an Int32Array"); - } - - if (!Number.isFinite(line)) { - throw new Error("line must be a finite number"); - } - - if (!Number.isFinite(column)) { - throw new Error("column must be a finite number"); - } - - if (decodedMappings.length === 0 || line < 0 || column < 0) return null; - - const index = indexOfMapping(decodedMappings, line, column); - if (index === -1) return null; - - return [decodedMappings[index + 3] + 1, decodedMappings[index + 4]]; -} - -async function fetchRemoteSourceMap(file: string, signal) { - const response = await globalThis.fetch(file + ".map", { - signal, - headers: { - Accept: "application/json", - "Mappings-Only": "1", - }, - }); - - if (response.ok) { - return await response.json(); - } - - return null; -} - -export var sourceMappings = new Map(); - -export function fetchMappings(file, signal) { - if (file.includes(".bun")) return null; - if (sourceMappings.has(file)) { - return sourceMappings.get(file); - } - - return fetchRemoteSourceMap(file, signal).then(json => { - if (!json) return null; - const { data } = parseSourceMap(json); - sourceMappings.set(file, data); - return data; - }); -} - -// this batches duplicate requests -export function fetchAllMappings(files, signal) { - var results = new Array(files.length); - var map = new Map(); - for (var i = 0; i < files.length; i++) { - const existing = map.get(files[i]); - if (existing) { - existing.push(i); - } else map.set(files[i], [i]); - } - - for (const [file, indices] of [...map.entries()]) { - const mapped = fetchMappings(file, signal); - if (mapped?.then) { - var resolvers = []; - for (let i = 0; i < indices.length; i++) { - results[indices[i]] = new Promise((resolve, reject) => { - resolvers[i] = res => resolve(res ? [res, i] : null); - }); - } - - mapped.finally(a => { - for (let resolve of resolvers) { - try { - resolve(a); - } catch { - } finally { - } - } - resolvers.length = 0; - resolvers = null; - }); - } else { - for (let i = 0; i < indices.length; i++) { - results[indices[i]] = mapped ? [mapped, indices[i]] : null; - } - } - } - - return results; -} - -function indexOfMapping(mappings: Int32Array, line: number, column: number) { - // the array is [generatedLine, generatedColumn, sourceIndex, sourceLine, sourceColumn, nameIndex] - // 0 - generated line - var count = mappings.length / 6; - var index = 0; - while (count > 0) { - var step = (count / 2) | 0; - var i = index + step; - // this multiply is slow but it's okay for now - var j = i * 6; - if (mappings[j] < line || (mappings[j] == line && mappings[j + 1] <= column)) { - index = i + 1; - count -= step + 1; - } else { - count = step; - } - } - - index = index | 0; - - if (index > 0) { - if (mappings[(index - 1) * 6] == line) { - return (index - 1) * 6; - } - } - - return null; -} diff --git a/packages/bun-error/stack-trace-parser.ts b/packages/bun-error/stack-trace-parser.ts deleted file mode 100644 index 10c1f3f18fdc..000000000000 --- a/packages/bun-error/stack-trace-parser.ts +++ /dev/null @@ -1,171 +0,0 @@ -const UNKNOWN_FUNCTION = ""; -import type { StackFrame } from "./schema"; - -/** - * This parses the different stack traces and puts them into one format - * This borrows heavily from TraceKit (https://github.com/csnover/TraceKit) - */ -export function parse(stackString): StackFrame[] { - const lines = stackString.split("\n"); - - return lines.reduce((stack, line) => { - const parseResult = parseChrome(line) || parseWinjs(line) || parseGecko(line) || parseNode(line) || parseJSC(line); - - if (parseResult) { - stack.push(parseResult); - } - - return stack; - }, []); -} - -const formatFile = file => { - if (!file) { - return ""; - } - - if (file.startsWith("blob:")) { - if (globalThis["__BUN"]?.client) { - const replacement = globalThis["__BUN"]?.client.dependencies.getFilePathFromBlob(file); - if (replacement) { - file = replacement; - } - } - } - - var _file = String(file); - if (_file.startsWith(globalThis.location?.origin)) { - _file = _file.substring(globalThis.location?.origin.length); - } - - while (_file.startsWith("/")) { - _file = _file.substring(1); - } - - if (_file.endsWith(".bun")) { - _file = "node_modules.bun"; - } - - return _file; -}; - -const chromeRe = - /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack||\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i; -const chromeEvalRe = /\((\S*)(?::(\d+))(?::(\d+))\)/; - -function parseChrome(line) { - const parts = chromeRe.exec(line); - - if (!parts) { - return null; - } - - const isNative = parts[2] && parts[2].indexOf("native") === 0; // start of line - const isEval = parts[2] && parts[2].indexOf("eval") === 0; // start of line - - const submatch = chromeEvalRe.exec(parts[2]); - if (isEval && submatch != null) { - // throw out eval line/column and use top-most line/column number - parts[2] = submatch[1]; // url - parts[3] = submatch[2]; // line - parts[4] = submatch[3]; // column - } - - return { - file: formatFile(!isNative ? parts[2] : null), - function_name: parts[1] || "", - position: { - line: parts[3] ? +parts[3] : null, - column_start: parts[4] ? +parts[4] : null, - }, - }; -} - -const winjsRe = - /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i; - -function parseWinjs(line) { - const parts = winjsRe.exec(line); - - if (!parts) { - return null; - } - - return { - file: formatFile(parts[2]), - function_name: parts[1], - position: { - line: +parts[3], - column_start: parts[4] ? +parts[4] : null, - }, - }; -} - -const geckoRe = - /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i; -const geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i; - -function parseGecko(line) { - const parts = geckoRe.exec(line); - - if (!parts) { - return null; - } - - const isEval = parts[3] && parts[3].indexOf(" > eval") > -1; - - const submatch = geckoEvalRe.exec(parts[3]); - if (isEval && submatch != null) { - // throw out eval line/column and use top-most line number - parts[3] = submatch[1]; - parts[4] = submatch[2]; - parts[5] = null; // no column when eval - } - - return { - file: formatFile(parts[3]), - function_name: parts[1] || "", - position: { - line: parts[4] ? +parts[4] : null, - column_start: parts[5] ? +parts[5] : null, - }, - }; -} - -const javaScriptCoreRe = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i; - -function parseJSC(line) { - const parts = javaScriptCoreRe.exec(line); - - if (!parts) { - return null; - } - - return { - file: formatFile(parts[3]), - function_name: parts[1] || "", - position: { - line: +parts[4], - column_start: parts[5] ? +parts[5] : null, - }, - }; -} - -const nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i; - -function parseNode(line) { - const parts = nodeRe.exec(line); - - if (!parts) { - return null; - } - - return { - file: formatFile(parts[2]), - function_name: parts[1] || "", - position: { - line: +parts[3], - column_start: parts[4] ? +parts[4] : null, - }, - }; -} diff --git a/src/bun_alloc/lib.rs b/src/bun_alloc/lib.rs index e9ed8e3690b1..fa01c50798fa 100644 --- a/src/bun_alloc/lib.rs +++ b/src/bun_alloc/lib.rs @@ -241,16 +241,6 @@ pub mod default_alloc { } } - #[inline] - pub fn calloc(count: usize, size: usize) -> *mut c_void { - if cfg!(bun_asan) { - // SAFETY: `libc::calloc` has no input preconditions; null on failure. - unsafe { libc::calloc(count, size) } - } else { - crate::mimalloc::mi_calloc(count, size) - } - } - /// # Safety /// `ptr` must be null or a live allocation from the default allocator. #[inline] diff --git a/src/bun_core/Global.rs b/src/bun_core/Global.rs index 56a912aec7f0..4f8188831515 100644 --- a/src/bun_core/Global.rs +++ b/src/bun_core/Global.rs @@ -328,7 +328,7 @@ impl SignalCode { #[cfg(not(unix))] { // Windows numbering: CRT plus libuv's synthetic SIGHUP/SIGQUIT/SIGKILL/ - // SIGWINCH (src/jsc/bindings/libuv/uv/win.h). The enum discriminants are Linux numbers + // SIGWINCH (vendor/libuv/include/uv/win.h). The enum discriminants are Linux numbers // and must not leak here (SIGABRT is 22 on Windows, not 6). use SignalCode as S; match self { diff --git a/src/bun_core/util.rs b/src/bun_core/util.rs index 8a599cc75379..9770faffcff3 100644 --- a/src/bun_core/util.rs +++ b/src/bun_core/util.rs @@ -3392,16 +3392,11 @@ impl GenericIndexOptional { pub trait GenericIndexInt: Copy + Eq + PartialOrd { const NULL_VALUE: Self; fn to_usize(self) -> usize; - fn from_usize(n: usize) -> Self; } macro_rules! generic_index_int { ($($t:ty),*) => { $( impl GenericIndexInt for $t { const NULL_VALUE: Self = <$t>::MAX; #[inline] fn to_usize(self) -> usize { self as usize } - #[inline] fn from_usize(n: usize) -> Self { - debug_assert!(n as u128 <= <$t>::MAX as u128, "GenericIndex::from_usize: truncation"); - n as Self - } } )* } } generic_index_int!(u8, u16, u32, u64, usize, i32, i64); diff --git a/src/cares_sys/c_ares.rs b/src/cares_sys/c_ares.rs index 09e53da5fee0..6637ed6eefdc 100644 --- a/src/cares_sys/c_ares.rs +++ b/src/cares_sys/c_ares.rs @@ -1524,7 +1524,6 @@ unsafe extern "C" { ) -> c_int; pub fn ares_free_hostent(host: *mut struct_hostent); pub fn ares_free_data(dataptr: *mut c_void); - pub safe fn ares_strerror(code: c_int) -> *const u8; } #[repr(C)] diff --git a/src/css/selectors/parser.rs b/src/css/selectors/parser.rs index 144ffcded494..25a28e298145 100644 --- a/src/css/selectors/parser.rs +++ b/src/css/selectors/parser.rs @@ -1621,13 +1621,6 @@ impl GenericSelectorList { true } - /// Do not call this! Use `serializer::serialize_selector_list()` or - /// `tocss_servo::to_css_selector_list()` instead. - #[deprecated = "use serializer::serialize_selector_list()"] - pub fn to_css(&self, _dest: &mut Printer) -> Result<(), PrintErr> { - unreachable!("use serializer::serialize_selector_list()"); - } - pub fn parse( parser: &mut SelectorParser, input: &mut CssParser, @@ -1818,13 +1811,6 @@ impl GenericSelector { parse_selector::(parser, input, &mut state, NestingRequirement::None) } - /// Do not call this! Use `serializer::serialize_selector()` or - /// `tocss_servo::to_css_selector()` instead. - #[deprecated = "use serializer::serialize_selector()"] - pub fn to_css(&self, _dest: &mut Printer) -> Result<(), PrintErr> { - unreachable!("use serializer::serialize_selector()"); - } - pub(crate) fn append(&mut self, component: GenericComponent) { let index = 'index: { for (i, comp) in self.components.iter().enumerate() { @@ -2274,13 +2260,6 @@ impl GenericComponent { matches!(self, Self::Combinator(_)) } - /// Do not call this! Use `serializer::serialize_component()` or - /// `tocss_servo::to_css_component()` instead. - #[deprecated = "use serializer::serialize_component()"] - pub fn to_css(&self, _dest: &mut Printer) -> Result<(), PrintErr> { - unreachable!("use serializer::serialize_component()"); - } - pub(crate) fn hash(&self, hasher: &mut Wyhash) { use GenericComponent as C; // Hash a variant tag, then the payload. @@ -2810,13 +2789,6 @@ pub enum Combinator { impl Combinator { // hash — via `#[derive(CssHash)]`. - /// Do not call this! Use `serializer::serialize_combinator()` or - /// `tocss_servo::to_css_combinator()` instead. - #[deprecated = "use serializer::serialize_combinator()"] - pub fn to_css(self, _dest: &mut Printer) -> Result<(), PrintErr> { - unreachable!("use serializer::serialize_combinator()"); - } - pub(crate) fn is_tree_combinator(self) -> bool { matches!( self, diff --git a/src/jsc/bindings/libuv/uv.h b/src/jsc/bindings/libuv/uv.h index 9eac5685a577..3c3076397dfa 100644 --- a/src/jsc/bindings/libuv/uv.h +++ b/src/jsc/bindings/libuv/uv.h @@ -66,11 +66,8 @@ struct uv__queue { struct uv__queue* prev; }; -#if defined(_WIN32) -#include "uv/win.h" -#else +/* This directory is only on the include path for non-Windows builds; Windows links the real libuv. */ #include "uv/unix.h" -#endif /* Expand this list if necessary. */ #define UV_ERRNO_MAP(XX) \ diff --git a/src/jsc/bindings/libuv/uv/aix.h b/src/jsc/bindings/libuv/uv/aix.h deleted file mode 100644 index 5a5c4cc67e16..000000000000 --- a/src/jsc/bindings/libuv/uv/aix.h +++ /dev/null @@ -1,32 +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_AIX_H -#define UV_AIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - int fs_fd; - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char* dir_filename; - -#endif /* UV_AIX_H */ diff --git a/src/jsc/bindings/libuv/uv/os390.h b/src/jsc/bindings/libuv/uv/os390.h deleted file mode 100644 index c68b71cf20c3..000000000000 --- a/src/jsc/bindings/libuv/uv/os390.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright libuv project 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_MVS_H -#define UV_MVS_H - -#define UV_PLATFORM_SEM_T long - -#define UV_PLATFORM_LOOP_FIELDS \ - void* ep; - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - char rfis_rftok[8]; - -#endif /* UV_MVS_H */ diff --git a/src/jsc/bindings/libuv/uv/posix.h b/src/jsc/bindings/libuv/uv/posix.h deleted file mode 100644 index 8c75a3514636..000000000000 --- a/src/jsc/bindings/libuv/uv/posix.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright libuv project 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_POSIX_H -#define UV_POSIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - struct pollfd* poll_fds; \ - size_t poll_fds_used; \ - size_t poll_fds_size; \ - unsigned char poll_fds_iterating; - -#endif /* UV_POSIX_H */ diff --git a/src/jsc/bindings/libuv/uv/sunos.h b/src/jsc/bindings/libuv/uv/sunos.h deleted file mode 100644 index 3842047c509d..000000000000 --- a/src/jsc/bindings/libuv/uv/sunos.h +++ /dev/null @@ -1,44 +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_SUNOS_H -#define UV_SUNOS_H - -#include -#include - -/* For the sake of convenience and reduced #ifdef-ery in src/unix/sunos.c, - * add the fs_event fields even when this version of SunOS doesn't support - * file watching. - */ -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t fs_event_watcher; \ - int fs_fd; - -#if defined(PORT_SOURCE_FILE) - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - file_obj_t fo; \ - int fd; - -#endif /* defined(PORT_SOURCE_FILE) */ - -#endif /* UV_SUNOS_H */ diff --git a/src/jsc/bindings/libuv/uv/tree.h b/src/jsc/bindings/libuv/uv/tree.h deleted file mode 100644 index 4581f90245aa..000000000000 --- a/src/jsc/bindings/libuv/uv/tree.h +++ /dev/null @@ -1,512 +0,0 @@ -/*- - * Copyright 2002 Niels Provos - * 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_ */ diff --git a/src/jsc/bindings/libuv/uv/unix.h b/src/jsc/bindings/libuv/uv/unix.h index 3dad451d13a3..4c6de8c35a5e 100644 --- a/src/jsc/bindings/libuv/uv/unix.h +++ b/src/jsc/bindings/libuv/uv/unix.h @@ -47,20 +47,10 @@ #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 diff --git a/src/jsc/bindings/libuv/uv/win.h b/src/jsc/bindings/libuv/uv/win.h deleted file mode 100644 index 629b758cbb43..000000000000 --- a/src/jsc/bindings/libuv/uv/win.h +++ /dev/null @@ -1,703 +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 - -#ifndef LOCALE_INVARIANT -#define LOCALE_INVARIANT 0x007f -#endif - -#include -/* 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 -#undef _TCP_INITIAL_RTO_PARAMETERS -#undef TCP_INITIAL_RTO_PARAMETERS -#undef PTCP_INITIAL_RTO_PARAMETERS -#include - -#include -#include -#include -#include -#include - -#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 */ diff --git a/src/jsc/bindings/uv-posix-polyfills.c b/src/jsc/bindings/uv-posix-polyfills.c index 3eea2489c1bf..19ae7e5040c8 100644 --- a/src/jsc/bindings/uv-posix-polyfills.c +++ b/src/jsc/bindings/uv-posix-polyfills.c @@ -25,14 +25,6 @@ uint64_t uv__hrtime(uv_clocktype_t type); #if defined(__linux__) #include "uv-posix-polyfills-linux.c" -// #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-posix-polyfills-darwin.c" #elif defined(__FreeBSD__) diff --git a/src/libdeflate_sys/libdeflate.rs b/src/libdeflate_sys/libdeflate.rs index b29a1aca0ed0..f9016455c44b 100644 --- a/src/libdeflate_sys/libdeflate.rs +++ b/src/libdeflate_sys/libdeflate.rs @@ -530,14 +530,6 @@ pub enum Status { } unsafe extern "C" { - pub fn libdeflate_deflate_decompress( - decompressor: *mut Decompressor, - in_: *const c_void, - in_nbytes: usize, - out: *mut c_void, - out_nbytes_avail: usize, - actual_out_nbytes_ret: *mut usize, - ) -> Status; pub(crate) fn libdeflate_deflate_decompress_ex( decompressor: *mut Decompressor, in_: *const c_void, diff --git a/src/mimalloc_sys/mimalloc.rs b/src/mimalloc_sys/mimalloc.rs index ad11e0e8536b..4ba35c9df577 100644 --- a/src/mimalloc_sys/mimalloc.rs +++ b/src/mimalloc_sys/mimalloc.rs @@ -14,7 +14,6 @@ unsafe extern "C" { pub fn mi_realloc(p: *mut c_void, newsize: usize) -> *mut c_void; pub fn mi_expand(p: *mut c_void, newsize: usize) -> *mut c_void; pub fn mi_free(p: *mut c_void); - pub fn mi_strdup(s: *const c_char) -> *mut c_char; /// No preconditions; returns null on failure. pub safe fn mi_zalloc(size: usize) -> *mut c_void; pub fn mi_usable_size(p: *const c_void) -> usize; @@ -81,7 +80,6 @@ unsafe extern "C" { pub fn mi_heap_new() -> *mut Heap; pub fn mi_heap_destroy(heap: *mut Heap); pub fn mi_heap_main() -> *mut Heap; - pub fn mi_heap_collect(heap: *mut Heap, force: bool); pub fn mi_heap_malloc(heap: *mut Heap, size: usize) -> *mut c_void; fn mi_heap_zalloc(heap: *mut Heap, size: usize) -> *mut c_void; fn mi_heap_calloc(heap: *mut Heap, count: usize, size: usize) -> *mut c_void; @@ -121,10 +119,6 @@ unsafe extern "C" { pub fn mi_is_in_heap_region(p: *const c_void) -> bool; } -unsafe extern "C" { - pub fn mi_thread_set_in_threadpool(); -} - // Named `Option` after mimalloc's `mi_option_t`; shadows `core::option::Option` in // this module (callers use `mimalloc::Option`). `enum(c_uint)` → `#[repr(u32)]` // (c_uint == u32 on all Bun targets; `#[repr(C)]` would give a signed c_int discriminant). diff --git a/src/runtime/api/html_rewriter.rs b/src/runtime/api/html_rewriter.rs index ff04a664bfc4..10b4ff0eca4f 100644 --- a/src/runtime/api/html_rewriter.rs +++ b/src/runtime/api/html_rewriter.rs @@ -1946,9 +1946,6 @@ impl crate::webcore::sink::JsSinkType for RewriterPipe { fn source(&mut self) -> Option<&mut SourceHandle> { Some(self.input_source.get_mut()) } - fn done(&self) -> bool { - self.done.get() - } } // ───────── .then() reactions for a content handler's promise ───────────── diff --git a/src/runtime/node/node_fs.rs b/src/runtime/node/node_fs.rs index 7dc9e2b47601..660b8b390a69 100644 --- a/src/runtime/node/node_fs.rs +++ b/src/runtime/node/node_fs.rs @@ -4432,11 +4432,6 @@ impl StringOrUndefined { /// For use in `Return`'s definitions to act as `void` while returning `null` to JavaScript pub struct Null; -impl Null { - pub fn to_js(&self, _: &JSGlobalObject) -> JSValue { - JSValue::NULL - } -} pub mod ret { use super::*; diff --git a/src/runtime/webcore/ArrayBufferSink.rs b/src/runtime/webcore/ArrayBufferSink.rs index 9038094fa05b..84be5c468128 100644 --- a/src/runtime/webcore/ArrayBufferSink.rs +++ b/src/runtime/webcore/ArrayBufferSink.rs @@ -190,7 +190,4 @@ impl crate::webcore::sink::JsSinkType for ArrayBufferSink { fn source(&mut self) -> Option<&mut SourceHandle> { Some(&mut self.source) } - fn done(&self) -> bool { - self.done - } } diff --git a/src/runtime/webcore/Blob.rs b/src/runtime/webcore/Blob.rs index 6c89abc05d2d..622da246eb03 100644 --- a/src/runtime/webcore/Blob.rs +++ b/src/runtime/webcore/Blob.rs @@ -7032,7 +7032,6 @@ pub trait FileCloser: Sized { fn io_request(&mut self) -> Option<&mut bun_io::Request>; fn io_poll(&mut self) -> &mut bun_io::Poll; fn task(&mut self) -> &mut bun_jsc::WorkPoolTask; - fn update(&mut self); #[cfg(windows)] fn loop_(&self) -> *mut bun_libuv_sys::uv_loop_t; @@ -7131,9 +7130,6 @@ macro_rules! impl_file_closer { fn task(&mut self) -> &mut ::bun_jsc::WorkPoolTask { &mut self.task } - fn update(&mut self) { - $T::update(self) - } #[cfg(windows)] fn loop_(&self) -> *mut ::bun_libuv_sys::uv_loop_t { unreachable!() diff --git a/src/runtime/webcore/FileSink.rs b/src/runtime/webcore/FileSink.rs index 3fa4d7e5a249..40535e341370 100644 --- a/src/runtime/webcore/FileSink.rs +++ b/src/runtime/webcore/FileSink.rs @@ -1313,9 +1313,6 @@ impl crate::webcore::sink::JsSinkType for FileSink { // SAFETY: JsCell — trait receiver is `&mut self`; sole borrow of `source`. Some(unsafe { self.source.get_mut() }) } - fn done(&self) -> bool { - self.done.get() - } fn pending_state_is_pending(&self) -> bool { self.pending.get().state == streams::PendingState::Pending } diff --git a/src/runtime/webcore/ReadableStream.rs b/src/runtime/webcore/ReadableStream.rs index 576c986be614..01cb35763bc9 100644 --- a/src/runtime/webcore/ReadableStream.rs +++ b/src/runtime/webcore/ReadableStream.rs @@ -180,10 +180,6 @@ impl ReadableStream { Ok(Some((out_stream1, out_stream2))) } - pub fn to_js(&self) -> JSValue { - self.value - } - /// Re-read this stream's tag (its native source may have changed hands). Pure, like `from_js_direct`. pub fn reload_tag(&mut self) { *self = ReadableStream::from_js_direct(self.value).unwrap_or(ReadableStream { diff --git a/src/runtime/webcore/Sink.rs b/src/runtime/webcore/Sink.rs index 210b6b987d9a..81dc1634ae3e 100644 --- a/src/runtime/webcore/Sink.rs +++ b/src/runtime/webcore/Sink.rs @@ -115,7 +115,7 @@ macro_rules! impl_js_sink_abi { /// Invoke inside the `impl JsSinkType for T` block; `Self::name` resolves to /// the inherent method ahead of the trait item being defined, so the forward /// does not recurse. Items whose bodies differ per sink (`finalize`, -/// `construct`, `end_from_js`, `source`, `done`, the `HAS_*` consts) stay +/// `construct`, `end_from_js`, `source`, the `HAS_*` consts) stay /// hand-written. #[macro_export] macro_rules! impl_js_sink_forwarders { @@ -333,9 +333,6 @@ pub trait JsSinkType: Sized + JsSinkAbi { /// `&mut Self` and the C++ dispatcher keeps using `m_sinkPtr` in the /// same frame; defer a last-owner free to the event loop. fn controller_detached(&mut self) {} - fn done(&self) -> bool { - false - } fn flush_from_js(&mut self, _global: &JSGlobalObject, _wait: bool) -> sys::Result { // Guarded by `HAS_FLUSH_FROM_JS`; default impl delegates to `flush()` // (returning undefined on success) so buffered bytes are diff --git a/src/runtime/webcore/blob/read_file.rs b/src/runtime/webcore/blob/read_file.rs index 5428f04d2cb8..086a3680d370 100644 --- a/src/runtime/webcore/blob/read_file.rs +++ b/src/runtime/webcore/blob/read_file.rs @@ -1019,9 +1019,6 @@ impl<'a> FileCloser for ReadFileUV<'a> { fn task(&mut self) -> &mut bun_jsc::WorkPoolTask { unreachable!("@hasField(ReadFileUV, \"io_request\") == false") } - fn update(&mut self) { - unreachable!("@hasField(ReadFileUV, \"io_request\") == false") - } fn schedule_close(_: &mut bun_io::Request) -> bun_io::Action<'_> { unreachable!("@hasField(ReadFileUV, \"io_request\") == false") } diff --git a/src/runtime/webcore/fetch/FetchRequestBodySink.rs b/src/runtime/webcore/fetch/FetchRequestBodySink.rs index 9f738a5ddd5c..e020564c83ab 100644 --- a/src/runtime/webcore/fetch/FetchRequestBodySink.rs +++ b/src/runtime/webcore/fetch/FetchRequestBodySink.rs @@ -294,7 +294,4 @@ impl crate::webcore::sink::JsSinkType for FetchRequestBodySink { fn source(&mut self) -> Option<&mut SourceHandle> { Some(&mut self.source) } - fn done(&self) -> bool { - self.done - } } diff --git a/src/runtime/webcore/streams.rs b/src/runtime/webcore/streams.rs index 8e43c642b2d2..6eb8eb9dddfd 100644 --- a/src/runtime/webcore/streams.rs +++ b/src/runtime/webcore/streams.rs @@ -2133,9 +2133,6 @@ impl crate::webcore::sink::JsSinkType fn source(&mut self) -> Option<&mut SourceHandle> { Some(&mut self.source) } - fn done(&self) -> bool { - self.is_done() - } } pub type HTTPSResponseSink = HTTPServerWritable; @@ -2547,9 +2544,6 @@ impl crate::webcore::sink::JsSinkType for NetworkSink { fn source(&mut self) -> Option<&mut SourceHandle> { Some(&mut self.source) } - fn done(&self) -> bool { - self.done - } } pub(crate) type NetworkSinkJSSink = crate::webcore::sink::JSSink; diff --git a/src/windows_sys/externs.rs b/src/windows_sys/externs.rs index 12c338e581f2..bcebb23f18a2 100644 --- a/src/windows_sys/externs.rs +++ b/src/windows_sys/externs.rs @@ -890,10 +890,6 @@ pub mod kernel32 { lpLastAccessTime: *const FILETIME, lpLastWriteTime: *const FILETIME, ) -> BOOL; - /// `SetHandleInformation` (`handleapi.h`). No pointer preconditions: - /// `hObject` is an opaque kernel handle (validated kernel-side; bad - /// handle → `FALSE` + `GetLastError`), `dwMask`/`dwFlags` are by-value. - pub safe fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) -> BOOL; /// `CreateProcessW` (`processthreadsapi.h`). pub fn CreateProcessW( lpApplicationName: LPCWSTR, @@ -1168,7 +1164,6 @@ pub mod ws2_32 { pub safe fn WSAGetLastError() -> c_int; /// No preconditions; writes the thread-local Winsock error slot. pub safe fn WSASetLastError(err: c_int); - pub fn closesocket(s: usize) -> c_int; pub fn recv(s: usize, buf: *mut c_void, len: c_int, flags: c_int) -> c_int; pub fn send(s: usize, buf: *const c_void, len: c_int, flags: c_int) -> c_int; /// `WSAPoll` (`winsock2.h`). Returns count of ready fds, 0 on timeout, diff --git a/src/zlib/lib.rs b/src/zlib/lib.rs index 333d8c9f37e6..63377d3f2be1 100644 --- a/src/zlib/lib.rs +++ b/src/zlib/lib.rs @@ -13,12 +13,6 @@ pub const MAX_WBITS: c_int = 15; unsafe extern "C" { pub safe fn zlibVersion() -> *const c_char; - pub fn compress( - dest: *mut Bytef, - dest_len: *mut uLongf, - source: *const Bytef, - source_len: uLong, - ) -> c_int; pub fn compress2( dest: *mut Bytef, dest_len: *mut uLongf, @@ -26,13 +20,6 @@ unsafe extern "C" { source_len: uLong, level: c_int, ) -> c_int; - pub safe fn compressBound(source_len: uLong) -> uLong; - pub fn uncompress( - dest: *mut Bytef, - dest_len: *mut uLongf, - source: *const Bytef, - source_len: uLong, - ) -> c_int; } pub use bun_zlib_sys::shared::{Bytef, uInt, uLong, uLongf}; @@ -40,8 +27,7 @@ pub use bun_zlib_sys::shared::{Bytef, uInt, uLong, uLongf}; // typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); // typedef void (*free_func) OF((voidpf opaque, voidpf address)); -pub use crate::internal::z_stream; -pub use crate::internal::z_streamp; +pub use bun_zlib_sys::shared::{z_stream, z_streamp}; // typedef struct z_stream_s { // z_const Bytef *next_in; /* next input byte */ @@ -65,10 +51,9 @@ pub use crate::internal::z_streamp; // uLong reserved; /* reserved for future use */ // } z_stream; -pub use crate::internal::FlushValue; -pub use crate::internal::ReturnCode; +pub use bun_zlib_sys::shared::{FlushValue, ReturnCode}; -use crate::internal::{DataType, zStream_struct}; +use bun_zlib_sys::shared::{DataType, zStream_struct}; // ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); @@ -1184,15 +1169,3 @@ fn step( let consumed = in_len - strm.avail_in as usize; (consumed, rc) } - -// Re-export from bun_zlib_sys, platform-selected. -mod internal { - #[cfg(not(windows))] - pub(super) use bun_zlib_sys::posix::{DataType, zStream_struct}; - #[cfg(not(windows))] - pub use bun_zlib_sys::posix::{FlushValue, ReturnCode, z_stream, z_streamp}; - #[cfg(windows)] - pub(super) use bun_zlib_sys::win32::{DataType, zStream_struct}; - #[cfg(windows)] - pub use bun_zlib_sys::win32::{FlushValue, ReturnCode, z_stream, z_streamp}; -} diff --git a/src/zlib_sys/lib.rs b/src/zlib_sys/lib.rs index 1ef905b360e6..bf0de1783cae 100644 --- a/src/zlib_sys/lib.rs +++ b/src/zlib_sys/lib.rs @@ -1,5 +1,3 @@ #![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] #![warn(unused_must_use)] -pub mod posix; pub mod shared; -pub mod win32; diff --git a/src/zlib_sys/posix.rs b/src/zlib_sys/posix.rs deleted file mode 100644 index d1199c0d6891..000000000000 --- a/src/zlib_sys/posix.rs +++ /dev/null @@ -1,33 +0,0 @@ -#![allow(non_camel_case_types, non_snake_case)] - -use core::ffi::{c_char, c_int}; - -pub use crate::shared::{DataType, FlushValue, ReturnCode, z_stream, z_streamp, zStream_struct}; - -unsafe extern "C" { - pub safe fn zlibVersion() -> *const c_char; - - pub fn deflateInit2_( - strm: z_streamp, - level: c_int, - method: c_int, - windowBits: c_int, - memLevel: c_int, - strategy: c_int, - version: *const c_char, - stream_size: c_int, - ) -> ReturnCode; - pub fn inflateInit2_( - strm: z_streamp, - windowBits: c_int, - version: *const c_char, - stream_size: c_int, - ) -> ReturnCode; - pub fn inflateBackInit_( - strm: z_streamp, - windowBits: c_int, - window: *mut u8, - version: *const c_char, - stream_size: c_int, - ) -> ReturnCode; -} diff --git a/src/zlib_sys/shared.rs b/src/zlib_sys/shared.rs index 89f1246e919b..cc50de88ced3 100644 --- a/src/zlib_sys/shared.rs +++ b/src/zlib_sys/shared.rs @@ -64,11 +64,7 @@ pub enum FlushValue { // // zlib (and zlib-ng compat) typedef `uLong` as `unsigned long`, so one // `c_ulong`-based definition is ABI-correct on LP64 (8-byte) *and* LLP64 -// (4-byte) targets. The two per-platform copies in posix.rs / win32.rs were -// already field-for-field identical; win32.rs had even normalized its -// `struct_internal_state` to match posix so rustc's -// `clashing_extern_declarations` lint saw the extern fns as compatible. This -// hoist makes that the actual single definition. +// (4-byte) targets. // --------------------------------------------------------------------------- use core::ffi::{c_char, c_uint, c_ulong, c_void}; @@ -80,7 +76,6 @@ pub type free_func = Option; // --------------------------------------------------------------------------- // zconf.h scalar typedefs — single source of truth. // -// Previously duplicated in win32.rs and bun_zlib::lib.rs. // All resolve to ABI-identical primitives on every // target Bun ships; `uLong` = `unsigned long` (4B on LLP64 Windows, 8B on LP64 // Unix) for the same reason zStream_struct above uses `c_ulong` directly. @@ -89,7 +84,6 @@ pub type Bytef = u8; pub type uInt = c_uint; pub type uLong = c_ulong; pub type uLongf = uLong; -pub type voidpf = *mut c_void; /// zlib's opaque `struct internal_state { int dummy; }` stub — applications /// never look inside, only carry the pointer. diff --git a/src/zlib_sys/win32.rs b/src/zlib_sys/win32.rs deleted file mode 100644 index 6d896df06f4a..000000000000 --- a/src/zlib_sys/win32.rs +++ /dev/null @@ -1,111 +0,0 @@ -#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)] - -use core::ffi::{c_char, c_int, c_uint, c_void}; - -pub use crate::shared::{ - Bytef, DataType, FlushValue, ReturnCode, uInt, uLong, uLongf, z_stream, z_streamp, - zStream_struct, -}; - -#[repr(C)] -pub struct struct_gz_header_s { - pub text: c_int, - pub time: uLong, - pub xflags: c_int, - pub os: c_int, - pub extra: *mut Bytef, - pub extra_len: uInt, - pub extra_max: uInt, - pub name: *mut Bytef, - pub name_max: uInt, - pub comment: *mut Bytef, - pub comm_max: uInt, - pub hcrc: c_int, - pub done: c_int, -} -pub(crate) type gz_header = struct_gz_header_s; -pub(crate) type gz_headerp = *mut gz_header; - -pub(crate) type in_func = Option c_uint>; -pub(crate) type out_func = Option ReturnCode>; - -unsafe extern "C" { - pub safe fn zlibVersion() -> *const c_char; - pub fn deflate(strm: z_streamp, flush: FlushValue) -> ReturnCode; - pub fn deflateEnd(strm: z_streamp) -> ReturnCode; - pub fn inflate(strm: z_streamp, flush: FlushValue) -> ReturnCode; - pub fn inflateEnd(strm: z_streamp) -> ReturnCode; - pub fn deflateSetDictionary( - strm: z_streamp, - dictionary: *const Bytef, - dictLength: uInt, - ) -> ReturnCode; - pub fn deflateReset(strm: z_streamp) -> ReturnCode; - pub fn deflateParams(strm: z_streamp, level: c_int, strategy: c_int) -> ReturnCode; - pub fn deflateBound(strm: z_streamp, sourceLen: uLong) -> uLong; - pub fn deflateSetHeader(strm: z_streamp, head: gz_headerp) -> ReturnCode; - pub fn inflateSetDictionary( - strm: z_streamp, - dictionary: *const Bytef, - dictLength: uInt, - ) -> ReturnCode; - pub fn inflateSync(strm: z_streamp) -> ReturnCode; - pub fn inflateReset(strm: z_streamp) -> ReturnCode; - pub fn inflateReset2(strm: z_streamp, windowBits: c_int) -> ReturnCode; - pub fn inflateGetHeader(strm: z_streamp, head: gz_headerp) -> ReturnCode; - pub fn inflateBack( - strm: z_streamp, - in_: in_func, - in_desc: *mut c_void, - out: out_func, - out_desc: *mut c_void, - ) -> ReturnCode; - pub fn compress( - dest: *mut Bytef, - destLen: *mut uLongf, - source: *const Bytef, - sourceLen: uLong, - ) -> ReturnCode; - pub fn compress2( - dest: *mut Bytef, - destLen: *mut uLongf, - source: *const Bytef, - sourceLen: uLong, - level: c_int, - ) -> ReturnCode; - pub safe fn compressBound(sourceLen: uLong) -> uLong; - pub fn uncompress( - dest: *mut Bytef, - destLen: *mut uLongf, - source: *const Bytef, - sourceLen: uLong, - ) -> ReturnCode; - pub fn adler32(adler: uLong, buf: *const Bytef, len: uInt) -> uLong; - pub fn crc32(crc: uLong, buf: *const Bytef, len: uInt) -> uLong; - pub fn deflateInit2_( - strm: z_streamp, - level: c_int, - method: c_int, - windowBits: c_int, - memLevel: c_int, - strategy: c_int, - version: *const c_char, - stream_size: c_int, - ) -> ReturnCode; - pub fn inflateInit2_( - strm: z_streamp, - windowBits: c_int, - version: *const c_char, - stream_size: c_int, - ) -> ReturnCode; - pub fn inflateBackInit_( - strm: z_streamp, - windowBits: c_int, - window: *mut u8, - version: *const c_char, - stream_size: c_int, - ) -> ReturnCode; - // pub fn get_crc_table() -> *const z_crc_t; - pub fn inflateResetKeep(strm: z_streamp) -> ReturnCode; - pub fn deflateResetKeep(strm: z_streamp) -> ReturnCode; -} diff --git a/src/zstd/lib.rs b/src/zstd/lib.rs index 5988681f7c7b..112edd3f54be 100644 --- a/src/zstd/lib.rs +++ b/src/zstd/lib.rs @@ -278,32 +278,7 @@ pub fn is_error(code: usize) -> bool { c::ZSTD_isError(code) != 0 } -/// ZSTD_decompress() : -/// `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames. -/// `dstCapacity` is an upper bound of originalSize to regenerate. -/// If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data. -/// @return : the number of bytes decompressed into `dst` (<= `dstCapacity`), -/// or an errorCode if it fails (which can be tested using ZSTD_isError()). */ -// ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity, -// const void* src, size_t compressedSize); -pub fn decompress(dest: &mut [u8], src: &[u8]) -> Result { - // SAFETY: dest/src are valid for their lengths; ZSTD_decompress reads src and writes dest. - let result = unsafe { - c::ZSTD_decompress( - dest.as_mut_ptr().cast::(), - dest.len(), - src.as_ptr().cast::(), - src.len(), - ) - }; - if c::ZSTD_isError(result) != 0 { - // SAFETY: ZSTD_getErrorName returns a static NUL-terminated string. - return Result::Err(unsafe { ZStr::from_c_ptr(c::ZSTD_getErrorName(result)) }); - } - Result::Success(result) -} - -/// [`decompress`] into `out`'s spare capacity, which is the output bound; commits the bytes written. +/// `ZSTD_decompress` into `out`'s spare capacity, which is the output bound; commits the bytes written. fn decompress_append(out: &mut Vec, src: &[u8]) -> core::result::Result<(), ZstdError> { let spare = out.spare_capacity_mut(); // SAFETY: spare/src are valid for their lengths; ZSTD_decompress reads src diff --git a/test/js/bun/http/serve.test.ts b/test/js/bun/http/serve.test.ts index 921da43653d4..83ed8ab21198 100644 --- a/test/js/bun/http/serve.test.ts +++ b/test/js/bun/http/serve.test.ts @@ -2100,6 +2100,85 @@ it.concurrent("dev error page embeds the thrown error, its stack, and build/reso expect(exitCode).toBe(0); }); +it.concurrent("dev error page ships a bun-error bundle that evaluates and registers the renderer", async () => { + using dir = tempDir("serve-dev-error-page-bundle", { + "server.ts": ` + const server = Bun.serve({ + port: 0, + hostname: "127.0.0.1", + development: true, + fetch() { + throw new Error("bundle-test boom"); + }, + }); + const html = await (await fetch(server.url)).text(); + // dev-error-page.html inlines one module script: two lines that move the JSON payload out of the + // document, then the packages/bun-error bundle, then the call into the function the bundle registers. + const lines = /