llvm/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp

//===-- sanitizer_posix_libcdep.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is shared between AddressSanitizer and ThreadSanitizer
// run-time libraries and implements libc-dependent POSIX-specific functions
// from sanitizer_libc.h.
//===----------------------------------------------------------------------===//

#include "sanitizer_platform.h"

#if SANITIZER_POSIX

#include "sanitizer_common.h"
#include "sanitizer_flags.h"
#include "sanitizer_platform_limits_netbsd.h"
#include "sanitizer_platform_limits_posix.h"
#include "sanitizer_platform_limits_solaris.h"
#include "sanitizer_posix.h"
#include "sanitizer_procmaps.h"

#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

#if SANITIZER_FREEBSD
// The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before
// that, it was never implemented.  So just define it to zero.
#undef MAP_NORESERVE
#define MAP_NORESERVE
#endif

sa_sigaction_t;

namespace __sanitizer {

u32 GetUid() {}

uptr GetThreadSelf() {}

void ReleaseMemoryPagesToOS(uptr beg, uptr end) {}

void SetShadowRegionHugePageMode(uptr addr, uptr size) {}

bool DontDumpShadowMemory(uptr addr, uptr length) {}

static rlim_t getlim(int res) {}

static void setlim(int res, rlim_t lim) {}

void DisableCoreDumperIfNecessary() {}

bool StackSizeIsUnlimited() {}

void SetStackSizeLimitInBytes(uptr limit) {}

bool AddressSpaceIsUnlimited() {}

void SetAddressSpaceUnlimited() {}

void Abort() {}

int Atexit(void (*function)(void)) {}

bool CreateDir(const char *pathname) {}

bool SupportsColoredOutput(fd_t fd) {}

#if !SANITIZER_GO
// TODO(glider): different tools may require different altstack size.
static uptr GetAltStackSize() {}

void SetAlternateSignalStack() {}

void UnsetAlternateSignalStack() {}

static void MaybeInstallSigaction(int signum,
                                  SignalHandlerType handler) {}

void InstallDeadlySignalHandlers(SignalHandlerType handler) {}

bool SignalContext::IsStackOverflow() const {}

#endif  // SANITIZER_GO

bool IsAccessibleMemoryRange(uptr beg, uptr size) {}

void PlatformPrepareForSandboxing(void *args) {}

static bool MmapFixed(uptr fixed_addr, uptr size, int additional_flags,
                      const char *name) {}

bool MmapFixedNoReserve(uptr fixed_addr, uptr size, const char *name) {}

bool MmapFixedSuperNoReserve(uptr fixed_addr, uptr size, const char *name) {}

uptr ReservedAddressRange::Init(uptr size, const char *name, uptr fixed_addr) {}

// Uses fixed_addr for now.
// Will use offset instead once we've implemented this function for real.
uptr ReservedAddressRange::Map(uptr fixed_addr, uptr size, const char *name) {}

uptr ReservedAddressRange::MapOrDie(uptr fixed_addr, uptr size,
                                    const char *name) {}

void ReservedAddressRange::Unmap(uptr addr, uptr size) {}

void *MmapFixedNoAccess(uptr fixed_addr, uptr size, const char *name) {}

void *MmapNoAccess(uptr size) {}

// This function is defined elsewhere if we intercepted pthread_attr_getstack.
extern "C" {
SANITIZER_WEAK_ATTRIBUTE int
real_pthread_attr_getstack(void *attr, void **addr, size_t *size);
} // extern "C"

int internal_pthread_attr_getstack(void *attr, void **addr, uptr *size) {}

#if !SANITIZER_GO
void AdjustStackSize(void *attr_) {}
#endif // !SANITIZER_GO

pid_t StartSubprocess(const char *program, const char *const argv[],
                      const char *const envp[], fd_t stdin_fd, fd_t stdout_fd,
                      fd_t stderr_fd) {}

bool IsProcessRunning(pid_t pid) {}

int WaitForProcess(pid_t pid) {}

bool IsStateDetached(int state) {}

} // namespace __sanitizer

#endif // SANITIZER_POSIX