# This optional file is used to exclude entrypoints/headers for specific targets.

# Check if sys/random.h is available. If it isn't that implies we're on an older
# version of linux, so we probably also don't have the statx syscall.
try_compile(
  has_sys_random
  ${CMAKE_CURRENT_BINARY_DIR}
  SOURCES ${LIBC_SOURCE_DIR}/cmake/modules/system_features/check_sys_random.cpp
)

if(NOT has_sys_random)
  list(APPEND TARGET_LLVMLIBC_REMOVED_ENTRYPOINTS
    libc.src.sys.stat.stat
  )
  # If we're doing a fullbuild we provide the random header ourselves.
  if(NOT LLVM_LIBC_FULL_BUILD)
    list(APPEND TARGET_LLVMLIBC_REMOVED_ENTRYPOINTS
      libc.src.sys.random.getrandom
    )
  endif()
endif()

include(CheckSymbolExists)
check_symbol_exists(SYS_faccessat2 "sys/syscall.h" HAVE_SYS_FACCESSAT2)
if(NOT HAVE_SYS_FACCESSAT2)
  message(VERBOSE "unistd.faccessat excluded from build, faccessat2 syscall is not available on the system")
  list(APPEND TARGET_LLVMLIBC_REMOVED_ENTRYPOINTS
    libc.src.unistd.faccessat
  )
endif()
