--- ../libdatadog-37d17ee71ae396782242d45e1b31af2887bbbbd3/libdd-common/src/threading.rs.orig 2026-05-07 19:55:05 UTC +++ ../libdatadog-37d17ee71ae396782242d45e1b31af2887bbbbd3/libdd-common/src/threading.rs @@ -2,6 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 /// Returns a numeric identifier for the current OS thread. +#[cfg(target_os = "freebsd")] +pub fn get_current_thread_id() -> i64 { + // SAFETY: pthread_getthreadid_np is safe to call from any thread + // and returns the thread ID of the calling thread. + unsafe { + libc::pthread_getthreadid_np() as i64 + } +} + +/// Returns a numeric identifier for the current OS thread. #[cfg(target_os = "linux")] pub fn get_current_thread_id() -> i64 { // SAFETY: syscall(SYS_gettid) has no preconditions for current thread. @@ -32,5 +42,5 @@ pub fn get_current_thread_id() -> i64 { } /// Returns a numeric identifier for the current OS thread. -#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))] +#[cfg(not(any(target_os = "freebsd", target_os = "linux", target_os = "macos", target_os = "windows")))] compile_error!("libdd_common::threading::get_current_thread_id is unsupported on this platform"); --- ../libdatadog-37d17ee71ae396782242d45e1b31af2887bbbbd3/libdd-common/src/unix_utils/fork.rs.orig 2026-05-07 19:55:05 UTC +++ ../libdatadog-37d17ee71ae396782242d45e1b31af2887bbbbd3/libdd-common/src/unix_utils/fork.rs @@ -1,7 +1,7 @@ // Copyright 2025-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -#[cfg(target_os = "macos")] +#[cfg(any(target_os = "freebsd", target_os = "macos"))] pub fn alt_fork() -> i32 { // There is a lower-level `__fork()` function in macOS, and we can call it from Rust, but the // runtime is much stricter about which operations (e.g., no malloc) are allowed in the child. --- ../libdatadog-37d17ee71ae396782242d45e1b31af2887bbbbd3/libdd-library-config/src/lib.rs.orig 2026-05-07 19:55:05 UTC +++ ../libdatadog-37d17ee71ae396782242d45e1b31af2887bbbbd3/libdd-library-config/src/lib.rs @@ -409,14 +409,19 @@ pub enum Target { } pub enum Target { + FreeBSD, Linux, Macos, Windows, } impl Target { - #[cfg(any(target_os = "linux", target_os = "macos", windows))] + #[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "macos", windows))] const fn current() -> Self { + #[cfg(target_os = "freebsd")] + { + Self::FreeBSD + } #[cfg(target_os = "linux")] { Self::Linux @@ -466,16 +471,17 @@ impl Configurator { } impl Configurator { - #[cfg(any(target_os = "linux", target_os = "macos", windows))] + #[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "macos", windows))] pub const FLEET_STABLE_CONFIGURATION_PATH: &'static str = Self::fleet_stable_configuration_path(Target::current()); - #[cfg(any(target_os = "linux", target_os = "macos", windows))] + #[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "macos", windows))] pub const LOCAL_STABLE_CONFIGURATION_PATH: &'static str = Self::local_stable_configuration_path(Target::current()); pub const fn local_stable_configuration_path(target: Target) -> &'static str { match target { + Target::FreeBSD => "%%LOCALBASE%%/etc/datadog-agent/application_monitoring.yaml", Target::Linux => "/etc/datadog-agent/application_monitoring.yaml", Target::Macos => "/opt/datadog-agent/etc/application_monitoring.yaml", Target::Windows => "C:\\ProgramData\\Datadog\\application_monitoring.yaml", @@ -484,6 +490,7 @@ impl Configurator { pub const fn fleet_stable_configuration_path(target: Target) -> &'static str { match target { + Target::FreeBSD => "%%LOCALBASE%%/etc/datadog-agent/managed/datadog-agent/stable/application_monitoring.yaml", Target::Linux => "/etc/datadog-agent/managed/datadog-agent/stable/application_monitoring.yaml", Target::Macos => "/opt/datadog-agent/etc/stable/application_monitoring.yaml", Target::Windows => "C:\\ProgramData\\Datadog\\managed\\datadog-agent\\stable\\application_monitoring.yaml",