folly/folly/detail/BUCK

load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")

oncall("fbcode_entropy_wardens_folly")

cpp_library(
    name = "async_trace",
    srcs = ["AsyncTrace.cpp"],
    headers = ["AsyncTrace.h"],
    deps = [
        "//folly:portability",
    ],
    exported_deps = [
        "//folly:optional",
    ],
)

cpp_library(
    name = "atomic_hash_utils",
    headers = ["AtomicHashUtils.h"],
    exported_deps = [
        "//folly/portability:asm",
    ],
)

cpp_library(
    name = "atomic_unordered_map_utils",
    headers = ["AtomicUnorderedMapUtils.h"],
    exported_deps = [
        "//folly:exception",
        "//folly/portability:sys_mman",
        "//folly/portability:unistd",
    ],
)

cpp_library(
    name = "discriminated_ptr_detail",
    headers = ["DiscriminatedPtrDetail.h"],
    exported_deps = [
        "//folly/functional:invoke",
    ],
)

cpp_library(
    name = "file_util_detail",
    srcs = ["FileUtilDetail.cpp"],
    headers = ["FileUtilDetail.h"],
    deps = [
        "//folly/portability:config",
    ],
    exported_deps = [
        "//folly/portability:sys_types",
    ],
)

cpp_library(
    name = "file_util_vector_detail",
    headers = ["FileUtilVectorDetail.h"],
    exported_deps = [
        ":file_util_detail",
        "//folly/portability:sys_uio",
        "//folly/portability:unistd",
    ],
)

cpp_library(
    name = "fingerprint_polynomial",
    headers = ["FingerprintPolynomial.h"],
)

cpp_library(
    name = "futex",
    srcs = ["Futex.cpp"],
    headers = [
        "Futex.h",
        "Futex-inl.h",
    ],
    deps = [
        "//folly:scope_guard",
        "//folly/hash:hash",
        "//folly/portability:sys_syscall",
    ],
    exported_deps = [
        "//folly/portability:unistd",
        "//folly/synchronization:parking_lot",
    ],
)

cpp_library(
    name = "group_varint_detail",
    headers = ["GroupVarintDetail.h"],
)

cpp_library(
    name = "ip_address",
    srcs = ["IPAddress.cpp"],
    headers = ["IPAddress.h"],
    deps = [
        "//folly/portability:fmt_compile",
    ],
    exported_deps = [
        "//folly/portability:sockets",
    ],
)

cpp_library(
    name = "ip_address_source",
    headers = ["IPAddressSource.h"],
    exported_deps = [
        "fbsource//third-party/fmt:fmt",
        ":ip_address",
    ],
    exported_external_deps = [
        "glog",
    ],
)

cpp_library(
    name = "iterators",
    headers = ["Iterators.h"],
)

cpp_library(
    name = "memory_idler",
    srcs = ["MemoryIdler.cpp"],
    headers = ["MemoryIdler.h"],
    deps = [
        "//folly:glog",
        "//folly:portability",
        "//folly:scope_guard",
        "//folly/concurrency:cache_locality",
        "//folly/memory:mallctl_helper",
        "//folly/memory:malloc",
        "//folly/portability:gflags",
        "//folly/portability:pthread",
        "//folly/portability:sys_mman",
        "//folly/portability:unistd",
        "//folly/system:pid",
    ],
    exported_deps = [
        ":futex",
        "//folly/hash:hash",
        "//folly/synchronization:atomic_struct",
        "//folly/system:thread_id",
    ],
)

cpp_library(
    name = "perf_scoped",
    srcs = ["PerfScoped.cpp"],
    headers = ["PerfScoped.h"],
    # folly subprocess is not supported on windows
    os_deps = [
        (
            "linux",
            ["//folly:subprocess"],
        ),
    ],
    deps = [
        "//folly:conv",
        "//folly/system:pid",
        "//folly/testing:test_util",
    ],
)

cpp_library(
    name = "mpmc_pipeline_detail",
    headers = ["MPMCPipelineDetail.h"],
    exported_deps = [
        "//folly:mpmc_queue",
    ],
)

cpp_library(
    name = "poly_detail",
    headers = ["PolyDetail.h"],
    exported_deps = [
        ":typelist",
        "//folly:poly_exception",
        "//folly:portability",
        "//folly:traits",
        "//folly:utility",
        "//folly/functional:invoke",
        "//folly/lang:exception",
        "//folly/lang:static_const",
    ],
)

cpp_library(
    name = "range_common",
    srcs = ["RangeCommon.cpp"],
    headers = ["RangeCommon.h"],
    undefined_symbols = True,  # TODO(T23121628): fix deps and remove
    deps = [
        "//folly/container:sparse_byte_set",
    ],
    exported_deps = [
        "//folly:likely",
    ],
)

cpp_library(
    name = "range_sse42",
    srcs = ["RangeSse42.cpp"],
    headers = ["RangeSse42.h"],
    undefined_symbols = True,  # TODO(T23121628): fix deps and remove
    deps = [
        ":sse",
        "//folly:likely",
        "//folly:portability",
    ],
    exported_deps = [
        ":range_common",
    ],
)

