Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions src/brotli_sys/brotli_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ unsafe extern "C" {
) -> BrotliDecoderResult;
// Query fns: opaque handle by reference + scalars only — `BrotliDecoder` is
// `!Freeze` (UnsafeCell) so internal C mutation through `&` is sound.
safe fn BrotliDecoderIsFinished(state: &BrotliDecoder) -> c_int;
pub safe fn BrotliDecoderGetErrorCode(state: &BrotliDecoder) -> BrotliDecoderErrorCode2;
pub safe fn BrotliDecoderErrorString(c: BrotliDecoderErrorCode) -> *const c_char;
safe fn BrotliDecoderVersion() -> u32;
}

bun_opaque::opaque_ffi! {
Expand Down Expand Up @@ -108,18 +106,6 @@ impl BrotliDecoder {
}
}

pub fn is_finished(state: &BrotliDecoder) -> bool {
BrotliDecoderIsFinished(state) != 0
}

pub fn get_error_code(state: &BrotliDecoder) -> BrotliDecoderErrorCode {
BrotliDecoderGetErrorCode(state)
}

pub fn version() -> u32 {
BrotliDecoderVersion()
}

pub fn initialize_brotli() -> bool {
true
}
Expand Down
110 changes: 3 additions & 107 deletions src/cares_sys/c_ares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@

#[cfg(windows)]
use core::ffi::c_short;
use core::ffi::{c_char, c_int, c_long, c_uint, c_ushort, c_void};
use core::ffi::{c_char, c_int, c_uint, c_ushort, c_void};
use core::ptr;

#[cfg(windows)]
use crate::winsock::{iovec, sockaddr, sockaddr_in, sockaddr_in6, socklen_t, timeval};
use crate::winsock::{sockaddr, sockaddr_in, sockaddr_in6, socklen_t};
#[cfg(not(windows))]
use libc::{iovec, sockaddr, sockaddr_in, sockaddr_in6, socklen_t, timeval};
use libc::{sockaddr, sockaddr_in, sockaddr_in6, socklen_t};

pub type ares_socklen_t = socklen_t;
type ares_ssize_t = isize;

#[cfg(windows)]
pub type ares_socket_t = usize; // Windows `SOCKET` is `UINT_PTR` (integer, not a pointer).
Expand Down Expand Up @@ -580,8 +579,6 @@ impl struct_nameinfo {
}
}

pub(crate) type struct_timeval = timeval;

bun_opaque::opaque_ffi! { pub struct struct_Channeldata; }

#[repr(C)]
Expand Down Expand Up @@ -989,15 +986,12 @@ pub(crate) type ares_addrinfo_callback =
unsafe extern "C" fn(*mut c_void, c_int, c_int, *mut AddrInfo);