cpp_library(
    name = "singleton",
    headers = ["Singleton.h"],
    exported_deps = [
        "//folly:traits",
    ],
)

cpp_library(
    name = "slow_fingerprint",
    headers = ["SlowFingerprint.h"],
    exported_deps = [
        ":fingerprint_polynomial",
        "//folly:fingerprint",
        "//folly:range",
    ],
)

cpp_library(
    name = "sse",
    srcs = ["Sse.cpp"],
    headers = ["Sse.h"],
    exported_deps = [
        "//folly:portability",
    ],
)

cpp_library(
    name = "simple_simd_string_utils",
    srcs = ["SimpleSimdStringUtils.cpp"],
    headers = [
        "SimpleSimdStringUtils.h",
        "SimpleSimdStringUtilsImpl.h",
    ],
    exported_deps = [
        "//folly:range",
        "//folly/algorithm/simd/detail:simd_any_of",
        "//folly/algorithm/simd/detail:simd_char_platform",
    ],
)

cpp_library(
    name = "split_string_simd",
    srcs = ["SplitStringSimd.cpp"],
    headers = [
        "SplitStringSimd.h",
        "SplitStringSimdImpl.h",
    ],
    deps = [
        "//folly:fbstring",
        "//folly:fbvector",
        "//folly:small_vector",
    ],
    exported_deps = [
        "//folly:portability",
        "//folly:range",
        "//folly/algorithm/simd/detail:simd_char_platform",
        "//folly/algorithm/simd/detail:simd_for_each",
        "//folly/lang:bits",
    ],
)

cpp_library(
    name = "socket_fast_open",
    srcs = ["SocketFastOpen.cpp"],
    headers = ["SocketFastOpen.h"],
    exported_deps = [
        "//folly/net:network_socket",
        "//folly/portability:sockets",
    ],
)

cpp_library(
    name = "static_singleton_manager",
    srcs = ["StaticSingletonManager.cpp"],
    headers = ["StaticSingletonManager.h"],
    deps = [
        "//folly/memory:reentrant_allocator",
    ],
    exported_deps = [
        ":singleton",
        "//folly:c_portability",
        "//folly:indestructible",
        "//folly:likely",
        "//folly:utility",
        "//folly/lang:thunk",
        "//folly/lang:type_info",
    ],
)

cpp_library(
    name = "thread_local_detail",
    srcs = ["ThreadLocalDetail.cpp"],
    headers = ["ThreadLocalDetail.h"],
    deps = [
        ":thread_local_globals",
        "//folly/lang:hint",
        "//folly/memory:sanitize_leak",
        "//folly/synchronization:call_once",
    ],
    exported_deps = [
        ":static_singleton_manager",
        ":unique_instance",
        "//folly:exception",
        "//folly:function",
        "//folly:map_util",
        "//folly:portability",
        "//folly:scope_guard",
        "//folly:shared_mutex",
        "//folly:synchronized",
        "//folly/concurrency/container:atomic_grow_array",
        "//folly/container:foreach",
        "//folly/lang:exception",
        "//folly/memory:malloc",
        "//folly/portability:pthread",
        "//folly/synchronization:micro_spin_lock",
        "//folly/synchronization:relaxed_atomic",
        "//folly/system:at_fork",
        "//folly/system:thread_id",
    ],
    exported_external_deps = [
        "glog",
    ],
)

cpp_library(
    name = "thread_local_globals",
    srcs = ["thread_local_globals.cpp"],
    headers = ["thread_local_globals.h"],
    deps = [
        ":static_singleton_manager",
        "//folly/lang:exception",
        "//folly/portability:pthread",
    ],
)

cpp_library(
    name = "turn_sequencer",
    headers = ["TurnSequencer.h"],
    exported_deps = [
        ":futex",
        "//folly:portability",
        "//folly/chrono:hardware",
        "//folly/portability:asm",
        "//folly/portability:unistd",
    ],
    exported_external_deps = [
        "glog",
    ],
)

cpp_library(
    name = "typelist",
    headers = ["TypeList.h"],
    exported_deps = [
        "//folly:traits",
        "//folly:utility",
    ],
)

cpp_library(
    name = "unique_instance",
    srcs = ["UniqueInstance.cpp"],
    headers = ["UniqueInstance.h"],
    deps = [
        "//folly:demangle",
        "//folly/lang:exception",
    ],
    exported_deps = [
        ":static_singleton_manager",
        "//folly:cpp_attributes",
    ],
)

cpp_library(
    name = "traponavx512",
    srcs = ["TrapOnAvx512.cpp"],
    headers = ["TrapOnAvx512.h"],
    arch_preprocessor_flags = {
        "x86_64": [
            "-msse4.2",
            "-mavx512f",
            "-mavx512vl",
        ],
    },
    deps = [
        "//folly:portability",
    ],
)