unsafe extern "C" {
pub fn ares_library_init(flags: c_int) -> c_int;
fn ares_library_init_mem(
flags: c_int,
amalloc: Option<unsafe extern "C" fn(usize) -> *mut c_void>,
afree: Option<unsafe extern "C" fn(*mut c_void)>,
arealloc: Option<unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void>,
) -> c_int;
pub fn ares_version(version: *mut c_int) -> *const u8;
pub fn ares_init(channelptr: *mut *mut Channel) -> c_int;
pub fn ares_init_options(
channelptr: *mut *mut Channel,
options: *mut Options,
Expand Down Expand Up @@ -1025,42 +1019,7 @@ unsafe extern "C" {
pub fn ares_freeaddrinfo(ai: *mut AddrInfo);
}

#[repr(C)]
pub struct ares_socket_functions {
pub socket: Option<unsafe extern "C" fn(c_int, c_int, c_int, *mut c_void) -> ares_socket_t>,
pub close: Option<unsafe extern "C" fn(ares_socket_t, *mut c_void) -> c_int>,
pub connect: Option<
unsafe extern "C" fn(ares_socket_t, *const sockaddr, ares_socklen_t, *mut c_void) -> c_int,
>,
pub recvfrom: Option<
unsafe extern "C" fn(
ares_socket_t,
*mut c_void,
usize,
c_int,
*mut sockaddr,
*mut ares_socklen_t,
*mut c_void,
) -> ares_ssize_t,
>,
pub sendv: Option<
unsafe extern "C" fn(ares_socket_t, *const iovec, c_int, *mut c_void) -> ares_ssize_t,
>,
}

unsafe extern "C" {
pub fn ares_set_socket_functions(
channel: *mut Channel,
funcs: *const ares_socket_functions,
user_data: *mut c_void,
);
pub fn ares_send(
channel: *mut Channel,
qbuf: *const u8,
qlen: c_int,
callback: ares_callback,
arg: *mut c_void,
);
pub fn ares_query(
channel: *mut Channel,
name: *const c_char,
Expand All @@ -1069,21 +1028,6 @@ unsafe extern "C" {
callback: ares_callback,
arg: *mut c_void,
);
pub fn ares_search(
channel: *mut Channel,
name: *const c_char,
dnsclass: c_int,
type_: c_int,
callback: ares_callback,
arg: *mut c_void,
);
pub fn ares_gethostbyname(
channel: *mut Channel,
name: *const c_char,
family: c_int,
callback: ares_host_callback,
arg: *mut c_void,
);
pub fn ares_gethostbyaddr(
channel: *mut Channel,
addr: *const c_void,
Expand All @@ -1100,45 +1044,12 @@ unsafe extern "C" {
callback: ares_nameinfo_callback,
arg: *mut c_void,
);
// pub fn ares_fds(channel: *mut Channel, read_fds: *mut fd_set, write_fds: *mut fd_set) -> c_int;
pub fn ares_getsock(channel: *mut Channel, socks: *mut ares_socket_t, numsocks: c_int)
-> c_int;
pub fn ares_timeout(
channel: *mut Channel,
maxtv: *mut struct_timeval,
tv: *mut struct_timeval,
) -> *mut struct_timeval;
// pub fn ares_process(channel: *mut Channel, read_fds: *mut fd_set, write_fds: *mut fd_set);
// Opaque handle by exclusive reference + scalars only.
pub safe fn ares_process_fd(
channel: &mut Channel,
read_fd: ares_socket_t,
write_fd: ares_socket_t,
);
pub fn ares_create_query(
name: *const c_char,
dnsclass: c_int,
type_: c_int,
id: c_ushort,
rd: c_int,
buf: *mut *mut u8,
buflen: *mut c_int,
max_udp_size: c_int,
) -> c_int;
pub fn ares_expand_name(
encoded: *const u8,
abuf: *const u8,
alen: c_int,
s: *mut *mut u8,
enclen: *mut c_long,
) -> c_int;
pub fn ares_expand_string(
encoded: *const u8,
abuf: *const u8,
alen: c_int,
s: *mut *mut u8,
enclen: *mut c_long,
) -> c_int;
// Pure read of opaque `!Sync` handle.
pub safe fn ares_queue_active_queries(channel: &Channel) -> usize;
}
Expand Down Expand Up @@ -1362,15 +1273,6 @@ impl AresReply for struct_ares_soa_reply {
}
}

#[repr(C)]
pub struct struct_ares_uri_reply {
pub next: *mut struct_ares_uri_reply,
pub priority: c_ushort,
pub weight: c_ushort,
pub uri: *mut u8,
pub ttl: c_int,
}

pub struct struct_any_reply {
pub a_reply: Option<Box<hostent_with_ttls>>,
pub aaaa_reply: Option<Box<hostent_with_ttls>>,
Expand Down Expand Up @@ -1635,12 +1537,6 @@ unsafe extern "C" {
alen: c_int,
soa_out: *mut *mut struct_ares_soa_reply,
) -> c_int;
pub fn ares_parse_uri_reply(
abuf: *const u8,
alen: c_int,
uri_out: *mut *mut struct_ares_uri_reply,
) -> c_int;
pub fn ares_free_string(str_: *mut c_void);
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;
Expand Down
16 changes: 1 addition & 15 deletions src/cares_sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,12 @@ pub mod c_ares_draft;
/// Winsock typedefs not provided by `libc` on `x86_64-pc-windows-msvc`.
#[cfg(windows)]
pub mod winsock {
use core::ffi::{c_int, c_long};
use core::ffi::c_int;
pub(crate) type socklen_t = c_int; // ws2tcpip.h: `typedef int socklen_t;`
// Same nominal type as `bun_sys::posix::sockaddr*`; sin_addr is `in_addr{s_addr}`
// (vs the previous `[u8;4]`) but the only caller (c_ares.rs `get_sockaddr`)
// takes `&raw mut → cast<c_void>`, so the field's nominal type is transparent.
pub(crate) use bun_libuv_sys::{sockaddr, sockaddr_in, sockaddr_in6};
#[repr(C)]
#[derive(Clone, Copy)]
pub struct timeval {
pub tv_sec: c_long,
pub tv_usec: c_long,
}
/// c-ares' `ares.h` defines its own POSIX-layout `struct iovec { void *iov_base; size_t iov_len; }`
/// on Windows for the `asendv` socket-function callback — it does NOT use `WSABUF`.
#[repr(C)]
#[derive(Clone, Copy)]
pub struct iovec {
pub iov_base: *mut core::ffi::c_void,
pub iov_len: usize,
}
}

/// `c_ares` and `c_ares_draft` resolve to the same module.
Expand Down
2 changes: 0 additions & 2 deletions src/jsc/bindings/BunHttp2CommonStrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ using namespace JSC;
class Http2CommonStrings {

public:
typedef JSC::JSString* (*commonStringInitializer)(Http2CommonStrings*, JSC::JSGlobalObject* globalObject);

HTTP2_COMMON_STRINGS_EACH_NAME(HTTP2_COMMON_STRINGS_ACCESSOR_DEFINITION)

void initialize();
Expand Down
19 changes: 0 additions & 19 deletions src/jsc/bindings/Cookie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,6 @@ ExceptionOr<Ref<Cookie>> Cookie::create(const String& name, const String& value,
return adoptRef(*new Cookie(name, value, domain, path, expires, secure, sameSite, httpOnly, maxAge, partitioned));
}

String Cookie::serialize(JSC::VM& vm, const std::span<const Ref<Cookie>> cookies)
{
if (cookies.empty())
return emptyString();

StringBuilder builder;
bool first = true;

for (const auto& cookie : cookies) {
if (!first)
builder.append("; "_s);

cookie->appendTo(vm, builder);
first = false;
}

return builder.toString();
}

ExceptionOr<Ref<Cookie>> Cookie::parse(StringView cookieString)
{
// RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
Expand Down
2 changes: 0 additions & 2 deletions src/jsc/bindings/Cookie.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class Cookie : public RefCounted<Cookie> {

static ExceptionOr<Ref<Cookie>> parse(StringView cookieString);

static String serialize(JSC::VM& vm, const std::span<const Ref<Cookie>> cookies);

const String& name() const { return m_name; }

const String& value() const { return m_value; }
Expand Down
1 change: 0 additions & 1 deletion src/jsc/bindings/DOMFormData.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class DOMFormData : public RefCounted<DOMFormData>, public ContextDestructionObs
Iterator createIterator(const ScriptExecutionContext* context) { return Iterator { *this }; }

private:
// explicit DOMFormData(ScriptExecutionContext*, const PAL::TextEncoding& = PAL::UTF8Encoding());
explicit DOMFormData(ScriptExecutionContext*);

void set(const String& name, Item&&);
Expand Down
10 changes: 0 additions & 10 deletions src/jsc/bindings/JSBakeResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@

namespace Bun {

static JSC_DECLARE_CUSTOM_GETTER(jsBakeResponsePrototypeGetSymbolFor);
static JSC_DECLARE_CUSTOM_GETTER(jsBakeResponsePrototypeGetType);
static JSC_DECLARE_CUSTOM_GETTER(jsBakeResponsePrototypeGetKey);
static JSC_DECLARE_CUSTOM_GETTER(jsBakeResponsePrototypeGetProps);
static JSC_DECLARE_CUSTOM_GETTER(jsBakeResponsePrototypeGetStore);
static JSC_DECLARE_CUSTOM_GETTER(jsBakeResponsePrototypeGetOwner);
static JSC_DECLARE_CUSTOM_GETTER(jsBakeResponsePrototypeGetDebugInfo);
static JSC_DECLARE_CUSTOM_GETTER(jsBakeResponsePrototypeGetDebugStack);
static JSC_DECLARE_CUSTOM_GETTER(jsBakeResponsePrototypeGetDebugTask);

extern JSC_CALLCONV void* JSC_HOST_CALL_ATTRIBUTES BakeResponseClass__constructForSSR(JSC::JSGlobalObject*, JSC::CallFrame*, int*, JSC::EncodedJSValue);
extern "C" SYSV_ABI JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ResponseClass__constructError(JSC::JSGlobalObject*, JSC::CallFrame*);
extern "C" SYSV_ABI JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ResponseClass__constructJSON(JSC::JSGlobalObject*, JSC::CallFrame*);
Expand Down
23 changes: 0 additions & 23 deletions src/jsc/bindings/JSMockFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,29 +788,6 @@ template<typename Visitor> void JSMockModule::visit(Visitor& visitor)
template void JSMockModule::visit(JSC::AbstractSlotVisitor&);
template void JSMockModule::visit(JSC::SlotVisitor&);

extern Structure* createMockResultStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
JSC::Structure* structure = globalObject->structureCache().emptyObjectStructureForPrototype(
globalObject,
globalObject->objectPrototype(),
2);
JSC::PropertyOffset offset;

structure = structure->addPropertyTransition(
vm,
structure,
vm.propertyNames->type,
0,
offset);

structure = structure->addPropertyTransition(
vm,
structure,
vm.propertyNames->value,
0, offset);
return structure;
}

static JSValue createMockResult(JSC::VM& vm, Zig::GlobalObject* globalObject, const WTF::String& type, JSC::JSValue value)
{
JSC::Structure* structure = globalObject->mockModule.mockResultStructure.getInitializedOnMainThread(globalObject);
Expand Down
8 changes: 0 additions & 8 deletions src/jsc/bindings/TextEncoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include "TextCodec.h"
#include "TextEncodingRegistry.h"
#include <wtf/NeverDestroyed.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/StringView.h>

Expand Down Expand Up @@ -81,11 +80,4 @@ char16_t TextEncoding::backslashAsCurrencySymbol() const
return shouldShowBackslashAsCurrencySymbolIn(m_name) ? 0x00A5 : '\\';
}

const TextEncoding& UTF8Encoding()
{
static NeverDestroyed<TextEncoding> globalUTF8Encoding("UTF-8"_s);
ASSERT(globalUTF8Encoding.get().isValid());
return globalUTF8Encoding;
}

} // namespace PAL
2 changes: 0 additions & 2 deletions src/jsc/bindings/TextEncoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class TextEncoding : public WTF::URLTextEncoding {
char16_t m_backslashAsCurrencySymbol;
};

PAL_EXPORT const TextEncoding& UTF8Encoding();

inline String TextEncoding::decode(std::span<const uint8_t> characters) const
{
bool ignored;
Expand Down
Loading